From 5ecda429d1aa937a8977c30876dca25c3e7e6735 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 24 Feb 2016 22:37:30 +0100 Subject: [PATCH] Check for Qt using PKG_CHECK_MODULES() in configure Running pkg-config directly was wrong for many reasons and we didn't even detect the libraries absence. --- configure | 216 +++++++++++++++++++++++++++++++++++++++++++++++++-- configure.in | 30 ++++--- 2 files changed, 228 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 7725b68fb5..49e5978fa5 100755 --- a/configure +++ b/configure @@ -971,6 +971,8 @@ Xxf86vm_LIBS Xxf86vm_CFLAGS Xinerama_LIBS Xinerama_CFLAGS +QT5_LIBS +QT5_CFLAGS PANGOFT2_LIBS PANGOFT2_CFLAGS PANGOXFT_LIBS @@ -1375,6 +1377,8 @@ PANGOXFT_CFLAGS PANGOXFT_LIBS PANGOFT2_CFLAGS PANGOFT2_LIBS +QT5_CFLAGS +QT5_LIBS Xinerama_CFLAGS Xinerama_LIBS Xxf86vm_CFLAGS @@ -2355,6 +2359,8 @@ Some influential environment variables: C compiler flags for PANGOFT2, overriding pkg-config PANGOFT2_LIBS linker flags for PANGOFT2, overriding pkg-config + QT5_CFLAGS C compiler flags for QT5, overriding pkg-config + QT5_LIBS linker flags for QT5, overriding pkg-config Xinerama_CFLAGS C compiler flags for Xinerama, overriding pkg-config Xinerama_LIBS @@ -25242,15 +25248,208 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$wxUSE_QT" = 1; then - TOOLKIT=QT - GUIDIST=QT_DIST - TOOLKIT_DIR="qt" - TOOLKIT_INCLUDE="${TOOLKIT_INCLUDE} `pkg-config Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test --cflags` -DQT_WIDGETS_LIB" - GUI_TK_LIBRARY="${GUI_TK_LIBRARY} `pkg-config Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test --libs`" - if `pkg-config --variable qt_config Qt5Core | grep "reduce_relocations" >/dev/null`; then - SAMPLES_CXXFLAGS="-fPIC $SAMPLES_CXXFLAGS" - WXCONFIG_CXXFLAGS="-fPIC $WXCONFIG_CXXFLAGS $TOOLKIT_INCLUDE" + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi + +fi + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for QT5" >&5 +$as_echo_n "checking for QT5... " >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$QT5_CFLAGS"; then + pkg_cv_QT5_CFLAGS="$QT5_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test\""; } >&5 + ($PKG_CONFIG --exists --print-errors "Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_QT5_CFLAGS=`$PKG_CONFIG --cflags "Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$QT5_LIBS"; then + pkg_cv_QT5_LIBS="$QT5_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test\""; } >&5 + ($PKG_CONFIG --exists --print-errors "Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_QT5_LIBS=`$PKG_CONFIG --libs "Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + QT5_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test"` + else + QT5_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test"` fi + # Put the nasty error message in config.log where it belongs + echo "$QT5_PKG_ERRORS" >&5 + + + as_fn_error $? "Qt5 libraries are not available" "$LINENO" 5 + + +elif test $pkg_failed = untried; then + + as_fn_error $? "Qt5 libraries are not available" "$LINENO" 5 + + +else + QT5_CFLAGS=$pkg_cv_QT5_CFLAGS + QT5_LIBS=$pkg_cv_QT5_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + TOOLKIT=QT + GUIDIST=QT_DIST + TOOLKIT_DIR="qt" + TOOLKIT_INCLUDE="${TOOLKIT_INCLUDE} ${QT5_CFLAGS}" + GUI_TK_LIBRARY="${GUI_TK_LIBRARY} ${QT5_LIBS}" + if `pkg-config --variable qt_config Qt5Core | grep "reduce_relocations" >/dev/null`; then + SAMPLES_CXXFLAGS="-fPIC $SAMPLES_CXXFLAGS" + WXCONFIG_CXXFLAGS="-fPIC $WXCONFIG_CXXFLAGS $TOOLKIT_INCLUDE" + fi + +fi fi TOOLKIT_DIR=`echo ${TOOLKIT} | tr '[A-Z]' '[a-z]'` @@ -40907,3 +41106,4 @@ echo " libmspack ${wxUSE_LIBMSPAC echo " sdl ${wxUSE_LIBSDL}" echo "" + diff --git a/configure.in b/configure.in index 6ff278de70..3971754689 100644 --- a/configure.in +++ b/configure.in @@ -3283,16 +3283,26 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config if test "$wxUSE_QT" = 1; then - TOOLKIT=QT - GUIDIST=QT_DIST - TOOLKIT_DIR="qt" - TOOLKIT_INCLUDE="${TOOLKIT_INCLUDE} `pkg-config Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test --cflags` -DQT_WIDGETS_LIB" - GUI_TK_LIBRARY="${GUI_TK_LIBRARY} `pkg-config Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test --libs`" - if `pkg-config --variable qt_config Qt5Core | grep "reduce_relocations" >/dev/null`; then - dnl build with position independent code if Qt needs it - SAMPLES_CXXFLAGS="-fPIC $SAMPLES_CXXFLAGS" - WXCONFIG_CXXFLAGS="-fPIC $WXCONFIG_CXXFLAGS $TOOLKIT_INCLUDE" - fi + PKG_PROG_PKG_CONFIG() + + PKG_CHECK_MODULES(QT5, + [Qt5Core Qt5Widgets Qt5Gui Qt5OpenGL Qt5Test], + [ + TOOLKIT=QT + GUIDIST=QT_DIST + TOOLKIT_DIR="qt" + TOOLKIT_INCLUDE="${TOOLKIT_INCLUDE} ${QT5_CFLAGS}" + GUI_TK_LIBRARY="${GUI_TK_LIBRARY} ${QT5_LIBS}" + if `pkg-config --variable qt_config Qt5Core | grep "reduce_relocations" >/dev/null`; then + dnl build with position independent code if Qt needs it + SAMPLES_CXXFLAGS="-fPIC $SAMPLES_CXXFLAGS" + WXCONFIG_CXXFLAGS="-fPIC $WXCONFIG_CXXFLAGS $TOOLKIT_INCLUDE" + fi + ], + [ + AC_MSG_ERROR([Qt5 libraries are not available]) + ] + ) fi dnl the name of the directory where the files for this toolkit live TOOLKIT_DIR=`echo ${TOOLKIT} | tr '[[A-Z]]' '[[a-z]]'`