source: Makefile @ af09afd

Last change on this file since af09afd 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
RevLine 
[b7d3cc34]1###########################
2## Makefile for BitlBee  ##
3##                       ##
4## Copyright 2002 Lintux ##
5###########################
6
7### DEFINITIONS
8
9-include Makefile.settings
10
11# Program variables
[8e6ecfe]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
[82149f4]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
[84b045d]19subdirs = lib protocols
[b7d3cc34]20
[e252d8c]21OUTFILE = bitlbee
[d1d6776]22
[b7d3cc34]23# Expansion of variables
24subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
25
[a949b43]26all: $(OUTFILE) $(OTR_PI) doc systemd
[b7d3cc34]27
[4b53c65]28doc:
[a85a8ab]29ifdef DOC
[4b53c65]30        $(MAKE) -C doc
[a85a8ab]31endif
[4b53c65]32
[cdb92c5]33uninstall: uninstall-bin uninstall-doc
[b7d3cc34]34        @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n'
35
[c564e25]36install: install-bin install-doc install-plugins
[3e6cdb6]37        @echo
38        @echo Installed successfully
39        @echo
[8ca172f]40ifndef SYSTEMDSYSTEMUNITDIR
[b7d3cc34]41        @if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi
[8ca172f]42endif
[b7d3cc34]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
[c564e25]44ifdef SYSTEMDSYSTEMUNITDIR
45        @echo If you want to start BitlBee using systemd, try \"make install-systemd\".
46endif
[3e6cdb6]47        @echo To be able to compile third party plugins, run \"make install-dev\"
[b7d3cc34]48        @echo
49
[3e6cdb6]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 \
[4b53c65]52        all clean distclean tar $(subdirs) doc
[b7d3cc34]53
54Makefile.settings:
55        @echo
56        @echo Run ./configure to create Makefile.settings, then rerun make
57        @echo
58
59clean: $(subdirs)
[c14959d]60        rm -f *.o $(OUTFILE) core utils/bitlbeed init/bitlbee*.service
[66b9e86e]61        $(MAKE) -C tests clean
[b7d3cc34]62
63distclean: clean $(subdirs)
[b0a89cc]64        rm -rf .depend
[b3c467b]65        rm -f Makefile.settings config.h bitlbee.pc
[34c0e90]66        find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -exec rm -f {} \;
[b0a89cc]67        @# May still be present in dirs of disabled protocols.
[b41d5d2]68        -find . -name .depend -exec rm -rf {} \;
[dcf0f3e]69        $(MAKE) -C tests distclean
[b7d3cc34]70
[66b9e86e]71check: all
[c2fa827]72        $(MAKE) -C tests
73
[66b9e86e]74gcov: check
75        gcov *.c
76
[348c11b]77lcov: check
78        lcov --directory . --capture --output-file bitlbee.info
79        genhtml -o coverage bitlbee.info
80
[b7d3cc34]81install-doc:
[a85a8ab]82ifdef DOC
[b7d3cc34]83        $(MAKE) -C doc install
[a85a8ab]84endif
[b7d3cc34]85
86uninstall-doc:
[a85a8ab]87ifdef DOC
[b7d3cc34]88        $(MAKE) -C doc uninstall
[a85a8ab]89endif
[b7d3cc34]90
91install-bin:
[57da960]92        mkdir -p $(DESTDIR)$(SBINDIR)
[ba3506e]93        $(INSTALL) -m 0755 $(OUTFILE) $(DESTDIR)$(SBINDIR)/$(OUTFILE)
[54b2a36]94ifdef IMPLIB
95        # import library for cygwin
[e199620]96        mkdir -p $(DESTDIR)$(LIBDIR)
[54b2a36]97        $(INSTALL) -m 0644 $(IMPLIB) $(DESTDIR)$(LIBDIR)/$(IMPLIB)
98endif
[b7d3cc34]99
100uninstall-bin:
[57da960]101        rm -f $(DESTDIR)$(SBINDIR)/$(OUTFILE)
[54b2a36]102ifdef IMPLIB
103        rm -f $(DESTDIR)$(LIBDIR)/$(IMPLIB)
104endif
[b7d3cc34]105
[cdb92c5]106install-dev:
[e506d6c]107        mkdir -p $(DESTDIR)$(INCLUDEDIR)
[ba3506e]108        $(INSTALL) -m 0644 config.h $(DESTDIR)$(INCLUDEDIR)
[ebe2c5e]109        for i in $(headers); do $(INSTALL) -m 0644 $$i $(DESTDIR)$(INCLUDEDIR); done
[e506d6c]110        mkdir -p $(DESTDIR)$(PCDIR)
[ba3506e]111        $(INSTALL) -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR)
[e506d6c]112
[cdb92c5]113uninstall-dev:
114        rm -f $(foreach hdr,$(headers),$(DESTDIR)$(INCLUDEDIR)/$(hdr))
115        -rmdir $(DESTDIR)$(INCLUDEDIR)
[e506d6c]116        rm -f $(DESTDIR)$(PCDIR)/bitlbee.pc
117
[b7d3cc34]118install-etc:
119        mkdir -p $(DESTDIR)$(ETCDIR)
[ba3506e]120        $(INSTALL) -m 0644 $(_SRCDIR_)motd.txt $(DESTDIR)$(ETCDIR)/motd.txt
121        $(INSTALL) -m 0644 $(_SRCDIR_)bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf
[b7d3cc34]122
123uninstall-etc:
124        rm -f $(DESTDIR)$(ETCDIR)/motd.txt
125        rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf
126        -rmdir $(DESTDIR)$(ETCDIR)
127
[a949b43]128install-plugins: install-plugin-otr
[57da960]129
130install-plugin-otr:
[858ea01]131ifdef OTR_PI
132        mkdir -p $(DESTDIR)$(PLUGINDIR)
[ba3506e]133        $(INSTALL) -m 0755 otr.so $(DESTDIR)$(PLUGINDIR)
[858ea01]134endif
[57da960]135
[417002e]136systemd:
137ifdef SYSTEMDSYSTEMUNITDIR
[0edb57f]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
[417002e]141endif
142
[a6c59bb]143install-systemd: systemd
[417002e]144ifdef SYSTEMDSYSTEMUNITDIR
145        mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
[ba3506e]146        $(INSTALL) -m 0644 init/bitlbee.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
147        $(INSTALL) -m 0644 init/bitlbee@.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
[0edb57f]148        $(INSTALL) -m 0644 $(_SRCDIR_)init/bitlbee.socket $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
[417002e]149else
[ebe2c5e]150        @echo SYSTEMDSYSTEMUNITDIR not set, not installing systemd unit files.
[417002e]151endif
152
[8ca172f]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
[b7d3cc34]159tar:
160        fakeroot debian/rules clean || make distclean
161        x=$$(basename $$(pwd)); \
162        cd ..; \
[61d21e5b]163        tar czf $$x.tar.gz --exclude=debian --exclude=.git* --exclude=.depend $$x
[b7d3cc34]164
165$(subdirs):
[65d0dfd]166        $(MAKE) -C $@ $(MAKECMDGOALS)
[b7d3cc34]167
[7fa5c19]168$(OTR_PI): %.so: $(_SRCDIR_)%.c
[858ea01]169        @echo '*' Building plugin $@
[65d0dfd]170        $(VERBOSE) $(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@ $(OTRFLAGS)
[858ea01]171
[7fa5c19]172$(objects): %.o: $(_SRCDIR_)%.c
[b7d3cc34]173        @echo '*' Compiling $<
[65d0dfd]174        $(VERBOSE) $(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
[b7d3cc34]175
176$(objects): Makefile Makefile.settings config.h
177
178$(OUTFILE): $(objects) $(subdirs)
179        @echo '*' Linking $(OUTFILE)
[65d0dfd]180        $(VERBOSE) $(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LDFLAGS_BITLBEE) $(LDFLAGS) $(EFLAGS)
[2a1c27f]181ifneq ($(firstword $(STRIP)), \#)
[b7d3cc34]182        @echo '*' Stripping $(OUTFILE)
[65d0dfd]183        $(VERBOSE) -$(STRIP) $(OUTFILE)
[b7d3cc34]184endif
185
186ctags: 
187        ctags `find . -name "*.c"` `find . -name "*.h"`
[4fca1db]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
[b0a89cc]193
[4b53c65]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
[b0a89cc]201-include .depend/*.d
[a0c6fc5]202# DO NOT DELETE
Note: See TracBrowser for help on using the repository browser.