diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-03 11:06:36 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-03 11:06:36 +0200 |
commit | cfc081f9c4f5f538145cbd93f98f714d0be1dad0 (patch) | |
tree | aa9c213cb875568d11194c10f92849605d2d3c0d /Makefile | |
parent | Use strcmpnul (diff) | |
download | contacts-cfc081f9c4f5f538145cbd93f98f714d0be1dad0.tar.gz contacts-cfc081f9c4f5f538145cbd93f98f714d0be1dad0.tar.bz2 contacts-cfc081f9c4f5f538145cbd93f98f714d0be1dad0.tar.xz |
m + Add multicall binary
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 47 |
1 files changed, 39 insertions, 8 deletions
@@ -32,18 +32,28 @@ HDR =\ common.h OBJ = $(BIN:=.o) +BOBJ = $(BIN:=.bo) -all: $(BIN) +all: $(BIN) contacts $(OBJ): $(@:.o=.c) $(HDR) - -libcontacts.a: $(OBJ) - $(AR) rc $@ $(OBJ) - $(AR) -s $@ +$(BOBJ): $(@:.bo=.c) $(HDR) .c.o: $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) +.c.bo: + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -Dmain="$$(printf '%s\n' $*_main | tr - _)" -DMULTICALL_BINARY + +contacts: contacts.o $(BOBJ) + $(CC) -o $@ $@.o $(BOBJ) $(LDFLAGS) + +contacts.c: contacts.c.in Makefile + printf '#define LIST_COMMANDS' > $@ + printf '\\\n\tX(%s)' $(BIN) | tr - _ >> $@ + printf '\n\n' >> $@ + cat contacts.c.in >> $@ + find-contact-by-email: find-contact-by-email.o $(CC) -o $@ $@.o $(LDFLAGS) @@ -120,13 +130,34 @@ install: $(BIN) mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" cp -- $(BIN) "$(DESTDIR)$(PREFIX)/bin/" +install-mcb: contacts + mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" + set -- $(BIN) &&\ + cp -- "$$1" "$(DESTDIR)$(PREFIX)/bin/$$1" &&\ + linkto="$$1" &&\ + shift 1 &&\ + cd -- "$(DESTDIR)$(PREFIX)/bin/" &&\ + for f; do\ + ln -- "$$linkto" "$$f" || exit 1;\ + done + +install-mcb-symlinks: contacts + mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" + mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" + cp -- contacts "$(DESTDIR)$(PREFIX)/lib/" + cd -- "$(DESTDIR)$(PREFIX)/bin/" &&\ + for f in $(BIN); do\ + ln -s -- ../lib/contacts "$$f" || exit 1;\ + done + uninstall: -cd -- "$(DESTDIR)$(PREFIX)/bin" && rm -f -- $(BIN) + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/contacts" clean: - -rm -f -- *.o *.a *.lo *.so *.su $(BIN) + -rm -f -- *.o *.a *.lo *.so *.bo *.su $(BIN) contacts contacts.c .SUFFIXES: -.SUFFIXES: .c .o +.SUFFIXES: .c .o .bo -.PHONY: all install uninstall clean +.PHONY: all install install-mcb install-mcb-symlinks uninstall clean |