]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* README.W32.template: Update the build documentation.
authorPaul Smith <psmith@gnu.org>
Sun, 19 Jun 2016 14:52:17 +0000 (10:52 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 25 Jun 2016 00:50:42 +0000 (20:50 -0400)
* build_w32.bat: Fix issues with Visual Studio builds.  Fix an error
that always created Debug builds.  Support 32bit and 64bit builds.

README.W32.template
build_w32.bat

index 3ac3354f5c9930a2c85e0999b7d619a99afc2e7a..9a0530748b7f2438a583463af9b5f1fb30d0c5ca 100644 (file)
@@ -5,16 +5,15 @@ It has also been used on Windows 95/98/NT, and on OS/2.
 It builds with the MinGW port of GCC (tested with GCC 3.4.2, 4.8.1,
 and 4.9.3).
 
-It also builds with MSVC 2.x, 4.x, 5.x, 6.x, 2003, and 14 (2015) as
-well as with .NET 7.x and .NET 2003.
+It also builds with MSVC 2.x, 4.x, 5.x, 6.x, 2005, 2008, 2010, 2012,
+2013, and 2015 as well as with .NET 7.x and .NET 2003.
 
-As of version 4.0, a build with Guile is supported (tested with Guile
-2.0.3).  To build with Guile, you will need, in addition to Guile
-itself, its dependency libraries and the pkg-config program.  The
-latter is used to figure out which compilation and link switches and
-libraries need to be mentioned on the compiler command lines to
-correctly link with Guile.  A Windows port of pkg-config can be found
-on ezwinports site:
+Building with Guile is supported (tested with Guile 2.0.3).  To build
+with Guile, you will need, in addition to Guile itself, its dependency
+libraries and the pkg-config program.  The latter is used to figure out
+which compilation and link switches and libraries need to be mentioned
+on the compiler command lines to correctly link with Guile.  A Windows
+port of pkg-config can be found on ezwinports site:
 
   http://sourceforge.net/projects/ezwinports/
 
@@ -56,7 +55,7 @@ Building with (MinGW-)GCC using build_w32.bat
  2. Open a W32 command prompt for your installed (MinGW-)GCC, setup a
     correct PATH and other environment variables for it, then execute ...
 
-        build_w32.bat gcc
+        .\build_w32.bat gcc
 
     This produces gnumake.exe in the GccRel directory.
     If you want a version of GNU make built with debugging enabled,
@@ -66,35 +65,44 @@ Building with (MinGW-)GCC using build_w32.bat
     gnumake.exe with Guile if it finds it.  If you have Guile
     installed, but want to build Make without Guile support, type
 
-        build_w32.bat --without-guile gcc
+        .\build_w32.bat --without-guile gcc
 
 
-Building with (MSVC++-)cl using build_w32.bat or NMakefile
-----------------------------------------------------------
+Building with (MSVC++-)cl using build_w32.bat
+---------------------------------------------
 
- 2. Open a W32 command prompt for your installed (MSVC++-)cl, setup a
-    correct PATH and other environment variables for it (usually via
-    executing vcvars32.bat or vsvars32.bat from the cl-installation,
-    e.g. "%VS71COMNTOOLS%vsvars32.bat"; or using a corresponding start
-    menue entry from the cl-installation), then execute EITHER ...
+ 2. Open a command shell, then execute ...
 
-        build_w32.bat
+        .\build_w32.bat
 
-    This produces gnumake.exe in the WinRel directory.
-    If you want a version of GNU make built with debugging enabled,
-    add the --debug option.
+    This produces a 64bit Release build of gnumake.exe in .\WinRel, using
+    the compiler found on the %Path%.  If no compiler is found, the batch
+    file will probe your system and choose the newest MSVC version it can
+    find.
+
+    If you want a 32bit version of GNU make, add the --x86 option.
+
+    If you want a Debug build of GNU make, add the --debug option.
+
+    The batch file will probe for Guile installation, and will build
+    gnumake.exe with Guile if it finds it.  If Guile is installed,
+    but you prefer to build GNU make without Guile support, add the
+    --without-guile option.
 
-    ... OR ...
+
+Building with (MSVC++-)cl using NMakefile
+-----------------------------------------
+
+ 2. Open a W32 command prompt for your installed (MSVC++-)cl, setup a
+    correct PATH and other environment variables for it (usually via
+    executing vcvars32.bat or vsvars32.bat from the cl-installation, or
+    using a corresponding start menu entry from the cl-installation),
+    then execute ...
 
         nmake /f NMakefile
 
     (this produces WinDebug/make.exe and WinRel/make.exe).
 
-    The batch file will probe for Guile installation, and will build
-    gnumake.exe with Guile if it finds it.  If you have Guile
-    installed, but want to build Make without Guile support, type
-
-        build_w32.bat --without-guile
 
 -------------------
 -- Notes/Caveats --
index 59e068b63fc4eb77b04dafa8fcf8e052efa8ded0..07b422a657447bb3aa8bf83fd3b5063213ada899 100755 (executable)
@@ -15,6 +15,7 @@ rem
 rem You should have received a copy of the GNU General Public License along\r
 rem with this program.  If not, see <http://www.gnu.org/licenses/>.\r
 \r
+setlocal\r
 call :Reset\r
 \r
 if "%1" == "-h" goto Usage\r
@@ -22,13 +23,17 @@ if "%1" == "--help" goto Usage
 \r
 set MAKE=gnumake\r
 set GUILE=Y\r
-set COMPILER=msvc\r
+set COMPILER=cl.exe\r
+set ARCH=x64\r
+set DEBUG=N\r
 \r
 :ParseSW\r
 if "%1" == "--debug" goto SetDebug\r
 if "%1" == "--without-guile" goto NoGuile\r
+if "%1" == "--x86" goto Set32Bit\r
 if "%1" == "gcc" goto SetCC\r
 if "%1" == "" goto DoneSW\r
+goto Usage\r
 \r
 :SetDebug\r
 set DEBUG=Y\r
@@ -41,6 +46,11 @@ echo Building without Guile
 shift\r
 goto ParseSW\r
 \r
+:Set32Bit\r
+set ARCH=x86\r
+shift\r
+goto ParseSW\r
+\r
 :SetCC\r
 set COMPILER=gcc\r
 echo Building with GCC\r
@@ -50,11 +60,65 @@ goto ParseSW
 rem Build with Guile is supported only on NT and later versions\r
 :DoneSW\r
 echo.\r
-echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8\r
+echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8/10\r
 if "%DEBUG%" == "Y" echo Building without compiler optimizations\r
 \r
 if "%COMPILER%" == "gcc" goto GccBuild\r
 \r
+rem Make sure we can find a compiler\r
+%COMPILER% >nul 2>&1\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS71COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%VS70COMNTOOLS%\..\..\VC\vcvarsall.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%V6TOOLS%\VC98\Bin\vcvars32.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%V6TOOLS%\VC97\Bin\vcvars32.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+set "VSVARS=%V5TOOLS%\VC\Bin\vcvars32.bat"\r
+call :CheckMSVC\r
+if not ERRORLEVEL 1 goto FoundMSVC\r
+\r
+rem We did not find anything--fail\r
+echo No MSVC compiler available.\r
+echo Please run vcvarsall.bat and/or configure your Path.\r
+exit /b 1\r
+\r
+:FoundMSVC\r
 set OUTDIR=.\WinRel\r
 set "OPTS=/O2 /D NDEBUG"\r
 set LINKOPTS=\r
@@ -149,7 +213,7 @@ if "%COMPILER%" == "gcc" goto GccCompile
 \r
 :: MSVC Compile\r
 echo on\r
-cl.exe /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR% /I . /I glob /I w32/include /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.obj /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c\r
+%COMPILER% /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR% /I . /I glob /I w32/include /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.obj /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c\r
 @echo off\r
 echo %OUTDIR%\%1.obj >>%OUTDIR%\link.sc\r
 goto :EOF\r
@@ -226,16 +290,25 @@ echo Guile found, building with Guile
 set "GUILECFLAGS=%GUILECFLAGS% -DHAVE_GUILE"\r
 goto :EOF\r
 \r
+:CheckMSVC\r
+if not exist "%VSVARS%" exit /b 1\r
+call "%VSVARS%" %ARCH%\r
+if ERRORLEVEL 1 exit /b 1\r
+%COMPILER% >nul 2>&1\r
+if ERRORLEVEL 1 exit /b 1\r
+goto :EOF\r
+\r
 :Usage\r
 echo Usage: %0 [options] [gcc]\r
 echo Options:\r
-echo.  --debug           For GCC only, make a debug build\r
-echo.                    (MSVC build always makes both debug and release)\r
 echo.  --without-guile   Do not compile Guile support even if found\r
+echo.  --debug           Make a Debug build--default is Release\r
+echo.  --x86             Make a 32bit binary--default is 64bit\r
 echo.  --help            Display these instructions and exit\r
 goto :EOF\r
 \r
 :Reset\r
+set ARCH=\r
 set COMPILER=\r
 set DEBUG=\r
 set GUILE=\r
@@ -247,4 +320,5 @@ set NOGUILE=
 set OPTS=\r
 set OUTDIR=\r
 set PKGMSC=\r
+set VSVARS=\r
 goto :EOF\r