comparison m4/m4_ax_have_qt.m4 @ 240:6ffe42286978

m4: use different method for CXXFLAGS
author Paper <paper@paper.us.eu.org>
date Fri, 19 Jan 2024 13:47:56 -0500
parents a7d0d543b334
children 06d6c351925c
comparison
equal deleted inserted replaced
239:cae61340cc86 240:6ffe42286978
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 am_have_qt_makefile_cxxflags="$am_have_qt_dir/cxxm"
85 cat > $am_have_qt_pro << EOF 86 am_have_qt_makefile_libs="$am_have_qt_dir/libsm"
87 # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt
88 cat > $am_have_qt_pro << EOF
86 win32 { 89 win32 {
87 CONFIG -= debug_and_release 90 CONFIG -= debug_and_release
88 CONFIG += release 91 CONFIG += release
92 }
93 mac {
94 CONFIG += sdk_no_version_check
89 } 95 }
90 # commented out all the modules we don't use 96 # commented out all the modules we don't use
91 # - paper 97 # - paper
92 #qtHaveModule(axcontainer): QT += axcontainer 98 #qtHaveModule(axcontainer): QT += axcontainer
93 #qtHaveModule(axserver): QT += axserver 99 #qtHaveModule(axserver): QT += axserver
116 #qtHaveModule(uitools): QT += uitools 122 #qtHaveModule(uitools): QT += uitools
117 #qtHaveModule(webkit): QT += webkit 123 #qtHaveModule(webkit): QT += webkit
118 #qtHaveModule(webkitwidgets): QT += webkitwidgets 124 #qtHaveModule(webkitwidgets): QT += webkitwidgets
119 #qtHaveModule(xml): QT += xml 125 #qtHaveModule(xml): QT += xml
120 #qtHaveModule(xmlpatterns): QT += xmlpatterns 126 #qtHaveModule(xmlpatterns): QT += xmlpatterns
121 qtHaveModule(widgets): QT += widgets 127 qtHaveModule(widgets): QT += widgets
122 percent.target = % 128 percent.target = %
123 percent.commands = @echo -n "\$(\$(@))\ " 129 percent.commands = @echo -n "\$(\$(@))\ "
124 QMAKE_EXTRA_TARGETS += percent 130 QMAKE_EXTRA_TARGETS += percent
125 EOF 131 EOF
126 $QMAKE $am_have_qt_pro -o $am_have_qt_makefile 132 cat > $am_have_qt_makefile_cxxflags << EOF
127 QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile CXXFLAGS INCPATH` 133 include $am_have_qt_makefile
128 QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile LIBS` 134
129 rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile 135 VAR:
130 rmdir $am_have_qt_dir 136 @echo \$(CXXFLAGS) \$(INCPATH)
131 137 EOF
132 # Look for specific tools in $PATH 138 cat > $am_have_qt_makefile_libs << EOF
133 QT_MOC=`which moc$am_have_qt_qmexe_suff` 139 include $am_have_qt_makefile
134 QT_UIC=`which uic$am_have_qt_qmexe_suff` 140
135 QT_RCC=`which rcc$am_have_qt_qmexe_suff` 141 VAR:
136 QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff` 142 @echo \$(LIBS)
137 QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff` 143 EOF
138 144 $QMAKE "$am_have_qt_pro" -o "$am_have_qt_makefile"
139 # Get Qt version from qmake 145 QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile_cxxflags VAR`
140 QT_DIR=`$QMAKE --version | grep -o -E /.+` 146 QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile_libs VAR`
141 147 rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile $am_have_qt_makefile_cxxflags $am_have_qt_makefile_libs
142 # All variables are defined, report the result 148 rmdir $am_have_qt_dir
143 AC_MSG_RESULT([$have_qt: 149
144 QT_CXXFLAGS=$QT_CXXFLAGS 150 # Look for specific tools in $PATH
145 QT_DIR=$QT_DIR 151 QT_MOC=`which moc$am_have_qt_qmexe_suff`
146 QT_LIBS=$QT_LIBS 152 QT_UIC=`which uic$am_have_qt_qmexe_suff`
147 QT_UIC=$QT_UIC 153 QT_RCC=`which rcc$am_have_qt_qmexe_suff`
148 QT_MOC=$QT_MOC 154 QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff`
149 QT_RCC=$QT_RCC 155 QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff`
150 QT_LRELEASE=$QT_LRELEASE 156
151 QT_LUPDATE=$QT_LUPDATE]) 157 # Get Qt version from qmake
152 else 158 QT_DIR=`$QMAKE --version | grep -o -E /.+`
153 # Qt was not found 159
154 have_qt=no 160 # All variables are defined, report the result
155 QT_CXXFLAGS= 161 AC_MSG_RESULT([$have_qt:
156 QT_DIR= 162 QT_CXXFLAGS=$QT_CXXFLAGS
157 QT_LIBS= 163 QT_DIR=$QT_DIR
158 QT_UIC= 164 QT_LIBS=$QT_LIBS
159 QT_MOC= 165 QT_UIC=$QT_UIC
160 QT_RCC= 166 QT_MOC=$QT_MOC
161 QT_LRELEASE= 167 QT_RCC=$QT_RCC
162 QT_LUPDATE= 168 QT_LRELEASE=$QT_LRELEASE
163 AC_MSG_RESULT($have_qt) 169 QT_LUPDATE=$QT_LUPDATE])
164 fi 170 else
165 AC_SUBST(QT_CXXFLAGS) 171 # Qt was not found
166 AC_SUBST(QT_DIR) 172 have_qt=no
167 AC_SUBST(QT_LIBS) 173 QT_CXXFLAGS=
168 AC_SUBST(QT_UIC) 174 QT_DIR=
169 AC_SUBST(QT_MOC) 175 QT_LIBS=
170 AC_SUBST(QT_RCC) 176 QT_UIC=
171 AC_SUBST(QT_LRELEASE) 177 QT_MOC=
172 AC_SUBST(QT_LUPDATE) 178 QT_RCC=
173 AC_SUBST(QMAKE) 179 QT_LRELEASE=
174 180 QT_LUPDATE=
175 #### Being paranoid: 181 AC_MSG_RESULT($have_qt)
176 if test x"$have_qt" = xyes; then 182 fi
177 AC_MSG_CHECKING(correct functioning of Qt installation) 183 AC_SUBST(QT_CXXFLAGS)
178 AC_CACHE_VAL(ax_cv_qt_test_result, 184 AC_SUBST(QT_DIR)
179 [ 185 AC_SUBST(QT_LIBS)
180 cat > ax_qt_test.h << EOF 186 AC_SUBST(QT_UIC)
187 AC_SUBST(QT_MOC)
188 AC_SUBST(QT_RCC)
189 AC_SUBST(QT_LRELEASE)
190 AC_SUBST(QT_LUPDATE)
191 AC_SUBST(QMAKE)
192
193 #### Being paranoid:
194 if test x"$have_qt" = xyes; then
195 AC_MSG_CHECKING(correct functioning of Qt installation)
196 AC_CACHE_VAL(ax_cv_qt_test_result,
197 [
198 cat > ax_qt_test.h << EOF
181 #include <qobject.h> 199 #include <qobject.h>
182 class Test : public QObject 200 class Test : public QObject
183 { 201 {
184 Q_OBJECT 202 Q_OBJECT
185 public: 203 public:
186 Test() {} 204 Test() {}
187 ~Test() {} 205 ~Test() {}
188 public slots: 206 public slots:
189 void receive() {} 207 void receive() {}
190 signals: 208 signals:
191 void send(); 209 void send();
192 }; 210 };
193 EOF 211 EOF
194 212
195 cat > ax_qt_main.$ac_ext << EOF 213 cat > ax_qt_main.$ac_ext << EOF
196 #include "ax_qt_test.h" 214 #include "ax_qt_test.h"
197 #include <qapplication.h> 215 #include <qapplication.h>
198 int main( int argc, char **argv ) 216 int main( int argc, char **argv )
199 { 217 {
200 QApplication app( argc, argv ); 218 QApplication app( argc, argv );
201 Test t; 219 Test t;
202 QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) ); 220 QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
203 } 221 }
204 EOF 222 EOF
205 223
206 ax_cv_qt_test_result="failure" 224 ax_cv_qt_test_result="failure"
207 ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" 225 ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
208 AC_TRY_EVAL(ax_try_1) 226 AC_TRY_EVAL(ax_try_1)
209 if test x"$ac_status" != x0; then 227 if test x"$ac_status" != x0; then
210 echo "$ax_err_1" >&AS_MESSAGE_LOG_FD 228 echo "$ax_err_1" >&AS_MESSAGE_LOG_FD
211 echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD 229 echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD
212 cat ax_qt_test.h >&AS_MESSAGE_LOG_FD 230 cat ax_qt_test.h >&AS_MESSAGE_LOG_FD
213 else 231 else
214 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" 232 ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >AS_MESSAGE_LOG_FD 2>&1"
215 AC_TRY_EVAL(ax_try_2) 233 AC_TRY_EVAL(ax_try_2)
216 if test x"$ac_status" != x0; then 234 if test x"$ac_status" != x0; then
217 echo "$ax_err_2" >&AS_MESSAGE_LOG_FD 235 echo "$ax_err_2" >&AS_MESSAGE_LOG_FD
218 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD 236 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
219 cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD 237 cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD
220 else 238 else
221 ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null" 239 ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null"
222 AC_TRY_EVAL(ax_try_3) 240 AC_TRY_EVAL(ax_try_3)
223 if test x"$ac_status" != x0; then 241 if test x"$ac_status" != x0; then
224 echo "$ax_err_3" >&AS_MESSAGE_LOG_FD 242 echo "$ax_err_3" >&AS_MESSAGE_LOG_FD
225 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD 243 echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
226 cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD 244 cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD
227 else 245 else
228 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" 246 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"
229 AC_TRY_EVAL(ax_try_4) 247 AC_TRY_EVAL(ax_try_4)
230 if test x"$ac_status" != x0; then 248 if test x"$ac_status" != x0; then
231 echo "$ax_err_4" >&AS_MESSAGE_LOG_FD 249 echo "$ax_err_4" >&AS_MESSAGE_LOG_FD
232 else 250 else
233 ax_cv_qt_test_result="success" 251 ax_cv_qt_test_result="success"
234 fi 252 fi
235 fi 253 fi
236 fi 254 fi
237 fi 255 fi
238 ])dnl AC_CACHE_VAL ax_cv_qt_test_result 256 ])dnl AC_CACHE_VAL ax_cv_qt_test_result
239 AC_MSG_RESULT([$ax_cv_qt_test_result]) 257 AC_MSG_RESULT([$ax_cv_qt_test_result])
240 if test x"$ax_cv_qt_test_result" = "xfailure"; then 258 if test x"$ax_cv_qt_test_result" = "xfailure"; then
241 AC_MSG_ERROR([Failed to find matching components of a complete 259 AC_MSG_ERROR([Failed to find matching components of a complete
242 Qt installation. Try using more options, 260 Qt installation. Try using more options,
243 see ./configure --help.]) 261 see ./configure --help.])
244 fi 262 fi
245 263
246 rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \ 264 rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \
247 ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main 265 ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main
248 fi 266 fi
249 ]) 267 ])