* Sync the recent cmake branch changes.
[reactos.git] / configure.cmd
1 @echo off
2
3 :: Get the source root directory
4 set REACTOS_SOURCE_DIR=%~dp0
5 set USE_NMAKE=
6
7 :: Detect build environment (MinGW, VS, WDK, ...)
8 if defined ROS_ARCH (
9 set BUILD_ENVIRONMENT=MinGW
10 set ARCH=%ROS_ARCH%
11 echo Detected RosBE for %ROS_ARCH%
12 ) else if defined DDK_TARGET_OS (
13 if "%_BUILDARCH%" == "x86" (
14 set ARCH=i386
15 )
16 if "%_BUILDARCH%" == "AMD64" (
17 set ARCH=amd64
18 )
19 set BUILD_ENVIRONMENT=WDK
20 set USE_NMAKE=1
21 echo Detected DDK/WDK for %DDK_TARGET_OS%-%ARCH%
22 )else if defined VCINSTALLDIR (
23 :: VS command prompt does not put this in enviroment vars
24 cl 2>&1 | find "x86" > NUL && set ARCH=i386
25 cl 2>&1 | find "x64" > NUL && set ARCH=amd64
26 cl 2>&1 | find "14." > NUL && set BUILD_ENVIRONMENT=VS8
27 cl 2>&1 | find "15." > NUL && set BUILD_ENVIRONMENT=VS9
28 cl 2>&1 | find "16." > NUL && set BUILD_ENVIRONMENT=VS10
29 if not defined BUILD_ENVIRONMENT (
30 echo Error: Visual Studio version too old or version detection failed.
31 exit /b
32 )
33 echo Detected Visual Studio Environment %BUILD_ENVIRONMENT%-%ARCH%
34 if not "%1" == "VSSolution" (
35 set USE_NMAKE=1
36 echo This script defaults to nmake. To use Visual Studio GUI specify "VSSolution" as a parameter.
37 )
38 ) else if defined sdkdir (
39 if "%TARGET_CPU%" == "x86" (
40 set ARCH=i386
41 )
42 if "%TARGET_CPU%" == "x64" (
43 set ARCH=amd64
44 )
45 set BUILD_ENVIRONMENT=SDK
46 set USE_NMAKE=1
47 echo Detected Windows SDK %TARGET_PLATFORM%-%ARCH%
48 )
49
50 if defined ARCH if defined BUILD_ENVIRONMENT (
51 goto createdirs
52 )
53
54 echo Error: Unable to detect a build environment. Configure script failure.
55 exit /b
56
57 :: Create directories
58 :createdirs
59
60 set REACTOS_OUTPUT_PATH=output-%BUILD_ENVIRONMENT%-%ARCH%
61 if "%REACTOS_SOURCE_DIR%" == "%CD%\" (
62 echo Creating directories in %REACTOS_OUTPUT_PATH%
63
64 if not exist %REACTOS_OUTPUT_PATH% (
65 mkdir %REACTOS_OUTPUT_PATH%
66 )
67 cd %REACTOS_OUTPUT_PATH%
68 )
69
70 if not exist host-tools (
71 mkdir host-tools
72 )
73 if not exist reactos (
74 mkdir reactos
75 )
76
77 :hostprep
78 echo Preparing host tools...
79 cd host-tools
80 if EXIST CMakeCache.txt (
81 del CMakeCache.txt /q
82 )
83 set REACTOS_BUILD_TOOLS_DIR=%CD%
84
85 if "%BUILD_ENVIRONMENT%" == "MinGW" (
86 cmake -G "MinGW Makefiles" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
87 ) else if defined USE_NMAKE (
88 cmake -G "NMake Makefiles" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
89 ) else if "%BUILD_ENVIRONMENT%" == "VS8" (
90 if "%ARCH%" == "amd64" (
91 cmake -G "Visual Studio 8 2005 Win64" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
92 ) else (
93 cmake -G "Visual Studio 8 2005" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
94 )
95 ) else if "%BUILD_ENVIRONMENT%" == "VS9" (
96 if "%ARCH%" == "amd64" (
97 cmake -G "Visual Studio 9 2008 Win64" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
98 ) else (
99 cmake -G "Visual Studio 9 2008" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
100 )
101 ) else if "%BUILD_ENVIRONMENT%" == "VS10" (
102 if "%ARCH%" == "amd64" (
103 cmake -G "Visual Studio 10 Win64" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
104 ) else (
105 cmake -G "Visual Studio 10" -DARCH=%ARCH% %REACTOS_SOURCE_DIR%
106 )
107 )
108 cd..
109
110 :reactprep
111 echo Preparing reactos...
112
113 cd reactos
114 if EXIST CMakeCache.txt (
115 del CMakeCache.txt /q
116 )
117
118 if "%BUILD_ENVIRONMENT%" == "MinGW" (
119 cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw32.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
120 ) else if defined USE_NMAKE (
121 cmake -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
122 ) else if "%BUILD_ENVIRONMENT%" == "VS8" (
123 if "%ARCH%" == "amd64" (
124 cmake -G "Visual Studio 8 2005 Win64" -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
125 ) else (
126 cmake -G "Visual Studio 8 2005" -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
127 )
128 ) else if "%BUILD_ENVIRONMENT%" == "VS9" (
129 if "%ARCH%" == "amd64" (
130 cmake -G "Visual Studio 9 2008 Win64" -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
131 ) else (
132 cmake -G "Visual Studio 9 2008" -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
133 )
134 ) else if "%BUILD_ENVIRONMENT%" == "VS10" (
135 if "%ARCH%" == "amd64" (
136 cmake -G "Visual Studio 10 Win64" -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
137 ) else (
138 cmake -G "Visual Studio 10" -DCMAKE_TOOLCHAIN_FILE=toolchain-msvc.cmake -DARCH=%ARCH% -DREACTOS_BUILD_TOOLS_DIR:DIR="%REACTOS_BUILD_TOOLS_DIR%" %REACTOS_SOURCE_DIR%
139 )
140 )
141
142 cd..
143
144 echo Configure script complete! Enter directories and execute appropriate build commands(ex: make, nmake, etc...).
145