You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by pt...@pobox.com on 2003/02/04 03:32:55 UTC

[PATCH] flood: Fixed floodenv.bat environment problem in Makefile.win.

Summary:
  Fixed floodenv.bat environment problem in Makefile.win.

This submission fixes the floodenv.bat environment problem.  This problem
occurs when Makefile.win tries to set up variables for use by external
prorams using floodenv.bat.  For example, Makefile.win invokes MSDEV
like this:
  floodenv.bat
  msdev flood.dsw /useenv /make ...
The invocation of floodenv.bat and MSDEV occur in independent
environments, so MSDEV does not inherit the environment variables set
by floodenv.bat.  For the build to complete, you need to generate and
invoke floodenv.bat before building with NMAKE and Makefile.win.
For example:
  nmake -f makefile.win floodenv.bat
  floodenv.bat
  nmake -f makefile.win

This patch fixes the problem by allowing Makefile.win to tell floodenv.bat
to set up the environment variables and optionally run some commands in
the new environment.  When we need to invoke an external program like
DevStudio, we tell floodenv.bat to execute the program so that it gets
a properly initialized environment.  The arguments to floodenv.bat
are optional, so you can still set up your environment using just
floodenv.bat.

NOTE: This patch is based on the patch for building without OpenSSL.
I sent this patch in an e-mail titled:
  [PATCH] flood: Fixed Win32 build when not using OpenSSL

Below is a summary of the file changes.

  * Added macro CFG_FLOOD to consolidate all the places
    that evaluate:
      flood - Win32 $(LONG)
    They now just reference $(CFG_FLOOD).
  * Added commentary to our floodenv.bat target.
  * The floodenv.bat target no longer inserts an:
      @echo off
    at the top of the file.  We now suppress the output
    of each line with a leading "@" symbol.  We do so
    because we want the line invoking the optional
    external command to echo the command so we can tell
    what arguments and options are used.
  * The floodenv.bat target now also writes to "$@", which
    is "floodenv.bat".  The usage helps minimize the places
    that use "floodenv.bat", thereby making it easier to
    maintain if we need to change the name in the future.
  * Changed floodenv.bat so that when we specify optional
    arguments to it, then it will execute the commands.
    If you do not specify arguments, you get the old
    behavior---floodenv.bat sets up your environment
    and then exits.
  * Created new macros to represent the different build
    tools we use:
      DEVENV_FLOOD: Uses DEVENV.
      MAKE_FLOOD:   Uses NMAKE to invoke flood.mak
                    (you need to generate flood.mak from within
                    DevStudio).
      MSDEV_FLOOD:  Uses MSDEV to invoke the VC6 flood.dsp
                    using the flood.dsw.
  * Consolidated the build and clean targets with the new
    macros:
      DEVENV_FLOOD, MAKE_FLOOD, MSDEV_FLOOD
    These macros consolidate the usage between the build and
    clean targets.  Several of the redundancy spread across
    multiple lines are now in macros, and their uses are
    simpler single lines.
  * Added .a and .y files to the clean target.  They are
    "generated" files from the "install" target.

--- Makefile.win.orig	Mon Feb 03 13:55:57 2003
+++ Makefile.win	Mon Feb 03 17:56:40 2003
@@ -101,16 +101,31 @@
 LONG=Release
 !ENDIF
 
+CFG_FLOOD = flood - Win32 $(LONG)
+
+# Floodenv.bat sets up environment variables and will optionally
+# execute any command in the new environment.  If we're guaranteed we
+# ran on Windows NT and newer versions, then we can make use of:
+#   goto :EOF
+# instead of:
+#   goto :end
+# and
+#   %*
+# instead of:
+#   %1 ... %9
+# See "goto /?" and "call /?" for details.
 floodenv.bat: Makefile.win
