]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* acinclude.m4 (grub_CHECK_PIC): New test.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 29 Feb 2012 14:30:11 +0000 (15:30 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 29 Feb 2012 14:30:11 +0000 (15:30 +0100)
* configure.ac: Add -fno-PIC to TARGET_CFLAGS if -fPIC is default.

ChangeLog
acinclude.m4
configure.ac

index 018b771ed0b76947c68f237edf414ece7b1073a9..9bde17b606e5ce380712f7a31e2cceff540c93b3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 5c623baeefd0237c237d912a6aae55a41a7e23ae..0eb2e2a17a8d17f35b0b94af1c4aed2a9c184805 100644 (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]
+])
index 4b64653c8cc693023b87effc799fa0aac57debbf..4f482f647fe6ffd6d9ed9022bff6b59b791419c8 100644 (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