summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2016-06-19 10:52:17 -0400
committerPaul Smith <psmith@gnu.org>2016-06-24 20:50:42 -0400
commit6f339b22eb87dc80d1037ccb04c787d156db0e8f (patch)
tree61452d6e58995da53db75c4b21b997fd9812de68
parente26560508c5fb9e803c100a6e79c9a6a1bf8c161 (diff)
downloadmake-git-6f339b22eb87dc80d1037ccb04c787d156db0e8f.tar.gz
* README.W32.template: Update the build documentation.
* build_w32.bat: Fix issues with Visual Studio builds. Fix an error that always created Debug builds. Support 32bit and 64bit builds.
-rw-r--r--README.W32.template64
-rwxr-xr-xbuild_w32.bat84
2 files changed, 115 insertions, 33 deletions
diff --git a/README.W32.template b/README.W32.template
index 3ac3354f..9a053074 100644
--- a/README.W32.template
+++ b/README.W32.template
@@ -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 --
diff --git a/build_w32.bat b/build_w32.bat
index 59e068b6..07b422a6 100755
--- a/build_w32.bat
+++ b/build_w32.bat
@@ -15,6 +15,7 @@ rem
rem You should have received a copy of the GNU General Public License along
rem with this program. If not, see <http://www.gnu.org/licenses/>.
+setlocal
call :Reset
if "%1" == "-h" goto Usage
@@ -22,13 +23,17 @@ if "%1" == "--help" goto Usage
set MAKE=gnumake
set GUILE=Y
-set COMPILER=msvc
+set COMPILER=cl.exe
+set ARCH=x64
+set DEBUG=N
:ParseSW
if "%1" == "--debug" goto SetDebug
if "%1" == "--without-guile" goto NoGuile
+if "%1" == "--x86" goto Set32Bit
if "%1" == "gcc" goto SetCC
if "%1" == "" goto DoneSW
+goto Usage
:SetDebug
set DEBUG=Y
@@ -41,6 +46,11 @@ echo Building without Guile
shift
goto ParseSW
+:Set32Bit
+set ARCH=x86
+shift
+goto ParseSW
+
:SetCC
set COMPILER=gcc
echo Building with GCC
@@ -50,11 +60,65 @@ goto ParseSW
rem Build with Guile is supported only on NT and later versions
:DoneSW
echo.
-echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8
+echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8/10
if "%DEBUG%" == "Y" echo Building without compiler optimizations
if "%COMPILER%" == "gcc" goto GccBuild
+rem Make sure we can find a compiler
+%COMPILER% >nul 2>&1
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS80COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS71COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%VS70COMNTOOLS%\..\..\VC\vcvarsall.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%V6TOOLS%\VC98\Bin\vcvars32.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%V6TOOLS%\VC97\Bin\vcvars32.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+set "VSVARS=%V5TOOLS%\VC\Bin\vcvars32.bat"
+call :CheckMSVC
+if not ERRORLEVEL 1 goto FoundMSVC
+
+rem We did not find anything--fail
+echo No MSVC compiler available.
+echo Please run vcvarsall.bat and/or configure your Path.
+exit /b 1
+
+:FoundMSVC
set OUTDIR=.\WinRel
set "OPTS=/O2 /D NDEBUG"
set LINKOPTS=
@@ -149,7 +213,7 @@ if "%COMPILER%" == "gcc" goto GccCompile
:: MSVC Compile
echo on
-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
+%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
@echo off
echo %OUTDIR%\%1.obj >>%OUTDIR%\link.sc
goto :EOF
@@ -226,16 +290,25 @@ echo Guile found, building with Guile
set "GUILECFLAGS=%GUILECFLAGS% -DHAVE_GUILE"
goto :EOF
+:CheckMSVC
+if not exist "%VSVARS%" exit /b 1
+call "%VSVARS%" %ARCH%
+if ERRORLEVEL 1 exit /b 1
+%COMPILER% >nul 2>&1
+if ERRORLEVEL 1 exit /b 1
+goto :EOF
+
:Usage
echo Usage: %0 [options] [gcc]
echo Options:
-echo. --debug For GCC only, make a debug build
-echo. (MSVC build always makes both debug and release)
echo. --without-guile Do not compile Guile support even if found
+echo. --debug Make a Debug build--default is Release
+echo. --x86 Make a 32bit binary--default is 64bit
echo. --help Display these instructions and exit
goto :EOF
:Reset
+set ARCH=
set COMPILER=
set DEBUG=
set GUILE=
@@ -247,4 +320,5 @@ set NOGUILE=
set OPTS=
set OUTDIR=
set PKGMSC=
+set VSVARS=
goto :EOF