comparison dep/utf8proc/Makefile @ 343:1faa72660932

*: transfer back to cmake from autotools autotools just made lots of things more complicated than they should have and many things broke (i.e. translations)
author Paper <paper@paper.us.eu.org>
date Thu, 20 Jun 2024 05:56:06 -0400
parents
children
comparison
equal deleted inserted replaced
342:adb79bdde329 343:1faa72660932
1 # libutf8proc Makefile
2
3 # programs
4 AR?=ar
5 CC?=gcc
6 INSTALL=install
7 FIND=find
8 PERL=perl
9
10 # compiler settings
11 CFLAGS ?= -O2
12 PICFLAG = -fPIC
13 C99FLAG = -std=c99
14 WCFLAGS = -Wsign-conversion -Wall -Wextra -pedantic
15 UCFLAGS = $(CPPFLAGS) $(CFLAGS) $(PICFLAG) $(C99FLAG) $(WCFLAGS) -DUTF8PROC_EXPORTS $(UTF8PROC_DEFINES)
16 LDFLAG_SHARED = -shared
17 SOFLAG = -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!
25 MAJOR=3
26 MINOR=0
27 PATCH=0
28
29 # api version (also in utf8proc.h and CMakeLists.txt)
30 VERSION=2.9.0
31
32 OS := $(shell uname)
33 ifeq ($(OS),Darwin) # MacOS X
34 SHLIB_EXT = dylib
35 SHLIB_VERS_EXT = $(MAJOR).dylib
36 else # GNU/Linux, at least (Windows should probably use cmake)
37 SHLIB_EXT = so
38 SHLIB_VERS_EXT = so.$(MAJOR).$(MINOR).$(PATCH)
39 endif
40
41 # installation directories (for 'make install')
42 prefix=/usr/local
43 libdir=$(prefix)/lib
44 includedir=$(prefix)/include
45 pkgconfigdir=$(libdir)/pkgconfig
46
47 pkglibdir=$(libdir:$(prefix)/%=%)
48 pkgincludedir=$(includedir:$(prefix)/%=%)
49
50 # meta targets
51
52 .PHONY: all clean data update manifest install
53
54 all: libutf8proc.a libutf8proc.$(SHLIB_EXT)
55
56 clean:
57 rm -f utf8proc.o libutf8proc.a libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.$(SHLIB_EXT)
58 rm -f libutf8proc.pc
59 ifneq ($(OS),Darwin)
60 rm -f libutf8proc.so.$(MAJOR)
61 endif
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
67 data: data/utf8proc_data.c.new
68
69 update: data/utf8proc_data.c.new
70 cp -f data/utf8proc_data.c.new utf8proc_data.c
71
72 manifest: MANIFEST.new
73
74 # real targets
75
76 data/utf8proc_data.c.new: libutf8proc.$(SHLIB_EXT) data/data_generator.rb data/charwidths.jl
77 $(MAKE) -C data utf8proc_data.c.new
78
79 utf8proc.o: utf8proc.h utf8proc.c utf8proc_data.c
80 $(CC) $(UCFLAGS) -c -o utf8proc.o utf8proc.c
81
82 libutf8proc.a: utf8proc.o
83 rm -f libutf8proc.a
84 $(AR) crs libutf8proc.a utf8proc.o
85
86 libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH): utf8proc.o
87 $(CC) $(LDFLAGS) $(LDFLAG_SHARED) -o $@ $(SOFLAG) -Wl,libutf8proc.so.$(MAJOR) utf8proc.o
88 chmod a-x $@
89
90 libutf8proc.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
94 libutf8proc.$(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
97 libutf8proc.dylib: libutf8proc.$(MAJOR).dylib
98 ln -f -s libutf8proc.$(MAJOR).dylib $@
99
100 libutf8proc.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
108 install: 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)
117 ifneq ($(OS),Darwin)
118 ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR)
119 endif
120
121 MANIFEST.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
129 data/NormalizationTest.txt:
130 $(MAKE) -C data NormalizationTest.txt
131
132 data/GraphemeBreakTest.txt:
133 $(MAKE) -C data GraphemeBreakTest.txt
134
135 data/Lowercase.txt:
136 $(MAKE) -C data Lowercase.txt
137
138 data/Uppercase.txt:
139 $(MAKE) -C data Uppercase.txt
140
141 test/tests.o: test/tests.c test/tests.h utf8proc.h
142 $(CC) $(UCFLAGS) -c -o test/tests.o test/tests.c
143
144 test/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
147 test/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
150 test/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
153 test/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
156 test/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
159 test/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
162 test/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
165 test/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
168 test/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
171 test/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
175 dist:
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
179 distcheck: 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 tar xzf utf8proc-$(VERSION).tar.gz
185 make -C utf8proc-$(VERSION) check
186 rm -rf utf8proc-$(VERSION)
187
188 check: 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
189 $(MAKE) -C bench
190 test/normtest data/NormalizationTest.txt
191 test/graphemetest data/GraphemeBreakTest.txt
192 test/charwidth
193 test/misc
194 test/valid
195 test/iterate
196 test/case
197 test/iscase data/Lowercase.txt data/Uppercase.txt
198 test/custom