diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-08 16:56:42 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-08 16:56:42 +0200 |
commit | b2da2d6f15e28b755f22bb5557e8c79b3abacd7e (patch) | |
tree | 05ad6f7e0b54a6864a5372353ce9da4ed89ea33e /Makefile | |
parent | libcontacts_save_contact: create directory if missing (diff) | |
download | libcontacts-b2da2d6f15e28b755f22bb5557e8c79b3abacd7e.tar.gz libcontacts-b2da2d6f15e28b755f22bb5557e8c79b3abacd7e.tar.bz2 libcontacts-b2da2d6f15e28b755f22bb5557e8c79b3abacd7e.tar.xz |
Add build of dynamically linked library
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 35 |
1 files changed, 31 insertions, 4 deletions
@@ -1,8 +1,20 @@ .POSIX: +LIB_MAJOR = 1 +LIB_MINOR = 0 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) + + CONFIGFILE = config.mk include $(CONFIGFILE) +OS = linux +# Linux: linux +# Mac OS: macos +# Windows: windows +include mk/$(OS).mk + + OBJ =\ libcontacts_address_destroy.o\ @@ -28,31 +40,46 @@ HDR =\ common.h\ libcontacts.h +LOBJ = $(OBJ:.o=.lo) -all: libcontacts.a + +all: libcontacts.a libcontacts.$(LIBEXT) $(OBJ): $($@:.o=.c) $(HDR) libcontacts.a: $(OBJ) + -rm -f -- $@ $(AR) rc $@ $(OBJ) $(AR) -s $@ +libcontacts.$(LIBEXT): $(LOBJ) + $(CC) $(LIBFLAGS) $(LDFLAGS_METHODS) -o $@ $(LOBJ) $(LDFLAGS) + .c.o: $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -install: libcontacts.a +.c.lo: + $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + +install: libcontacts.a libcontacts.$(LIBEXT) mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" mkdir -p -- "$(DESTDIR)$(PREFIX)/include" cp -- libcontacts.a "$(DESTDIR)$(PREFIX)/lib/" cp -- libcontacts.h "$(DESTDIR)$(PREFIX)/include/" + cp -- libcontacts.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libcontacts.$(LIBMINOREXT)" + ln -sf -- libcontacts.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libcontacts.$(LIBMAJOREXT)" + ln -sf -- libcontacts.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libcontacts.$(LIBEXT)" uninstall: + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcontacts.$(LIBMAJOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcontacts.$(LIBMINOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcontacts.$(LIBEXT)" -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libcontacts.a" -rm -f -- "$(DESTDIR)$(PREFIX)/include/libcontacts.h" clean: - -rm -f -- *.o *.a *.lo *.so *.su + -rm -f -- *.o *.a *.lo *.so *.dylib *.dll *.su .SUFFIXES: -.SUFFIXES: .c .o +.SUFFIXES: .c .o .lo .PHONY: all install uninstall clean |