1@ECHO OFF
2
3REM ~ Copyright 2002-2018 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
7if "_%1_" == "_yacc_" goto Guess_Yacc
8if "_%1_" == "_test_path_" (
9    shift
10    goto Test_Path)
11goto Guess
12
13
14:Clear_Error
15ver >nul
16goto :eof
17
18
19:Test_Path
20REM Tests for the given executable file presence in the directories in the PATH
21REM environment variable. Additionally sets FOUND_PATH to the path of the
22REM found file.
23call :Clear_Error
24setlocal
25set test=%~$PATH:1
26endlocal
27if not errorlevel 1 set FOUND_PATH=%~dp$PATH:1
28goto :eof
29
30
31:Guess
32REM Let vswhere tell us where msvc is at, if available.
33call :Clear_Error
34call vswhere_usability_wrapper.cmd
35call :Clear_Error
36REM VSUNKCOMNTOOLS represents unknown but detected version from vswhere
37if NOT "_%VSUNKCOMNTOOLS%_" == "__" (
38    set "B2_TOOLSET=vcunk"
39    set "B2_TOOLSET_ROOT=%VSUNKCOMNTOOLS%..\..\VC\"
40    goto :eof)
41if NOT "_%VS160COMNTOOLS%_" == "__" (
42    set "B2_TOOLSET=vc142"
43    set "B2_TOOLSET_ROOT=%VS160COMNTOOLS%..\..\VC\"
44    goto :eof)
45if NOT "_%VS150COMNTOOLS%_" == "__" (
46    set "B2_TOOLSET=vc141"
47    set "B2_TOOLSET_ROOT=%VS150COMNTOOLS%..\..\VC\"
48    goto :eof)
49if EXIST "%VS_ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"  (
50    set "B2_TOOLSET=vc141"
51    set "B2_TOOLSET_ROOT=%VS_ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\VC\"
52    exit /b 0)
53if EXIST "%VS_ProgramFiles%\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat"  (
54    set "B2_TOOLSET=vc141"
55    set "B2_TOOLSET_ROOT=%VS_ProgramFiles%\Microsoft Visual Studio\2017\Professional\VC\"
56    exit /b 0)
57if EXIST "%VS_ProgramFiles%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"  (
58    set "B2_TOOLSET=vc141"
59    set "B2_TOOLSET_ROOT=%VS_ProgramFiles%\Microsoft Visual Studio\2017\Community\VC\"
60    exit /b 0)
61if NOT "_%VS140COMNTOOLS%_" == "__" (
62    set "B2_TOOLSET=vc14"
63    set "B2_TOOLSET_ROOT=%VS140COMNTOOLS%..\..\VC\"
64    exit /b 0)
65if EXIST "%VS_ProgramFiles%\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT" (
66    set "B2_TOOLSET=vc14"
67    set "B2_TOOLSET_ROOT=%VS_ProgramFiles%\Microsoft Visual Studio 14.0\VC\"
68    exit /b 0)
69if NOT "_%VS120COMNTOOLS%_" == "__" (
70    set "B2_TOOLSET=vc12"
71    set "B2_TOOLSET_ROOT=%VS120COMNTOOLS%..\..\VC\"
72    exit /b 0)
73if EXIST "%VS_ProgramFiles%\Microsoft Visual Studio 12.0\VC\VCVARSALL.BAT" (
74    set "B2_TOOLSET=vc12"
75    set "B2_TOOLSET_ROOT=%VS_ProgramFiles%\Microsoft Visual Studio 12.0\VC\"
76    exit /b 0)
77if NOT "_%VS110COMNTOOLS%_" == "__" (
78    set "B2_TOOLSET=vc11"
79    set "B2_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
80    exit /b 0)
81if EXIST "%VS_ProgramFiles%\Microsoft Visual Studio 11.0\VC\VCVARSALL.BAT" (
82    set "B2_TOOLSET=vc11"
83    set "B2_TOOLSET_ROOT=%VS_ProgramFiles%\Microsoft Visual Studio 11.0\VC\"
84    exit /b 0)
85call :Test_Path cl.exe
86if not errorlevel 1 (
87    set "B2_TOOLSET=msvc"
88    set "B2_TOOLSET_ROOT=%FOUND_PATH%..\"
89    exit /b 0)
90call :Test_Path vcvars32.bat
91if not errorlevel 1 (
92    set "B2_TOOLSET=msvc"
93    call "%FOUND_PATH%VCVARS32.BAT"
94    set "B2_TOOLSET_ROOT=%MSVCDir%\"
95    exit /b 0)
96if EXIST "C:\Borland\BCC55\Bin\bcc32.exe" (
97    set "B2_TOOLSET=borland"
98    set "B2_TOOLSET_ROOT=C:\Borland\BCC55\"
99    exit /b 0)
100call :Test_Path bcc32.exe
101if not errorlevel 1 (
102    set "B2_TOOLSET=borland"
103    set "B2_TOOLSET_ROOT=%FOUND_PATH%..\"
104    exit /b 0)
105call :Test_Path icl.exe
106if not errorlevel 1 (
107    set "B2_TOOLSET=intel-win32"
108    set "B2_TOOLSET_ROOT=%FOUND_PATH%..\"
109    exit /b 0)
110if EXIST "C:\MinGW\bin\gcc.exe" (
111    set "B2_TOOLSET=mingw"
112    set "B2_TOOLSET_ROOT=C:\MinGW\"
113    exit /b 0)
114REM Could not find a suitable toolset
115exit /b 1
116