Hi,

Sometimes 'make config' or 'make reconfig' don't work well.

Please consider the following situation:

1. Do 'hg clone' to get the latest source codes.
2. Do 'make config && make'.
3. A few days later, do 'hg pull -u' to get the updated codes
   which include updated src/auto/configure. (To simulate this, just do
   'touch src/auto/configure'.)
4. Do 'make config' again. Then the following error will be shown:

configure: loading cache auto/config.cache
configure: error: `CFLAGS' has changed since the previous run:
configure:   former value:  `-g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1'
configure:   current value: `-g -O2 -U_FORTIFY_SOURCE  -U_FORTIFY_SOURCE 
-D_FORTIFY_SOURCE=1'
configure: error: `LDFLAGS' has changed since the previous run:
configure:   former value:  `-L.       -L/usr/local/lib -Wl,--as-needed'
configure:   current value: `-L.      -L.       -L/usr/local/lib 
-Wl,--as-needed -Wl,--as-needed'
configure: error: in `/cygdrive/c/work/vim/src':
configure: error: changes in the environment can compromise the build
configure: error: run `make distclean' and/or `rm auto/config.cache' and start 
over
Makefile:1657: recipe for target `config' failed
make: *** [config] Error 1

When I run 'make distclean' as the message says, I get the same error again.
This is caused by dependency of 'auto/config.mk'. The 'Makefile' includes
'auto/config.mk' which depends on 'auto/configure'. So if 'auto/configure'
is updated, the 'make' command tries to update 'auto/config.mk' before doing
'make distclean' itself.

If I run 'rm auto/config.cache', 'make config' succeeds at that time.
But if src/auto/configure is updated again, the same error will be shown again.
Additionally, 'CFLAGS' and 'LDFLAGS' become longer and longer when I run
'rm auto/config.cache && make config' again and again.

I made a patch to fix this strange behavior.
'rm auto/config.cache' will be done automatically if needed.
'CFLAGS' and 'LDFLAGS' are also fixed properly.

Best regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


# HG changeset patch
# Parent 5ec6d1aa71bed577c98066badacdff9cba8e0265

diff --git a/src/Makefile b/src/Makefile
--- a/src/Makefile
+++ b/src/Makefile
@@ -1656,6 +1656,11 @@
 # sure configure is run when it's needed.
 #
 config auto/config.mk: auto/configure config.mk.in config.h.in
+	if test -f auto/config.cache && \
+	    grep '^ac_cv_env_CFLAGS_value=' auto/config.cache > /dev/null && \
+	    ! grep -x -F 'ac_cv_env_CFLAGS_value=$(CFLAGS)' auto/config.cache > /dev/null; then \
+		rm auto/config.cache; \
+	fi
 	GUI_INC_LOC="$(GUI_INC_LOC)" GUI_LIB_LOC="$(GUI_LIB_LOC)" \
 		CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \
 		LDFLAGS="$(LDFLAGS)" $(CONF_SHELL) srcdir="$(srcdir)" \
diff --git a/src/configure.in b/src/configure.in
--- a/src/configure.in
+++ b/src/configure.in
@@ -776,6 +776,7 @@
       ldflags_save=$LDFLAGS
       CFLAGS="$CFLAGS $perlcppflags"
       LIBS="$LIBS $perllibs"
+      perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
       LDFLAGS="$perlldflags $LDFLAGS"
       AC_TRY_LINK(,[ ],
 	     AC_MSG_RESULT(yes); perl_ok=yes,
@@ -789,7 +790,9 @@
 	  PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
 	fi
 	if test "X$perlldflags" != "X"; then
-	  LDFLAGS="$perlldflags $LDFLAGS"
+	  if test "X`echo \"$LDFLAGS\" | grep -F -e \"$perlldflags\"`" = "X"; then
+	    LDFLAGS="$perlldflags $LDFLAGS"
+	  fi
 	fi
 	PERL_LIBS=$perllibs
 	PERL_SRC="auto/if_perl.c if_perlsfio.c"
@@ -1518,7 +1521,9 @@
 	  dnl configure, so strip these flags first (if present)
 	  rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
 	  if test "X$rubyldflags" != "X"; then
-	    LDFLAGS="$rubyldflags $LDFLAGS"
+	    if test "X`echo \"$LDFLAGS\" | grep -F -e \"$rubyldflags\"`" = "X"; then
+	      LDFLAGS="$rubyldflags $LDFLAGS"
+	    fi
 	  fi
 	fi
 	RUBY_SRC="if_ruby.c"
@@ -3682,7 +3687,7 @@
   dnl And undefine it first to avoid a warning.
   AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
   if test "$gccmajor" -gt "3"; then
-    CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
+    CFLAGS=`echo "$CFLAGS" | sed -e 's/ *-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/ *-D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
     AC_MSG_RESULT(yes)
   else
     AC_MSG_RESULT(no)
@@ -3697,7 +3702,7 @@
 LINK_AS_NEEDED=
 # Check if linker supports --as-needed and --no-as-needed options
 if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
-  LDFLAGS="$LDFLAGS -Wl,--as-needed"
+  LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *-Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
   LINK_AS_NEEDED=yes
 fi
 if test "$LINK_AS_NEEDED" = yes; then

Raspunde prin e-mail lui