configure.ac: add support for position-independent executables. can be disabled
authorNathan Bryant <loanshark@uncensored.citadel.org>
Thu, 11 Dec 2003 04:06:55 +0000 (04:06 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Thu, 11 Dec 2003 04:06:55 +0000 (04:06 +0000)
with --disable-pie

citadel/ChangeLog
citadel/configure.ac

index a27f0f57a5ee63c29d42937dcdd8a225b20a6c3d..c6a6fdda366c62a2a9a1ca08f877f2962912488d 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 612.12  2003/12/11 04:06:55  nbryant
+ configure.ac: add support for position-independent executables. can be disabled
+ with --disable-pie
+
  Revision 612.11  2003/12/11 03:44:18  nbryant
  domain.c: include <arpa/nameser_compat.h> if present
  configure.ac: check for <arpa/nameser_compat.h>
@@ -5146,3 +5150,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index c990f4b235dad05386f61d4d80aaec92399f7f26..6d56daae967bc6178d71de0dc267e39511106a73 100644 (file)
@@ -17,6 +17,8 @@ AC_ARG_ENABLE(chkpwd, [  --disable-chkpwd        don't build 'chkpwd'])
 AC_ARG_ENABLE(threaded-client, [  --disable-threaded-client
                          disable multithreaded client])
 
+AC_ARG_ENABLE(pie, [  --disable-pie           don't build position-independent executables])
+
 AC_ARG_WITH(pam, [  --with-pam              use PAM if present (see PAM.txt before you try this)])
 AC_ARG_WITH(kthread, [  --with-kthread          use kernel threads (on FreeBSD) (not recommended yet)])
 AC_ARG_WITH(db, [  --with-db@<:@=DIR@:>@         use Sleepycat DB 3.x @<:@DIR=/usr/local/BerkeleyDB.3.@<:@123@:>@@:>@])
@@ -111,6 +113,21 @@ if test "$GCC" = yes; then
                ;;
        esac
 fi
+
+if test "x$enable_pie" != xno; then
+       save_CFLAGS="$CFLAGS"
+       save_LDFLAGS="$LDFLAGS"
+       CFLAGS="$CFLAGS -fpie"
+       LDFLAGS="$LDFLAGS -pie -fpie"
+       AC_CACHE_CHECK([whether compiler accepts -pie -fpie], ac_cv_pie_fpie,
+       [AC_TRY_LINK([], [],
+       ac_cv_pie_fpie=yes, ac_cv_pie_fpie=no)])
+       if test $ac_cv_pie_fpie = no; then
+               CFLAGS="$save_CFLAGS"
+               LDFLAGS="$save_LDFLAGS"
+       fi
+fi
+
 AC_PROG_INSTALL
 AC_PROG_YACC
 missing_dir=`cd $ac_aux_dir && pwd`