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