aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile45
-rw-r--r--config.mk6
-rw-r--r--mk/linux.mk7
-rw-r--r--mk/macos.mk7
-rw-r--r--mk/windows.mk7
5 files changed, 58 insertions, 14 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
diff --git a/config.mk b/config.mk
index 941bc29..166cd0c 100644
--- a/config.mk
+++ b/config.mk
@@ -1,8 +1,8 @@
PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
+CC = c99
+
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
-CFLAGS = -std=c99 -Wall
+CFLAGS = -Wall
LDFLAGS = -lgrapheme
-
-CC = cc
diff --git a/mk/linux.mk b/mk/linux.mk
new file mode 100644
index 0000000..038120b
--- /dev/null
+++ b/mk/linux.mk
@@ -0,0 +1,7 @@
+LIBEXT = so
+LIBFLAGS = -shared -Wl,-soname,libparsepsf.$(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..18d9433
--- /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/libparsepsf.$(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 = :