Index: Makefile
===================================================================
--- Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -171,5 +171,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 $(objects): Makefile Makefile.settings config.h
@@ -177,5 +177,5 @@
 $(OUTFILE): $(objects) $(subdirs)
 	@echo '*' Linking $(OUTFILE)
-	@$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LFLAGS) $(EFLAGS)
+	@$(CC) $(objects) $(subdirobjs) -o $(OUTFILE) $(LDFLAGS_BITLBEE) $(LFLAGS) $(EFLAGS)
 ifndef DEBUG
 	@echo '*' Stripping $(OUTFILE)
Index: configure
===================================================================
--- configure	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ configure	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -42,4 +42,6 @@
 ssl=auto
 
+pie=1
+
 arch=`uname -s`
 cpu=`uname -m`
@@ -80,4 +82,5 @@
 --debug=0/1	Disable/enable debugging		$debug
 --strip=0/1	Disable/enable binary stripping		$strip
+--pie=0/1       Build position independent executable   $pie
 --gcov=0/1	Disable/enable test coverage reporting	$gcov
 --plugins=0/1	Disable/enable plugins support		$plugins
@@ -90,4 +93,5 @@
 --ssl=...	SSL library to use (gnutls, nss, openssl, bogus, auto)
 							$ssl
+
 
 --target=...	Cross compilation target 		same as host
@@ -198,4 +202,9 @@
 else
 	[ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing"
+fi
+
+if [ "$pie" = "1" ]; then
+	echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings
+	echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings
 fi
 
@@ -748,4 +757,10 @@
 fi
 
+if [ "$pie" = "1" ]; then
+	echo '  Building PIE executable'
+else
+	echo '  Building non-PIE executable'
+fi
+
 if [ "$strip" = "1" ]; then
 	echo '  Binary stripping enabled.'
Index: lib/Makefile
===================================================================
--- lib/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ lib/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -42,5 +42,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 -include .depend/*.d
Index: protocols/Makefile
===================================================================
--- protocols/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ protocols/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -55,5 +55,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 -include .depend/*.d
Index: protocols/jabber/Makefile
===================================================================
--- protocols/jabber/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ protocols/jabber/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -38,5 +38,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 jabber_mod.o: $(objects)
Index: protocols/msn/Makefile
===================================================================
--- protocols/msn/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ protocols/msn/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -38,5 +38,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 msn_mod.o: $(objects)
Index: protocols/oscar/Makefile
===================================================================
--- protocols/oscar/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ protocols/oscar/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -39,5 +39,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 oscar_mod.o: $(objects)
Index: protocols/purple/Makefile
===================================================================
--- protocols/purple/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ protocols/purple/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -39,5 +39,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 purple_mod.o: $(objects)
Index: protocols/twitter/Makefile
===================================================================
--- protocols/twitter/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ protocols/twitter/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -38,5 +38,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 twitter_mod.o: $(objects)
Index: protocols/yahoo/Makefile
===================================================================
--- protocols/yahoo/Makefile	(revision 68709f5618175d0ecb9b2b160cbb2ce2d4ddc7bc)
+++ protocols/yahoo/Makefile	(revision 7281ad13e9dadb1369590617eb06265b084a1726)
@@ -39,5 +39,5 @@
 $(objects): %.o: $(_SRCDIR_)%.c
 	@echo '*' Compiling $<
-	@$(CC) -c $(CFLAGS) $< -o $@
+	@$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
 
 yahoo_mod.o: $(objects)
