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"
|
WHICH="which"
|
||||||
|
|
||||||
|
PERL=
|
||||||
|
findPerl()
|
||||||
|
{
|
||||||
PERL=`$WHICH perl 2>/dev/null`
|
PERL=`$WHICH perl 2>/dev/null`
|
||||||
|
}
|
||||||
|
|
||||||
# find out which awk we want to use, prefer gawk, then nawk, then regular awk
|
# find out which awk we want to use, prefer gawk, then nawk, then regular awk
|
||||||
AWK=
|
AWK=
|
||||||
|
findAwk()
|
||||||
|
{
|
||||||
for e in gawk nawk awk; do
|
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
|
if "$WHICH" $e >/dev/null 2>&1 && ( $e -f /dev/null /dev/null ) >/dev/null 2>&1; then
|
||||||
AWK=$e
|
AWK=$e
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# find a make command
|
# find a make command
|
||||||
|
findMake()
|
||||||
|
{
|
||||||
if [ -z "$MAKE" ]; then
|
if [ -z "$MAKE" ]; then
|
||||||
MAKE=
|
MAKE=
|
||||||
for mk in gmake make; do
|
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, we need it later in the config.tests
|
||||||
export MAKE
|
export MAKE
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# make sure qmake is not confused by these. recursion via Makefiles would
|
# make sure qmake is not confused by these. recursion via Makefiles would
|
||||||
# be still affected, so just unsetting them here is not an option.
|
# be still affected, so just unsetting them here is not an option.
|
||||||
|
checkQMakeEnv()
|
||||||
|
{
|
||||||
if [ -n "$QMAKESPEC" ] || [ -n "$XQMAKESPEC" ] || \
|
if [ -n "$QMAKESPEC" ] || [ -n "$XQMAKESPEC" ] || \
|
||||||
[ -n "$QMAKEPATH" ] || [ -n "$QMAKEFEATURES" ]; then
|
[ -n "$QMAKEPATH" ] || [ -n "$QMAKEFEATURES" ]; then
|
||||||
echo >&2 "Please make sure to unset the QMAKESPEC, XQMAKESPEC, QMAKEPATH,"
|
echo >&2 "Please make sure to unset the QMAKESPEC, XQMAKESPEC, QMAKEPATH,"
|
||||||
echo >&2 "and QMAKEFEATURES environment variables prior to building Qt."
|
echo >&2 "and QMAKEFEATURES environment variables prior to building Qt."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# do this early so we don't store it in config.status
|
# do this early so we don't store it in config.status
|
||||||
CFG_TOPLEVEL=
|
CFG_TOPLEVEL=
|
||||||
relpathMangled=$relpath
|
|
||||||
outpathPrefix=
|
outpathPrefix=
|
||||||
|
checkTopLevelBuild()
|
||||||
|
{
|
||||||
|
relpathMangled=$relpath
|
||||||
if [ x"$1" = x"-top-level" ]; then
|
if [ x"$1" = x"-top-level" ]; then
|
||||||
CFG_TOPLEVEL=yes
|
CFG_TOPLEVEL=yes
|
||||||
relpathMangled=`dirname "$relpath"`
|
relpathMangled=`dirname "$relpath"`
|
||||||
@ -95,9 +110,48 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
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
|
OPT_CMDLINE= # expanded version for the script
|
||||||
QMAKE_CMDLINE= # verbatim version for qmake call
|
QMAKE_CMDLINE= # verbatim version for qmake call
|
||||||
|
getOptAndQMakeCmdLines()
|
||||||
|
{
|
||||||
set -f # suppress globbing in for loop
|
set -f # suppress globbing in for loop
|
||||||
SAVED_IFS=$IFS
|
SAVED_IFS=$IFS
|
||||||
IFS='
|
IFS='
|
||||||
@ -132,6 +186,7 @@ for i in $OPT_CMDLINE; do
|
|||||||
done
|
done
|
||||||
set +f
|
set +f
|
||||||
IFS=$SAVED_IFS
|
IFS=$SAVED_IFS
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# utility functions
|
# utility functions
|
||||||
@ -298,7 +353,8 @@ getQMakeConf()
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# operating system detection
|
# operating system detection
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
detectOperatingSystem()
|
||||||
|
{
|
||||||
# need that throughout the script
|
# need that throughout the script
|
||||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||||
@ -312,11 +368,12 @@ if [ "$OSTYPE" = "msys" ]; then
|
|||||||
relpath=`(cd "$relpath"; pwd -W)`
|
relpath=`(cd "$relpath"; pwd -W)`
|
||||||
outpath=`pwd -W`
|
outpath=`pwd -W`
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Verify Xcode installation on Mac OS
|
# Verify Xcode installation on Mac OS
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
maybeVerifyXcode()
|
||||||
|
{
|
||||||
if [ "$BUILD_ON_MAC" = "yes" ]; then
|
if [ "$BUILD_ON_MAC" = "yes" ]; then
|
||||||
if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then
|
if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then
|
||||||
echo >&2
|
echo >&2
|
||||||
@ -339,7 +396,7 @@ if [ "$BUILD_ON_MAC" = "yes" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Qt version detection
|
# Qt version detection
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@ -347,6 +404,8 @@ QT_VERSION=
|
|||||||
QT_MAJOR_VERSION=
|
QT_MAJOR_VERSION=
|
||||||
QT_MINOR_VERSION=0
|
QT_MINOR_VERSION=0
|
||||||
QT_PATCH_VERSION=0
|
QT_PATCH_VERSION=0
|
||||||
|
detectQtVersion()
|
||||||
|
{
|
||||||
eval `sed -n -e 's/^MODULE_VERSION = \(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*\)$/QT_VERSION=\1\
|
eval `sed -n -e 's/^MODULE_VERSION = \(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*\)$/QT_VERSION=\1\
|
||||||
QT_MAJOR_VERSION=\2\
|
QT_MAJOR_VERSION=\2\
|
||||||
QT_MINOR_VERSION=\3\
|
QT_MINOR_VERSION=\3\
|
||||||
@ -356,7 +415,7 @@ if [ -z "$QT_MAJOR_VERSION" ]; then
|
|||||||
echo "Cannot proceed."
|
echo "Cannot proceed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# initalize variables
|
# initalize variables
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@ -372,11 +431,13 @@ OPT_VERBOSE=no
|
|||||||
OPT_HELP=
|
OPT_HELP=
|
||||||
CFG_SILENT=no
|
CFG_SILENT=no
|
||||||
CFG_DEV=no
|
CFG_DEV=no
|
||||||
|
BUILD_WITH_CMAKE=no
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
parseCommandline()
|
||||||
|
{
|
||||||
# parse the arguments, setting things to "yes" or "no"
|
# parse the arguments, setting things to "yes" or "no"
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
CURRENT_OPT="$1"
|
CURRENT_OPT="$1"
|
||||||
@ -523,6 +584,9 @@ while [ "$#" -gt 0 ]; do
|
|||||||
# need to keep this here, to ensure qmake is built silently
|
# need to keep this here, to ensure qmake is built silently
|
||||||
CFG_SILENT="$VAL"
|
CFG_SILENT="$VAL"
|
||||||
;;
|
;;
|
||||||
|
cmake)
|
||||||
|
BUILD_WITH_CMAKE=yes
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -532,11 +596,12 @@ while [ "$#" -gt 0 ]; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ "x$ERROR" = "xyes" ] && exit 1
|
[ "x$ERROR" = "xyes" ] && exit 1
|
||||||
|
}
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# help - interactive parts of the script _after_ this section please
|
# help - interactive parts of the script _after_ this section please
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
handleHelp()
|
||||||
|
{
|
||||||
if [ "$OPT_HELP" = "yes" ]; then
|
if [ "$OPT_HELP" = "yes" ]; then
|
||||||
cat $relpath/config_help.txt
|
cat $relpath/config_help.txt
|
||||||
if [ -n "$CFG_TOPLEVEL" ]; then
|
if [ -n "$CFG_TOPLEVEL" ]; then
|
||||||
@ -551,12 +616,13 @@ if [ "$OPT_HELP" = "yes" ]; then
|
|||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# platform detection
|
# platform detection
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
PLATFORM_NOTES=
|
PLATFORM_NOTES=
|
||||||
|
detectPlatform()
|
||||||
|
{
|
||||||
if [ -z "$PLATFORM" ]; then
|
if [ -z "$PLATFORM" ]; then
|
||||||
case "$UNAME_SYSTEM:$UNAME_RELEASE" in
|
case "$UNAME_SYSTEM:$UNAME_RELEASE" in
|
||||||
Darwin:*)
|
Darwin:*)
|
||||||
@ -622,11 +688,13 @@ if [ -z "$PLATFORM" ]; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
echo "$PLATFORM_NOTES" > "${outpathPrefix}.config.notes"
|
echo "$PLATFORM_NOTES" > "${outpathPrefix}.config.notes"
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# command line and environment validation
|
# command line and environment validation
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
validateEnv()
|
||||||
|
{
|
||||||
if [ -d "$PLATFORM" ]; then
|
if [ -d "$PLATFORM" ]; then
|
||||||
QMAKESPEC="$PLATFORM"
|
QMAKESPEC="$PLATFORM"
|
||||||
else
|
else
|
||||||
@ -656,11 +724,12 @@ if [ '!' -d "$QMAKESPEC" ]; then
|
|||||||
echo
|
echo
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# build tree initialization
|
# build tree initialization
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
initBuildTree()
|
||||||
|
{
|
||||||
# is this a shadow build?
|
# is this a shadow build?
|
||||||
if [ "$OPT_SHADOW" = "maybe" ]; then
|
if [ "$OPT_SHADOW" = "maybe" ]; then
|
||||||
OPT_SHADOW=no
|
OPT_SHADOW=no
|
||||||
@ -688,22 +757,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then
|
|||||||
|
|
||||||
mkdir -p "$outpath/mkspecs"
|
mkdir -p "$outpath/mkspecs"
|
||||||
fi
|
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)
|
# $1: input variable name (awk regexp)
|
||||||
# $2: optional output variable name
|
# $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"
|
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
|
# build qmake
|
||||||
echo "Creating qmake..."
|
echo "Creating qmake..."
|
||||||
mkdir -p "$outpath/qmake" || exit
|
mkdir -p "$outpath/qmake" || exit
|
||||||
@ -813,11 +884,14 @@ setBootstrapVariable()
|
|||||||
fi
|
fi
|
||||||
echo "Done."
|
echo "Done."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# create a qt.conf for the Qt build tree itself
|
# 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
|
# 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.
|
# replaced in-place with a version which is suitable for building all of Qt.
|
||||||
QTCONFFILE="$outpath/bin/qt.conf"
|
QTCONFFILE="$outpath/bin/qt.conf"
|
||||||
@ -834,11 +908,13 @@ if [ x"$relpath" != x"$outpath" ]; then
|
|||||||
Prefix=$relpath
|
Prefix=$relpath
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# configure and build top-level makefile
|
# configure and build top-level makefile
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
createToplevelMakefile()
|
||||||
|
{
|
||||||
# recreate command line for qmake
|
# recreate command line for qmake
|
||||||
set -f
|
set -f
|
||||||
SAVED_IFS=$IFS
|
SAVED_IFS=$IFS
|
||||||
@ -859,3 +935,42 @@ if [ -n "$CFG_HOST_QT_TOOLS_PATH" ]; then
|
|||||||
else
|
else
|
||||||
"$outpath/bin/qmake" "$relpathMangled" -- "$@"
|
"$outpath/bin/qmake" "$relpathMangled" -- "$@"
|
||||||
fi
|
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…
x
Reference in New Issue
Block a user