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 36relconf=`basename $0` 37# the directory of this script is the "source tree" 38relpath=`dirname $0` 39relpath=`(cd "$relpath"; /bin/pwd)` 40# the current directory is the "build tree" or "object tree" 41outpath=`/bin/pwd` 42 43WHICH="which" 44 45PERL=`$WHICH perl 2>/dev/null` 46 47# find out which awk we want to use, prefer gawk, then nawk, then regular awk 48AWK= 49for 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 54done 55 56# find a make command 57if [ -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 72fi 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. 76if [ -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 81fi 82 83# do this early so we don't store it in config.status 84CFG_TOPLEVEL= 85relpathMangled=$relpath 86outpathPrefix= 87if [ x"$1" = x"-top-level" ]; then 88 CFG_TOPLEVEL=yes 89 relpathMangled=`dirname "$relpath"` 90 outpathPrefix=../ 91 shift 92else 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 97fi 98 99OPT_CMDLINE= # expanded version for the script 100QMAKE_CMDLINE= # verbatim version for qmake call 101set -f # suppress globbing in for loop 102SAVED_IFS=$IFS 103IFS=' 104' 105for 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" 128done 129set -- 130for i in $OPT_CMDLINE; do 131 set -- "$@" "$i" 132done 133set +f 134IFS=$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 142expandQMakeConf() 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 161extractQMakeVariables() 162{ 163 LC_ALL=C $AWK ' 164BEGIN { 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} 215END { 216 for (var in values) { 217 print var "=" values[var] 218 } 219} 220' 221} 222 223getSingleQMakeVariable() 224{ 225 echo "$2" | $AWK "/^($1)=/ { print substr(\$0, index(\$0, \"=\") + 1) }" 226} 227 228macSDKify() 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 286getQMakeConf() 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 300UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown 301UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown 302UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown 303 304BUILD_ON_MAC=no 305if [ -d /System/Library/Frameworks/Cocoa.framework ]; then 306 BUILD_ON_MAC=yes 307fi 308if [ "$OSTYPE" = "msys" ]; then 309 relpath=`(cd "$relpath"; pwd -W)` 310 outpath=`pwd -W` 311fi 312 313#------------------------------------------------------------------------------- 314# Verify Xcode installation on Mac OS 315#------------------------------------------------------------------------------- 316 317if [ "$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 338fi 339 340#----------------------------------------------------------------------------- 341# Qt version detection 342#----------------------------------------------------------------------------- 343QT_VERSION= 344QT_MAJOR_VERSION= 345QT_MINOR_VERSION=0 346QT_PATCH_VERSION=0 347eval `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` 351if [ -z "$QT_MAJOR_VERSION" ]; then 352 echo "Cannot process version from .qmake.conf" 353 echo "Cannot proceed." 354 exit 1 355fi 356 357#------------------------------------------------------------------------------- 358# initialize variables 359#------------------------------------------------------------------------------- 360 361# QTDIR may be set and point to an old or system-wide Qt installation 362unset QTDIR 363 364# initalize internal variables 365CFG_RELEASE_TOOLS=no 366PLATFORM= 367OPT_SHADOW=maybe 368OPT_VERBOSE=no 369OPT_HELP= 370CFG_SILENT=no 371CFG_DEV=no 372 373#------------------------------------------------------------------------------- 374# parse command line arguments 375#------------------------------------------------------------------------------- 376 377# parse the arguments, setting things to "yes" or "no" 378while [ "$#" -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 # most options don't need processing in the configure script, skip them. qmake will do the real validation 478 *) 479 shift 480 continue 481 ;; 482 esac 483 484 shift 485 486 UNKNOWN_OPT=no 487 case "$VAR" in 488 external-hostbindir) 489 CFG_HOST_QT_TOOLS_PATH="$VAL" 490 ;; 491 platform) 492 PLATFORM="$VAL" 493 ;; 494 optimized-qmake|optimized-tools) 495 if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then 496 CFG_RELEASE_TOOLS="$VAL" 497 fi 498 ;; 499 developer-build) 500 CFG_DEV="yes" 501 ;; 502 h|help) 503 if [ "$VAL" = "yes" ]; then 504 OPT_HELP="$VAL" 505 else 506 UNKNOWN_OPT=yes 507 fi 508 ;; 509 v|verbose) 510 if [ "$VAL" = "yes" ]; then 511 OPT_VERBOSE=yes 512 elif [ "$VAL" = "no" ]; then 513 OPT_VERBOSE=no 514 else 515 UNKNOWN_OPT=yes 516 fi 517 ;; 518 silent) 519 # need to keep this here, to ensure qmake is built silently 520 CFG_SILENT="$VAL" 521 ;; 522 *) 523 ;; 524 esac 525 if [ "$UNKNOWN_OPT" = "yes" ]; then 526 echo "${CURRENT_OPT}: invalid command-line switch" 527 ERROR=yes 528 fi 529done 530[ "x$ERROR" = "xyes" ] && exit 1 531 532#------------------------------------------------------------------------------- 533# help - interactive parts of the script _after_ this section please 534#------------------------------------------------------------------------------- 535 536if [ "$OPT_HELP" = "yes" ]; then 537 cat $relpath/config_help.txt 538 if [ -n "$CFG_TOPLEVEL" ]; then 539 IFS=' 540' 541 for i in $relpathMangled/qt*/config_help.txt; do 542 if [ x"$i" != x"$relpath/config_help.txt" ]; then 543 echo 544 cat "$i" 545 fi 546 done 547 fi 548 exit 0 549fi 550 551#------------------------------------------------------------------------------- 552# platform detection 553#------------------------------------------------------------------------------- 554 555PLATFORM_NOTES= 556if [ -z "$PLATFORM" ]; then 557 case "$UNAME_SYSTEM:$UNAME_RELEASE" in 558 Darwin:*) 559 PLATFORM=macx-clang 560 ;; 561 AIX:*) 562 #PLATFORM=aix-g++ 563 PLATFORM=aix-g++-64 564 PLATFORM_NOTES="AIX: aix-g++ aix-g++-64" 565 ;; 566 GNU:*) 567 PLATFORM=hurd-g++ 568 ;; 569 FreeBSD:*) 570 if [ "$(uname -r | cut -d. -f1)" -ge 10 ]; then 571 PLATFORM=freebsd-clang 572 PLATFORM_NOTES="FreeBSD: freebsd-g++" 573 else 574 PLATFORM=freebsd-g++ 575 PLATFORM_NOTES="FreeBSD: freebsd-clang" 576 fi 577 ;; 578 OpenBSD:*) 579 PLATFORM=openbsd-g++ 580 ;; 581 NetBSD:*) 582 PLATFORM=netbsd-g++ 583 ;; 584 HP-UX:*) 585 case "$UNAME_MACHINE" in 586 ia64) 587 PLATFORM=hpuxi-g++-64 588 ;; 589 esac 590 ;; 591 Linux:*) 592 PLATFORM=linux-g++ 593 PLATFORM_NOTES="Linux: linux-clang linux-icc" 594 ;; 595 SunOS:5*) 596 #PLATFORM=solaris-g++-64 597 PLATFORM=solaris-cc 598 #PLATFORM=solaris-cc64 599 PLATFORM_NOTES="Solaris: solaris-g++-64 solaris-cc-64" 600 ;; 601 CYGWIN*:*) 602 PLATFORM=cygwin-g++ 603 ;; 604 LynxOS*:*) 605 PLATFORM=lynxos-g++ 606 ;; 607 QNX:*) 608 PLATFORM=unsupported/qnx-g++ 609 ;; 610 *) 611 echo >&2 612 echo " The build script does not currently recognize all" >&2 613 echo " platforms supported by Qt." >&2 614 echo " Rerun this script with a -platform option listed to" >&2 615 echo " set the system/compiler combination you use." >&2 616 echo >&2 617 exit 2 618 esac 619fi 620echo "$PLATFORM_NOTES" > "${outpathPrefix}.config.notes" 621 622#------------------------------------------------------------------------------- 623# command line and environment validation 624#------------------------------------------------------------------------------- 625 626if [ -d "$PLATFORM" ]; then 627 QMAKESPEC="$PLATFORM" 628else 629 QMAKESPEC="$relpath/mkspecs/${PLATFORM}" 630fi 631 632if [ "$BUILD_ON_MAC" = "yes" ]; then 633 if [ `basename $QMAKESPEC` = "macx-xcode" ]; then 634 echo >&2 635 echo " Platform 'macx-xcode' should not be used when building Qt/Mac." >&2 636 echo " Please build Qt/Mac with 'macx-clang' or 'macx-g++', then use" >&2 637 echo " the 'macx-xcode' spec for your application, and it will link to" >&2 638 echo " the Qt/Mac build using the settings of the original mkspec." >&2 639 echo >&2 640 exit 2 641 fi 642fi 643 644# check specified platforms are supported 645if [ '!' -d "$QMAKESPEC" ]; then 646 echo 647 echo " The specified system/compiler is not supported:" 648 echo 649 echo " $QMAKESPEC" 650 echo 651 echo " Please see the README file for a complete list." 652 echo 653 exit 2 654fi 655 656#------------------------------------------------------------------------------- 657# build tree initialization 658#------------------------------------------------------------------------------- 659 660# is this a shadow build? 661if [ "$OPT_SHADOW" = "maybe" ]; then 662 OPT_SHADOW=no 663 if [ "$relpath" != "$outpath" ] && [ '!' -f "$outpath/configure" ]; then 664 if [ -h "$outpath" ]; then 665 [ "$relpath" -ef "$outpath" ] || OPT_SHADOW=yes 666 else 667 OPT_SHADOW=yes 668 fi 669 fi 670fi 671if [ "$OPT_SHADOW" = "yes" ]; then 672 if [ -f "$relpath/.qmake.cache" -o -f "$relpath/src/corelib/global/qconfig.h" -o -f "$relpath/src/corelib/global/qconfig.cpp" ]; then 673 echo >&2 "You cannot make a shadow build from a source tree containing a previous build." 674 echo >&2 "Cannot proceed." 675 exit 1 676 fi 677 [ "$OPT_VERBOSE" = "yes" ] && echo "Performing shadow build..." 678fi 679 680if [ "$OPT_SHADOW" = "yes" ]; then 681 echo "Preparing build tree..." 682 683 [ -d "$outpath/bin" ] || mkdir -p "$outpath/bin" 684 685 mkdir -p "$outpath/mkspecs" 686fi 687 688# ----------------------------------------------------------------------------- 689# build qmake 690# ----------------------------------------------------------------------------- 691 692# symlink includes 693if [ -e "$relpath/.git" ]; then 694 if [ -z "$PERL" ]; then 695 echo 696 echo "You need perl in your PATH to make a build from GIT." 697 echo "Cannot proceed." 698 exit 1 699 fi 700 701 "$relpath/bin/syncqt.pl" -version $QT_VERSION -minimal -module QtCore "$relpath" || exit 1 702fi 703 704# $1: input variable name (awk regexp) 705# $2: optional output variable name 706# $3: optional value transformation (sed command) 707# relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter 708# is where the resulting variable is written to 709setBootstrapVariable() 710{ 711 getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile" 712} 713 714# build qmake 715if [ '!' -f "$outpath/bin/qmake" ] ; then 716 echo "Creating qmake..." 717 mkdir -p "$outpath/qmake" || exit 718 719 in_mkfile=$relpath/qmake/Makefile.unix 720 mkfile=$outpath/qmake/Makefile 721 if [ -f "$mkfile" ]; then 722 [ "$CFG_DEV" = "yes" ] && "$WHICH" chflags >/dev/null 2>&1 && chflags nouchg "$mkfile" 723 rm -f "$mkfile" 724 fi 725 726 echo "########################################################################" > "$mkfile" 727 echo "## This file was autogenerated by configure, all changes will be lost ##" >> "$mkfile" 728 echo "########################################################################" >> "$mkfile" 729 EXTRA_CXXFLAGS="\$(QMAKE_CXXFLAGS) \$(QMAKE_CXXFLAGS_CXX11) \$(QMAKE_CXXFLAGS_SPLIT_SECTIONS)" 730 EXTRA_LFLAGS="\$(QMAKE_LFLAGS) \$(QMAKE_LFLAGS_GCSECTIONS)" 731 732 [ "$CFG_SILENT" = "yes" ] && CC_TRANSFORM='s,^,\@,' || CC_TRANSFORM= 733 setBootstrapVariable QMAKE_CC CC "$CC_TRANSFORM" 734 setBootstrapVariable QMAKE_CXX CXX "$CC_TRANSFORM" 735 setBootstrapVariable QMAKE_CXXFLAGS 736 setBootstrapVariable QMAKE_CXXFLAGS_CXX11 737 setBootstrapVariable QMAKE_CXXFLAGS_SPLIT_SECTIONS 738 setBootstrapVariable QMAKE_LFLAGS 739 setBootstrapVariable QMAKE_LFLAGS_GCSECTIONS 740 741 if [ "$CFG_DEBUG" = "no" ] || [ "$CFG_RELEASE_TOOLS" = "yes" ]; then 742 setBootstrapVariable QMAKE_CXXFLAGS_RELEASE 743 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_RELEASE)" 744 else 745 setBootstrapVariable QMAKE_CXXFLAGS_DEBUG 746 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_DEBUG)" 747 fi 748 749 adjrelpath=`echo "$relpath" | sed 's/ /\\\\\\\\ /g'` 750 adjoutpath=`echo "$outpath" | sed 's/ /\\\\\\\\ /g'` 751 adjqmakespec=`echo "$QMAKESPEC" | sed 's/ /\\\\\\\\ /g'` 752 753 echo "BUILD_PATH = .." >> "$mkfile" 754 echo "SOURCE_PATH = $adjrelpath" >> "$mkfile" 755 if [ -e "$relpath/.git" ]; then 756 echo 'INC_PATH = $(BUILD_PATH)/include' >> "$mkfile" 757 else 758 echo 'INC_PATH = $(SOURCE_PATH)/include' >> "$mkfile" 759 fi 760 echo "QMAKESPEC = $adjqmakespec" >> "$mkfile" 761 echo "QT_VERSION = $QT_VERSION" >> "$mkfile" 762 echo "QT_MAJOR_VERSION = $QT_MAJOR_VERSION" >> "$mkfile" 763 echo "QT_MINOR_VERSION = $QT_MINOR_VERSION" >> "$mkfile" 764 echo "QT_PATCH_VERSION = $QT_PATCH_VERSION" >> "$mkfile" 765 echo "CONFIG_CXXFLAGS = $EXTRA_CXXFLAGS" >> "$mkfile" 766 echo "CONFIG_LFLAGS = $EXTRA_LFLAGS" >> "$mkfile" 767 echo "RM_F = rm -f" >> "$mkfile" 768 echo "RM_RF = rm -rf" >> "$mkfile" 769 770 case `basename "$PLATFORM"` in 771 win32-*g++*) 772 cat "$in_mkfile.win32" >> "$mkfile" 773 ;; 774 *) 775 cat "$in_mkfile.unix" >> "$mkfile" 776 if [ "$BUILD_ON_MAC" = "yes" ]; then 777 cat "$in_mkfile.macos" >> "$mkfile" 778 fi 779 ;; 780 esac 781 echo >>"$mkfile" 782 783 if [ "$BUILD_ON_MAC" = "yes" ]; then 784 echo "EXTRA_CXXFLAGS += -MMD" >> "$mkfile" 785 cat "$in_mkfile" >> "$mkfile" 786 echo "-include \$(notdir \$(DEPEND_SRC:%.cpp=%.d))" >> "$mkfile" 787 else 788 cat "$in_mkfile" >> "$mkfile" 789 if "$WHICH" makedepend >/dev/null 2>&1 && grep 'depend:' "$mkfile" >/dev/null 2>&1; then 790 (cd "$outpath/qmake" && "$MAKE" -f "$mkfile" depend) >/dev/null 2>&1 791 sed 's,^.*/\([^/]*.o\):,\1:,g' "$mkfile" >"$mkfile.tmp" 792 sed "s,$outpath,$adjoutpath,g" "$mkfile.tmp" >"$mkfile" 793 rm "$mkfile.tmp" 794 fi 795 fi 796 797 if [ "$OPT_VERBOSE" = yes ]; then 798 # Show the output of make 799 (cd "$outpath/qmake"; "$MAKE") || exit 2 800 else 801 # Hide the output of make 802 # Use bash to print dots, if we have it, and stdout is a tty. 803 if test -t 1 && $WHICH bash > /dev/null 2>/dev/null; then 804 bash -c 'set -o pipefail 805 cd "$0/qmake"; "$1" | while read line; do 806 builtin echo -n . 807 done' "$outpath" "$MAKE" || exit 2 808 else 809 (cd "$outpath/qmake"; "$MAKE" -s) || exit 2 810 fi 811 echo "Done." 812 fi 813fi # Creating qmake 814 815#------------------------------------------------------------------------------- 816# create a qt.conf for the Qt build tree itself 817#------------------------------------------------------------------------------- 818 819# Note that this file is just sufficient to boot configure, by which it is 820# replaced in-place with a version which is suitable for building all of Qt. 821QTCONFFILE="$outpath/bin/qt.conf" 822cat > "$QTCONFFILE" <<EOF 823[EffectivePaths] 824Prefix=.. 825[Paths] 826TargetSpec=dummy 827HostSpec=$PLATFORM 828EOF 829if [ x"$relpath" != x"$outpath" ]; then 830 cat >> "$QTCONFFILE" <<EOF 831[EffectiveSourcePaths] 832Prefix=$relpath 833EOF 834fi 835 836#------------------------------------------------------------------------------- 837# configure and build top-level makefile 838#------------------------------------------------------------------------------- 839 840# recreate command line for qmake 841set -f 842SAVED_IFS=$IFS 843IFS=' 844' 845for i in $QMAKE_CMDLINE; do 846 set -- "$@" "$i" 847done 848set +f 849IFS=$SAVED_IFS 850 851if [ -n "$CFG_TOPLEVEL" ]; then 852 cd .. 853fi 854 855if [ -n "$CFG_HOST_QT_TOOLS_PATH" ]; then 856 "$CFG_HOST_QT_TOOLS_PATH/qmake" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" 857else 858 "$outpath/bin/qmake" "$relpathMangled" -- "$@" 859fi 860