than having CFLAGS= in the template files.
It uses -O2 for gcc (generated by autoconf), and -O for non-gcc, unless
the template overrides it.
 if test "$ac_env_CFLAGS_set" = set; then
   CFLAGS=$ac_env_CFLAGS_value
 fi
+# configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc
+if test x"$CFLAGS" = x""; then
+   CFLAGS="-O"
+fi
 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
   CFLAGS="$CFLAGS -g"
 fi
 
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.293 2003/10/03 03:08:14 pgsql Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.294 2003/10/09 03:20:33 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
 if test "$ac_env_CFLAGS_set" = set; then
   CFLAGS=$ac_env_CFLAGS_value
 fi
+# configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc
+if test x"$CFLAGS" = x""; then 
+   CFLAGS="-O"
+fi
 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
   CFLAGS="$CFLAGS -g"
 fi
 
 esac
 
 case $host_os in
-  bsdi2.0 | bsdi2.1 | bsdi3*)
-    CC=gcc2
-    ;;
+  bsdi2.0 | bsdi2.1 | bsdi3*) CC=gcc2;;
 esac
 
 THREAD_SUPPORT=yes
 
-CFLAGS='-O2'
 SRCH_LIB='/usr/local/lib'
 
-CFLAGS='-pipe'
-
 case $host_cpu in
-  alpha*)   CFLAGS="$CFLAGS -O" ;;
+  alpha*)   CFLAGS="-O";;
 esac
 
 THREAD_SUPPORT=yes
 NEED_REENTRANT_FUNCS=yes
 THREAD_CPPFLAGS="-D_THREAD_SAFE"
 case $host_os in
-       freebsd2*|freebsd3*|freebsd4*)
-           THREAD_LIBS="-pthread"
-           ;;
-       *)
-           THREAD_LIBS="-lc_r"
-           ;;
+   freebsd2*|freebsd3*|freebsd4*) THREAD_LIBS="-pthread";;
+   *) THREAD_LIBS="-lc_r";;
 esac
 
-if test "$GCC" = yes ; then
-  CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED"
-  CFLAGS="-O2"
-else
+CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED"
+
+if test "$GCC" != yes ; then
   CC="$CC -Ae"
-  CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED"
   CFLAGS="+O2"
 fi
 
-CFLAGS=-O2
 # Force _GNU_SOURCE on; plperl is broken with Perl 5.8.0 otherwise
 CPPFLAGS="-D_GNU_SOURCE"
 
 NEED_REENTRANT_FUNCS=yes   # Debian kernel 2.2 2003-09-27
 THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
 THREAD_LIBS="-lpthread"
-
 
-CFLAGS='-O2 -pipe'
-
 THREAD_SUPPORT=yes
 NEED_REENTRANT_FUNCS=yes   # 1.6 2003-09-14
 
 AROPT=rc
-CFLAGS=
 SHARED_LIB=
 DLSUFFIX=.o
 
-if test "$GCC" = yes ; then
-  CFLAGS=
-else
+if test "$GCC" != yes ; then
   CC="$CC -std"
   CFLAGS='-O4 -Olimit 2000'
 fi
 
-CFLAGS=-I/usr/local/include
-LIBS=-lunix
+CFLAGS="-O2 -I/usr/local/include"
+LIBS="-lunix"
 
-if test "$GCC" = yes; then
-  CFLAGS=-O2
-else
-  CFLAGS=-O
-fi
 CC="$CC -b elf"
 
 
-if test "$GCC" = yes ; then
-  CFLAGS=
-else
+if test "$GCC" != yes ; then
   CC="$CC -Xa"         # relaxed ISO C mode
-  CFLAGS=-v            # -v is like gcc -Wall
+  CFLAGS="-O -v"       # -v is like gcc -Wall
 fi
 
 THREAD_SUPPORT=yes
 
 CFLAGS='-v -O -K i486,host,inline,loop_unroll -Dsvr4'
-LIBS=-lc89 
+LIBS="-lc89"
 
 if test "$GCC" = yes; then
-  CFLAGS=-O2
   THREAD_CPPFLAGS="-pthread"
 else
 # the -Kno_host is temporary for a bug in the compiler.  See -hackers
 
-if test "$GCC" = yes; then
-  CFLAGS="-O2"
-fi
 
-if test "$GCC" = yes; then
-  CFLAGS="-O2"
-fi