summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-01-31 12:49:53 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-26 10:07:09 +0200
commit68c7f80a672e1d6d2710e49548a7c83b105d8d5f (patch)
tree43b8333c96ec03b3ee0c7932a6a4e9756ae6fb05 /configure
parent3e29d87844e1b6b0360ff05e38993567a85ac445 (diff)
downloadqt4-tools-68c7f80a672e1d6d2710e49548a7c83b105d8d5f.tar.gz
revamp reading of bootstrap variables
make the "evaluator" able to process simple variable expansions. cache the processed spec, so it is not re-read for every variable. (cherry picked from qtbase commit 3cf6521f54175031382672c3331899fe1f98a6c9) (cherry picked from qtbase commit f5a03eec2d0f12917572bfa9cb48b4145768480a) Change-Id: I20e69ec7b65faa7d571e68dbfea6c21c79a62641 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Donald Carr <donald.carr@nokia.com>
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure141
1 files changed, 84 insertions, 57 deletions
diff --git a/configure b/configure
index 257650c7be..c1667b6d6f 100755
--- a/configure
+++ b/configure
@@ -127,16 +127,76 @@ getQMakeConf1()
esac; done < "$1"
}
+getQMakeConf2()
+{
+ $AWK '
+BEGIN {
+ values["LITERAL_WHITESPACE"] = " "
+ values["LITERAL_DOLLAR"] = "$"
+}
+/^[_A-Z0-9.]+[ \t]*\+?=/ {
+ valStart = index($0, "=") + 1
+
+ append = 0
+ if (substr($0, valStart - 2, 1) == "+") {
+ append = 1
+ }
+
+ variable = substr($0, 0, valStart - 2 - append)
+ value = substr($0, valStart)
+ gsub("[ \t]+", "", variable)
+ gsub("^[ \t]+", "", value)
+ gsub("[ \t]+$", "", value)
+
+ ovalue = ""
+ while (match(value, /\$\$(\{[_A-Z0-9.]+\}|[_A-Z0-9.]+)/)) {
+ ovalue = ovalue substr(value, 1, RSTART - 1)
+ var = substr(value, RSTART + 2, RLENGTH - 2)
+ value = substr(value, RSTART + RLENGTH)
+ if (var ~ /^{/) {
+ var = substr(var, 2, length(var) - 2)
+ }
+ ovalue = ovalue values[var]
+ }
+ ovalue = ovalue value
+
+ combinedValue = values[variable]
+ if (append == 1 && length(combinedValue) > 0) {
+ combinedValue = combinedValue " " ovalue
+ } else {
+ combinedValue = ovalue
+ }
+ values[variable] = combinedValue
+}
+END {
+ for (var in values) {
+ print var "=" values[var]
+ }
+}
+'
+}
+
+getQMakeConf3()
+{
+ echo "$2" | $AWK "/^($1)=/ { print substr(\$0, index(\$0, \"=\") + 1) }"
+}
# relies on $QMAKESPEC being set correctly. parses include statements in
# qmake.conf and prints out the expanded file
getQMakeConf()
{
- tmpSPEC="$QMAKESPEC"
- if [ -n "$1" ]; then
- tmpSPEC="$1"
+ if [ -z "$specvals" ]; then
+ specvals=`getQMakeConf1 "$QMAKESPEC/qmake.conf" | getQMakeConf2`
fi
- getQMakeConf1 "$tmpSPEC/qmake.conf"
+ getQMakeConf3 "$1" "$specvals"
+}
+
+getXQMakeConf()
+{
+ if [ -z "$xspecvals" ]; then
+ xspecvals=`getQMakeConf1 "$XQMAKESPEC/qmake.conf" | getQMakeConf2`
+ fi
+ getQMakeConf3 "$1" "$xspecvals"
}
# relies on $TEST_COMPILER being set correctly
@@ -2966,7 +3026,7 @@ fi
# now look at the configs and figure out what platform we are config'd for
[ "$CFG_EMBEDDED" = "no" ] && [ "$PLATFORM_QPA" != "yes" ] \
- && [ '!' -z "`getQMakeConf \"$XQMAKESPEC\" | grep QMAKE_LIBS_X11 | awk '{print $3;}'`" ] \
+ && [ -n "`getXQMakeConf QMAKE_LIBS_X11`" ] \
&& PLATFORM_X11=yes
### echo "$XQMAKESPEC" | grep mkspecs/qws >/dev/null 2>&1 && PLATFORM_QWS=yes
@@ -3236,7 +3296,7 @@ fi
if [ -z "$PKG_CONFIG" ]; then
# See if PKG_CONFIG is set in the mkspec:
- PKG_CONFIG=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%PKG_CONFIG[^_].*=%%p' | tr '\n' ' '`
+ PKG_CONFIG=`getXQMakeConf PKG_CONFIG`
fi
if [ -z "$PKG_CONFIG" ]; then
PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
@@ -3322,7 +3382,7 @@ else
CFG_FRAMEWORK=no
fi
-QMAKE_CONF_COMPILER=`getQMakeConf "$XQMAKESPEC" | grep "^QMAKE_CXX[^_A-Z0-9]" | sed "s,.* *= *\(.*\)$,\1," | tail -1`
+QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`
TEST_COMPILER="$CXX"
[ -z "$TEST_COMPILER" ] && TEST_COMPILER=$QMAKE_CONF_COMPILER
@@ -3392,9 +3452,9 @@ fi
# auto-detect support for separate debug info in objcopy
if [ "$CFG_SEPARATE_DEBUG_INFO" != "no" ] && [ "$CFG_SHARED" = "yes" ]; then
- TEST_COMPILER_CFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CFLAGS[^_=]*[+*]*=%%p' | tr '\n' ' '`
- TEST_COMPILER_CXXFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CXXFLAGS[^_=]*[+*]*=%%p' | tr '\n' ' '`
- TEST_OBJCOPY=`getQMakeConf "$XQMAKESPEC" | grep "^QMAKE_OBJCOPY" | sed "s%.* *= *\(.*\)$%\1%" | tail -1`
+ TEST_COMPILER_CFLAGS=`getXQMakeConf QMAKE_CFLAGS`
+ TEST_COMPILER_CXXFLAGS=`getXQMakeConf QMAKE_CXXFLAGS`
+ TEST_OBJCOPY=`getXQMakeConf QMAKE_OBJCOPY`
COMPILER_WITH_FLAGS="$TEST_COMPILER $TEST_COMPILER_CXXFLAGS"
COMPILER_WITH_FLAGS=`echo "$COMPILER_WITH_FLAGS" | sed -e "s%\\$\\$QMAKE_CFLAGS%$TEST_COMPILER_CFLAGS%g"`
if "$unixtests/objcopy.test" "$COMPILER_WITH_FLAGS" "$TEST_OBJCOPY" "$OPT_VERBOSE"; then
@@ -4448,7 +4508,7 @@ elif [ "$PLATFORM_MAC" = "yes" ]; then
Platform="Qt for Mac OS X"
elif [ "$XPLATFORM_MINGW" = "yes" ]; then
Platform="Qt for Windows"
-elif [ '!' -z "`getQMakeConf \"$XQMAKESPEC\" | grep QMAKE_LIBS_X11 | awk '{print $3;}'`" ]; then
+elif [ -n "`getXQMakeConf grep QMAKE_LIBS_X11`" ]; then
PLATFORM_X11=yes
Platform="Qt for Linux/X11"
fi
@@ -4776,43 +4836,14 @@ if [ -n "$PERL" ] && [ -x "$relpath/bin/syncqt" ]; then
fi
fi
-# $1: variable name
-# $2: optional transformation
+# $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
-# Assumes that the optional transformation produces the same variable name for each hit
setBootstrapVariable()
{
- getQMakeConf | $AWK '/^('"$1"')[^_A-Z0-9]/ { print $0; }' | ( [ -n "$2" ] && sed "$2" ; [ -z "$2" ] && cat ) | $AWK '
-BEGIN {
- variable = ""
- combinedValue = ""
-}
-{
- valStart = index($0, "=") + 1
-
- append = 0
- if (substr($0, valStart - 2, 1) == "+") {
- append = 1
- }
-
- variable = substr($0, 0, valStart - 2 - append)
- value = substr($0, valStart)
- gsub("[ \t]+", "", variable)
- gsub("^[ \t]+", "", value)
- gsub("[ \t]+$", "", value)
-
- if (append == 1 && length(combinedValue) > 0) {
- combinedValue = combinedValue " " value
- } else {
- combinedValue = value
- }
-}
-END {
- if (length(combinedValue) > 0) {
- printf "%s = %s\n", variable, combinedValue
- }
-}' >> "$mkfile"
+ getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
}
# build qmake
@@ -4875,15 +4906,11 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
[ -n "$CC" ] && echo "CC = $CC" >> "$mkfile"
[ -n "$CXX" ] && echo "CXX = $CXX" >> "$mkfile"
- if [ "$CFG_SILENT" = "yes" ]; then
- [ -z "$CC" ] && setBootstrapVariable QMAKE_CC 's,QMAKE_CC.*=,CC=\@,'
- [ -z "$CXX" ] && setBootstrapVariable QMAKE_CXX 's,QMAKE_CXX.*=,CXX=\@,'
- else
- [ -z "$CC" ] && setBootstrapVariable QMAKE_CC 's,QMAKE_CC,CC,'
- [ -z "$CXX" ] && setBootstrapVariable QMAKE_CXX 's,QMAKE_CXX,CXX,'
- fi
+ [ "$CFG_SILENT" = "yes" ] && CC_TRANSFORM='s,^,\@,' || CC_TRANSFORM=
+ [ -z "$CC" ] && setBootstrapVariable QMAKE_CC CC "$CC_TRANSFORM"
+ [ -z "$CXX" ] && setBootstrapVariable QMAKE_CXX CXX "$CC_TRANSFORM"
setBootstrapVariable QMAKE_CFLAGS
- setBootstrapVariable QMAKE_CXXFLAGS 's,\$\$QMAKE_CFLAGS,\$(QMAKE_CFLAGS),'
+ setBootstrapVariable QMAKE_CXXFLAGS
setBootstrapVariable QMAKE_LFLAGS
if [ $QT_EDITION = "QT_EDITION_OPENSOURCE" ]; then
@@ -4892,18 +4919,18 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
fi
if [ "$CFG_RELEASE_QMAKE" = "yes" ]; then
setBootstrapVariable QMAKE_CFLAGS_RELEASE
- setBootstrapVariable QMAKE_CXXFLAGS_RELEASE 's,\$\$QMAKE_CFLAGS_RELEASE,\$(QMAKE_CFLAGS_RELEASE),'
+ setBootstrapVariable QMAKE_CXXFLAGS_RELEASE
EXTRA_CFLAGS="$EXTRA_CFLAGS \$(QMAKE_CFLAGS_RELEASE)"
EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_RELEASE)"
elif [ "$CFG_DEBUG" = "yes" ]; then
setBootstrapVariable QMAKE_CFLAGS_DEBUG
- setBootstrapVariable QMAKE_CXXFLAGS_DEBUG 's,\$\$QMAKE_CFLAGS_DEBUG,\$(QMAKE_CFLAGS_DEBUG),'
+ setBootstrapVariable QMAKE_CXXFLAGS_DEBUG
EXTRA_CFLAGS="$EXTRA_CFLAGS \$(QMAKE_CFLAGS_DEBUG)"
EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_DEBUG)"
fi
- if [ '!' -z "$RPATH_FLAGS" ] && [ '!' -z "`getQMakeConf \"$QMAKESPEC\" | $AWK '/QMAKE_(LFLAGS_)?RPATH/ {print $3;}'`" ]; then
- setBootstrapVariable "QMAKE_(LFLAGS_)?RPATH" 's,\$\$LITERAL_WHITESPACE, ,;s,QMAKE_RPATH,QMAKE_LFLAGS_RPATH,'
+ if [ -n "$RPATH_FLAGS" ] && [ -n "`getQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then
+ setBootstrapVariable "QMAKE_(LFLAGS_)?RPATH" QMAKE_LFLAGS_RPATH
for rpath in $RPATH_FLAGS; do
EXTRA_LFLAGS="\$(QMAKE_LFLAGS_RPATH)\"$rpath\" $EXTRA_LFLAGS"
done
@@ -7399,7 +7426,7 @@ if [ "$PLATFORM_MAC" = "yes" ]; then
if [ "$CFG_RPATH" = "yes" ]; then
QMAKE_CONFIG="$QMAKE_CONFIG absolute_library_soname"
fi
-elif [ -z "`getQMakeConf \"$XQMAKESPEC\" | $AWK '/QMAKE_(LFLAGS_)?RPATH/ {print $3;}'`" ]; then
+elif [ -z "`getXQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then
if [ -n "$RPATH_FLAGS" ]; then
echo
echo "ERROR: -R cannot be used on this platform as \$QMAKE_LFLAGS_RPATH is"