version the shared library (fix #24)
authorSteven G. Johnson <stevenj@alum.mit.edu>
Sun, 8 Mar 2015 02:49:54 +0000 (21:49 -0500)
committerSteven G. Johnson <stevenj@alum.mit.edu>
Sun, 8 Mar 2015 02:49:54 +0000 (21:49 -0500)
.travis.yml
Makefile

index 1f2780a04b5e5c17aa92f1d23d4ecfbf28255368..df424ade30be96ea92d998d30827e968abb66522 100644 (file)
@@ -5,5 +5,6 @@ compiler:
 notifications:
     email: false
 script:
-    - make && make check
+    - make prefix=`pwd`/local install
+    - make check
     - make utf8proc_data.c.new && (diff utf8proc_data.c.new utf8proc_data.c > /dev/null)
index 678f5b67bb8e3833b07c0675b04adcbf3975a26b..61929ef504574f2436b8bdcf980a561ce434d038 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,23 +1,39 @@
 # libutf8proc Makefile
 
+# programs
 CURL=curl
 RUBY=ruby
 PERL=perl
 MAKE=make
+AR=ar
+INSTALL=install
 
-# settings
-
+# compiler settings
 cflags = -O2 -std=c99 -pedantic -Wall -fpic -DUTF8PROC_EXPORTS $(CFLAGS)
 cc = $(CC) $(cflags)
-AR = ar
+
+# shared-library version MAJOR.MINOR.RELEASE ... this may be *different*
+# from the utf8proc version number because it indicates ABI compatibility,
+# not API compatibility: MAJOR should be incremented whenever *binary*
+# compatibility is broken, even if the API is backward-compatibile
+MAJOR=1
+MINOR=2
+RELEASE=0
 
 OS := $(shell uname)
-ifeq ($(OS),Darwin)
-       SHLIB_EXT = dylib
-else #TODO Windows
-       SHLIB_EXT = so
+ifeq ($(OS),Darwin) # MacOS X
+  SHLIB_EXT = dylib
+  SHLIB_VERS_EXT = $(MAJOR).dylib
+else # GNU/Linux, at least (Windows should probably use cmake)
+  SHLIB_EXT = so
+  SHLIB_VERS_EXT = so.$(MAJOR).$(MINOR).$(REVISION)
 endif
 
+# installation directories (for 'make install')
+prefix=/usr/local
+libdir=$(prefix)/lib
+includedir=$(prefix)/include
+
 # meta targets
 
 all: c-library
@@ -25,7 +41,7 @@ all: c-library
 c-library: libutf8proc.a libutf8proc.$(SHLIB_EXT)
 
 clean:
-       rm -f utf8proc.o libutf8proc.a libutf8proc.$(SHLIB_EXT) test/normtest test/graphemetest data/UnicodeData.txt data/DerivedCoreProperties.txt data/CompositionExclusions.txt data/CaseFolding.txt data/NormalizationTest.txt data/GraphemeBreakTest.txt
+       rm -f utf8proc.o libutf8proc.a libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.$(SHLIB_EXT) test/normtest test/graphemetest data/UnicodeData.txt data/DerivedCoreProperties.txt data/CompositionExclusions.txt data/CaseFolding.txt data/NormalizationTest.txt data/GraphemeBreakTest.txt
        $(MAKE) -C bench clean
 
 update: utf8proc_data.c.new
@@ -58,13 +74,26 @@ libutf8proc.a: utf8proc.o
        rm -f libutf8proc.a
        $(AR) rs libutf8proc.a utf8proc.o
 
-libutf8proc.so: utf8proc.o
-       $(cc) -shared -o libutf8proc.$(SHLIB_EXT) utf8proc.o
-       chmod a-x libutf8proc.$(SHLIB_EXT)
+libutf8proc.so.$(MAJOR).$(MINOR).$(REVISION): utf8proc.o
+       $(cc) -shared -o $@ -soname libutf8proc.so.$(MAJOR) utf8proc.o
+       chmod a-x $@
+
+libutf8proc.so: libutf8proc.so.$(MAJOR).$(MINOR).$(REVISION)
+       ln -s libutf8proc.so.$(MAJOR).$(MINOR).$(REVISION) $@
+
+libutf8proc.$(MAJOR).dylib: utf8proc.o
+       $(cc) -dynamiclib -o $@ $^ -install_name $(libdir)/$@ -Wl,-compatibility_version -Wl,$(MAJOR) -Wl,-current_version -Wl,$(MAJOR).$(MINOR).$(REVISION)
 
-libutf8proc.dylib: utf8proc.o
-       $(cc) -dynamiclib -o $@ $^ -install_name $(libdir)/$@
+libutf8proc.dylib: libutf8proc.$(MAJOR).dylib
+       ln -s libutf8proc.$(MAJOR).dylib $@
 
+install: libutf8proc.a libutf8proc.$(SHLIB_EXT) libutf8proc.$(SHLIB_VERS_EXT)
+       mkdir -m 755 -p $(includedir)
+       $(INSTALL) -m 644 utf8proc.h $(includedir)
+       mkdir -m 755 -p $(libdir)
+       $(INSTALL) -m 644 libutf8proc.a $(libdir)
+       $(INSTALL) -m 755 libutf8proc.$(SHLIB_VERS_EXT) $(libdir)
+       ln -f -s $(libdir)/libutf8proc.$(SHLIB_VERS_EXT) $(libdir)/libutf8proc.$(SHLIB_EXT)
 
 # Test programs