@@ -33,13 +33,43 @@ set confargs=%config_make:.mak=.sub%
3333set debug_configure =
3434echo> %config_make% # CONFIGURE
3535type nul > %confargs%
36+ set args = %*
37+ goto :loop
38+
39+ :shift_argv
40+ call %~dp0 shellsplit.cmd
41+ set " argv1 = %argv2% "
42+ set " argv2 = %argv% "
43+ if not defined argv1 if defined argv2 goto :shift_argv
44+ exit /b
45+
46+ :take_arg
47+ if defined arg exit /b
48+ if not defined argv2 exit /b
49+ if not " %argv2:~0 ,1 % " == " -" (set " arg=%argv2% " & call :shift_argv)
50+ exit /b
51+
52+ :set
53+ set %1
54+ exit /b
55+
3656: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
57+ call :shift_argv
58+ if not defined argv1 goto :end
59+
60+ for /f " delims== tokens=1*" %%I in (" %argv1% " ) do ((set " opt=%%I " ) && (set " arg=%%J " ))
61+ set " opt = %opt:~1 % "
62+ set " eq = "
63+ if defined arg (
64+ set " eq = ="
65+ set " arg = %arg:~0 ,-1 % "
66+ ) else (
67+ set " opt = %opt:~0 ,-1 % "
68+ )
69+ if " %opt% " == " " (
70+ echo 1 >& 2 %configure% : assignment for empty variable name %argv1%
71+ exit /b 1
72+ )
4373 if " %opt% " == " --debug-configure" (
4474 echo on
4575 set " debug_configure = yes"
@@ -85,7 +115,7 @@ for /f "delims== tokens=1,*" %%I in ("%~1") do ((set "opt=%%I") && (set "arg=%%J
85115 )
86116goto :loop ;
87117:target
88- if " %eq% " == " " (set " arg= %~1 " & shift)
118+ if " %eq% " == " " call : take_arg
89119 if " %arg% " == " " (
90120 echo 1 >& 2 %configure% : missing argument for %opt%
91121 exit /b 1
@@ -105,32 +135,37 @@ goto :loop ;
105135 )
106136goto :unknown_opt
107137:name
108- if " %eq% " == " " (set " arg= %~1 " & shift)
138+ if " %eq% " == " " call : take_arg
109139 echo>> %config_make% %var% = %arg%
110140goto :loopend ;
111141:dir
112- if " %eq% " == " " (set " arg= %~1 " & shift)
142+ if " %eq% " == " " call : take_arg
113143 echo>> %config_make% %opt:~2 % = %arg:\ =/ %
114144goto :loopend ;
115145:enable
116- echo>> %confargs% " %opt% " \
117- if %enable% == yes (set " opt=%opt:~9 % " ) else (set " opt=%opt:~10 % " )
118- if " %opt% " == " install-doc" (
146+ if %enable% == yes (
147+ if " %eq% " == " " call :take_arg
148+ set " feature = %opt:~9 % "
149+ ) else (
150+ set " feature = %opt:~10 % "
151+ )
152+ if %enable% == yes if defined arg set " enable = %arg% "
153+ if " %feature% " == " install-doc" (
119154 echo>> %config_make% RDOCTARGET = %enable:yes =r % doc
120155 )
121- if " %opt % " == " install-static-library" (
156+ if " %feature % " == " install-static-library" (
122157 echo>> %config_make% INSTALL_STATIC_LIBRARY = %enable%
123158 )
124- if " %opt % " == " debug-env" (
159+ if " %feature % " == " debug-env" (
125160 echo>> %config_make% ENABLE_DEBUG_ENV = %enable%
126161 )
127- if " %opt % " == " devel" (
162+ if " %feature % " == " devel" (
128163 echo>> %config_make% RUBY_DEVEL = %enable%
129164 )
130- if " %opt % " == " rubygems" (
131- echo>> %config_make% USE_RUBYGEMS = %enable%
165+ if " %feature % " == " rubygems" (
166+ echo>> %config_make% USE_RUBYGEMS = %enable%
132167 )
133- goto :loop ;
168+ goto :loopend ;
134169:withoutarg
135170 echo>> %confargs% " %opt% " \
136171 if " %opt% " == " --without-baseruby" goto :nobaseruby
@@ -140,7 +175,7 @@ goto :loop ;
140175goto :loop ;
141176:witharg
142177 if " %opt% " == " --with-static-linked-ext" goto :extstatic
143- if " %eq% " == " " (set " arg= %~1 " & shift)
178+ if " %eq% " == " " call : take_arg
144179 if not " %arg% " == " " (
145180 echo>> %confargs% " %opt% =%arg:$ =$$ % " \
146181 ) else (
@@ -158,7 +193,7 @@ goto :loop ;
158193:ntver
159194 :: - For version constants, see
160195 :: - 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% " )
196+ if " %eq% " == " " (set " NTVER=%~1 " & call : shift_argv ) else (set " NTVER=%arg% " )
162197 if /i not " %NTVER:~0 ,2 % " == " 0x" if /i not " %NTVER:~0 ,13 % " == " _WIN32_WINNT_" (
163198 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 (
164199 call :set NTVER=%%N TVER:%%i =%%i %%
@@ -168,11 +203,11 @@ goto :loop ;
168203 echo>> %config_make% NTVER = %NTVER%
169204goto :loopend ;
170205:extout
171- if " %eq% " == " " (set " arg= %~1 " & shift)
206+ if " %eq% " == " " call : take_arg
172207 if not " %arg% " == " .ext" (echo>> %config_make% EXTOUT = %arg% )
173208goto :loopend ;
174209:path
175- if " %eq% " == " " (set " arg= %~1 " & shift)
210+ if " %eq% " == " " call : take_arg
176211 set " pathlist = %pathlist%%a rg:\ =/ % ;"
177212goto :loopend ;
178213:extstatic
@@ -236,7 +271,7 @@ goto :loop ;
236271 echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK)
237272 echo --with-ntver=_WIN32_WINNT_XXXX
238273 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 .
274+ echo Note that parameters containing spaces must be enclosed within double quotes.
240275 del %confargs% %config_make%
241276goto :EOF
242277:unknown_opt
0 commit comments