configure: properly quote glesv2 flags
authorRobin Burchell <robin.burchell@collabora.co.uk>
Fri, 29 Jun 2012 07:16:15 +0000 (09:16 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 2 Jul 2012 23:09:07 +0000 (01:09 +0200)
pkg-config returns glesv2 build flags, which are parsed into a few
variables. However, extra spaces get included in these variables and
quoted, which makes includes paths not work.

This problem can only be hit, if you do not have GL ES 2 headers
installed system-wide, but you do have installed into $prefix, and
pkg-config configured to return the configuration for $prefix. Even
though pkg-config returns correct paths, extra space gets included.

Fix it by parsing the strings returned by pkg-config just like a shell
would parse a command line. pkg-config escapes e.g. spaces, so those
escape sequences need to be interpreted, while doing word-splitting. The
result is a quoted list, as expected in the qmake files.

Done-with: Pekka Paalanen <ppaalanen@gmail.com>
Change-Id: I0593ef7e0606ac5ea80da046e45f86806206951a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
configure

index c85c39c..097bd90 100755 (executable)
--- a/configure
+++ b/configure
@@ -108,6 +108,21 @@ QMakeVar()
     echo "$2" "$eq" "$3" >> "$QMAKE_VARS_FILE"
 }
 
+shellArgumentListToQMakeListHelper()
+{
+    local retval
+    for arg in "$@"; do retval="$retval \"$arg\""; done
+    echo "$retval"
+}
+
+# Convert a string usable on a shell command line into word-by-word quoted
+# qmake list.
+shellArgumentListToQMakeList()
+{
+    # eval is needed for the shell to interpret the backslash escape sequences
+    eval shellArgumentListToQMakeListHelper "$@"
+}
+
 # Helper function for getQMakeConf. It parses include statements in
 # qmake.conf and prints out the expanded file
 getQMakeConf1()
@@ -4518,9 +4533,9 @@ elif [ "$CFG_OPENGL" = "es2" ]; then
         QMAKE_LIBDIR_OPENGL_ES2=`$PKG_CONFIG --libs-only-L glesv2 2>/dev/null | sed -e 's,^-L,,g' -e 's, -L, ,g'`
         QMAKE_LIBS_OPENGL_ES2=`$PKG_CONFIG --libs glesv2 2>/dev/null`
         QMAKE_CFLAGS_OPENGL_ES2=`$PKG_CONFIG --cflags glesv2 2>/dev/null`
-        QMakeVar set QMAKE_INCDIR_OPENGL_ES2 "$QMAKE_INCDIR_OPENGL_ES2"
-        QMakeVar set QMAKE_LIBDIR_OPENGL_ES2 "$QMAKE_LIBDIR_OPENGL_ES2"
-        QMakeVar set QMAKE_LIBS_OPENGL_ES2 "$QMAKE_LIBS_OPENGL_ES2"
+        QMakeVar set QMAKE_INCDIR_OPENGL_ES2 "`shellArgumentListToQMakeList "$QMAKE_INCDIR_OPENGL_ES2"`"
+        QMakeVar set QMAKE_LIBDIR_OPENGL_ES2 "`shellArgumentListToQMakeList "$QMAKE_LIBDIR_OPENGL_ES2"`"
+        QMakeVar set QMAKE_LIBS_OPENGL_ES2 "`shellArgumentListToQMakeList "$QMAKE_LIBS_OPENGL_ES2"`"
     fi
 
     "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2
@@ -5809,7 +5824,7 @@ fi
 
 if [ -n "$QMAKE_INCDIR_OPENGL_ES2" ]; then
     echo "#Qt opengl include path" >> "$QTCONFIG.tmp"
-    echo "QMAKE_INCDIR_OPENGL_ES2 = \"$QMAKE_INCDIR_OPENGL_ES2\"" >> "$QTCONFIG.tmp"
+    echo "QMAKE_INCDIR_OPENGL_ES2 = `shellArgumentListToQMakeList "$QMAKE_INCDIR_OPENGL_ES2"`" >> "$QTCONFIG.tmp"
 fi
 
 # replace qconfig.pri if it differs from the newly created temp file