summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2022-12-26 13:10:26 -0500
committerPaul Smith <psmith@gnu.org>2022-12-26 13:10:26 -0500
commit937e9aa32d8db6537edbd7260315106f7086b340 (patch)
tree95e115769c597ef90fa66f7c1f1733e96b583e66
parent8e9c7db1e1b21e0a7754e2d333e551208220be2b (diff)
downloadmake-git-937e9aa32d8db6537edbd7260315106f7086b340.tar.gz
Make bootstrap.bat more portable
Using backslashes in a sed command line is tricky as different programs use them differently as escape sequences. Eli Zaretskii points out that Windows "echo" doesn't do any processing, so rework all our sed invocations to use script files created by echo. * bootstrap.bat: Use echo to create sed script files instead of -e. * Basic.mk.template: Fix typo in the comments. * .gitignore: Ignore any .sed scripts.
-rw-r--r--.gitignore2
-rw-r--r--Basic.mk.template2
-rw-r--r--bootstrap.bat31
3 files changed, 30 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 08195763..1ea8c55c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,7 +37,7 @@ configure
stamp-*
.dirstamp
gnulib
-convert.sed
+*.sed
# Build artifacts
.deps/
diff --git a/Basic.mk.template b/Basic.mk.template
index 07a45454..4216d1ec 100644
--- a/Basic.mk.template
+++ b/Basic.mk.template
@@ -2,7 +2,7 @@
#
# NOTE:
# If you have no 'make' program at all to process this makefile:
-# * On Windows, run ".\buildw32.bat" to bootstrap one.
+# * On Windows, run ".\build_w32.bat" to bootstrap one.
# * On MS-DOS, run ".\builddos.bat" to bootstrap one.
#
# Once you have a GNU make program created, you can use it with this makefile
diff --git a/bootstrap.bat b/bootstrap.bat
index c1f6819a..f421ea7c 100644
--- a/bootstrap.bat
+++ b/bootstrap.bat
@@ -45,6 +45,13 @@ call :Download lib intprops-internal.h
echo -- Configuring the workspace
copy /Y gl\lib\*.* lib > nul
+:: In general it's tricky to use special characters as arguments to a program
+:: in Windows batch files; the quoting rules are obscure and have changed over
+:: time which means older systems may behave differently. However, Windows
+:: echo is a dumb program that just writes out its command line without much
+:: interpreting: all we have to be careful of is ^ quoting. So, use echo
+:: to create script files to use with sed -f rather than using sed -e.
+
:: Create a sed script to convert templates
if exist convert.sed del /Q convert.sed
echo s,@PACKAGE@,make,g > convert.sed
@@ -56,9 +63,17 @@ if ERRORLEVEL 1 goto Failed
echo s,@PACKAGE_TARNAME@,make,g >> convert.sed
if ERRORLEVEL 1 goto Failed
echo s,@PACKAGE_URL@,https://www.gnu.org/software/make/,g >> convert.sed
-sed -n "s/^AC_INIT(\[GNU.Make\],\[\([0-9.]*\)\].*/s,@PACKAGE_VERSION@,\1,g/p" configure.ac >> convert.sed
+echo s/^^AC_INIT^(\[GNU.Make\],\[\^([0-9.]*\^)\].*/s,@PACKAGE_VERSION@,\1,g/p > cac.sed
+sed -n -f cac.sed 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
+:: Get the list of sources from Makefile.am
+echo s,\\\n,,g > mam.sed
+echo s,[ \t][ \t]*, ,g >> mam.sed
+echo s, [^^ ]*\.h,,g >> mam.sed
+echo s,src/,$^(src^),g >> mam.sed
+echo s,lib/,$^(lib^),g >> mam.sed
+echo s/^^\^([A-Za-z0-9]*\^)_SRCS *= *\^(.*\^)/s,%%\1_SOURCES%%,\2,/p > mam2.sed
+sed -z -f mam.sed Makefile.am | sed -n -f mam2.sed >> convert.sed
if ERRORLEVEL 1 goto Failed
echo - Creating Basic.mk
@@ -70,10 +85,20 @@ if ERRORLEVEL 1 goto Failed
echo - Creating 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
+echo s/;.*// > gmk.sed
+echo /^^[ \t]*$/d >> gmk.sed
+echo s/"/\\"/g >> gmk.sed
+echo s/$/ \\/ >> gmk.sed
+sed -f gmk.sed src\gmk-default.scm >> src\gmk-default.h
if ERRORLEVEL 1 goto Failed
echo ^";>> src\gmk-default.h
+:: These files would be created by bootstrap; they are not needed on Windows
+:: but our makefile depends on them
+echo >> lib\alloca.in.h
+
+del /Q convert.sed cac.sed mam.sed mam2.sed gmk.sed
+
echo.
echo Done. Run build_w32.bat to build GNU make.
goto :EOF