aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile45
-rw-r--r--mk/linux.mk7
-rw-r--r--mk/macos.mk7
-rw-r--r--mk/windows.mk7
4 files changed, 59 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 2c7879e..5e43f74 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,18 @@
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 =\
libskrift_add_180_degree_rotation.o\
libskrift_add_270_degree_rotation.o\
@@ -48,34 +60,53 @@ HDR =\
srgb-gamma.h\
$(LIB_HDR)
-all: libskrift.a demo
-$(OBJ): $(@:.o=.c) $(HDR)
+LOBJ = $(OBJ:.o=.lo)
+
+
+all: libskrift.a libskrift.$(LIBEXT) demo
+$(OBJ): $(HDR)
+$(LOBJ): $(HDR)
demo.o: demo.c $(LIB_HDR)
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+.c.lo:
+ $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+libskrift.$(LIBEXT): $(LOBJ)
+ $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)
+
libskrift.a: $(OBJ)
+ -rm -f -- $@
$(AR) rc $@ $(OBJ)
$(AR) ts $@ > /dev/null
-.c.o:
- $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
-
demo: demo.o libskrift.a
$(CC) -o $@ $@.o libskrift.a $(LDFLAGS)
-install: libskrift.a
+install: libskrift.a libskrift.$(LIBEXT)
mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
cp -- libskrift.a "$(DESTDIR)$(PREFIX)/lib"
+ cp -- libskrift.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMINOREXT)"
+ $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMINOREXT)"
+ ln -sf -- "libskrift.$(LIBMINOREXT)" "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMAJOREXT)"
+ ln -sf -- "libskrift.$(LIBMAJOREXT)" "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBEXT)"
+ cp -- libskrift.a "$(DESTDIR)$(PREFIX)/lib"
cp -- libskrift.h "$(DESTDIR)$(PREFIX)/include"
uninstall:
-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.a"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBEXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMAJOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMINOREXT)"
-rm -f -- "$(DESTDIR)$(PREFIX)/include/libskrift.h"
clean:
-rm -f -- *.o *.lo *.su *.a *.so *.so.* demo
.SUFFIXES:
-.SUFFIXES: .c .o
+.SUFFIXES: .c .o .lo
.PHONY: all install uninstall clean
diff --git a/mk/linux.mk b/mk/linux.mk
new file mode 100644
index 0000000..10a9461
--- /dev/null
+++ b/mk/linux.mk
@@ -0,0 +1,7 @@
+LIBEXT = so
+LIBFLAGS = -shared -Wl,-soname,libskrift.$(LIBEXT).$(LIB_MAJOR)
+
+LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR)
+LIBMINOREXT = $(LIBEXT).$(LIB_MAJOR).$(LIB_MINOR)
+
+FIX_INSTALL_NAME = :
diff --git a/mk/macos.mk b/mk/macos.mk
new file mode 100644
index 0000000..d10e427
--- /dev/null
+++ b/mk/macos.mk
@@ -0,0 +1,7 @@
+LIBEXT = dylib
+LIBFLAGS = -dynamiclib -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION)
+
+LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT)
+LIBMINOREXT = $(LIB_MAJOR).$(LIB_MINOR).$(LIBEXT)
+
+FIX_INSTALL_NAME = install_name_tool -id "$(PREFIX)/lib/libskrift.$(LIBMAJOREXT)"
diff --git a/mk/windows.mk b/mk/windows.mk
new file mode 100644
index 0000000..304b6be
--- /dev/null
+++ b/mk/windows.mk
@@ -0,0 +1,7 @@
+LIBEXT = dll
+LIBFLAGS = -shared
+
+LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT)
+LIBMINOREXT = $(LIB_MAJOR).$(LIB_MINOR).$(LIBEXT)
+
+FIX_INSTALL_NAME = :