configure: enable PIE and RELRO by default if compiler supports it.

(cherry picked from commit d79e3a641de934cd7546b2e628a8c6ea175b6c37)
This commit is contained in:
Juan RP 2012-09-04 11:31:48 +02:00
parent 6ece895957
commit 886807687e
2 changed files with 15 additions and 16 deletions

2
NEWS
View File

@ -1,5 +1,7 @@
xbps-0.17 (???):
* configure: if compiler supports PIE and RELRO, enable them by default.
* xbps-repo(8): the 'show-deps' target does not show the repository from
the matching target package, just the list of dependencies.

21
configure vendored
View File

@ -14,7 +14,6 @@ TARGET=
DEBUG=
BUILD_TESTS=
BUILD_API_DOCS=
BUILD_PIE=
BUILD_STATIC=
SILENT=yes
HAVE_VISIBILITY=no
@ -43,7 +42,6 @@ for instance \`--prefix=\$HOME'.
--debug Build with debugging code and symbols
--verbose Disable silent build to see compilation details
--with-api-docs Install XBPS API Library documentation (default disabled)
--with-pie Build XBPS programs as PIE (default disabled)
--with-static Build XBPS static utils (default disabled)
--with-tests Build and install Kyua tests (default disabled)
Needs atf >= 0.15 (http://code.google.com/p/kyua)
@ -70,7 +68,6 @@ for x; do
--datadir|--infodir) ;; # ignore autotools
--with-api-docs) BUILD_API_DOCS=$var;;
--verbose) unset SILENT;;
--with-pie) BUILD_PIE=$var;;
--pkgconfigdir) PKGCONFIGDIR=$var;;
--with-tests) BUILD_TESTS=yes;;
--with-static) BUILD_STATIC=yes;;
@ -159,7 +156,6 @@ ETCDIR="${ETCDIR}/xbps"
echo "ETCDIR ?= $ETCDIR" >>$CONFIG_MK
[ -z "$DEBUG" ] && DEBUG=no
[ -z "$BUILD_PIE" ] && BUILD_PIE_VALUE=no
if [ -z "$CC" ]; then
printf "Looking for compiler ... "
@ -212,7 +208,6 @@ linux)
;;
esac
# Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features
XCC="$CC `$SED -n -e 's/CPPLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
XCC="$XCC `$SED -n -e 's/CFLAGS+=*\(.*\)/\1/p' $CONFIG_MK`"
@ -295,20 +290,22 @@ if [ $? -ne 0 ]; then
check_compiler_flag dynamic r LIBXBPS_LDFLAGS
fi
#
# Check for -Wl,-z,relro,-z,now
check_compiler_flag "l,-z,relro,-z,now" W LDFLAGS
#
# Check if -fPIE and -pie are supported if --build-pie is set.
#
if [ -n "$BUILD_PIE" ]; then
check_compiler_flag PIE f PROG_CFLAGS
if [ $? -eq 0 ]; then
check_compiler_flag PIE f PROG_CFLAGS
if [ $? -eq 0 ]; then
check_compiler_flag pie "" PROG_LDFLAGS
fi
if [ $? -eq 0 ]; then
fi
if [ $? -eq 0 ]; then
echo "Building programs as PIE (Position Independent Executable)."
BUILD_PIE_VALUE=yes
else
else
BUILD_PIE_VALUE=no
fi
fi
#