aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-19 22:09:49 +0100
committerMattias Andrée <maandree@kth.se>2022-02-19 22:09:49 +0100
commitc18cacf683d1b5ae6256d71fb5076cae02fa9daf (patch)
tree02cee1c9472d9131a52a8a0705da97c74ca4a008 /Makefile
parentFirst commit (diff)
downloadlibparsepsf-c18cacf683d1b5ae6256d71fb5076cae02fa9daf.tar.gz
libparsepsf-c18cacf683d1b5ae6256d71fb5076cae02fa9daf.tar.bz2
libparsepsf-c18cacf683d1b5ae6256d71fb5076cae02fa9daf.tar.xz
Improve makefile
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 34 insertions, 11 deletions
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