1@ECHO OFF
2
3REM ~ Copyright 2002-2007 Rene Rivera.
4REM ~ Distributed under the Boost Software License, Version 1.0.
5REM ~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7setlocal
8goto Start
9
10
11:Set_Error
12color 00
13goto :eof
14
15
16:Clear_Error
17ver >nul
18goto :eof
19
20
21:Error_Print
22REM Output an error message and set the errorlevel to indicate failure.
23setlocal
24ECHO ###
25ECHO ### %1
26ECHO ###
27ECHO ### You can specify the toolset as the argument, i.e.:
28ECHO ###     .\build.bat msvc
29ECHO ###
30ECHO ### Toolsets supported by this script are: borland, como, gcc, gcc-nocygwin,
31ECHO ###     intel-win32, metrowerks, mingw, msvc, vc7, vc8, vc9, vc10, vc11, vc12, vc14
32ECHO ###
33call :Set_Error
34endlocal
35goto :eof
36
37
38:Test_Path
39REM Tests for the given executable file presence in the directories in the PATH
40REM environment variable. Additionaly sets FOUND_PATH to the path of the
41REM found file.
42call :Clear_Error
43setlocal
44set test=%~$PATH:1
45endlocal
46if not errorlevel 1 set FOUND_PATH=%~dp$PATH:1
47goto :eof
48
49
50:Test_Option
51REM Tests whether the given string is in the form of an option: "--*"
52call :Clear_Error
53setlocal
54set test=%1
55if not defined test (
56    call :Set_Error
57    goto Test_Option_End
58)
59set test=###%test%###
60set test=%test:"###=%
61set test=%test:###"=%
62set test=%test:###=%
63if not "-" == "%test:~1,1%" call :Set_Error
64:Test_Option_End
65endlocal
66goto :eof
67
68
69:Test_Empty
70REM Tests whether the given string is not empty
71call :Clear_Error
72setlocal
73set test=%1
74if not defined test (
75    call :Clear_Error
76    goto Test_Empty_End
77)
78set test=###%test%###
79set test=%test:"###=%
80set test=%test:###"=%
81set test=%test:###=%
82if not "" == "%test%" call :Set_Error
83:Test_Empty_End
84endlocal
85goto :eof
86
87
88:Call_If_Exists
89if EXIST %1 call %*
90goto :eof
91
92
93:Guess_Toolset
94REM Try and guess the toolset to bootstrap the build with...
95REM Sets BOOST_JAM_TOOLSET to the first found toolset.
96REM May also set BOOST_JAM_TOOLSET_ROOT to the
97REM location of the found toolset.
98
99call :Clear_Error
100call :Test_Empty %ProgramFiles%
101if not errorlevel 1 set ProgramFiles=C:\Program Files
102
103call :Clear_Error
104if NOT "_%VS140COMNTOOLS%_" == "__" (
105    set "BOOST_JAM_TOOLSET=vc14"
106    set "BOOST_JAM_TOOLSET_ROOT=%VS140COMNTOOLS%..\..\VC\"
107    goto :eof)
108call :Clear_Error
109if EXIST "%ProgramFiles%\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT" (
110    set "BOOST_JAM_TOOLSET=vc14"
111    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio 14.0\VC\"
112    goto :eof)
113call :Clear_Error
114if NOT "_%VS120COMNTOOLS%_" == "__" (
115    set "BOOST_JAM_TOOLSET=vc12"
116    set "BOOST_JAM_TOOLSET_ROOT=%VS120COMNTOOLS%..\..\VC\"
117    goto :eof)
118call :Clear_Error
119if EXIST "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\VCVARSALL.BAT" (
120    set "BOOST_JAM_TOOLSET=vc12"
121    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio 12.0\VC\"
122    goto :eof)
123call :Clear_Error
124if NOT "_%VS110COMNTOOLS%_" == "__" (
125    set "BOOST_JAM_TOOLSET=vc11"
126    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
127    goto :eof)
128call :Clear_Error
129if EXIST "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\VCVARSALL.BAT" (
130    set "BOOST_JAM_TOOLSET=vc11"
131    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio 11.0\VC\"
132    goto :eof)
133call :Clear_Error
134if NOT "_%VS100COMNTOOLS%_" == "__" (
135    set "BOOST_JAM_TOOLSET=vc10"
136    set "BOOST_JAM_TOOLSET_ROOT=%VS100COMNTOOLS%..\..\VC\"
137    goto :eof)
138call :Clear_Error
139if EXIST "%ProgramFiles%\Microsoft Visual Studio 10.0\VC\VCVARSALL.BAT" (
140    set "BOOST_JAM_TOOLSET=vc10"
141    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio 10.0\VC\"
142    goto :eof)
143call :Clear_Error
144if NOT "_%VS90COMNTOOLS%_" == "__" (
145    set "BOOST_JAM_TOOLSET=vc9"
146    set "BOOST_JAM_TOOLSET_ROOT=%VS90COMNTOOLS%..\..\VC\"
147    goto :eof)
148call :Clear_Error
149if EXIST "%ProgramFiles%\Microsoft Visual Studio 9.0\VC\VCVARSALL.BAT" (
150    set "BOOST_JAM_TOOLSET=vc9"
151    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio 9.0\VC\"
152    goto :eof)
153call :Clear_Error
154if NOT "_%VS80COMNTOOLS%_" == "__" (
155    set "BOOST_JAM_TOOLSET=vc8"
156    set "BOOST_JAM_TOOLSET_ROOT=%VS80COMNTOOLS%..\..\VC\"
157    goto :eof)
158call :Clear_Error
159if EXIST "%ProgramFiles%\Microsoft Visual Studio 8\VC\VCVARSALL.BAT" (
160    set "BOOST_JAM_TOOLSET=vc8"
161    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio 8\VC\"
162    goto :eof)
163call :Clear_Error
164if NOT "_%VS71COMNTOOLS%_" == "__" (
165    set "BOOST_JAM_TOOLSET=vc7"
166    set "BOOST_JAM_TOOLSET_ROOT=%VS71COMNTOOLS%\..\..\VC7\"
167    goto :eof)
168call :Clear_Error
169if NOT "_%VCINSTALLDIR%_" == "__" (
170    REM %VCINSTALLDIR% is also set for VC9 (and probably VC8)
171    set "BOOST_JAM_TOOLSET=vc7"
172    set "BOOST_JAM_TOOLSET_ROOT=%VCINSTALLDIR%\VC7\"
173    goto :eof)
174call :Clear_Error
175if EXIST "%ProgramFiles%\Microsoft Visual Studio .NET 2003\VC7\bin\VCVARS32.BAT" (
176    set "BOOST_JAM_TOOLSET=vc7"
177    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio .NET 2003\VC7\"
178    goto :eof)
179call :Clear_Error
180if EXIST "%ProgramFiles%\Microsoft Visual Studio .NET\VC7\bin\VCVARS32.BAT" (
181    set "BOOST_JAM_TOOLSET=vc7"
182    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio .NET\VC7\"
183    goto :eof)
184call :Clear_Error
185if NOT "_%MSVCDir%_" == "__" (
186    set "BOOST_JAM_TOOLSET=msvc"
187    set "BOOST_JAM_TOOLSET_ROOT=%MSVCDir%\"
188    goto :eof)
189call :Clear_Error
190if EXIST "%ProgramFiles%\Microsoft Visual Studio\VC98\bin\VCVARS32.BAT" (
191    set "BOOST_JAM_TOOLSET=msvc"
192    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual Studio\VC98\"
193    goto :eof)
194call :Clear_Error
195if EXIST "%ProgramFiles%\Microsoft Visual C++\VC98\bin\VCVARS32.BAT" (
196    set "BOOST_JAM_TOOLSET=msvc"
197    set "BOOST_JAM_TOOLSET_ROOT=%ProgramFiles%\Microsoft Visual C++\VC98\"
198    goto :eof)
199call :Clear_Error
200call :Test_Path cl.exe
201if not errorlevel 1 (
202    set "BOOST_JAM_TOOLSET=msvc"
203    set "BOOST_JAM_TOOLSET_ROOT=%FOUND_PATH%..\"
204    goto :eof)
205call :Clear_Error
206call :Test_Path vcvars32.bat
207if not errorlevel 1 (
208    set "BOOST_JAM_TOOLSET=msvc"
209    call "%FOUND_PATH%VCVARS32.BAT"
210    set "BOOST_JAM_TOOLSET_ROOT=%MSVCDir%\"
211    goto :eof)
212call :Clear_Error
213if EXIST "C:\Borland\BCC55\Bin\bcc32.exe" (
214    set "BOOST_JAM_TOOLSET=borland"
215    set "BOOST_JAM_TOOLSET_ROOT=C:\Borland\BCC55\"
216    goto :eof)
217call :Clear_Error
218call :Test_Path bcc32.exe
219if not errorlevel 1 (
220    set "BOOST_JAM_TOOLSET=borland"
221    set "BOOST_JAM_TOOLSET_ROOT=%FOUND_PATH%..\"
222    goto :eof)
223call :Clear_Error
224call :Test_Path icl.exe
225if not errorlevel 1 (
226    set "BOOST_JAM_TOOLSET=intel-win32"
227    set "BOOST_JAM_TOOLSET_ROOT=%FOUND_PATH%..\"
228    goto :eof)
229call :Clear_Error
230if EXIST "C:\MinGW\bin\gcc.exe" (
231    set "BOOST_JAM_TOOLSET=mingw"
232    set "BOOST_JAM_TOOLSET_ROOT=C:\MinGW\"
233    goto :eof)
234call :Clear_Error
235if NOT "_%CWFolder%_" == "__" (
236    set "BOOST_JAM_TOOLSET=metrowerks"
237    set "BOOST_JAM_TOOLSET_ROOT=%CWFolder%\"
238    goto :eof )
239call :Clear_Error
240call :Test_Path mwcc.exe
241if not errorlevel 1 (
242    set "BOOST_JAM_TOOLSET=metrowerks"
243    set "BOOST_JAM_TOOLSET_ROOT=%FOUND_PATH%..\..\"
244    goto :eof)
245call :Clear_Error
246call :Error_Print "Could not find a suitable toolset."
247goto :eof
248
249
250:Guess_Yacc
251REM Tries to find bison or yacc in common places so we can build the grammar.
252call :Clear_Error
253call :Test_Path yacc.exe
254if not errorlevel 1 (
255    set "YACC=yacc -d"
256    goto :eof)
257call :Clear_Error
258call :Test_Path bison.exe
259if not errorlevel 1 (
260    set "YACC=bison -d --yacc"
261    goto :eof)
262call :Clear_Error
263if EXIST "C:\Program Files\GnuWin32\bin\bison.exe" (
264    set "YACC=C:\Program Files\GnuWin32\bin\bison.exe" -d --yacc
265    goto :eof)
266call :Clear_Error
267call :Error_Print "Could not find Yacc to build the Jam grammar."
268goto :eof
269
270
271:Start
272set BOOST_JAM_TOOLSET=
273set BOOST_JAM_ARGS=
274
275REM If no arguments guess the toolset;
276REM or if first argument is an option guess the toolset;
277REM otherwise the argument is the toolset to use.
278call :Clear_Error
279call :Test_Empty %1
280if not errorlevel 1 (
281    call :Guess_Toolset
282    if not errorlevel 1 ( goto Setup_Toolset ) else ( goto Finish )
283)
284
285call :Clear_Error
286call :Test_Option %1
287if not errorlevel 1 (
288    call :Guess_Toolset
289    if not errorlevel 1 ( goto Setup_Toolset ) else ( goto Finish )
290)
291
292call :Clear_Error
293set BOOST_JAM_TOOLSET=%1
294shift
295goto Setup_Toolset
296
297
298:Setup_Toolset
299REM Setup the toolset command and options. This bit of code
300REM needs to be flexible enough to handle both when
301REM the toolset was guessed at and found, or when the toolset
302REM was indicated in the command arguments.
303REM NOTE: The strange multiple "if ?? == _toolset_" tests are that way
304REM because in BAT variables are subsituted only once during a single
305REM command. A complete "if ... else ..."
306REM is a single command, even though it's in multiple lines here.
307:Setup_Args
308call :Clear_Error
309call :Test_Empty %1
310if not errorlevel 1 goto Config_Toolset
311call :Clear_Error
312call :Test_Option %1
313if errorlevel 1 (
314    set BOOST_JAM_ARGS=%BOOST_JAM_ARGS% %1
315    shift
316    goto Setup_Args
317)
318:Config_Toolset
319if NOT "_%BOOST_JAM_TOOLSET%_" == "_metrowerks_" goto Skip_METROWERKS
320if NOT "_%CWFolder%_" == "__" (
321    set "BOOST_JAM_TOOLSET_ROOT=%CWFolder%\"
322    )
323set "PATH=%BOOST_JAM_TOOLSET_ROOT%Other Metrowerks Tools\Command Line Tools;%PATH%"
324set "BOOST_JAM_CC=mwcc -runtime ss -cwd include -DNT -lkernel32.lib -ladvapi32.lib -luser32.lib"
325set "BOOST_JAM_OPT_JAM=-o bootstrap\jam0.exe"
326set "BOOST_JAM_OPT_MKJAMBASE=-o bootstrap\mkjambase0.exe"
327set "BOOST_JAM_OPT_YYACC=-o bootstrap\yyacc0.exe"
328set "_known_=1"
329:Skip_METROWERKS
330if NOT "_%BOOST_JAM_TOOLSET%_" == "_msvc_" goto Skip_MSVC
331if NOT "_%MSVCDir%_" == "__" (
332    set "BOOST_JAM_TOOLSET_ROOT=%MSVCDir%\"
333    )
334call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%bin\VCVARS32.BAT"
335if not "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
336    set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
337    )
338set "BOOST_JAM_CC=cl /nologo /GZ /Zi /MLd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG kernel32.lib advapi32.lib user32.lib"
339set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
340set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
341set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
342set "_known_=1"
343:Skip_MSVC
344if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc7_" goto Skip_VC7
345if NOT "_%VS71COMNTOOLS%_" == "__" (
346    set "BOOST_JAM_TOOLSET_ROOT=%VS71COMNTOOLS%..\..\VC7\"
347    )
348if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%bin\VCVARS32.BAT"
349if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
350    if "_%VCINSTALLDIR%_" == "__" (
351        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
352        ) )
353set "BOOST_JAM_CC=cl /nologo /GZ /Zi /MLd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG kernel32.lib advapi32.lib user32.lib"
354set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
355set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
356set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
357set "_known_=1"
358:Skip_VC7
359if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc8_" goto Skip_VC8
360if NOT "_%VS80COMNTOOLS%_" == "__" (
361    set "BOOST_JAM_TOOLSET_ROOT=%VS80COMNTOOLS%..\..\VC\"
362    )
363if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
364if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
365    if "_%VCINSTALLDIR%_" == "__" (
366        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
367        ) )
368set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
369set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
370set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
371set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
372set "_known_=1"
373:Skip_VC8
374if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc9_" goto Skip_VC9
375if NOT "_%VS90COMNTOOLS%_" == "__" (
376    set "BOOST_JAM_TOOLSET_ROOT=%VS90COMNTOOLS%..\..\VC\"
377    )
378if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
379if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
380    if "_%VCINSTALLDIR%_" == "__" (
381        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
382        ) )
383set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
384set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
385set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
386set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
387set "_known_=1"
388:Skip_VC9
389if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc10_" goto Skip_VC10
390if NOT "_%VS100COMNTOOLS%_" == "__" (
391    set "BOOST_JAM_TOOLSET_ROOT=%VS100COMNTOOLS%..\..\VC\"
392    )
393if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
394if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
395    if "_%VCINSTALLDIR%_" == "__" (
396        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
397        ) )
398set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
399set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
400set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
401set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
402set "_known_=1"
403:Skip_VC10
404if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc11_" goto Skip_VC11
405if NOT "_%VS110COMNTOOLS%_" == "__" (
406    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
407    )
408if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
409if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
410    if "_%VCINSTALLDIR%_" == "__" (
411        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
412        ) )
413set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
414set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
415set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
416set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
417set "_known_=1"
418:Skip_VC11
419if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc12_" goto Skip_VC12
420if NOT "_%VS120COMNTOOLS%_" == "__" (
421    set "BOOST_JAM_TOOLSET_ROOT=%VS120COMNTOOLS%..\..\VC\"
422    )
423if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
424if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
425    if "_%VCINSTALLDIR%_" == "__" (
426        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
427        ) )
428set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
429set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
430set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
431set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
432set "_known_=1"
433:Skip_VC12
434if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc14_" goto Skip_VC14
435if NOT "_%VS140COMNTOOLS%_" == "__" (
436    set "BOOST_JAM_TOOLSET_ROOT=%VS140COMNTOOLS%..\..\VC\"
437    )
438if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
439if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
440    if "_%VCINSTALLDIR%_" == "__" (
441        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
442        ) )
443set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
444set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
445set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
446set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
447set "_known_=1"
448:Skip_VC14
449if NOT "_%BOOST_JAM_TOOLSET%_" == "_borland_" goto Skip_BORLAND
450if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
451    call :Test_Path bcc32.exe )
452if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
453    if not errorlevel 1 (
454        set "BOOST_JAM_TOOLSET_ROOT=%FOUND_PATH%..\"
455        ) )
456if not "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
457    set "PATH=%BOOST_JAM_TOOLSET_ROOT%Bin;%PATH%"
458    )
459set "BOOST_JAM_CC=bcc32 -WC -w- -q -I%BOOST_JAM_TOOLSET_ROOT%Include -L%BOOST_JAM_TOOLSET_ROOT%Lib /DNT -nbootstrap"
460set "BOOST_JAM_OPT_JAM=-ejam0"
461set "BOOST_JAM_OPT_MKJAMBASE=-emkjambasejam0"
462set "BOOST_JAM_OPT_YYACC=-eyyacc0"
463set "_known_=1"
464:Skip_BORLAND
465if NOT "_%BOOST_JAM_TOOLSET%_" == "_como_" goto Skip_COMO
466set "BOOST_JAM_CC=como -DNT"
467set "BOOST_JAM_OPT_JAM=-o bootstrap\jam0.exe"
468set "BOOST_JAM_OPT_MKJAMBASE=-o bootstrap\mkjambase0.exe"
469set "BOOST_JAM_OPT_YYACC=-o bootstrap\yyacc0.exe"
470set "_known_=1"
471:Skip_COMO
472if NOT "_%BOOST_JAM_TOOLSET%_" == "_gcc_" goto Skip_GCC
473set "BOOST_JAM_CC=gcc -DNT"
474set "BOOST_JAM_OPT_JAM=-o bootstrap\jam0.exe"
475set "BOOST_JAM_OPT_MKJAMBASE=-o bootstrap\mkjambase0.exe"
476set "BOOST_JAM_OPT_YYACC=-o bootstrap\yyacc0.exe"
477set "_known_=1"
478:Skip_GCC
479if NOT "_%BOOST_JAM_TOOLSET%_" == "_gcc-nocygwin_" goto Skip_GCC_NOCYGWIN
480set "BOOST_JAM_CC=gcc -DNT -mno-cygwin"
481set "BOOST_JAM_OPT_JAM=-o bootstrap\jam0.exe"
482set "BOOST_JAM_OPT_MKJAMBASE=-o bootstrap\mkjambase0.exe"
483set "BOOST_JAM_OPT_YYACC=-o bootstrap\yyacc0.exe"
484set "_known_=1"
485:Skip_GCC_NOCYGWIN
486if NOT "_%BOOST_JAM_TOOLSET%_" == "_intel-win32_" goto Skip_INTEL_WIN32
487set "BOOST_JAM_CC=icl -DNT /nologo kernel32.lib advapi32.lib user32.lib"
488set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
489set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
490set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
491set "_known_=1"
492:Skip_INTEL_WIN32
493if NOT "_%BOOST_JAM_TOOLSET%_" == "_mingw_" goto Skip_MINGW
494if not "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
495    set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
496    )
497set "BOOST_JAM_CC=gcc -DNT"
498set "BOOST_JAM_OPT_JAM=-o bootstrap\jam0.exe"
499set "BOOST_JAM_OPT_MKJAMBASE=-o bootstrap\mkjambase0.exe"
500set "BOOST_JAM_OPT_YYACC=-o bootstrap\yyacc0.exe"
501set "_known_=1"
502:Skip_MINGW
503call :Clear_Error
504if "_%_known_%_" == "__" (
505    call :Error_Print "Unknown toolset: %BOOST_JAM_TOOLSET%"
506)
507if errorlevel 1 goto Finish
508
509echo ###
510echo ### Using '%BOOST_JAM_TOOLSET%' toolset.
511echo ###
512
513set YYACC_SOURCES=yyacc.c
514set MKJAMBASE_SOURCES=mkjambase.c
515set BJAM_SOURCES=
516set BJAM_SOURCES=%BJAM_SOURCES% command.c compile.c constants.c debug.c
517set BJAM_SOURCES=%BJAM_SOURCES% execcmd.c execnt.c filent.c frames.c function.c
518set BJAM_SOURCES=%BJAM_SOURCES% glob.c hash.c hdrmacro.c headers.c jam.c
519set BJAM_SOURCES=%BJAM_SOURCES% jambase.c jamgram.c lists.c make.c make1.c
520set BJAM_SOURCES=%BJAM_SOURCES% object.c option.c output.c parse.c pathnt.c
521set BJAM_SOURCES=%BJAM_SOURCES% pathsys.c regexp.c rules.c scan.c search.c
522set BJAM_SOURCES=%BJAM_SOURCES% subst.c timestamp.c variable.c modules.c
523set BJAM_SOURCES=%BJAM_SOURCES% strings.c filesys.c builtins.c md5.c class.c
524set BJAM_SOURCES=%BJAM_SOURCES% cwd.c w32_getreg.c native.c modules/set.c
525set BJAM_SOURCES=%BJAM_SOURCES% modules/path.c modules/regex.c
526set BJAM_SOURCES=%BJAM_SOURCES% modules/property-set.c modules/sequence.c
527set BJAM_SOURCES=%BJAM_SOURCES% modules/order.c
528
529set BJAM_UPDATE=
530:Check_Update
531call :Test_Empty %1
532if not errorlevel 1 goto Check_Update_End
533call :Clear_Error
534setlocal
535set test=%1
536set test=###%test%###
537set test=%test:"###=%
538set test=%test:###"=%
539set test=%test:###=%
540if "%test%" == "--update" goto Found_Update
541endlocal & set BOOST_JAM_TOOLSET=%BOOST_JAM_TOOLSET%
542shift
543if not "_%BJAM_UPDATE%_" == "_update_" goto Check_Update
544:Found_Update
545endlocal & set BOOST_JAM_TOOLSET=%BOOST_JAM_TOOLSET%
546set BJAM_UPDATE=update
547:Check_Update_End
548if "_%BJAM_UPDATE%_" == "_update_" (
549    if not exist ".\bootstrap\jam0.exe" (
550        set BJAM_UPDATE=
551    )
552)
553
554@echo ON
555@if "_%BJAM_UPDATE%_" == "_update_" goto Skip_Bootstrap
556if exist bootstrap rd /S /Q bootstrap
557md bootstrap
558@if not exist jamgram.y goto Bootstrap_GrammarPrep
559@if not exist jamgramtab.h goto Bootstrap_GrammarPrep
560@goto Skip_GrammarPrep
561:Bootstrap_GrammarPrep
562%BOOST_JAM_CC% %BOOST_JAM_OPT_YYACC% %YYACC_SOURCES%
563@if not exist ".\bootstrap\yyacc0.exe" goto Skip_GrammarPrep
564.\bootstrap\yyacc0 jamgram.y jamgramtab.h jamgram.yy
565:Skip_GrammarPrep
566@if not exist jamgram.c goto Bootstrap_GrammarBuild
567@if not exist jamgram.h goto Bootstrap_GrammarBuild
568@goto Skip_GrammarBuild
569:Bootstrap_GrammarBuild
570@echo OFF
571if "_%YACC%_" == "__" (
572    call :Guess_Yacc
573)
574if errorlevel 1 goto Finish
575@echo ON
576%YACC% jamgram.y
577@if errorlevel 1 goto Finish
578del /f jamgram.c
579rename y.tab.c jamgram.c
580del /f jamgram.h
581rename y.tab.h jamgram.h
582:Skip_GrammarBuild
583@echo ON
584@if exist jambase.c goto Skip_Jambase
585%BOOST_JAM_CC% %BOOST_JAM_OPT_MKJAMBASE% %MKJAMBASE_SOURCES%
586@if not exist ".\bootstrap\mkjambase0.exe" goto Skip_Jambase
587.\bootstrap\mkjambase0 jambase.c Jambase
588:Skip_Jambase
589%BOOST_JAM_CC% %BOOST_JAM_OPT_JAM% %BJAM_SOURCES%
590:Skip_Bootstrap
591@if not exist ".\bootstrap\jam0.exe" goto Skip_Jam
592@set args=%*
593@echo OFF
594:Set_Args
595setlocal
596call :Test_Empty %args%
597if not errorlevel 1 goto Set_Args_End
598set test=###%args:~0,2%###
599set test=%test:"###=%
600set test=%test:###"=%
601set test=%test:###=%
602set test=%test:~0,1%
603if "-" == "%test%" goto Set_Args_End
604endlocal
605set args=%args:~1%
606goto Set_Args
607:Set_Args_End
608@echo ON
609@if "_%BJAM_UPDATE%_" == "_update_" goto Skip_Clean
610.\bootstrap\jam0 -f build.jam --toolset=%BOOST_JAM_TOOLSET% "--toolset-root=%BOOST_JAM_TOOLSET_ROOT% " %args% clean
611:Skip_Clean
612.\bootstrap\jam0 -f build.jam --toolset=%BOOST_JAM_TOOLSET% "--toolset-root=%BOOST_JAM_TOOLSET_ROOT% " %args%
613:Skip_Jam
614
615:Finish
616exit /b %ERRORLEVEL%
617