summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-03-28 08:07:31 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-03-28 16:59:03 +0400
commite530f7a2abee2fd80a0672bbd71f91a52c244053 (patch)
tree44af5f0d155050d879bd57a07fcf7792e23674aa
parent0e7d3a78cb86042ba3b1e4920adf7eae73e6b5b5 (diff)
downloadlibatomic_ops-e530f7a2abee2fd80a0672bbd71f91a52c244053.tar.gz
Fix configure to define __PIC__ macro explicitly only if not done by GCC
(Apply commit 058dd11 from 'master' branch) * configure.ac (PICFLAG): Adjust AC_MSG_CHECKING message; report "none" result if no -fPIC is needed (for Cygwin/MinGW); determine whether GCC -fPIC option causes __PIC__ macro definition; pass -D __PIC__ to PICFLAG (instead of CFLAGS) only if not defined automatically in case -fPIC specified; update comment.
-rw-r--r--configure.ac24
1 files changed, 16 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index 32ce544..f6a0b93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,24 +19,32 @@ AC_FUNC_MMAP
AC_HEADER_STDC
# AC_CHECK_HEADERS([ ])
-# Determine PIC flag, adjust default CFLAGS
+# Determine PIC flag.
need_asm=false
PICFLAG=
-AC_MSG_CHECKING(Determining PIC compiler flag)
+AC_MSG_CHECKING(for PIC compiler flag)
if test "$GCC" = yes; then
case "$host" in
- *-*-solaris*)
- AC_MSG_RESULT(-fPIC)
- PICFLAG=-fPIC
- # Workaround: at least GCC 3.4.6 does not define this macro.
- CFLAGS="$CFLAGS -D__PIC__=1"
- ;;
*-*-cygwin* | *-*-mingw*)
# Cygwin and Mingw[-w32/64] do not need -fPIC.
+ AC_MSG_RESULT("<none>")
;;
*)
AC_MSG_RESULT(-fPIC)
PICFLAG=-fPIC
+ AC_MSG_CHECKING(whether gcc -fPIC causes __PIC__ definition)
+ # Workaround: at least GCC 3.4.6 (Solaris) does not define this macro.
+ old_CFLAGS="$CFLAGS"
+ CFLAGS="$PICFLAG $CFLAGS"
+ AC_TRY_COMPILE([],[
+ #ifndef __PIC__
+ # error
+ #endif
+ ], [ac_cv_pic_macro=yes], [ac_cv_pic_macro=no])
+ CFLAGS="$old_CFLAGS"
+ AC_MSG_RESULT($ac_cv_pic_macro)
+ AS_IF([test "$ac_cv_pic_macro" = yes], [],
+ [PICFLAG="-D__PIC__=1 $PICFLAG"])
;;
esac
else