source: Makefile

Last change on this file was 82149f4, checked in by GitHub <noreply@…>, at 2023-03-04T19:59:09Z

Fixes related to external-json-parser (#165)

  • configure: append conditionally json-parser to pc file

json-parser needs to be appended to Requires section of pkg-config file
when bitlbee is configured to use external-json-parser. This change is
needed for external plugins like bitlbee-steam.

  • Makefile: do not install json.h when system json-parser is used

install-dev target should not install bundled json.h when bitlbee is
configured to use external-json-parser.

  • Use correct json.h header file with respect to external_json_parser value

The preprocessor must include correct json.h header file with respect to
external_json_parser value, otherwise function prototypes and other
definitions do not need to correspond with object used for linking.

The state before this commit is that local version lib/json.h is used
always for compilation and external_json_parser variable controls if
local lib/json.o or global libjsonparser.so will be linked.

In order to fix this problem, #include directives in lib/json_util.h and
lib/oauth2.c were changed from "json.h" to <json.h> and preprocessor -I
flags were moved after conditional json-parser flags, which is enough
for solving the issue. Additionally, USE_EXTERNAL_JSON_PARSER macro is
exported when external-json-parser is used and it is used in lib/json.h
to trigger an error message, which should prevent similar mistakes in
future.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1###########################
2## Makefile for BitlBee  ##
3##                       ##
4## Copyright 2002 Lintux ##
5###########################
6
7### DEFINITIONS
8
9-include Makefile.settings
10
11# Program variables
12objects = 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
13allheaders = $(wildcard $(_SRCDIR_)*.h $(_SRCDIR_)lib/*.h $(_SRCDIR_)protocols/*.h)
14ifeq ($(EXTERNAL_JSON_PARSER),1)
15headers = $(filter-out $(_SRCDIR_)lib/json.h,$(allheaders))
16else
17headers = $(allheaders)
18endif
19subdirs = lib protocols
20
21OUTFILE = bitlbee
22
23# Expansion of variables
24subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
25
26all: $(OUTFILE) $(OTR_PI) doc systemd
27
28doc:
29ifdef DOC
30        $(MAKE) -C doc
31endif
32
33uninstall: 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
36install: install-bin install-doc install-plugins
37        @echo
38        @echo Installed successfully
39        @echo
40ifndef 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
42endif
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
44ifdef SYSTEMDSYSTEMUNITDIR
45        @echo If you want to start BitlBee using systemd, try \"make install-systemd\".
46endif
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
54Makefile.settings:
55        @echo
56        @echo Run ./configure to create Makefile.settings, then rerun make
57        @echo
58
59clean: $(subdirs)
60        rm -f *.o $(OUTFILE) core utils/bitlbeed init/bitlbee*.service
61        $(MAKE) -C tests clean
62
63distclean: 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
71check: all
72        $(MAKE) -C tests
73
74gcov: check
75        gcov *.c
76
77lcov: check
78        lcov --directory . --capture --output-file bitlbee.info
79        genhtml -o coverage bitlbee.info
80
81install-doc:
82ifdef DOC
83        $(MAKE) -C doc install
84endif
85
86uninstall-doc:
87ifdef DOC
88        $(MAKE) -C doc uninstall
89endif
90
91install-bin:
92        mkdir -p $(DESTDIR)$(SBINDIR)
93        $(INSTALL) -m 0755 $(OUTFILE) $(DESTDIR)$(SBINDIR)/$(OUTFILE)
94ifdef IMPLIB
95        # import library for cygwin
96        mkdir -p $(DESTDIR)$(LIBDIR)
97        $(INSTALL) -m 0644 $(IMPLIB) $(DESTDIR)$(LIBDIR)/$(IMPLIB)
98endif
99
100uninstall-bin:
101        rm -f $(DESTDIR)$(SBINDIR)/$(OUTFILE)
102ifdef IMPLIB
103        rm -f $(DESTDIR)$(LIBDIR)/$(IMPLIB)
104endif
105
106install-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
113uninstall-dev:
114        rm -f $(foreach hdr,$(headers),$(DESTDIR)$(INCLUDEDIR)/$(hdr))
115        -rmdir $(DESTDIR)$(INCLUDEDIR)
116        rm -f $(DESTDIR)$(PCDIR)/bitlbee.pc
117
118install-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
123uninstall-etc:
124        rm -f $(DESTDIR)$(ETCDIR)/motd.txt
125        rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf
126        -rmdir $(DESTDIR)$(ETCDIR)
127
128install-plugins: install-plugin-otr
129
130install-plugin-otr:
131ifdef OTR_PI
132        mkdir -p $(DESTDIR)$(PLUGINDIR)
133        $(INSTALL) -m 0755 otr.so $(DESTDIR)$(PLUGINDIR)
134endif
135
136systemd:
137ifdef 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
141endif
142
143install-systemd: systemd
144ifdef 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)
149else
150        @echo SYSTEMDSYSTEMUNITDIR not set, not installing systemd unit files.
151endif
152
153ifdef SYSUSERSDIR
154        $(INSTALL) -Dm644 init/bitlbee.sysusers $(DESTDIR)/$(SYSUSERSDIR)/bitlbee.conf
155else
156        @echo SYSUSERSDIR not set, not install sysusers.d files
157endif
158
159tar:
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)
181ifneq ($(firstword $(STRIP)), \#)
182        @echo '*' Stripping $(OUTFILE)
183        $(VERBOSE) -$(STRIP) $(OUTFILE)
184endif
185
186ctags: 
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.
191helloworld:
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.
196testhelp: 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
Note: See TracBrowser for help on using the repository browser.