summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPaul P Komkoff Jr <i@stingr.net>2008-08-13 16:17:04 +0100
committerPaul Jakma <paul@quagga.net>2008-08-22 19:52:12 +0100
commit46bc0e432e756fcb8fc4f703b47cd25b9fc7139c (patch)
tree60100ca1e11c3c3600441d366b236f4a2de519ca /configure.ac
parentd664ae1182c29b74b409bc8594b7bd0575e91ce9 (diff)
[build] Test for GNU-style PIE support in toolchain and enable
2008-08-13 Paul P Komkoff Jr <i@stingr.net> * configure.ac: add a configure flag and autoconf macro, which will determine if your toolchain supports PIE. * */Makefile.am: add corresponding CFLAGS and LDFLAGS into appropriate places. Signed-off-by: Paul Jakma <paul@quagga.net>
Diffstat (limited to 'configure.ac')
-rwxr-xr-xconfigure.ac28
1 files changed, 27 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 746b5cea..5c6c0d7d 100755
--- a/configure.ac
+++ b/configure.ac
@@ -60,9 +60,10 @@ fi
dnl --------------------
dnl Check CC and friends
dnl --------------------
+AC_LANG([C])
AC_PROG_CC
AC_PROG_CPP
-
+AM_PROG_CC_C_O
AC_PROG_EGREP
dnl autoconf 2.59 appears not to support AC_PROG_SED
@@ -1395,6 +1396,31 @@ dnl ----------
CONFDATE=`date '+%Y%m%d'`
AC_SUBST(CONFDATE)
+dnl Conditionally enable PIE support for GNU toolchains.
+enable_pie=yes
+
+AC_ARG_ENABLE(pie, AS_HELP_STRING([--disable-pie], [Do not build tools as a Position Independent Executables]))
+if test "$enable_pie" = "yes"; then
+ AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
+ save_CFLAGS=$CFLAGS
+ save_LDFLAGS=$LDFLAGS
+ CFLAGS="$CFLAGS -fPIE"
+ LDFLAGS="$LDFLAGS -pie"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
+ [ap_cv_cc_pie=yes], [ap_cv_cc_pie=no]
+ )
+ CFLAGS=$save_CFLAGS
+ LDFLAGS=$save_LDFLAGS
+ ])
+ if test "$ap_cv_cc_pie" = "yes"; then
+ PICFLAGS="-fPIE"
+ PILDFLAGS="-pie"
+ fi
+fi
+
+AC_SUBST(PICFLAGS)
+AC_SUBST(PILDFLAGS)
+
dnl ------------------------------
dnl set paths for state directory
dnl ------------------------------