14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl Check for support for position independent executables
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl Copyright (C) 2013 Red Hat, Inc.
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl This library is free software; you can redistribute it and/or
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl modify it under the terms of the GNU Lesser General Public
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl License as published by the Free Software Foundation; either
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl version 2.1 of the License, or (at your option) any later version.
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl This library is distributed in the hope that it will be useful,
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl Lesser General Public License for more details.
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl You should have received a copy of the GNU Lesser General Public
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomidnl License along with this library. If not, see
14a7cd46677cc0052319f2cd84a7b720efa60499Aki TuomiAC_DEFUN([AC_CC_PIE],[
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi PIE_LDFLAGS=
fdf3e1e28e824a562b895c8c6b5d77d70146d357Josef 'Jeff' Sipek if test $enable_hardening = yes; then
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi OLD_CFLAGS=$CFLAGS
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi case "$host" in
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi *-*-mingw* | *-*-msvc* | *-*-cygwin* )
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi ;; dnl All code is position independent on Win32 target
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi CFLAGS="-fPIE -DPIE"
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi gl_COMPILER_OPTION_IF([-pie], [
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi PIE_CFLAGS="-fPIE -DPIE"
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi PIE_LDFLAGS="-pie"
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi dnl some versions of clang require -Wl,-pie instead of -pie
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi gl_COMPILER_OPTION_IF([[-Wl,-pie]], [
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi PIE_CFLAGS="-fPIE -DPIE"
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi PIE_LDFLAGS="-Wl,-pie"
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi ], [AC_MSG_RESULT([not supported])],
7e86d6308f3f4226c3ed42052cbeb11749821bc2Aki Tuomi [AC_LANG_PROGRAM()]
7e86d6308f3f4226c3ed42052cbeb11749821bc2Aki Tuomi [AC_LANG_PROGRAM()]
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi CFLAGS=$OLD_CFLAGS
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi AC_SUBST([PIE_CFLAGS])
14a7cd46677cc0052319f2cd84a7b720efa60499Aki Tuomi AC_SUBST([PIE_LDFLAGS])