From 801427abc2924195b35be19abe4f64dbbea82263 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 1 Nov 2003 20:48:51 +0000 Subject: [PATCH] Unset CFLAGS before reading template. This should be more robust. When --enable-debug is used, then the default CFLAGS for non-GCC is just -g without -O. Backpatch enhancement of Autoconf inline test that detects problems with the HP C compiler. --- config/c-compiler.m4 | 42 +++++++++++++++++++++++++++++++++++++++++- configure | 14 +++++++++----- configure.in | 13 ++++++++----- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 1649b105aa..d5fdd2ff9e 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -1,5 +1,5 @@ # Macros to detect C compiler features -# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.9 2003/10/25 15:32:11 petere Exp $ +# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.10 2003/11/01 20:48:51 petere Exp $ # PGAC_C_SIGNED @@ -149,3 +149,43 @@ CFLAGS=$pgac_save_CFLAGS if test "$ac_env_CFLAGS_set" != set; then CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing" fi])# PGAC_PROG_CC_NO_STRICT_ALIASING + + +# The below backpatches the following Autoconf change: +# +# 2002-03-28 Kevin Ryde +# +# * lib/autoconf/c.m4 (AC_C_INLINE): Test with a typedef return value, +# to avoid versions of HP C which don't allow that. +# +# When we upgrade to Autoconf >= 2.53a then we can drop this and rely +# on the standard macro. + +# AC_C_INLINE +# ----------- +# Do nothing if the compiler accepts the inline keyword. +# Otherwise define inline to __inline__ or __inline if one of those work, +# otherwise define inline to be empty. +AC_DEFUN([AC_C_INLINE], +[AC_REQUIRE([AC_PROG_CC_STDC])dnl +AC_CACHE_CHECK([for inline], ac_cv_c_inline, +[ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + AC_COMPILE_IFELSE([AC_LANG_SOURCE( +[#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw int foo () {return 0; } +#endif +])], + [ac_cv_c_inline=$ac_kw; break]) +done +]) +case $ac_cv_c_inline in + inline | yes) ;; + no) AC_DEFINE(inline,, + [Define as `__inline' if that's what the C compiler calls it, + or to nothing if it is not supported.]) ;; + *) AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline) ;; +esac +])# AC_C_INLINE diff --git a/configure b/configure index 992e289fbe..e7f93a27cc 100755 --- a/configure +++ b/configure @@ -2384,7 +2384,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -pgac_CFLAGS_before_template=$CFLAGS +unset CFLAGS # # Read the template @@ -2399,12 +2399,15 @@ pgac_CFLAGS_before_template=$CFLAGS if test "$ac_env_CFLAGS_set" = set; then CFLAGS=$ac_env_CFLAGS_value -elif test "$pgac_CFLAGS_before_template" != "$CFLAGS"; then +elif test "${CFLAGS+set}" = set; then : # (keep what template set) elif test "$GCC" = yes; then CFLAGS="-O2" else - CFLAGS="-O" + # if the user selected debug mode, don't use -O + if test "$enable_debug" != yes; then + CFLAGS="-O" + fi fi # Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later. @@ -2473,7 +2476,7 @@ if test "$ac_env_CFLAGS_set" != set; then fi # supply -g if --enable-debug -if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then +if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then CFLAGS="$CFLAGS -g" fi @@ -9314,7 +9317,8 @@ for ac_kw in inline __inline__ __inline; do #line $LINENO "configure" #include "confdefs.h" #ifndef __cplusplus -static $ac_kw int static_foo () {return 0; } +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } $ac_kw int foo () {return 0; } #endif diff --git a/configure.in b/configure.in index 46ee9d05c0..124be26ff0 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $Header: /cvsroot/pgsql/configure.in,v 1.299 2003/10/28 20:26:45 tgl Exp $ +dnl $Header: /cvsroot/pgsql/configure.in,v 1.300 2003/11/01 20:48:51 petere Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -229,7 +229,7 @@ esac AC_PROG_CC([$pgac_cc_list]) -pgac_CFLAGS_before_template=$CFLAGS +unset CFLAGS # # Read the template @@ -244,19 +244,22 @@ pgac_CFLAGS_before_template=$CFLAGS if test "$ac_env_CFLAGS_set" = set; then CFLAGS=$ac_env_CFLAGS_value -elif test "$pgac_CFLAGS_before_template" != "$CFLAGS"; then +elif test "${CFLAGS+set}" = set; then : # (keep what template set) elif test "$GCC" = yes; then CFLAGS="-O2" else - CFLAGS="-O" + # if the user selected debug mode, don't use -O + if test "$enable_debug" != yes; then + CFLAGS="-O" + fi fi # Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later. PGAC_PROG_CC_NO_STRICT_ALIASING # supply -g if --enable-debug -if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then +if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then CFLAGS="$CFLAGS -g" fi