summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile29
-rw-r--r--linux.mk5
-rw-r--r--macos.mk5
4 files changed, 35 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 072827c..0ee6f2e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@
*.gcno
*.gcda
*.test
+*.dylib
diff --git a/Makefile b/Makefile
index d5db58a..f17e587 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,16 @@
CONFIGFILE = config.mk
include $(CONFIGFILE)
+OS = linux
+# linux = Linux
+# macos = Mac OS
+include $(OS).mk
+
+LIB_MAJOR = 1
+LIB_MINOR = 0
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+
+
LANG =\
swedish
@@ -11,6 +21,9 @@ OBJ =\
libnumtext_remove_separators.o\
$(LANG:=.o)
+LOBJ =\
+ $(OBJ:.o=.lo)
+
HDR =\
libnumtext.h\
common.h
@@ -22,9 +35,9 @@ TEST_OBJ =\
$(TEST:=.o)
-all: libnumtext.a
+all: libnumtext.a libnumtext.$(LIBEXT)
$(OBJ): $(HDR)
-$(OBJ:.o=.lo): $(HDR)
+$(LOBJ): $(HDR)
$(TEST_OBJ): libnumtext.h
$(TEST): libnumtext.a
@@ -41,6 +54,9 @@ libnumtext.a: $(OBJ)
@rm -f -- $@
$(AR) rc $@ $(OBJ)
+libnumtext.$(LIBEXT): $(LOBJ)
+ $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)
+
check: $(TEST)
@set -e &&\
for t in $(TEST); do\
@@ -48,18 +64,21 @@ check: $(TEST)
"./$$t" || exit 1;\
done
-install: libnumtext.a
+install: libnumtext.a libnumtext.$(LIBEXT)
mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
cp -- libnumtext.a "$(DESTDIR)$(PREFIX)/lib/"
+ cp -- libnumtext.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libnumtext.$(LIBMINOREXT)"
+ ln -sf -- libnumtext.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libnumtext.$(LIBMAJOREXT)"
+ ln -sf -- libnumtext.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libnumtext.$(LIBEXT)"
cp -- libnumtext.h "$(DESTDIR)$(PREFIX)/include/"
uninstall:
- -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libnumtext.a"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libnumtext".*
-rm -f -- "$(DESTDIR)$(PREFIX)/include/libnumtext.h"
clean:
- -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda *.test
+ -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda *.test *.dylib
.SUFFIXES:
.SUFFIXES: .lo .o .c .test .test.o
diff --git a/linux.mk b/linux.mk
new file mode 100644
index 0000000..2659516
--- /dev/null
+++ b/linux.mk
@@ -0,0 +1,5 @@
+LIBEXT = so
+LIBFLAGS = -shared -Wl,-soname,libnumtext.$(LIBEXT).$(LIB_MAJOR)
+
+LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR)
+LIBMINOREXT = $(LIBEXT).$(LIB_VERSION)
diff --git a/macos.mk b/macos.mk
new file mode 100644
index 0000000..b475197
--- /dev/null
+++ b/macos.mk
@@ -0,0 +1,5 @@
+LIBEXT = dylib
+LIBFLAGS = -dynamiclib
+
+LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT)
+LIBMINOREXT = $(LIB_VERSION).$(LIBEXT)