Debian Codegraph @

configure

raw symbols SCIP
1 #!/bin/sh
2 #############################################################################
3 ##
4 ## Copyright (C) 2016 The Qt Company Ltd.
5 ## Copyright (C) 2016 Intel Corporation.
6 ## Contact: https://www.qt.io/licensing/
7 ##
8 ## This file is the build configuration utility of the Qt Toolkit.
9 ##
10 ## $QT_BEGIN_LICENSE:GPL-EXCEPT$
11 ## Commercial License Usage
12 ## Licensees holding valid commercial Qt licenses may use this file in
13 ## accordance with the commercial license agreement provided with the
14 ## Software or, alternatively, in accordance with the terms contained in
15 ## a written agreement between you and The Qt Company. For licensing terms
16 ## and conditions see https://www.qt.io/terms-conditions. For further
17 ## information use the contact form at https://www.qt.io/contact-us.
18 ##
19 ## GNU General Public License Usage
20 ## Alternatively, this file may be used under the terms of the GNU
21 ## General Public License version 3 as published by the Free Software
22 ## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
23 ## included in the packaging of this file. Please review the following
24 ## information to ensure the GNU General Public License requirements will
25 ## be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 ##
27 ## $QT_END_LICENSE$
28 ##
29 #############################################################################
30
31 #-------------------------------------------------------------------------------
32 # script initialization
33 #-------------------------------------------------------------------------------
34
35 # the name of this script
36 relconf=`basename $0`
37 # the directory of this script is the "source tree"
38 relpath=`dirname $0`
39 relpath=`(cd "$relpath"; /bin/pwd)`
40 # the current directory is the "build tree" or "object tree"
41 outpath=`/bin/pwd`
42
43 WHICH="which"
44
45 PERL=`$WHICH perl 2>/dev/null`
46
47 # find out which awk we want to use, prefer gawk, then nawk, then regular awk
48 AWK=
49 for e in gawk nawk awk; do
50 if "$WHICH" $e >/dev/null 2>&1 && ( $e -f /dev/null /dev/null ) >/dev/null 2>&1; then
51 AWK=$e
52 break
53 fi
54 done
55
56 # find a make command
57 if [ -z "$MAKE" ]; then
58 MAKE=
59 for mk in gmake make; do
60 if "$WHICH" $mk >/dev/null 2>&1; then
61 MAKE=`"$WHICH" $mk`
62 break
63 fi
64 done
65 if [ -z "$MAKE" ]; then
66 echo >&2 "You don't seem to have 'make' or 'gmake' in your PATH."
67 echo >&2 "Cannot proceed."
68 exit 1
69 fi
70 # export MAKE, we need it later in the config.tests
71 export MAKE
72 fi
73
74 # make sure qmake is not confused by these. recursion via Makefiles would
75 # be still affected, so just unsetting them here is not an option.
76 if [ -n "$QMAKESPEC" ] || [ -n "$XQMAKESPEC" ] || \
77 [ -n "$QMAKEPATH" ] || [ -n "$QMAKEFEATURES" ]; then
78 echo >&2 "Please make sure to unset the QMAKESPEC, XQMAKESPEC, QMAKEPATH,"
79 echo >&2 "and QMAKEFEATURES environment variables prior to building Qt."
80 exit 1
81 fi
82
83 # do this early so we don't store it in config.status
84 CFG_TOPLEVEL=
85 relpathMangled=$relpath
86 outpathPrefix=
87 if [ x"$1" = x"-top-level" ]; then
88 CFG_TOPLEVEL=yes
89 relpathMangled=`dirname "$relpath"`
90 outpathPrefix=../
91 shift
92 else
93 if [ -f ../.qmake.super ]; then
94 echo >&2 "ERROR: You cannot configure qtbase separately within a top-level build."
95 exit 1
96 fi
97 fi
98
99 OPT_CMDLINE= # expanded version for the script
100 QMAKE_CMDLINE= # verbatim version for qmake call
101 set -f # suppress globbing in for loop
102 SAVED_IFS=$IFS
103 IFS='
104 '
105 for i in "$@"; do
106 case $i in
107 -redo|--redo)
108 optfile=${outpathPrefix}config.opt
109 if test -n "$CFG_TOPLEVEL" && ! test -f $optfile; then
110 optfile=config.opt
111 fi
112 if ! test -f $optfile; then
113 echo >&2 "No config.opt present - cannot redo configuration."
114 exit 1
115 fi
116 for a in `cat $optfile`; do
117 OPT_CMDLINE="$OPT_CMDLINE
118 $a"
119 done
120 ;;
121 *)
122 OPT_CMDLINE="$OPT_CMDLINE
123 $i"
124 ;;
125 esac
126 QMAKE_CMDLINE="$QMAKE_CMDLINE
127 $i"
128 done
129 set --
130 for i in $OPT_CMDLINE; do
131 set -- "$@" "$i"
132 done
133 set +f
134 IFS=$SAVED_IFS
135
136 #-------------------------------------------------------------------------------
137 # utility functions
138 #-------------------------------------------------------------------------------
139
140 # Helper function for getQMakeConf. It parses include statements in
141 # qmake.conf and prints out the expanded file
142 expandQMakeConf()
143 {
144 while read line; do case "$line" in
145 include*)
146 inc_file=`echo "$line" | sed -n -e '/^include.*(.*)/s/include.*(\(.*\)).*$/\1/p'`
147 current_dir=`dirname "$1"`
148 conf_file="$current_dir/$inc_file"
149 if [ ! -f "$conf_file" ]; then
150 echo "WARNING: Unable to find file $conf_file" >&2
151 continue
152 fi
153 expandQMakeConf "$conf_file"
154 ;;
155 *)
156 echo "$line"
157 ;;
158 esac; done < "$1"
159 }
160
161 extractQMakeVariables()
162 {
163 LC_ALL=C $AWK '
164 BEGIN {
165 values["LITERAL_WHITESPACE"] = " "
166 values["LITERAL_DOLLAR"] = "$"
167 }
168 /^[_A-Z0-9.]+[ \t]*\+?=/ {
169 valStart = index($0, "=") + 1
170
171 append = 0
172 if (substr($0, valStart - 2, 1) == "+") {
173 append = 1
174 }
175
176 variable = substr($0, 0, valStart - 2 - append)
177 value = substr($0, valStart)
178 gsub("[ \t]+", "", variable)
179 gsub("^[ \t]+", "", value)
180 gsub("[ \t]+$", "", value)
181
182 ovalue = ""
183 while (match(value, /\$\$(\{[_A-Z0-9.]+\}|[_A-Z0-9.]+)/)) {
184 ovalue = ovalue substr(value, 1, RSTART - 1)
185 var = substr(value, RSTART + 2, RLENGTH - 2)
186 value = substr(value, RSTART + RLENGTH)
187 if (var ~ /^\{/) {
188 var = substr(var, 2, length(var) - 2)
189 }
190 ovalue = ovalue values[var]
191 }
192 value = ovalue value
193
194 ovalue = ""
195 while (match(value, /\$\$system\(("[^"]*"|[^)]*)\)/)) {
196 ovalue = ovalue substr(value, 1, RSTART - 1)
197 cmd = substr(value, RSTART + 9, RLENGTH - 10)
198 gsub(/^"|"$/, "", cmd)
199 value = substr(value, RSTART + RLENGTH)
200 while ((cmd | getline line) > 0) {
201 ovalue = ovalue line
202 }
203 close(cmd)
204 }
205 value = ovalue value
206
207 combinedValue = values[variable]
208 if (append == 1 && length(combinedValue) > 0) {
209 combinedValue = combinedValue " " value
210 } else {
211 combinedValue = value
212 }
213 values[variable] = combinedValue
214 }
215 END {
216 for (var in values) {
217 print var "=" values[var]
218 }
219 }
220 '
221 }
222
223 getSingleQMakeVariable()
224 {
225 echo "$2" | $AWK "/^($1)=/ { print substr(\$0, index(\$0, \"=\") + 1) }"
226 }
227
228 macSDKify()
229 {
230 # Normally we take care of sysrootifying in sdk.prf, but configure extracts some
231 # values before qmake is even built, so we have to duplicate the logic here.
232
233 sdk=$(getSingleQMakeVariable "QMAKE_MAC_SDK" "$1")
234 if [ -z "$sdk" ]; then echo "QMAKE_MAC_SDK must be set when building on Mac" >&2; exit 1; fi
235 sysroot=$(/usr/bin/xcrun --sdk $sdk --show-sdk-path 2>/dev/null)
236 if [ -z "$sysroot" ]; then echo "Failed to resolve SDK path for '$sdk'" >&2; exit 1; fi
237
238 case "$sdk" in
239 macosx*)
240 version_min_flag="-mmacosx-version-min=$(getSingleQMakeVariable QMAKE_MACOSX_DEPLOYMENT_TARGET "$1")"
241 ;;
242 iphoneos*)
243 version_min_flag="-miphoneos-version-min=$(getSingleQMakeVariable QMAKE_IOS_DEPLOYMENT_TARGET "$1")"
244 ;;
245 iphonesimulator*)
246 version_min_flag="-mios-simulator-version-min=$(getSingleQMakeVariable QMAKE_IOS_DEPLOYMENT_TARGET "$1")"
247 ;;
248 appletvos*)
249 version_min_flag="-mappletvos-version-min=$(getSingleQMakeVariable QMAKE_TVOS_DEPLOYMENT_TARGET "$1")"
250 ;;
251 appletvsimulator*)
252 version_min_flag="-mtvos-simulator-version-min=$(getSingleQMakeVariable QMAKE_TVOS_DEPLOYMENT_TARGET "$1")"
253 ;;
254 watchos*)
255 version_min_flag="-mwatchos-version-min=$(getSingleQMakeVariable QMAKE_WATCHOS_DEPLOYMENT_TARGET "$1")"
256 ;;
257 watchsimulator*)
258 version_min_flag="-mwatchos-simulator-version-min=$(getSingleQMakeVariable QMAKE_WATCHOS_DEPLOYMENT_TARGET "$1")"
259 ;;
260 *)
261 ;;
262 esac
263
264 echo "$1" | while read line; do
265 case "$line" in
266 QMAKE_CC=*|QMAKE_CXX=*|QMAKE_FIX_RPATH=*|QMAKE_AR=*|QMAKE_RANLIB=*|QMAKE_LINK=*|QMAKE_LINK_SHLIB=*)
267 # Prefix tool with toolchain path
268 var=$(echo "$line" | cut -d '=' -f 1)
269 val=$(echo "$line" | cut -d '=' -f 2-)
270 sdk_val=$(/usr/bin/xcrun -sdk $sdk -find $(echo $val | cut -d ' ' -f 1))
271 val=$(echo $sdk_val $(echo $val | cut -s -d ' ' -f 2-))
272 echo "$var=$val"
273 ;;
274 QMAKE_CFLAGS=*|QMAKE_CXXFLAGS=*|QMAKE_LFLAGS=*)
275 echo "$line -isysroot $sysroot $version_min_flag"
276 ;;
277 *)
278 echo "$line"
279 ;;
280 esac
281 done
282 }
283
284 # relies on $QMAKESPEC being set correctly. parses include statements in
285 # qmake.conf and prints out the expanded file
286 getQMakeConf()
287 {
288 if [ -z "$specvals" ]; then
289 specvals=`expandQMakeConf "$QMAKESPEC/qmake.conf" | extractQMakeVariables`
290 if [ "$BUILD_ON_MAC" = "yes" ]; then specvals=$(macSDKify "$specvals"); fi
291 fi
292 getSingleQMakeVariable "$1" "$specvals"
293 }
294
295 #-------------------------------------------------------------------------------
296 # operating system detection
297 #-------------------------------------------------------------------------------
298
299 # need that throughout the script
300 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
301 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
302 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
303
304 BUILD_ON_MAC=no
305 if [ -d /System/Library/Frameworks/Cocoa.framework ]; then
306 BUILD_ON_MAC=yes
307 fi
308 if [ "$OSTYPE" = "msys" ]; then
309 relpath=`(cd "$relpath"; pwd -W)`
310 outpath=`pwd -W`
311 fi
312
313 #-------------------------------------------------------------------------------
314 # Verify Xcode installation on Mac OS
315 #-------------------------------------------------------------------------------
316
317 if [ "$BUILD_ON_MAC" = "yes" ]; then
318 if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then
319 echo >&2
320 echo " No Xcode selected. Please install Xcode via the App Store, " >&2
321 echo " or the command line developer tools via xcode-select --install, " >&2
322 echo " and use xcode-select --switch to choose the right installation. " >&2
323 echo " See the xcode-select man page for more information." >&2
324 echo >&2
325 exit 2
326 fi
327
328 # In the else case we are probably using a Command Line Tools installation
329 if /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1; then
330 if ! /usr/bin/xcrun xcodebuild -license check 2>/dev/null; then
331 echo >&2
332 echo " Xcode setup not complete. You need to confirm the license" >&2
333 echo " agreement by running 'sudo xcrun xcodebuild -license accept'." >&2
334 echo >&2
335 exit 2
336 fi
337 fi
338 fi
339
340 #-----------------------------------------------------------------------------
341 # Qt version detection
342 #-----------------------------------------------------------------------------
343 QT_VERSION=
344 QT_MAJOR_VERSION=
345 QT_MINOR_VERSION=0
346 QT_PATCH_VERSION=0
347 eval `sed -n -e 's/^MODULE_VERSION = \(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*\)$/QT_VERSION=\1\
348 QT_MAJOR_VERSION=\2\
349 QT_MINOR_VERSION=\3\
350 QT_PATCH_VERSION=\4/p' < "$relpath"/.qmake.conf`
351 if [ -z "$QT_MAJOR_VERSION" ]; then
352 echo "Cannot process version from .qmake.conf"
353 echo "Cannot proceed."
354 exit 1
355 fi
356
357 #-------------------------------------------------------------------------------
358 # initialize variables
359 #-------------------------------------------------------------------------------
360
361 # QTDIR may be set and point to an old or system-wide Qt installation
362 unset QTDIR
363
364 # initalize internal variables
365 CFG_RELEASE_TOOLS=no
366 PLATFORM=
367 OPT_SHADOW=maybe
368 OPT_VERBOSE=no
369 OPT_HELP=
370 CFG_SILENT=no
371 CFG_DEV=no
372
373 #-------------------------------------------------------------------------------
374 # parse command line arguments
375 #-------------------------------------------------------------------------------
376
377 # parse the arguments, setting things to "yes" or "no"
378 while [ "$#" -gt 0 ]; do
379 CURRENT_OPT="$1"
380 case "$1" in
381 #Autoconf style options
382 --enable-*)
383 VAR=`echo $1 | sed 's,^--enable-\(.*\),\1,'`
384 VAL=yes
385 ;;
386 --disable-*)
387 VAR=`echo $1 | sed 's,^--disable-\(.*\),\1,'`
388 VAL=no
389 ;;
390 --*=*)
391 VAR=`echo $1 | sed 's,^--\(.*\)=.*,\1,'`
392 VAL=`echo $1 | sed 's,^--.*=\(.*\),\1,'`
393 ;;
394 --no-*)
395 VAR=`echo $1 | sed 's,^--no-\(.*\),\1,'`
396 VAL=no
397 ;;
398 --*)
399 VAR=`echo $1 | sed 's,^--\(.*\),\1,'`
400 VAL=yes
401 ;;
402 #Qt plugin options
403 -no-*-*|-plugin-*-*|-qt-*-*)
404 VAR=`echo $1 | sed 's,^-[^-]*-\(.*\),\1,'`
405 VAL=`echo $1 | sed 's,^-\([^-]*\).*,\1,'`
406 ;;
407 #Qt style no options
408 -no-*)
409 VAR=`echo $1 | sed 's,^-no-\(.*\),\1,'`
410 VAL=no
411 ;;
412 #Qt style options that pass an argument
413 -prefix| \
414 -docdir| \
415 -headerdir| \
416 -plugindir| \
417 -importdir| \
418 -qmldir| \
419 -archdatadir| \
420 -datadir| \
421 -libdir| \
422 -bindir| \
423 -libexecdir| \
424 -translationdir| \
425 -sysconfdir| \
426 -examplesdir| \
427 -testsdir| \
428 -hostdatadir| \
429 -hostbindir| \
430 -hostlibdir| \
431 -extprefix| \
432 -sysroot| \
433 -external-hostbindir| \
434 -make| \
435 -nomake| \
436 -skip| \
437 -platform| \
438 -xplatform| \
439 -device| \
440 -device-option| \
441 -sdk| \
442 -android-sdk| \
443 -android-ndk| \
444 -android-ndk-platform| \
445 -android-ndk-host| \
446 -android-arch)
447 VAR=`echo $1 | sed 's,^-\(.*\),\1,'`
448 shift
449 VAL="$1"
450 ;;
451 #Qt style complex options in one command
452 -enable-*|-disable-*)
453 VAR=`echo $1 | sed 's,^-\([^-]*\)-.*,\1,'`
454 VAL=`echo $1 | sed 's,^-[^-]*-\(.*\),\1,'`
455 ;;
456 #Qt Builtin/System style options
457 -no-*|-system-*|-qt-*)
458 VAR=`echo $1 | sed 's,^-[^-]*-\(.*\),\1,'`
459 VAL=`echo $1 | sed 's,^-\([^-]*\)-.*,\1,'`
460 ;;
461 #Options that cannot be generalized
462 -hostprefix)
463 VAR=`echo $1 | sed 's,^-\(.*\),\1,'`
464 # this option may or may not be followed by an argument
465 if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
466 VAL=$outpath
467 else
468 shift;
469 VAL=$1
470 fi
471 ;;
472 #General options, including Qt style yes options
473 -*)
474 VAR=`echo $1 | sed 's,^-\(.*\),\1,'`
475 VAL="yes"
476 ;;
477 # Special case for macOS universal builds
478 QMAKE_APPLE_DEVICE_ARCHS=*)
479 QMAKE_APPLE_DEVICE_ARCHS=`echo $1 | sed 's,^QMAKE_APPLE_DEVICE_ARCHS=\(.*\),\1,'`
480 ;;
481 # most options don't need processing in the configure script, skip them. qmake will do the real validation
482 *)
483 shift
484 continue
485 ;;
486 esac
487
488 shift
489
490 UNKNOWN_OPT=no
491 case "$VAR" in
492 external-hostbindir)
493 CFG_HOST_QT_TOOLS_PATH="$VAL"
494 ;;
495 platform)
496 PLATFORM="$VAL"
497 ;;
498 optimized-qmake|optimized-tools)
499 if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
500 CFG_RELEASE_TOOLS="$VAL"
501 fi
502 ;;
503 developer-build)
504 CFG_DEV="yes"
505 ;;
506 h|help)
507 if [ "$VAL" = "yes" ]; then
508 OPT_HELP="$VAL"
509 else
510 UNKNOWN_OPT=yes
511 fi
512 ;;
513 v|verbose)
514 if [ "$VAL" = "yes" ]; then
515 OPT_VERBOSE=yes
516 elif [ "$VAL" = "no" ]; then
517 OPT_VERBOSE=no
518 else
519 UNKNOWN_OPT=yes
520 fi
521 ;;
522 silent)
523 # need to keep this here, to ensure qmake is built silently
524 CFG_SILENT="$VAL"
525 ;;
526 *)
527 ;;
528 esac
529 if [ "$UNKNOWN_OPT" = "yes" ]; then
530 echo "${CURRENT_OPT}: invalid command-line switch"
531 ERROR=yes
532 fi
533 done
534 [ "x$ERROR" = "xyes" ] && exit 1
535
536 #-------------------------------------------------------------------------------
537 # help - interactive parts of the script _after_ this section please
538 #-------------------------------------------------------------------------------
539
540 if [ "$OPT_HELP" = "yes" ]; then
541 cat $relpath/config_help.txt
542 if [ -n "$CFG_TOPLEVEL" ]; then
543 IFS='
544 '
545 for i in $relpathMangled/qt*/config_help.txt; do
546 if [ x"$i" != x"$relpath/config_help.txt" ]; then
547 echo
548 cat "$i"
549 fi
550 done
551 fi
552 exit 0
553 fi
554
555 #-------------------------------------------------------------------------------
556 # platform detection
557 #-------------------------------------------------------------------------------
558
559 PLATFORM_NOTES=
560 if [ -z "$PLATFORM" ]; then
561 case "$UNAME_SYSTEM:$UNAME_RELEASE" in
562 Darwin:*)
563 PLATFORM=macx-clang
564 ;;
565 AIX:*)
566 #PLATFORM=aix-g++
567 PLATFORM=aix-g++-64
568 PLATFORM_NOTES="AIX: aix-g++ aix-g++-64"
569 ;;
570 GNU:*)
571 PLATFORM=hurd-g++
572 ;;
573 FreeBSD:*)
574 if [ "$(uname -r | cut -d. -f1)" -ge 10 ]; then
575 PLATFORM=freebsd-clang
576 PLATFORM_NOTES="FreeBSD: freebsd-g++"
577 else
578 PLATFORM=freebsd-g++
579 PLATFORM_NOTES="FreeBSD: freebsd-clang"
580 fi
581 ;;
582 OpenBSD:*)
583 PLATFORM=openbsd-g++
584 ;;
585 NetBSD:*)
586 PLATFORM=netbsd-g++
587 ;;
588 HP-UX:*)
589 case "$UNAME_MACHINE" in
590 ia64)
591 PLATFORM=hpuxi-g++-64
592 ;;
593 esac
594 ;;
595 Linux:*)
596 PLATFORM=linux-g++
597 PLATFORM_NOTES="Linux: linux-clang linux-icc"
598 ;;
599 SunOS:5*)
600 #PLATFORM=solaris-g++-64
601 PLATFORM=solaris-cc
602 #PLATFORM=solaris-cc64
603 PLATFORM_NOTES="Solaris: solaris-g++-64 solaris-cc-64"
604 ;;
605 CYGWIN*:*)
606 PLATFORM=cygwin-g++
607 ;;
608 LynxOS*:*)
609 PLATFORM=lynxos-g++
610 ;;
611 QNX:*)
612 PLATFORM=unsupported/qnx-g++
613 ;;
614 *)
615 echo >&2
616 echo " The build script does not currently recognize all" >&2
617 echo " platforms supported by Qt." >&2
618 echo " Rerun this script with a -platform option listed to" >&2
619 echo " set the system/compiler combination you use." >&2
620 echo >&2
621 exit 2
622 esac
623 fi
624 echo "$PLATFORM_NOTES" > "${outpathPrefix}.config.notes"
625
626 #-------------------------------------------------------------------------------
627 # command line and environment validation
628 #-------------------------------------------------------------------------------
629
630 if [ -d "$PLATFORM" ]; then
631 QMAKESPEC="$PLATFORM"
632 else
633 QMAKESPEC="$relpath/mkspecs/${PLATFORM}"
634 fi
635
636 if [ "$BUILD_ON_MAC" = "yes" ]; then
637 if [ `basename $QMAKESPEC` = "macx-xcode" ]; then
638 echo >&2
639 echo " Platform 'macx-xcode' should not be used when building Qt/Mac." >&2
640 echo " Please build Qt/Mac with 'macx-clang' or 'macx-g++', then use" >&2
641 echo " the 'macx-xcode' spec for your application, and it will link to" >&2
642 echo " the Qt/Mac build using the settings of the original mkspec." >&2
643 echo >&2
644 exit 2
645 fi
646 fi
647
648 # check specified platforms are supported
649 if [ '!' -d "$QMAKESPEC" ]; then
650 echo
651 echo " The specified system/compiler is not supported:"
652 echo
653 echo " $QMAKESPEC"
654 echo
655 echo " Please see the README file for a complete list."
656 echo
657 exit 2
658 fi
659
660 #-------------------------------------------------------------------------------
661 # build tree initialization
662 #-------------------------------------------------------------------------------
663
664 # is this a shadow build?
665 if [ "$OPT_SHADOW" = "maybe" ]; then
666 OPT_SHADOW=no
667 if [ "$relpath" != "$outpath" ] && [ '!' -f "$outpath/configure" ]; then
668 if [ -h "$outpath" ]; then
669 [ "$relpath" -ef "$outpath" ] || OPT_SHADOW=yes
670 else
671 OPT_SHADOW=yes
672 fi
673 fi
674 fi
675 if [ "$OPT_SHADOW" = "yes" ]; then
676 if [ -f "$relpath/.qmake.cache" -o -f "$relpath/src/corelib/global/qconfig.h" -o -f "$relpath/src/corelib/global/qconfig.cpp" ]; then
677 echo >&2 "You cannot make a shadow build from a source tree containing a previous build."
678 echo >&2 "Cannot proceed."
679 exit 1
680 fi
681 [ "$OPT_VERBOSE" = "yes" ] && echo "Performing shadow build..."
682 fi
683
684 if [ "$OPT_SHADOW" = "yes" ]; then
685 echo "Preparing build tree..."
686
687 [ -d "$outpath/bin" ] || mkdir -p "$outpath/bin"
688
689 mkdir -p "$outpath/mkspecs"
690 fi
691
692 # -----------------------------------------------------------------------------
693 # build qmake
694 # -----------------------------------------------------------------------------
695
696 # symlink includes
697 if [ -e "$relpath/.git" ]; then
698 if [ -z "$PERL" ]; then
699 echo
700 echo "You need perl in your PATH to make a build from GIT."
701 echo "Cannot proceed."
702 exit 1
703 fi
704
705 "$relpath/bin/syncqt.pl" -version $QT_VERSION -minimal -module QtCore "$relpath" || exit 1
706 fi
707
708 # $1: input variable name (awk regexp)
709 # $2: optional output variable name
710 # $3: optional value transformation (sed command)
711 # relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter
712 # is where the resulting variable is written to
713 setBootstrapVariable()
714 {
715 getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
716 }
717
718 # build qmake
719 echo "Creating qmake..."
720 mkdir -p "$outpath/qmake" || exit
721
722 in_mkfile=$relpath/qmake/Makefile.unix
723 mkfile=$outpath/qmake/Makefile
724 if [ -f "$mkfile" ]; then
725 [ "$CFG_DEV" = "yes" ] && "$WHICH" chflags >/dev/null 2>&1 && chflags nouchg "$mkfile"
726 rm -f "$mkfile"
727 fi
728
729 echo "########################################################################" > "$mkfile"
730 echo "## This file was autogenerated by configure, all changes will be lost ##" >> "$mkfile"
731 echo "########################################################################" >> "$mkfile"
732 EXTRA_CXXFLAGS="\$(QMAKE_CXXFLAGS) \$(QMAKE_CXXFLAGS_CXX11) \$(QMAKE_CXXFLAGS_SPLIT_SECTIONS)"
733 EXTRA_LFLAGS="\$(QMAKE_LFLAGS) \$(QMAKE_LFLAGS_GCSECTIONS)"
734
735 [ "$CFG_SILENT" = "yes" ] && CC_TRANSFORM='s,^,\@,' || CC_TRANSFORM=
736 setBootstrapVariable QMAKE_CC CC "$CC_TRANSFORM"
737 setBootstrapVariable QMAKE_CXX CXX "$CC_TRANSFORM"
738 setBootstrapVariable QMAKE_CXXFLAGS
739 setBootstrapVariable QMAKE_CXXFLAGS_CXX11
740 setBootstrapVariable QMAKE_CXXFLAGS_SPLIT_SECTIONS
741 setBootstrapVariable QMAKE_LFLAGS
742 setBootstrapVariable QMAKE_LFLAGS_GCSECTIONS
743
744 if [ "$CFG_DEBUG" = "no" ] || [ "$CFG_RELEASE_TOOLS" = "yes" ]; then
745 setBootstrapVariable QMAKE_CXXFLAGS_RELEASE
746 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_RELEASE)"
747 else
748 setBootstrapVariable QMAKE_CXXFLAGS_DEBUG
749 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_DEBUG)"
750 fi
751
752 adjrelpath=`echo "$relpath" | sed 's/ /\\\\\\\\ /g'`
753 adjoutpath=`echo "$outpath" | sed 's/ /\\\\\\\\ /g'`
754 adjqmakespec=`echo "$QMAKESPEC" | sed 's/ /\\\\\\\\ /g'`
755
756 echo "BUILD_PATH = .." >> "$mkfile"
757 echo "SOURCE_PATH = $adjrelpath" >> "$mkfile"
758 if [ -e "$relpath/.git" ]; then
759 echo 'INC_PATH = $(BUILD_PATH)/include' >> "$mkfile"
760 else
761 echo 'INC_PATH = $(SOURCE_PATH)/include' >> "$mkfile"
762 fi
763 echo "QMAKESPEC = $adjqmakespec" >> "$mkfile"
764 echo "QT_VERSION = $QT_VERSION" >> "$mkfile"
765 echo "QT_MAJOR_VERSION = $QT_MAJOR_VERSION" >> "$mkfile"
766 echo "QT_MINOR_VERSION = $QT_MINOR_VERSION" >> "$mkfile"
767 echo "QT_PATCH_VERSION = $QT_PATCH_VERSION" >> "$mkfile"
768 echo "CONFIG_CXXFLAGS = $EXTRA_CXXFLAGS" >> "$mkfile"
769 echo "CONFIG_LFLAGS = $EXTRA_LFLAGS" >> "$mkfile"
770 echo "RM_F = rm -f" >> "$mkfile"
771 echo "RM_RF = rm -rf" >> "$mkfile"
772
773 case `basename "$PLATFORM"` in
774 win32-*g++*)
775 cat "$in_mkfile.win32" >> "$mkfile"
776 ;;
777 *)
778 cat "$in_mkfile.unix" >> "$mkfile"
779 if [ "$BUILD_ON_MAC" = "yes" ]; then
780 cat "$in_mkfile.macos" >> "$mkfile"
781 fi
782 ;;
783 esac
784 echo >>"$mkfile"
785
786 if [ "$BUILD_ON_MAC" = "yes" ]; then
787 echo "EXTRA_CXXFLAGS += -MMD" >> "$mkfile"
788 for arch in $QMAKE_APPLE_DEVICE_ARCHS; do
789 echo "EXTRA_CXXFLAGS += -arch $arch" >> "$mkfile"
790 echo "EXTRA_LFLAGS += -arch $arch" >> "$mkfile"
791 done
792 cat "$in_mkfile" >> "$mkfile"
793 echo "-include \$(notdir \$(DEPEND_SRC:%.cpp=%.d))" >> "$mkfile"
794 else
795 cat "$in_mkfile" >> "$mkfile"
796 if "$WHICH" makedepend >/dev/null 2>&1 && grep 'depend:' "$mkfile" >/dev/null 2>&1; then
797 (cd "$outpath/qmake" && "$MAKE" -f "$mkfile" depend) >/dev/null 2>&1
798 sed 's,^.*/\([^/]*.o\):,\1:,g' "$mkfile" >"$mkfile.tmp"
799 sed "s,$outpath,$adjoutpath,g" "$mkfile.tmp" >"$mkfile"
800 rm "$mkfile.tmp"
801 fi
802 fi
803
804 if [ "$OPT_VERBOSE" = yes ]; then
805 # Show the output of make
806 (cd "$outpath/qmake"; "$MAKE") || exit 2
807 else
808 # Hide the output of make
809 # Use bash to print dots, if we have it, and stdout is a tty.
810 if test -t 1 && $WHICH bash > /dev/null 2>/dev/null; then
811 bash -c 'set -o pipefail
812 cd "$0/qmake"; "$1" | while read line; do
813 builtin echo -n .
814 done' "$outpath" "$MAKE" || exit 2
815 else
816 (cd "$outpath/qmake"; "$MAKE" -s) || exit 2
817 fi
818 echo "Done."
819 fi
820
821 #-------------------------------------------------------------------------------
822 # create a qt.conf for the Qt build tree itself
823 #-------------------------------------------------------------------------------
824
825 # Note that this file is just sufficient to boot configure, by which it is
826 # replaced in-place with a version which is suitable for building all of Qt.
827 QTCONFFILE="$outpath/bin/qt.conf"
828 cat > "$QTCONFFILE" <<EOF
829 [EffectivePaths]
830 Prefix=..
831 [Paths]
832 TargetSpec=dummy
833 HostSpec=$PLATFORM
834 EOF
835 if [ x"$relpath" != x"$outpath" ]; then
836 cat >> "$QTCONFFILE" <<EOF
837 [EffectiveSourcePaths]
838 Prefix=$relpath
839 EOF
840 fi
841
842 #-------------------------------------------------------------------------------
843 # configure and build top-level makefile
844 #-------------------------------------------------------------------------------
845
846 # recreate command line for qmake
847 set -f
848 SAVED_IFS=$IFS
849 IFS='
850 '
851 for i in $QMAKE_CMDLINE; do
852 set -- "$@" "$i"
853 done
854 set +f
855 IFS=$SAVED_IFS
856
857 if [ -n "$CFG_TOPLEVEL" ]; then
858 cd ..
859 fi
860
861 if [ -n "$CFG_HOST_QT_TOOLS_PATH" ]; then
862 "$CFG_HOST_QT_TOOLS_PATH/qmake" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@"
863 else
864 "$outpath/bin/qmake" "$relpathMangled" -- "$@"
865 fi