Mercurial > minori
comparison m4/m4_ax_have_qt.m4 @ 242:82470f83f0c2
autotools: make windows build work
also, I've added back the method I made for getting the vars as
variables rather than separate files, so less clutter in tmp folders :)
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Mon, 22 Jan 2024 19:06:23 -0800 |
| parents | 06d6c351925c |
| children |
comparison
equal
deleted
inserted
replaced
| 241:06d6c351925c | 242:82470f83f0c2 |
|---|---|
| 47 # | 47 # |
| 48 # LICENSE | 48 # LICENSE |
| 49 # | 49 # |
| 50 # Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net> | 50 # Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net> |
| 51 # Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com> | 51 # Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com> |
| 52 # Copyright (c) 2024 Paper <mrpapersonic@gmail.com> | |
| 52 # | 53 # |
| 53 # Copying and distribution of this file, with or without modification, are | 54 # Copying and distribution of this file, with or without modification, are |
| 54 # permitted in any medium without royalty provided the copyright notice | 55 # permitted in any medium without royalty provided the copyright notice |
| 55 # and this notice are preserved. This file is offered as-is, without any | 56 # and this notice are preserved. This file is offered as-is, without any |
| 56 # warranty. | 57 # warranty. |
| 58 #serial 25 | 59 #serial 25 |
| 59 | 60 |
| 60 AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT]) | 61 AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT]) |
| 61 AC_DEFUN([AX_HAVE_QT], | 62 AC_DEFUN([AX_HAVE_QT], |
| 62 [ | 63 [ |
| 63 AC_REQUIRE([AC_PROG_CXX]) | 64 AC_REQUIRE([AC_PROG_CXX]) |
| 64 AC_REQUIRE([AC_PATH_X]) | 65 AC_REQUIRE([AC_PATH_X]) |
| 65 AC_REQUIRE([AC_PATH_XTRA]) | 66 AC_REQUIRE([AC_PATH_XTRA]) |
| 66 # openSUSE leap 15.3 installs qmake-qt5, not qmake, for example. | 67 # openSUSE leap 15.3 installs qmake-qt5, not qmake, for example. |
| 67 # Store the full name (like qmake-qt5) into QMAKE | 68 # Store the full name (like qmake-qt5) into QMAKE |
| 68 # and the specifier (like -qt5 or empty) into am_have_qt_qmexe_suff. | 69 # and the specifier (like -qt5 or empty) into am_have_qt_qmexe_suff. |
| 69 AC_ARG_VAR([QMAKE],"Qt make tool") | 70 AC_ARG_VAR([QMAKE],"Qt make tool") |
| 70 AC_CHECK_TOOLS([QMAKE],[qmake qmake-qt6 qmake-qt5],[false]) | 71 AC_CHECK_TOOLS([QMAKE],[qmake qmake-qt6 qmake-qt5],[false]) |
| 71 | 72 |
| 72 AC_MSG_CHECKING(for Qt) | 73 AC_MSG_CHECKING(for Qt) |
| 73 am_have_qt_qmexe_suff=`echo $QMAKE | sed 's,^.*qmake,,'` | 74 am_have_qt_qmexe_suff=`echo $QMAKE | sed 's,^.*qmake,,'` |
| 74 # If we have Qt5 or later in the path, we're golden | 75 # If we have Qt5 or later in the path, we're golden |
| 75 ver=`$QMAKE --version | grep -o "Qt version ."` | 76 ver=`$QMAKE --version | grep -o "Qt version ."` |
| 76 | 77 |
| 77 if test "$ver" ">" "Qt version 4"; then | 78 if test "$ver" ">" "Qt version 4"; then |
| 78 have_qt=yes | 79 have_qt=yes |
| 79 # This pro file dumps qmake's variables, but it only works on Qt 5 or later | 80 # This pro file dumps qmake's variables, but it only works on Qt 5 or later |
| 80 am_have_qt_dir=`mktemp -d` | 81 am_have_qt_dir=`mktemp -d` |
| 81 am_have_qt_pro="$am_have_qt_dir/test.pro" | 82 am_have_qt_pro="$am_have_qt_dir/test.pro" |
| 82 am_have_qt_stash="$am_have_qt_dir/.qmake.stash" | 83 am_have_qt_stash="$am_have_qt_dir/.qmake.stash" |
| 83 am_have_qt_makefile="$am_have_qt_dir/Makefile" | 84 am_have_qt_makefile="$am_have_qt_dir/Makefile" |
| 84 # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt | 85 # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt |
| 85 cat > $am_have_qt_pro << EOF | 86 cat > $am_have_qt_pro << EOF |
| 86 win32 { | 87 win32 { |
| 87 CONFIG -= debug_and_release | 88 CONFIG -= debug_and_release |
| 88 CONFIG += release | 89 CONFIG += release |
| 89 } | 90 } |
| 91 | |
| 92 CONFIG += sdk_no_version_check | |
| 93 | |
| 94 # use absolute paths, useful on windows | |
| 95 # where qmake really loves giving relative paths | |
| 96 QMAKE_PROJECT_DEPTH = 0 | |
| 97 | |
| 98 # commented out all the modules we don't use | |
| 90 #qtHaveModule(axcontainer): QT += axcontainer | 99 #qtHaveModule(axcontainer): QT += axcontainer |
| 91 #qtHaveModule(axserver): QT += axserver | 100 #qtHaveModule(axserver): QT += axserver |
| 92 #qtHaveModule(concurrent): QT += concurrent | 101 #qtHaveModule(concurrent): QT += concurrent |
| 93 qtHaveModule(core): QT += core | 102 qtHaveModule(core): QT += core |
| 94 #qtHaveModule(dbus): QT += dbus | 103 #qtHaveModule(dbus): QT += dbus |
| 119 qtHaveModule(widgets): QT += widgets | 128 qtHaveModule(widgets): QT += widgets |
| 120 percent.target = % | 129 percent.target = % |
| 121 percent.commands = @echo -n "\$(\$(@))\ " | 130 percent.commands = @echo -n "\$(\$(@))\ " |
| 122 QMAKE_EXTRA_TARGETS += percent | 131 QMAKE_EXTRA_TARGETS += percent |
| 123 EOF | 132 EOF |
| 124 $QMAKE $am_have_qt_pro -o $am_have_qt_makefile | 133 am_have_qt_makefile_cxxflags=`cat << EOF |
| 125 QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile CXXFLAGS INCPATH` | 134 include $am_have_qt_makefile |
| 126 QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile LIBS` | 135 |
| 127 rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile | 136 VAR: |
| 128 rmdir $am_have_qt_dir | 137 @echo \\$(CXXFLAGS) \\$(INCPATH) |
| 129 | 138 EOF` |
| 130 # Look for specific tools in $PATH | 139 am_have_qt_makefile_libs=`cat << EOF |
| 131 QT_MOC=`which moc$am_have_qt_qmexe_suff` | 140 include $am_have_qt_makefile |
| 132 QT_UIC=`which uic$am_have_qt_qmexe_suff` | 141 |
| 133 QT_RCC=`which rcc$am_have_qt_qmexe_suff` | 142 VAR: |
| 134 QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff` | 143 @echo \\$(LIBS) |
| 135 QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff` | 144 EOF` |
| 136 | 145 $QMAKE "$am_have_qt_pro" -o "$am_have_qt_makefile" |
| 137 # Get Qt version from qmake | 146 QT_CXXFLAGS=`cd $am_have_qt_dir; echo "\$am_have_qt_makefile_cxxflags" | make -s -f - VAR` |
| 138 QT_DIR=`$QMAKE --version | grep -o -E /.+` | 147 QT_LIBS=`cd $am_have_qt_dir; echo "\$am_have_qt_makefile_libs" | make -s -f - VAR` |
| 139 | 148 rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile |
| 140 # All variables are defined, report the result | 149 rmdir $am_have_qt_dir |
| 141 AC_MSG_RESULT([$have_qt: | 150 |
| 142 QT_CXXFLAGS=$QT_CXXFLAGS | 151 # Look for specific tools in $PATH |
| 143 QT_DIR=$QT_DIR | 152 QT_MOC=`which moc$am_have_qt_qmexe_suff` |
| 144 QT_LIBS=$QT_LIBS | 153 QT_UIC=`which uic$am_have_qt_qmexe_suff` |
| 145 QT_UIC=$QT_UIC | 154 QT_RCC=`which rcc$am_have_qt_qmexe_suff` |
| 146 QT_MOC=$QT_MOC | 155 QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff` |
| 147 QT_RCC=$QT_RCC | 156 QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff` |
| 148 QT_LRELEASE=$QT_LRELEASE | 157 |
| 149 QT_LUPDATE=$QT_LUPDATE]) | 158 # Get Qt version from qmake |
| 150 else | 159 QT_DIR=`$QMAKE --version | grep -o -E /.+` |
| 151 # Qt was not found | 160 |
| 152 have_qt=no | 161 # All variables are defined, report the result |
| 153 QT_CXXFLAGS= | 162 AC_MSG_RESULT([$have_qt: |
| 154 QT_DIR= | 163 QT_CXXFLAGS=$QT_CXXFLAGS |
| 155 QT_LIBS= | 164 QT_DIR=$QT_DIR |
| 156 QT_UIC= | 165 QT_LIBS=$QT_LIBS |
| 157 QT_MOC= | 166 QT_UIC=$QT_UIC |
| 158 QT_RCC= | 167 QT_MOC=$QT_MOC |
| 159 QT_LRELEASE= | 168 QT_RCC=$QT_RCC |
| 160 QT_LUPDATE= | 169 QT_LRELEASE=$QT_LRELEASE |
| 161 AC_MSG_RESULT($have_qt) | 170 QT_LUPDATE=$QT_LUPDATE]) |
| 162 fi | 171 else |
| 163 AC_SUBST(QT_CXXFLAGS) | 172 # Qt was not found |
| 164 AC_SUBST(QT_DIR) | 173 have_qt=no |
| 165 AC_SUBST(QT_LIBS) | 174 QT_CXXFLAGS= |
| 166 AC_SUBST(QT_UIC) | 175 QT_DIR= |
| 167 AC_SUBST(QT_MOC) | 176 QT_LIBS= |
| 168 AC_SUBST(QT_RCC) | 177 QT_UIC= |
| 169 AC_SUBST(QT_LRELEASE) | 178 QT_MOC= |
| 170 AC_SUBST(QT_LUPDATE) | 179 QT_RCC= |
| 171 AC_SUBST(QMAKE) | 180 QT_LRELEASE= |
| 172 | 181 QT_LUPDATE= |
| 173 #### Being paranoid: | 182 AC_MSG_RESULT($have_qt) |
| 174 if test x"$have_qt" = xyes; then | 183 fi |
| 175 AC_MSG_CHECKING(correct functioning of Qt installation) | 184 AC_SUBST(QT_CXXFLAGS) |
| 176 AC_CACHE_VAL(ax_cv_qt_test_result, | 185 AC_SUBST(QT_DIR) |
| 177 [ | 186 AC_SUBST(QT_LIBS) |
| 178 cat > ax_qt_test.h << EOF | 187 AC_SUBST(QT_UIC) |
| 188 AC_SUBST(QT_MOC) | |
| 189 AC_SUBST(QT_RCC) | |
| 190 AC_SUBST(QT_LRELEASE) | |
| 191 AC_SUBST(QT_LUPDATE) | |
| 192 AC_SUBST(QMAKE) | |
| 193 | |
| 194 #### Being paranoid: | |
| 195 if test x"$have_qt" = xyes; then | |
| 196 AC_MSG_CHECKING(correct functioning of Qt installation) | |
| 197 AC_CACHE_VAL(ax_cv_qt_test_result, | |
| 198 [ | |
| 199 cat > ax_qt_test.h << EOF | |
| 179 #include <qobject.h> | 200 #include <qobject.h> |
| 180 class Test : public QObject | 201 class Test : public QObject |
| 181 { | 202 { |
| 182 Q_OBJECT | 203 Q_OBJECT |
| 183 public: | 204 public: |
| 184 Test() {} | 205 Test() {} |
| 185 ~Test() {} | 206 ~Test() {} |
| 186 public slots: | 207 public slots: |
| 187 void receive() {} | 208 void receive() {} |
| 188 signals: | 209 signals: |
| 189 void send(); | 210 void send(); |
| 190 }; | 211 }; |
| 191 EOF | 212 EOF |
| 192 | 213 |
| 193 cat > ax_qt_main.$ac_ext << EOF | 214 cat > ax_qt_main.$ac_ext << EOF |
| 194 #include "ax_qt_test.h" | 215 #include "ax_qt_test.h" |
| 195 #include <qapplication.h> | 216 #include <qapplication.h> |
| 196 int main( int argc, char **argv ) | 217 int main( int argc, char **argv ) |
| 197 { | 218 { |
| 198 QApplication app( argc, argv ); | 219 QApplication app( argc, argv ); |
| 199 Test t; | 220 Test t; |
| 200 QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) ); | 221 QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) ); |
| 201 } | 222 } |
| 202 EOF | 223 EOF |
| 203 | 224 |
| 204 ax_cv_qt_test_result="failure" | 225 ax_cv_qt_test_result="failure" |
| 205 ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" | 226 ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" |
| 206 AC_TRY_EVAL(ax_try_1) | 227 AC_TRY_EVAL(ax_try_1) |
| 207 if test x"$ac_status" != x0; then | 228 if test x"$ac_status" != x0; then |
| 208 echo "$ax_err_1" >&AS_MESSAGE_LOG_FD | 229 echo "$ax_err_1" >&AS_MESSAGE_LOG_FD |
| 209 echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD | 230 echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD |
| 210 cat ax_qt_test.h >&AS_MESSAGE_LOG_FD | 231 cat ax_qt_test.h >&AS_MESSAGE_LOG_FD |
| 211 else | 232 else |
| 212 ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" | 233 ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" |
| 213 AC_TRY_EVAL(ax_try_2) | 234 AC_TRY_EVAL(ax_try_2) |
| 214 if test x"$ac_status" != x0; then | 235 if test x"$ac_status" != x0; then |
| 215 echo "$ax_err_2" >&AS_MESSAGE_LOG_FD | 236 echo "$ax_err_2" >&AS_MESSAGE_LOG_FD |
| 216 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD | 237 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD |
| 217 cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD | 238 cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD |
| 218 else | 239 else |
| 219 ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null" | 240 ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null" |
| 220 AC_TRY_EVAL(ax_try_3) | 241 AC_TRY_EVAL(ax_try_3) |
| 221 if test x"$ac_status" != x0; then | 242 if test x"$ac_status" != x0; then |
| 222 echo "$ax_err_3" >&AS_MESSAGE_LOG_FD | 243 echo "$ax_err_3" >&AS_MESSAGE_LOG_FD |
| 223 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD | 244 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD |
| 224 cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD | 245 cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD |
| 225 else | 246 else |
| 226 ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null" | 247 ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null" |
| 227 AC_TRY_EVAL(ax_try_4) | 248 AC_TRY_EVAL(ax_try_4) |
| 228 if test x"$ac_status" != x0; then | 249 if test x"$ac_status" != x0; then |
| 229 echo "$ax_err_4" >&AS_MESSAGE_LOG_FD | 250 echo "$ax_err_4" >&AS_MESSAGE_LOG_FD |
| 230 else | 251 else |
| 231 ax_cv_qt_test_result="success" | 252 ax_cv_qt_test_result="success" |
| 232 fi | 253 fi |
| 233 fi | 254 fi |
| 234 fi | 255 fi |
| 235 fi | 256 fi |
| 236 ])dnl AC_CACHE_VAL ax_cv_qt_test_result | 257 ])dnl AC_CACHE_VAL ax_cv_qt_test_result |
| 237 AC_MSG_RESULT([$ax_cv_qt_test_result]) | 258 AC_MSG_RESULT([$ax_cv_qt_test_result]) |
| 238 if test x"$ax_cv_qt_test_result" = "xfailure"; then | 259 if test x"$ax_cv_qt_test_result" = "xfailure"; then |
| 239 AC_MSG_ERROR([Failed to find matching components of a complete | 260 AC_MSG_ERROR([Failed to find matching components of a complete |
| 240 Qt installation. Try using more options, | 261 Qt installation. Try using more options, |
| 241 see ./configure --help.]) | 262 see ./configure --help.]) |
| 242 fi | 263 fi |
| 243 | 264 |
| 244 rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \ | 265 rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \ |
| 245 ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main | 266 ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main |
| 246 fi | 267 fi |
| 247 ]) | 268 ]) |
