diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | README.git | 4 | ||||
-rw-r--r-- | bootstrap.bat | 62 | ||||
-rwxr-xr-x | build_w32.bat | 42 | ||||
-rw-r--r-- | tests/run_make_tests.pl | 4 | ||||
-rw-r--r-- | tests/scripts/features/temp_stdin | 2 |
6 files changed, 89 insertions, 26 deletions
@@ -37,6 +37,7 @@ configure stamp-h1 .dirstamp gnulib +convert.sed # Build artifacts .deps/ @@ -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 --------------------- diff --git a/bootstrap.bat b/bootstrap.bat index 12077fe1..cfba11ec 100644 --- a/bootstrap.bat +++ b/bootstrap.bat @@ -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 diff --git a/build_w32.bat b/build_w32.bat index 49ac821a..5153ee8c 100755 --- a/build_w32.bat +++ b/build_w32.bat @@ -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:
diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl index a534176f..95c07db7 100644 --- a/tests/run_make_tests.pl +++ b/tests/run_make_tests.pl @@ -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; diff --git a/tests/scripts/features/temp_stdin b/tests/scripts/features/temp_stdin index 59925caf..af2de2f9 100644 --- a/tests/scripts/features/temp_stdin +++ b/tests/scripts/features/temp_stdin @@ -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. |