summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure208
1 files changed, 173 insertions, 35 deletions
diff --git a/configure b/configure
index d350ca5c7f..fe9ceec93f 100755
--- a/configure
+++ b/configure
@@ -42,18 +42,27 @@ outpath=`/bin/pwd`
WHICH="which"
+PERL=
+findPerl()
+{
PERL=`$WHICH perl 2>/dev/null`
+}
# find out which awk we want to use, prefer gawk, then nawk, then regular awk
AWK=
+findAwk()
+{
for e in gawk nawk awk; do
if "$WHICH" $e >/dev/null 2>&1 && ( $e -f /dev/null /dev/null ) >/dev/null 2>&1; then
AWK=$e
break
fi
done
+}
# find a make command
+findMake()
+{
if [ -z "$MAKE" ]; then
MAKE=
for mk in gmake make; do
@@ -70,39 +79,102 @@ if [ -z "$MAKE" ]; then
# export MAKE, we need it later in the config.tests
export MAKE
fi
+}
# make sure qmake is not confused by these. recursion via Makefiles would
# be still affected, so just unsetting them here is not an option.
+checkQMakeEnv()
+{
if [ -n "$QMAKESPEC" ] || [ -n "$XQMAKESPEC" ] || \
[ -n "$QMAKEPATH" ] || [ -n "$QMAKEFEATURES" ]; then
echo >&2 "Please make sure to unset the QMAKESPEC, XQMAKESPEC, QMAKEPATH,"
echo >&2 "and QMAKEFEATURES environment variables prior to building Qt."
exit 1
fi
+}
# do this early so we don't store it in config.status
CFG_TOPLEVEL=
-relpathMangled=$relpath
outpathPrefix=
-if [ x"$1" = x"-top-level" ]; then
- CFG_TOPLEVEL=yes
- relpathMangled=`dirname "$relpath"`
- outpathPrefix=../
- shift
-else
- if [ -f ../.qmake.super ]; then
- echo >&2 "ERROR: You cannot configure qtbase separately within a top-level build."
- exit 1
+
+checkTopLevelBuild()
+{
+ relpathMangled=$relpath
+ if [ x"$1" = x"-top-level" ]; then
+ CFG_TOPLEVEL=yes
+ relpathMangled=`dirname "$relpath"`
+ outpathPrefix=../
+ else
+ if [ -f ../.qmake.super ]; then
+ echo >&2 "ERROR: You cannot configure qtbase separately within a top-level build."
+ exit 1
+ fi
fi
+}
+
+CMAKE_CMDLINE=
+getCMakeCmdLine()
+{
+PASSTHRU=
+set -f # suppress globbing in for loop
+SAVED_IFS=$IFS
+IFS='
+'
+
+if [ "$CFG_DEV" = "yes" ]; then
+ CMAKE_CMDLINE="$CMAKE_CMDLINE
+-DFEATURE_developer_build=ON"
+ CMAKE_CMDLINE="$CMAKE_CMDLINE
+-DBUILD_TESTING=ON"
+ CMAKE_CMDLINE="$CMAKE_CMDLINE
+-DBUILD_EXAMPLES=ON"
+fi
+
+if [ "$CMAKE_MAKEFILES" = "no" ]; then
+ CMAKE_CMDLINE="$CMAKE_CMDLINE
+-G Ninja"
fi
+for i in "$@"; do
+ if [ "$PASSTHRU" = "yes" ]; then
+ CMAKE_CMDLINE="$CMAKE_CMDLINE
+$i"
+ else
+ case $i in
+ --no-*)
+ VAR=`echo $i | sed 's,^--no-\(.*\),\1,'`
+ CMAKE_CMDLINE="$CMAKE_CMDLINE
+-DFEATURE_${VAR}=OFF"
+ ;;
+ -no-*)
+ VAR=`echo $i | sed 's,^-no-\(.*\),\1,'`
+ CMAKE_CMDLINE="$CMAKE_CMDLINE
+-DFEATURE_${VAR}=OFF"
+ ;;
+ --)
+ PASSTHRU=yes
+ ;;
+ *)
+ ;;
+ esac
+ fi
+done
+set +f
+IFS=$SAVED_IFS
+}
+
OPT_CMDLINE= # expanded version for the script
QMAKE_CMDLINE= # verbatim version for qmake call
+getOptAndQMakeCmdLines()
+{
set -f # suppress globbing in for loop
SAVED_IFS=$IFS
IFS='
'
for i in "$@"; do
+ if [ x"$i" = x"-top-level" ]; then
+ continue
+ fi
case $i in
-redo|--redo)
optfile=${outpathPrefix}config.opt
@@ -132,6 +204,7 @@ for i in $OPT_CMDLINE; do
done
set +f
IFS=$SAVED_IFS
+}
#-------------------------------------------------------------------------------
# utility functions
@@ -298,7 +371,8 @@ getQMakeConf()
#-------------------------------------------------------------------------------
# operating system detection
#-------------------------------------------------------------------------------
-
+detectOperatingSystem()
+{
# need that throughout the script
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
@@ -312,11 +386,12 @@ if [ "$OSTYPE" = "msys" ]; then
relpath=`(cd "$relpath"; pwd -W)`
outpath=`pwd -W`
fi
-
+}
#-------------------------------------------------------------------------------
# Verify Xcode installation on Mac OS
#-------------------------------------------------------------------------------
-
+maybeVerifyXcode()
+{
if [ "$BUILD_ON_MAC" = "yes" ]; then
if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then
echo >&2
@@ -339,7 +414,7 @@ if [ "$BUILD_ON_MAC" = "yes" ]; then
fi
fi
fi
-
+}
#-----------------------------------------------------------------------------
# Qt version detection
#-----------------------------------------------------------------------------
@@ -347,6 +422,8 @@ QT_VERSION=
QT_MAJOR_VERSION=
QT_MINOR_VERSION=0
QT_PATCH_VERSION=0
+detectQtVersion()
+{
eval `sed -n -e 's/^MODULE_VERSION = \(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*\)$/QT_VERSION=\1\
QT_MAJOR_VERSION=\2\
QT_MINOR_VERSION=\3\
@@ -356,7 +433,7 @@ if [ -z "$QT_MAJOR_VERSION" ]; then
echo "Cannot proceed."
exit 1
fi
-
+}
#-------------------------------------------------------------------------------
# initialize variables
#-------------------------------------------------------------------------------
@@ -372,11 +449,14 @@ OPT_VERBOSE=no
OPT_HELP=
CFG_SILENT=no
CFG_DEV=no
+BUILD_WITH_CMAKE=no
+CMAKE_MAKEFILES=no
#-------------------------------------------------------------------------------
# parse command line arguments
#-------------------------------------------------------------------------------
-
+parseCommandline()
+{
# parse the arguments, setting things to "yes" or "no"
while [ "$#" -gt 0 ]; do
CURRENT_OPT="$1"
@@ -522,6 +602,13 @@ while [ "$#" -gt 0 ]; do
# need to keep this here, to ensure qmake is built silently
CFG_SILENT="$VAL"
;;
+ cmake)
+ BUILD_WITH_CMAKE=yes
+ ;;
+ cmake-makefiles)
+ BUILD_WITH_CMAKE=yes
+ CMAKE_MAKEFILES=yes
+ ;;
*)
;;
esac
@@ -531,11 +618,12 @@ while [ "$#" -gt 0 ]; do
fi
done
[ "x$ERROR" = "xyes" ] && exit 1
-
+}
#-------------------------------------------------------------------------------
# help - interactive parts of the script _after_ this section please
#-------------------------------------------------------------------------------
-
+handleHelp()
+{
if [ "$OPT_HELP" = "yes" ]; then
cat $relpath/config_help.txt
if [ -n "$CFG_TOPLEVEL" ]; then
@@ -550,12 +638,13 @@ if [ "$OPT_HELP" = "yes" ]; then
fi
exit 0
fi
-
+}
#-------------------------------------------------------------------------------
# platform detection
#-------------------------------------------------------------------------------
-
PLATFORM_NOTES=
+detectPlatform()
+{
if [ -z "$PLATFORM" ]; then
case "$UNAME_SYSTEM:$UNAME_RELEASE" in
Darwin:*)
@@ -621,11 +710,13 @@ if [ -z "$PLATFORM" ]; then
esac
fi
echo "$PLATFORM_NOTES" > "${outpathPrefix}.config.notes"
+}
#-------------------------------------------------------------------------------
# command line and environment validation
#-------------------------------------------------------------------------------
-
+validateEnv()
+{
if [ -d "$PLATFORM" ]; then
QMAKESPEC="$PLATFORM"
else
@@ -655,11 +746,12 @@ if [ '!' -d "$QMAKESPEC" ]; then
echo
exit 2
fi
-
+}
#-------------------------------------------------------------------------------
# build tree initialization
#-------------------------------------------------------------------------------
-
+initBuildTree()
+{
# is this a shadow build?
if [ "$OPT_SHADOW" = "maybe" ]; then
OPT_SHADOW=no
@@ -687,11 +779,24 @@ if [ "$OPT_SHADOW" = "yes" ]; then
mkdir -p "$outpath/mkspecs"
fi
+}
+
+# $1: input variable name (awk regexp)
+# $2: optional output variable name
+# $3: optional value transformation (sed command)
+# relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter
+# is where the resulting variable is written to
+setBootstrapVariable()
+{
+ getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
+}
# -----------------------------------------------------------------------------
# build qmake
# -----------------------------------------------------------------------------
+buildQMake()
+{
# symlink includes
if [ -e "$relpath/.git" ]; then
if [ -z "$PERL" ]; then
@@ -703,17 +808,6 @@ if [ -e "$relpath/.git" ]; then
"$relpath/bin/syncqt.pl" -version $QT_VERSION -minimal -module QtCore "$relpath" || exit 1
fi
-
-# $1: input variable name (awk regexp)
-# $2: optional output variable name
-# $3: optional value transformation (sed command)
-# relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter
-# is where the resulting variable is written to
-setBootstrapVariable()
-{
- getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
-}
-
# build qmake
echo "Creating qmake..."
mkdir -p "$outpath/qmake" || exit
@@ -812,11 +906,14 @@ setBootstrapVariable()
fi
echo "Done."
fi
+}
#-------------------------------------------------------------------------------
# create a qt.conf for the Qt build tree itself
#-------------------------------------------------------------------------------
+createQtConf()
+{
# Note that this file is just sufficient to boot configure, by which it is
# replaced in-place with a version which is suitable for building all of Qt.
QTCONFFILE="$outpath/bin/qt.conf"
@@ -833,11 +930,13 @@ if [ x"$relpath" != x"$outpath" ]; then
Prefix=$relpath
EOF
fi
+}
#-------------------------------------------------------------------------------
# configure and build top-level makefile
#-------------------------------------------------------------------------------
-
+createToplevelMakefile()
+{
# recreate command line for qmake
set -f
SAVED_IFS=$IFS
@@ -858,3 +957,42 @@ if [ -n "$CFG_HOST_QT_TOOLS_PATH" ]; then
else
"$outpath/bin/qmake" "$relpathMangled" -- "$@"
fi
+}
+
+runCMake()
+{
+# recreate command line for cmake
+set -f
+SAVED_IFS=$IFS
+IFS='
+'
+for i in $CMAKE_CMDLINE; do
+ set -- $* "$i"
+done
+set +f
+IFS=$SAVED_IFS
+cmake $* "$relpath"
+}
+
+parseCommandline "$@"
+handleHelp
+if [ "$BUILD_WITH_CMAKE" = "yes" ]; then
+ getCMakeCmdLine $@
+ runCMake
+else
+ findPerl
+ findAwk
+ findMake
+ checkQMakeEnv
+ checkTopLevelBuild "$@"
+ getOptAndQMakeCmdLines "$@"
+ detectOperatingSystem
+ maybeVerifyXcode
+ detectQtVersion
+ detectPlatform
+ validateEnv
+ initBuildTree
+ buildQMake
+ createQtConf
+ createToplevelMakefile
+fi