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