aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/c-compiler.m418
-rwxr-xr-xconfigure110
-rw-r--r--configure.in12
3 files changed, 138 insertions, 2 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index cc25cf94ba0..2e3fba877a3 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -1,5 +1,5 @@
# Macros to detect C compiler features
-# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.16 2008/04/18 18:43:08 alvherre Exp $
+# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.17 2008/05/18 20:13:12 tgl Exp $
# PGAC_C_SIGNED
@@ -110,3 +110,19 @@ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[CFLAGS="$pgac_save_CFLAGS"
AC_MSG_RESULT(no)])
])# PGAC_PROG_CC_CFLAGS_OPT
+
+
+
+# PGAC_PROG_CC_LDFLAGS_OPT
+# ------------------------
+# Given a string, check if the compiler supports the string as a
+# command-line option. If it does, add the string to LDFLAGS.
+AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
+[AC_MSG_CHECKING([if $CC supports $1])
+pgac_save_LDFLAGS=$LDFLAGS
+LDFLAGS="$pgac_save_LDFLAGS $1"
+AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+ AC_MSG_RESULT(yes),
+ [LDFLAGS="$pgac_save_LDFLAGS"
+ AC_MSG_RESULT(no)])
+])# PGAC_PROG_CC_LDFLAGS_OPT
diff --git a/configure b/configure
index f71fcd642d7..20d1f5b4a9e 100755
--- a/configure
+++ b/configure
@@ -4318,6 +4318,116 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+# If compiler will take -Wl,--as-needed then add that to LDFLAGS.
+# This is much easier than trying to filter LIBS to the minimum for each
+# executable. (Note that shared libraries won't use this switch, though.)
+# On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
+if test "$PORTNAME" != "darwin"; then
+ { echo "$as_me:$LINENO: checking if $CC supports -Wl,--as-needed" >&5
+echo $ECHO_N "checking if $CC supports -Wl,--as-needed... $ECHO_C" >&6; }
+pgac_save_LDFLAGS=$LDFLAGS
+LDFLAGS="$pgac_save_LDFLAGS -Wl,--as-needed"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ LDFLAGS="$pgac_save_LDFLAGS"
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+
+else
+ { echo "$as_me:$LINENO: checking if $CC supports -Wl,-dead_strip_dylibs" >&5
+echo $ECHO_N "checking if $CC supports -Wl,-dead_strip_dylibs... $ECHO_C" >&6; }
+pgac_save_LDFLAGS=$LDFLAGS
+LDFLAGS="$pgac_save_LDFLAGS -Wl,-dead_strip_dylibs"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ LDFLAGS="$pgac_save_LDFLAGS"
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+
+fi
+
# Create compiler version string
if test x"$GCC" = x"yes" ; then
cc_string="GCC `${CC} --version | sed q`"
diff --git a/configure.in b/configure.in
index b8f83960308..a888e352749 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.560 2008/05/03 00:24:05 adunstan Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.561 2008/05/18 20:13:12 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@@ -450,6 +450,16 @@ fi
AC_PROG_CPP
AC_SUBST(GCC)
+# If compiler will take -Wl,--as-needed then add that to LDFLAGS.
+# This is much easier than trying to filter LIBS to the minimum for each
+# executable. (Note that shared libraries won't use this switch, though.)
+# On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
+if test "$PORTNAME" != "darwin"; then
+ PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed])
+else
+ PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-dead_strip_dylibs])
+fi
+
# Create compiler version string
if test x"$GCC" = x"yes" ; then
cc_string="GCC `${CC} --version | sed q`"