WSANOTINITIALISED is an okay error when shutting down WvStreams in win32.
[wvstreams.git] / Makefile
blob1989ace69bac8c09444bb88f5da2b96886dde0fc
1 WVSTREAMS=.
3 include wvrules.mk
5 ifdef _WIN32
6 include win32.mk
7 endif
9 %: %.subst
10 sed -e 's/#VERSION#/$(WVPACKAGE_VERSION)/g' < $< > $@
12 ifeq ("$(enable_testgui)", "no")
13 WVTESTRUN=env
14 endif
16 LIBS += $(LIBS_XPLC) -lm
18 ifeq ($(USE_WVSTREAMS_ARGP),1)
19 utils/wvargs.o-CPPFLAGS += -Iargp
20 libwvutils.so-LIBS += -Largp -largp
21 libwvstatic.a-LIBS += -Largp -largp
22 libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c \
23 argp-help.c argp-parse.c argp-pv.c \
24 argp-pvh.c
25 argp_Os=$(patsubst %.c,%.o,$(libargp_a_SOURCES)) \
26 $(shell grep "^LIBOBJS" argp/Makefile | cut -d" " -f1-3 --complement)
27 argp_OBJS=$(patsubst %,argp/%,$(argp_Os))
29 # argp does its own dependency checking, so let's call it once per wvstreams
30 # build, in case some system dependencies have changed and argp should be
31 # recompiled
32 .PHONY: .argp-phony
33 .argp-phony:
34 @$(MAKE) -C argp
35 $(argp_OBJS): .argp-phony
36 @echo -n
37 else
38 argp_OBJS=
39 endif
42 # libwvbase: a the minimal code needed to link a wvstreams program.
44 BASEOBJS = \
45 utils/wvbuffer.o utils/wvbufferstore.o \
46 utils/wvcont.o \
47 utils/wverror.o \
48 streams/wvfdstream.o \
49 utils/wvfork.o \
50 utils/wvhash.o \
51 utils/wvhashtable.o \
52 utils/wvlinklist.o \
53 utils/wvmoniker.o \
54 utils/wvregex.o \
55 utils/wvscatterhash.o utils/wvsorter.o \
56 utils/wvattrs.o \
57 utils/wvstring.o utils/wvstringlist.o \
58 utils/wvstringmask.o \
59 utils/strutils.o \
60 utils/wvtask.o \
61 utils/wvtimeutils.o \
62 streams/wvistreamlist.o \
63 utils/wvstreamsdebugger.o \
64 streams/wvlog.o \
65 streams/wvstream.o \
66 uniconf/uniconf.o \
67 uniconf/uniconfgen.o uniconf/uniconfkey.o uniconf/uniconfroot.o \
68 uniconf/unihashtree.o \
69 uniconf/unimountgen.o \
70 uniconf/unitempgen.o \
71 utils/wvbackslash.o \
72 utils/wvencoder.o \
73 utils/wvtclstring.o \
74 utils/wvstringcache.o \
75 uniconf/uniinigen.o \
76 uniconf/unigenhack.o \
77 uniconf/unilistiter.o \
78 streams/wvfile.o \
79 streams/wvstreamclone.o \
80 streams/wvconstream.o \
81 utils/wvcrashbase.o
82 TARGETS += libwvbase.so
83 libwvbase_OBJS += $(filter-out uniconf/unigenhack.o $(WV_EXCLUDES),$(BASEOBJS))
84 libwvbase.so: $(libwvbase_OBJS) uniconf/unigenhack.o
85 libwvbase.so-LIBS += $(LIBXPLC)
88 # libwvutils: handy utility library for C++
90 TARGETS += libwvutils.so
91 TESTS += $(call tests_cc,utils/tests)
92 libwvutils_OBJS += $(filter-out $(BASEOBJS) $(TESTOBJS),$(call objects,utils))
93 libwvutils.so: $(libwvutils_OBJS) $(LIBWVBASE) $(argp_OBJS)
94 libwvutils.so-LIBS += -lz -lcrypt $(LIBS_PAM)
95 utils/tests/%: PRELIBS+=$(LIBWVSTREAMS)
98 # libwvstreams: stream/event handling library
100 TARGETS += libwvstreams.so
101 TARGETS += crypto/tests/ssltest ipstreams/tests/unixtest
102 TARGETS += crypto/tests/printcert
103 ifneq ("$(with_readline)", "no")
104 TARGETS += ipstreams/tests/wsd
105 ipstreams/tests/wsd-LIBS += -lreadline
106 else
107 TEST_SKIP_OBJS += ipstreams/tests/wsd
108 endif
109 TESTS += $(call tests_cc,configfile/tests)
110 TESTS += $(call tests_cc,streams/tests)
111 TESTS += $(call tests_cc,ipstreams/tests)
112 TESTS += $(call tests_cc,crypto/tests)
113 TESTS += $(call tests_cc,urlget/tests)
114 TESTS += $(call tests_cc,linuxstreams/tests)
115 libwvstreams_OBJS += $(filter-out $(BASEOBJS), \
116 $(call objects,configfile crypto ipstreams \
117 $(ARCH_SUBDIRS) streams urlget))
118 libwvstreams.so: $(libwvstreams_OBJS) $(LIBWVUTILS)
119 libwvstreams.so-LIBS += -lz -lssl -lcrypto $(LIBS_PAM)
120 configfile/tests/% streams/tests/% ipstreams/tests/% crypto/tests/% \
121 urlget/tests/% linuxstreams/tests/%: PRELIBS+=$(LIBWVSTREAMS)
124 # libuniconf: unified configuration system
126 TARGETS += libuniconf.so
127 TARGETS += uniconf/daemon/uniconfd uniconf/tests/uni
128 TESTS += $(call tests_cc,uniconf/tests) uniconf/tests/uni
129 libuniconf_OBJS += $(filter-out $(BASEOBJS) uniconf/daemon/uniconfd.o, \
130 $(call objects,uniconf uniconf/daemon))
131 libuniconf.so: $(libuniconf_OBJS) $(LIBWVSTREAMS)
132 uniconf/daemon/uniconfd uniconf/tests/uni: $(LIBUNICONF)
133 uniconf/daemon/uniconfd: uniconf/daemon/uniconfd.o $(LIBUNICONF)
134 uniconf/daemon/uniconfd: uniconf/daemon/uniconfd.ini \
135 uniconf/daemon/uniconfd.8
136 uniconf/tests/%: PRELIBS+=$(LIBUNICONF)
139 # libwvdbus: C++ DBus library based on wvstreams
141 ifneq ("$(with_dbus)", "no")
142 TARGETS += libwvdbus.so
143 TARGETS += dbus/tests/wvdbus dbus/tests/wvdbusd
144 TESTS += $(call tests_cc,dbus/tests)
145 libwvdbus_OBJS += $(call objects,dbus)
146 libwvdbus.so: $(libwvdbus_OBJS) $(LIBWVSTREAMS)
147 libwvdbus.so-LIBS += $(LIBS_DBUS)
148 dbus/tests/%: PRELIBS+=$(LIBWVDBUS)
149 else
150 TEST_SKIP_OBJS += dbus/t/%
151 endif
154 # libwvqt: helper library to make WvStreams work better in Qt event loops
156 ifneq ("$(with_qt)", "no")
157 TARGETS += libwvqt.so
158 TESTS += $(patsubst %.cc,%,$(wildcard qt/tests/*.cc))
159 libwvqt_OBJS += $(call objects,qt)
160 libwvqt.so: $(libwvqt_OBJS) $(LIBWVSTREAMS)
161 libwvqt.so-LIBS += $(LIBS_QT)
162 qt/tests/%: PRELIBS+=$(LIBWVQT)
164 qt/wvqtstreamclone.o: include/wvqtstreamclone.moc
165 qt/wvqthook.o: include/wvqthook.moc
166 endif
169 # libwvstatic.a: all the wvstreams libraries in one static .a file, to make
170 # it easy to link your programs statically to wvstreams.
172 TARGETS += libwvstatic.a
173 libwvstatic.a: \
174 $(libwvbase_OBJS) \
175 $(libwvutils_OBJS) \
176 $(libwvstreams_OBJS) \
177 $(libuniconf_OBJS) \
178 $(libwvdbus_OBJS) \
179 $(libwvqt_OBJS) \
180 uniconf/unigenhack_s.o \
181 $(argp_OBJS)
184 # libwvtest: the WvTest tools for writing C++ unit tests
186 TARGETS += wvtestmain.o libwvtest.a
187 TESTOBJS = utils/wvtest.o
188 libwvtest.a: wvtestmain.o $(TESTOBJS)
191 # Some example programs
193 TARGETS += examples/wvgrep/wvgrep examples/wvgrep/wvegrep
194 examples/wvgrep/wvgrep: examples/wvgrep/wvgrep.o $(LIBWVSTREAMS)
195 examples/wvgrep/wvegrep: examples/wvgrep/wvgrep
196 ln -f $< $@
199 TARGETS_SO = $(filter %.so,$(TARGETS))
200 TARGETS_A = $(filter %.a,$(TARGETS))
202 all: $(filter-out $(WV_EXCLUDES), $(TARGETS))
204 TESTS += wvtestmain
206 REAL_TESTS = $(filter-out $(TEST_SKIP_OBJS), $(TESTS))
207 $(addsuffix .o,$(REAL_TESTS)):
208 tests: $(REAL_TESTS)
210 test: all tests qtest
212 qtest: all wvtestmain
213 LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(WVSTREAMS_LIB)" $(WVTESTRUN) $(MAKE) runtests
215 runtests:
216 $(VALGRIND) ./wvtestmain '$(TESTNAME)'
217 ifeq ("$(TESTNAME)", "")
218 cd uniconf/tests && DAEMON=0 ./unitest.sh
219 cd uniconf/tests && DAEMON=1 ./unitest.sh
220 endif
222 wvtestmain: \
223 $(filter-out $(TEST_SKIP_OBJS), $(call objects, $(filter-out win32/%, \
224 $(shell find . -type d -name t -printf "%P\n")))) \
225 $(LIBWVDBUS) $(LIBUNICONF) $(LIBWVSTREAMS) $(LIBWVTEST)
227 distclean: clean
228 rm -f uniconf/daemon/uniconfd.8 uniconf/tests/uni
229 rm -f config.mk config.log config.status \
230 include/wvautoconf.h config.cache reconfigure \
231 stamp-h.in configure include/wvautoconf.h.in
232 rm -rf autom4te.cache
233 rm -f pkgconfig/*.pc
235 clean:
236 $(subdirs)
237 @rm -fv .junk $(TARGETS) uniconf/daemon/uniconfd \
238 $(TESTS) tmp*.ini uniconf/daemon/uniconfd.ini \
239 .wvtest-total \
240 $(shell find . -name '*.o' -o -name '.*.d' \
241 -o -name '*~' -o -name '*.moc')
243 clean-targets:
244 rm -fv $(TARGETS)
246 clean-tests:
247 rm -fv $(TESTS)
249 kdoc:
250 kdoc -f html -d Docs/kdoc-html --name wvstreams --strip-h-path */*.h
252 doxygen:
253 doxygen
255 .PHONY: \
256 clean distclean \
257 kdoc doxygen \
258 install install-shared install-dev uninstall \
259 tests test