Skip to content

Commit a3bfddf

Browse files
committed
Win32: Refactor configurations
Pass configure options to the generated Makefile as-is.
1 parent a687b2e commit a3bfddf

File tree

3 files changed

+123
-166
lines changed

3 files changed

+123
-166
lines changed

win32/Makefile.sub

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@ ruby_version = $(MAJOR).$(MINOR).0
190190
!if defined(ABI_VERSION)
191191
ruby_version = $(ruby_version)+$(ABI_VERSION)
192192
!endif
193-
!if !defined(RUBY_VERSION_NAME)
194-
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
195-
!endif
196193
RUBY_PROGRAM_VERSION = $(MAJOR).$(MINOR).$(TEENY)
197194

198195
!ifndef RUBY_SO_NAME
@@ -1131,6 +1128,11 @@ s,@TEENY@,$(TEENY),;t t
11311128
s,@ruby_version@,$(ruby_version),;t t
11321129
s,@RUBY_PROGRAM_VERSION@,$$(MAJOR).$$(MINOR).$$(TEENY),;t t
11331130
s,@RUBY_API_VERSION@,$$(MAJOR).$$(MINOR),;t t
1131+
!if defined(RUBY_VERSION_NAME)
1132+
s,@RUBY_VERSION_NAME@,$(RUBY_VERSION_NAME),;t t
1133+
!else
1134+
s,@RUBY_VERSION_NAME@,$$(RUBY_BASE_NAME)-$$(ruby_version),;t t
1135+
!endif
11341136
s,@rubylibprefix@,$${prefix}/lib/$${RUBY_BASE_NAME},;t t
11351137
s,@rubyarchdir@,$${rubylibdir}/$${arch},;t t
11361138
s,@rubylibdir@,$${rubylibprefix}/$${ruby_version},;t t
@@ -1140,7 +1142,7 @@ s,@sitelibdir@,$${sitedir}/$${ruby_version},;t t
11401142
s,@vendordir@,$${rubylibprefix}/vendor_ruby,;t t
11411143
s,@vendorarchdir@,$${vendorlibdir}/$${sitearch},;t t
11421144
s,@vendorlibdir@,$${vendordir}/$${ruby_version},;t t
1143-
s,@rubyhdrdir@,$$(includedir)/$${RUBY_BASE_NAME}-$$(ruby_version),;t t
1145+
s,@rubyhdrdir@,$$(includedir)/$$(RUBY_VERSION_NAME),;t t
11441146
s,@sitehdrdir@,$$(rubyhdrdir)/site_ruby,;t t
11451147
s,@vendorhdrdir@,$$(rubyhdrdir)/vendor_ruby,;t t
11461148
s,@rubyarchhdrdir@,$$(rubyhdrdir)/$${arch},;t t

win32/configure.bat

