-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.bat
297 lines (261 loc) · 7.74 KB
/
configure.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Copyright (C) 2016 The Qt Company Ltd.
:: Copyright (C) 2016 Intel Corporation.
:: Contact: https://www.qt.io/licensing/
::
:: This file is part of the tools applications of the Qt Toolkit.
::
:: $QT_BEGIN_LICENSE:GPL-EXCEPT$
:: Commercial License Usage
:: Licensees holding valid commercial Qt licenses may use this file in
:: accordance with the commercial license agreement provided with the
:: Software or, alternatively, in accordance with the terms contained in
:: a written agreement between you and The Qt Company. For licensing terms
:: and conditions see https://www.qt.io/terms-conditions. For further
:: information use the contact form at https://www.qt.io/contact-us.
::
:: GNU General Public License Usage
:: Alternatively, this file may be used under the terms of the GNU
:: General Public License version 3 as published by the Free Software
:: Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
:: included in the packaging of this file. Please review the following
:: information to ensure the GNU General Public License requirements will
:: be met: https://www.gnu.org/licenses/gpl-3.0.html.
::
:: $QT_END_LICENSE$
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
set ARGS=%*
set QTSRC=%~dp0
set QTSRC=%QTSRC:~0,-1%
set QTDIR=%CD%
rem Make sure qmake is not confused by these. Recursion via Makefiles would
rem be still affected, so just unsetting them here is not an option.
if not "%QMAKESPEC%" == "" goto envfail
if not "%XQMAKESPEC%" == "" goto envfail
if not "%QMAKEPATH%" == "" goto envfail
if not "%QMAKEFEATURES%" == "" goto envfail
goto envok
:envfail
echo >&2 Please make sure to unset the QMAKESPEC, XQMAKESPEC, QMAKEPATH,
echo >&2 and QMAKEFEATURES environment variables prior to building Qt.
exit /b 1
:envok
rem Parse command line
set TOPLEVEL=false
set TOPQTSRC=%QTSRC%
set TOPQTDIR=%QTDIR%
if /i not "%~1" == "-top-level" goto notoplevel
set ARGS=%ARGS:~10%
set TOPLEVEL=true
for %%P in ("%TOPQTSRC%") do set TOPQTSRC=%%~dpP
set TOPQTSRC=%TOPQTSRC:~0,-1%
for %%P in ("%QTDIR%") do set TOPQTDIR=%%~dpP
set TOPQTDIR=%TOPQTDIR:~0,-1%
goto wastoplevel
:notoplevel
if not exist ..\.qmake.super goto wastoplevel
echo ERROR: You cannot configure qtbase separately within a top-level build. >&2
exit /b 1
:wastoplevel
set SYNCQT=
set PLATFORM=
set MAKE=
call :doargs %ARGS%
if errorlevel 1 exit /b
goto doneargs
:doargs
if "%~1" == "" exit /b
if "%~1" == "/?" goto help
if "%~1" == "-?" goto help
if /i "%~1" == "/h" goto help
if /i "%~1" == "-h" goto help
if /i "%~1" == "/help" goto help
if /i "%~1" == "-help" goto help
if /i "%~1" == "--help" goto help
if /i "%~1" == "-redo" goto redo
if /i "%~1" == "--redo" goto redo
if /i "%~1" == "-platform" goto platform
if /i "%~1" == "--platform" goto platform
if /i "%~1" == "-no-syncqt" goto nosyncqt
if /i "%~1" == "--no-syncqt" goto nosyncqt
if /i "%~1" == "-make-tool" goto maketool
if /i "%~1" == "--make-tool" goto maketool
:nextarg
shift
goto doargs
:help
type %QTSRC%\config_help.txt
if %TOPLEVEL% == false exit /b 1
for /d %%p in ("%TOPQTSRC%"\qt*) do (
if not "%%p" == "%QTSRC%" (
if exist "%%p\config_help.txt" (
echo.
type "%%p\config_help.txt"
)
)
)
exit /b 1
:redo
if not exist "%TOPQTDIR%\config.opt" goto redoerr
set rargs=
for /f "usebackq delims=" %%i in ("%TOPQTDIR%\config.opt") do set rargs=!rargs! "%%i"
call :doargs %rargs%
goto nextarg
:redoerr
echo No config.opt present - cannot redo configuration. >&2
exit /b 1
:platform
shift
if "%~1" == "win32-msvc2012" goto msvc
if "%~1" == "win32-msvc2013" goto msvc
if "%~1" == "win32-msvc2015" goto msvc
if "%~1" == "win32-msvc2017" goto msvc
set PLATFORM=%~1
goto nextarg
:msvc
echo. >&2
echo Notice: re-mapping requested qmake spec to unified 'win32-msvc'. >&2
echo. >&2
set PLATFORM=win32-msvc
goto nextarg
:nosyncqt
set SYNCQT=false
goto nextarg
:maketool
shift
set MAKE=%~1
goto nextarg
:doneargs
rem Find various executables
for %%C in (clang-cl.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C
rem Determine host spec
if "%PLATFORM%" == "" (
if not "%icl.exe%" == "" (
set PLATFORM=win32-icc
) else if not "%cl.exe%" == "" (
set PLATFORM=win32-msvc
) else if not "%clang-cl.exe%" == "" (
set PLATFORM=win32-clang-msvc
) else if not "%g++.exe%" == "" (
set PLATFORM=win32-g++
) else (
echo Cannot detect host toolchain. Please use -platform. Aborting. >&2
exit /b 1
)
)
if not exist "%QTSRC%\mkspecs\%PLATFORM%\qmake.conf" (
echo Host platform '%PLATFORM%' is invalid. Aborting. >&2
exit /b 1
)
if "%PLATFORM:win32-g++=%" == "%PLATFORM%" (
if "%MAKE%" == "" (
if not "%jom.exe%" == "" (
set MAKE=jom
) else (
set MAKE=nmake
)
)
set tmpl=win32
) else (
if "%MAKE%" == "" (
set MAKE=mingw32-make
)
set tmpl=unix
)
rem Prepare build dir
if not exist mkspecs (
md mkspecs
if errorlevel 1 exit /b
)
if not exist bin (
md bin
if errorlevel 1 exit /b
)
if not exist qmake (
md qmake
if errorlevel 1 exit /b
)
rem Extract Qt's version from .qmake.conf
for /f "eol=# tokens=1,2,3,4 delims=.= " %%i in (%QTSRC%\.qmake.conf) do (
if %%i == MODULE_VERSION (
set QTVERMAJ=%%j
set QTVERMIN=%%k
set QTVERPAT=%%l
)
)
set QTVERSION=%QTVERMAJ%.%QTVERMIN%.%QTVERPAT%
rem Create forwarding headers
if "%SYNCQT%" == "" (
if exist "%QTSRC%\.git" (
set SYNCQT=true
) else (
set SYNCQT=false
)
)
if "%SYNCQT%" == "true" (
if not "%perl.exe%" == "" (
echo Running syncqt ...
"%perl.exe%" -w "%QTSRC%\bin\syncqt.pl" -minimal -version %QTVERSION% -module QtCore -outdir "%QTDIR%" %QTSRC%
if errorlevel 1 exit /b
) else (
echo Perl not found in PATH. Aborting. >&2
exit /b 1
)
)
rem Build qmake
echo Bootstrapping qmake ...
cd qmake
if errorlevel 1 exit /b
echo #### Generated by configure.bat - DO NOT EDIT! ####> Makefile
echo/>> Makefile
echo BUILD_PATH = ..>> Makefile
if "%tmpl%" == "win32" (
echo SOURCE_PATH = %QTSRC%>> Makefile
) else (
echo SOURCE_PATH = %QTSRC:\=/%>> Makefile
)
if exist "%QTSRC%\.git" (
echo INC_PATH = ../include>> Makefile
) else (
echo INC_PATH = $^(SOURCE_PATH^)/include>> Makefile
)
echo QT_VERSION = %QTVERSION%>> Makefile
rem These must have trailing spaces to avoid misinterpretation as 5>>, etc.
echo QT_MAJOR_VERSION = %QTVERMAJ% >> Makefile
echo QT_MINOR_VERSION = %QTVERMIN% >> Makefile
echo QT_PATCH_VERSION = %QTVERPAT% >> Makefile
if "%tmpl%" == "win32" (
echo QMAKESPEC = %PLATFORM%>> Makefile
) else (
echo QMAKESPEC = $^(SOURCE_PATH^)/mkspecs/%PLATFORM%>> Makefile
echo CONFIG_CXXFLAGS = -std=c++11 -ffunction-sections>> Makefile
echo CONFIG_LFLAGS = -Wl,--gc-sections>> Makefile
type "%QTSRC%\qmake\Makefile.unix.win32" >> Makefile
type "%QTSRC%\qmake\Makefile.unix.mingw" >> Makefile
)
echo/>> Makefile
type "%QTSRC%\qmake\Makefile.%tmpl%" >> Makefile
%MAKE%
if errorlevel 1 (cd .. & exit /b 1)
cd ..
rem Generate qt.conf
> "%QTDIR%\bin\qt.conf" (
@echo [EffectivePaths]
@echo Prefix=..
@echo [Paths]
@echo TargetSpec=dummy
@echo HostSpec=%PLATFORM%
)
if not "%QTDIR%" == "%QTSRC%" (
>> "%QTDIR%\bin\qt.conf" (
@echo [EffectiveSourcePaths]
@echo Prefix=%QTSRC:\=/%
)
)
rem Launch qmake-based configure
cd "%TOPQTDIR%"
"%QTDIR%\bin\qmake.exe" "%TOPQTSRC%" -- %ARGS%