]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Fix bootstrap.bat for bootstrapping on Windows
authorPaul Smith <psmith@gnu.org>
Sun, 14 Aug 2022 19:03:40 +0000 (15:03 -0400)
committerPaul Smith <psmith@gnu.org>
Tue, 23 Aug 2022 01:19:18 +0000 (21:19 -0400)
* 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.

.gitignore
README.git
bootstrap.bat
build_w32.bat
tests/run_make_tests.pl
tests/scripts/features/temp_stdin

index 6be365dd1a6c52492af8c6a6f9e5b90487d20669..dfd14036b483bfa7b217e63b0f0a7c6541c38189 100644 (file)
@@ -37,6 +37,7 @@ configure
 stamp-h1
 .dirstamp
 gnulib
+convert.sed
 
 # Build artifacts
 .deps/
index a1592ada30cb48836666865412fb74ff317da506..17165da8b032d987be174e6175cf665753241523 100644 (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
 ---------------------
index 12077fe1b20b178ba260106950bed165bfec4ff6..cfba11ecadcdc321d4cb3e9e586aa5e53459dde7 100644 (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
index 49ac821a0a2c783899c4f98cd52eb85107e40cc7..5153ee8c1cf633b61281bbadbab2e0a729f917dd 100755 (executable)
@@ -38,6 +38,7 @@ set O=obj
 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
@@ -46,6 +47,7 @@ if exist maintMakefile (
 )\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
@@ -54,6 +56,11 @@ if "%1" == "tcc" goto SetTCC
 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
@@ -223,10 +230,11 @@ mkdir %OUTDIR%\lib
 \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
@@ -295,6 +303,7 @@ goto :EOF
 ::\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
@@ -303,21 +312,21 @@ if "%COMPILER%" == "gcc" goto GccCompile
 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
@@ -328,20 +337,20 @@ goto :EOF
 \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
@@ -349,22 +358,12 @@ goto :EOF
 \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
@@ -422,6 +421,13 @@ call %COMPILER% >nul 2>&1
 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
index a534176fb42d41112314aeb87d95307540c39e5c..95c07db7d1fc598535411000e415d749e38b7b0a 100644 (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;
index 59925caf395641ad59bb7e28d9d3ee875f72a65b..af2de2f9d0f0a8917fcd44f8d22675e6db679a38 100644 (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.