diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-17 13:05:22 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-17 13:05:22 +0200 |
commit | 9c68f09356974511f622207d7cc96b20a175fcf2 (patch) | |
tree | aecf6e586eba4362d7dd726398c78a6a789911b9 /Makefile | |
parent | Makefile: add install and uninstall rules (diff) | |
download | libparser-9c68f09356974511f622207d7cc96b20a175fcf2.tar.gz libparser-9c68f09356974511f622207d7cc96b20a175fcf2.tar.bz2 libparser-9c68f09356974511f622207d7cc96b20a175fcf2.tar.xz |
Add dynamically linked version of library
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -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 |