On Mon, 04 Nov 2019 05:35:46 +0200, Eli Zaretskii wrote:

> And how do you suggest to fix this?

For your consideration attached 3 patches implementing the suggested idea: a
new optional command line flag '--exe-name' to build_w32.bat to help the
user pass an executable name (default: 'gnumake') used at link time.

Please feel free to edit and apply it.

Thanks,
J.
>From 719d2337933e6e1d699c414a56689e34a00d078a Mon Sep 17 00:00:00 2001
From: Jannick <thirdedit...@gmx.net>
Date: Tue, 5 Nov 2019 16:00:54 +0100
Subject: [PATCH 01/13] Windows build: regroup code blocks in build_w32.bat

Minor commit without essentially changing the script logic.

* build_w32.bat:
  - move default value definition block before --help check block.
  - unquote the command line argument.
---
 build_w32.bat | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/build_w32.bat b/build_w32.bat
index b245d05..f1a55a4 100755
--- a/build_w32.bat
+++ b/build_w32.bat
@@ -24,13 +24,7 @@ if not "%RECURSEME%"=="%~0" (
 
 call :Reset
 
-if "%1" == "-h" goto Usage
-if "%1" == "--help" goto Usage
-
-echo.
-echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8/10
-echo.
-
+:: set defaults
 set MAKE=gnumake
 set GUILE=Y
 set COMPILER=cl.exe
@@ -38,6 +32,13 @@ set O=obj
 set ARCH=x64
 set DEBUG=N
 
+if "%~1" == "-h" goto Usage
+if "%~1" == "--help" goto Usage
+
+echo.
+echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8/10
+echo.
+
 if exist maintMakefile (
     set MAINT=Y
 ) else (
@@ -45,11 +46,11 @@ if exist maintMakefile (
 )
 
 :ParseSW
-if "%1" == "--debug" goto SetDebug
-if "%1" == "--without-guile" goto NoGuile
-if "%1" == "--x86" goto Set32Bit
-if "%1" == "gcc" goto SetCC
-if "%1" == "" goto DoneSW
+if "%~1" == "--debug" goto SetDebug
+if "%~1" == "--without-guile" goto NoGuile
+if "%~1" == "--x86" goto Set32Bit
+if "%~1" == "gcc" goto SetCC
+if "%~1" == "" goto DoneSW
 goto Usage
 
 :SetDebug
-- 
2.24.0.windows.1

>From c2d43fa48cd0b479d09dacfeca881ae1be4f9f31 Mon Sep 17 00:00:00 2001
From: Jannick <thirdedit...@gmx.net>
Date: Tue, 5 Nov 2019 16:04:22 +0100
Subject: [PATCH 02/13] Windows build: enhance error reporting in build_w32.bat

* build_w32.bat:
  - add subroutine ErrorExit
  - report error about illegal command line argument
---
 build_w32.bat | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/build_w32.bat b/build_w32.bat
index f1a55a4..b166ec1 100755
--- a/build_w32.bat
+++ b/build_w32.bat
@@ -51,7 +51,7 @@ if "%~1" == "--without-guile" goto NoGuile
 if "%~1" == "--x86" goto Set32Bit
 if "%~1" == "gcc" goto SetCC
 if "%~1" == "" goto DoneSW
-goto Usage
+call :ErrorExit "Illegal command line argument '%~1'."
 
 :SetDebug
 set DEBUG=Y
@@ -375,6 +375,13 @@ if ERRORLEVEL 1 exit /b 1
 if ERRORLEVEL 1 exit /b 1
 goto :EOF
 
+:ErrorExit
+echo.-- %~1
+echo.
+call :Usage
+exit 1
+goto :EOF
+
 :Usage
 echo Usage: %0 [options] [gcc]
 echo Options:
-- 
2.24.0.windows.1

>From 85235aa251690b682c62c3166d7510e98ae0ff3c Mon Sep 17 00:00:00 2001
From: Jannick <thirdedit...@gmx.net>
Date: Tue, 5 Nov 2019 16:52:16 +0100
Subject: [PATCH 03/13] Windows build: add optional cmd line flag --exe-name to
 build_w32.bat

This commit helps the user choose a name for the GNUMake executable
different from the default 'gnumake.exe' used at link time.

More on dynamic objects: 
https://www.gnu.org/software/make/manual/make.html#Loading-Objects.

Sample calls:
  - build_w32.bat --exe-name mingw32-make gcc
  - build_w32.bat --exe-name msvc-make

* build_w32.bat:
  - add optional flag --exe-name requiring an argument specifying
     the executable name without extension '.exe'.  Default is 'gnumake'
     still.
  - when linking with GCC, create import library named after exe name
     of the form 'lib<EXE-NAME>-1.dll.a'.
  - add new flag to usage screen.
---
 build_w32.bat | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/build_w32.bat b/build_w32.bat
index b166ec1..41a0b4e 100755
--- a/build_w32.bat
+++ b/build_w32.bat
@@ -47,6 +47,7 @@ if exist maintMakefile (
 
 :ParseSW
 if "%~1" == "--debug" goto SetDebug
+if "%~1" == "--exe-name" goto SetExeName
 if "%~1" == "--without-guile" goto NoGuile
 if "%~1" == "--x86" goto Set32Bit
 if "%~1" == "gcc" goto SetCC
@@ -59,6 +60,17 @@ echo - Building without compiler optimizations
 shift
 goto ParseSW
 
+:SetExeName
+shift
+set TMP=%~1
+if "%TMP%" == "" call :ErrorExit "Required command line argument after flag 
'--exe-name' missing."
+if not "%TMP:.exe=%" == "%TMP%" if "%TMP:~-4%" == ".exe" call :ErrorExit 
"Executable name '%TMP%' should be WITHOUT extension '.exe'."
+set MAKE=%TMP%
+set "TMP="
+echo - Setting executable name to '%MAKE%'
+shift
+goto ParseSW
+
 :NoGuile
 set GUILE=N
 echo - Building without Guile
@@ -306,7 +318,7 @@ goto :EOF
 :: GCC Link
 echo on
 echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 
-lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
-%COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe 
@%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a
+%COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe 
@%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/lib%MAKE%-1.dll.a
 @echo off
 goto :EOF
 
@@ -385,10 +397,11 @@ goto :EOF
 :Usage
 echo Usage: %0 [options] [gcc]
 echo Options:
-echo.  --without-guile   Do not compile Guile support even if found
-echo.  --debug           Make a Debug build--default is Release
-echo.  --x86             Make a 32bit binary--default is 64bit
-echo.  --help            Display these instructions and exit
+echo.  --exe-name ^<NAME^>     Set executable name (without extension 
'.exe')--default is '%MAKE%'
+echo.  --without-guile       Do not compile Guile support even if found
+echo.  --debug               Make a Debug build--default is Release
+echo.  --x86                 Make a 32bit binary--default is 64bit
+echo.  --help                Display these instructions and exit
 goto :EOF
 
 :Reset
-- 
2.24.0.windows.1

Reply via email to