summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-19 22:50:54 +0100
committerMattias Andrée <maandree@kth.se>2022-02-19 22:50:54 +0100
commit8b0df151f0039b238f434ede99b8b7d79619d86c (patch)
treeffd844d914643f5f1fd005153ee1d50d69474137
parentAdd cmpa, bloc, bdat, sbix, and EBSC + minor fix + add language and encoding IDs (diff)
downloadlibparsesfnt-8b0df151f0039b238f434ede99b8b7d79619d86c.tar.gz
libparsesfnt-8b0df151f0039b238f434ede99b8b7d79619d86c.tar.bz2
libparsesfnt-8b0df151f0039b238f434ede99b8b7d79619d86c.tar.xz
Improve makefile
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--Makefile35
-rw-r--r--config.mk4
-rw-r--r--mk/linux.mk7
-rw-r--r--mk/macos.mk7
-rw-r--r--mk/windows.mk7
5 files changed, 56 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index f84b6f2..4c20a08 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 = 0
+LIB_MINOR = 1
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+
+
MODULES =\
head\
bhed\
@@ -41,6 +53,9 @@ HDR =\
libparsesfnt.h\
common.h
+LOBJ = $(OBJ:.o=.lo)
+
+
AR_OBJ = $(OBJ)
# Using "AR_OBJ=libparsesfnt-all.o" can reduce the size of the
# library, however this may affect the size of applications that
@@ -49,9 +64,15 @@ AR_OBJ = $(OBJ)
# MODULES to the parts your application will use; note however
# that 'fpgm' covers both 'fpgm' and 'prep'.
-all: libparsesfnt.a
+SO_LOBJ = $(LOBJ)
+# You may use "SO_LOBJ=libparsesfnt-all.lo".
+
+
+all: libparsesfnt.a libparsesfnt.$(LIBEXT)
$(OBJ): $(@:.o=.c) $(HDR)
+$(LOBJ): $(@:.o=.c) $(HDR)
libparsesfnt-all.o: libparsesfnt-all.c $(HDR)
+libparsesfnt-all.lo: libparsesfnt-all.c $(HDR)
libparsesfnt-all.c: $(OBJ:.o=.c)
cat $(OBJ:.o=.c) > $@
@@ -62,18 +83,28 @@ libparsesfnt-all.c: $(OBJ:.o=.c)
.c.lo:
$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+libparsesfnt.$(LIBEXT): $(SO_LOBJ)
+ $(CC) $(LIBFLAGS) -o $@ $(SO_LOBJ) $(LDFLAGS)
+
libparsesfnt.a: $(AR_OBJ)
@rm -f -- $@
$(AR) rc $@ $(AR_OBJ)
-install: libparsesfnt.a
+install: libparsesfnt.a libparsesfnt.$(LIBEXT)
mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
cp -- libparsesfnt.a "$(DESTDIR)$(PREFIX)/lib/"
+ cp -- libparsesfnt.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.$(LIBMINOREXT)"
+ $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.$(LIBMINOREXT)"
+ ln -sf -- "libparsesfnt.$(LIBMINOREXT)" "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.$(LIBMAJOREXT)"
+ ln -sf -- "libparsesfnt.$(LIBMAJOREXT)" "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.$(LIBEXT)"
cp -- libparsesfnt.h "$(DESTDIR)$(PREFIX)/include/"
uninstall:
-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.a"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.$(LIBEXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.$(LIBMAJOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libparsesfnt.$(LIBMINOREXT)"
-rm -f -- "$(DESTDIR)$(PREFIX)/include/libparsesfnt.h"
clean:
diff --git a/config.mk b/config.mk
index af85cea..2fa94a8 100644
--- a/config.mk
+++ b/config.mk
@@ -1,8 +1,8 @@
PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
-CC = cc
+CC = c99
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
-CFLAGS = -std=c99 -Wall
+CFLAGS = -Wall
LDFLAGS =
diff --git a/mk/linux.mk b/mk/linux.mk
new file mode 100644
index 0000000..e0b0f8b
--- /dev/null
+++ b/mk/linux.mk
@@ -0,0 +1,7 @@
+LIBEXT = so
+LIBFLAGS = -shared -Wl,-soname,libparsesfnt.$(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..f3aace1
--- /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/libparsesfnt.$(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 = :