Use macros that are always available, in dummy project.
[autotroll.git] / build-aux / autotroll.m4
blobe5cb25ecf174637e4d5b1c02c931cc92898e01bc
1 # Build Qt apps with the autotools (Autoconf/Automake).
2 # M4 macros.
3 # This file is part of AutoTroll.
4 # Copyright (C) 2006  Benoit Sigoure <benoit.sigoure@lrde.epita.fr>
6 # AutoTroll is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 # USA.
21 # In addition, as a special exception, the copyright holders of AutoTroll
22 # give you unlimited permission to copy, distribute and modify the configure
23 # scripts that are the output of Autoconf when processing the macros of
24 # AutoTroll.  You need not follow the terms of the GNU General Public License
25 # when using or distributing such scripts, even though portions of the text of
26 # AutoTroll appear in them. The GNU General Public License (GPL) does govern
27 # all other use of the material that constitutes AutoTroll.
29 # This special exception to the GPL applies to versions of AutoTroll
30 # released by the copyright holders of AutoTroll.  Note that people who make
31 # modified versions of AutoTroll are not obligated to grant this special
32 # exception for their modified versions; it is their choice whether to do so.
33 # The GNU General Public License gives permission to release a modified version
34 # without this exception; this exception also makes it possible to release a
35 # modified version which carries forward this exception.
37  # ------------- #
38  # DOCUMENTATION #
39  # ------------- #
41 # Disclaimer: Never tested with anything else than Qt 4.2! Feedback welcome.
42 # Simply invoke AT_WITH_QT in your configure.ac. AT_WITH_QT can take
43 # arguments which are documented in depth below. The default arguments are
44 # equivalent to the default .pro file generated by qmake.
46 # Invoking AT_WITH_QT will do the following:
47 #  - Add a --with-qt option to your configure
48 #  - Find qmake, moc and uic and save them in the make variables $(QMAKE),
49 #    $(MOC), $(UIC).
50 #  - Save the path to Qt in $(QT_PATH)
51 #  - Find the flags to use Qt, that is:
52 #     * $(QT_DEFINES): -D's defined by qmake.
53 #     * $(QT_CFLAGS): CFLAGS as defined by qmake (C?!)
54 #     * $(QT_CXXFLAGS): CXXFLAGS as defined by qmake.
55 #     * $(QT_INCPATH): -I's defined by qmake.
56 #     * $(QT_CPPFLAGS): Same as $(QT_DEFINES) + $(QT_INCPATH)
57 #     * $(QT_LFLAGS): LFLAGS defined by qmake.
58 #     * $(QT_LDFLAGS): Same thing as $(QT_LFLAGS).
59 #     * $(QT_LIBS): LIBS defined by qmake.
61 # You *MUST* invoke $(MOC) and/or $(UIC) where necessary. AutoTroll provides
62 # you with Makerules to ease this, here is a sample Makefile.am to use with
63 # AutoTroll which builds the code given in the chapter 7 of the Qt Tutorial:
64 # http://doc.trolltech.com/4.2/tutorial-t7.html
66 # -------------------------------------------------------------------------
67 # include $(top_srcdir)/build-aux/autotroll.mk
69 # ACLOCAL_AMFLAGS = -I build-aux
71 # bin_PROGRAMS = lcdrange
72 # lcdrange_SOURCES =  $(BUILT_SOURCES) lcdrange.cpp lcdrange.h main.cpp
73 # lcdrange_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS)
74 # lcdrange_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS)
75 # lcdrange_LDFLAGS  = $(QT_LDFLAGS) $(LDFLAGS)
76 # lcdrange_LDADD    = $(QT_LIBS) $(LDADD)
78 # BUILT_SOURCES = lcdrange.moc.cpp
79 # -------------------------------------------------------------------------
81 # Note that your MOC, UIC and QRC files *MUST* be listed manually in
82 # BUILT_SOURCES. If you name them properly (eg: .moc.cc, .qrc.cc, .ui.cc -- of
83 # course you can use .cpp or .cxx or .C rather than .cc) AutoTroll will build
84 # them automagically for you (using implicit rules defined in autotroll.mk).
86 m4_define([_AUTOTROLL_SERIAL], [m4_translit([
87 # serial 4
88 ], [#
89 ], [])])
92 m4_ifdef([AX_INSTEAD_IF], [],
93 [AC_DEFUN([AX_INSTEAD_IF],
94   [m4_ifval([$1],
95     [AC_MSG_WARN([$2]); [$1]],
96     [AC_MSG_ERROR([$2])])])])
98 m4_pattern_forbid([^AT_])dnl
99 m4_pattern_forbid([^_AT_])dnl
101 # AT_WITH_QT([QT_modules], [QT_config], [QT_misc], [RUN-IF-FAILED], [RUN-IF-OK])
102 # ------------------------------------------------------------------------------
103 # Enable Qt support and add an option --with-qt to the configure script.
105 # The QT_modules argument is optional and defines extra modules to enable or
106 # disable (it's equivalent to the QT variable in .pro files). Modules can be
107 # specified as follows:
109 # AT_WITH_QT   => No argument -> No QT value.
110 #                                Qmake sets it to "core gui" by default.
111 # AT_WITH_QT([xml])   => QT += xml
112 # AT_WITH_QT([+xml])  => QT += xml
113 # AT_WITH_QT([-gui])  => QT -= gui
114 # AT_WITH_QT([xml -gui +sql svg])  => QT += xml sql svg
115 #                                     QT -= gui
117 # The QT_config argument is also optional and follows the same convention as
118 # QT_modules. Instead of changing the QT variable, it changes the CONFIG
119 # variable, which is used to tweak configuration and compiler options.
121 # The last argument, QT_misc (also optional) will be copied as-is the .pro
122 # file used to guess how to compile Qt apps. You may use it to further tweak
123 # the build process of Qt apps if tweaking the QT or CONFIG variables isn't
124 # enough for you.
126 # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
127 # problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
128 # called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
129 AC_DEFUN([AT_WITH_QT],
130 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
131 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
132 AC_REQUIRE([AC_PROG_CXX])dnl
133 echo "$as_me: this is autotroll.m4[]_AUTOTROLL_SERIAL" >&AS_MESSAGE_LOG_FD
135   test x"$TROLL" != x && echo 'ViM rox emacs.'
137 dnl Memo: AC_ARG_WITH(package, help-string, [if-given], [if-not-given])
138   AC_ARG_WITH([qt],
139               [AS_HELP_STRING([--with-qt],
140                  [Path to Qt @<:@Look in PATH and /usr/local/Trolltech@:>@])],
141               [QT_PATH=$withval])
143   # this is a hack to get decent flow control with 'break'
144   for _qt_ignored in once; do
146   # Find Qt.
147   AC_ARG_VAR([QT_PATH], [Path to the Qt installation])
148   if test -d /usr/local/Trolltech; then
149     # Try to find the latest version.
150     tmp_qt_paths=`echo /usr/local/Trolltech/*/bin | tr ' ' '\n' | sort -nr \
151                                               | xargs | sed 's/  */:/g'`
152   fi
153   # Path to which recent MacPorts (~v1.7) install Qt4.
154   test -d /opt/local/libexec/qt4-mac/bin \
155     && tmp_qt_paths="$tmp_qt_paths:/opt/local/libexec/qt4-mac/bin"
157   # Find qmake.
158   AC_ARG_VAR([QMAKE], [Qt Makefile generator command])
159   AC_PATH_PROGS([QMAKE], [qmake qmake-qt4 qmake-qt3], [missing],
160                 [$QT_DIR:$QT_PATH:$PATH:$tmp_qt_paths])
161   if test x"$QMAKE" = xmissing; then
162     AX_INSTEAD_IF([$4], [Cannot find qmake in your PATH. Try using --with-qt.])
163     break
164   fi
166   # Find moc (Meta Object Compiler).
167   AC_ARG_VAR([MOC], [Qt Meta Object Compiler command])
168   AC_PATH_PROGS([MOC], [moc moc-qt4 moc-qt3], [missing],
169                 [$QT_PATH:$PATH:$tmp_qt_paths])
170   if test x"$MOC" = xmissing; then
171     AX_INSTEAD_IF([$4],
172    [Cannot find moc (Meta Object Compiler) in your PATH. Try using --with-qt.])
173     break
174   fi
176   # Find uic (User Interface Compiler).
177   AC_ARG_VAR([UIC], [Qt User Interface Compiler command])
178   AC_PATH_PROGS([UIC], [uic uic-qt4 uic-qt3 uic3], [missing],
179                 [$QT_PATH:$PATH:$tmp_qt_paths])
180   if test x"$UIC" = xmissing; then
181     AX_INSTEAD_IF([$4],
182 [Cannot find uic (User Interface Compiler) in your PATH. Try using --with-qt.])
183     break
184   fi
186   # Find rcc (Qt Resource Compiler).
187   AC_ARG_VAR([RCC], [Qt Resource Compiler command])
188   AC_PATH_PROGS([RCC], [rcc], [false], [$QT_PATH:$PATH:$tmp_qt_paths])
189   if test x"$UIC" = xfalse; then
190     AC_MSG_WARN([Cannot find rcc (Qt Resource Compiler) in your PATH.\
191   Try using --with-qt.])
192   fi
194   AC_MSG_CHECKING([whether host operating system is Darwin])
195   at_darwin=no
196   at_qmake_args=
197   case $host_os in
198     darwin*)
199       at_darwin=yes
200       at_qmake_args='-spec macx-g++'
201       ;;
202   esac
203   AC_MSG_RESULT([$at_darwin])
205   # If we don't know the path to Qt, guess it from the path to qmake.
206   if test x"$QT_PATH" = x; then
207     QT_PATH=`dirname "$QMAKE"`
208   fi
209   if test x"$QT_PATH" = x; then
210     AX_INSTEAD_IF([$4],
211                   [Cannot find the path to your Qt install. Use --with-qt.])
212     break
213   fi
214   AC_SUBST([QT_PATH])
216   # Get ready to build a test-app with Qt.
217   if mkdir conftest.dir && cd conftest.dir; then :; else
218     AX_INSTEAD_IF([$4], [Cannot mkdir conftest.dir or cd to that directory.])
219     break
220   fi
222   cat >conftest.h <<_ASEOF
223 #include <QObject>
225 class Foo: public QObject
227   Q_OBJECT;
228 public:
229   Foo();
230   ~Foo() {}
231 public Q_SLOTS:
232   void setValue(int value);
233 Q_SIGNALS:
234   void valueChanged(int newValue);
235 private:
236   int value_;
238 _ASEOF
240   cat >conftest.cpp <<_ASEOF
241 #include "conftest.h"
242 Foo::Foo()
243   : value_ (42)
245   connect(this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
248 void Foo::setValue(int value)
250   value_ = value;
253 int main()
255   Foo f;
257 _ASEOF
258   if $QMAKE -project; then :; else
259     AX_INSTEAD_IF([$4], [Calling $QMAKE -project failed.])
260     break
261   fi
263   # Find the .pro file generated by qmake.
264   pro_file='conftest.dir.pro'
265   test -f $pro_file || pro_file=`echo *.pro`
266   if test -f "$pro_file"; then :; else
267     AX_INSTEAD_IF([$4], [Can't find the .pro file generated by Qmake.])
268     break
269   fi
271 dnl Tweak the value of QT in the .pro if have been the 1st arg.
272 m4_ifval([$1], [_AT_TWEAK_PRO_FILE([QT], [$1])])
274 dnl Tweak the value of CONFIG in the .pro if have been given a 2nd arg.
275 m4_ifval([$2], [_AT_TWEAK_PRO_FILE([CONFIG], [$2])])
277 m4_ifval([$3],
278 [ # Add the extra-settings the user wants to set in the .pro
279   echo "$3" >>"$pro_file"
282   echo "$as_me:$LINENO: Invoking $QMAKE on $pro_file" >&AS_MESSAGE_LOG_FD
283   sed 's/^/| /' "$pro_file" >&AS_MESSAGE_LOG_FD
285   if $QMAKE $at_qmake_args; then :; else
286     AX_INSTEAD_IF([$4], [Calling $QMAKE $at_qmake_args failed.])
287     break
288   fi
290   # QMake has a very annoying misfeature: sometimes it generates Makefiles
291   # where all the references to the files from the Qt installation are
292   # relative.  We can't use them as-is because if we take, say, a
293   # -I../../usr/include/Qt from that Makefile, the flag is invalid as soon
294   # as we use it in another (sub) directory.  So what this perl pass does is
295   # that it rewrite all relative paths to absolute paths.  Another problem
296   # when building on Cygwin is that QMake mixes paths with blackslashes and
297   # forward slashes and paths must be handled with extra care because of the
298   # stupid Windows drive letters.
299   echo "$as_me:$LINENO: fixing the Makefiles:" Makefile* >&AS_MESSAGE_LOG_FD
300   cat >fixmk.pl <<\EOF
301 [use strict;
302 use Cwd qw(cwd abs_path);
303 # This variable is useful on Cygwin for the following reason: Say that you are
304 # in `/' (that is, in fact you are in C:/cygwin, or something like that) if you
305 # `cd ..' then obviously you remain in `/' (that is in C:/cygwin).  QMake
306 # generates paths that are relative to C:/ (or another driver letter, whatever)
307 # so the trick to get the `..' resolved properly is to prepend the absolute
308 # path of the current working directory in a Windows-style.  C:/cygwin/../ will
309 # properly become C:/.
310 my $d = "";
311 my $r2a = 0;
312 my $b2f = 0;
314 my $cygwin = 0;
315 if ($^O eq "cygwin") {
316   $cygwin = 1;
317   $d = cwd();
318   $d = `cygpath --mixed '$d'`;
319   chomp($d);
320   $d .= "/";
323 sub rel2abs($)
325   my $p = $d . shift;
326   # print "r2a p=$p";
327   -e $p || return $p;
328   if ($cygwin) {
329     $p = `cygpath --mixed '$p'`;
330     chomp($p);
331   }
332   else {
333     # Do not use abs_path on Cygwin: it incorrectly resolves the paths that are
334     # relative to C:/ rather than `/'.
335     $p = abs_path($p);
336   }
337   # print " -> $p\n";
338   ++$r2a;
339   return $p;
342 # Only useful on Cygwin.
343 sub back2forward($)
345   my $p = shift;
346   # print "b2f p=$p";
347   -e $p || return $p;
348   $p = `cygpath --mixed '$p'`;
349   chomp($p);
350   # print " -> $p\n";
351   ++$b2f;
352   return $p;
355 foreach my $mk (@ARGV)
357   next if $mk =~ /~$/;
358   open(MK, $mk) or die("open $mk: $!");
359   # print "mk=$mk\n";
360   my $file = join("", <MK>);
361   close(MK) or die("close $mk: $!");
362   rename $mk, $mk . "~" or die("rename $mk: $!");
363   $file =~ s{(?:\.\.[\\/])+(?:[^"'\s:]+)}{rel2abs($&)}gse;
364   $file =~ s{(?:[a-zA-Z]:[\\/])?(?:[^"\s]+\\[^"\s:]+)+}
365             {back2forward($&)}gse if $cygwin;
366   open(MK, ">", $mk) or die("open >$mk: $!");
367   print MK $file;
368   close(MK) or die("close >$mk: $!");
369   print "$mk: updated $r2a relative paths and $b2f backslash-style paths\n";
370   $r2a = 0;
371   $b2f = 0;
375   perl >&AS_MESSAGE_LOG_FD -w fixmk.pl Makefile* ||
376   AC_MSG_WARN([failed to fix the Makefiles generated by $QMAKE])
377   rm -f fixmk.pl
379   # Try to compile a simple Qt app.
380   AC_CACHE_CHECK([whether we can build a simple Qt app], [at_cv_qt_build],
381   [at_cv_qt_build=ko
382   : ${MAKE=make}
384   if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
385     at_cv_qt_build='ok, looks like Qt 4'
386   else
387     echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
388 instead" >&AS_MESSAGE_LOG_FD
389     sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h && mv tmp.h conftest.h
390     if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
391       at_cv_qt_build='ok, looks like Qt 3'
392     else
393       # Sometimes (such as on Debian) build will fail because Qt hasn't been
394       # installed in debug mode and qmake tries (by default) to build apps in
395       # debug mode => Try again in release mode.
396       echo "$as_me:$LINENO: Build failed, trying to enforce release mode" \
397             >&AS_MESSAGE_LOG_FD
399       _AT_TWEAK_PRO_FILE([CONFIG], [+release])
401       sed 's/<qobject.h>/<QObject>/' conftest.h > tmp.h && mv tmp.h conftest.h
402       if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
403         at_cv_qt_build='ok, looks like Qt 4, release mode forced'
404       else
405         echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
406 instead" >&AS_MESSAGE_LOG_FD
407         sed 's/<QObject>/<qobject.h>/' conftest.h >tmp.h && mv tmp.h conftest.h
408         if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
409           at_cv_qt_build='ok, looks like Qt 3, release mode forced'
410         else
411           at_cv_qt_build=ko
412           echo "$as_me:$LINENO: failed program was:" >&AS_MESSAGE_LOG_FD
413           sed 's/^/| /' conftest.h >&AS_MESSAGE_LOG_FD
414           echo "$as_me:$LINENO: failed program was:" >&AS_MESSAGE_LOG_FD
415           sed 's/^/| /' conftest.cpp >&AS_MESSAGE_LOG_FD
416         fi # if make with Qt3-style #include and release mode forced.
417       fi # if make with Qt4-style #include and release mode forced.
418     fi # if make with Qt3-style #include.
419   fi # if make with Qt4-style #include.
420   ])dnl end: AC_CACHE_CHECK(at_cv_qt_build)
422   if test x"$at_cv_qt_build" = xko; then
423     AX_INSTEAD_IF([$4], [Cannot build a test Qt program])
424     break
425   fi
426   QT_VERSION_MAJOR=`echo "$at_cv_qt_build" | sed 's/[[^0-9]]*//g'`
427   AC_SUBST([QT_VERSION_MAJOR])
429   # This sed filter is applied after an expression of the form: /^FOO.*=/!d;
430   # It starts by removing the beginning of the line, removing references to
431   # SUBLIBS, removing unnecessary whitespaces at the beginning, and prefixes
432   # all variable uses by QT_.
433   qt_sed_filter='s///;
434                  s/$(SUBLIBS)//g;
435                  s/^ *//;
436                  s/\$(\(@<:@A-Z_@:>@@<:@A-Z_@:>@*\))/$(QT_\1)/g'
438   # Find the Makefile (qmake happens to generate a fake Makefile which invokes
439   # a Makefile.Debug or Makefile.Release). We we have both, we'll pick the
440   # Makefile.Release. The reason is that the main difference is that release
441   # uses -Os and debug -g. We can override -Os by passing another -O but we
442   # usually don't override -g.
443   if test -f Makefile.Release; then
444     at_mfile='Makefile.Release'
445   else
446     at_mfile='Makefile'
447   fi
448   if test -f $at_mfile; then :; else
449     AX_INSTEAD_IF([$4], [Cannot find the Makefile generated by qmake.])
450     break
451   fi
453   # Find the DEFINES of Qt (should have been named CPPFLAGS).
454   AC_CACHE_CHECK([for the DEFINES to use with Qt], [at_cv_env_QT_DEFINES],
455   [at_cv_env_QT_DEFINES=`sed "/^DEFINES@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
456   AC_SUBST([QT_DEFINES], [$at_cv_env_QT_DEFINES])
458   # Find the CFLAGS of Qt (We can use Qt in C?!)
459   AC_CACHE_CHECK([for the CFLAGS to use with Qt], [at_cv_env_QT_CFLAGS],
460   [at_cv_env_QT_CFLAGS=`sed "/^CFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
461   AC_SUBST([QT_CFLAGS], [$at_cv_env_QT_CFLAGS])
463   # Find the CXXFLAGS of Qt.
464   AC_CACHE_CHECK([for the CXXFLAGS to use with Qt], [at_cv_env_QT_CXXFLAGS],
465   [at_cv_env_QT_CXXFLAGS=`sed "/^CXXFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
466   AC_SUBST([QT_CXXFLAGS], [$at_cv_env_QT_CXXFLAGS])
468   # Find the INCPATH of Qt.
469   AC_CACHE_CHECK([for the INCPATH to use with Qt], [at_cv_env_QT_INCPATH],
470   [at_cv_env_QT_INCPATH=`sed "/^INCPATH@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
471   AC_SUBST([QT_INCPATH], [$at_cv_env_QT_INCPATH])
473   AC_SUBST([QT_CPPFLAGS], ["$at_cv_env_QT_DEFINES $at_cv_env_QT_INCPATH"])
475   # Find the LFLAGS of Qt (Should have been named LDFLAGS)
476   AC_CACHE_CHECK([for the LDFLAGS to use with Qt], [at_cv_env_QT_LDFLAGS],
477   [at_cv_env_QT_LDFLAGS=`sed "/^LFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
478   AC_SUBST([QT_LFLAGS], [$at_cv_env_QT_LDFLAGS])
479   AC_SUBST([QT_LDFLAGS], [$at_cv_env_QT_LDFLAGS])
481   # Find the LIBS of Qt.
482   AC_CACHE_CHECK([for the LIBS to use with Qt], [at_cv_env_QT_LIBS],
483   [at_cv_env_QT_LIBS=`sed "/^LIBS@<:@^A-Z@:>@*=/!d;$qt_sed_filter" $at_mfile`
484    if test x$at_darwin = xyes; then
485      # Fix QT_LIBS: as of today Libtool (GNU Libtool 1.5.23a) doesn't handle
486      # -F properly. The "bug" has been fixed on 22 October 2006
487      # by Peter O'Gorman but we provide backward compatibility here.
488      at_cv_env_QT_LIBS=`echo "$at_cv_env_QT_LIBS" \
489                              | sed 's/^-F/-Wl,-F/;s/ -F/ -Wl,-F/g'`
490    fi
491   ])
492   AC_SUBST([QT_LIBS], [$at_cv_env_QT_LIBS])
494   cd .. && rm -rf conftest.dir
496   # Run the user code
497   $5
499   done  # end hack (useless for to be able to use break)
502 # AT_REQUIRE_QT_VERSION(QT_version, RUN-IF-FAILED, RUN-IF-OK)
503 # -----------------------------------------------------------
504 # Check (using qmake) that Qt's version "matches" QT_version.
505 # Must be run AFTER AT_WITH_QT. Requires autoconf 2.60.
507 # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
508 # problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
509 # called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
510 AC_DEFUN([AT_REQUIRE_QT_VERSION],
511 [ AC_PREREQ([2.60])
512   # this is a hack to get decent flow control with 'break'
513   for _qt_ignored in once; do
515   if test x"$QMAKE" = x; then
516     AX_INSTEAD_IF([$2],
517                   [\$QMAKE is empty.\
518   Did you invoke AT@&t@_WITH_QT before AT@&t@_REQUIRE_QT_VERSION?])
519     break
520   fi
521   AC_CACHE_CHECK([for Qt's version], [at_cv_QT_VERSION],
522   [echo "$as_me:$LINENO: Running $QMAKE --version:" >&AS_MESSAGE_LOG_FD
523   $QMAKE --version >&AS_MESSAGE_LOG_FD 2>&1
524   qmake_version_sed=['/^.*\([0-9]\.[0-9]\.[0-9]\).*$/!d;s//\1/']
525   at_cv_QT_VERSION=`$QMAKE --version 2>&1 | sed "$qmake_version_sed"`])
526   if test x"$at_cv_QT_VERSION" = x; then
527     AX_INSTEAD_IF([$2], [Cannot detect Qt's version.])
528     break
529   fi
530   AC_SUBST([QT_VERSION], [$at_cv_QT_VERSION])
531   AS_VERSION_COMPARE([$QT_VERSION], [$1],
532     [AX_INSTEAD_IF([$2; break;], [This package requires Qt $1 or above.])])
534   # Run the user code
535   $3
537   done  # end hack (useless for to be able to use break)
540 # _AT_TWEAK_PRO_FILE(QT_VAR, VALUE)
541 # ---------------------------
542 # @internal. Tweak the variable QT_VAR in the .pro.
543 # VALUE is an IFS-separated list of value and each value is rewritten
544 # as follows:
545 #   +value  => QT_VAR += value
546 #   -value  => QT_VAR -= value
547 #    value  => QT_VAR += value
548 AC_DEFUN([_AT_TWEAK_PRO_FILE],
549 [ # Tweak the value of $1 in the .pro file for $2.
551   qt_conf=''
552   for at_mod in $2; do
553     at_mod=`echo "$at_mod" | sed 's/^-//; tough
554                                   s/^+//; beef
555                                   :ough
556                                   s/^/$1 -= /;n
557                                   :eef
558                                   s/^/$1 += /'`
559     qt_conf="$qt_conf
560 $at_mod"
561   done
562   echo "$qt_conf" | sed 1d >>"$pro_file"