1 # Makefile for the UCW Library (c) 1997--2014 Martin Mares <mj@ucw.cz>
4 LIBUCW=$(o)/ucw/libucw.pc
7 include $(s)/ucw/utils/Makefile
12 alloc alloc_str alloc-std \
13 bigalloc mempool mempool-str mempool-fmt eltpool \
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 \
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 char-cat char-upper char-lower unicode varint stkstring \
23 prime primetable random \
24 time-stamp time-timer time-conf \
25 bit-ffs bit-fls bit-array \
27 mainloop main-block main-rec \
28 proctitle exitstatus runcmd \
29 lizard lizard-safe adler32 sighandler \
30 md5 sha1 sha1-hmac crc crc-tables \
32 io-careful io-sync io-mmap io-size \
33 string str-esc str-split str-match str-imatch str-hex str-fix \
37 resource trans res-fd res-mem res-subpool res-mempool res-eltpool \
40 opt opt-help opt-conf \
41 table table-types xtypes xtypes-basic
43 LIBUCW_MAIN_INCLUDES= \
44 lib.h log.h tbf.h threads.h time.h \
45 alloc.h mempool.h eltpool.h \
46 clists.h slists.h simple-lists.h \
47 string.h stkstring.h unicode.h varint.h chartype.h regex.h \
50 bbuf.h gbuf.h gary.h bitarray.h bitsig.h \
51 hashfunc.h hashtable.h \
52 heap.h binheap.h binheap-node.h \
56 conf.h getopt.h ipaccess.h \
57 fastbuf.h io.h ff-unicode.h ff-varint.h ff-binary.h fb-socket.h \
64 kmp.h kmp-search.h trie.h binsearch.h \
72 table.h table-types.h \
75 ifdef CONFIG_UCW_THREADS
76 # Some modules require threading
77 LIBUCW_MODS+=threads-conf workqueue asio
78 LIBUCW_MAIN_INCLUDES+=workqueue.h semaphore.h asio.h
81 ifdef CONFIG_UCW_FB_DIRECT
82 LIBUCW_MODS+=fb-direct
85 ifdef CONFIG_UCW_OWN_GETOPT
86 include $(s)/ucw/getopt/Makefile
89 LIBUCW_INCLUDES=$(LIBUCW_MAIN_INCLUDES)
91 include $(s)/ucw/sorter/Makefile
92 include $(s)/ucw/doc/Makefile
94 LIBUCW_MOD_PATHS=$(addprefix $(o)/ucw/,$(LIBUCW_MODS))
96 export LIBUCW_LIBS=-lm
97 ifdef CONFIG_UCW_THREADS
98 LIBUCW_LIBS+=-lpthread
100 ifdef CONFIG_UCW_PCRE
103 ifdef CONFIG_UCW_MONOTONIC_CLOCK
107 $(o)/ucw/libucw$(LV).a: $(addsuffix .o,$(LIBUCW_MOD_PATHS))
108 $(o)/ucw/libucw$(LV).so: $(addsuffix .oo,$(LIBUCW_MOD_PATHS))
109 $(o)/ucw/libucw$(LV).so: SONAME_SUFFIX=.0
110 $(o)/ucw/libucw$(LV).so: LIBS+=$(LIBUCW_LIBS)
112 ifdef CONFIG_INSTALL_API
113 $(o)/ucw/libucw.pc: $(addprefix $(o)/ucw/libucw$(LV),.a .so)
116 $(o)/ucw/hashfunc.o $(o)/ucw/hashfunc.oo: CFLAGS += -funroll-loops
117 $(o)/ucw/lizard.o: CFLAGS += $(COPT2) -funroll-loops
119 $(o)/ucw/ff-varint-t: $(LIBUCW)
120 $(o)/ucw/varint-t: $(LIBUCW)
121 $(o)/ucw/conf-test: $(o)/ucw/conf-test.o $(LIBUCW)
122 $(o)/ucw/hash-test: $(o)/ucw/hash-test.o $(LIBUCW)
123 $(o)/ucw/hashfunc-test: $(o)/ucw/hashfunc-test.o $(LIBUCW)
124 $(o)/ucw/asort-test: $(o)/ucw/asort-test.o $(LIBUCW)
125 $(o)/ucw/redblack-test: $(o)/ucw/redblack-test.o $(LIBUCW)
126 $(o)/ucw/binheap-test: $(o)/ucw/binheap-test.o $(LIBUCW)
127 $(o)/ucw/lizard-test: $(o)/ucw/lizard-test.o $(LIBUCW)
128 $(o)/ucw/kmp-test: $(o)/ucw/kmp-test.o $(LIBUCW)
129 $(o)/ucw/strtonum-test: $(o)/ucw/strtonum-test.o $(LIBUCW)
131 $(o)/ucw/kmp-test: $(LIBCHARSET)
133 $(o)/ucw/ipaccess-test: $(o)/ucw/ipaccess-test.o $(LIBUCW)
134 $(o)/ucw/trie-test: $(o)/ucw/trie-test.o $(LIBUCW)
135 $(o)/ucw/opt-test: $(o)/ucw/opt-test.o $(LIBUCW)
136 $(o)/ucw/table-test: $(o)/ucw/table-test.o $(LIBUCW)
137 $(o)/ucw/table-test-2: $(o)/ucw/table-test-2.o $(LIBUCW)
138 $(o)/ucw/table-test-align: $(o)/ucw/table-test-align.o $(LIBUCW)
139 $(o)/ucw/xtypes-test: $(o)/ucw/xtypes-test.o $(LIBUCW)
141 TESTS+=$(addprefix $(o)/ucw/,regex.test unicode.test hash-test.test mempool.test stkstring.test \
142 slists.test bbuf.test kmp-test.test getopt.test ff-unicode.test eltpool.test \
143 trie-test.test string.test sha1.test asort-test.test binheap-test.test \
144 fb-file.test fb-socket.test fb-grow.test fb-pool.test fb-atomic.test fb-limfd.test fb-temp.test \
145 fb-mem.test fb-buffer.test fb-mmap.test fb-multi.test fb-null.test \
146 redblack-test.test url.test strtonum-test.test \
147 gary.test time.test crc.test signames.test md5.test bitops.test opt.test \
148 table.test table-test.test table-test-2.test table-test-align.test xtypes-test.test)
150 $(o)/ucw/varint.test: $(o)/ucw/varint-t
151 $(o)/ucw/regex.test: $(o)/ucw/regex-t
152 $(o)/ucw/unicode.test: $(o)/ucw/unicode-t
153 $(o)/ucw/hash-test.test: $(o)/ucw/hash-test
154 $(o)/ucw/mempool.test: $(o)/ucw/mempool-t $(o)/ucw/mempool-fmt-t $(o)/ucw/mempool-str-t
155 $(o)/ucw/stkstring.test: $(o)/ucw/stkstring-t
156 $(o)/ucw/bitops.test: $(o)/ucw/bit-ffs-t $(o)/ucw/bit-fls-t
157 $(o)/ucw/slists.test: $(o)/ucw/slists-t
158 $(o)/ucw/kmp-test.test: $(o)/ucw/kmp-test
159 $(o)/ucw/bbuf.test: $(o)/ucw/bbuf-t
160 $(o)/ucw/getopt.test: $(o)/ucw/getopt-t
161 $(o)/ucw/ff-unicode.test: $(o)/ucw/ff-unicode-t
162 $(o)/ucw/ff-varint.test: $(o)/ucw/ff-varint-t
163 $(o)/ucw/eltpool.test: $(o)/ucw/eltpool-t
164 $(o)/ucw/string.test: $(o)/ucw/str-hex-t $(o)/ucw/str-esc-t $(o)/ucw/str-fix-t
165 $(o)/ucw/sha1.test: $(o)/ucw/sha1-t $(o)/ucw/sha1-hmac-t
166 $(o)/ucw/trie-test.test: $(o)/ucw/trie-test
167 $(o)/ucw/asort-test.test: $(o)/ucw/asort-test
168 $(o)/ucw/binheap-test.test: $(o)/ucw/binheap-test
169 $(o)/ucw/redblack-test.test: $(o)/ucw/redblack-test
170 $(o)/ucw/strtonum-test.test: $(o)/ucw/strtonum-test
171 $(addprefix $(o)/ucw/fb-,file.test grow.test pool.test socket.test atomic.test \
172 limfd.test temp.test mem.test buffer.test mmap.test multi.test null.test): %.test: %-t
173 $(o)/ucw/url.test: $(o)/ucw/url-t
174 $(o)/ucw/gary.test: $(o)/ucw/gary-t
175 $(o)/ucw/time.test: $(o)/ucw/time-conf-t
176 $(o)/ucw/crc.test: $(o)/ucw/crc-t
177 $(o)/ucw/signames.test: $(o)/ucw/signames-t
178 $(o)/ucw/md5.test: $(o)/ucw/md5-t
179 $(o)/ucw/opt.test: $(o)/ucw/opt-test
180 $(o)/ucw/table.test: $(o)/ucw/table-t
181 $(o)/ucw/table-test.test: $(o)/ucw/table-test
182 $(o)/ucw/table-test-2.test: $(o)/ucw/table-test-2
183 $(o)/ucw/table-test-align.test: $(o)/ucw/table-test-align
184 $(o)/ucw/xtypes-test.test: $(o)/ucw/xtypes-test
186 ifdef CONFIG_UCW_THREADS
187 TESTS+=$(addprefix $(o)/ucw/,asio.test)
188 $(o)/ucw/asio.test: $(o)/ucw/asio-t
191 # The version of autoconf.h that is a part of the public API needs to have
192 # the internal symbols filtered out, so we generate ucw/autoconf.h in the
193 # configure script and let the public config.h refer to <ucw/autoconf.h>
194 # instead of plain "autoconf.h".
197 API_INCLUDES+=$(o)/ucw/.include-stamp
198 $(o)/ucw/.include-stamp: $(addprefix $(s)/ucw/,$(LIBUCW_INCLUDES)) $(o)/ucw/autoconf.h
199 $(Q)$(BUILDSYS)/install-includes $(<D) run/include/ucw $(LIBUCW_INCLUDES)
200 $(Q)$(BUILDSYS)/install-includes $(o)/ucw run/include/ucw autoconf.h
201 $(Q)sed -e 's/^#include "autoconf\.h"/#include <ucw\/autoconf.h>/' <$(s)/ucw/config.h >run/include/ucw/config.h
203 run/lib/pkgconfig/libucw.pc: $(o)/ucw/libucw.pc
205 ifdef CONFIG_UCW_PERL
206 include $(s)/ucw/perl/Makefile
209 ifdef CONFIG_UCW_SHELL_UTILS
210 include $(s)/ucw/shell/Makefile
215 INSTALL_TARGETS+=install-libucw-lib
217 install -d -m 755 $(DESTDIR)$(INSTALL_LIB_DIR)
218 install -m 644 run/lib/libucw$(LV).so.0 $(DESTDIR)$(INSTALL_LIB_DIR)/libucw$(LV).so.0.0
219 ln -sf libucw$(LV).so.0.0 $(DESTDIR)$(INSTALL_LIB_DIR)/libucw$(LV).so.0
220 .PHONY: install-libucw-lib
222 INSTALL_TARGETS+=install-libucw-api
223 install-libucw-api: install-ucw-sorter-api
224 install -d -m 755 $(DESTDIR)$(INSTALL_LIB_DIR) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/ $(DESTDIR)$(INSTALL_PKGCONFIG_DIR)
225 install -m 644 $(addprefix run/include/ucw/,$(LIBUCW_MAIN_INCLUDES) autoconf.h config.h) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/
226 install -m 644 run/lib/pkgconfig/libucw.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR)
227 ln -sf libucw$(LV).so.0.0 $(DESTDIR)$(INSTALL_LIB_DIR)/libucw$(LV).so
228 install -m 644 run/lib/libucw$(LV).a $(DESTDIR)$(INSTALL_LIB_DIR)
229 .PHONY: install-libucw-api
231 INSTALL_TARGETS+=install-libucw-config
232 install-libucw-config:
233 install -d -m 755 $(DESTDIR)$(INSTALL_CONFIG_DIR)
234 install -m 644 run/$(CONFIG_DIR)/libucw $(DESTDIR)$(INSTALL_CONFIG_DIR)
235 .PHONY: install-libucw-config