1
0
forked from bip/bip

Enable PIE executable creation.

This commit is contained in:
Arnaud Cornet 2010-08-07 12:10:32 +01:00
parent 7712ae3a92
commit 4f5f08677f

View File

@ -40,9 +40,9 @@ AC_CHECK_FUNCS([ftruncate gethostname gettimeofday localtime_r memmove memset mk
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debug build])) AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debug build]))
AC_ARG_WITH([openssl], AS_HELP_STRING([--without-openssl], [Disable SSL using OpenSSL])) AC_ARG_WITH([openssl], AS_HELP_STRING([--without-openssl], [Disable SSL using OpenSSL]))
AC_ARG_ENABLE([oidentd], AS_HELP_STRING([--enable-oidentd], [Enable oidentd support (bip overwrites ~/.oidentd.conf with this on!)])) AC_ARG_ENABLE([oidentd], AS_HELP_STRING([--enable-oidentd], [Enable oidentd support (bip overwrites ~/.oidentd.conf with this on!)]))
AC_ARG_ENABLE([pie], AS_HELP_STRING([--disable-pie], [Do not build a position independent executable]))
AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes) AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes)
AS_IF([test "x$enable_debug" = "xyes"], [ AS_IF([test "x$enable_debug" = "xyes"], [
CFLAGS="-O0 -g -W -Wall" CFLAGS="-O0 -g -W -Wall"
LDFLAGS="-g" LDFLAGS="-g"
@ -54,11 +54,16 @@ AS_IF([test "x$enable_debug" = "xyes"], [
], [ ], [
CFLAGS="-O2 -g -W -Wall" CFLAGS="-O2 -g -W -Wall"
LDFLAGS="-g" LDFLAGS="-g"
enable_debug=no
]) ])
AM_CONDITIONAL(OIDENTD, test x$enable_identd = xyes)
AS_IF([test "x$enable_oidentd" = "xyes"], [ AS_IF([test "x$enable_oidentd" = "xyes"], [
AC_DEFINE([HAVE_OIDENTD], [], [Have bip edit ~/.oidentd.conf]) AC_DEFINE([HAVE_OIDENTD], [], [Have bip edit ~/.oidentd.conf])
], [
enable_oidentd=no
]) ])
AM_CONDITIONAL(OIDENTD, test x$enable_identd = xyes)
AS_IF([test "x$with_openssl" != "xno"], [ AS_IF([test "x$with_openssl" != "xno"], [
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [ AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [
AC_MSG_ERROR([library 'crypto' is required for OpenSSL support]) AC_MSG_ERROR([library 'crypto' is required for OpenSSL support])
@ -68,6 +73,29 @@ AS_IF([test "x$with_openssl" != "xno"], [
AC_MSG_ERROR([library 'ssl' is required for OpenSSL support]) AC_MSG_ERROR([library 'ssl' is required for OpenSSL support])
with_openssl=no with_openssl=no
], -lssl) ], -lssl)
], [
with_openssl=no
])
AS_IF([test "x$enable_pie" != "xno"], [
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_TRY_RUN([static int foo[30000]; int main () { return 0; }],
[ap_cv_cc_pie=yes],
[ap_cv_cc_pie=no],
[ap_cv_cc_pie=yes]
)
CFLAGS=$save_CFLAGS
LDFLAGS=$save_LDFLAGS
])
if test "$ap_cv_cc_pie" = "yes"; then
CFLAGS="$CFLAGS -fPIE"
LDFLAGS="$LDFLAGS -pie"
enable_pie=yes
fi
]) ])
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
@ -78,4 +106,5 @@ echo OPENSSL: yes
]) ])
echo DEBUG: $enable_debug $backtrace echo DEBUG: $enable_debug $backtrace
echo OIDENTD: $enable_oidentd echo OIDENTD: $enable_oidentd
echo PIE: $enable_pie