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_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) |
---|
13 | headers = $(wildcard *.h lib/*.h protocols/*.h) |
---|
14 | subdirs = lib protocols |
---|
15 | |
---|
16 | ifeq ($(TARGET),i586-mingw32msvc) |
---|
17 | objects += win32.o |
---|
18 | LDFLAGS+=-lws2_32 |
---|
19 | EFLAGS+=-lsecur32 |
---|
20 | OUTFILE=bitlbee.exe |
---|
21 | else |
---|
22 | objects += unix.o conf.o log.o |
---|
23 | OUTFILE=bitlbee |
---|
24 | endif |
---|
25 | |
---|
26 | # Expansion of variables |
---|
27 | subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o) |
---|
28 | |
---|
29 | all: $(OUTFILE) $(OTR_PI) $(SKYPE_PI) doc systemd |
---|
30 | ifdef SKYPE_PI |
---|
31 | $(MAKE) -C protocols/skype doc |
---|
32 | endif |
---|
33 | |
---|
34 | doc: |
---|
35 | $(MAKE) -C doc |
---|
36 | |
---|
37 | uninstall: uninstall-bin uninstall-doc |
---|
38 | @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n' |
---|
39 | |
---|
40 | install: install-bin install-doc install-plugins |
---|
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 | @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 |
---|
43 | ifdef SYSTEMDSYSTEMUNITDIR |
---|
44 | @echo If you want to start BitlBee using systemd, try \"make install-systemd\". |
---|
45 | endif |
---|
46 | @echo |
---|
47 | |
---|
48 | .PHONY: install install-bin install-etc install-doc install-plugins install-systemd \ |
---|
49 | uninstall uninstall-bin uninstall-etc uninstall-doc \ |
---|
50 | all clean distclean tar $(subdirs) doc |
---|
51 | |
---|
52 | Makefile.settings: |
---|
53 | @echo |
---|
54 | @echo Run ./configure to create Makefile.settings, then rerun make |
---|
55 | @echo |
---|
56 | |
---|
57 | clean: $(subdirs) |
---|
58 | rm -f *.o $(OUTFILE) core utils/bitlbeed init/bitlbee*.service |
---|
59 | $(MAKE) -C tests clean |
---|
60 | ifdef SKYPE_PI |
---|
61 | $(MAKE) -C protocols/skype clean |
---|
62 | endif |
---|
63 | |
---|
64 | distclean: clean $(subdirs) |
---|
65 | rm -rf .depend |
---|
66 | rm -f Makefile.settings config.h bitlbee.pc |
---|
67 | find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -exec rm -f {} \; |
---|
68 | @# May still be present in dirs of disabled protocols. |
---|
69 | -find . -name .depend -exec rm -rf {} \; |
---|
70 | $(MAKE) -C tests distclean |
---|
71 | |
---|
72 | check: all |
---|
73 | $(MAKE) -C tests |
---|
74 | |
---|
75 | gcov: check |
---|
76 | gcov *.c |
---|
77 | |
---|
78 | lcov: check |
---|
79 | lcov --directory . --capture --output-file bitlbee.info |
---|
80 | genhtml -o coverage bitlbee.info |
---|
81 | |
---|
82 | install-doc: |
---|
83 | $(MAKE) -C doc install |
---|
84 | ifdef SKYPE_PI |
---|
85 | $(MAKE) -C protocols/skype install-doc |
---|
86 | endif |
---|
87 | |
---|
88 | uninstall-doc: |
---|
89 | $(MAKE) -C doc uninstall |
---|
90 | ifdef SKYPE_PI |
---|
91 | $(MAKE) -C protocols/skype uninstall-doc |
---|
92 | endif |
---|
93 | |
---|
94 | install-bin: |
---|
95 | mkdir -p $(DESTDIR)$(SBINDIR) |
---|
96 | $(INSTALL) -m 0755 $(OUTFILE) $(DESTDIR)$(SBINDIR)/$(OUTFILE) |
---|
97 | |
---|
98 | uninstall-bin: |
---|
99 | rm -f $(DESTDIR)$(SBINDIR)/$(OUTFILE) |
---|
100 | |
---|
101 | install-dev: |
---|
102 | mkdir -p $(DESTDIR)$(INCLUDEDIR) |
---|
103 | $(INSTALL) -m 0644 config.h $(DESTDIR)$(INCLUDEDIR) |
---|
104 | for i in $(headers); do $(INSTALL) -m 0644 $(_SRCDIR_)$$i $(DESTDIR)$(INCLUDEDIR); done |
---|
105 | mkdir -p $(DESTDIR)$(PCDIR) |
---|
106 | $(INSTALL) -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR) |
---|
107 | |
---|
108 | uninstall-dev: |
---|
109 | rm -f $(foreach hdr,$(headers),$(DESTDIR)$(INCLUDEDIR)/$(hdr)) |
---|
110 | -rmdir $(DESTDIR)$(INCLUDEDIR) |
---|
111 | rm -f $(DESTDIR)$(PCDIR)/bitlbee.pc |
---|
112 | |
---|
113 | install-etc: |
---|
114 | mkdir -p $(DESTDIR)$(ETCDIR) |
---|
115 | $(INSTALL) -m 0644 $(_SRCDIR_)motd.txt $(DESTDIR)$(ETCDIR)/motd.txt |
---|
116 | $(INSTALL) -m 0644 $(_SRCDIR_)bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf |
---|
117 | |
---|
118 | uninstall-etc: |
---|
119 | rm -f $(DESTDIR)$(ETCDIR)/motd.txt |
---|
120 | rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf |
---|
121 | -rmdir $(DESTDIR)$(ETCDIR) |
---|
122 | |
---|
123 | install-plugins: install-plugin-otr install-plugin-skype |
---|
124 | |
---|
125 | install-plugin-otr: |
---|
126 | ifdef OTR_PI |
---|
127 | mkdir -p $(DESTDIR)$(PLUGINDIR) |
---|
128 | $(INSTALL) -m 0755 otr.so $(DESTDIR)$(PLUGINDIR) |
---|
129 | endif |
---|
130 | |
---|
131 | install-plugin-skype: |
---|
132 | ifdef SKYPE_PI |
---|
133 | mkdir -p $(DESTDIR)$(PLUGINDIR) |
---|
134 | $(INSTALL) -m 0755 skype.so $(DESTDIR)$(PLUGINDIR) |
---|
135 | mkdir -p $(DESTDIR)$(ETCDIR)/../skyped $(DESTDIR)$(BINDIR) |
---|
136 | $(INSTALL) -m 0644 $(_SRCDIR_)protocols/skype/skyped.cnf $(DESTDIR)$(ETCDIR)/../skyped/skyped.cnf |
---|
137 | $(INSTALL) -m 0644 $(_SRCDIR_)protocols/skype/skyped.conf.dist $(DESTDIR)$(ETCDIR)/../skyped/skyped.conf |
---|
138 | $(INSTALL) -m 0755 $(_SRCDIR_)protocols/skype/skyped.py $(DESTDIR)$(BINDIR)/skyped |
---|
139 | $(MAKE) -C protocols/skype install-doc |
---|
140 | endif |
---|
141 | |
---|
142 | systemd: |
---|
143 | ifdef SYSTEMDSYSTEMUNITDIR |
---|
144 | mkdir -p init |
---|
145 | sed 's|@sbindir@|$(SBINDIR)|' $(_SRCDIR_)init/bitlbee.service.in > init/bitlbee.service |
---|
146 | sed 's|@sbindir@|$(SBINDIR)|' $(_SRCDIR_)init/bitlbee@.service.in > init/bitlbee@.service |
---|
147 | endif |
---|
148 | |
---|
149 | install-systemd: systemd |
---|
150 | ifdef SYSTEMDSYSTEMUNITDIR |
---|
151 | ifeq ($(shell id -u),0) |
---|
152 | mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
153 | $(INSTALL) -m 0644 init/bitlbee.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
154 | $(INSTALL) -m 0644 init/bitlbee@.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
155 | $(INSTALL) -m 0644 $(_SRCDIR_)init/bitlbee.socket $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
---|
156 | else |
---|
157 | @echo Not root, so not installing systemd files. |
---|
158 | endif |
---|
159 | endif |
---|
160 | |
---|
161 | tar: |
---|
162 | fakeroot debian/rules clean || make distclean |
---|
163 | x=$$(basename $$(pwd)); \ |
---|
164 | cd ..; \ |
---|
165 | tar czf $$x.tar.gz --exclude=debian --exclude=.bzr* --exclude=.depend $$x |
---|
166 | |
---|
167 | $(subdirs): |
---|
168 | @$(MAKE) -C $@ $(MAKECMDGOALS) |
---|
169 | |
---|
170 | $(OTR_PI): %.so: $(_SRCDIR_)%.c |
---|
171 | @echo '*' Building plugin $@ |
---|
172 | @$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@ $(OTRFLAGS) |
---|
173 | |
---|
174 | $(SKYPE_PI): $(_SRCDIR_)protocols/skype/skype.c |
---|
175 | @echo '*' Building plugin skype |
---|
176 | @$(CC) $(CFLAGS) $(LDFLAGS) $(SKYPEFLAGS) $< -o $@ |
---|
177 | |
---|
178 | $(objects): %.o: $(_SRCDIR_)%.c |
---|
179 | @echo '*' Compiling $< |
---|
180 | @$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@ |
---|
181 | |
---|
182 | $(objects): Makefile Makefile.settings config.h |
---|
183 | |
---|
184 | $(OUTFILE): $(objects) $(subdirs) |
---|
185 | @echo '*' Linking $(OUTFILE) |
---|
186 | @$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LDFLAGS_BITLBEE) $(LDFLAGS) $(EFLAGS) |
---|
187 | ifndef DEBUG |
---|
188 | @echo '*' Stripping $(OUTFILE) |
---|
189 | @-$(STRIP) $(OUTFILE) |
---|
190 | endif |
---|
191 | |
---|
192 | ctags: |
---|
193 | ctags `find . -name "*.c"` `find . -name "*.h"` |
---|
194 | |
---|
195 | # Using this as a bogus Make target to test if a GNU-compatible version of |
---|
196 | # make is available. |
---|
197 | helloworld: |
---|
198 | @echo Hello World |
---|
199 | |
---|
200 | # Check if we can load the helpfile. (This fails if some article is >1KB.) |
---|
201 | # If print returns a NULL pointer, the file is unusable. |
---|
202 | testhelp: doc |
---|
203 | gdb --eval-command='b main' --eval-command='r' \ |
---|
204 | --eval-command='print help_init(&global->helpfile, "doc/user-guide/help.txt")' \ |
---|
205 | $(OUTFILE) < /dev/null |
---|
206 | |
---|
207 | -include .depend/*.d |
---|
208 | # DO NOT DELETE |
---|