Teach configure to run either qmake or cmake
Task-number: QTBUG-74139 Change-Id: I609ec4b3ef9f30455bd72aaebad0b6c766c39cd7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
9fade925e3
commit
3a9ffadf69
177
configure
vendored
177
configure
vendored
@ -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,20 +79,26 @@ 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=
|
||||
checkTopLevelBuild()
|
||||
{
|
||||
relpathMangled=$relpath
|
||||
if [ x"$1" = x"-top-level" ]; then
|
||||
CFG_TOPLEVEL=yes
|
||||
relpathMangled=`dirname "$relpath"`
|
||||
@ -95,9 +110,48 @@ else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
CMAKE_CMDLINE=
|
||||
getCMakeCmdLine()
|
||||
{
|
||||
PASSTHRU=
|
||||
set -f # suppress globbing in for loop
|
||||
SAVED_IFS=$IFS
|
||||
IFS='
|
||||
'
|
||||
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='
|
||||
@ -132,6 +186,7 @@ for i in $OPT_CMDLINE; do
|
||||
done
|
||||
set +f
|
||||
IFS=$SAVED_IFS
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# utility functions
|
||||
@ -298,7 +353,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 +368,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 +396,7 @@ if [ "$BUILD_ON_MAC" = "yes" ]; then
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Qt version detection
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -347,6 +404,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 +415,7 @@ if [ -z "$QT_MAJOR_VERSION" ]; then
|
||||
echo "Cannot proceed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
# initalize variables
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -372,11 +431,13 @@ OPT_VERBOSE=no
|
||||
OPT_HELP=
|
||||
CFG_SILENT=no
|
||||
CFG_DEV=no
|
||||
BUILD_WITH_CMAKE=no
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# parse command line arguments
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
parseCommandline()
|
||||
{
|
||||
# parse the arguments, setting things to "yes" or "no"
|
||||
while [ "$#" -gt 0 ]; do
|
||||
CURRENT_OPT="$1"
|
||||
@ -523,6 +584,9 @@ while [ "$#" -gt 0 ]; do
|
||||
# need to keep this here, to ensure qmake is built silently
|
||||
CFG_SILENT="$VAL"
|
||||
;;
|
||||
cmake)
|
||||
BUILD_WITH_CMAKE=yes
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
@ -532,11 +596,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
|
||||
@ -551,12 +616,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:*)
|
||||
@ -622,11 +688,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
|
||||
@ -656,11 +724,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
|
||||
@ -688,22 +757,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then
|
||||
|
||||
mkdir -p "$outpath/mkspecs"
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# build qmake
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# symlink includes
|
||||
if [ -e "$relpath/.git" ]; then
|
||||
if [ -z "$PERL" ]; then
|
||||
echo
|
||||
echo "You need perl in your PATH to make a build from GIT."
|
||||
echo "Cannot proceed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$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
|
||||
@ -715,6 +769,23 @@ 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
|
||||
echo
|
||||
echo "You need perl in your PATH to make a build from GIT."
|
||||
echo "Cannot proceed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$relpath/bin/syncqt.pl" -version $QT_VERSION -minimal -module QtCore "$relpath" || exit 1
|
||||
fi
|
||||
# build qmake
|
||||
echo "Creating qmake..."
|
||||
mkdir -p "$outpath/qmake" || exit
|
||||
@ -813,11 +884,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"
|
||||
@ -834,11 +908,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
|
||||
@ -859,3 +935,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
|
||||
|
Loading…
Reference in New Issue
Block a user