Skip to content

Commit 801427a

Browse files
committed
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.
1 parent 0543af2 commit 801427a

File tree

3 files changed

+58
-11
lines changed

3 files changed

+58
-11
lines changed

config/c-compiler.m4

+41-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Macros to detect C compiler features
2-
# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.9 2003/10/25 15:32:11 petere Exp $
2+
# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.10 2003/11/01 20:48:51 petere Exp $
33

44

55
# PGAC_C_SIGNED
@@ -149,3 +149,43 @@ CFLAGS=$pgac_save_CFLAGS
149149
if test "$ac_env_CFLAGS_set" != set; then
150150
CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing"
151151
fi])# PGAC_PROG_CC_NO_STRICT_ALIASING
152+
153+
154+
# The below backpatches the following Autoconf change:
155+
#
156+
# 2002-03-28 Kevin Ryde <[email protected]>
157+
#
158+
# * lib/autoconf/c.m4 (AC_C_INLINE): Test with a typedef return value,
159+
# to avoid versions of HP C which don't allow that.
160+
#
161+
# When we upgrade to Autoconf >= 2.53a then we can drop this and rely
162+
# on the standard macro.
163+
164+
# AC_C_INLINE
165+
# -----------
166+
# Do nothing if the compiler accepts the inline keyword.
167+
# Otherwise define inline to __inline__ or __inline if one of those work,
168+
# otherwise define inline to be empty.
169+
AC_DEFUN([AC_C_INLINE],
170+
[AC_REQUIRE([AC_PROG_CC_STDC])dnl
171+
AC_CACHE_CHECK([for inline], ac_cv_c_inline,
172+
[ac_cv_c_inline=no
173+
for ac_kw in inline __inline__ __inline; do
174+
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
175+
[#ifndef __cplusplus
176+
typedef int foo_t;
177+
static $ac_kw foo_t static_foo () {return 0; }
178+
$ac_kw int foo () {return 0; }
179+
#endif
180+
])],
181+
[ac_cv_c_inline=$ac_kw; break])
182+
done
183+
])
184+
case $ac_cv_c_inline in
185+
inline | yes) ;;
186+
no) AC_DEFINE(inline,,
187+
[Define as `__inline' if that's what the C compiler calls it,
188+
or to nothing if it is not supported.]) ;;
189+
*) AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline) ;;
190+
esac
191+
])# AC_C_INLINE

configure

+9-5
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
23842384
ac_compiler_gnu=$ac_cv_c_compiler_gnu
23852385

23862386

2387-
pgac_CFLAGS_before_template=$CFLAGS
2387+
unset CFLAGS
23882388

23892389
#
23902390
# Read the template
@@ -2399,12 +2399,15 @@ pgac_CFLAGS_before_template=$CFLAGS
23992399

24002400
if test "$ac_env_CFLAGS_set" = set; then
24012401
CFLAGS=$ac_env_CFLAGS_value
2402-
elif test "$pgac_CFLAGS_before_template" != "$CFLAGS"; then
2402+
elif test "${CFLAGS+set}" = set; then
24032403
: # (keep what template set)
24042404
elif test "$GCC" = yes; then
24052405
CFLAGS="-O2"
24062406
else
2407-
CFLAGS="-O"
2407+
# if the user selected debug mode, don't use -O
2408+
if test "$enable_debug" != yes; then
2409+
CFLAGS="-O"
2410+
fi
24082411
fi
24092412

24102413
# 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
24732476
fi
24742477

24752478
# supply -g if --enable-debug
2476-
if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
2479+
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
24772480
CFLAGS="$CFLAGS -g"
24782481
fi
24792482

@@ -9314,7 +9317,8 @@ for ac_kw in inline __inline__ __inline; do
93149317
#line $LINENO "configure"
93159318
#include "confdefs.h"
93169319
#ifndef __cplusplus
9317-
static $ac_kw int static_foo () {return 0; }
9320+
typedef int foo_t;
9321+
static $ac_kw foo_t static_foo () {return 0; }
93189322
$ac_kw int foo () {return 0; }
93199323
#endif
93209324

configure.in

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.299 2003/10/28 20:26:45 tgl Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.300 2003/11/01 20:48:51 petere Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -229,7 +229,7 @@ esac
229229

230230
AC_PROG_CC([$pgac_cc_list])
231231

232-
pgac_CFLAGS_before_template=$CFLAGS
232+
unset CFLAGS
233233

234234
#
235235
# Read the template
@@ -244,19 +244,22 @@ pgac_CFLAGS_before_template=$CFLAGS
244244

245245
if test "$ac_env_CFLAGS_set" = set; then
246246
CFLAGS=$ac_env_CFLAGS_value
247-
elif test "$pgac_CFLAGS_before_template" != "$CFLAGS"; then
247+
elif test "${CFLAGS+set}" = set; then
248248
: # (keep what template set)
249249
elif test "$GCC" = yes; then
250250
CFLAGS="-O2"
251251
else
252-
CFLAGS="-O"
252+
# if the user selected debug mode, don't use -O
253+
if test "$enable_debug" != yes; then
254+
CFLAGS="-O"
255+
fi
253256
fi
254257

255258
# Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
256259
PGAC_PROG_CC_NO_STRICT_ALIASING
257260

258261
# supply -g if --enable-debug
259-
if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
262+
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
260263
CFLAGS="$CFLAGS -g"
261264
fi
262265

0 commit comments

Comments
 (0)