Merge fix for logging of mode changes by charly.
[jelmer/ctrlproxy.git] / Makefile
1 # Makefile for ctrlproxy
2 # Copyright (C) 2002-2009 Jelmer Vernooij <jelmer@samba.org>
3 # NOTE: This file is *NOT* autogenerated.
4
5 include Makefile.settings
6
7 BINS += ctrlproxy$(EXEEXT)
8 SBINS += ctrlproxyd$(EXEEXT)
9
10 GCOV = gcov
11
12 ifeq ($(WITH_GCOV),1)
13 CFLAGS += --coverage
14 LIBS += --coverage
15 endif
16
17 LIBS += $(GNUTLS_LIBS)
18 CFLAGS += $(GNUTLS_CFLAGS)
19
20 CFLAGS+=-DHAVE_CONFIG_H -DDEFAULT_CONFIG_DIR=\"$(DEFAULT_CONFIG_DIR)\" -DHELPFILE=\"$(HELPFILE)\"
21 CFLAGS+=-DMODULESDIR=\"$(modulesdir)\" -DSTRICT_MEMORY_ALLOCS=
22
23 .PHONY: all clean distclean install install-bin install-dirs install-doc install-data install-pkgconfig
24
25 all:: $(BINS) $(SBINS)
26
27 ifeq ($(HAVE_PYTHON),yes)
28 check:: check-python
29 all:: python
30 endif
31
32 experimental:: all 
33
34 doxygen:
35         doxygen
36
37 libircdir = libirc
38 include $(libircdir)/Makefile
39
40 objs = src/posix.o \
41            src/redirect.o \
42            src/cache.o \
43            src/util.o \
44            src/hooks.o \
45            src/plugins.o \
46            src/settings.o \
47            src/log.o \
48            src/client.o \
49            src/gen_config.o \
50            src/repl.o \
51            src/ctcp_redirect.o \
52            src/ctcp.o \
53            src/motd.o \
54            src/nickserv.o \
55            src/keyfile.o \
56            src/admin.o \
57            src/user.o \
58            src/help.o \
59            src/repl_backends.o \
60            src/listener.o \
61            src/log_support.o \
62            src/log_custom.o \
63            src/log_subst.o \
64            src/auto_away.o \
65            src/network.o \
66            $(CTRLPROXY_SSL_OBJS)
67 all_objs += $(objs)
68
69 headers = src/admin.h \
70                   src/ctcp.h \
71                   src/ctrlproxy.h \
72                   src/hooks.h \
73                   src/log_support.h \
74                   src/repl.h \
75                   src/settings.h \
76                   src/ssl.h \
77                   src/log.h \
78                   src/cache.h
79 dep_files = $(patsubst %.o, %.d, $(objs))
80
81 ctrlproxy$(EXEEXT): src/main.o $(objs) $(LIBIRC)
82         @echo Linking $@: $(LD) $(LDFLAGS) -rdynamic -o $@ $^ $(LIBS)
83         @$(LD) $(LDFLAGS) $(DYNAMIC) -o $@ $^ $(LIBS)
84
85 src/settings.o: CFLAGS+=-DSYSCONFDIR=\"${sysconfdir}\"
86
87 daemon/main.o: CFLAGS+=-DDEFAULT_CONFIG_FILE=\"${sysconfdir}/ctrlproxyd.conf\" \
88                            -DSSL_CREDENTIALS_DIR=\"${sysconfdir}/ctrlproxy/ssl\" \
89                                            -DPIDFILE=\"${localstatedir}/run/ctrlproxyd.pid\"
90
91 daemon_objs += daemon/main.o daemon/user.o daemon/client.o daemon/backend.o
92
93 ctrlproxyd$(EXEEXT): $(daemon_objs) $(objs) $(LIBIRC)
94         @echo Linking $@
95         @$(CC) $(LDFLAGS) $(DYNAMIC) -o $@ $^ $(LIBS)
96
97 ctrlproxy-admin$(EXEEXT): src/admin-cmd.o
98         @echo Linking $@
99         @$(CC) $(LDFLAGS) $(DYNAMIC) -o $@ $^ $(LIBS)
100
101 %.o: %.c
102         @echo Compiling $<
103         @$(CC) -I. -I$(libircdir) -Isrc $(CFLAGS) $(GCOV_CFLAGS) -c $< -o $@
104
105 %.d: %.c config.h
106         @$(CC) -I. -I$(libircdir) -Isrc -M -MT $(<:.c=.o) $(CFLAGS) $(PYTHON_CFLAGS) $< -o $@
107
108 # This looks a bit weird but is here to ensure that we never try to 
109 # run ./autogen.sh outside of bzr checkouts
110 ifeq ($(BZR_CHECKOUT),yes)
111 configure: autogen.sh configure.ac acinclude.m4
112         ./$<
113 else
114 configure:
115         ./autogen.sh
116 endif
117
118 ctrlproxy.pc Makefile.settings config.h: configure Makefile.settings.in ctrlproxy.pc.in
119         ./$<
120
121 install: all install-dirs install-bin install-header install-data install-pkgconfig $(EXTRA_INSTALL_TARGETS)
122 install-dirs:
123         $(INSTALL) -d $(DESTDIR)$(modulesdir)
124
125 uninstall: uninstall-bin uninstall-header uninstall-data uninstall-pkgconfig $(patsubst install-%,uninstall-%,$(EXTRA_INSTALL_TARGETS))
126 uninstall-bin:
127         -rm -f $(DESTDIR)$(bindir)/ctrlproxy$(EXEEXT) \
128                    $(DESTDIR)$(bindir)/ctrlproxy-admin$(EXEEXT) \
129                    $(DESTDIR)$(sbindir)/ctrlproxyd$(EXEEXT)
130         -rmdir $(DESTDIR)$(bindir)
131         -rmdir $(DESTDIR)$(sbindir)
132         -rmdir $(DESTDIR)$(modulesdir)
133
134 install-bin:
135         $(INSTALL) -d $(DESTDIR)$(bindir)
136         $(INSTALL) -d $(DESTDIR)$(sbindir)
137         $(INSTALL) $(BINS) $(DESTDIR)$(bindir)
138         $(INSTALL) $(SBINS) $(DESTDIR)$(sbindir)
139
140 uninstall-header:
141         -rm -f $(patsubst %,$(DESTDIR)$(destincludedir)/%,$(notdir $(headers) $(libirc_headers)))
142         -rmdir $(DESTDIR)$(destincludedir)
143
144 install-header::
145         $(INSTALL) -d $(DESTDIR)$(destincludedir)
146         $(INSTALL) -m 0644 $(libirc_headers) $(headers) $(DESTDIR)$(destincludedir)
147
148 doc::
149         $(MAKE) -C doc PACKAGE_VERSION=$(PACKAGE_VERSION)
150
151 install-doc:: doc
152         $(INSTALL) -d $(DESTDIR)$(docdir)
153         $(MAKE) -C doc install PACKAGE_VERSION=$(PACKAGE_VERSION)
154
155 uninstall-doc: 
156         $(MAKE) -C doc uninstall
157         -rmdir $(DESTDIR)$(docdir)
158
159 uninstall-data::
160         -rm -f $(DESTDIR)$(DEFAULT_CONFIG_DIR)/motd
161         -rm -f $(DESTDIR)$(DEFAULT_CONFIG_DIR)/config
162         -rmdir $(DESTDIR)$(DEFAULT_CONFIG_DIR)
163         -rmdir $(DESTDIR)$(sysconfdir)
164
165 install-data:
166         $(INSTALL) -d $(DESTDIR)$(sysconfdir)
167         $(INSTALL) -d $(DESTDIR)$(DEFAULT_CONFIG_DIR)
168         $(INSTALL) -m 0644 motd $(DESTDIR)$(DEFAULT_CONFIG_DIR)
169         $(INSTALL) -m 0644 config.default $(DESTDIR)$(DEFAULT_CONFIG_DIR)/config
170
171 install-pkgconfig:
172         $(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig
173         $(INSTALL) -m 0644 ctrlproxy.pc $(DESTDIR)$(libdir)/pkgconfig
174
175 uninstall-pkgconfig:
176         -rm -f $(DESTDIR)$(libdir)/pkgconfig/ctrlproxy.pc
177         -rmdir $(DESTDIR)$(libdir)/pkgconfig
178
179 gcov: check
180         $(GCOV) -f -p -o src/ src/*.c 
181
182 lcov:
183         lcov --base-directory `pwd` --directory . --capture --output-file ctrlproxy.info
184         genhtml -o coverage ctrlproxy.info
185
186 %.$(SHLIBEXT):
187         @echo Linking $@
188         @$(CC) -shared $(LDFLAGS) -o $@ $^
189
190 cscope.out::
191         cscope -b -R
192
193 clean::
194         @echo Removing object files and executables
195         @rm -f src/*.o daemon/*.o python/*.o testsuite/check ctrlproxy$(EXEEXT) testsuite/*.o *~
196         @rm -f ctrlproxy-admin$(EXEEXT)
197         @rm -f ctrlproxyd$(EXEEXT)
198         @rm -f mods/*.$(SHLIBEXT) mods/*.o
199         @echo Removing gcov output
200         @rm -f *.gcov *.gcno *.gcda  */*.gcda */*.gcno */*.gcov
201         @echo Removing test output
202         @rm -rf test-*
203
204 doc-dist:: configure
205         $(MAKE) -C doc dist
206
207 dist: configure doc-dist distclean
208
209 distclean:: clean 
210         rm -f build config.h ctrlproxy.pc *.log
211         rm -rf autom4te.cache/ config.log config.status
212
213 realclean:: distclean
214         @$(MAKE) -C doc clean
215
216 ctags:
217         ctags -R .
218
219 # Python specific stuff below this line
220 mods/python.o python/ctrlproxy.o: CFLAGS+=$(PYTHON_CFLAGS)
221 mods/python.o python/ctrlproxy.o: CFLAGS+=-fPIC
222 mods/libpython.so: mods/python.o python/ctrlproxy.o $(pyirc_objs)
223 mods/libpython.so: LDFLAGS+=$(PYTHON_LDFLAGS)
224
225 ifeq ($(HAVE_PYTHON),yes)
226 all_objs += $(pyirc_objs) mods/python.o python/ctrlproxy.o
227 endif
228
229 python:: mods/libpython.$(SHLIBEXT)
230
231 install-python: all
232         $(PYTHON) setup.py install --root="$(DESTDIR)"
233
234 clean::
235         @rm -f python/tests/*.pyc
236 #       $(PYTHON) setup.py clean
237
238 # RFC compliance testing using ircdtorture
239
240 TEST_SERVER := localhost
241 TEST_PORT := 6667
242
243 testsuite/ctrlproxyrc.torture: testsuite/ctrlproxyrc.torture.in
244         sed -e 's/@SERVER@/$(TEST_SERVER)/;s/@PORT@/$(TEST_PORT)/;' < $< > $@
245
246 rfctest: testsuite/ctrlproxyrc.torture
247         @$(IRCDTORTURE) -- ./ctrlproxy -d 0 -i TEST -r $<
248
249 # Unit tests
250 check_objs = testsuite/test-cmp.o testsuite/test-user.o \
251                          testsuite/test-admin.o testsuite/test-isupport.o \
252                          testsuite/test-parser.o testsuite/test-state.o \
253                          testsuite/test-util.o testsuite/test-line.o \
254                          testsuite/torture.o testsuite/test-linestack.o \
255                          testsuite/test-client.o testsuite/test-network.o \
256                          testsuite/test-tls.o testsuite/test-redirect.o \
257                          testsuite/test-networkinfo.o testsuite/test-ctcp.o \
258                          testsuite/test-help.o testsuite/test-nickserv.o \
259                          testsuite/test-url.o testsuite/test-motd.o \
260                          testsuite/test-log-subst.o testsuite/test-transport.o
261
262 testsuite/check: $(check_objs) $(objs) $(LIBIRC)
263         @echo Linking $@
264         @$(CC) $(LIBS) -o $@ $^ $(CHECK_LIBS)
265
266 check:: testsuite/check
267         @echo Running testsuite
268         @$(DEBUGGER) ./testsuite/check $(CHECK_OPTIONS)
269
270 check-nofork:: 
271         $(MAKE) check CHECK_OPTIONS=-nsv
272
273 check-gdb: 
274         $(MAKE) check-nofork DEBUGGER="gdb --args"
275
276 clean::
277         @echo Removing dependency files
278         @rm -f $(dep_files)
279
280 examples:: example/libfoo.$(SHLIBEXT) example/libirc-simple
281
282 example/libfoo.$(SHLIBEXT): example/foo.o
283 example/foo.o: CFLAGS+=-I$(libircdir)
284
285 example/libirc-simple: example/irc_simple.o $(LIBIRC)
286         @Linking $@
287         @$(CC) -o $@ $^
288
289 example/irc_simple.o: CFLAGS+=-I$(libircdir)
290
291 ifeq ($(GCC),yes)
292 -include $(dep_files)
293 endif