Skip to content

Commit 3095904

Browse files
committed
mswin: fix configure.bat
Avoid being affected by the existing environment variable `target` Ensure `call set` works correctly even if the external command `set` exists Make `--disable-install-doc` work again Prevent `--with-static-linked-ext` from consuming subsequent arguments Make `--with-opt-dir` work correctly when specifying an existing directory
1 parent 9715b29 commit 3095904

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

win32/configure.bat

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
@echo off
22
@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1
33
set PROMPT=$E[94m+$E[m$S
4+
goto :main
45

6+
:set
7+
set %*
8+
exit /b
9+
10+
:main
511
if "%~dp0" == "%CD%\" (
612
echo don't run in win32 directory.
713
exit /b 999
@@ -14,11 +20,12 @@ if "%~dp0" == "%CD%\" (
1420
)
1521

1622
set "WIN32DIR=%WIN32DIR:\=/%:/:"
17-
call set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%"
18-
call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%"
23+
call :set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%"
24+
call :set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%"
1925
set "WIN32DIR=%WIN32DIR:~0,-3%"
2026

2127
set configure=%~0
28+
set target=
2229
set optdirs=
2330
set pathlist=
2431
set config_make=confargs~%RANDOM%.mak
@@ -88,7 +95,6 @@ goto :loop ;
8895
echo>>%confargs% "--target=%arg:$=$$%" \
8996
goto :loop ;
9097
:program_name
91-
if "%eq%" == "" (set "arg=%~1" & shift)
9298
for /f "delims=- tokens=1,*" %I in ("%opt%") do set "var=%%J"
9399
if "%var%" == "prefix" (set "var=PROGRAM_PREFIX" & goto :name)
94100
if "%var%" == "suffix" (set "var=PROGRAM_SUFFIX" & goto :name)
@@ -109,7 +115,7 @@ goto :loopend ;
109115
:enable
110116
echo>>%confargs% "%opt%" \
111117
if %enable% == yes (set "opt=%opt:~9%") else (set "opt=%opt:~10%")
112-
if "%opt%" == "rdoc" (
118+
if "%opt%" == "install-doc" (
113119
echo>> %config_make% RDOCTARGET = %enable:yes=r%doc
114120
)
115121
if "%opt%" == "install-static-library" (
@@ -155,9 +161,9 @@ goto :loop ;
155161
if "%eq%" == "" (set "NTVER=%~1" & shift) else (set "NTVER=%arg%")
156162
if /i not "%NTVER:~0,2%" == "0x" if /i not "%NTVER:~0,13%" == "_WIN32_WINNT_" (
157163
for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
158-
call set NTVER=%%NTVER:%%i=%%i%%
164+
call :set NTVER=%%NTVER:%%i=%%i%%
159165
)
160-
call set NTVER=_WIN32_WINNT_%%NTVER%%
166+
call :set NTVER=_WIN32_WINNT_%%NTVER%%
161167
)
162168
echo>> %config_make% NTVER = %NTVER%
163169
goto :loopend ;
@@ -170,7 +176,7 @@ goto :loopend ;
170176
set "pathlist=%pathlist%%arg:\=/%;"
171177
goto :loopend ;
172178
:extstatic
173-
if "%eq%" == "" (set "arg=static" & shift)
179+
if "%eq%" == "" (set "arg=static")
174180
echo>> %config_make% EXTSTATIC = %arg%
175181
goto :loopend ;
176182
:baseruby
@@ -205,7 +211,7 @@ goto :loop ;
205211
:optdir-loop
206212
for /f "delims=; tokens=1,*" %%I in ("%arg%") do (set "d=%%I" & set "arg=%%J")
207213
pushd %d:/=\% 2> nul && (
208-
set "optdirs=%optdirs%;%CD:\=/%"
214+
call :set "optdirs=%optdirs%;%%CD:\=/%%"
209215
popd
210216
) || (
211217
set "optdirs=%optdirs%;%d:\=/%"
@@ -241,7 +247,7 @@ goto :EOF
241247
exit /b 1
242248
:end
243249
if "%debug_configure%" == "yes" (type %confargs%)
244-
if defined optdirs (for %%I in ("%optdirs:~1%") do echo>>%config_make% optdirs = %%~I)
250+
if defined optdirs (echo>>%config_make% optdirs = %optdirs:~1%)
245251
(
246252
echo.
247253
echo configure_args = \

0 commit comments

Comments
 (0)