From 0c7bd9a57f2a308bb9659200eda3b7e45f8d5d3c Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 17 Jul 2016 12:31:24 +0200 Subject: [PATCH] Check path of Qt tools if qtchooser is detected The full path of the tools is retained only if the Qt directory is specified using --with-qt-dir. Now, when qtchooser was detected it was blindly assumed that the corresponding system tools were being used. These tools discriminate between Qt4 and Qt5 through the option -qt=qt4 or -qt=qt5. However, the original Qt tools don't understand these options, so that if they come first in the PATH, configuration fails. So, only use those options if we are reasonably sure that the system Qt is wanted. This is achieved by comparing the paths of qtchooser and tools as, typically, they are located in the same directory. In this way, if one prepends the bin directory of a custom Qt build to PATH (and accordingly adjusts PKG_CONFIG_PATH), configuration succeeds even if --with-qt-dir is not specified. --- config/qt4.m4 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/qt4.m4 b/config/qt4.m4 index f39c0ed67e..03f0c05341 100644 --- a/config/qt4.m4 +++ b/config/qt4.m4 @@ -75,7 +75,13 @@ AC_DEFUN([QT_FIND_TOOL], if test -n "$qt_cv_bin" ; then AC_PATH_PROGS($1, [$2], [], $qt_cv_bin) elif qtchooser -l 2>/dev/null | grep -q ^$qt_ext\$ >/dev/null ; then - AC_CHECK_PROG($1, $2, [$2 -qt=$qt_ext],, [$PATH]) + AC_PATH_PROG(qtc_path, qtchooser, [], [$PATH]) + AC_PATH_PROG($2_path, $2, [], [$PATH]) + qtc_path=$(dirname "$qtc_path") + $2_path=$(dirname "$$2_path") + if test "$qtc_path" = "$$2_path" ; then + AC_CHECK_PROG($1, $2, [$2 -qt=$qt_ext],, [$PATH]) + fi fi if test -z "$$1"; then AC_CHECK_PROGS($1, [$2-$qt_ext $2],[],$PATH)