* 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.
stamp-h1
.dirstamp
gnulib
+convert.sed
# Build artifacts
.deps/
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
---------------------
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
set ARCH=x64\r
set DEBUG=N\r
set DIRENT=Y\r
+set VERBOSE=N\r
\r
if exist maintMakefile (\r
set MAINT=Y\r
)\r
\r
:ParseSW\r
+if "%1" == "--verbose" goto SetVerbose\r
if "%1" == "--debug" goto SetDebug\r
if "%1" == "--without-guile" goto NoGuile\r
if "%1" == "--x86" goto Set32Bit\r
if "%1" == "" goto DoneSW\r
goto Usage\r
\r
+:SetVerbose\r
+set VERBOSE=Y\r
+shift\r
+goto ParseSW\r
+\r
:SetDebug\r
set DEBUG=Y\r
echo - Building without compiler optimizations\r
\r
if "%GUILE%" == "Y" call :ChkGuile\r
\r
+if not exist src\config.h.W32 goto NotConfig\r
+\r
echo.\r
echo Compiling %OUTDIR% version\r
\r
-if exist src\config.h.W32.template call :ConfigSCM\r
copy src\config.h.W32 %OUTDIR%\src\config.h\r
\r
copy lib\glob.in.h %OUTDIR%\lib\glob.h\r
::\r
\r
:Compile\r
+if "%VERBOSE%" == "N" echo - Compiling %1.c\r
echo %LNKOUT%/%1.%O% >>%OUTDIR%\link.sc\r
set EXTRAS=\r
if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"\r
if "%COMPILER%" == "tcc" goto TccCompile\r
\r
:: MSVC Compile\r
-echo on\r
+if "%VERBOSE%" == "Y" echo on\r
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\r
@echo off\r
goto CompileDone\r
\r
:GccCompile\r
:: GCC Compile\r
-echo on\r
+if "%VERBOSE%" == "Y" echo on\r
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\r
@echo off\r
goto CompileDone\r
\r
:TccCompile\r
:: TCC Compile\r
-echo on\r
+if "%VERBOSE%" == "Y" echo on\r
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\r
@echo off\r
goto CompileDone\r
\r
:Link\r
echo.\r
-echo Linking %LNKOUT%/%MAKE%.exe\r
+echo - Linking %LNKOUT%/%MAKE%.exe\r
if "%COMPILER%" == "gcc" goto GccLink\r
if "%COMPILER%" == "tcc" goto TccLink\r
\r
:: MSVC Link\r
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\r
-echo on\r
+if "%VERBOSE%" == "Y" echo on\r
call link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc\r
@echo off\r
goto :EOF\r
\r
:GccLink\r
:: GCC Link\r
-echo on\r
+if "%VERBOSE%" == "Y" echo on\r
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc\r
call %COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a\r
@echo off\r
\r
:TccLink\r
:: TCC Link\r
-echo on\r
+if "%VERBOSE%" == "Y" echo on\r
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc\r
call %COMPILER% -mthreads %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc \r
@echo off\r
goto :EOF\r
\r
-:ConfigSCM\r
-echo Generating config from SCM templates\r
-call sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.ac > %OUTDIR%\src\config.h.W32.sed\r
-echo s,%%PACKAGE%%,make,g >> %OUTDIR%\src\config.h.W32.sed\r
-call sed -f %OUTDIR%\src\config.h.W32.sed src\config.h.W32.template > src\config.h.W32\r
-echo static const char *const GUILE_module_defn = ^" \ > src\gmk-default.h\r
-call sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" src\gmk-default.scm >> src\gmk-default.h\r
-echo ^";>> src\gmk-default.h\r
-goto :EOF\r
-\r
:ChkGuile\r
:: Build with Guile is supported only on NT and later versions\r
if not "%OS%" == "Windows_NT" goto NoGuile\r
if ERRORLEVEL 1 exit /b 1\r
goto :EOF\r
\r
+:NotConfig\r
+echo.\r
+echo *** This workspace is not configured.\r
+echo Either retrieve the configured source in the release tarball\r
+echo or, if building from Git, run the .\bootstrap.bat script first.\r
+exit /b 1\r
+\r
:Usage\r
echo Usage: %0 [options] [gcc] OR [tcc]\r
echo Options:\r
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;
}
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;
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.