]> mj.ucw.cz Git - libucw.git/blob - ucw/Makefile
Released as 6.5.16.
[libucw.git] / ucw / Makefile
1 # Makefile for the UCW Library (c) 1997--2015 Martin Mares <mj@ucw.cz>
2
3 DIRS+=ucw
4 LIBUCW=$(o)/ucw/libucw.pc
5
6 ifdef CONFIG_UCW_UTILS
7 include $(s)/ucw/utils/Makefile
8 endif
9
10 LIBUCW_MODS= \
11         threads \
12         alloc alloc_str alloc-std \
13         bigalloc mempool mempool-str mempool-fmt eltpool \
14         partmap hashfunc \
15         slists simple-lists bitsig \
16         log log-stream log-file log-syslog log-conf tbf \
17         conf-context conf-alloc conf-dump conf-input conf-intr conf-journal conf-parse conf-section conf-getopt \
18         ipaccess \
19         fastbuf ff-binary ff-string ff-printf ff-unicode ff-varint ff-stkstring \
20         fb-file fb-mem fb-temp tempfile fb-mmap fb-limfd fb-buffer fb-grow fb-pool fb-atomic fb-param fb-socket fb-multi fb-null \
21         fw-hex \
22         char-cat char-upper char-lower unicode varint stkstring \
23         wildmatch regex \
24         prime primetable \
25         random-legacy random-fast random-strong \
26         time-stamp time-timer time-conf \
27         bit-ffs bit-fls bit-array \
28         url \
29         mainloop main-block main-rec \
30         proctitle exitstatus runcmd \
31         lizard lizard-safe adler32 sighandler \
32         md5 sha1 sha1-hmac crc crc-tables \
33         base64 base224 \
34         io-careful io-sync io-mmap io-size \
35         string str-esc str-split str-match str-imatch str-hex str-fix \
36         bbuf gary \
37         getopt \
38         strtonum \
39         resource trans res-fd res-mem res-subpool res-mempool res-eltpool \
40         daemon daemon-ctrl \
41         signames \
42         opt opt-help opt-conf \
43         table xtypes xtypes-basic xtypes-extra
44
45 LIBUCW_MAIN_INCLUDES= \
46         lib.h log.h tbf.h threads.h time.h \
47         alloc.h mempool.h eltpool.h \
48         clists.h slists.h simple-lists.h \
49         string.h stkstring.h unicode.h varint.h chartype.h regex.h \
50         wildmatch.h \
51         unaligned.h \
52         bbuf.h gbuf.h gary.h bitarray.h bitsig.h \
53         hashfunc.h hashtable.h \
54         heap.h binheap.h binheap-node.h \
55         redblack.h \
56         prime.h \
57         random.h \
58         bitops.h \
59         conf.h getopt.h ipaccess.h \
60         fastbuf.h io.h ff-unicode.h ff-varint.h ff-binary.h fb-socket.h fw-hex.h \
61         url.h \
62         mainloop.h \
63         process.h \
64         lizard.h \
65         md5.h sha1.h crc.h \
66         base64.h base224.h \
67         kmp.h kmp-search.h trie.h binsearch.h \
68         partmap.h \
69         strtonum.h \
70         resource.h trans.h \
71         daemon.h \
72         signames.h \
73         sighandler.h \
74         opt.h \
75         table.h xtypes-extra.h \
76         xtypes.h
77
78 ifdef CONFIG_UCW_THREADS
79 # Some modules require threading
80 LIBUCW_MODS+=threads-conf workqueue asio
81 LIBUCW_MAIN_INCLUDES+=workqueue.h semaphore.h asio.h
82 endif
83
84 ifdef CONFIG_UCW_FB_DIRECT
85 LIBUCW_MODS+=fb-direct
86 endif
87
88 ifdef CONFIG_UCW_OWN_GETOPT
89 include $(s)/ucw/getopt/Makefile
90 endif
91
92 LIBUCW_INCLUDES=$(LIBUCW_MAIN_INCLUDES)
93
94 include $(s)/ucw/sorter/Makefile
95 include $(s)/ucw/doc/Makefile
96
97 LIBUCW_MOD_PATHS=$(addprefix $(o)/ucw/,$(LIBUCW_MODS))
98
99 export LIBUCW_LIBS=-lm
100 ifdef CONFIG_UCW_THREADS
101 LIBUCW_LIBS+=-lpthread
102 endif
103 ifdef CONFIG_UCW_PCRE
104 LIBUCW_LIBS+=-lpcre
105 endif
106 ifdef CONFIG_UCW_MONOTONIC_CLOCK
107 LIBUCW_LIBS+=-lrt
108 endif
109
110 $(o)/ucw/libucw$(LV).a: $(addsuffix .o,$(LIBUCW_MOD_PATHS))
111 $(o)/ucw/libucw$(LV).so: $(addsuffix .oo,$(LIBUCW_MOD_PATHS))
112 $(o)/ucw/libucw$(LV).so: SONAME_SUFFIX=.0
113 $(o)/ucw/libucw$(LV).so: LIBS+=$(LIBUCW_LIBS)
114
115 ifdef CONFIG_INSTALL_API
116 $(o)/ucw/libucw.pc: $(addprefix $(o)/ucw/libucw$(LV),.a .so)
117 endif
118
119 $(o)/ucw/hashfunc.o $(o)/ucw/hashfunc.oo: CFLAGS += -funroll-loops
120 $(o)/ucw/lizard.o: CFLAGS += $(COPT2) -funroll-loops
121
122 $(o)/ucw/ff-varint-t: $(LIBUCW)
123 $(o)/ucw/varint-t: $(LIBUCW)
124 $(o)/ucw/conf-test: $(o)/ucw/conf-test.o $(LIBUCW)
125 $(o)/ucw/hash-test: $(o)/ucw/hash-test.o $(LIBUCW)
126 $(o)/ucw/hashfunc-test: $(o)/ucw/hashfunc-test.o $(LIBUCW)
127 $(o)/ucw/asort-test: $(o)/ucw/asort-test.o $(LIBUCW)
128 $(o)/ucw/redblack-test: $(o)/ucw/redblack-test.o $(LIBUCW)
129 $(o)/ucw/binheap-test: $(o)/ucw/binheap-test.o $(LIBUCW)
130 $(o)/ucw/lizard-test: $(o)/ucw/lizard-test.o $(LIBUCW)
131 $(o)/ucw/kmp-test: $(o)/ucw/kmp-test.o $(LIBUCW)
132 $(o)/ucw/strtonum-test: $(o)/ucw/strtonum-test.o $(LIBUCW)
133 ifdef CONFIG_CHARSET
134 $(o)/ucw/kmp-test: $(LIBCHARSET)
135 endif
136 $(o)/ucw/ipaccess-test: $(o)/ucw/ipaccess-test.o $(LIBUCW)
137 $(o)/ucw/trie-test: $(o)/ucw/trie-test.o $(LIBUCW)
138 $(o)/ucw/opt-test: $(o)/ucw/opt-test.o $(LIBUCW)
139 $(o)/ucw/table-test: $(o)/ucw/table-test.o $(LIBUCW)
140 $(o)/ucw/table-test-2: $(o)/ucw/table-test-2.o $(LIBUCW)
141 $(o)/ucw/table-test-align: $(o)/ucw/table-test-align.o $(LIBUCW)
142 $(o)/ucw/xtypes-test: $(o)/ucw/xtypes-test.o $(LIBUCW)
143 $(o)/ucw/random-test: $(o)/ucw/random-test.o $(LIBUCW)
144
145 TESTS+=$(addprefix $(o)/ucw/,regex.test unicode.test hash-test.test mempool.test stkstring.test \
146     slists.test bbuf.test kmp-test.test getopt.test ff-unicode.test eltpool.test \
147     trie-test.test string.test sha1.test asort-test.test binheap-test.test \
148     fb-file.test fb-socket.test fb-grow.test fb-pool.test fb-atomic.test fb-limfd.test fb-temp.test \
149     fb-mem.test fb-buffer.test fb-mmap.test fb-multi.test fb-null.test \
150     redblack-test.test url.test strtonum-test.test \
151     gary.test time.test crc.test signames.test md5.test bitops.test opt.test \
152     table.test table-test.test table-test-2.test table-test-align.test xtypes-test.test random-test.test)
153
154 $(o)/ucw/varint.test: $(o)/ucw/varint-t
155 $(o)/ucw/regex.test: $(o)/ucw/regex-t
156 $(o)/ucw/unicode.test: $(o)/ucw/unicode-t
157 $(o)/ucw/hash-test.test: $(o)/ucw/hash-test
158 $(o)/ucw/mempool.test: $(o)/ucw/mempool-t $(o)/ucw/mempool-fmt-t $(o)/ucw/mempool-str-t
159 $(o)/ucw/stkstring.test: $(o)/ucw/stkstring-t
160 $(o)/ucw/bitops.test: $(o)/ucw/bit-ffs-t $(o)/ucw/bit-fls-t
161 $(o)/ucw/slists.test: $(o)/ucw/slists-t
162 $(o)/ucw/kmp-test.test: $(o)/ucw/kmp-test
163 $(o)/ucw/bbuf.test: $(o)/ucw/bbuf-t
164 $(o)/ucw/getopt.test: $(o)/ucw/getopt-t
165 $(o)/ucw/ff-unicode.test: $(o)/ucw/ff-unicode-t
166 $(o)/ucw/ff-varint.test: $(o)/ucw/ff-varint-t
167 $(o)/ucw/eltpool.test: $(o)/ucw/eltpool-t
168 $(o)/ucw/string.test: $(o)/ucw/str-hex-t $(o)/ucw/str-esc-t $(o)/ucw/str-fix-t
169 $(o)/ucw/sha1.test: $(o)/ucw/sha1-t $(o)/ucw/sha1-hmac-t
170 $(o)/ucw/trie-test.test: $(o)/ucw/trie-test
171 $(o)/ucw/asort-test.test: $(o)/ucw/asort-test
172 $(o)/ucw/binheap-test.test: $(o)/ucw/binheap-test
173 $(o)/ucw/redblack-test.test: $(o)/ucw/redblack-test
174 $(o)/ucw/strtonum-test.test: $(o)/ucw/strtonum-test
175 $(addprefix $(o)/ucw/fb-,file.test grow.test pool.test socket.test atomic.test \
176         limfd.test temp.test mem.test buffer.test mmap.test multi.test null.test): %.test: %-t
177 $(o)/ucw/url.test: $(o)/ucw/url-t
178 $(o)/ucw/gary.test: $(o)/ucw/gary-t
179 $(o)/ucw/time.test: $(o)/ucw/time-conf-t
180 $(o)/ucw/crc.test: $(o)/ucw/crc-t
181 $(o)/ucw/signames.test: $(o)/ucw/signames-t
182 $(o)/ucw/md5.test: $(o)/ucw/md5-t
183 $(o)/ucw/opt.test: $(o)/ucw/opt-test
184 $(o)/ucw/table.test: $(o)/ucw/table-t
185 $(o)/ucw/table-test.test: $(o)/ucw/table-test
186 $(o)/ucw/table-test-2.test: $(o)/ucw/table-test-2
187 $(o)/ucw/table-test-align.test: $(o)/ucw/table-test-align
188 $(o)/ucw/xtypes-test.test: $(o)/ucw/xtypes-test
189 $(o)/ucw/random-test.test: $(o)/ucw/random-test
190
191 ifdef CONFIG_UCW_THREADS
192 TESTS+=$(addprefix $(o)/ucw/,asio.test)
193 $(o)/ucw/asio.test: $(o)/ucw/asio-t
194 endif
195
196 # The version of autoconf.h that is a part of the public API needs to have
197 # the internal symbols filtered out, so we generate ucw/autoconf.h in the
198 # configure script and let the public config.h refer to <ucw/autoconf.h>
199 # instead of plain "autoconf.h".
200
201 API_LIBS+=libucw
202 API_INCLUDES+=$(o)/ucw/.include-stamp
203 $(o)/ucw/.include-stamp: $(addprefix $(s)/ucw/,$(LIBUCW_INCLUDES)) $(o)/ucw/autoconf.h
204         $(Q)$(BUILDSYS)/install-includes $(<D) run/include/ucw $(LIBUCW_INCLUDES)
205         $(Q)$(BUILDSYS)/install-includes $(o)/ucw run/include/ucw autoconf.h
206         $(Q)sed -e 's/^#include "autoconf\.h"/#include <ucw\/autoconf.h>/' <$(s)/ucw/config.h >run/include/ucw/config.h
207         $(Q)touch $@
208 run/lib/pkgconfig/libucw.pc: $(o)/ucw/libucw.pc
209
210 ifdef CONFIG_UCW_PERL
211 include $(s)/ucw/perl/Makefile
212 endif
213
214 ifdef CONFIG_UCW_SHELL_UTILS
215 include $(s)/ucw/shell/Makefile
216 endif
217
218 CONFIGS+=libucw
219
220 INSTALL_TARGETS+=install-libucw-lib
221 install-libucw-lib:
222         install -d -m 755 $(DESTDIR)$(INSTALL_LIB_DIR)
223         install -m 644 run/lib/libucw$(LV).so.0 $(DESTDIR)$(INSTALL_LIB_DIR)/libucw$(LV).so.0.0
224         ln -sf libucw$(LV).so.0.0 $(DESTDIR)$(INSTALL_LIB_DIR)/libucw$(LV).so.0
225 .PHONY: install-libucw-lib
226
227 INSTALL_TARGETS+=install-libucw-api
228 install-libucw-api: install-ucw-sorter-api
229         install -d -m 755 $(DESTDIR)$(INSTALL_LIB_DIR) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/ $(DESTDIR)$(INSTALL_PKGCONFIG_DIR)
230         install -m 644 $(addprefix run/include/ucw/,$(LIBUCW_MAIN_INCLUDES) autoconf.h config.h) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/
231         install -m 644 run/lib/pkgconfig/libucw.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR)
232         ln -sf libucw$(LV).so.0.0 $(DESTDIR)$(INSTALL_LIB_DIR)/libucw$(LV).so
233         install -m 644 run/lib/libucw$(LV).a $(DESTDIR)$(INSTALL_LIB_DIR)
234 .PHONY: install-libucw-api
235
236 INSTALL_TARGETS+=install-libucw-config
237 install-libucw-config:
238         install -d -m 755 $(DESTDIR)$(INSTALL_CONFIG_DIR)
239         install -m 644 run/$(CONFIG_DIR)/libucw $(DESTDIR)$(INSTALL_CONFIG_DIR)
240 .PHONY: install-libucw-config