Skip to content

Commit

Permalink
Allow one to run the configure script from a different directory and …
Browse files Browse the repository at this point in the history
…put all

build files in there. I need this to properly make Debian package variants
(i.e. libpurple and native).
  • Loading branch information
Wilm0r committed May 25, 2010
1 parent 51a799e commit f60079b
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ tar:
$(subdirs):
@$(MAKE) -C $@ $(MAKECMDGOALS)

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

Expand Down
2 changes: 1 addition & 1 deletion bitlbee.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define MAX_STRING 511

#if HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif

#include <fcntl.h>
Expand Down
24 changes: 23 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ LFLAGS=
EFLAGS=
EOF
srcdir="$(dirname $0)"
if [ "$srcdir" != "." ]; then
echo
echo "configure script run from a different directory. Will create some symlinks..."
if [ ! -e Makefile -o -L Makefile ]; then
mkdir -p $(cd "$srcdir"; find . -type d)
find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
dst="$PWD"
cd "$srcdir"
for i in $(find . -name Makefile); do
ln -s "$PWD${i#.}" "$dst/$i";
done
cd "$dst"
rm -rf .bzr
fi
echo "SRCDIR=$srcdir/" >> Makefile.settings
CFLAGS="$CFLAGS -I${dst}"
else
srcdir=$PWD
fi
cat<<EOF>config.h
/* BitlBee settings, generated by configure
Expand Down Expand Up @@ -160,7 +182,7 @@ else
fi
echo CFLAGS=$CFLAGS >> Makefile.settings
echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings
echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
Expand Down
3 changes: 3 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
-include ../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)doc/
endif

all:
# Only build the docs if this is a bzr checkout
Expand Down
4 changes: 4 additions & 0 deletions doc/user-guide/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
-include ../../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)doc/user-guide/
endif

EXTRAPARANEWLINE = 1
# EXTRAPARANEWLINE = 0

Expand Down
5 changes: 4 additions & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### DEFINITIONS

-include ../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)lib/
endif

# [SH] Program variables
objects = arc.o base64.o $(EVENT_HANDLER) ftutil.o http_client.o ini.o md5.o misc.o oauth.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o
Expand Down Expand Up @@ -36,6 +39,6 @@ lib.o: $(objects) $(subdirs)

$(objects): ../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@
5 changes: 4 additions & 1 deletion protocols/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### DEFINITIONS

-include ../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)protocols/
endif

# [SH] Program variables
objects = nogaim.o
Expand Down Expand Up @@ -48,6 +51,6 @@ protocols.o: $(objects) $(subdirs)

$(objects): ../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@
5 changes: 4 additions & 1 deletion protocols/jabber/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### DEFINITIONS

-include ../../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)protocols/jabber/
endif

# [SH] Program variables
objects = conference.o io.o iq.o jabber.o jabber_util.o message.o presence.o s5bytestream.o sasl.o si.o
Expand All @@ -32,7 +35,7 @@ distclean: clean

$(objects): ../../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

Expand Down
5 changes: 4 additions & 1 deletion protocols/msn/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### DEFINITIONS

-include ../../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)protocols/msn/
endif

# [SH] Program variables
objects = invitation.o msn.o msn_util.o ns.o passport.o sb.o tables.o
Expand All @@ -32,7 +35,7 @@ distclean: clean

$(objects): ../../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

Expand Down
6 changes: 5 additions & 1 deletion protocols/oscar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
### DEFINITIONS

-include ../../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)protocols/oscar/
CFLAGS += -I$(SRCDIR)
endif

# [SH] Program variables
objects = admin.o auth.o bos.o buddylist.o chat.o chatnav.o conn.o icq.o im.o info.o misc.o msgcookie.o rxhandlers.o rxqueue.o search.o service.o snac.o ssi.o stats.o tlv.o txqueue.o oscar_util.o oscar.o
Expand All @@ -32,7 +36,7 @@ distclean: clean

$(objects): ../../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

Expand Down
5 changes: 4 additions & 1 deletion protocols/purple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### DEFINITIONS

-include ../../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)protocols/purple/
endif

# [SH] Program variables
objects = ft.o purple.o
Expand All @@ -32,7 +35,7 @@ distclean: clean

$(objects): ../../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

Expand Down
5 changes: 4 additions & 1 deletion protocols/twitter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### DEFINITIONS

-include ../../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)protocols/twitter/
endif

# [SH] Program variables
objects = twitter.o twitter_http.o twitter_lib.o
Expand All @@ -32,7 +35,7 @@ distclean: clean

$(objects): ../../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

Expand Down
5 changes: 4 additions & 1 deletion protocols/yahoo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### DEFINITIONS

-include ../../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)protocols/yahoo/
endif

# [SH] Program variables
objects = yahoo.o crypt.o libyahoo2.o yahoo_fn.o yahoo_httplib.o yahoo_util.o
Expand All @@ -32,7 +35,7 @@ distclean: clean

$(objects): ../../Makefile.settings Makefile

$(objects): %.o: %.c
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

Expand Down
5 changes: 4 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
-include ../Makefile.settings
ifdef SRCDIR
SRCDIR := $(SRCDIR)tests/
endif

LFLAGS +=-lcheck

Expand All @@ -18,6 +21,6 @@ check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../l
@echo '*' Linking $@
@$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS)

%.o: %.c
%.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@

0 comments on commit f60079b

Please sign in to comment.