source: Makefile @ 757515a

Last change on this file since 757515a was d203495, checked in by Jelmer Vernooij <jelmer@…>, at 2014-07-19T23:55:24Z

Allow LDFLAGS to be provided in the environment and consistently use $(LDFLAGS)
when linking (not partially linking).

  • Property mode set to 100644
File size: 6.4 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
[858ea01]12objects = 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)
[a7e6ba9]13headers = bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h lib/events.h lib/ftutil.h lib/http_client.h lib/ini.h lib/json.h lib/json_util.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/account.h protocols/bee.h protocols/ft.h protocols/nogaim.h
[84b045d]14subdirs = lib protocols
[b7d3cc34]15
[1bf9492]16ifeq ($(TARGET),i586-mingw32msvc)
[d1d6776]17objects += win32.o
[d203495]18LDFLAGS+=-lws2_32
[73c2dce]19EFLAGS+=-lsecur32
[6a72a57]20OUTFILE=bitlbee.exe
[d1d6776]21else
[4146a07]22objects += unix.o conf.o log.o
[6a72a57]23OUTFILE=bitlbee
[d1d6776]24endif
25
[b7d3cc34]26# Expansion of variables
27subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
28
[4b53c65]29all: $(OUTFILE) $(OTR_PI) $(SKYPE_PI) doc systemd
[5155570]30ifdef SKYPE_PI
31        $(MAKE) -C protocols/skype doc
32endif
[b7d3cc34]33
[4b53c65]34doc:
35        $(MAKE) -C doc
36
[cdb92c5]37uninstall: uninstall-bin uninstall-doc
[b7d3cc34]38        @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n'
39
[c564e25]40install: install-bin install-doc install-plugins
[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
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
[c564e25]43ifdef SYSTEMDSYSTEMUNITDIR
44        @echo If you want to start BitlBee using systemd, try \"make install-systemd\".
45endif
[b7d3cc34]46        @echo
47
[417002e]48.PHONY:   install   install-bin   install-etc   install-doc install-plugins install-systemd \
[b7d3cc34]49        uninstall uninstall-bin uninstall-etc uninstall-doc \
[4b53c65]50        all clean distclean tar $(subdirs) doc
[b7d3cc34]51
52Makefile.settings:
53        @echo
54        @echo Run ./configure to create Makefile.settings, then rerun make
55        @echo
56
57clean: $(subdirs)
[c14959d]58        rm -f *.o $(OUTFILE) core utils/bitlbeed init/bitlbee*.service
[66b9e86e]59        $(MAKE) -C tests clean
[757e1e0]60ifdef SKYPE_PI
61        $(MAKE) -C protocols/skype clean
62endif
[b7d3cc34]63
64distclean: clean $(subdirs)
[b0a89cc]65        rm -rf .depend
[b3c467b]66        rm -f Makefile.settings config.h bitlbee.pc
[34c0e90]67        find . -name 'DEADJOE' -o -name '*.orig' -o -name '*.rej' -o -name '*~' -exec rm -f {} \;
[b0a89cc]68        @# May still be present in dirs of disabled protocols.
[b41d5d2]69        -find . -name .depend -exec rm -rf {} \;
[dcf0f3e]70        $(MAKE) -C tests distclean
[b7d3cc34]71
[66b9e86e]72check: all
[c2fa827]73        $(MAKE) -C tests
74
[66b9e86e]75gcov: check
76        gcov *.c
77
[348c11b]78lcov: check
79        lcov --directory . --capture --output-file bitlbee.info
80        genhtml -o coverage bitlbee.info
81
[b7d3cc34]82install-doc:
83        $(MAKE) -C doc install
[5155570]84ifdef SKYPE_PI
85        $(MAKE) -C protocols/skype install-doc
86endif
[b7d3cc34]87
88uninstall-doc:
89        $(MAKE) -C doc uninstall
[5155570]90ifdef SKYPE_PI
91        $(MAKE) -C protocols/skype uninstall-doc
92endif
[b7d3cc34]93
94install-bin:
[57da960]95        mkdir -p $(DESTDIR)$(SBINDIR)
[ba3506e]96        $(INSTALL) -m 0755 $(OUTFILE) $(DESTDIR)$(SBINDIR)/$(OUTFILE)
[b7d3cc34]97
98uninstall-bin:
[57da960]99        rm -f $(DESTDIR)$(SBINDIR)/$(OUTFILE)
[b7d3cc34]100
[cdb92c5]101install-dev:
[e506d6c]102        mkdir -p $(DESTDIR)$(INCLUDEDIR)
[ba3506e]103        $(INSTALL) -m 0644 config.h $(DESTDIR)$(INCLUDEDIR)
104        for i in $(headers); do $(INSTALL) -m 0644 $(_SRCDIR_)$$i $(DESTDIR)$(INCLUDEDIR); done
[e506d6c]105        mkdir -p $(DESTDIR)$(PCDIR)
[ba3506e]106        $(INSTALL) -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR)
[e506d6c]107
[cdb92c5]108uninstall-dev:
109        rm -f $(foreach hdr,$(headers),$(DESTDIR)$(INCLUDEDIR)/$(hdr))
110        -rmdir $(DESTDIR)$(INCLUDEDIR)
[e506d6c]111        rm -f $(DESTDIR)$(PCDIR)/bitlbee.pc
112
[b7d3cc34]113install-etc:
114        mkdir -p $(DESTDIR)$(ETCDIR)
[ba3506e]115        $(INSTALL) -m 0644 $(_SRCDIR_)motd.txt $(DESTDIR)$(ETCDIR)/motd.txt
116        $(INSTALL) -m 0644 $(_SRCDIR_)bitlbee.conf $(DESTDIR)$(ETCDIR)/bitlbee.conf
[b7d3cc34]117
118uninstall-etc:
119        rm -f $(DESTDIR)$(ETCDIR)/motd.txt
120        rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf
121        -rmdir $(DESTDIR)$(ETCDIR)
122
[57da960]123install-plugins: install-plugin-otr install-plugin-skype
124
125install-plugin-otr:
[858ea01]126ifdef OTR_PI
127        mkdir -p $(DESTDIR)$(PLUGINDIR)
[ba3506e]128        $(INSTALL) -m 0755 otr.so $(DESTDIR)$(PLUGINDIR)
[858ea01]129endif
[57da960]130
131install-plugin-skype:
[370899f]132ifdef SKYPE_PI
133        mkdir -p $(DESTDIR)$(PLUGINDIR)
[ba3506e]134        $(INSTALL) -m 0755 skype.so $(DESTDIR)$(PLUGINDIR)
[57da960]135        mkdir -p $(DESTDIR)$(ETCDIR)/../skyped $(DESTDIR)$(BINDIR)
[ba3506e]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
[cb90dc9]139        $(MAKE) -C protocols/skype install-doc
[370899f]140endif
[858ea01]141
[417002e]142systemd:
143ifdef SYSTEMDSYSTEMUNITDIR
[0edb57f]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
[417002e]147endif
148
149install-systemd:
150ifdef SYSTEMDSYSTEMUNITDIR
[13688ec]151ifeq ($(shell id -u),0)
[417002e]152        mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
[ba3506e]153        $(INSTALL) -m 0644 init/bitlbee.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
154        $(INSTALL) -m 0644 init/bitlbee@.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
[0edb57f]155        $(INSTALL) -m 0644 $(_SRCDIR_)init/bitlbee.socket $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
[417002e]156else
157        @echo Not root, so not installing systemd files.
158endif
159endif
160
[b7d3cc34]161tar:
162        fakeroot debian/rules clean || make distclean
163        x=$$(basename $$(pwd)); \
164        cd ..; \
[b0a89cc]165        tar czf $$x.tar.gz --exclude=debian --exclude=.bzr* --exclude=.depend $$x
[b7d3cc34]166
167$(subdirs):
168        @$(MAKE) -C $@ $(MAKECMDGOALS)
169
[7fa5c19]170$(OTR_PI): %.so: $(_SRCDIR_)%.c
[858ea01]171        @echo '*' Building plugin $@
[9fc017d]172        @$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@ $(OTRFLAGS)
[858ea01]173
[7fa5c19]174$(SKYPE_PI): $(_SRCDIR_)protocols/skype/skype.c
[370899f]175        @echo '*' Building plugin skype
[d203495]176        @$(CC) $(CFLAGS) $(LDFLAGS) $(SKYPEFLAGS) $< -o $@
[370899f]177
[7fa5c19]178$(objects): %.o: $(_SRCDIR_)%.c
[b7d3cc34]179        @echo '*' Compiling $<
[7281ad1]180        @$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
[b7d3cc34]181
182$(objects): Makefile Makefile.settings config.h
183
184$(OUTFILE): $(objects) $(subdirs)
185        @echo '*' Linking $(OUTFILE)
[d203495]186        @$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LDFLAGS_BITLBEE) $(LDFLAGS) $(EFLAGS)
[b7d3cc34]187ifndef DEBUG
188        @echo '*' Stripping $(OUTFILE)
189        @-$(STRIP) $(OUTFILE)
190endif
191
192ctags: 
193        ctags `find . -name "*.c"` `find . -name "*.h"`
[4fca1db]194
195# Using this as a bogus Make target to test if a GNU-compatible version of
196# make is available.
197helloworld:
198        @echo Hello World
[b0a89cc]199
[4b53c65]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.
202testhelp: 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
[b0a89cc]207-include .depend/*.d
[a0c6fc5]208# DO NOT DELETE
Note: See TracBrowser for help on using the repository browser.