$OpenBSD: patch-src_configure,v 1.1.1.1 2015/07/16 00:20:53 juanfra Exp $

"adjust auto-configuration of CPPFLAGS vs. CFLAGS"

https://github.com/plt/racket/commit/cf8c3c9cfe767a767a7237c34075e69cdfd16f64

"configure: fix '--enable-noopt'"

https://github.com/plt/racket/commit/40f79dd72e1da335c490e4e7f50841037e589c97

--- src/configure.orig	Mon Jul 13 22:54:14 2015
+++ src/configure	Mon Jul 13 22:53:11 2015
@@ -3268,7 +3268,16 @@ if test "${enable_ios}" != "" ; then
   SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} LDFLAGS="'"'"${LDFLAGS}"'"'
 fi
 
+
 if test "${enable_oskit}" = "no" ; then
+  # Auto-set CC, CPP, etc.
+
+  if test "${CFLAGS}${CC}${CPP}" = "" ; then
+    starts_out_default=yes
+  else
+    starts_out_default=no
+  fi
+
   ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4195,6 +4204,18 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext 
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+
+  if test "$starts_out_default" = "yes" ; then
+    if test "$GCC" = "yes" ; then
+      # Auto selection of C compiler picked GCC, so we
+      # assume it also picked the GNU preprocessor; move
+      # auto-picked CFLAGS to PREFLAGS so that compilation
+      # and preprocessing are in sync (e.g., for optimization flags)
+      PREFLAGS="${CFLAGS} ${PREFLAGS}"
+      CPPFLAGS="${CFLAGS} ${CPPFLAGS}"
+      CFLAGS=""
+    fi
+  fi
   if test "$AS" = '' ; then
     AS="${ac_tool_prefix}as"
     as_was_set=no
@@ -6560,6 +6581,8 @@ fi
 if test "${enable_noopt}" = "yes" ; then
   AWKPRG='BEGIN { FS = "(^| )-O(0|1|2|3|4|5|6|7|8|9)?( |$)" } /.*/ { for (i = 1; i < NF; i++) printf "%s ", $i; print $NF }'
   CFLAGS=`echo "$CFLAGS" | awk "$AWKPRG"`
+  CPPFLAGS=`echo "$CPPFLAGS" | awk "$AWKPRG"`
+  PREFLAGS=`echo "$PREFLAGS" | awk "$AWKPRG"`
 fi
 
 ############## usersetup ################
