configure.ac: Only compile with -fPIC if the target supports it.
authorHans-Peter Nilsson <hp@axis.com>
Tue, 25 Aug 2015 23:32:06 +0000 (23:32 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Tue, 25 Aug 2015 23:32:06 +0000 (23:32 +0000)
* configure.ac: Only compile with -fPIC if the target
supports it.
* configure: Regenerate.

From-SVN: r227203

libbacktrace/ChangeLog
libbacktrace/configure
libbacktrace/configure.ac

index c31c651f95c6b3b83bda5f7ca7778988f599c7ae..8961199e36d860a6354dd8924e644275cee504c3 100644 (file)
@@ -1,3 +1,9 @@
+2015-08-26  Hans-Peter Nilsson  <hp@axis.com>
+
+       * configure.ac: Only compile with -fPIC if the target
+       supports it.
+       * configure: Regenerate.
+
 2015-08-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * configure.ac: Set have_mmap to no on spu-*-* targets.
index 268659948e8daad0c405a7c594b98492549c1fe3..72832d529e1700af0e9357990589e016e8d30adc 100755 (executable)
 
 # When building as a target library, shared libraries may want to link
 # this in.  We don't want to provide another shared library to
-# complicate dependencies.  Instead, we just compile with -fPIC.
+# complicate dependencies.  Instead, we just compile with -fPIC, if
+# the target supports compiling with that option.
 PIC_FLAG=
 if test -n "${with_target_subdir}"; then
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -fPIC"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
   PIC_FLAG=-fPIC
 fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  CFLAGS="$ac_save_CFLAGS"
+fi
 # Similarly, use -fPIC with --enable-host-shared:
 # Check whether --enable-host-shared was given.
 if test "${enable_host_shared+set}" = set; then :
index a0e487bb42d71fa88cda59a0b16cbf733716cfaa..feca006974b39c953081a8d6ebb10da3dc53f505 100644 (file)
@@ -163,10 +163,14 @@ fi
 
 # When building as a target library, shared libraries may want to link
 # this in.  We don't want to provide another shared library to
-# complicate dependencies.  Instead, we just compile with -fPIC.
+# complicate dependencies.  Instead, we just compile with -fPIC, if
+# the target supports compiling with that option.
 PIC_FLAG=
 if test -n "${with_target_subdir}"; then
-  PIC_FLAG=-fPIC
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -fPIC"
+  AC_TRY_COMPILE([], [], [PIC_FLAG=-fPIC])
+  CFLAGS="$ac_save_CFLAGS"
 fi
 # Similarly, use -fPIC with --enable-host-shared:
 AC_ARG_ENABLE(host-shared,