@@ -7,6 +7,19 @@ goto :main
77set %*
88exit /b
99
10+ :shift
11+ call %~dp0 shellsplit.cmd
12+ set " argv1 = %argv2% "
13+ set " argv2 = %argv% "
14+ if not defined argv1 if defined argv2 goto :shift
15+ exit /b
16+
17+ :take_arg
18+ if defined arg exit /b
19+ if not defined argv2 exit /b
20+ if not " %argv2:~0 ,1 % " == " -" (set " arg=%argv2% " & call :shift)
21+ exit /b
22+
1023:main
1124if " %~dp0 " == " %CD% \" (
1225 echo don't run in win32 directory.
@@ -25,6 +38,7 @@ call :set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%"
2538set " WIN32DIR = %WIN32DIR:~0 ,-3 % "
2639
2740set configure = %~0
41+ set args = %*
2842set target =
2943set optdirs =
3044set pathlist =
@@ -34,12 +48,21 @@ set debug_configure=
3448echo> %config_make% # CONFIGURE
3549type nul > %confargs%
3650:loop
37- if [%1 ] == [] goto :end ;
38- if " %~1 " == " " (shift & goto :loop)
39- for /f " delims== tokens=1,*" %%I in (" %~1 " ) do ((set " opt=%%I " ) && (set " arg=%%J " ))
40- set " eq = ="
41- if " %arg% " == " " if not " %~1 " == " %opt% =%arg% " (set " eq=" )
42- shift
51+ call :shift
52+ if not defined argv1 goto :end
53+ for /f " delims== tokens=1,*" %%I in (" %argv1% " ) do ((set " opt=%%I " ) && (set " arg=%%J " ))
54+ set " opt = %opt:~1 % "
55+ if defined arg (
56+ set " eq = ="
57+ set " arg = %arg:~0 ,-1 % "
58+ ) else (
59+ set " eq = "
60+ set " opt = %opt:~0 ,-1 % "
61+ )
62+ if " %opt% " == " " (
63+ echo 1 >& 2 %configure% : assignment for empty variable name %argv1%
64+ exit /b 1
65+ )
4366 if " %opt% " == " --debug-configure" (
4467 echo on
4568 set " debug_configure = yes"
@@ -85,7 +108,7 @@ for /f "delims== tokens=1,*" %%I in ("%~1") do ((set "opt=%%I") && (set "arg=%%J
85108 )
86109goto :loop ;
87110:target
88- if " %eq% " == " " (set " arg= %~1 " & shift)
111+ if " %eq% " == " " call : take_arg
89112 if " %arg% " == " " (
90113 echo 1 >& 2 %configure% : missing argument for %opt%
91114 exit /b 1
@@ -105,32 +128,37 @@ goto :loop ;
105128 )
106129goto :unknown_opt
107130:name
108- if " %eq% " == " " (set " arg= %~1 " & shift)
131+ if " %eq% " == " " call : take_arg
109132 echo>> %config_make% %var% = %arg%
110133goto :loopend ;
111134:dir
112- if " %eq% " == " " (set " arg= %~1 " & shift)
135+ if " %eq% " == " " call : take_arg
113136 echo>> %config_make% %opt:~2 % = %arg:\ =/ %
114137goto :loopend ;
115138:enable
116- echo>> %confargs% " %opt% " \
117- if %enable% == yes (set " opt=%opt:~9 % " ) else (set " opt=%opt:~10 % " )
118- if " %opt% " == " install-doc" (
139+ if %enable% == yes (
140+ if " %eq% " == " " call :take_arg
141+ set " feature = %opt:~9 % "
142+ ) else (
143+ set " feature = %opt:~10 % "
144+ )
145+ if %enable% == yes if defined arg (set " enable=%arg% " )
146+ if " %feature% " == " install-doc" (
119147 echo>> %config_make% RDOCTARGET = %enable:yes =r % doc
120148 )
121- if " %opt % " == " install-static-library" (
149+ if " %feature % " == " install-static-library" (
122150 echo>> %config_make% INSTALL_STATIC_LIBRARY = %enable%
123151 )
124- if " %opt % " == " debug-env" (
152+ if " %feature % " == " debug-env" (
125153 echo>> %config_make% ENABLE_DEBUG_ENV = %enable%
126154 )
127- if " %opt % " == " devel" (
155+ if " %feature % " == " devel" (
128156 echo>> %config_make% RUBY_DEVEL = %enable%
129157 )
130- if " %opt % " == " rubygems" (
131- echo>> %config_make% USE_RUBYGEMS = %enable%
158+ if " %feature % " == " rubygems" (
159+ echo>> %config_make% USE_RUBYGEMS = %enable%
132160 )
133- goto :loop ;
161+ goto :loopend ;
134162:withoutarg
135163 echo>> %confargs% " %opt% " \
136164 if " %opt% " == " --without-baseruby" goto :nobaseruby
@@ -140,7 +168,7 @@ goto :loop ;
140168goto :loop ;
141169:witharg
142170 if " %opt% " == " --with-static-linked-ext" goto :extstatic
143- if " %eq% " == " " (set " arg= %~1 " & shift)
171+ if " %eq% " == " " call : take_arg
144172 if not " %arg% " == " " (
145173 echo>> %confargs% " %opt% =%arg:$ =$$ % " \
146174 ) else (
@@ -158,7 +186,7 @@ goto :loop ;
158186:ntver
159187 :: - For version constants, see
160188 :: - https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt#remarks
161- if " %eq% " == " " (set " NTVER=%~1 " & shift) else (set " NTVER=%arg% " )
189+ if " %eq% " == " " (set " NTVER=%~1 " & call : shift) else (set " NTVER=%arg% " )
162190 if /i not " %NTVER:~0 ,2 % " == " 0x" if /i not " %NTVER:~0 ,13 % " == " _WIN32_WINNT_" (
163191 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 (
164192 call :set NTVER=%%N TVER:%%i =%%i %%
@@ -168,11 +196,11 @@ goto :loop ;
168196 echo>> %config_make% NTVER = %NTVER%
169197goto :loopend ;
170198:extout
171- if " %eq% " == " " (set " arg= %~1 " & shift)
199+ if " %eq% " == " " call : take_arg
172200 if not " %arg% " == " .ext" (echo>> %config_make% EXTOUT = %arg% )
173201goto :loopend ;
174202:path
175- if " %eq% " == " " (set " arg= %~1 " & shift)
203+ if " %eq% " == " " call : take_arg
176204 set " pathlist = %pathlist%%a rg:\ =/ % ;"
177205goto :loopend ;
178206:extstatic
@@ -236,7 +264,7 @@ goto :loop ;
236264 echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK)
237265 echo --with-ntver=_WIN32_WINNT_XXXX
238266 echo --with-ntver=XXXX same as --with-ntver=_WIN32_WINNT_XXXX
239- echo Note that '[1m=,;[m' need to be enclosed within double quotes in batch file command line .
267+ echo Note that parameters containing spaces must be enclosed within double quotes.
240268 del %confargs% %config_make%
241269goto :EOF
242270:unknown_opt
0 commit comments