[autotroll] Documentation fixes and formatting.
[ttfautohint.git] / m4 / autotroll.m4
blobc954fe4124777a0496240bb48950a38bfaafb9c6
1 # Build Qt apps with the autotools (Autoconf/Automake).
2 # M4 macros.
4 # This file is part of AutoTroll.
6 # Copyright (C) 2006  Benoit Sigoure <benoit.sigoure@lrde.epita.fr>
7 #   modified 2012 by Werner Lemberg <wl@gnu.org>
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.
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.
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.
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.
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.
42  # ------------- #
43  # DOCUMENTATION #
44  # ------------- #
46 # Disclaimer: Tested with Qt 4.2 and 4.8 only.  Feedback welcome.
47 # Simply invoke AT_WITH_QT in your configure.ac.  AT_WITH_QT can take
48 # arguments which are documented in depth below.  The default
49 # arguments are equivalent to the default .pro file generated by
50 # qmake.
52 # Invoking AT_WITH_QT will do the following:
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 #  - Add option `--without-qt', which is equivalent to `--with-qt=no'.
60 #  - If Qt support is enabled, set HAVE_QT to 1 (and to 0 otherwise).
61 #  - Find the programs `qmake', `moc', `uic', and `rcc' and save them
62 #    in the make variables $(QMAKE), $(MOC), $(UIC), and $(RCC).
63 #  - Save the path to Qt binaries in $(QT_PATH).
64 #  - Find the flags necessary to compile and link Qt, that is:
65 #     * $(QT_DEFINES): -D's defined by qmake.
66 #     * $(QT_CFLAGS): CFLAGS as defined by qmake (C?!)
67 #     * $(QT_CXXFLAGS): CXXFLAGS as defined by qmake.
68 #     * $(QT_INCPATH): -I's defined by qmake.
69 #     * $(QT_CPPFLAGS): Same as $(QT_DEFINES) + $(QT_INCPATH).
70 #     * $(QT_LFLAGS): LFLAGS defined by qmake.
71 #     * $(QT_LDFLAGS): Same thing as $(QT_LFLAGS).
72 #     * $(QT_LIBS): LIBS defined by qmake.
74 # You *MUST* invoke $(MOC) and/or $(UIC) by yourself where necessary.
75 # AutoTroll provides you with Makerules to ease this; here is a sample
76 # Makefile.am to use with AutoTroll which builds the code given in
77 # chapter 7 of the Qt Tutorial
78 # (http://doc.trolltech.com/4.2/tutorial-t7.html).
80 # -------------------------------------------------------------------------
81 # include $(top_srcdir)/build-aux/autotroll.mk
83 # ACLOCAL_AMFLAGS = -I build-aux
85 # bin_PROGRAMS = lcdrange
86 # lcdrange_SOURCES  = $(BUILT_SOURCES) lcdrange.cpp lcdrange.h main.cpp
87 # lcdrange_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS)
88 # lcdrange_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS)
89 # lcdrange_LDFLAGS  = $(QT_LDFLAGS) $(LDFLAGS)
90 # lcdrange_LDADD    = $(QT_LIBS) $(LDADD)
92 # BUILT_SOURCES = lcdrange.moc.cpp
93 # -------------------------------------------------------------------------
95 # Note that your MOC, UIC, and RRC files *MUST* be listed explicitly
96 # in BUILT_SOURCES.  If you name them properly (e.g. `.moc.cc',
97 # `.qrc.cc', `.ui.cc' -- of course you can use `.cpp' or `.cxx' or
98 # `.C' rather than `.cc') AutoTroll will build them automagically for
99 # you, using implicit rules defined in `autotroll.mk'.
101 m4_define([_AUTOTROLL_SERIAL],
102   [m4_translit([
103 # serial 7
104 ], [#
105 ], [])])
108 m4_ifdef([AX_INSTEAD_IF],
109   [],
110   [AC_DEFUN([AX_INSTEAD_IF],
111     [m4_ifval([$1],
112       [AC_MSG_WARN([$2])
113        [$1]],
114       [AC_MSG_ERROR([$2])])])])
117 m4_pattern_forbid([^AT_])
118 m4_pattern_forbid([^_AT_])
121 # AT_WITH_QT([QT_modules], [QT_config], [QT_misc], [RUN-IF-FAILED], [RUN-IF-OK])
122 # ------------------------------------------------------------------------------
123 # Enable Qt support and add an option --with-qt to the configure
124 # script.
126 # The QT_modules argument is optional and defines extra modules to
127 # enable or disable (it's equivalent to the QT variable in .pro
128 # files).  Modules can be specified as follows:
130 # AT_WITH_QT   => No argument -> No QT value.
131 #                                Qmake sets it to "core gui" by
132 #                                default.
133 # AT_WITH_QT([xml])   => QT += xml
134 # AT_WITH_QT([+xml])  => QT += xml
135 # AT_WITH_QT([-gui])  => QT -= gui
136 # AT_WITH_QT([xml -gui +sql svg])  => QT += xml sql svg
137 #                                     QT -= gui
139 # The QT_config argument is also optional and follows the same
140 # convention as QT_modules.  Instead of changing the QT variable, it
141 # changes the CONFIG variable, which is used to tweak configuration
142 # and compiler options.
144 # The last argument, QT_misc (also optional) will be copied as-is the
145 # .pro file used to guess how to compile Qt apps.  You may use it to
146 # further tweak the build process of Qt apps if tweaking the QT or
147 # CONFIG variables isn't enough for you.
149 # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or
150 # if any problem happens.  If this argument is omitted, then
151 # AC_MSG_ERROR will be called.  RUN-IF-OK is arbitrary code to execute
152 # if Qt was successfully found.
154 AC_DEFUN([AT_WITH_QT],
155   [AC_REQUIRE([AC_CANONICAL_HOST])
156    AC_REQUIRE([AC_CANONICAL_BUILD])
157    AC_REQUIRE([AC_PROG_CXX])
159    echo "$as_me: this is autotroll.m4[]_AUTOTROLL_SERIAL" \
160      >& AS_MESSAGE_LOG_FD
162    # This is a hack to get decent flow control with `break'.
163    for _qt_ignored in once; do
165      AC_ARG_WITH([qt],
166        AS_HELP_STRING([--with-qt@<:@=ARG@:>@],
167          [Qt support.  ARG can be `yes' (the default), `no',
168           or a path to Qt binaries; if `yes' or empty,
169           use PATH and some default directories to find Qt binaries]))
171      if test x"$with_qt" = x"no"; then
172        HAVE_QT=0
173        break
174      else
175        HAVE_QT=1
176      fi
178      if test x"$with_qt" = x"yes"; then
179        QT_PATH=
180      else
181        QT_PATH=$with_qt
182      fi
184      # Find Qt.
185      AC_ARG_VAR([QT_PATH],
186        [path to Qt binaries])
187      if test -d /usr/local/Trolltech; then
188        # Try to find the latest version.
189        tmp_qt_paths=`echo /usr/local/Trolltech/*/bin \
190                      | tr ' ' '\n' \
191                      | sort -nr \
192                      | xargs \
193                      | sed 's/  */:/g'`
194      fi
196      # Path to which recent MacPorts (~v1.7) install Qt4.
197      test -d /opt/local/libexec/qt4-mac/bin \
198      && tmp_qt_paths="$tmp_qt_paths:/opt/local/libexec/qt4-mac/bin"
200      # Find qmake.
201      AC_ARG_VAR([QMAKE],
202        [Qt Makefile generator command])
203      AC_PATH_PROGS([QMAKE],
204        [qmake qmake-qt4 qmake-qt3],
205        [missing],
206        [$QT_DIR:$QT_PATH:$PATH:$tmp_qt_paths])
207      if test x"$QMAKE" = xmissing; then
208        AX_INSTEAD_IF([$4],
209          [Cannot find qmake.  Try --with-qt=PATH.])
210        break
211      fi
213      # Find moc (Meta Object Compiler).
214      AC_ARG_VAR([MOC],
215        [Qt Meta Object Compiler command])
216      AC_PATH_PROGS([MOC],
217        [moc moc-qt4 moc-qt3],
218        [missing],
219        [$QT_PATH:$PATH:$tmp_qt_paths])
220      if test x"$MOC" = xmissing; then
221        AX_INSTEAD_IF([$4],
222          [Cannot find moc (Meta Object Compiler).  Try --with-qt=PATH.])
223        break
224      fi
226      # Find uic (User Interface Compiler).
227      AC_ARG_VAR([UIC],
228        [Qt User Interface Compiler command])
229      AC_PATH_PROGS([UIC],
230        [uic uic-qt4 uic-qt3 uic3],
231        [missing],
232        [$QT_PATH:$PATH:$tmp_qt_paths])
233      if test x"$UIC" = xmissing; then
234        AX_INSTEAD_IF([$4],
235          [Cannot find uic (User Interface Compiler).  Try --with-qt=PATH.])
236        break
237      fi
239      # Find rcc (Qt Resource Compiler).
240      AC_ARG_VAR([RCC],
241        [Qt Resource Compiler command])
242      AC_PATH_PROGS([RCC],
243        [rcc],
244        [missing],
245        [$QT_PATH:$PATH:$tmp_qt_paths])
246      if test x"$RCC" = xmissing; then
247        AC_MSG_WARN(
248          [Cannot find rcc (Qt Resource Compiler).  Try --with-qt=PATH.])
249      fi
251      AC_MSG_CHECKING([whether host operating system is Darwin])
252      at_darwin=no
253      at_qmake_args=
254      case $host_os in
255        darwin*)
256          at_darwin=yes
257          at_qmake_args='-spec macx-g++'
258          ;;
259      esac
260      AC_MSG_RESULT([$at_darwin])
262      # If we don't know the path to Qt, guess it from the path to
263      # qmake.
264      if test x"$QT_PATH" = x; then
265        QT_PATH=`dirname "$QMAKE"`
266      fi
267      if test x"$QT_PATH" = x; then
268        AX_INSTEAD_IF([$4],
269          [Cannot find your Qt installation.  Try --with-qt=PATH.])
270        break
271      fi
272      AC_SUBST([QT_PATH])
274      # Get ready to build a test-app with Qt.
275      if mkdir conftest.dir \
276         && cd conftest.dir; then
277        :
278      else
279        AX_INSTEAD_IF([$4],
280          [Cannot mkdir conftest.dir or cd to that directory.])
281        break
282      fi
284      cat >conftest.h <<_ASEOF
286 #include <QObject>
288 class Foo: public QObject
290   Q_OBJECT;
291 public:
292   Foo();
293   ~Foo() {}
294 public Q_SLOTS:
295   void setValue(int value);
296 Q_SIGNALS:
297   void valueChanged(int newValue);
298 private:
299   int value_;
302 _ASEOF
304      cat >conftest.cpp <<_ASEOF
306 #include "conftest.h"
308 Foo::Foo()
309   : value_ (42)
311   connect(this, SIGNAL(valueChanged(int)),
312           this, SLOT(setValue(int)));
315 void Foo::setValue(int value)
317   value_ = value;
320 int main()
322   Foo f;
325 _ASEOF
327      if $QMAKE -project; then
328        :
329      else
330        AX_INSTEAD_IF([$4],
331          [Calling $QMAKE -project failed.])
332        break
333      fi
335      # Find the .pro file generated by qmake.
336      pro_file=conftest.dir.pro
337      test -f $pro_file || pro_file=`echo *.pro`
338      if test -f "$pro_file"; then
339        :
340      else
341        AX_INSTEAD_IF([$4],
342          [Can't find the .pro file generated by Qmake.])
343        break
344      fi
346      dnl Tweak the value of QT in the .pro if have been the 1st arg.
347      m4_ifval([$1],
348        [_AT_TWEAK_PRO_FILE([QT], [$1])])
350      dnl Tweak the value of CONFIG in the .pro if have been given a
351      dnl 2nd arg.
352      m4_ifval([$2],
353        [_AT_TWEAK_PRO_FILE([CONFIG], [$2])])
355      m4_ifval([$3],
356        [ # Add the extra-settings the user wants to set in the .pro.
357          echo "$3" >>"$pro_file"
358        ])
360      echo "$as_me:$LINENO: Invoking $QMAKE on $pro_file" \
361        >& AS_MESSAGE_LOG_FD
362      sed 's/^/| /' "$pro_file" >& AS_MESSAGE_LOG_FD
364      if $QMAKE $at_qmake_args; then
365        :
366      else
367        AX_INSTEAD_IF([$4],
368          [Calling $QMAKE $at_qmake_args failed.])
369        break
370      fi
372      # QMake has a very annoying misfeature: Sometimes it generates
373      # Makefiles where all the references to the files from the Qt
374      # installation are relative.  We can't use them as-is because if
375      # we take, say, a -I../../usr/include/Qt from that Makefile, the
376      # flag is invalid as soon as we use it in another (sub)
377      # directory.  So what this perl pass does is that it rewrites all
378      # relative paths to absolute paths.  Another problem when
379      # building on Cygwin is that QMake mixes paths with backslashes
380      # and forward slashes and paths must be handled with extra care
381      # because of the stupid Windows drive letters.
382      echo "$as_me:$LINENO: fixing the Makefiles:" Makefile* \
383        >& AS_MESSAGE_LOG_FD
384      cat >fixmk.pl <<\EOF
387  use strict;
388  use Cwd qw(cwd abs_path);
390  # This variable is useful on Cygwin for the following reason: Say
391  # that you are in `/' (that is, in fact you are in C:/cygwin, or
392  # something like that).  If you `cd ..' then obviously you remain in
393  # `/' (that is in C:/cygwin).  QMake generates paths that are
394  # relative to C:/ (or another drive letter, whatever) so the trick to
395  # get the `..' resolved properly is to prepend the absolute path of
396  # the current working directory in a Windows-style.  C:/cygwin/../
397  # will properly become C:/.
398  my $d = "";
399  my $r2a = 0;
400  my $b2f = 0;
402  my $cygwin = 0;
403  if ($^O eq "cygwin") {
404    $cygwin = 1;
405    $d = cwd();
406    $d = `cygpath --mixed '$d'`;
407    chomp($d);
408    $d .= "/";
411  sub rel2abs($)
413    my $p = $d . shift;
414    # print "r2a p=$p";
415    -e $p || return $p;
416    if ($cygwin) {
417      $p = `cygpath --mixed '$p'`;
418      chomp($p);
419    }
420    else {
421     # Do not use abs_path on Cygwin: it incorrectly resolves the paths
422     # that are relative to C:/ rather than `/'.
423      $p = abs_path($p);
424    }
425    # print " -> $p\n";
426    ++$r2a;
427    return $p;
430  # Only useful on Cygwin.
431  sub back2forward($)
433    my $p = shift;
434    # print "b2f p=$p";
435    -e $p || return $p;
436    $p = `cygpath --mixed '$p'`;
437    chomp($p);
438    # print " -> $p\n";
439    ++$b2f;
440    return $p;
443  foreach my $mk (@ARGV)
445    next if $mk =~ /~$/;
446    open(MK, $mk) or die("open $mk: $!");
447    # print "mk=$mk\n";
448    my $file = join("", <MK>);
449    close(MK) or die("close $mk: $!");
450    rename $mk, $mk . "~" or die("rename $mk: $!");
451    $file =~ s{(?:\.\.[\\/])+(?:[^"'\s:]+)}{rel2abs($&)}gse;
452    $file =~ s{(?:[a-zA-Z]:[\\/])?(?:[^"\s]+\\[^"\s:]+)+}
453              {back2forward($&)}gse if $cygwin;
454    open(MK, ">", $mk) or die("open >$mk: $!");
455    print MK $file;
456    close(MK) or die("close >$mk: $!");
457    print "$mk: updated $r2a relative paths and $b2f backslash-style paths\n";
458    $r2a = 0;
459    $b2f = 0;
465      perl >& AS_MESSAGE_LOG_FD -w fixmk.pl Makefile* \
466      || AC_MSG_WARN([failed to fix the Makefiles generated by $QMAKE])
467      rm -f fixmk.pl
469      # Try to compile a simple Qt app.
470      AC_CACHE_CHECK([whether we can build a simple Qt application],
471        [at_cv_qt_build],
472        [at_cv_qt_build=ko
473         : ${MAKE=make}
475         if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then
476           at_cv_qt_build='ok, looks like Qt 4'
477         else
478           echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> instead" \
479             >& AS_MESSAGE_LOG_FD
480           sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h \
481             && mv tmp.h conftest.h
482           if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then
483             at_cv_qt_build='ok, looks like Qt 3'
484           else
485             # Sometimes (such as on Debian) build will fail because Qt
486             # hasn't been installed in debug mode and qmake tries (by
487             # default) to build apps in debug mode => Try again in
488             # release mode.
489             echo "$as_me:$LINENO: Build failed, trying to enforce release mode" \
490               >& AS_MESSAGE_LOG_FD
492             _AT_TWEAK_PRO_FILE([CONFIG], [+release])
494             sed 's/<qobject.h>/<QObject>/' conftest.h > tmp.h \
495               && mv tmp.h conftest.h
496             if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then
497               at_cv_qt_build='ok, looks like Qt 4, release mode forced'
498             else
499               echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> instead" \
500                 >& AS_MESSAGE_LOG_FD
501               sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h \
502                 && mv tmp.h conftest.h
503               if $MAKE >& AS_MESSAGE_LOG_FD 2>&1; then
504                 at_cv_qt_build='ok, looks like Qt 3, release mode forced'
505               else
506                 at_cv_qt_build=ko
507                 echo "$as_me:$LINENO: failed program was:" \
508                   >& AS_MESSAGE_LOG_FD
509                 sed 's/^/| /' conftest.h >& AS_MESSAGE_LOG_FD
510                 echo "$as_me:$LINENO: failed program was:" \
511                   >& AS_MESSAGE_LOG_FD
512                 sed 's/^/| /' conftest.cpp >& AS_MESSAGE_LOG_FD
513               fi # if make with Qt3-style #include and release mode forced.
514             fi # if make with Qt4-style #include and release mode forced.
515           fi # if make with Qt3-style #include.
516         fi # if make with Qt4-style #include.
517        ])dnl end: AC_CACHE_CHECK(at_cv_qt_build)
519      if test x"$at_cv_qt_build" = xko; then
520        AX_INSTEAD_IF([$4],
521          [Cannot build a test Qt program])
522        cd ..
523        break
524      fi
526      QT_VERSION_MAJOR=`echo "$at_cv_qt_build" | sed 's/[[^0-9]]*//g'`
527      AC_SUBST([QT_VERSION_MAJOR])
529      # This sed filter is applied after an expression of the form:
530      # /^FOO.*=/!d; it starts by removing the beginning of the line,
531      # removing references to SUBLIBS, removing unnecessary
532      # whitespaces at the beginning, and prefixes all variable uses by
533      # QT_.
534      qt_sed_filter='s///;
535                     s/$(SUBLIBS)//g;
536                     s/^ *//;
537                     s/\$(\(@<:@A-Z_@:>@@<:@A-Z_@:>@*\))/$(QT_\1)/g'
539      # Find the Makefile (qmake happens to generate a fake Makefile
540      # which invokes a Makefile.Debug or Makefile.Release).  If we
541      # have both, we'll pick the Makefile.Release.  The reason is that
542      # that release uses -Os and debug -g.  We can override -Os by
543      # passing another -O but we usually don't override -g.
544      if test -f Makefile.Release; then
545        at_mfile='Makefile.Release'
546      else
547        at_mfile='Makefile'
548      fi
549      if test -f $at_mfile; then
550        :
551      else
552        AX_INSTEAD_IF([$4],
553          [Cannot find the Makefile generated by qmake.])
554        cd ..
555        break
556      fi
558      # Find the DEFINES of Qt (should have been named CPPFLAGS).
559      AC_CACHE_CHECK([for the DEFINES to use with Qt],
560        [at_cv_env_QT_DEFINES],
561        [at_cv_env_QT_DEFINES=`sed "/^DEFINES@<:@^A-Z=@:>@*=/!d;
562                                    $qt_sed_filter" $at_mfile`])
563      AC_SUBST([QT_DEFINES],
564        [$at_cv_env_QT_DEFINES])
566      # Find the CFLAGS of Qt.  (We can use Qt in C?!)
567      AC_CACHE_CHECK([for the CFLAGS to use with Qt],
568        [at_cv_env_QT_CFLAGS],
569        [at_cv_env_QT_CFLAGS=`sed "/^CFLAGS@<:@^A-Z=@:>@*=/!d;
570                                   $qt_sed_filter" $at_mfile`])
571      AC_SUBST([QT_CFLAGS],
572        [$at_cv_env_QT_CFLAGS])
574      # Find the CXXFLAGS of Qt.
575      AC_CACHE_CHECK([for the CXXFLAGS to use with Qt],
576        [at_cv_env_QT_CXXFLAGS],
577        [at_cv_env_QT_CXXFLAGS=`sed "/^CXXFLAGS@<:@^A-Z=@:>@*=/!d;
578                                     $qt_sed_filter" $at_mfile`])
579      AC_SUBST([QT_CXXFLAGS],
580        [$at_cv_env_QT_CXXFLAGS])
582      # Find the INCPATH of Qt.
583      AC_CACHE_CHECK([for the INCPATH to use with Qt],
584        [at_cv_env_QT_INCPATH],
585        [at_cv_env_QT_INCPATH=`sed "/^INCPATH@<:@^A-Z=@:>@*=/!d;
586                                    $qt_sed_filter" $at_mfile`])
587      AC_SUBST([QT_INCPATH],
588        [$at_cv_env_QT_INCPATH])
590      AC_SUBST([QT_CPPFLAGS],
591        ["$at_cv_env_QT_DEFINES $at_cv_env_QT_INCPATH"])
593      # Find the LFLAGS of Qt (Should have been named LDFLAGS).
594      AC_CACHE_CHECK([for the LDFLAGS to use with Qt],
595        [at_cv_env_QT_LDFLAGS],
596        [at_cv_env_QT_LDFLAGS=`sed "/^LFLAGS@<:@^A-Z=@:>@*=/!d;
597                                    $qt_sed_filter" $at_mfile`])
598      AC_SUBST([QT_LFLAGS],
599        [$at_cv_env_QT_LDFLAGS])
600      AC_SUBST([QT_LDFLAGS],
601        [$at_cv_env_QT_LDFLAGS])
603      # Find the LIBS of Qt.
604      AC_CACHE_CHECK([for the LIBS to use with Qt],
605       [at_cv_env_QT_LIBS],
606       [at_cv_env_QT_LIBS=`sed "/^LIBS@<:@^A-Z@:>@*=/!d;
607                                $qt_sed_filter" $at_mfile`
608        if test x$at_darwin = xyes; then
609          # Fix QT_LIBS: as of today Libtool (GNU Libtool 1.5.23a)
610          # doesn't handle -F properly.  The "bug" has been fixed on 22
611          # October 2006 by Peter O'Gorman but we provide backward
612          # compatibility here.
613          at_cv_env_QT_LIBS=`echo "$at_cv_env_QT_LIBS" \
614                             | sed 's/^-F/-Wl,-F/;
615                                    s/ -F/ -Wl,-F/g'`
616        fi])
617      AC_SUBST([QT_LIBS],
618        [$at_cv_env_QT_LIBS])
620      cd .. && rm -rf conftest.dir
622      # Run the user code
623      $5
625    done  # end hack (useless FOR to be able to use break)
627    AC_SUBST(HAVE_QT)
628   ])
631 # AT_REQUIRE_QT_VERSION(QT_version, [RUN-IF-FAILED], [RUN-IF-OK])
632 # ---------------------------------------------------------------
633 # Check (using qmake) that Qt's version "matches" QT_version.  Must be
634 # run *after* AT_WITH_QT.  Requires autoconf 2.60.
636 # This macro is ignored if Qt support has been disabled (using
637 # `--with-qt=no' or `--without-qt').
639 # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or
640 # if any problem happens.  If this argument is omitted, then
641 # AC_MSG_ERROR will be called.  RUN-IF-OK is arbitrary code to execute
642 # if Qt was successfully found.
644 AC_DEFUN([AT_REQUIRE_QT_VERSION],
645   [AC_PREREQ([2.60])
647    # this is a hack to get decent flow control with `break'
648    for _qt_ignored in once; do
650      if test $HAVE_QT = 0; then
651        break
652      fi
654      if test x"$QMAKE" = x; then
655        AX_INSTEAD_IF([$2],
656         [\$QMAKE is empty.  Did you invoke AT@&t@_WITH_QT before AT@&t@_REQUIRE_QT_VERSION?])
657        break
658      fi
660      AC_CACHE_CHECK([for Qt's version],
661        [at_cv_QT_VERSION],
662        [echo "$as_me:$LINENO: Running $QMAKE --version:" \
663           >& AS_MESSAGE_LOG_FD
664         $QMAKE --version >& AS_MESSAGE_LOG_FD 2>&1
665         qmake_version_sed=['/^.*\([0-9]\.[0-9]\.[0-9]\).*$/!d;s//\1/']
666         at_cv_QT_VERSION=`$QMAKE --version 2>&1 \
667                           | sed "$qmake_version_sed"`])
668      if test x"$at_cv_QT_VERSION" = x; then
669        AX_INSTEAD_IF([$2],
670          [Cannot detect Qt's version.])
671        break
672      fi
673      AC_SUBST([QT_VERSION],
674        [$at_cv_QT_VERSION])
675      AS_VERSION_COMPARE([$QT_VERSION], [$1],
676        [AX_INSTEAD_IF([$2],
677           [This package requires Qt $1 or above.])
678         break])
680      # Run the user code
681      $3
683    done  # end hack (useless for to be able to use break)
684   ])
687 # _AT_TWEAK_PRO_FILE(QT_VAR, VALUE)
688 # ---------------------------------
689 # @internal.  Tweak the variable QT_VAR in the .pro file.  VALUE is an
690 # IFS-separated list of value, and each value is rewritten as follows:
692 #   +value  => QT_VAR += value
693 #   -value  => QT_VAR -= value
694 #    value  => QT_VAR += value
696 AC_DEFUN([_AT_TWEAK_PRO_FILE],
697   [ # Tweak the value of $1 in the .pro file for $2.
698    qt_conf=''
699    for at_mod in $2; do
700      at_mod=`echo "$at_mod" | sed 's/^-//; tough
701                                    s/^+//; beef
702                                    :ough
703                                    s/^/$1 -= /;n
704                                    :eef
705                                    s/^/$1 += /'`
706      qt_conf="\
707 $qt_conf
708 $at_mod"
709    done
710     echo "$qt_conf" | sed 1d >>"$pro_file"
711   ])