1 | ########################### |
---|
2 | ## Makefile for BitlBee ## |
---|
3 | ## ## |
---|
4 | ## Copyright 2002 Lintux ## |
---|
5 | ########################### |
---|
6 | |
---|
7 | ### DEFINITIONS |
---|
8 | |
---|
9 | -include Makefile.settings |
---|
10 | |
---|
11 | # Program variables |
---|
12 | objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_cap.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS) auth.o $(AUTH_OBJS) unix.o conf.o log.o |
---|
13 | allheaders = $(wildcard $(_SRCDIR_)*.h $(_SRCDIR_)lib/*.h $(_SRCDIR_)protocols/*.h) |
---|
14 | ifeq ($(EXTERNAL_JSON_PARSER),1) |
---|
15 | headers = $(filter-out $(_SRCDIR_)lib/json.h,$(allheaders)) |
---|
16 | else |
---|
17 | headers = $(allheaders) |
---|
18 | endif |
---|
19 | subdirs = lib protocols |
---|
20 | |
---|
21 | OUTFILE = bitlbee |
---|
22 | |
---|
23 | # Expansion of variables |
---|
24 | subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o) |
---|
25 | |
---|
26 | all: $(OUTFILE) $(OTR_PI) doc systemd |
---|
27 | |
---|
28 | doc: |
---|
29 | ifdef DOC |
---|
30 | $(MAKE) -C doc |
---|
31 | endif |
---|
32 | |
---|
33 | uninstall: uninstall-bin uninstall-doc |
---|
34 | @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n' |
---|
35 | |
---|
36 | install: install-bin install-doc install-plugins |
---|
37 | @echo |
---|
38 | @echo Installed successfully |
---|
39 | @echo |
---|
40 | ifndef SYSTEMDSYSTEMUNITDIR |
---|
41 | @if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi |
---|
42 | endif |
---|
43 | @if ! [ -e $(DESTDIR)$(ETCDIR)/bitlbee.conf ]; then echo -e '\nNo files are installed in '$(DESTDIR)$(ETCDIR)' by make install. Run make install-etc to do that.'; fi |
---|
44 | ifdef SYSTEMDSYSTEMUNITDIR |
---|
45 | @echo If you want to start BitlBee using systemd, try \"make install-systemd\". |
---|
46 | endif |
---|
47 | @echo To be able to compile third party plugins, run \"make install-dev\" |
---|
48 | @echo |
---|
49 | |
---|
50 | .PHONY: install install-bin install-etc install-doc install-plugins install-systemd install-dev \ |
---|
51 | uninstall uninstall-bin uninstall-etc uninstall-doc uninstall-etc \ |
---|
52 | all clean distclean tar $(subdirs) doc |
---|
53 | |
---|
54 | Makefile.settings: |
---|
55 | @echo |
---|
56 | @echo Run ./configure to create Makefile.settings, then rerun make |
---|
57 | @echo |
---|
58 | |
---|
59 | clean: $(subdirs) |
---|
60 | rm -f *.o $(OUTFILE) core utils/bitlbeed init/bitlbee*.service |
---|
61 | $(MAKE) -C tests clean |
---|
62 | |
---|
63 | distclean: clean $(subdirs) |
---|
64 | rm -rf .depend |
---|
65 | rm -f Makefile.settings config.h bitlbee.pc |
---|
66 | find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -exec rm -f {} \; |
---|
67 | @# May still be present in dirs of disabled protocols. |
---|
68 | -find . -name .depend -exec rm -rf {} \; |
---|
69 | $(MAKE) -C tests distclean |
---|
70 | |
---|
71 | check: all |
---|
72 | $(MAKE) -C tests |
---|
73 | |
---|
74 | gcov: check |
---|
75 | gcov *.c |
---|
76 | |
---|
77 | lcov: check |
---|
78 | lcov --directory . --capture --output-file bitlbee.info |
---|
79 | genhtml -o coverage bitlbee.info |
---|
80 | |
---|
81 | install-doc: |
---|
82 | ifdef DOC |
---|
83 | $(MAKE) -C doc install |
---|
84 | endif |
---|
85 | |
---|
86 | uninstall-doc: |
---|
87 | ifdef DOC |
---|
88 | $(MAKE) -C doc uninstall |
---|
89 | endif |
---|
90 | |
---|
91 | install-bin: |
---|
92 | mkdir -p $(DESTDIR)$(SBINDIR) |
---|
93 | $(INSTALL) -m 0755 $(OUTFILE) $(DESTDIR)$(SBINDIR)/$(OUTFILE) |
---|
94 | ifdef IMPLIB |
---|
95 | # import library for cygwin |
---|
96 | mkdir -p $(DESTDIR)$(LIBDIR) |
---|
97 | $(INSTALL) -m 0644 $(IMPLIB) $(DESTDIR)$(LIBDIR)/$(IMPLIB) |
---|
98 | endif |
---|
99 | |
---|
100 | uninstall-bin: |
---|
101 | rm -f $(DESTDIR)$(SBINDIR)/$(OUTFILE) |
---|
102 | ifdef IMPLIB |
---|
103 | rm -f $(DESTDIR)$(LIBDIR)/$(IMPLIB) |
---|
104 | endif |
---|
105 | |
---|
106 | install-dev: |
---|
107 | mkdir -p $(DESTDIR)$(INCLUDEDIR) |
---|
108 | $(INSTALL) -m 0644 config.h $(DESTDIR)$(INCLUDEDIR) |
---|
109 | for i in $(headers); do $(INSTALL) -m 0644 $$i $(DESTDIR)$(INCLUDEDIR); done |
---|
110 | mkdir -p $(DESTDIR)$(PCDIR) |
---|
111 | $(INSTALL) -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR) |
---|
112 | |
---|
113 | uninstall-dev: |
---|
114 | rm -f $(foreach hdr,$(headers),$(DESTDIR)$(INCLUDEDIR)/$(hdr)) |
---|
115 | -rmdir $(DESTDIR)$(INCLUDEDIR) |
---|
116 | rm -f $(DESTDIR)$(PCDIR)/bitlbee.pc |
---|
117 | |
---|
118 | install-etc: |
---|
119 | mkdir -p $(DESTDIR)$(ETCDIR) |
---|
120 | $(INSTALL) -m 0644 $(_SRCDIR_)motd.txt $(DESTDIR)$(ETCDIR)/motd.txt |
---|
121 | $(INSTALL) -m 0644 $(_SRCDIR_)bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf |
---|
122 | |
---|
123 | uninstall-etc: |
---|
124 | rm -f $(DESTDIR)$(ETCDIR)/motd.txt |
---|
125 | rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf |
---|
126 | -rmdir $(DESTDIR)$(ETCDIR) |
---|
127 | |
---|
128 | install-plugins: install-plugin-otr |
---|
129 | |
---|
130 | install-plugin-otr: |
---|
131 | ifdef OTR_PI |
---|
132 | mkdir -p $(DESTDIR)$(PLUGINDIR) |
---|
133 | $(INSTALL) -m 0755 otr.so $(DESTDIR)$(PLUGINDIR) |
---|
134 | endif |
---|
135 | |
---|
136 | systemd: |
---|
137 | ifdef SYSTEMDSYSTEMUNITDIR |
---|
138 | mkdir -p init |
---|
139 | sed 's|@sbindir@|$(SBINDIR)|' $(_SRCDIR_)init/bitlbee.service.in > init/bitlbee.service |
---|
140 | sed 's|@sbindir@|$(SBINDIR)|' $(_SRCDIR_)init/bitlbee@.service.in > init/bitlbee@.service |
---|
141 | endif |
---|
142 | |
---|
143 | install-systemd: systemd |
---|
144 | ifdef SYSTEMDSYSTEMUNITDIR |
---|
145 | mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
146 | $(INSTALL) -m 0644 init/bitlbee.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
147 | $(INSTALL) -m 0644 init/bitlbee@.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
148 | $(INSTALL) -m 0644 $(_SRCDIR_)init/bitlbee.socket $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
149 | else |
---|
150 | @echo SYSTEMDSYSTEMUNITDIR not set, not installing systemd unit files. |
---|
151 | endif |
---|
152 | |
---|
153 | ifdef SYSUSERSDIR |
---|
154 | $(INSTALL) -Dm644 init/bitlbee.sysusers $(DESTDIR)/$(SYSUSERSDIR)/bitlbee.conf |
---|
155 | else |
---|
156 | @echo SYSUSERSDIR not set, not install sysusers.d files |
---|
157 | endif |
---|
158 | |
---|
159 | tar: |
---|
160 | fakeroot debian/rules clean || make distclean |
---|
161 | x=$$(basename $$(pwd)); \ |
---|
162 | cd ..; \ |
---|
163 | tar czf $$x.tar.gz --exclude=debian --exclude=.git* --exclude=.depend $$x |
---|
164 | |
---|
165 | $(subdirs): |
---|
166 | $(MAKE) -C $@ $(MAKECMDGOALS) |
---|
167 | |
---|
168 | $(OTR_PI): %.so: $(_SRCDIR_)%.c |
---|
169 | @echo '*' Building plugin $@ |
---|
170 | $(VERBOSE) $(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@ $(OTRFLAGS) |
---|
171 | |
---|
172 | $(objects): %.o: $(_SRCDIR_)%.c |
---|
173 | @echo '*' Compiling $< |
---|
174 | $(VERBOSE) $(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@ |
---|
175 | |
---|
176 | $(objects): Makefile Makefile.settings config.h |
---|
177 | |
---|
178 | $(OUTFILE): $(objects) $(subdirs) |
---|
179 | @echo '*' Linking $(OUTFILE) |
---|
180 | $(VERBOSE) $(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LDFLAGS_BITLBEE) $(LDFLAGS) $(EFLAGS) |
---|
181 | ifneq ($(firstword $(STRIP)), \#) |
---|
182 | @echo '*' Stripping $(OUTFILE) |
---|
183 | $(VERBOSE) -$(STRIP) $(OUTFILE) |
---|
184 | endif |
---|
185 | |
---|
186 | ctags: |
---|
187 | ctags `find . -name "*.c"` `find . -name "*.h"` |
---|
188 | |
---|
189 | # Using this as a bogus Make target to test if a GNU-compatible version of |
---|
190 | # make is available. |
---|
191 | helloworld: |
---|
192 | @echo Hello World |
---|
193 | |
---|
194 | # Check if we can load the helpfile. (This fails if some article is >1KB.) |
---|
195 | # If print returns a NULL pointer, the file is unusable. |
---|
196 | testhelp: doc |
---|
197 | gdb --eval-command='b main' --eval-command='r' \ |
---|
198 | --eval-command='print help_init(&global->helpfile, "doc/user-guide/help.txt")' \ |
---|
199 | $(OUTFILE) < /dev/null |
---|
200 | |
---|
201 | -include .depend/*.d |
---|
202 | # DO NOT DELETE |
---|