11dnl Process this file with autoconf to produce a configure script.
2- dnl $Header: /cvsroot/pgsql/configure.in,v 1.295 2003/10/14 00:48:09 momjian Exp $
2+ dnl $Header: /cvsroot/pgsql/configure.in,v 1.296 2003/10/15 22:23:56 tgl Exp $
33dnl
44dnl Developers, please strive to achieve this order:
55dnl
@@ -234,18 +234,28 @@ AC_PROG_CC([$pgac_cc_list])
234234#
235235. "$srcdir/src/template/$template" || exit
236236
237- # adjust CFLAGS per template
237+ # The template may have supplied a default setting for CFLAGS.
238+ # Override this if CFLAGS was set in the original environment.
238239if test "$ac_env_CFLAGS_set" = set; then
239240 CFLAGS=$ac_env_CFLAGS_value
240- fi
241- if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
242- CFLAGS="$CFLAGS -g"
243241else
244- # configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc
245- if test x"$CFLAGS" = x""; then
246- CFLAGS="-O"
242+ # autoconf already set the default CFLAGS for gcc to be -O2, but we
243+ # need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
244+ if test "$GCC" = yes; then
245+ CFLAGS="$CFLAGS -fno-strict-aliasing"
247246 fi
248247fi
248+ # supply -g if --enable-debug
249+ if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
250+ CFLAGS="$CFLAGS -g"
251+ fi
252+ # default to -O rather than empty CFLAGS; this path will not be taken for
253+ # gcc (since autoconf supplies -O2), nor if --enable-debug (because -O -g
254+ # doesn't work on most non-gcc compilers), nor if the template provided
255+ # some CFLAGS.
256+ if test "$ac_env_CFLAGS_set" != set -a x"$CFLAGS" = x""; then
257+ CFLAGS="-O"
258+ fi
249259AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
250260
251261# We already have this in Makefile.win32, but configure needs it too
@@ -261,7 +271,7 @@ AC_TRY_LINK([], [return 0;],
261271 [AC_MSG_RESULT(no)
262272 AC_MSG_ERROR([cannot proceed])])
263273
264- # Defend against gcc -ffastmath
274+ # Defend against gcc -ffast-math
265275if test "$GCC" = yes; then
266276AC_TRY_COMPILE([], [@%:@ifdef __FAST_MATH__
267277choke me