1 # Makefile for the UCW Library (c) 1997--2009 Martin Mares <mj@ucw.cz>
4 LIBUCW=$(o)/ucw/libucw.pc
7 include $(s)/ucw/utils/Makefile
12 alloc alloc_str realloc bigalloc mempool mempool-str mempool-fmt eltpool \
13 mmap partmap hashfunc \
14 slists simple-lists bitsig \
15 log log-stream log-file log-syslog log-conf proctitle tbf \
16 conf-alloc conf-dump conf-input conf-intr conf-journal conf-parse conf-section \
19 fastbuf ff-binary ff-string ff-printf ff-unicode ff-stkstring \
20 fb-file carefulio fb-mem fb-temp tempfile fb-mmap fb-limfd fb-buffer fb-grow fb-pool fb-atomic fb-param fb-socket \
21 char-cat char-upper char-lower unicode stkstring \
23 prime primetable random timer randomkey \
26 mainloop exitstatus runcmd sighandler \
27 lizard lizard-safe adler32 \
32 string str-esc str-split str-match str-imatch str-hex \
37 LIBUCW_MAIN_INCLUDES= \
38 lib.h log.h threads.h \
40 clists.h slists.h simple-lists.h \
41 string.h stkstring.h unicode.h chartype.h regex.h \
43 unaligned.h prefetch.h \
44 bbuf.h gbuf.h bitarray.h bitsig.h \
45 hashfunc.h hashtable.h \
46 heap.h binheap.h binheap-node.h \
50 conf.h getopt.h ipaccess.h \
52 fastbuf.h lfs.h ff-unicode.h ff-binary.h \
59 kmp.h kmp-search.h binsearch.h \
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
69 ifdef CONFIG_UCW_FB_DIRECT
70 LIBUCW_MODS+=fb-direct
73 ifdef CONFIG_OWN_GETOPT
74 include $(s)/ucw/getopt/Makefile
77 LIBUCW_INCLUDES=$(LIBUCW_MAIN_INCLUDES)
79 include $(s)/ucw/sorter/Makefile
80 include $(s)/ucw/doc/Makefile
82 LIBUCW_MOD_PATHS=$(addprefix $(o)/ucw/,$(LIBUCW_MODS))
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))
88 $(o)/ucw/hashfunc.o $(o)/ucw/hashfunc.oo: CFLAGS += -funroll-loops
89 $(o)/ucw/lizard.o: CFLAGS += $(COPT2) -funroll-loops
91 $(o)/ucw/conf-test: $(o)/ucw/conf-test.o $(LIBUCW)
92 $(o)/ucw/lfs-test: $(o)/ucw/lfs-test.o $(LIBUCW)
93 $(o)/ucw/hash-test: $(o)/ucw/hash-test.o $(LIBUCW)
94 $(o)/ucw/hashfunc-test: $(o)/ucw/hashfunc-test.o $(LIBUCW)
95 $(o)/ucw/asort-test: $(o)/ucw/asort-test.o $(LIBUCW)
96 $(o)/ucw/redblack-test: $(o)/ucw/redblack-test.o $(LIBUCW)
97 $(o)/ucw/binheap-test: $(o)/ucw/binheap-test.o $(LIBUCW)
98 $(o)/ucw/lizard-test: $(o)/ucw/lizard-test.o $(LIBUCW)
99 $(o)/ucw/kmp-test: $(o)/ucw/kmp-test.o $(LIBUCW)
100 $(o)/ucw/strtonum-test: $(o)/ucw/strtonum-test.o $(LIBUCW)
102 $(o)/ucw/kmp-test: $(LIBCHARSET)
104 $(o)/ucw/ipaccess-test: $(o)/ucw/ipaccess-test.o $(LIBUCW)
105 $(o)/ucw/trie-test: $(o)/ucw/trie-test.o $(LIBUCW)
107 TESTS+=$(addprefix $(o)/ucw/,regex.test unicode.test hash-test.test mempool.test stkstring.test \
108 slists.test bbuf.test kmp-test.test getopt.test ff-unicode.test eltpool.test \
109 fb-socket.test trie-test.test string.test sha1.test asort-test.test binheap-test.test \
110 redblack-test.test fb-file.test fb-grow.test fb-pool.test fb-atomic.test \
111 fb-limfd.test fb-temp.test fb-mem.test fb-buffer.test fb-mmap.test url.test strtonum-test.test)
113 $(o)/ucw/regex.test: $(o)/ucw/regex-t
114 $(o)/ucw/unicode.test: $(o)/ucw/unicode-t
115 $(o)/ucw/hash-test.test: $(o)/ucw/hash-test
116 $(o)/ucw/mempool.test: $(o)/ucw/mempool-t $(o)/ucw/mempool-fmt-t $(o)/ucw/mempool-str-t
117 $(o)/ucw/stkstring.test: $(o)/ucw/stkstring-t
118 $(o)/ucw/bitops.test: $(o)/ucw/bit-ffs-t $(o)/ucw/bit-fls-t
119 $(o)/ucw/slists.test: $(o)/ucw/slists-t
120 $(o)/ucw/kmp-test.test: $(o)/ucw/kmp-test
121 $(o)/ucw/bbuf.test: $(o)/ucw/bbuf-t
122 $(o)/ucw/getopt.test: $(o)/ucw/getopt-t
123 $(o)/ucw/ff-unicode.test: $(o)/ucw/ff-unicode-t
124 $(o)/ucw/eltpool.test: $(o)/ucw/eltpool-t
125 $(o)/ucw/string.test: $(o)/ucw/str-hex-t $(o)/ucw/str-esc-t
126 $(o)/ucw/sha1.test: $(o)/ucw/sha1-t $(o)/ucw/sha1-hmac-t
127 $(o)/ucw/trie-test.test: $(o)/ucw/trie-test
128 $(o)/ucw/asort-test.test: $(o)/ucw/asort-test
129 $(o)/ucw/binheap-test.test: $(o)/ucw/binheap-test
130 $(o)/ucw/redblack-test.test: $(o)/ucw/redblack-test
131 $(o)/ucw/strtonum-test.test: $(o)/ucw/strtonum-test
132 $(addprefix $(o)/ucw/fb-,file.test grow.test pool.test socket.test atomic.test \
133 limfd.test temp.test mem.test buffer.test mmap.test): %.test: %-t
134 $(o)/ucw/url.test: $(o)/ucw/url-t
136 ifdef CONFIG_UCW_THREADS
137 TESTS+=$(addprefix $(o)/ucw/,asio.test)
138 $(o)/ucw/asio.test: $(o)/ucw/asio-t
141 # The version of autoconf.h that is a part of the public API needs to have
142 # the internal symbols filtered out, so we generate ucw/autoconf.h in the
143 # configure script and let the public config.h refer to <ucw/autoconf.h>
144 # instead of plain "autoconf.h".
147 API_INCLUDES+=$(o)/ucw/.include-stamp
148 $(o)/ucw/.include-stamp: $(addprefix $(s)/ucw/,$(LIBUCW_INCLUDES)) $(o)/ucw/autoconf.h
149 $(Q)$(BUILDSYS)/install-includes $(<D) run/include/ucw $(LIBUCW_INCLUDES)
150 $(Q)$(BUILDSYS)/install-includes $(o)/ucw run/include/ucw autoconf.h
151 $(Q)sed -e 's/^#include "autoconf\.h"/#include <ucw\/autoconf.h>/' <$(s)/ucw/config.h >run/include/ucw/config.h
153 run/lib/pkgconfig/libucw.pc: $(o)/ucw/libucw.pc
155 ifdef CONFIG_UCW_PERL
156 include $(s)/ucw/perl/Makefile
159 ifdef CONFIG_UCW_SHELL_UTILS
160 include $(s)/ucw/shell/Makefile
165 INSTALL_TARGETS+=install-libucw
167 install -d -m 755 $(DESTDIR)$(INSTALL_LIB_DIR) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/ $(DESTDIR)$(INSTALL_PKGCONFIG_DIR) $(DESTDIR)$(INSTALL_CONFIG_DIR)
168 install -m 644 $(addprefix run/include/ucw/,$(LIBUCW_MAIN_INCLUDES) autoconf.h config.h) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/
169 install -m 644 run/lib/pkgconfig/libucw.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR)
170 install -m 644 run/lib/libucw.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR)
171 install -m 644 run/$(CONFIG_DIR)/libucw $(DESTDIR)$(INSTALL_CONFIG_DIR)
173 .PHONY: install-libucw