From 9c68f09356974511f622207d7cc96b20a175fcf2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 17 Apr 2021 13:05:22 +0200 Subject: Add dynamically linked version of library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0b424bd..490ce9a 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,24 @@ .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 + -all: libparser.a libparser-generate calc-example/calc + +all: libparser.a libparser.$(LIBEXT) libparser-generate calc-example/calc libparser.o: libparser.c libparser.h +libparser.lo: libparser.c libparser.h calc-example/calc-syntax.o: calc-example/calc-syntax.c libparser.h .c.o: @@ -21,28 +34,37 @@ libparser.a: libparser.o $(AR) rc $@ libparser.o $(AR) -s $@ +libparser.$(LIBEXT): libparser.lo + $(CC) $(LIBFLAGS) -o $@ libparser.lo $(LDFLAGS) + calc-example/calc: calc-example/calc.o calc-example/calc-syntax.o libparser.a $(CC) -o $@ calc-example/calc.o calc-example/calc-syntax.o libparser.a $(LDFLAGS) calc-example/calc-syntax.c: libparser-generate calc-example/calc.syntax ./libparser-generate _expr < calc-example/calc.syntax > $@ -install: libparser.a libparser-generate +install: libparser.a libparser.$(LIBEXT) libparser-generate mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" mkdir -p -- "$(DESTDIR)$(PREFIX)/include" cp -- libparser-generate "$(DESTDIR)$(PREFIX)/bin" cp -- libparser.a "$(DESTDIR)$(PREFIX)/lib" + cp -- libparser.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBMINOREXT)" + ln -sf -- libparser.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBMAJOREXT)" + ln -sf -- libparser.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBEXT)" cp -- libparser.h "$(DESTDIR)$(PREFIX)/include" uninstall: -rm -f -- "$(DESTDIR)$(PREFIX)/bin/libparser-generate" -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparser.a" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBMAJOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBMINOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBEXT)" -rm -f -- "$(DESTDIR)$(PREFIX)/include/libparser.h" clean: - -rm -f -- *.o *.lo *.a *.so *.su *-example/*.o *-example/*.su *-example/*-syntax.c libparser-generate - -rm -f -- calc-example/calc + -rm -f -- *.o *.lo *.a *.so *.su *.dylib *.dll *-example/*.o *-example/*.su *-example/*-syntax.c + -rm -f -- libparser-generate calc-example/calc .SUFFIXES: .SUFFIXES: .c .o .lo -- cgit v1.2.3-70-g09d2