Lines changed: 112 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ for %%I in (%0) do if /%%~dpI/ == /%CD%\/ (
1010
set XINCFLAGS=
1111
set XLDFLAGS=
1212

13-
echo> ~tmp~.mak ####
14-
echo>> ~tmp~.mak conf = %0
15-
echo>> ~tmp~.mak $(conf): nul
16-
echo>> ~tmp~.mak @del ~setup~.mak
17-
echo>> ~tmp~.mak @$(MAKE) -l$(MAKEFLAGS) -f $(@D)/setup.mak \
18-
if exist pathlist.tmp del pathlist.tmp
19-
echo>confargs.tmp #define CONFIGURE_ARGS \
13+
set conf=%0
14+
set pathlist=
15+
set config_make=confargs~%RANDOM%.mak
16+
set confargs=%config_make:.mak=.c%
17+
echo>%config_make% # CONFIGURE
18+
(
19+
echo #define $ $$ //
20+
echo !ifndef CONFIGURE_ARGS
21+
echo #define CONFIGURE_ARGS \
22+
) >%confargs%
2023
:loop
2124
set opt=%1
2225
if "%1" == "" goto :end
@@ -28,6 +31,7 @@ if "%1" == "target" goto :target
2831
if "%1" == "--with-static-linked-ext" goto :extstatic
2932
if "%1" == "--program-prefix" goto :pprefix
3033
if "%1" == "--program-suffix" goto :suffix
34+
if "%1" == "--program-transform-name" goto :transform_name
3135
if "%1" == "--program-name" goto :installname
3236
if "%1" == "--install-name" goto :installname
3337
if "%1" == "--so-name" goto :soname
@@ -59,166 +63,170 @@ if "%opt:~0,7%" == "--with-" goto :witharg
5963
if "%1" == "-h" goto :help
6064
if "%1" == "--help" goto :help
6165
if "%opt:~0,1%" == "-" (
62-
echo>>confargs.tmp %1 \
66+
echo>>%confargs% %1 \
6367
set witharg=
6468
) else if "%witharg%" == "" (
65-
echo>>confargs.tmp %1 \
69+
echo>>%confargs% %1 \
6670
) else (
67-
echo>>confargs.tmp ,%1\
71+
echo>>%confargs% ,%1\
6872
)
6973
shift
7074
goto :loop ;
7175
:srcdir
72-
echo>> ~tmp~.mak "srcdir=%~2" \
73-
echo>>confargs.tmp --srcdir=%2 \
76+
echo>> %config_make% srcdir = %~2
77+
echo>>%confargs% --srcdir=%2 \
7478
shift
7579
shift
7680
goto :loop ;
7781
:prefix
78-
echo>> ~tmp~.mak "prefix=%~2" \
79-
echo>>confargs.tmp %1=%2 \
82+
echo>> %config_make% prefix = %~2
83+
echo>>%confargs% %1=%2 \
8084
shift
8185
shift
8286
goto :loop ;
8387
:pprefix
84-
echo>> ~tmp~.mak "PROGRAM_PREFIX=%~2" \
85-
echo>>confargs.tmp %1=%2 \
88+
echo>> %config_make% PROGRAM_PREFIX = %~2
89+
echo>>%confargs% %1=%2 \
8690
shift
8791
shift
8892
goto :loop ;
8993
:suffix
90-
echo>> ~tmp~.mak "PROGRAM_SUFFIX=%~2" \
91-
echo>>confargs.tmp %1=%2 \
94+
echo>> %config_make% PROGRAM_SUFFIX = %~2
95+
echo>>%confargs% %1=%2 \
9296
shift
9397
shift
9498
goto :loop ;
9599
:installname
96-
echo>> ~tmp~.mak "RUBY_INSTALL_NAME=%~2" \
97-
echo>>confargs.tmp %1=%2 \
100+
echo>> %config_make% RUBY_INSTALL_NAME = %~2
101+
echo>>%confargs% %1=%2 \
98102
shift
99103
shift
100104
goto :loop ;
101105
:soname
102-
echo>> ~tmp~.mak "RUBY_SO_NAME=%~2" \
103-
echo>>confargs.tmp %1=%2 \
106+
echo>> %config_make% RUBY_SO_NAME = %~2
107+
echo>>%confargs% %1=%2 \
108+
shift
109+
shift
110+
goto :loop ;
111+
:transform_name
112+
104113
shift
105114
shift
106115
goto :loop ;
107116
:target
108-
echo>> ~tmp~.mak "%~2" \
109-
echo>>confargs.tmp --target=%2 \
110-
if NOT "%~2" == "x64-mswin64" goto target3
111-
:target2
112-
echo>> ~tmp~.mak "TARGET_OS=mswin64" \
113-
:target3
117+
echo>> %config_make% target = %~2
118+
echo>>%confargs% --target=%2 \
119+
if "%~2" == "x64-mswin64" (
120+
echo>> %config_make% TARGET_OS = mswin64
121+
)
114122
shift
115123
shift
116124
goto :loop ;
117125
:extstatic
118-
echo>> ~tmp~.mak "EXTSTATIC=static" \
119-
echo>>confargs.tmp %1 \
126+
echo>> %config_make% EXTSTATIC = static
127+
echo>>%confargs% %1 \
120128
shift
121129
goto :loop ;
122130
:enable-rdoc
123-
echo>> ~tmp~.mak "RDOCTARGET=rdoc" \
124-
echo>>confargs.tmp %1 \
131+
echo>> %config_make% RDOCTARGET = rdoc
132+
echo>>%confargs% %1 \
125133
shift
126134
goto :loop ;
127135
:disable-rdoc
128-
echo>> ~tmp~.mak "RDOCTARGET=nodoc" \
129-
echo>>confargs.tmp %1 \
136+
echo>> %config_make% RDOCTARGET = nodoc
137+
echo>>%confargs% %1 \
130138
shift
131139
goto :loop ;
132140
:enable-lib
133-
echo>> ~tmp~.mak "INSTALL_STATIC_LIBRARY=yes" \
134-
echo>>confargs.tmp %1 \
141+
echo>> %config_make% INSTALL_STATIC_LIBRARY = yes
142+
echo>>%confargs% %1 \
135143
shift
136144
goto :loop ;
137145
:disable-lib
138-
echo>> ~tmp~.mak "INSTALL_STATIC_LIBRARY=no" \
139-
echo>>confargs.tmp %1 \
146+
echo>> %config_make% INSTALL_STATIC_LIBRARY = no
147+
echo>>%confargs% %1 \
140148
shift
141149
goto :loop ;
142150
:enable-debug-env
143-
echo>> ~tmp~.mak "ENABLE_DEBUG_ENV=yes" \
144-
echo>>confargs.tmp %1 \
151+
echo>> %config_make% ENABLE_DEBUG_ENV = yes
152+
echo>>%confargs% %1 \
145153
shift
146154
goto :loop ;
147155
:disable-debug-env
148-
echo>> ~tmp~.mak "ENABLE_DEBUG_ENV=no" \
149-
echo>>confargs.tmp %1 \
156+
echo>> %config_make% ENABLE_DEBUG_ENV = no
157+
echo>>%confargs% %1 \
150158
shift
151159
goto :loop ;
152160
:enable-devel
153-
echo>> ~tmp~.mak "RUBY_DEVEL=yes" \
154-
echo>>confargs.tmp %1 \
161+
echo>> %config_make% RUBY_DEVEL = yes
162+
echo>>%confargs% %1 \
155163
shift
156164
goto :loop ;
157165
:disable-devel
158-
echo>> ~tmp~.mak "RUBY_DEVEL=no" \
159-
echo>>confargs.tmp %1 \
166+
echo>> %config_make% RUBY_DEVEL = no
167+
echo>>%confargs% %1 \
160168
shift
161169
goto :loop ;
162170
:enable-rubygems
163-
echo>> ~tmp~.mak "USE_RUBYGEMS=yes" \
164-
echo>>confargs.tmp %1 \
171+
echo>> %config_make% USE_RUBYGEMS = yes
172+
echo>>%confargs% %1 \
165173
shift
166174
goto :loop ;
167175
:disable-rubygems
168-
echo>> ~tmp~.mak "USE_RUBYGEMS=no" \
169-
echo>>confargs.tmp %1 \
176+
echo>> %config_make% USE_RUBYGEMS = no
177+
echo>>%confargs% %1 \
170178
shift
171179
goto :loop ;
172180
:ntver
173-
echo>> ~tmp~.mak "NTVER=%~2" \
174-
echo>>confargs.tmp %1=%2 \
181+
echo>> %config_make% NTVER = %~2
182+
echo>>%confargs% %1=%2 \
175183
shift
176184
shift
177185
goto :loop ;
178186
:extout
179-
echo>> ~tmp~.mak "EXTOUT=%~2" \
180-
echo>>confargs.tmp %1=%2 \
187+
if not "%~2" == ".ext" (echo>> %config_make% EXTOUT = %~2)
188+
echo>>%confargs% %1=%2 \
181189
shift
182190
shift
183191
goto :loop ;
184192
:path
185-
echo>>pathlist.tmp %~2;\
186-
echo>>confargs.tmp %1=%2 \
193+
set pathlist=%pathlist%%~2;
194+
echo>>%confargs% %1=%2 \
187195
shift
188196
shift
189197
goto :loop ;
190198
:baseruby
191-
echo>> ~tmp~.mak "BASERUBY=%~2" \
192-
echo>>confargs.tmp %1=%2 \
199+
echo>> %config_make% BASERUBY = %~2
200+
echo>>%confargs% %1=%2 \
193201
shift
194202
shift
195203
goto :loop ;
196204
:nobaseruby
197-
echo>> ~tmp~.mak "HAVE_BASERUBY=no" \
198-
echo>>confargs.tmp %1=%2 \
205+
echo>> %config_make% HAVE_BASERUBY = no
206+
echo>>%confargs% %1=%2 \
199207
shift
200208
goto :loop ;
201209
:libdir
202-
echo>> ~tmp~.mak "libdir_basename=%~2" \
203-
echo>>confargs.tmp %1=%2 \
210+
echo>> %config_make% libdir_basename = %~2
211+
echo>>%confargs% %1=%2 \
204212
shift
205213
shift
206214
goto :loop ;
207215
:git
208-
echo>> ~tmp~.mak "GIT=%~2" \
209-
echo>>confargs.tmp %1=%2 \
216+
echo>> %config_make% GIT = %~2
217+
echo>>%confargs% %1=%2 \
210218
shift
211219
shift
212220
goto :loop ;
213221
:nogit
214-
echo>> ~tmp~.mak "GIT=never-use" \
215-
echo>> ~tmp~.mak "HAVE_GIT=no" \
216-
echo>>confargs.tmp %1 \
222+
echo>> %config_make% GIT = never-use
223+
echo>> %config_make% HAVE_GIT = no
224+
echo>>%confargs% %1 \
217225
shift
218226
goto :loop ;
219227
:gmp
220-
echo>> ~tmp~.mak "WITH_GMP=yes" \
221-
echo>>confargs.tmp %1=1 \
228+
echo>> %config_make% WITH_GMP = yes
229+
echo>>%confargs% %1=1 \
222230
shift
223231
shift
224232
goto :loop ;
@@ -233,13 +241,13 @@ goto :loop ;
233241
)
234242
)
235243
:witharg
236-
echo>>confargs.tmp %1=%2\
244+
echo>>%confargs% %1=%2\
237245
set witharg=1
238246
shift
239247
shift
240248
goto :loop ;
241249
:withoutarg
242-
echo>>confargs.tmp %1 \
250+
echo>>%confargs% %1 \
243251
shift
244252
goto :loop ;
245253
:help
@@ -259,35 +267,41 @@ goto :loop ;
259267
echo --disable-install-doc do not install rdoc indexes during install
260268
echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK)
261269
echo Note that `,' and `;' need to be enclosed within double quotes in batch file command line.
262-
del *.tmp
263-
del ~tmp~.mak
270+
del %confargs% %config_make%
264271
goto :exit
265272
:end
266-
echo>> ~tmp~.mak WIN32DIR=$(@D:\=/)
267-
echo.>>confargs.tmp
268-
echo>confargs.c #define $ $$ //
269-
echo>>confargs.c !ifndef CONFIGURE_ARGS
270-
type>>confargs.c confargs.tmp
271-
echo>>confargs.c configure_args = CONFIGURE_ARGS
272-
echo>>confargs.c !endif
273-
echo>>confargs.c #undef $
274-
if exist pathlist.tmp echo>>confargs.c #define PATH_LIST \
275-
if exist pathlist.tmp type>>confargs.c pathlist.tmp
276-
if exist pathlist.tmp echo.>>confargs.c
277-
if exist pathlist.tmp echo>>confargs.c pathlist = PATH_LIST
278-
cl -EP confargs.c > ~setup~.mak 2>nul
279-
if exist pathlist.tmp echo>>~setup~.mak PATH = $(pathlist:;=/bin;)$(PATH)
280-
if exist pathlist.tmp echo>>~setup~.mak INCLUDE = $(pathlist:;=/include;)
281-
if exist pathlist.tmp echo>>~setup~.mak LIB = $(pathlist:;=/lib;)
282-
echo>>~setup~.mak XINCFLAGS = %XINCFLAGS%
283-
echo>>~setup~.mak XLDFLAGS = %XLDFLAGS%
284-
type>>~setup~.mak ~tmp~.mak
285-
del *.tmp > nul
286-
del ~tmp~.mak > nul
287-
echo>>~setup~.mak @if exist Makefile.old del Makefile.old
288-
echo>>~setup~.mak @if exist Makefile ren Makefile Makefile.old
289-
echo>>~setup~.mak @ren Makefile.new Makefile
290-
nmake -alf ~setup~.mak MAKEFILE=Makefile.new
273+
(
274+
echo //
275+
echo configure_args = CONFIGURE_ARGS
276+
echo !endif
277+
echo #undef $
278+
) >> %confargs%
279+
(
280+
cl -EP %confargs% 2>nul | findstr "! ="
281+
echo.
282+
if NOT "%XINCFLAGS%" == "" echo XINCFLAGS = %XINCFLAGS%
283+
if NOT "%XLDFLAGS%" == "" echo XLDFLAGS = %XLDFLAGS%
284+
if NOT "%pathlist%" == "" (
285+
call echo PATH = %%pathlist:;=/bin;%%$^(PATH^)
286+
call echo INCLUDE = %%pathlist:;=/include;%%$^(INCLUDE^)
287+
call echo LIB = %%pathlist:;=/lib;%%$^(LIB^)
288+
)
289+
) >> %config_make%
290+
del %confargs% > nul
291+
292+
set setup_make=%config_make:confargs=setup%
293+
(
294+
echo #### -*- makefile -*-
295+
echo conf = %conf%
296+
echo $^(conf^): nul
297+
echo @del %setup_make%
298+
echo @$^(MAKE^) -l$^(MAKEFLAGS^) -f $^(@D^)/setup.mak \
299+
echo WIN32DIR=$^(@D:\=/^) config_make=%config_make%
300+
echo -@move /y Makefile Makefile.old ^> nul 2^> nul
301+
echo @ren Makefile.new Makefile
302+
) > %setup_make%
303+
nmake -alf %setup_make% MAKEFILE=Makefile.new
304+
291305
exit /b %ERRORLEVEL%
292306
:exit
293307
@endlocal

0 commit comments

Comments
 (0)