* acinclude.m4 (grub_CHECK_PIC): New test.

* configure.ac: Add -fno-PIC to TARGET_CFLAGS if -fPIC is default.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-29 15:30:11 +01:00
parent 97304d7c53
commit 7bd8b0c776
3 changed files with 41 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2012-02-29 Vladimir Serbinenko <phcoder@gmail.com>
* acinclude.m4 (grub_CHECK_PIC): New test.
* configure.ac: Add -fno-PIC to TARGET_CFLAGS if -fPIC is default.
2012-02-29 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/libgcc.h (__STDC_VERSION__): Define if it's not yet so

View File

@ -424,3 +424,31 @@ else
AC_MSG_RESULT([no])
[fi]
])
dnl Check if the C compiler supports `-fPIC'.
AC_DEFUN([grub_CHECK_PIC],[
[# Position independent executable.
pic_possible=yes]
AC_MSG_CHECKING([whether `$CC' has `-fPIC' as default])
# Is this a reliable test case?
AC_LANG_CONFTEST([AC_LANG_SOURCE([[
#ifdef __PIC__
int main() {
return 0;
}
#else
#error NO __PIC__ DEFINED
#endif
]])])
[# `$CC -c -o ...' might not be portable. But, oh, well... Is calling
# `ac_compile' like this correct, after all?
if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then]
AC_MSG_RESULT([yes])
[# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
rm -f conftest.s
else
pic_possible=no]
AC_MSG_RESULT([no])
[fi]
])

View File

@ -596,6 +596,14 @@ if [ x"$pie_possible" = xyes ]; then
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
fi]
# Position independent executable.
grub_CHECK_PIC
[# Need that, because some distributions ship compilers that include
# `-fPIC' in the default specs.
if [ x"$pic_possible" = xyes ]; then
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
fi]
# Smashing stack protector.
grub_CHECK_STACK_PROTECTOR
# Need that, because some distributions ship compilers that include