-	echo @echo off>floodenv.bat
-	echo set SRCLIB=$(SRCLIB)>>floodenv.bat
-	echo set APRPATH=$(APRPATH)>>floodenv.bat
-	echo set APRUTILPATH=$(APRUTILPATH)>>floodenv.bat
-	echo set OPENSSLPATH=$(OPENSSLPATH)>>floodenv.bat
-	echo set REGEXPATH=$(REGEXPATH)>>floodenv.bat
+	echo @set SRCLIB=$(SRCLIB)>$@
+	echo @set APRPATH=$(APRPATH)>>$@
+	echo @set APRUTILPATH=$(APRUTILPATH)>>$@
+	echo @set OPENSSLPATH=$(OPENSSLPATH)>>$@
+	echo @set REGEXPATH=$(REGEXPATH)>>$@
 !IF "$(HAVE_SSL)" == "1"
-	echo set LINKSSL=libeay32.lib ssleay32.lib /libpath:"$(SSLBIN)">>floodenv.bat
+	echo @set LINKSSL=libeay32.lib ssleay32.lib /libpath:"$(SSLBIN)">>$@
 !ENDIF
+	echo @if "%%1" == "" goto :end>>$@
+	echo call %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 1>>$@
+	echo :end>>$@
 
 regex.h: $(REGEXPATH)\pcreposix.h
 	copy "$(REGEXPATH)\pcreposix.h" regex.h < <<
@@ -146,41 +161,28 @@
 !ENDIF
 !ENDIF
 
-!IF EXIST("flood.mak")
-
-clean:
-	-floodenv.bat
-	$(MAKE) $(MAKEOPT) -f flood.mak CFG="flood - Win32 $(LONG)" RECURSE=0 CLEAN
-	del config.h floodenv.bat regex.h
-
-build: config.h
-	floodenv.bat
-	$(MAKE) $(MAKEOPT) -f flood.mak CFG="flood - Win32 $(LONG)" RECURSE=0
+DEVENV_FLOOD = call floodenv.bat devenv flood.sln /useenv
+MAKE_FLOOD   = call floodenv.bat $(MAKE) $(MAKEOPT) -f flood.mak \
+               "CFG=$(CFG_FLOOD)" "RECURSE=0"
+MSDEV_FLOOD  = call floodenv.bat msdev flood.dsw /useenv /make "$(CFG_FLOOD)"
 
+clean: floodenv.bat
+!IF EXIST("flood.mak")
+	$(MAKE_FLOOD) CLEAN
 !ELSEIF EXIST("flood.sln")
-
-clean:  
-	-floodenv.bat
-	devenv flood.sln /useenv /clean $(LONG) /project flood
-	del config.h floodenv.bat regex.h
-
-build: config.h
-	floodenv.bat
-	devenv flood.sln /useenv /build $(LONG) /project flood
-
+	$(DEVENV_FLOOD) /clean $(LONG) /project flood
 !ELSE
-
-clean:  
-	-floodenv.bat
-	msdev flood.dsw /USEENV /MAKE \
-		"flood - Win32 $(LONG)" /CLEAN
-	del config.h floodenv.bat regex.h
+	$(MSDEV_FLOOD) /clean
+!ENDIF
+	del .a .y config.h floodenv.bat regex.h
 
 build: config.h
-	floodenv.bat
-	msdev flood.dsw /USEENV /MAKE \
-		"flood - Win32 $(LONG)" 
-
+!IF EXIST("flood.mak")
+	$(MAKE_FLOOD)
+!ELSEIF EXIST("flood.sln")
+	$(DEVENV_FLOOD) /build $(LONG) /project flood
+!ELSE
+	$(MSDEV_FLOOD)
 !ENDIF
 
 install:

Re: [PATCH] flood: Fixed floodenv.bat environment problem in Makefile.win.

Posted by "William A. Rowe, Jr." <wr...@apache.org>.
I liked the earlier patch to enable/disable OpenSSL.  But the patches
below indicate why we don't use batch files... we can't go digging
throughout the system and order the various VisualStudios and
PlatformSDKs correctly; that has to be up to the developer.

SO...

The update to VisualStudio 6.0 format?  +1
Cleaning up the SSL envvars list and detection?  +1
Using floodenv as an 'invoker' of make?  --1

