summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile77
1 files changed, 54 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 7e38b58..69b6757 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,14 @@
.POSIX:
CONFIGFILE = config.mk
-include $(CONFIGFILE)
-HDR =\
- common.h\
- large.h
+CALLTYPE = multicall-hardlinks
+# multicall-hardlinks = multiple hardlinks of the same multicall binary is installed
+# multicall-symlinks = multiple links to a multicall binary named $(PREFIX)/bin/pdatools are installed
+# singlecall = separate binaries are install for each command
+
-BIN_ =\
+BIN =\
backlight\
clock\
counter\
@@ -15,31 +16,60 @@ BIN_ =\
stopwatch\
timer
-OBJ = $(BIN_:=.o)
-BIN = $(BIN_:=.bin)
-MAN1 = $(BIN_:=.1)
+HDR =\
+ common.h\
+ large.h
+
+OBJ = $(BIN:=.o)
+BOBJ = $(OBJ:.o=.bo)
+MAN1 = $(BIN:=.1)
+
+
+include $(CONFIGFILE)
+include $(CALLTYPE).mk
-all: $(BIN)
$(OBJ): $(@:.o=.c) $(HDR)
-$(BIN): $(@:.bin=.o)
+$(BOBJ): $(@:.bo=.c) $(HDR)
.c.o:
- $(CC) -c -o $@ $< $(CFLAGS)
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+.c.bo:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -Dmain="$$(printf '%s\n' main__$* | tr - _)" -DMULTICALL_BINARY
-.o.bin:
- $(CC) -o $@ $< $(LDFLAGS)
+pdatools: pdatools.o $(BOBJ)
+ $(CC) -o $@ $@.o $(BOBJ) $(LDFLAGS)
+
+pdatools.c: pdatools.c.in Makefile
+ printf '#define LIST_COMMANDS' > $@
+ printf '\\\n\tX(%s)' $(BIN) | tr - _ >> $@
+ printf '\n\n' >> $@
+ cat pdatools.c.in >> $@
large.h: large.sh
./large.sh > $@
-install: $(BIN)
- mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
+backlight: backlight.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
+
+clock: clock.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
+
+counter: counter.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
+
+dice: dice.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
+
+stopwatch: stopwatch.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
+
+timer: timer.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
+
+install-common:
mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
- for f in $(BIN_); do\
- ! test -d "$(DESTDIR)$(PREFIX)/bin/$$f" &&\
- cp -- "$$f.bin" "$(DESTDIR)$(PREFIX)/bin/$$f" || exit 1;\
- done
cp -- $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"
post-install:
@@ -48,12 +78,13 @@ post-install:
uninstall:
-cd -- "$(DESTDIR)$(PREFIX)/bin" && rm -f -- $(BIN_)
- -cd -- "$(DESTDIR)$(MANPREFIX)/man1" && rm -f $(MAN1)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man1" && rm -f -- $(MAN1)
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/pdatools"
clean:
- -rm -rf -- *.o *.su *.bin large.h
+ -rm -rf -- *.o *.a *.lo *.so *.bo *.su $(BIN) large.h pdatools pdatools.c
.SUFFIXES:
-.SUFFIXES: .bin .o .c
+.SUFFIXES: .o .c .bo
-.PHONY: all install post-install uninstall clean
+.PHONY: all install install-common post-install uninstall clean