1@echo off
2@setlocal disabledelayedexpansion
3
4echo> ~tmp~.mak ####
5echo>> ~tmp~.mak conf = %0
6echo>> ~tmp~.mak $(conf): nul
7echo>> ~tmp~.mak 	@del ~setup~.mak
8echo>> ~tmp~.mak 	@-$(MAKE) -l$(MAKEFLAGS) -f $(@D)/setup.mak \
9if exist pathlist.tmp del pathlist.tmp
10echo>confargs.tmp #define CONFIGURE_ARGS \
11:loop
12if "%1" == "" goto :end
13if "%1" == "--prefix" goto :prefix
14if "%1" == "--srcdir" goto :srcdir
15if "%1" == "srcdir" goto :srcdir
16if "%1" == "--target" goto :target
17if "%1" == "target" goto :target
18if "%1" == "--with-static-linked-ext" goto :extstatic
19if "%1" == "--program-prefix" goto :pprefix
20if "%1" == "--program-suffix" goto :suffix
21if "%1" == "--program-name" goto :installname
22if "%1" == "--install-name" goto :installname
23if "%1" == "--so-name" goto :soname
24if "%1" == "--enable-install-doc" goto :enable-rdoc
25if "%1" == "--disable-install-doc" goto :disable-rdoc
26if "%1" == "--enable-debug-env" goto :enable-debug-env
27if "%1" == "--disable-debug-env" goto :disable-debug-env
28if "%1" == "--enable-rubygems" goto :enable-rubygems
29if "%1" == "--disable-rubygems" goto :disable-rubygems
30if "%1" == "--extout" goto :extout
31if "%1" == "--path" goto :path
32if "%1" == "--with-baseruby" goto :baseruby
33if "%1" == "--with-ntver" goto :ntver
34echo %1| findstr "^--with-.*-dir$" > nul
35if not errorlevel 1 goto :witharg
36echo %1| findstr "^--with-.*-include$" > nul
37if not errorlevel 1 goto :witharg
38echo %1| findstr "^--with-.*-lib$" > nul
39if not errorlevel 1 goto :witharg
40echo %1| findstr "^--with-ext$" > nul
41if not errorlevel 1 goto :witharg
42echo %1| findstr "^--with-extensions$" > nul
43if not errorlevel 1 goto :witharg
44echo %1| findstr "^--without-ext$" > nul
45if not errorlevel 1 goto :witharg
46echo %1| findstr "^--without-extensions$" > nul
47if not errorlevel 1 goto :witharg
48if "%1" == "-h" goto :help
49if "%1" == "--help" goto :help
50  echo>>confargs.tmp %1 \
51  shift
52goto :loop
53:srcdir
54  echo>> ~tmp~.mak 	"srcdir=%~2" \
55  echo>>confargs.tmp --srcdir=%2 \
56  shift
57  shift
58goto :loop
59:prefix
60  echo>> ~tmp~.mak 	"prefix=%~2" \
61  echo>>confargs.tmp %1=%2 \
62  shift
63  shift
64goto :loop
65:pprefix
66  echo>> ~tmp~.mak 	"PROGRAM_PREFIX=%~2" \
67  echo>>confargs.tmp %1=%2 \
68  shift
69  shift
70goto :loop
71:suffix
72  echo>> ~tmp~.mak 	"PROGRAM_SUFFIX=%~2" \
73  echo>>confargs.tmp %1=%2 \
74  shift
75  shift
76goto :loop
77:installname
78  echo>> ~tmp~.mak 	"RUBY_INSTALL_NAME=%~2" \
79  echo>>confargs.tmp %1=%2 \
80  shift
81  shift
82goto :loop
83:soname
84  echo>> ~tmp~.mak 	"RUBY_SO_NAME=%~2" \
85  echo>>confargs.tmp %1=%2 \
86  shift
87  shift
88goto :loop
89:target
90  echo>> ~tmp~.mak 	"%~2" \
91  echo>>confargs.tmp --target=%2 \
92  if "%~2" == "x64-mswin64" goto target2
93  if NOT "%~2" == "ia64-mswin64" goto target3
94:target2
95  echo>> ~tmp~.mak 	"TARGET_OS=mswin64" \
96:target3
97  shift
98  shift
99goto :loop
100:extstatic
101  echo>> ~tmp~.mak 	"EXTSTATIC=static" \
102  echo>>confargs.tmp %1 \
103  shift
104goto :loop
105:enable-rdoc
106  echo>> ~tmp~.mak 	"RDOCTARGET=rdoc" \
107  echo>>confargs.tmp %1 \
108  shift
109goto :loop
110:disable-rdoc
111  echo>> ~tmp~.mak 	"RDOCTARGET=nodoc" \
112  echo>>confargs.tmp %1 \
113  shift
114goto :loop
115:enable-debug-env
116  echo>> ~tmp~.mak 	"ENABLE_DEBUG_ENV=yes" \
117  echo>>confargs.tmp %1 \
118  shift
119goto :loop
120:disable-debug-env
121  echo>> ~tmp~.mak 	"ENABLE_DEBUG_ENV=no" \
122  echo>>confargs.tmp %1 \
123  shift
124goto :loop
125:enable-rubygems
126  echo>> ~tmp~.mak 	"USE_RUBYGEMS=YES" \
127  echo>>confargs.tmp %1 \
128  shift
129goto :loop
130:disable-rubygems
131  echo>> ~tmp~.mak 	"USE_RUBYGEMS=NO" \
132  echo>>confargs.tmp %1 \
133  shift
134goto :loop
135:ntver
136  echo>> ~tmp~.mak 	"NTVER=%~2" \
137  echo>>confargs.tmp %1=%2 \
138  shift
139  shift
140goto :loop
141:extout
142  echo>> ~tmp~.mak 	"EXTOUT=%~2" \
143  echo>>confargs.tmp %1=%2 \
144  shift
145  shift
146goto :loop
147:path
148  echo>>pathlist.tmp %~2;\
149  echo>>confargs.tmp %1=%2 \
150  shift
151  shift
152goto :loop
153:baseruby
154  echo>> ~tmp~.mak 	"BASERUBY=%~2" \
155  echo>>confargs.tmp %1=%2 \
156  shift
157  shift
158goto :loop
159:witharg
160  echo>>confargs.tmp %1=%2 \
161  shift
162  shift
163goto :loop
164:help
165  echo Configuration:
166  echo   --help                  display this help
167  echo   --srcdir=DIR            find the sources in DIR [configure dir or `..']
168  echo Installation directories:
169  echo   --prefix=PREFIX         install files in PREFIX [/usr]
170  echo System types:
171  echo   --target=TARGET         configure for TARGET [i386-mswin32]
172  echo Optional Package:
173  echo   --with-baseruby=RUBY    use RUBY as baseruby [ruby]
174  echo   --with-static-linked-ext link external modules statically
175  echo   --with-ext="a,b,..."    use extensions a, b, ...
176  echo   --without-ext="a,b,..." ignore extensions a, b, ...
177  echo   --disable-install-doc   do not install rdoc indexes during install
178  echo   --disable-win95         disable win95 support
179  echo   --with-ntver=0xXXXX     target NT version (shouldn't use with old SDK)
180  del *.tmp
181  del ~tmp~.mak
182goto :exit
183:end
184echo>> ~tmp~.mak 	WIN32DIR=$(@D:\=/)
185echo.>>confargs.tmp
186echo>confargs.c #define $ $$ 
187echo>>confargs.c !ifndef CONFIGURE_ARGS
188type>>confargs.c confargs.tmp
189echo>>confargs.c configure_args = CONFIGURE_ARGS
190echo>>confargs.c !endif
191echo>>confargs.c #undef $
192if exist pathlist.tmp echo>>confargs.c #define PATH_LIST \
193if exist pathlist.tmp type>>confargs.c pathlist.tmp
194if exist pathlist.tmp echo.>>confargs.c
195if exist pathlist.tmp echo>>confargs.c pathlist = PATH_LIST
196cl -EP confargs.c > ~setup~.mak 2>nul
197if exist pathlist.tmp echo>>~setup~.mak PATH = $(pathlist:;=/bin;)$(PATH)
198if exist pathlist.tmp echo>>~setup~.mak INCLUDE = $(pathlist:;=/include;)
199if exist pathlist.tmp echo>>~setup~.mak LIB = $(pathlist:;=/lib;)
200type>>~setup~.mak ~tmp~.mak
201del *.tmp > nul
202del ~tmp~.mak > nul
203echo>>~setup~.mak 	@if exist Makefile.old del Makefile.old
204echo>>~setup~.mak 	@if exist Makefile ren Makefile Makefile.old
205echo>>~setup~.mak 	@ren Makefile.new Makefile
206nmake -alf ~setup~.mak MAKEFILE=Makefile.new
207:exit
208@endlocal
209