Let me take your patches and experiment later today.  I believe we
can use this general structure to create a 'config' set of envvars that
can be #include'd into makefile.win.  This gets the developer back
to nmake'ing -f makefile.win - after they've run a configure.bat style
app to set up the SSL environment (and perhaps - even capture the
then-current state of the compiler options so that 'memory' of /useenv
is consistent from then on.)

I should have a better sense for this by tomorrow.

Bill


At 08:32 PM 2/3/2003, ptran@pobox.com wrote:
>Summary:
>  Fixed floodenv.bat environment problem in Makefile.win.
>
>This submission fixes the floodenv.bat environment problem.  This problem
>occurs when Makefile.win tries to set up variables for use by external
>prorams using floodenv.bat.  For example, Makefile.win invokes MSDEV
>like this:
>  floodenv.bat
>  msdev flood.dsw /useenv /make ...
>The invocation of floodenv.bat and MSDEV occur in independent
>environments, so MSDEV does not inherit the environment variables set
>by floodenv.bat.  For the build to complete, you need to generate and
>invoke floodenv.bat before building with NMAKE and Makefile.win.
>For example:
>  nmake -f makefile.win floodenv.bat
>  floodenv.bat
>  nmake -f makefile.win
>
>This patch fixes the problem by allowing Makefile.win to tell floodenv.bat
>to set up the environment variables and optionally run some commands in
>the new environment.  When we need to invoke an external program like
>DevStudio, we tell floodenv.bat to execute the program so that it gets
>a properly initialized environment.  The arguments to floodenv.bat
>are optional, so you can still set up your environment using just
>floodenv.bat.
>
>NOTE: This patch is based on the patch for building without OpenSSL.
>I sent this patch in an e-mail titled:
>  [PATCH] flood: Fixed Win32 build when not using OpenSSL
>
>Below is a summary of the file changes.
>
>  * Added macro CFG_FLOOD to consolidate all the places
>    that evaluate:
>      flood - Win32 $(LONG)
>    They now just reference $(CFG_FLOOD).
>  * Added commentary to our floodenv.bat target.
>  * The floodenv.bat target no longer inserts an:
>      @echo off
>    at the top of the file.  We now suppress the output
>    of each line with a leading "@" symbol.  We do so
>    because we want the line invoking the optional
>    external command to echo the command so we can tell
>    what arguments and options are used.
>  * The floodenv.bat target now also writes to "$@", which
>    is "floodenv.bat".  The usage helps minimize the places
>    that use "floodenv.bat", thereby making it easier to
>    maintain if we need to change the name in the future.
>  * Changed floodenv.bat so that when we specify optional
>    arguments to it, then it will execute the commands.
>    If you do not specify arguments, you get the old
>    behavior---floodenv.bat sets up your environment
>    and then exits.
>  * Created new macros to represent the different build
>    tools we use:
>      DEVENV_FLOOD: Uses DEVENV.
>      MAKE_FLOOD:   Uses NMAKE to invoke flood.mak
>                    (you need to generate flood.mak from within
>                    DevStudio).
>      MSDEV_FLOOD:  Uses MSDEV to invoke the VC6 flood.dsp
>                    using the flood.dsw.
>  * Consolidated the build and clean targets with the new
>    macros:
>      DEVENV_FLOOD, MAKE_FLOOD, MSDEV_FLOOD
>    These macros consolidate the usage between the build and
>    clean targets.  Several of the redundancy spread across
>    multiple lines are now in macros, and their uses are
>    simpler single lines.
>  * Added .a and .y files to the clean target.  They are
>    "generated" files from the "install" target.
>
>--- Makefile.win.orig   Mon Feb 03 13:55:57 2003
>+++ Makefile.win        Mon Feb 03 17:56:40 2003
>@@ -101,16 +101,31 @@
> LONG=Release
> !ENDIF
> 
>+CFG_FLOOD = flood - Win32 $(LONG)
>+
>+# Floodenv.bat sets up environment variables and will optionally
>+# execute any command in the new environment.  If we're guaranteed we
>+# ran on Windows NT and newer versions, then we can make use of:
>+#   goto :EOF
>+# instead of:
>+#   goto :end
>+# and
>+#   %*
>+# instead of:
>+#   %1 ... %9
>+# See "goto /?" and "call /?" for details.
> floodenv.bat: Makefile.win
>-       echo @echo off>floodenv.bat
>-       echo set SRCLIB=$(SRCLIB)>>floodenv.bat
>-       echo set APRPATH=$(APRPATH)>>floodenv.bat
>-       echo set APRUTILPATH=$(APRUTILPATH)>>floodenv.bat
>-       echo set OPENSSLPATH=$(OPENSSLPATH)>>floodenv.bat
>-       echo set REGEXPATH=$(REGEXPATH)>>floodenv.bat
>+       echo @set SRCLIB=$(SRCLIB)>$@
>+       echo @set APRPATH=$(APRPATH)>>$@
>+       echo @set APRUTILPATH=$(APRUTILPATH)>>$@
>+       echo @set OPENSSLPATH=$(OPENSSLPATH)>>$@
>+       echo @set REGEXPATH=$(REGEXPATH)>>$@
> !IF "$(HAVE_SSL)" == "1"
>-       echo set LINKSSL=libeay32.lib ssleay32.lib /libpath:"$(SSLBIN)">>floodenv.bat
>+       echo @set LINKSSL=libeay32.lib ssleay32.lib /libpath:"$(SSLBIN)">>$@
> !ENDIF
>+       echo @if "%%1" == "" goto :end>>$@
>+       echo call %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 1>>$@
>+       echo :end>>$@
> 
> regex.h: $(REGEXPATH)\pcreposix.h
>        copy "$(REGEXPATH)\pcreposix.h" regex.h < <<
>@@ -146,41 +161,28 @@
> !ENDIF
> !ENDIF
> 
>-!IF EXIST("flood.mak")
>-
>-clean:
>-       -floodenv.bat
>-       $(MAKE) $(MAKEOPT) -f flood.mak CFG="flood - Win32 $(LONG)" RECURSE=0 CLEAN
>-       del config.h floodenv.bat regex.h
>-
>-build: config.h
>-       floodenv.bat
>-       $(MAKE) $(MAKEOPT) -f flood.mak CFG="flood - Win32 $(LONG)" RECURSE=0
>+DEVENV_FLOOD = call floodenv.bat devenv flood.sln /useenv
>+MAKE_FLOOD   = call floodenv.bat $(MAKE) $(MAKEOPT) -f flood.mak \
>+               "CFG=$(CFG_FLOOD)" "RECURSE=0"
>+MSDEV_FLOOD  = call floodenv.bat msdev flood.dsw /useenv /make "$(CFG_FLOOD)"
> 
>+clean: floodenv.bat
>+!IF EXIST("flood.mak")
>+       $(MAKE_FLOOD) CLEAN
> !ELSEIF EXIST("flood.sln")
>-
>-clean:  
>-       -floodenv.bat
>-       devenv flood.sln /useenv /clean $(LONG) /project flood
>-       del config.h floodenv.bat regex.h
>-
>-build: config.h
>-       floodenv.bat
>-       devenv flood.sln /useenv /build $(LONG) /project flood
>-
>+       $(DEVENV_FLOOD) /clean $(LONG) /project flood
> !ELSE
>-
>-clean:  
>-       -floodenv.bat
>-       msdev flood.dsw /USEENV /MAKE \
>-               "flood - Win32 $(LONG)" /CLEAN
>-       del config.h floodenv.bat regex.h
>+       $(MSDEV_FLOOD) /clean
>+!ENDIF
>+       del .a .y config.h floodenv.bat regex.h
> 
> build: config.h
>-       floodenv.bat
>-       msdev flood.dsw /USEENV /MAKE \
>-               "flood - Win32 $(LONG)" 
>-
>+!IF EXIST("flood.mak")
>+       $(MAKE_FLOOD)
>+!ELSEIF EXIST("flood.sln")
>+       $(DEVENV_FLOOD) /build $(LONG) /project flood
>+!ELSE
>+       $(MSDEV_FLOOD)
> !ENDIF
> 
> install: