| 1 |
AC_DEFUN([AX_CHECK_PIE], [ |
| 2 |
AC_ARG_ENABLE([pie], AS_HELP_STRING([--disable-pie], [Disable Position-Independent Executable]), [], [enable_pie=yes]) |
| 3 |
AS_IF([test "x$enable_pie" = "xyes"], [ |
| 4 |
AC_MSG_CHECKING([if $CC supports PIE]) |
| 5 |
BAKLDFLAGS="$LDFLAGS" |
| 6 |
BAKCFLAGS="$CFLAGS" |
| 7 |
LDFLAGS="$LDFLAGS -pie" |
| 8 |
CFLAGS="$CFLAGS -fpie -fPIE -DPIE" |
| 9 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ |
| 10 |
if $CC $CFLAGS $LDFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then |
| 11 |
LDFLAGS="$BAKLDFLAGS" |
| 12 |
AC_MSG_RESULT(no) |
| 13 |
else |
| 14 |
AC_MSG_RESULT(yes) |
| 15 |
fi |
| 16 |
rm -f conftest conftest.c conftest.o |
| 17 |
], [LDFLAGS="$BAKLDFLAGS" ; CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)]) |
| 18 |
]) |
| 19 |
]) |