1dnl 2dnl Check for Qt 5 3dnl 4 5qt_min_ver=5.9.0 6 7check_qt5() { 8 AC_ARG_WITH(qmake, 9 AC_HELP_STRING([--with-qmake=prog],[use prog instead of looking for qmake for Qt 5]), 10 [ QMAKE="$with_qmake" ],) 11 12 if ! test -z "$QMAKE"; then 13 AC_MSG_CHECKING(for qmake) 14 AC_MSG_RESULT(using supplied $QMAKE) 15 else 16 AC_PATH_TOOL(QMAKE, qmake-qt5,, $PATH) 17 if test -z "$QMAKE"; then 18 AC_PATH_TOOL(QMAKE, qmake,, $PATH) 19 fi 20 fi 21 22 if test x"$QMAKE" = x; then 23 AC_MSG_CHECKING(for Qt 5) 24 AC_MSG_RESULT(no: qmake not found) 25 return 26 fi 27 28 qmake_properties="`mktemp`" 29 30 "$QMAKE" -query > "$qmake_properties" 31 32 qmake_ver="`$ac_cv_path_EGREP '^QT_VERSION:' "$qmake_properties" | sed 's/^QT_VERSION://'`" 33 34 AC_MSG_CHECKING(for qmake's version) 35 if test -z "qmake_ver"; then 36 AC_MSG_RESULT(unknown; please contact the author) 37 return 38 elif ! check_version $qt_min_ver $qmake_ver; then 39 AC_MSG_RESULT(too old: $qmake_ver, neet at least $qt_mIN-ver) 40 return 41 else 42 AC_MSG_RESULT($qmake_ver) 43 fi 44 45 qt_bindir="`$ac_cv_path_EGREP '^QT_INSTALL_BINS:' "$qmake_properties" | sed 's/^QT_INSTALL_BINS://'`" 46 qt_libexecdir="`$ac_cv_path_EGREP '^QT_INSTALL_LIBEXECS:' "$qmake_properties" | sed 's/^QT_INSTALL_LIBEXECS://'`" 47 qt_searchpath="$qt_libexecdir:$qt_bindir:$PATH" 48 49 rm -f "$qmake_properties" 50 51 AC_PATH_PROG(LCONVERT, lconvert,, [$qt_searchpath]) 52 AC_PATH_PROG(MOC, moc,, [$qt_searchpath]) 53 AC_PATH_PROG(RCC, rcc,, [$qt_searchpath]) 54 AC_PATH_PROG(UIC, uic,, [$qt_searchpath]) 55 56 if test x"$MOC" = x; then 57 AC_MSG_CHECKING(for Qt 5) 58 AC_MSG_RESULT(no: could not find the moc executable) 59 return 60 61 elif test x"$RCC" = x; then 62 AC_MSG_CHECKING(for Qt 5) 63 AC_MSG_RESULT(no: could not find the rcc executable) 64 return 65 66 elif test x"$UIC" = x; then 67 AC_MSG_CHECKING(for Qt 5) 68 AC_MSG_RESULT(no: could not find the uic executable) 69 return 70 fi 71 72 73 if test x"$enable_static_qt" = "xyes"; then 74 AC_DEFINE(HAVE_STATIC_QT,,[define if building against a static Qt library]) 75 QT_PKG_CONFIG_STATIC=--static 76 else 77 QT_PKG_CONFIG_STATIC= 78 fi 79 80 if test "x$with_qt_pkg_config" = xyes; then 81 with_qt_pkg_config_modules="`echo "$with_qt_pkg_config_modules" | sed -e 's/ /,/g'`" 82 if test x"$with_qt_pkg_config_modules" != x ; then 83 with_qt_pkg_config_modules="$with_qt_pkg_config_modules," 84 fi 85 86 orig_with_qt_pkg_config_modules="$with_qt_pkg_config_modules," 87 88 with_qt_pkg_config_modules="$with_qt_pkg_config_modules,Qt5Core" 89 90 if test x"$enable_gui" = xyes; then 91 with_qt_pkg_config_modules="$with_qt_pkg_config_modules,Qt5Gui,Qt5Widgets,Qt5Multimedia,Qt5Network,Qt5Concurrent" 92 fi 93 94 if test x"$MINGW" = x1; then 95 with_qt_pkg_config_modules="$with_qt_pkg_config_modules,Qt5WinExtras" 96 fi 97 98 PKG_CHECK_EXISTS([$with_qt_pkg_config_modules],[ok=1],[ok=0]) 99 PKG_CHECK_EXISTS([Qt5PlatformSupport],[with_qt_pkg_config_modules="$with_qt_pkg_config_modules,Qt5PlatformSupport"]) 100 101 if test $ok = 0; then 102 AC_MSG_CHECKING(for Qt 5) 103 AC_MSG_RESULT(no: not found by pkg-config) 104 return 105 fi 106 107 if test x"$MINGW" != x1 && ! echo "$host" | grep -q -i apple ; then 108 PKG_CHECK_EXISTS([Qt5DBus],[dbus_found=yes],[dbus_found=no]) 109 if test x"$dbus_found" = xyes; then 110 with_qt_pkg_config_modules="$with_qt_pkg_config_modules,Qt5DBus" 111 AC_DEFINE(HAVE_QTDBUS, 1, [Define if QtDBus is present]) 112 fi 113 fi 114 115 with_qt_pkg_config_modules="`echo "$with_qt_pkg_config_modules" | sed -e 's/,/ /g'`" 116 QT_CFLAGS="`$PKG_CONFIG --cflags $with_qt_pkg_config_modules $QT_PKG_CONFIG_STATIC`" 117 QT_LIBS="`$PKG_CONFIG --libs $with_qt_pkg_config_modules $QT_PKG_CONFIG_STATIC`" 118 QT_LIBS_NON_GUI="`$PKG_CONFIG --libs $orig_with_qt_pkg_config_modules,Qt5Core $QT_PKG_CONFIG_STATIC`" 119 fi 120 121 dnl compile test program 122 AC_LANG_PUSH(C++) 123 AC_CACHE_VAL(am_cv_qt5_compilation, [ 124 run_qt_test=1 125 while true; do 126 ac_save_CXXFLAGS="$CXXFLAGS" 127 ac_save_LIBS="$LIBS" 128 CXXFLAGS="$STD_CXX $CXXFLAGS $QT_CFLAGS -fPIC" 129 LIBS="$LDFLAGS $QT_LIBS" 130 unset ac_cv_qt_compilation 131 132 AC_TRY_LINK([ 133#include <QtCore> 134#include <QCoreApplication> 135class Config : public QCoreApplication { 136public: 137Config(int &argc, char **argv); 138}; 139Config::Config(int &argc, char **argv) 140: QCoreApplication(argc,argv) {setApplicationName("config");} 141 ], [ 142int ai = 0; 143char **ac = 0; 144Config app(ai,ac); 145return 0; 146 ], [ am_cv_qt5_compilation=1 ], [ am_cv_qt5_compilation=0 ]) 147 148 CXXFLAGS="$ac_save_CXXFLAGS" 149 LIBS="$ac_save_LIBS" 150 151 if test x"$am_cv_qt5_compilation" = x1; then 152 break 153 154 elif test x"$run_qt_test" = "x1"; then 155 QT_CFLAGS="$QT_CFLAGS -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtWidgets -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include/QtWidgets -I/usr/local/include/QtNetwork -I/usr/local/include/QtPlatformSupport" 156 run_qt_test=3 157 158 else 159 break 160 161 fi 162 done 163 ]) 164 AC_LANG_POP() 165 166 rm -f src/mkvtoolnix-gui/static_plugins.cpp 167 168 if ! test x"$am_cv_qt5_compilation" = x1; then 169 AC_MSG_CHECKING(for Qt 5) 170 AC_MSG_RESULT(no: test program could not be compiled) 171 return 172 fi 173 174 if test x"$QT_PKG_CONFIG_STATIC" != x; then 175 qmake_dir="`mktemp -d`" 176 177 if test x"$MINGW" = x1 && check_version 5.10.0 $moc_ver; then 178 QTPLUGIN="qwindowsvistastyle" 179 else 180 QTPLUGIN="" 181 fi 182 183 touch "$qmake_dir/empty.cpp" 184 cat > "$qmake_dir/dummy.pro" <<EOF 185QT += core multimedia 186QTPLUGIN += $QTPLUGIN 187CONFIG += release static 188TARGET = console 189TEMPLATE = app 190SOURCES += empty.cpp 191EOF 192 193 old_wd="$PWD" 194 cd "$qmake_dir" 195 196 "$QMAKE" -makefile -nocache dummy.pro > /dev/null 2>&1 197 result=$? 198 199 cd "$old_wd" 200 201 makefile="" 202 if test x$result != x0; then 203 problem="qmake failed to create Makefile" 204 205 elif ! test -f "$qmake_dir/console_plugin_import.cpp"; then 206 problem="static plugin list could not be generated via $QMAKE" 207 208 elif test -f "$qmake_dir/Makefile.Release"; then 209 makefile="$qmake_dir/Makefile.Release" 210 211 elif test -f "$qmake_dir/Makefile"; then 212 makefile="$qmake_dir/Makefile" 213 214 else 215 problem="the Makefile created by $QMAKE could not be found" 216 fi 217 218 if test x"$problem" = x; then 219 qmake_libs="`grep '^LIBS' "$makefile" | sed -Ee 's/^LIBS[[ \t]]*=[[ \t]]*//'`" 220 QT_LIBS="$qmake_libs $QT_LIBS" 221 222 cp "$qmake_dir/console_plugin_import.cpp" src/mkvtoolnix-gui/static_plugins.cpp 223 fi 224 225 rm -rf "$qmake_dir" 226 227 unset makefile qmake_libs qmake_dir 228 fi 229 230 AC_MSG_CHECKING(for Qt 5) 231 232 if test x"$problem" = x; then 233 AC_DEFINE(HAVE_QT, 1, [Define if Qt is present]) 234 AC_MSG_RESULT(yes) 235 have_qt5=yes 236 else 237 AC_MSG_RESULT(no: $problem) 238 fi 239 240 unset problem 241} 242 243AC_ARG_ENABLE([qt5], 244 AC_HELP_STRING([--enable-qt5],[compile with Qt 5 (yes if Qt 6 is not found)]), 245 [],[enable_qt5=yes]) 246AC_ARG_ENABLE([static_qt], 247 AC_HELP_STRING([--enable-static-qt],[link to static versions of the Qt 5 library (no)])) 248AC_ARG_WITH([qt_pkg_config_modules], 249 AC_HELP_STRING([--with-qt-pkg-config-modules=modules],[gather include/link flags for additional Qt 5 modules from pkg-config])) 250AC_ARG_WITH([qt_pkg_config], 251 AC_HELP_STRING([--without-qt-pkg-config], [do not use pkg-config for detecting Qt 5; instead rely on QT_CFLAGS/QT_LIBS being set correctly already]), 252 [ with_qt_pkg_config=${withval} ], [ with_qt_pkg_config=yes ]) 253 254have_qt5=no 255 256if test x"$have_qt6" = "xyes"; then 257 AC_MSG_CHECKING(for Qt 5) 258 AC_MSG_RESULT(no: already using Qt 6) 259 260elif test x"$enable_qt5" != xyes; then 261 AC_MSG_CHECKING(for Qt 5) 262 AC_MSG_RESULT(no: disabled by user request) 263 264else 265 check_qt5 266fi 267