[LIBXSLT] Update to version 1.1.32. CORE-14291
[reactos.git] / configure.cmd
1 @echo off
2
3 REM This is needed so as to avoid static expansion of environment variables
4 REM inside if (...) conditionals.
5 REM See http://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file
6 REM for more explanation.
7 REM Precisely needed for configuring Visual Studio Environment.
8 setlocal enabledelayedexpansion
9
10 REM Does the user need help?
11 if /I "%1" == "help" goto help
12 if /I "%1" == "/?" (
13 :help
14 echo Help for configure script
15 echo Syntax: path\to\source\configure.cmd [script-options] [Cmake-options]
16 echo Available script-options: Codeblocks, Eclipse, Makefiles, clang, VSSolution, RTC
17 echo Cmake-options: -DVARIABLE:TYPE=VALUE
18 goto quit
19 )
20
21 REM Special case %1 = arm_hosttools %2 = vcvarsall.bat %3 = %CMAKE_GENERATOR%
22 if /I "%1" == "arm_hosttools" (
23 echo Configuring x86 host tools for ARM cross build
24
25 REM This launches %VSINSTALLDIR%VS\vcvarsall.bat
26 call %2 x86
27
28 REM Configure host tools for x86.
29 cmake -G %3 -DARCH:STRING=i386 %~dp0
30 exit
31 )
32
33 REM Get the source root directory
34 set REACTOS_SOURCE_DIR=%~dp0
35
36 REM Ensure there's no spaces in the source path
37 echo %REACTOS_SOURCE_DIR%| find " " > NUL
38 if %ERRORLEVEL% == 0 (
39 echo. && echo Your source path contains at least one space.
40 echo This will cause problems with building.
41 echo Please rename your folders so there are no spaces in the source path,
42 echo or move your source to a different folder.
43 goto quit
44 )
45
46 REM Set default generator
47 set CMAKE_GENERATOR="Ninja"
48 set CMAKE_GENERATOR_HOST=!CMAKE_GENERATOR!
49
50 REM Detect presence of cmake
51 cmd /c cmake --version 2>&1 | find "cmake version" > NUL || goto cmake_notfound
52
53 REM Detect build environment (MinGW, VS, WDK, ...)
54 if defined ROS_ARCH (
55 echo Detected RosBE for %ROS_ARCH%
56 set BUILD_ENVIRONMENT=MinGW
57 set ARCH=%ROS_ARCH%
58 set MINGW_TOOCHAIN_FILE=toolchain-gcc.cmake
59
60 ) else if defined VCINSTALLDIR (
61 REM VS command prompt does not put this in environment vars
62 cl 2>&1 | find "x86" > NUL && set ARCH=i386
63 cl 2>&1 | find "x64" > NUL && set ARCH=amd64
64 cl 2>&1 | find "ARM" > NUL && set ARCH=arm
65 cl 2>&1 | find "15.00." > NUL && set VS_VERSION=9
66 cl 2>&1 | find "16.00." > NUL && set VS_VERSION=10
67 cl 2>&1 | find "17.00." > NUL && set VS_VERSION=11
68 cl 2>&1 | find "18.00." > NUL && set VS_VERSION=12
69 cl 2>&1 | find "19.00." > NUL && set VS_VERSION=14
70 cl 2>&1 | find "19.10." > NUL && set VS_VERSION=15
71 cl 2>&1 | find "19.11." > NUL && set VS_VERSION=15
72 cl 2>&1 | find "19.12." > NUL && set VS_VERSION=15
73 if not defined VS_VERSION (
74 echo Error: Visual Studio version too old or version detection failed.
75 goto quit
76 )
77 set BUILD_ENVIRONMENT=VS
78 set VS_SOLUTION=0
79 set VS_RUNTIME_CHECKS=0
80 echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!!VS_VERSION!-!ARCH!
81 ) else (
82 echo Error: Unable to detect build environment. Configure script failure.
83 goto quit
84 )
85
86 REM Checkpoint
87 if not defined ARCH (
88 echo Unknown build architecture
89 goto quit
90 )
91
92 set NEW_STYLE_BUILD=1
93 set USE_CLANG_CL=0
94
95 REM Parse command line parameters
96 :repeat
97 if /I "%1" == "-DNEW_STYLE_BUILD" (
98 set NEW_STYLE_BUILD=%2
99 ) else if "%BUILD_ENVIRONMENT%" == "MinGW" (
100 if /I "%1" == "Codeblocks" (
101 set CMAKE_GENERATOR="CodeBlocks - MinGW Makefiles"
102 ) else if /I "%1" == "Eclipse" (
103 set CMAKE_GENERATOR="Eclipse CDT4 - MinGW Makefiles"
104 ) else if /I "%1" == "Makefiles" (
105 set CMAKE_GENERATOR="MinGW Makefiles"
106 ) else if /I "%1" == "VSSolution" (
107 echo. && echo Error: Creation of VS Solution files is not supported in a MinGW environment.
108 echo Please run this command in a [Developer] Command Prompt for Visual Studio.
109 goto quit
110 ) else if /I "%1" == "RTC" (
111 echo. && echo Warning: RTC switch is ignored outside of a Visual Studio environment. && echo.
112 ) else if /I "%1" NEQ "" (
113 echo %1| find /I "-D" > NUL
114 if %ERRORLEVEL% == 0 (
115 REM User is passing a switch to CMake
116 REM Ignore it, and ignore the next parameter that follows
117 Shift
118 ) else (
119 echo. && echo Warning: Unrecognized switch "%1" && echo.
120 )
121 ) else (
122 goto continue
123 )
124 ) else (
125 if /I "%1" == "CodeBlocks" (
126 set CMAKE_GENERATOR="CodeBlocks - NMake Makefiles"
127 ) else if /I "%1" == "Eclipse" (
128 set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
129 ) else if /I "%1" == "Makefiles" (
130 set CMAKE_GENERATOR="NMake Makefiles"
131 ) else if /I "%1" == "clang" (
132 set USE_CLANG_CL=1
133 ) else if /I "%1" == "VSSolution" (
134 set VS_SOLUTION=1
135 REM explicitly set VS version for project generator
136 if /I "%2" == "-VS_VER" (
137 set VS_VERSION=%3
138 echo Visual Studio Environment set to !BUILD_ENVIRONMENT!!VS_VERSION!-!ARCH!
139 )
140 if "!VS_VERSION!" == "9" (
141 if "!ARCH!" == "amd64" (
142 set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"
143 ) else (
144 set CMAKE_GENERATOR="Visual Studio 9 2008"
145 )
146 ) else if "!VS_VERSION!" == "10" (
147 if "!ARCH!" == "amd64" (
148 set CMAKE_GENERATOR="Visual Studio 10 Win64"
149 ) else (
150 set CMAKE_GENERATOR="Visual Studio 10"
151 )
152 ) else if "!VS_VERSION!" == "11" (
153 if "!ARCH!" == "amd64" (
154 set CMAKE_GENERATOR="Visual Studio 11 Win64"
155 ) else if "!ARCH!" == "arm" (
156 set CMAKE_GENERATOR="Visual Studio 11 ARM"
157 set CMAKE_GENERATOR_HOST="Visual Studio 11"
158 ) else (
159 set CMAKE_GENERATOR="Visual Studio 11"
160 )
161 ) else if "!VS_VERSION!" == "12" (
162 if "!ARCH!" == "amd64" (
163 set CMAKE_GENERATOR="Visual Studio 12 Win64"
164 ) else if "!ARCH!" == "arm" (
165 set CMAKE_GENERATOR="Visual Studio 12 ARM"
166 set CMAKE_GENERATOR_HOST="Visual Studio 12"
167 ) else (
168 set CMAKE_GENERATOR="Visual Studio 12"
169 )
170 ) else if "!VS_VERSION!" == "14" (
171 if "!ARCH!" == "amd64" (
172 set CMAKE_GENERATOR="Visual Studio 14 Win64"
173 ) else if "!ARCH!" == "arm" (
174 set CMAKE_GENERATOR="Visual Studio 14 ARM"
175 set CMAKE_GENERATOR_HOST="Visual Studio 14"
176 ) else (
177 set CMAKE_GENERATOR="Visual Studio 14"
178 )
179 ) else if "!VS_VERSION!" == "15" (
180 if "!ARCH!" == "amd64" (
181 set CMAKE_GENERATOR="Visual Studio 15 Win64"
182 ) else if "!ARCH!" == "arm" (
183 set CMAKE_GENERATOR="Visual Studio 15 ARM"
184 set CMAKE_GENERATOR_HOST="Visual Studio 15"
185 ) else (
186 set CMAKE_GENERATOR="Visual Studio 15"
187 )
188 )
189 ) else if /I "%1" == "RTC" (
190 echo Runtime checks enabled
191 set VS_RUNTIME_CHECKS=1
192 ) else if /I "%1" NEQ "" (
193 echo %1| find /I "-D" > NUL
194 if %ERRORLEVEL% == 0 (
195 REM User is passing a switch to CMake
196 REM Ignore it, and ignore the next parameter that follows
197 Shift
198 ) else (
199 echo. && echo Warning: Unrecognized switch "%1" && echo.
200 )
201 ) else (
202 goto continue
203 )
204 )
205
206 REM Go to next parameter
207 SHIFT
208 goto repeat
209 :continue
210
211 REM Inform the user about the default build
212 if "!CMAKE_GENERATOR!" == "Ninja" (
213 echo This script defaults to Ninja. Type "configure help" for alternative options.
214 )
215
216 REM Create directories
217 set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
218
219 if "%VS_SOLUTION%" == "1" (
220 set REACTOS_OUTPUT_PATH=%REACTOS_OUTPUT_PATH%-sln
221 )
222
223 if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
224 set CD_SAME_AS_SOURCE=1
225 echo Creating directories in %REACTOS_OUTPUT_PATH%
226
227 if not exist %REACTOS_OUTPUT_PATH% (
228 mkdir %REACTOS_OUTPUT_PATH%
229 )
230 cd %REACTOS_OUTPUT_PATH%
231 )
232
233 if "%VS_SOLUTION%" == "1" (
234
235 if exist build.ninja (
236 echo. && echo Error: This directory has already been configured for ninja.
237 echo An output folder configured for ninja can't be reconfigured for VSSolution.
238 echo Use an empty folder or delete the contents of this folder, then try again.
239 goto quit
240 )
241 ) else if exist REACTOS.sln (
242 echo. && echo Error: This directory has already been configured for Visual Studio.
243 echo An output folder configured for VSSolution can't be reconfigured for ninja.
244 echo Use an empty folder or delete the contents of this folder, then try again. && echo.
245 goto quit
246 )
247
248 if "%NEW_STYLE_BUILD%"=="0" (
249
250 if not exist host-tools (
251 mkdir host-tools
252 )
253
254 if not exist reactos (
255 mkdir reactos
256 )
257
258 echo Preparing host tools...
259 cd host-tools
260 if EXIST CMakeCache.txt (
261 del CMakeCache.txt /q
262 )
263
264 set REACTOS_BUILD_TOOLS_DIR=!CD!
265
266 REM Use x86 for ARM host tools
267 if "%ARCH%" == "arm" (
268 REM Launch new script instance for x86 host tools configuration
269 start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR_HOST%
270 ) else (
271 cmake -G %CMAKE_GENERATOR% -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
272 )
273
274 cd..
275
276 )
277
278 echo Preparing reactos...
279
280 if "%NEW_STYLE_BUILD%"=="0" (
281 cd reactos
282 )
283
284 if EXIST CMakeCache.txt (
285 del CMakeCache.txt /q
286 del host-tools\CMakeCache.txt /q
287 )
288
289 if "%NEW_STYLE_BUILD%"=="0" (
290 set BUILD_TOOLS_FLAG=-DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%"
291 )
292
293 if "%BUILD_ENVIRONMENT%" == "MinGW" (
294 cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%"
295 ) else if %USE_CLANG_CL% == 1 (
296 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DUSE_CLANG_CL:BOOL=1 -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
297 ) else (
298 cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
299 )
300
301 if "%NEW_STYLE_BUILD%"=="0" (
302 cd..
303 )
304
305 if %ERRORLEVEL% NEQ 0 (
306 goto quit
307 )
308
309 if "%CD_SAME_AS_SOURCE%" == "1" (
310 set ENDV= from %REACTOS_OUTPUT_PATH%
311 )
312
313 if "%VS_SOLUTION%" == "1" (
314 set ENDV= You can now use msbuild or open REACTOS.sln%ENDV%.
315 ) else (
316 set ENDV= Execute appropriate build commands ^(ex: ninja, make, nmake, etc...^)%ENDV%
317 )
318
319 echo. && echo Configure script complete^^!%ENDV%
320
321 goto quit
322
323 :cmake_notfound
324 echo Unable to find cmake, if it is installed, check your PATH variable.
325
326 :quit
327 endlocal
328 exit /b