Mercurial > minori
comparison m4/autotroll.m4 @ 250:c130f47f6f48
*: many many changes
e.g. the search page is actually implemented now!
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Sun, 04 Feb 2024 21:17:17 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 249:6b2441c776dd | 250:c130f47f6f48 |
|---|---|
| 1 # Build Qt apps with the autotools (Autoconf/Automake). | |
| 2 # M4 macros. | |
| 3 # | |
| 4 # This file is part of AutoTroll. | |
| 5 # | |
| 6 # Copyright (C) 2006-2018 Benoit Sigoure <benoit.sigoure@lrde.epita.fr> | |
| 7 # Copyright (C) 2012-2023 Werner Lemberg <wl@gnu.org> | |
| 8 # | |
| 9 # AutoTroll is free software; you can redistribute it and/or modify it | |
| 10 # under the terms of the GNU General Public License as published by | |
| 11 # the Free Software Foundation; either version 2 of the License, or | |
| 12 # (at your option) any later version. | |
| 13 # | |
| 14 # This program is distributed in the hope that it will be useful, but | |
| 15 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 # General Public License for more details. | |
| 18 # | |
| 19 # You should have received a copy of the GNU General Public License | |
| 20 # along with this program; if not, write to the Free Software | |
| 21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
| 22 # 02110-1301, USA. | |
| 23 # | |
| 24 # In addition, as a special exception, the copyright holders of | |
| 25 # AutoTroll give you unlimited permission to copy, distribute and | |
| 26 # modify the configure scripts that are the output of Autoconf when | |
| 27 # processing the macros of AutoTroll. You need not follow the terms | |
| 28 # of the GNU General Public License when using or distributing such | |
| 29 # scripts, even though portions of the text of AutoTroll appear in | |
| 30 # them. The GNU General Public License (GPL) does govern all other | |
| 31 # use of the material that constitutes AutoTroll. | |
| 32 # | |
| 33 # This special exception to the GPL applies to versions of AutoTroll | |
| 34 # released by the copyright holders of AutoTroll. Note that people | |
| 35 # who make modified versions of AutoTroll are not obligated to grant | |
| 36 # this special exception for their modified versions; it is their | |
| 37 # choice whether to do so. The GNU General Public License gives | |
| 38 # permission to release a modified version without this exception; | |
| 39 # this exception also makes it possible to release a modified version | |
| 40 # which carries forward this exception. | |
| 41 | |
| 42 # ------------- # | |
| 43 # DOCUMENTATION # | |
| 44 # ------------- # | |
| 45 | |
| 46 # Disclaimer: Tested with Qt 4.2, 4.8, Qt 5.x, and Qt 6 only. | |
| 47 # Feedback welcome. Simply invoke AT_WITH_QT in your configure.ac. | |
| 48 # AT_WITH_QT can take arguments which are documented in depth below. | |
| 49 # The default arguments are equivalent to the default .pro file | |
| 50 # generated by qmake. | |
| 51 # | |
| 52 # Invoking AT_WITH_QT will do the following: | |
| 53 # | |
| 54 # - Add option `--with-qt[=ARG]' to your configure script. Possible | |
| 55 # values for ARG are `yes' (which is the default) and `no' to | |
| 56 # enable and disable Qt support, respectively, or a path to the | |
| 57 # directory which contains the Qt binaries in case you have a | |
| 58 # non-stardard location. | |
| 59 # | |
| 60 # - Add option `--without-qt', which is equivalent to `--with-qt=no'. | |
| 61 # | |
| 62 # - On MacOS, add `-spec macx-g++' or `-spec macx-lang' (if `$CXX | |
| 63 # --version' output contains `clang'). This can be overridden with | |
| 64 # the QMAKESPEC environment variable, for example | |
| 65 # | |
| 66 # QMAKESPEC='macx-clang' ./configure ... | |
| 67 # | |
| 68 # (The QMAKESPEC variable is honoured for non-MacOS builds also.) | |
| 69 # | |
| 70 # - If Qt support is enabled, define C preprocessor macro HAVE_QT. | |
| 71 # | |
| 72 # - Find the programs `qmake', `moc', `uic', and `rcc' and save them | |
| 73 # in the make variables $(QMAKE), $(MOC), $(UIC), and $(RCC). | |
| 74 # | |
| 75 # - Save the path to Qt binaries in $(QT_PATH). | |
| 76 # | |
| 77 # - Find the flags necessary to compile and link Qt, that is: | |
| 78 # | |
| 79 # * $(QT_DEFINES): -D's defined by qmake. | |
| 80 # * $(QT_CFLAGS): CFLAGS as defined by qmake (C?!) | |
| 81 # * $(QT_CXXFLAGS): CXXFLAGS as defined by qmake. | |
| 82 # * $(QT_INCPATH): -I's defined by qmake. | |
| 83 # * $(QT_CPPFLAGS): Same as $(QT_DEFINES) + $(QT_INCPATH). | |
| 84 # * $(QT_LFLAGS): LFLAGS defined by qmake. | |
| 85 # * $(QT_LDFLAGS): Same thing as $(QT_LFLAGS). | |
| 86 # * $(QT_LIBS): LIBS defined by qmake. | |
| 87 # | |
| 88 # - Provide @QT_STATIC_PLUGINS@, which holds some additional C++ | |
| 89 # declarations necessary for linking with static Qt plugins (for | |
| 90 # dynamic Qt builds it contains a dummy typedef declaration | |
| 91 # instead). Use this substitution in a `foo.cpp.in' C++ template | |
| 92 # file or something similar, which must be registered in | |
| 93 # configure.ac's call to AC_CONFIG_FILES so that a proper `foo.cpp' | |
| 94 # file gets created. Then compile and link `foo.cpp' with your | |
| 95 # program in the usual automake way. | |
| 96 # | |
| 97 # NOTE: It is not possible to automatically detect whether a Qt | |
| 98 # release earlier than version 5 is built as a static library! For | |
| 99 # this reason, @QT_STATIC_PLUGINS@ always contains the dummy | |
| 100 # typedef declaration if not using Qt5. | |
| 101 # | |
| 102 # You *MUST* invoke $(MOC) and/or $(UIC) by yourself where necessary. | |
| 103 # AutoTroll provides you with Makerules to ease this; here is a sample | |
| 104 # Makefile.am to use with AutoTroll which builds the code given in | |
| 105 # chapter 7 of the Qt Tutorial | |
| 106 # (http://doc.trolltech.com/4.2/tutorial-t7.html). | |
| 107 # | |
| 108 # ------------------------------------------------------------------------- | |
| 109 # include $(top_srcdir)/build-aux/autotroll.mk | |
| 110 # | |
| 111 # ACLOCAL_AMFLAGS = -I build-aux | |
| 112 # | |
| 113 # bin_PROGRAMS = lcdrange | |
| 114 # lcdrange_SOURCES = $(BUILT_SOURCES) lcdrange.cpp lcdrange.h main.cpp | |
| 115 # lcdrange_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) | |
| 116 # lcdrange_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) | |
| 117 # lcdrange_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS) | |
| 118 # lcdrange_LDADD = $(QT_LIBS) $(LDADD) | |
| 119 # | |
| 120 # BUILT_SOURCES = lcdrange.moc.cpp | |
| 121 # ------------------------------------------------------------------------- | |
| 122 # | |
| 123 # Note that your MOC, UIC, and RCC files *MUST* be listed explicitly | |
| 124 # in BUILT_SOURCES. If you name them properly (e.g. `.moc.cc', | |
| 125 # `.qrc.cc', `.ui.cc' -- of course you can use `.cpp' or `.cxx' or | |
| 126 # `.C' rather than `.cc') AutoTroll will build them automagically for | |
| 127 # you, using implicit rules defined in `autotroll.mk'. | |
| 128 | |
| 129 m4_define([_AUTOTROLL_SERIAL], | |
| 130 [m4_translit([ | |
| 131 # serial 17 | |
| 132 ], [# | |
| 133 ], [])]) | |
| 134 | |
| 135 | |
| 136 m4_ifdef([AX_INSTEAD_IF], | |
| 137 [], | |
| 138 [AC_DEFUN([AX_INSTEAD_IF], | |
| 139 [m4_ifval([$1], | |
| 140 [AC_MSG_WARN([$2]) | |
| 141 [$1]], | |
| 142 [AC_MSG_ERROR([$2])])])]) | |
| 143 | |
| 144 | |
| 145 # AX_PATH_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH]) | |
| 146 # ------------------------------------------------------------------------- | |
| 147 AC_DEFUN([AX_PATH_TOOLS], | |
| 148 [for ax_tool in $2; do | |
| 149 AC_PATH_TOOL([$1], [$ax_tool], [], [$4]) | |
| 150 test -n "$$1" && break | |
| 151 done | |
| 152 m4_ifval([$3], [test -n "$$1" || $1="$3"]) | |
| 153 ]) | |
| 154 | |
| 155 | |
| 156 m4_pattern_forbid([^AT_]) | |
| 157 m4_pattern_forbid([^_AT_]) | |
| 158 | |
| 159 | |
| 160 # AT_WITH_QT([QT_modules], [QT_config], [QT_misc], [RUN-IF-FAILED], [RUN-IF-OK]) | |
| 161 # ------------------------------------------------------------------------------ | |
| 162 # Enable Qt support and add an option --with-qt to the configure | |
| 163 # script. | |
| 164 # | |
| 165 # The QT_modules argument is optional and defines extra modules to | |
| 166 # enable or disable (it's equivalent to the QT variable in .pro | |
| 167 # files). Modules can be specified as follows: | |
| 168 # | |
| 169 # AT_WITH_QT => No argument -> No QT value. | |
| 170 # Qmake sets it to "core gui" by | |
| 171 # default. | |
| 172 # AT_WITH_QT([xml]) => QT += xml | |
| 173 # AT_WITH_QT([+xml]) => QT += xml | |
| 174 # AT_WITH_QT([-gui]) => QT -= gui | |
| 175 # AT_WITH_QT([xml -gui +sql svg]) => QT += xml sql svg | |
| 176 # QT -= gui | |
| 177 # | |
| 178 # The QT_config argument is also optional and follows the same | |
| 179 # convention as QT_modules. Instead of changing the QT variable, it | |
| 180 # changes the CONFIG variable, which is used to tweak configuration | |
| 181 # and compiler options. | |
| 182 # | |
| 183 # The last argument, QT_misc (also optional) will be copied as-is the | |
| 184 # .pro file used to guess how to compile Qt apps. You may use it to | |
| 185 # further tweak the build process of Qt apps if tweaking the QT or | |
| 186 # CONFIG variables isn't enough for you (for example, to control which | |
| 187 # static plugins get used). | |
| 188 # | |
| 189 # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or | |
| 190 # if any problem happens. If this argument is omitted, then | |
| 191 # AC_MSG_ERROR will be called. RUN-IF-OK is arbitrary code to execute | |
| 192 # if Qt was successfully found. | |
| 193 | |
| 194 AC_DEFUN([AT_WITH_QT], | |
| 195 [AC_REQUIRE([AC_CANONICAL_HOST]) | |
| 196 AC_REQUIRE([AC_CANONICAL_BUILD]) | |
| 197 AC_REQUIRE([AC_PROG_CXX]) | |
| 198 | |
| 199 echo "$as_me: this is autotroll.m4[]_AUTOTROLL_SERIAL" \ | |
| 200 >& AS_MESSAGE_LOG_FD | |
| 201 | |
| 202 # This is a hack to get decent flow control with `break'. | |
| 203 for _qt_ignored in once; do | |
| 204 | |
| 205 AC_ARG_WITH([qt], | |
| 206 AS_HELP_STRING([--with-qt@<:@=ARG@:>@], | |
| 207 [Qt support. ARG can be `yes' (the default), `no', | |
| 208 or a path to Qt binaries; if `yes' or empty, | |
| 209 use PATH and some default directories to find Qt binaries])) | |
| 210 | |
| 211 if test x"$with_qt" = x"no"; then | |
| 212 break | |
| 213 else | |
| 214 AC_DEFINE([HAVE_QT],[1], | |
| 215 [Define if the Qt framework is available.]) | |
| 216 fi | |
| 217 | |
| 218 if test x"$with_qt" = x"yes"; then | |
| 219 QT_PATH= | |
| 220 else | |
| 221 QT_PATH=$with_qt | |
| 222 fi | |
| 223 | |
| 224 # Find Qt. | |
| 225 AC_ARG_VAR([QT_PATH], | |
| 226 [path to Qt binaries]) | |
| 227 QT_TOOL_PATH=$QT_PATH:$PATH | |
| 228 | |
| 229 # Find qmake. | |
| 230 AC_ARG_VAR([QMAKE], | |
| 231 [Qt Makefile generator command]) | |
| 232 AX_PATH_TOOLS([QMAKE], | |
| 233 [qmake qmake-qt5 qmake-qt4 qmake-qt3], | |
| 234 [missing], | |
| 235 [$QT_TOOL_PATH]) | |
| 236 if test x"$QMAKE" = xmissing; then | |
| 237 if test x"$with_qt" = "x"; then | |
| 238 with_qt="no" | |
| 239 else | |
| 240 AX_INSTEAD_IF([$4], | |
| 241 [Cannot find qmake. Try --with-qt=PATH.]) | |
| 242 fi | |
| 243 break | |
| 244 fi | |
| 245 | |
| 246 # Find moc (Meta Object Compiler). | |
| 247 AC_ARG_VAR([MOC], | |
| 248 [Qt Meta Object Compiler command]) | |
| 249 AX_PATH_TOOLS([MOC], | |
| 250 [moc moc-qt5 moc-qt4 moc-qt3], | |
| 251 [missing], | |
| 252 [$QT_TOOL_PATH]) | |
| 253 if test x"$MOC" = xmissing; then | |
| 254 AX_INSTEAD_IF([$4], | |
| 255 [Cannot find moc (Meta Object Compiler). Try --with-qt=PATH.]) | |
| 256 break | |
| 257 fi | |
| 258 | |
| 259 # Find uic (User Interface Compiler). | |
| 260 AC_ARG_VAR([UIC], | |
| 261 [Qt User Interface Compiler command]) | |
| 262 AX_PATH_TOOLS([UIC], | |
| 263 [uic uic-qt5 uic-qt4 uic-qt3 uic3], | |
| 264 [missing], | |
| 265 [$QT_TOOL_PATH]) | |
| 266 if test x"$UIC" = xmissing; then | |
| 267 AX_INSTEAD_IF([$4], | |
| 268 [Cannot find uic (User Interface Compiler). Try --with-qt=PATH.]) | |
| 269 break | |
| 270 fi | |
| 271 | |
| 272 # Find rcc (Qt Resource Compiler). | |
| 273 AC_ARG_VAR([RCC], | |
| 274 [Qt Resource Compiler command]) | |
| 275 AX_PATH_TOOLS([RCC], | |
| 276 [rcc rcc-qt5], | |
| 277 [missing], | |
| 278 [$QT_TOOL_PATH]) | |
| 279 if test x"$RCC" = xmissing; then | |
| 280 AC_MSG_WARN( | |
| 281 [Cannot find rcc (Qt Resource Compiler). Try --with-qt=PATH.]) | |
| 282 fi | |
| 283 | |
| 284 AC_ARG_VAR([LUPDATE], | |
| 285 [Qt Linguist updater command]) | |
| 286 AX_PATH_TOOLS([LUPDATE], | |
| 287 [lupdate lupdate-qt5 lrelease-qt6], | |
| 288 [missing], | |
| 289 [$QT_TOOL_PATH]) | |
| 290 if test "x$LUPDATE" = "xmissing"; then | |
| 291 AC_MSG_WARN( | |
| 292 [Cannot find lupdate (Qt Linguist updater). Try --with-qt=PATH.]) | |
| 293 fi | |
| 294 | |
| 295 AC_ARG_VAR([LRELEASE], | |
| 296 [Qt Linguist compiler command]) | |
| 297 AX_PATH_TOOLS([LRELEASE], | |
| 298 [lrelease lrelease-qt5 lrelease-qt6], | |
| 299 [missing], | |
| 300 [$QT_TOOL_PATH]) | |
| 301 if test "x$LRELEASE" = "xmissing"; then | |
| 302 AC_MSG_WARN( | |
| 303 [Cannot find lrelease (Qt Linguist compiler). Try --with-qt=PATH.]) | |
| 304 fi | |
| 305 | |
| 306 AC_MSG_CHECKING([whether host operating system is Darwin]) | |
| 307 at_darwin=no | |
| 308 at_qmake_args= | |
| 309 case $host_os in | |
| 310 dnl ( | |
| 311 darwin*) | |
| 312 at_darwin=yes | |
| 313 ;; | |
| 314 esac | |
| 315 AC_MSG_RESULT([$at_darwin]) | |
| 316 | |
| 317 AC_MSG_CHECKING([whether QMAKESPEC environment variable is set]) | |
| 318 if test x"$QMAKESPEC" = x; then | |
| 319 if test x"$at_darwin" = xyes; then | |
| 320 if $CXX --version | grep -q -i clang; then | |
| 321 at_qmake_args='-spec macx-clang' | |
| 322 else | |
| 323 at_qmake_args='-spec macx-g++' | |
| 324 fi | |
| 325 AC_MSG_RESULT([no, using $at_qmake_args]) | |
| 326 else | |
| 327 AC_MSG_RESULT([no]) | |
| 328 fi | |
| 329 else | |
| 330 AC_MSG_RESULT([yes, using $QMAKESPEC]) | |
| 331 fi | |
| 332 | |
| 333 # If we don't know the path to Qt, guess it from the path to | |
| 334 # qmake. | |
| 335 if test x"$QT_PATH" = x; then | |
| 336 QT_PATH=`dirname "$QMAKE"` | |
| 337 fi | |
| 338 if test x"$QT_PATH" = x; then | |
| 339 AX_INSTEAD_IF([$4], | |
| 340 [Cannot find your Qt installation. Try --with-qt=PATH.]) | |
| 341 break | |
| 342 fi | |
| 343 AC_SUBST([QT_PATH]) | |
| 344 | |
| 345 # Get ready to build a test-app with Qt. | |
| 346 if mkdir conftest.dir \ | |
| 347 && cd conftest.dir; then | |
| 348 : | |
| 349 else | |
| 350 AX_INSTEAD_IF([$4], | |
| 351 [Cannot mkdir conftest.dir or cd to that directory.]) | |
| 352 break | |
| 353 fi | |
| 354 | |
| 355 cat >conftest.h <<_ASEOF | |
| 356 | |
| 357 #include <QObject> | |
| 358 | |
| 359 class Foo: public QObject | |
| 360 { | |
| 361 Q_OBJECT; | |
| 362 public: | |
| 363 Foo(); | |
| 364 ~Foo() {} | |
| 365 public Q_SLOTS: | |
| 366 void setValue(int value); | |
| 367 Q_SIGNALS: | |
| 368 void valueChanged(int newValue); | |
| 369 private: | |
| 370 int value_; | |
| 371 }; | |
| 372 | |
| 373 _ASEOF | |
| 374 | |
| 375 cat >conftest.cpp <<_ASEOF | |
| 376 | |
| 377 #include "conftest.h" | |
| 378 | |
| 379 Foo::Foo() | |
| 380 : value_ (42) | |
| 381 { | |
| 382 connect(this, SIGNAL(valueChanged(int)), | |
| 383 this, SLOT(setValue(int))); | |
| 384 } | |
| 385 | |
| 386 void Foo::setValue(int value) | |
| 387 { | |
| 388 value_ = value; | |
| 389 } | |
| 390 | |
| 391 int main() | |
| 392 { | |
| 393 Foo f; | |
| 394 } | |
| 395 | |
| 396 _ASEOF | |
| 397 | |
| 398 if $QMAKE -project; then | |
| 399 : | |
| 400 else | |
| 401 AX_INSTEAD_IF([$4], | |
| 402 [Calling $QMAKE -project failed.]) | |
| 403 break | |
| 404 fi | |
| 405 | |
| 406 # Find the .pro file generated by qmake. | |
| 407 pro_file=conftest.dir.pro | |
| 408 test -f $pro_file || pro_file=`echo *.pro` | |
| 409 if test -f "$pro_file"; then | |
| 410 : | |
| 411 else | |
| 412 AX_INSTEAD_IF([$4], | |
| 413 [Can't find the .pro file generated by Qmake.]) | |
| 414 break | |
| 415 fi | |
| 416 | |
| 417 dnl This is for Qt5; for Qt4 it does nothing special. | |
| 418 _AT_TWEAK_PRO_FILE([QT], [+widgets]) | |
| 419 | |
| 420 dnl Undocumented qmake: always use absolute paths. | |
| 421 dnl Defaults to 4. | |
| 422 _AT_TWEAK_PRO_FILE([QMAKE_PROJECT_DEPTH], [0]) | |
| 423 | |
| 424 dnl Tweak the value of QT in the .pro file if we have a first | |
| 425 dnl argument. | |
| 426 m4_ifval([$1], | |
| 427 [_AT_TWEAK_PRO_FILE([QT], [$1])]) | |
| 428 | |
| 429 dnl Tweak the value of CONFIG in the .pro file if we have a | |
| 430 dnl second argument. | |
| 431 m4_ifval([$2], | |
| 432 [_AT_TWEAK_PRO_FILE([CONFIG], [$2])]) | |
| 433 | |
| 434 m4_ifval([$3], | |
| 435 [ # Add the extra-settings the user wants to set in the .pro | |
| 436 # file. | |
| 437 echo "$3" >>"$pro_file" | |
| 438 ]) | |
| 439 | |
| 440 echo "$as_me:$LINENO: Invoking $QMAKE on $pro_file" \ | |
| 441 >& AS_MESSAGE_LOG_FD | |
| 442 sed 's/^/| /' "$pro_file" >& AS_MESSAGE_LOG_FD | |
| 443 | |
| 444 if $QMAKE $at_qmake_args; then | |
| 445 : | |
| 446 else | |
| 447 AX_INSTEAD_IF([$4], | |
| 448 [Calling $QMAKE $at_qmake_args failed.]) | |
| 449 break | |
| 450 fi | |
| 451 | |
| 452 # Try to compile a simple Qt app. | |
| 453 AC_CACHE_CHECK([whether we can build a simple Qt application], | |
| 454 [at_cv_qt_build], | |
| 455 [at_cv_qt_build=ko | |
| 456 : ${MAKE=make} | |
| 457 | |
| 458 if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then | |
| 459 at_cv_qt_build='ok, looks like Qt 4, Qt 5, or Qt 6' | |
| 460 else | |
| 461 echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> instead" \ | |
| 462 >& AS_MESSAGE_LOG_FD | |
| 463 sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h \ | |
| 464 && mv tmp.h conftest.h | |
| 465 if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then | |
| 466 at_cv_qt_build='ok, looks like Qt 3' | |
| 467 else | |
| 468 # Sometimes (such as on Debian) build will fail because Qt | |
| 469 # hasn't been installed in debug mode and qmake tries (by | |
| 470 # default) to build apps in debug mode => Try again in | |
| 471 # release mode. | |
| 472 echo "$as_me:$LINENO: Build failed, trying to enforce release mode" \ | |
| 473 >& AS_MESSAGE_LOG_FD | |
| 474 | |
| 475 _AT_TWEAK_PRO_FILE([CONFIG], [+release]) | |
| 476 | |
| 477 sed 's/<qobject.h>/<QObject>/' conftest.h > tmp.h \ | |
| 478 && mv tmp.h conftest.h | |
| 479 if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then | |
| 480 at_cv_qt_build='ok, looks like Qt 4 or Qt 5, release mode forced' | |
| 481 else | |
| 482 echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> instead" \ | |
| 483 >& AS_MESSAGE_LOG_FD | |
| 484 sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h \ | |
| 485 && mv tmp.h conftest.h | |
| 486 if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then | |
| 487 at_cv_qt_build='ok, looks like Qt 3, release mode forced' | |
| 488 else | |
| 489 at_cv_qt_build=ko | |
| 490 echo "$as_me:$LINENO: failed program was:" \ | |
| 491 >& AS_MESSAGE_LOG_FD | |
| 492 sed 's/^/| /' conftest.h >& AS_MESSAGE_LOG_FD | |
| 493 echo "$as_me:$LINENO: failed program was:" \ | |
| 494 >& AS_MESSAGE_LOG_FD | |
| 495 sed 's/^/| /' conftest.cpp >& AS_MESSAGE_LOG_FD | |
| 496 fi # if make with Qt3-style #include and release mode forced. | |
| 497 fi # if make with Qt4/5-style #include and release mode forced. | |
| 498 fi # if make with Qt3-style #include. | |
| 499 fi # if make with Qt4/5-style #include. | |
| 500 ])dnl end: AC_CACHE_CHECK(at_cv_qt_build) | |
| 501 | |
| 502 if test x"$at_cv_qt_build" = xko; then | |
| 503 AX_INSTEAD_IF([$4], | |
| 504 [Cannot build a test Qt program]) | |
| 505 cd .. | |
| 506 break | |
| 507 fi | |
| 508 | |
| 509 QT_VERSION_MAJOR=`echo "$at_cv_qt_build" | sed 's/[[^0-9]]*//g'` | |
| 510 AC_SUBST([QT_VERSION_MAJOR]) | |
| 511 | |
| 512 # This sed filter is applied after an expression of the form | |
| 513 # /^FOO.*=/!d; it starts by removing the beginning of the line | |
| 514 # (using the empty regular expression //, which repeats the last | |
| 515 # regular expression match), removing references to SUBLIBS, | |
| 516 # removing unnecessary whitespace at the beginning, then prefixing | |
| 517 # our exported variables with QT_. Note that `LDFLAGS' is | |
| 518 # intentionally omitted. | |
| 519 qt_sed_filter='s///; | |
| 520 s/$(SUBLIBS)//g; | |
| 521 s/^ *//; | |
| 522 s/\$(DEFINES)/$(QT_DEFINES)/g; | |
| 523 s/\$(CFLAGS)/$(QT_CFLAGS)/g; | |
| 524 s/\$(CXXFLAGS)/$(QT_CXXFLAGS)/g; | |
| 525 s/\$(INCPATH)/$(QT_INCPATH)/g; | |
| 526 s/\$(CPPFLAGS)/$(QT_CPPFLAGS)/g; | |
| 527 s/\$(LFLAGS)/$(QT_LFLAGS)/g; | |
| 528 s/\$(LIBS)/$(QT_LIBS)/g' | |
| 529 | |
| 530 # Find the Makefile (qmake happens to generate a fake Makefile | |
| 531 # which invokes a Makefile.Debug or Makefile.Release). If we | |
| 532 # have both, we'll pick the Makefile.Release. The reason is that | |
| 533 # this release uses -Os and debug -g. We can override -Os by | |
| 534 # passing another -O but we usually don't override -g. | |
| 535 if test -f Makefile.Release; then | |
| 536 at_mfile='Makefile.Release' | |
| 537 else | |
| 538 at_mfile='Makefile' | |
| 539 fi | |
| 540 if test -f $at_mfile; then | |
| 541 : | |
| 542 else | |
| 543 AX_INSTEAD_IF([$4], | |
| 544 [Cannot find the Makefile generated by qmake.]) | |
| 545 cd .. | |
| 546 break | |
| 547 fi | |
| 548 | |
| 549 # Find the DEFINES of Qt (should have been named CPPFLAGS). | |
| 550 AC_CACHE_CHECK([for the DEFINES to use with Qt], | |
| 551 [at_cv_env_QT_DEFINES], | |
| 552 [at_cv_env_QT_DEFINES=`sed "/^DEFINES@<:@^A-Z=@:>@*=/!d; | |
| 553 $qt_sed_filter" $at_mfile`]) | |
| 554 AC_SUBST([QT_DEFINES], | |
| 555 [$at_cv_env_QT_DEFINES]) | |
| 556 | |
| 557 # Find the CFLAGS of Qt. (We can use Qt in C?!) | |
| 558 AC_CACHE_CHECK([for the CFLAGS to use with Qt], | |
| 559 [at_cv_env_QT_CFLAGS], | |
| 560 [at_cv_env_QT_CFLAGS=`sed "/^CFLAGS@<:@^A-Z=@:>@*=/!d; | |
| 561 $qt_sed_filter" $at_mfile`]) | |
| 562 AC_SUBST([QT_CFLAGS], | |
| 563 [$at_cv_env_QT_CFLAGS]) | |
| 564 | |
| 565 # Find the CXXFLAGS of Qt. | |
| 566 AC_CACHE_CHECK([for the CXXFLAGS to use with Qt], | |
| 567 [at_cv_env_QT_CXXFLAGS], | |
| 568 [at_cv_env_QT_CXXFLAGS=`sed "/^CXXFLAGS@<:@^A-Z=@:>@*=/!d; | |
| 569 $qt_sed_filter" $at_mfile`]) | |
| 570 AC_SUBST([QT_CXXFLAGS], | |
| 571 [$at_cv_env_QT_CXXFLAGS]) | |
| 572 | |
| 573 # Find the INCPATH of Qt. | |
| 574 AC_CACHE_CHECK([for the INCPATH to use with Qt], | |
| 575 [at_cv_env_QT_INCPATH], | |
| 576 [at_cv_env_QT_INCPATH=`sed "/^INCPATH@<:@^A-Z=@:>@*=/!d; | |
| 577 $qt_sed_filter" $at_mfile`]) | |
| 578 AC_SUBST([QT_INCPATH], | |
| 579 [$at_cv_env_QT_INCPATH]) | |
| 580 | |
| 581 AC_SUBST([QT_CPPFLAGS], | |
| 582 ["$at_cv_env_QT_DEFINES $at_cv_env_QT_INCPATH"]) | |
| 583 | |
| 584 # Find the LFLAGS of Qt (should have been named LDFLAGS). | |
| 585 AC_CACHE_CHECK([for the LDFLAGS to use with Qt], | |
| 586 [at_cv_env_QT_LDFLAGS], | |
| 587 [at_cv_env_QT_LDFLAGS=`sed "/^LFLAGS@<:@^A-Z=@:>@*=/!d; | |
| 588 $qt_sed_filter" $at_mfile`]) | |
| 589 AC_SUBST([QT_LFLAGS], | |
| 590 [$at_cv_env_QT_LDFLAGS]) | |
| 591 AC_SUBST([QT_LDFLAGS], | |
| 592 [$at_cv_env_QT_LDFLAGS]) | |
| 593 | |
| 594 # Find the LIBS of Qt. | |
| 595 AC_CACHE_CHECK([for the LIBS to use with Qt], | |
| 596 [at_cv_env_QT_LIBS], | |
| 597 [at_cv_env_QT_LIBS=`sed "/^LIBS@<:@^A-Z@:>@*=/!d; | |
| 598 $qt_sed_filter" $at_mfile` | |
| 599 if test x$at_darwin = xyes; then | |
| 600 # Fix QT_LIBS: as of today Libtool (GNU Libtool 1.5.23a) | |
| 601 # doesn't handle -F properly. The "bug" has been fixed on 22 | |
| 602 # October 2006 by Peter O'Gorman but we provide backward | |
| 603 # compatibility here. | |
| 604 at_cv_env_QT_LIBS=`echo "$at_cv_env_QT_LIBS" \ | |
| 605 | sed 's/^-F/-Wl,-F/; | |
| 606 s/ -F/ -Wl,-F/g'` | |
| 607 fi]) | |
| 608 AC_SUBST([QT_LIBS], | |
| 609 [$at_cv_env_QT_LIBS]) | |
| 610 | |
| 611 # We can't use AC_CACHE_CHECK for data that contains newlines. | |
| 612 AC_MSG_CHECKING([for necessary static plugin code]) | |
| 613 # find static plugin data generated by qmake | |
| 614 if test -f conftest.dir_plugin_import.cpp; then | |
| 615 QT_STATIC_PLUGINS=`cat conftest.dir_plugin_import.cpp` | |
| 616 else | |
| 617 QT_STATIC_PLUGINS="\ | |
| 618 // We have Qt earlier than version 5 or a dynamic build. | |
| 619 // Provide dummy typedef to avoid empty source code. | |
| 620 typedef int _qt_not_a_static_build;" | |
| 621 fi | |
| 622 AC_SUBST([QT_STATIC_PLUGINS]) | |
| 623 AM_SUBST_NOTMAKE([QT_STATIC_PLUGINS]) | |
| 624 AC_MSG_RESULT([$QT_STATIC_PLUGINS]) | |
| 625 | |
| 626 cd .. && rm -rf conftest.dir | |
| 627 | |
| 628 # Run the user code | |
| 629 $5 | |
| 630 | |
| 631 done # end hack (useless FOR to be able to use break) | |
| 632 ]) | |
| 633 | |
| 634 | |
| 635 # AT_REQUIRE_QT_VERSION(QT_version, [RUN-IF-FAILED], [RUN-IF-OK]) | |
| 636 # --------------------------------------------------------------- | |
| 637 # Check (using qmake) that Qt's version "matches" QT_version. Must be | |
| 638 # run *AFTER* AT_WITH_QT. Requires autoconf 2.60. | |
| 639 # | |
| 640 # This macro is ignored if Qt support has been disabled (using | |
| 641 # `--with-qt=no' or `--without-qt'). | |
| 642 # | |
| 643 # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or | |
| 644 # if any problem happens. If this argument is omitted, then | |
| 645 # AC_MSG_ERROR will be called. RUN-IF-OK is arbitrary code to execute | |
| 646 # if Qt was successfully found. | |
| 647 # | |
| 648 # This macro provides the Qt version in $(QT_VERSION). | |
| 649 | |
| 650 AC_DEFUN([AT_REQUIRE_QT_VERSION], | |
| 651 [AC_PREREQ([2.60]) | |
| 652 | |
| 653 # This is a hack to get decent flow control with `break'. | |
| 654 for _qt_ignored in once; do | |
| 655 | |
| 656 if test x"$with_qt" = x"no"; then | |
| 657 break | |
| 658 fi | |
| 659 | |
| 660 if test x"$QMAKE" = x; then | |
| 661 AX_INSTEAD_IF([$2], | |
| 662 [\$QMAKE is empty. Did you invoke AT@&t@_WITH_QT before AT@&t@_REQUIRE_QT_VERSION?]) | |
| 663 break | |
| 664 fi | |
| 665 | |
| 666 AC_CACHE_CHECK([for Qt's version], | |
| 667 [at_cv_QT_VERSION], | |
| 668 [echo "$as_me:$LINENO: Running $QMAKE --version:" \ | |
| 669 >& AS_MESSAGE_LOG_FD | |
| 670 $QMAKE --version >& AS_MESSAGE_LOG_FD 2>&1 | |
| 671 qmake_version_sed=['/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/!d;s//\1/'] | |
| 672 at_cv_QT_VERSION=`$QMAKE --version 2>&1 \ | |
| 673 | sed "$qmake_version_sed"`]) | |
| 674 if test x"$at_cv_QT_VERSION" = x; then | |
| 675 AX_INSTEAD_IF([$2], | |
| 676 [Cannot detect Qt's version.]) | |
| 677 break | |
| 678 fi | |
| 679 AC_SUBST([QT_VERSION], | |
| 680 [$at_cv_QT_VERSION]) | |
| 681 AS_VERSION_COMPARE([$QT_VERSION], [$1], | |
| 682 [AX_INSTEAD_IF([$2], | |
| 683 [This package requires Qt $1 or above.]) | |
| 684 break]) | |
| 685 | |
| 686 # Run the user code | |
| 687 $3 | |
| 688 | |
| 689 done # end hack (useless FOR to be able to use break) | |
| 690 ]) | |
| 691 | |
| 692 | |
| 693 # _AT_TWEAK_PRO_FILE(QT_VAR, VALUE) | |
| 694 # --------------------------------- | |
| 695 # @internal. Tweak the variable QT_VAR in the .pro file. VALUE is an | |
| 696 # IFS-separated list of values, and each value is rewritten as | |
| 697 # follows: | |
| 698 # | |
| 699 # +value => QT_VAR += value | |
| 700 # -value => QT_VAR -= value | |
| 701 # value => QT_VAR += value | |
| 702 | |
| 703 AC_DEFUN([_AT_TWEAK_PRO_FILE], | |
| 704 [ # Tweak the value of $1 in the .pro file for $2. | |
| 705 qt_conf='' | |
| 706 for at_mod in $2; do | |
| 707 at_mod=`echo "$at_mod" | sed 's/^-//; tough | |
| 708 s/^+//; beef | |
| 709 :ough | |
| 710 s/^/$1 -= /;n | |
| 711 :eef | |
| 712 s/^/$1 += /'` | |
| 713 qt_conf="\ | |
| 714 $qt_conf | |
| 715 $at_mod" | |
| 716 done | |
| 717 echo "$qt_conf" | sed 1d >>"$pro_file" | |
| 718 ]) | |
| 719 | |
| 720 # eof |
