* build_w32.bat [WIN]: Use call for all invocations

This commit is contained in:
Paul Smith 2022-06-18 16:42:11 -04:00
parent 97e51c0285
commit 08c964b4ac

View file

@ -93,7 +93,7 @@ if "%COMPILER%" == "gcc" goto FindGcc
if "%COMPILER%" == "tcc" goto FindTcc if "%COMPILER%" == "tcc" goto FindTcc
:: Find a compiler. Visual Studio requires a lot of effort to locate :-/. :: Find a compiler. Visual Studio requires a lot of effort to locate :-/.
%COMPILER% >nul 2>&1 call %COMPILER% >nul 2>&1
if not ERRORLEVEL 1 goto FoundMSVC if not ERRORLEVEL 1 goto FoundMSVC
:: Visual Studio 17 and above provides the "vswhere" tool :: Visual Studio 17 and above provides the "vswhere" tool
@ -175,7 +175,7 @@ if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE"
:: Show the compiler version that we found :: Show the compiler version that we found
:: Unfortunately this also shows a "usage" note; I can't find anything better. :: Unfortunately this also shows a "usage" note; I can't find anything better.
echo. echo.
%COMPILER% call %COMPILER%
goto Build goto Build
:FindGcc :FindGcc
@ -189,7 +189,7 @@ if "%DEBUG%" == "Y" set LNKOUT=./GccDebug
if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE" if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"
:: Show the compiler version that we found :: Show the compiler version that we found
echo. echo.
%COMPILER% --version call %COMPILER% --version
if not ERRORLEVEL 1 goto Build if not ERRORLEVEL 1 goto Build
echo No %COMPILER% found. echo No %COMPILER% found.
exit 1 exit 1
@ -204,7 +204,7 @@ if "%DEBUG%" == "Y" set LNKOUT=./TccDebug
if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE" if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"
:: Show the compiler version that we found :: Show the compiler version that we found
echo. echo.
%COMPILER% -v call %COMPILER% -v
if not ERRORLEVEL 1 goto Build if not ERRORLEVEL 1 goto Build
echo No %COMPILER% found. echo No %COMPILER% found.
exit 1 exit 1
@ -304,21 +304,21 @@ if "%COMPILER%" == "tcc" goto TccCompile
:: MSVC Compile :: MSVC Compile
echo on echo on
%COMPILER% /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR%/src /I src /I %OUTDIR%/lib /I lib /I src/w32/include /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.%O% /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c call %COMPILER% /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR%/src /I src /I %OUTDIR%/lib /I lib /I src/w32/include /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.%O% /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c
@echo off @echo off
goto CompileDone goto CompileDone
:GccCompile :GccCompile
:: GCC Compile :: GCC Compile
echo on echo on
%COMPILER% -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c call %COMPILER% -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c
@echo off @echo off
goto CompileDone goto CompileDone
:TccCompile :TccCompile
:: TCC Compile :: TCC Compile
echo on echo on
%COMPILER% -mthreads -Wall -std=c11 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -D_cdecl= -D_MSC_VER -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c call %COMPILER% -mthreads -Wall -std=c11 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -D_cdecl= -D_MSC_VER -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c
@echo off @echo off
goto CompileDone goto CompileDone
@ -335,7 +335,7 @@ if "%COMPILER%" == "tcc" goto TccLink
:: MSVC Link :: MSVC Link
echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >>%OUTDIR%\link.sc echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >>%OUTDIR%\link.sc
echo on echo on
link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc call link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc
@echo off @echo off
goto :EOF goto :EOF
@ -343,7 +343,7 @@ goto :EOF
:: GCC Link :: GCC Link
echo on echo on
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
%COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a call %COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a
@echo off @echo off
goto :EOF goto :EOF
@ -351,42 +351,44 @@ goto :EOF
:: TCC Link :: TCC Link
echo on echo on
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
%COMPILER% -mthreads %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc call %COMPILER% -mthreads %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc
@echo off @echo off
goto :EOF goto :EOF
:ConfigSCM :ConfigSCM
echo Generating config from SCM templates echo Generating config from SCM templates
sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.ac > %OUTDIR%\src\config.h.W32.sed call sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.ac > %OUTDIR%\src\config.h.W32.sed
echo s,%%PACKAGE%%,make,g >> %OUTDIR%\src\config.h.W32.sed echo s,%%PACKAGE%%,make,g >> %OUTDIR%\src\config.h.W32.sed
sed -f %OUTDIR%\src\config.h.W32.sed src\config.h.W32.template > src\config.h.W32 call sed -f %OUTDIR%\src\config.h.W32.sed src\config.h.W32.template > src\config.h.W32
echo static const char *const GUILE_module_defn = ^" \ > src\gmk-default.h echo static const char *const GUILE_module_defn = ^" \ > src\gmk-default.h
sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" src\gmk-default.scm >> src\gmk-default.h call sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" src\gmk-default.scm >> src\gmk-default.h
echo ^";>> src\gmk-default.h echo ^";>> src\gmk-default.h
goto :EOF goto :EOF
:ChkGuile :ChkGuile
:: Build with Guile is supported only on NT and later versions :: Build with Guile is supported only on NT and later versions
if not "%OS%" == "Windows_NT" goto NoGuile if not "%OS%" == "Windows_NT" goto NoGuile
pkg-config --help > %OUTDIR%\guile.tmp 2> NUL call pkg-config --help > %OUTDIR%\guile.tmp 2> NUL
if ERRORLEVEL 1 goto NoPkgCfg if ERRORLEVEL 1 goto NoPkgCfg
echo Checking for Guile 2.0 set PKGMSC=
if not "%COMPILER%" == "gcc" set PKGMSC=--msvc-syntax if not "%COMPILER%" == "gcc" set PKGMSC=--msvc-syntax
pkg-config --cflags --short-errors "guile-2.0" > %OUTDIR%\guile.tmp
if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp
pkg-config --libs --static --short-errors %PKGMSC% "guile-2.0" > %OUTDIR%\guile.tmp echo Checking for Guile 2.0
if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp call pkg-config --cflags --short-errors "guile-2.0" > %OUTDIR%\gl-c2.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\gl-c2.tmp
call pkg-config --libs --static --short-errors %PKGMSC% "guile-2.0" > %OUTDIR%\gl-l2.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\gl-l2.tmp
if not "%GUILECFLAGS%" == "" goto GuileDone if not "%GUILECFLAGS%" == "" goto GuileDone
echo Checking for Guile 1.8 echo Checking for Guile 1.8
pkg-config --cflags --short-errors "guile-1.8" > %OUTDIR%\guile.tmp call pkg-config --cflags --short-errors "guile-1.8" > %OUTDIR%\gl-c18.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\gl-c18.tmp
pkg-config --libs --static --short-errors %PKGMSC% "guile-1.8" > %OUTDIR%\guile.tmp call pkg-config --libs --static --short-errors %PKGMSC% "guile-1.8" > %OUTDIR%\gl-l18.tmp 2> NUL
if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\gl-l18.tmp
if not "%GUILECFLAGS%" == "" goto GuileDone if not "%GUILECFLAGS%" == "" goto GuileDone
@ -405,10 +407,10 @@ goto :EOF
:FindVswhere :FindVswhere
set VSWHERE=vswhere set VSWHERE=vswhere
"%VSWHERE%" -help >nul 2>&1 call "%VSWHERE%" -help >nul 2>&1
if not ERRORLEVEL 1 exit /b 0 if not ERRORLEVEL 1 exit /b 0
set "VSWHERE=C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere" set "VSWHERE=C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere"
"%VSWHERE%" -help >nul 2>&1 call "%VSWHERE%" -help >nul 2>&1
if ERRORLEVEL 1 exit /b 1 if ERRORLEVEL 1 exit /b 1
goto :EOF goto :EOF
@ -416,7 +418,7 @@ goto :EOF
if not exist "%VSVARS%" exit /b 1 if not exist "%VSVARS%" exit /b 1
call "%VSVARS%" %ARCH% call "%VSVARS%" %ARCH%
if ERRORLEVEL 1 exit /b 1 if ERRORLEVEL 1 exit /b 1
%COMPILER% >nul 2>&1 call %COMPILER% >nul 2>&1
if ERRORLEVEL 1 exit /b 1 if ERRORLEVEL 1 exit /b 1
goto :EOF goto :EOF