From c18cacf683d1b5ae6256d71fb5076cae02fa9daf Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 19 Feb 2022 22:09:49 +0100 Subject: Improve makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 61b281b..80d433c 100644 --- a/Makefile +++ b/Makefile @@ -3,26 +3,42 @@ CONFIGFILE = config.mk include $(CONFIGFILE) +OS = linux +# Linux: linux +# Mac OS: macos +# Windows: windows +include mk/$(OS).mk + +LIB_MAJOR = 1 +LIB_MINOR = 0 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) + + OBJ =\ libparsepsf.o -LIB_HDR =\ +HDR =\ libparsepsf.h -HDR =\ - $(LIB_HDR) -all: libparsepsf.a demo -$(OBJ): $(@:.o=.c) $(HDR) -libparsepsf.o: libparsepsf.c $(LIB_HDR) +all: libparsepsf.a libparsepsf.$(LIBEXT) demo +$(OBJ): $(HDR) +$(LOBJ): $(HDR) + +.c.o: + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + +.c.lo: + $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + +libparsepsf.$(LIBEXT): $(LOBJ) + $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS) libparsepsf.a: $(OBJ) + -rm -f -- $@ $(AR) rc $@ $(OBJ) $(AR) ts $@ > /dev/null -.c.o: - $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) - demo: demo.o libparsepsf.a $(CC) -o $@ $@.o libparsepsf.a $(LDFLAGS) @@ -30,16 +46,23 @@ install: libparsepsf.a mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" mkdir -p -- "$(DESTDIR)$(PREFIX)/include" cp -- libparsepsf.a "$(DESTDIR)$(PREFIX)/lib" + cp -- libparsepsf.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libparsepsf.$(LIBMINOREXT)" + $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libparsepsf.$(LIBMINOREXT)" + ln -sf -- "libsha1.$(LIBMINOREXT)" "$(DESTDIR)$(PREFIX)/lib/libparsepsf.$(LIBMAJOREXT)" + ln -sf -- "libsha1.$(LIBMAJOREXT)" "$(DESTDIR)$(PREFIX)/lib/libparsepsf.$(LIBEXT)" cp -- libparsepsf.h "$(DESTDIR)$(PREFIX)/include" uninstall: -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsepsf.a" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsepsf.$(LIBEXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsepsf.$(LIBMAJOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsepsf.$(LIBMINOREXT)" -rm -f -- "$(DESTDIR)$(PREFIX)/include/libparsepsf.h" clean: -rm -f -- *.o *.lo *.su *.a *.so *.so.* demo .SUFFIXES: -.SUFFIXES: .c .o +.SUFFIXES: .lo .o .c -.PHONY: all install uninstall clean +.PHONY: all check install uninstall clean -- cgit v1.2.3-70-g09d2