Fix bootstrap.bat for bootstrapping on Windows

* README.git: Clarify that these methods are lightly tested.
* build_w32.bat: Don't support any config step: fail if not completed.
Move the config steps into bootstrap.bat.  Don't print compile lines
by default and add a --verbose option to show them.
* bootstrap.bat: Ensure we have curl and sed before we do anything.
Pull the latest necessary files from gnulib.  Create a convert.sed
script that can update the various template files, and update
Basic.mk, config.h.W32, and gmk-default.h.
* tests/run_make_tests.pl: Remove CRLF rather than using chop.  If we
run perl in Git for Bash it seems to handle newlines differently.
* tests/scripts/features/temp_stdin: Remove the make copy and close
STDIN so we can delete the temp file on Windows.
* .gitignore: Ignore the convert.sed script.
This commit is contained in:
Paul Smith 2022-08-14 15:03:40 -04:00
parent ab31f0b594
commit 62da1c45e5
6 changed files with 89 additions and 26 deletions

1
.gitignore vendored
View File

@ -37,6 +37,7 @@ configure
stamp-h1
.dirstamp
gnulib
convert.sed
# Build artifacts
.deps/

View File

@ -162,6 +162,10 @@ script to prime your Git workspace:
Next, rename the file README.W32.template to README.W32 and follow those
instructions.
Note, neither of these methods are tested regularly by the GNU make
maintainers. Building for Windows from a distribution tarball IS tested
regularly.
Debugging and Testing
---------------------

View File

@ -19,16 +19,66 @@ setlocal
set "svurl=https://git.savannah.gnu.org/cgit"
set "gnuliburl=%svurl%/gnulib.git/plain"
where curl >nul 2>&1
if ERRORLEVEL 1 (
echo Cannot find curl: it must be installed for bootstrap
exit /b 1
)
where sed >nul 2>&1
if ERRORLEVEL 1 (
echo Cannot find sed: it must be installed for bootstrap
echo Hint: you can use the sed provided in the Git for Windows install
exit /b 1
)
if exist lib goto Downloads
mkdir lib
if ERRORLEVEL 1 exit /b 1
:Downloads
echo -- Downloading Gnulib modules
call :Download lib getloadavg.c
call :Download lib intprops.h
goto :Done
call :Download lib intprops-internal.h
echo -- Configuring the workspace
copy /Y gl\lib\*.* lib > nul
:: Create a sed script to convert templates
if exist convert.sed del /Q convert.sed
echo s,%%PACKAGE%%,make,g > convert.sed
if ERRORLEVEL 1 goto Failed
sed -n "s/^AC_INIT(\[GNU.make\],\[\([0-9.]*\)\].*/s,%%VERSION%%,\1,g/p" configure.ac >> convert.sed
if ERRORLEVEL 1 goto Failed
sed -z -e s/\\\n//g -e "s/[ \t][ \t]*/ /g" -e "s, [^ ]*\.h,,g" -e "s,src/,$(src),g" -e "s,lib/,$(lib),g" Makefile.am | sed -n "s/^\([A-Za-z0-9]*\)_SRCS *= *\(.*\)/s,%%\1_SOURCES%%,\2,/p" >> convert.sed
if ERRORLEVEL 1 goto Failed
echo - Creating Basic.mk
call sed -f convert.sed Basic.mk.template > Basic.mk
if ERRORLEVEL 1 goto Failed
echo - Creating src\config.h.W32
call sed -f convert.sed src\config.h.W32.template > src\config.h.W32
if ERRORLEVEL 1 goto Failed
echo - Creating src\gmk-default.h
echo static const char *const GUILE_module_defn = ^" \ > src\gmk-default.h
call sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" src\gmk-default.scm >> src\gmk-default.h
if ERRORLEVEL 1 goto Failed
echo ^";>> src\gmk-default.h
echo.
echo Done. Run build_w32.bat to build GNU make.
goto :EOF
:Download
echo Downloading %1\%2
curl -sS -o %1\%2 "%gnuliburl%/%1/%2"
if exist "%1\%2" goto :EOF
echo - Downloading %1\%2
curl -sS -o "%1\%2" "%gnuliburl%/%1/%2"
if ERRORLEVEL 1 exit /b 1
goto :EOF
:Done
echo Done. Run build_w32.bat to build GNU make.
goto :EOF
:Failed
echo *** Bootstrap failed.
echo Resolve the issue, or use the configured source in the release tarball
exit /b 1

