Subject: Re: bug#15675: the configure script invoked before make

From: Eli Zaretskii <[email-masked]>
Date: Thu, 24 Oct 2013 19:11:32 +0300

> From: Glenn Morris <[email-masked]>
> Date: Thu, 24 Oct 2013 00:07:01 -0400
> Cc: [email-masked]
> 
> Andy Moreton wrote:
> 
> > CPP = gcc -I ../nt/inc -E
> 
> Seems wrong to me for CPP to contain any -I option. Where does that come from?

>From the configure script.

The story begins, innocently enough, here:

    case "${canonical}" in
      *-darwin* )               opsys=darwin ;;
      *-mingw32 )
		opsys=mingw32
		# MinGW overrides and adds some system headers in nt/inc.
		GCC_TEST_OPTIONS="-I $srcdir/nt/inc"

(MinGW needs the test programs to pick up headers in nt/inc, since
those headers define some stuff which is not available in the MinGW
system headers.  This is what GCC_TEST_OPTIONS are for, right?)

Then the configure script sets CC to something that uses these
switches:

  if test x$GCC = xyes; then
    test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"

So far, so good.  But then:

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
  $as_echo_n "checking how to run the C preprocessor... " >&6; }
  # On Suns, sometimes $CPP names a directory.
  if test -n "$CPP" && test -d "$CPP"; then
    CPP=
  fi
  if test -z "$CPP"; then
    if test "${ac_cv_prog_CPP+set}" = set; then :
    $as_echo_n "(cached) " >&6
  else
	# Double quotes because CPP needs to be expanded
      for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
      do         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [...]
      done
      ac_cv_prog_CPP=$CPP

  fi
    CPP=$ac_cv_prog_CPP

This sets CPP to "$CC -E", and the rest, as they say, is history.

The problem here seems to be that the script confuses the value of CPP
needed to run the test programs with the value of CPP that is needed
to be substituted for @CPP@.  The latter should have any
GCC_TEST_OPTIONS removed from it.