Makefile (7266B)
1# libutf8proc Makefile 2 3# programs 4AR?=ar 5CC?=gcc 6INSTALL=install 7FIND=find 8PERL=perl 9 10# compiler settings 11CFLAGS ?= -O2 12PICFLAG = -fPIC 13C99FLAG = -std=c99 14WCFLAGS = -Wsign-conversion -Wall -Wextra -pedantic 15UCFLAGS = $(CPPFLAGS) $(CFLAGS) $(PICFLAG) $(C99FLAG) $(WCFLAGS) -DUTF8PROC_EXPORTS $(UTF8PROC_DEFINES) 16LDFLAG_SHARED = -shared 17SOFLAG = -Wl,-soname 18 19# shared-library version MAJOR.MINOR.PATCH ... this may be *different* 20# from the utf8proc version number because it indicates ABI compatibility, 21# not API compatibility: MAJOR should be incremented whenever *binary* 22# compatibility is broken, even if the API is backward-compatible. 23# The API version number is defined in utf8proc.h. 24# Be sure to also update these ABI versions in MANIFEST and CMakeLists.txt! 25MAJOR=3 26MINOR=0 27PATCH=0 28 29# api version (also in utf8proc.h and CMakeLists.txt) 30VERSION=2.9.0 31 32OS := $(shell uname) 33ifeq ($(OS),Darwin) # MacOS X 34 SHLIB_EXT = dylib 35 SHLIB_VERS_EXT = $(MAJOR).dylib 36else # GNU/Linux, at least (Windows should probably use cmake) 37 SHLIB_EXT = so 38 SHLIB_VERS_EXT = so.$(MAJOR).$(MINOR).$(PATCH) 39endif 40 41# installation directories (for 'make install') 42prefix=/usr/local 43libdir=$(prefix)/lib 44includedir=$(prefix)/include 45pkgconfigdir=$(libdir)/pkgconfig 46 47pkglibdir=$(libdir:$(prefix)/%=%) 48pkgincludedir=$(includedir:$(prefix)/%=%) 49 50# meta targets 51 52.PHONY: all clean data update manifest install 53 54all: libutf8proc.a libutf8proc.$(SHLIB_EXT) 55 56clean: 57 rm -f utf8proc.o libutf8proc.a libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.$(SHLIB_EXT) 58 rm -f libutf8proc.pc 59ifneq ($(OS),Darwin) 60 rm -f libutf8proc.so.$(MAJOR) 61endif 62 rm -f test/tests.o test/normtest test/graphemetest test/printproperty test/charwidth test/valid test/iterate test/case test/custom test/misc test/iscase 63 rm -rf MANIFEST.new tmp 64 $(MAKE) -C bench clean 65 $(MAKE) -C data clean 66 67data: data/utf8proc_data.c.new 68 69update: data/utf8proc_data.c.new 70 cp -f data/utf8proc_data.c.new utf8proc_data.c 71 72manifest: MANIFEST.new 73 74# real targets 75 76data/utf8proc_data.c.new: libutf8proc.$(SHLIB_EXT) data/data_generator.jl 77 $(MAKE) -C data utf8proc_data.c.new 78 79utf8proc.o: utf8proc.h utf8proc.c utf8proc_data.c 80 $(CC) $(UCFLAGS) -c -o utf8proc.o utf8proc.c 81 82libutf8proc.a: utf8proc.o 83 rm -f libutf8proc.a 84 $(AR) crs libutf8proc.a utf8proc.o 85 86libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH): utf8proc.o 87 $(CC) $(LDFLAGS) $(LDFLAG_SHARED) -o $@ $(SOFLAG) -Wl,libutf8proc.so.$(MAJOR) utf8proc.o 88 chmod a-x $@ 89 90libutf8proc.so: libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH) 91 ln -f -s libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH) $@ 92 ln -f -s libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH) $@.$(MAJOR) 93 94libutf8proc.$(MAJOR).dylib: utf8proc.o 95 $(CC) $(LDFLAGS) -dynamiclib -o $@ $^ -install_name $(libdir)/$@ -Wl,-compatibility_version -Wl,$(MAJOR) -Wl,-current_version -Wl,$(MAJOR).$(MINOR).$(PATCH) 96 97libutf8proc.dylib: libutf8proc.$(MAJOR).dylib 98 ln -f -s libutf8proc.$(MAJOR).dylib $@ 99 100libutf8proc.pc: libutf8proc.pc.in 101 sed \ 102 -e 's#PREFIX#$(prefix)#' \ 103 -e 's#LIBDIR#$(pkglibdir)#' \ 104 -e 's#INCLUDEDIR#$(pkgincludedir)#' \ 105 -e 's#VERSION#$(MAJOR).$(MINOR).$(PATCH)#' \ 106 libutf8proc.pc.in > libutf8proc.pc 107 108install: libutf8proc.a libutf8proc.$(SHLIB_EXT) libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.pc 109 mkdir -m 755 -p $(DESTDIR)$(includedir) 110 $(INSTALL) -m 644 utf8proc.h $(DESTDIR)$(includedir) 111 mkdir -m 755 -p $(DESTDIR)$(libdir) 112 $(INSTALL) -m 644 libutf8proc.a $(DESTDIR)$(libdir) 113 $(INSTALL) -m 755 libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir) 114 mkdir -m 755 -p $(DESTDIR)$(pkgconfigdir) 115 $(INSTALL) -m 644 libutf8proc.pc $(DESTDIR)$(pkgconfigdir)/libutf8proc.pc 116 ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.$(SHLIB_EXT) 117ifneq ($(OS),Darwin) 118 ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR) 119endif 120 121MANIFEST.new: 122 rm -rf tmp 123 $(MAKE) install prefix=/usr DESTDIR=$(PWD)/tmp 124 $(FIND) tmp/usr -mindepth 1 -type l -printf "%P -> %l\n" -or -type f -printf "%P\n" -or -type d -printf "%P/\n" | LC_ALL=C sort > $@ 125 rm -rf tmp 126 127# Test programs 128 129data/NormalizationTest.txt: 130 $(MAKE) -C data NormalizationTest.txt 131 132data/GraphemeBreakTest.txt: 133 $(MAKE) -C data GraphemeBreakTest.txt 134 135data/Lowercase.txt: 136 $(MAKE) -C data Lowercase.txt 137 138data/Uppercase.txt: 139 $(MAKE) -C data Uppercase.txt 140 141test/tests.o: test/tests.c test/tests.h utf8proc.h 142 $(CC) $(UCFLAGS) -c -o test/tests.o test/tests.c 143 144test/normtest: test/normtest.c test/tests.o utf8proc.o utf8proc.h test/tests.h 145 $(CC) $(UCFLAGS) $(LDFLAGS) test/normtest.c test/tests.o utf8proc.o -o $@ 146 147test/graphemetest: test/graphemetest.c test/tests.o utf8proc.o utf8proc.h test/tests.h 148 $(CC) $(UCFLAGS) $(LDFLAGS) test/graphemetest.c test/tests.o utf8proc.o -o $@ 149 150test/printproperty: test/printproperty.c test/tests.o utf8proc.o utf8proc.h test/tests.h 151 $(CC) $(UCFLAGS) $(LDFLAGS) test/printproperty.c test/tests.o utf8proc.o -o $@ 152 153test/charwidth: test/charwidth.c test/tests.o utf8proc.o utf8proc.h test/tests.h 154 $(CC) $(UCFLAGS) $(LDFLAGS) test/charwidth.c test/tests.o utf8proc.o -o $@ 155 156test/valid: test/valid.c test/tests.o utf8proc.o utf8proc.h test/tests.h 157 $(CC) $(UCFLAGS) $(LDFLAGS) test/valid.c test/tests.o utf8proc.o -o $@ 158 159test/iterate: test/iterate.c test/tests.o utf8proc.o utf8proc.h test/tests.h 160 $(CC) $(UCFLAGS) $(LDFLAGS) test/iterate.c test/tests.o utf8proc.o -o $@ 161 162test/iscase: test/iscase.c test/tests.o utf8proc.o utf8proc.h test/tests.h 163 $(CC) $(UCFLAGS) $(LDFLAGS) test/iscase.c test/tests.o utf8proc.o -o $@ 164 165test/case: test/case.c test/tests.o utf8proc.o utf8proc.h test/tests.h 166 $(CC) $(UCFLAGS) $(LDFLAGS) test/case.c test/tests.o utf8proc.o -o $@ 167 168test/custom: test/custom.c test/tests.o utf8proc.o utf8proc.h test/tests.h 169 $(CC) $(UCFLAGS) $(LDFLAGS) test/custom.c test/tests.o utf8proc.o -o $@ 170 171test/misc: test/misc.c test/tests.o utf8proc.o utf8proc.h test/tests.h 172 $(CC) $(UCFLAGS) $(LDFLAGS) -DUNICODE_VERSION='"'`$(PERL) -ne "/^UNICODE_VERSION=/ and print $$';" data/Makefile`'"' test/misc.c test/tests.o utf8proc.o -o $@ 173 174# make release tarball from master branch 175dist: 176 git archive master --prefix=utf8proc-$(VERSION)/ -o utf8proc-$(VERSION).tar.gz 177 178# build tarball, make sure it passes checks, and make sure version numbers are consistent 179distcheck: dist 180 test `grep UTF8PROC_VERSION utf8proc.h | cut -d' ' -f3 | tr '\n' .` = $(VERSION). || exit 1 181 test `grep "utf8proc VERSION" CMakeLists.txt |cut -d' ' -f 4` = $(VERSION) || exit 1 182 test `grep libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH) MANIFEST | wc -l` = 3 || exit 1 183 test `grep 'set(SO_' CMakeLists.txt |cut -d' ' -f2 | tr -d ')' | tr '\n' '.'` = $(MAJOR).$(MINOR).$(PATCH). || exit 1 184 rm -rf utf8proc-$(VERSION) 185 tar xzf utf8proc-$(VERSION).tar.gz 186 make -C utf8proc-$(VERSION) check 187 rm -rf utf8proc-$(VERSION) 188 189check: test/normtest data/NormalizationTest.txt data/Lowercase.txt data/Uppercase.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/iscase test/custom test/charwidth test/misc test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o 190 $(MAKE) -C bench 191 test/normtest data/NormalizationTest.txt 192 test/graphemetest data/GraphemeBreakTest.txt 193 test/charwidth 194 test/misc 195 test/valid 196 test/iterate 197 test/case 198 test/iscase data/Lowercase.txt data/Uppercase.txt 199 test/custom