View File

@ -38,6 +38,7 @@ set O=obj
set ARCH=x64
set DEBUG=N
set DIRENT=Y
set VERBOSE=N
if exist maintMakefile (
set MAINT=Y
@ -46,6 +47,7 @@ if exist maintMakefile (
)
:ParseSW
if "%1" == "--verbose" goto SetVerbose
if "%1" == "--debug" goto SetDebug
if "%1" == "--without-guile" goto NoGuile
if "%1" == "--x86" goto Set32Bit
@ -54,6 +56,11 @@ if "%1" == "tcc" goto SetTCC
if "%1" == "" goto DoneSW
goto Usage
:SetVerbose
set VERBOSE=Y
shift
goto ParseSW
:SetDebug
set DEBUG=Y
echo - Building without compiler optimizations
@ -223,10 +230,11 @@ mkdir %OUTDIR%\lib
if "%GUILE%" == "Y" call :ChkGuile
if not exist src\config.h.W32 goto NotConfig
echo.
echo Compiling %OUTDIR% version
if exist src\config.h.W32.template call :ConfigSCM
copy src\config.h.W32 %OUTDIR%\src\config.h
copy lib\glob.in.h %OUTDIR%\lib\glob.h
@ -295,6 +303,7 @@ goto :EOF
::
:Compile
if "%VERBOSE%" == "N" echo - Compiling %1.c
echo %LNKOUT%/%1.%O% >>%OUTDIR%\link.sc
set EXTRAS=
if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"
@ -303,21 +312,21 @@ if "%COMPILER%" == "gcc" goto GccCompile
if "%COMPILER%" == "tcc" goto TccCompile
:: MSVC Compile
echo on
if "%VERBOSE%" == "Y" echo on
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
goto CompileDone
:GccCompile
:: GCC Compile
echo on
if "%VERBOSE%" == "Y" echo on
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
goto CompileDone
:TccCompile
:: TCC Compile
echo on
if "%VERBOSE%" == "Y" echo on
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
goto CompileDone
@ -328,20 +337,20 @@ goto :EOF
:Link
echo.
echo Linking %LNKOUT%/%MAKE%.exe
echo - Linking %LNKOUT%/%MAKE%.exe
if "%COMPILER%" == "gcc" goto GccLink
if "%COMPILER%" == "tcc" goto TccLink
:: 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 on
if "%VERBOSE%" == "Y" echo on
call link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc
@echo off
goto :EOF
:GccLink
:: GCC Link
echo on
if "%VERBOSE%" == "Y" echo on
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
call %COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a
@echo off
@ -349,22 +358,12 @@ goto :EOF
:TccLink
:: TCC Link
echo on
if "%VERBOSE%" == "Y" echo on
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
call %COMPILER% -mthreads %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc
@echo off
goto :EOF
:ConfigSCM
echo Generating config from SCM templates
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
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
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
goto :EOF
:ChkGuile
:: Build with Guile is supported only on NT and later versions
if not "%OS%" == "Windows_NT" goto NoGuile
@ -422,6 +421,13 @@ call %COMPILER% >nul 2>&1
if ERRORLEVEL 1 exit /b 1
goto :EOF
:NotConfig
echo.
echo *** This workspace is not configured.
echo Either retrieve the configured source in the release tarball
echo or, if building from Git, run the .\bootstrap.bat script first.
exit /b 1
:Usage
echo Usage: %0 [options] [gcc] OR [tcc]
echo Options:

View File

@ -573,7 +573,7 @@ sub set_more_defaults
create_file('make.mk', 'all:;$(info $(MAKE))');
my $mk = `$make_path -sf make.mk`;
unlink('make.mk');
chop $mk;
$mk =~ s/\r?\n$//;
$mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE)\n";
$make_path = $mk;
}
@ -583,7 +583,7 @@ sub set_more_defaults
create_file('shell.mk', 'all:;$(info $(SHELL))');
$sh_name = `$make_path -sf shell.mk`;
unlink('shell.mk');
chop $sh_name;
$sh_name =~ s/\r?\n$//;
if (! $sh_name) {
print "Cannot determine shell\n";
$is_posix_sh = 0;

View File

@ -98,8 +98,10 @@ force:
check_tempfile($tdir);
@make_command = @make_orig;
unlink($makecopy);
}
close(STDIN);
unlink('input.mk', 'bye.mk');
# This tells the test driver that the perl test script executed properly.