From b73b10c4659994ec48f72f639bd308768764f2e8 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 8 Sep 2021 20:54:25 +0200 Subject: Add dynamic library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d5db58a..f17e587 100644 --- a/Makefile +++ b/Makefile @@ -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 -- cgit v1.2.3-70-g09d2