diff options
author | Mattias Andrée <maandree@kth.se> | 2021-09-08 20:54:25 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-09-08 20:54:25 +0200 |
commit | b73b10c4659994ec48f72f639bd308768764f2e8 (patch) | |
tree | 821dd8669fc881a02b9225623654466ce002361e | |
parent | test: m + test separator removal (diff) | |
download | libnumtext-b73b10c4659994ec48f72f639bd308768764f2e8.tar.gz libnumtext-b73b10c4659994ec48f72f639bd308768764f2e8.tar.bz2 libnumtext-b73b10c4659994ec48f72f639bd308768764f2e8.tar.xz |
Add dynamic library
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | linux.mk | 5 | ||||
-rw-r--r-- | macos.mk | 5 |
4 files changed, 35 insertions, 5 deletions
@@ -11,3 +11,4 @@ *.gcno *.gcda *.test +*.dylib @@ -3,6 +3,16 @@ CONFIGFILE = config.mk include $(CONFIGFILE) +OS = linux +# linux = Linux +# macos = Mac OS +include $(OS).mk + +LIB_MAJOR = 1 +LIB_MINOR = 0 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) + + LANG =\ swedish @@ -11,6 +21,9 @@ OBJ =\ libnumtext_remove_separators.o\ $(LANG:=.o) +LOBJ =\ + $(OBJ:.o=.lo) + HDR =\ libnumtext.h\ common.h @@ -22,9 +35,9 @@ TEST_OBJ =\ $(TEST:=.o) -all: libnumtext.a +all: libnumtext.a libnumtext.$(LIBEXT) $(OBJ): $(HDR) -$(OBJ:.o=.lo): $(HDR) +$(LOBJ): $(HDR) $(TEST_OBJ): libnumtext.h $(TEST): libnumtext.a @@ -41,6 +54,9 @@ libnumtext.a: $(OBJ) @rm -f -- $@ $(AR) rc $@ $(OBJ) +libnumtext.$(LIBEXT): $(LOBJ) + $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS) + check: $(TEST) @set -e &&\ for t in $(TEST); do\ @@ -48,18 +64,21 @@ check: $(TEST) "./$$t" || exit 1;\ done -install: libnumtext.a +install: libnumtext.a libnumtext.$(LIBEXT) mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" mkdir -p -- "$(DESTDIR)$(PREFIX)/include" cp -- libnumtext.a "$(DESTDIR)$(PREFIX)/lib/" + cp -- libnumtext.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libnumtext.$(LIBMINOREXT)" + ln -sf -- libnumtext.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libnumtext.$(LIBMAJOREXT)" + ln -sf -- libnumtext.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libnumtext.$(LIBEXT)" cp -- libnumtext.h "$(DESTDIR)$(PREFIX)/include/" uninstall: - -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libnumtext.a" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libnumtext".* -rm -f -- "$(DESTDIR)$(PREFIX)/include/libnumtext.h" clean: - -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda *.test + -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda *.test *.dylib .SUFFIXES: .SUFFIXES: .lo .o .c .test .test.o diff --git a/linux.mk b/linux.mk new file mode 100644 index 0000000..2659516 --- /dev/null +++ b/linux.mk @@ -0,0 +1,5 @@ +LIBEXT = so +LIBFLAGS = -shared -Wl,-soname,libnumtext.$(LIBEXT).$(LIB_MAJOR) + +LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) +LIBMINOREXT = $(LIBEXT).$(LIB_VERSION) diff --git a/macos.mk b/macos.mk new file mode 100644 index 0000000..b475197 --- /dev/null +++ b/macos.mk @@ -0,0 +1,5 @@ +LIBEXT = dylib +LIBFLAGS = -dynamiclib + +LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) +LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) |