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