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