The following experimental patch is a work in progress to see whether it is feasble to get rid of our current solutions (1/ try pkg-config 2/ try linking with X11) to detect Qt. This uses a heavily butchered version of the autotroll set of m4 macros found somewhere on the net.
The situation now is that I can 1/ build LyX on mandriva 2007.1+Qt 4.2 2/ build LyX on OSX 10.4+Qt 4.3 installed as a bundle (straight from trolltech's site) Remaining problems are - requires autoconf 2.60 (easy to fix) - does not do a separate check for QtCore only. I'll fix it if it is really needed not to link against QtGui (shouldn't this be a no-op for stuff like tex2lyx?) - has no way to force linking against static libs (useful for OS X?) Making this work should be as easy as ./configure --with-qt=/path/to/qt4/dir The --with-qt is only needed if the right qmake is not on your path (I did not need it on osx) I have no idea whether this works on windows/mingw or windows/cygwin, but I'd be interested to learn about it. The general idea is that I want to avoid working further on that if it proves to be a dead-end. JMarc PS: on a related note, shall we try to switch to libtool 2.2 for 1.6?
svndiff Index: src/frontends/qt4/Makefile.am =================================================================== --- src/frontends/qt4/Makefile.am (revision 24081) +++ src/frontends/qt4/Makefile.am (working copy) @@ -8,15 +8,15 @@ CLEANFILES += $(BUILT_SOURCES) ######################### Qt stuff ############################# # Use _() for localization instead of tr() or trUtf8() -UIC4FLAGS=-tr lyx::qt_ +UICFLAGS=-tr lyx::qt_ ui_%.h: ui/%.ui - $(UIC4) $(UIC4FLAGS) $< -o $@ + $(UIC) $(UICFLAGS) $< -o $@ MOCEDFILES = $(MOCHEADER:%.h=%_moc.cpp) %_moc.cpp: %.h - $(MOC4) -o $@ $< + $(MOC) -o $@ $< Resources.qrc: Makefile echo "<!DOCTYPE RCC><RCC version='1.0'><qresource>" > $@ @@ -26,7 +26,7 @@ Resources.qrc: Makefile echo "</qresource></RCC>" >> $@ Resources.cpp: Resources.qrc - $(RCC4) $< -name Resources -o $@ + $(RCC) $< -name Resources -o $@ ######################### LIBRARIES ############################# @@ -34,15 +34,15 @@ Resources.cpp: Resources.qrc noinst_LTLIBRARIES = liblyxqt4.la liblyxqt4_la_DEPENDENCIES = $(MOCEDFILES) -liblyxqt4_la_LDFLAGS = $(QT4_LDFLAGS) -liblyxqt4_la_LIBADD = $(QT4_LIB) +liblyxqt4_la_LDFLAGS = $(QT_LDFLAGS) +liblyxqt4_la_LIBADD = $(QT_LIBS) AM_CPPFLAGS += \ - $(QT4_CPPFLAGS) \ + $(QT_CPPFLAGS) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/frontends \ -I$(top_srcdir)/images \ - $(QT4_INCLUDES) $(BOOST_INCLUDES) + $(BOOST_INCLUDES) SOURCEFILES = \ ButtonPolicy.cpp \ Index: src/Makefile.am =================================================================== --- src/Makefile.am (revision 24081) +++ src/Makefile.am (working copy) @@ -23,6 +23,9 @@ OTHERLIBS = $(BOOST_LIBS) $(INTLLIBS) $( noinst_LTLIBRARIES = liblyxcore.la bin_PROGRAMS = lyx +lyx_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) +lyx_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) +lyx_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS) lyx_LDADD = \ liblyxcore.la \ liblyxmathed.la \ @@ -32,7 +35,7 @@ lyx_LDADD = \ liblyxgraphics.la \ support/liblyxsupport.la \ $(OTHERLIBS) \ - $(QT4_LIB) + $(QT_LIBS) if LYX_WIN_RESOURCE .rc.o: Index: src/support/Makefile.am =================================================================== --- src/support/Makefile.am (revision 24081) +++ src/support/Makefile.am (working copy) @@ -7,8 +7,7 @@ EXTRA_DIST = pch.h \ noinst_LTLIBRARIES = liblyxsupport.la -liblyxsupport_la_LIBADD = $(LIBSHLWAPI) $(QT4_CORE_LIB) $(BOOST_SIGNALS) -liblyxsupport_la_LDFLAGS = $(QT4_CORE_LDFLAGS) +liblyxsupport_la_LIBADD = $(LIBSHLWAPI) $(BOOST_SIGNALS) BUILT_SOURCES = $(PCH_FILE) @@ -23,7 +22,7 @@ CLEANFILES += $(MOCEDFILES) BUILT_SOURCES += $(MOCEDFILES) %_moc.cpp: %.h - $(MOC4) -o $@ $< + $(MOC) -o $@ $< liblyxsupport_la_DEPENDENCIES = $(MOCEDFILES) @@ -31,7 +30,7 @@ liblyxsupport_la_DEPENDENCIES = $(MOCEDF ################################################################## AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES) -AM_CPPFLAGS += $(QT4_CPPFLAGS) $(QT4_CORE_INCLUDES) -I$(srcdir)/minizip +AM_CPPFLAGS += $(QT_CPPFLAGS) -I$(srcdir)/minizip # force the use of C++ compiler for minizip/*.c files, because # gcc can not go through the included boost files. @@ -148,8 +147,8 @@ check_PROGRAMS = \ check_lstrings check_convert_LDADD = liblyxsupport.la \ - $(BOOST_LIBS) $(QT4_CORE_LIB) -check_convert_LDFLAGS = $(QT4_CORE_LDFLAGS) + $(BOOST_LIBS) $(QT_CORE_LIBS) +check_convert_LDFLAGS = $(QT_CORE_LDFLAGS) check_convert_SOURCES = \ tests/check_convert.cpp \ tests/boost.cpp @@ -159,8 +158,8 @@ check_filetools_SOURCES = \ tests/check_filetools.cpp \ tests/boost.cpp -check_lstrings_LDADD = liblyxsupport.la $(BOOST_LIBS) $(QT4_CORE_LIB) -check_lstrings_LDFLAGS = $(QT4_CORE_LDFLAGS) +check_lstrings_LDADD = liblyxsupport.la $(BOOST_LIBS) $(QT_CORE_LIB) +check_lstrings_LDFLAGS = $(QT_CORE_LDFLAGS) check_lstrings_SOURCES = \ tests/check_lstrings.cpp \ tests/boost.cpp Index: src/client/Makefile.am =================================================================== --- src/client/Makefile.am (revision 24081) +++ src/client/Makefile.am (working copy) @@ -15,7 +15,7 @@ lyxclient.1: lyxclient_LDADD = \ $(top_builddir)/src/support/liblyxsupport.la \ - $(BOOST_LIBS) $(INTLLIBS) @LIBS@ $(SOCKET_LIBS) + $(BOOST_LIBS) $(INTLLIBS) @LIBS@ $(SOCKET_LIBS) $(QT_LIBS) # everything below the line containing the single backslashs # an ugly hack and needed because of the Index: src/tex2lyx/Makefile.am =================================================================== --- src/tex2lyx/Makefile.am (revision 24081) +++ src/tex2lyx/Makefile.am (working copy) @@ -65,7 +65,7 @@ tex2lyx_SOURCES = \ tex2lyx_LDADD = \ $(top_builddir)/src/support/liblyxsupport.la \ - $(LIBICONV) $(BOOST_LIBS) @LIBS@ + $(LIBICONV) $(BOOST_LIBS) @LIBS@ $(QT_LIBS) tex2lyx.1: cp -p $(srcdir)/tex2lyx.man tex2lyx.1 Index: configure.ac =================================================================== --- configure.ac (revision 24081) +++ configure.ac (working copy) @@ -181,18 +181,6 @@ AC_CHECK_HEADERS(zlib.h, [LYX_LIB_ERROR(zlib.h,zlib)]) -### Check for X libraries -AC_PATH_XTRA -case $have_x in - yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS" - CPPFLAGS="$CPPFLAGS $X_CFLAGS";; - no) LYX_ERROR(dnl -[Cannot find X window libraries and/or headers. Check your installation. - If you use a Linux system, check that you have installed - the development tools.]);; - disable) ;; -esac - ### check which frontend we want to use dnl The code below is not in a macro, because this would cause big @@ -200,21 +188,22 @@ dnl problems with the AC_REQUIRE contain for frontend in $FRONTENDS ; do case "$frontend" in qt4) - QT4_DO_IT_ALL + AT_WITH_QT(,[no_keywords genuine_str no_stl clean_namespace]) + AT_REQUIRE_QT_VERSION([4.2.0]) FRONTENDS_PROGS="$FRONTENDS_PROGS lyx-qt4\$(EXEEXT)" FRONTENDS_SUBDIRS="$FRONTENDS_SUBDIRS qt4" RPM_FRONTEND="qt4" FRONTEND_INFO="${FRONTEND_INFO}\ Qt 4 Frontend:\n\ - Qt 4 version:\t\t${QT4_VERSION}\n" + Qt 4 version:\t\t${QT_VERSION}\n" dnl qt 4 build will fail without moc or uic - if test -z "$MOC4"; then - LYX_ERROR([moc 4 binary not found !]) + if test -z "$MOC"; then + LYX_ERROR([moc binary not found !]) fi - if test -z "$UIC4"; then - LYX_ERROR([uic 4 binary not found !]) + if test -z "$UIC"; then + LYX_ERROR([uic binary not found !]) fi - if test -z "$QT4_LIB"; then + if test -z "$QT_LIBS"; then LYX_ERROR([qt 4 library not found !]) fi ;; Index: config/autotroll.m4 =================================================================== --- config/autotroll.m4 (revision 0) +++ config/autotroll.m4 (revision 0) @@ -0,0 +1,360 @@ +# Build Qt apps with the autotools (Autoconf/Automake). +# M4 macros. +# This file is part of AutoTroll. +# Copyright (C) 2006 Benoit Sigoure <[EMAIL PROTECTED]> +# +# AutoTroll is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + + # ------------- # + # DOCUMENTATION # + # ------------- # + +# Disclaimer: Never tested with anything else than Qt 4.2! Feedback welcome. +# Simply invoke AT_WITH_QT in your configure.ac. AT_WITH_QT can take +# arguments which are documented in depth below. The default arguments are +# equivalent to the default .pro file generated by qmake. +# +# Invoking AT_WITH_QT will do the following: +# - Add a --with-qt option to your configure +# - Find qmake, moc and uic and save them in the make variables $(QMAKE), +# $(MOC), $(UIC). +# - Save the path to Qt in $(QT_PATH) +# - Find the flags to use Qt, that is: +# * $(QT_DEFINES): -D's defined by qmake. +# * $(QT_CXXFLAGS): CXXFLAGS as defined by qmake. +# * $(QT_INCPATH): -I's defined by qmake. +# * $(QT_CPPFLAGS): Same as $(QT_DEFINES) + $(QT_INCPATH) +# * $(QT_LDFLAGS): LFLAGS defined by qmake. +# * $(QT_LIBS): LIBS defined by qmake. +# +# You *MUST* invoke $(MOC) and/or $(UIC) where necessary. AutoTroll provides +# you with Makerules to ease this, here is a sample Makefile.am to use with +# AutoTroll which builds the code given in the chapter 7 of the Qt Tutorial: +# http://doc.trolltech.com/4.2/tutorial-t7.html +# +# ------------------------------------------------------------------------- +# include $(top_srcdir)/build-aux/autotroll.mk +# +# ACLOCAL_AMFLAGS = -I build-aux +# +# bin_PROGRAMS = lcdrange +# lcdrange_SOURCES = $(BUILT_SOURCES) lcdrange.cpp lcdrange.h main.cpp +# lcdrange_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) +# lcdrange_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) +# lcdrange_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS) +# lcdrange_LDADD = $(QT_LIBS) $(LDADD) +# +# BUILT_SOURCES = lcdrange.moc.cpp +# ------------------------------------------------------------------------- +# +# Note that your MOC, UIC and QRC files *MUST* be listed manually in +# BUILT_SOURCES. If you name them properly (eg: .moc.cc, .qrc.cc, .ui.cc -- of +# course you can use .cpp or .cxx or .C rather than .cc) AutoTroll will build +# them automagically for you (using implicit rules defined in autotroll.mk). + +m4_pattern_forbid([^AT_])dnl +m4_pattern_forbid([^_AT_])dnl + +# AT_WITH_QT([QT_modules], [QT_config], [QT_misc]) +# ------------------------------------------------ +# Enable Qt support and add an option --with-qt to the configure script. +# +# The QT_modules argument is optional and defines extra modules to enable or +# disable (it's equivalent to the QT variable in .pro files). Modules can be +# specified as follows: +# +# AT_WITH_QT => No argument -> No QT value. +# Qmake sets it to "core gui" by default. +# AT_WITH_QT([xml]) => QT += xml +# AT_WITH_QT([+xml]) => QT += xml +# AT_WITH_QT([-gui]) => QT -= gui +# AT_WITH_QT([xml -gui +sql svg]) => QT += xml sql svg +# QT -= gui +# +# The QT_config argument is also optional and follows the same convention as +# QT_modules. Instead of changing the QT variable, it changes the CONFIG +# variable, which is used to tweak configuration and compiler options. +# +# The last argument, QT_misc (also optional) will be copied as-is the .pro +# file used to guess how to compile Qt apps. You may use it to further tweak +# the build process of Qt apps if tweaking the QT or CONFIG variables isn't +# enough for you. +AC_DEFUN([AT_WITH_QT], +[ AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + AC_REQUIRE([AC_PROG_CXX]) + + test x"$TROLL" != x && echo 'ViM rox emacs.' + +dnl Memo: AC_ARG_WITH(package, help-string, [if-given], [if-not-given]) + AC_ARG_WITH([qt], + [AS_HELP_STRING([--with-qt], + [Path to Qt @<:@Look in PATH and /usr/local/Trolltech@:>@])], + [QT_PATH=$withval/bin], [QT_PATH=]) + + # Find Qt. + if test -d /usr/local/Trolltech; then + # Try to find the latest version. + tmp_qt_paths=`echo /usr/local/Trolltech/*/bin | tr ' ' '\n' | sort -nr \ + | xargs | sed 's/ */:/g'` + fi + + # Find qmake. + AC_PATH_PROGS([QMAKE], [qmake], [missing], [$QT_DIR:$QT_PATH:$PATH:$tmp_qt_paths]) + if test x"$QMAKE" = xmissing; then + AC_MSG_ERROR([Cannot find qmake in your PATH. Try using --with-qt.]) + fi + + # Find moc (Meta Object Compiler). + AC_PATH_PROGS([MOC], [moc], [missing], [$QT_PATH:$PATH:$tmp_qt_paths]) + if test x"$MOC" = xmissing; then + AC_MSG_ERROR([Cannot find moc (Meta Object Compiler) in your PATH. Try using --with-qt.]) + fi + + # Find uic (User Interface Compiler). + AC_PATH_PROGS([UIC], [uic], [missing], [$QT_PATH:$PATH:$tmp_qt_paths]) + if test x"$UIC" = xmissing; then + AC_MSG_ERROR([Cannot find uic (User Interface Compiler) in your PATH. Try using --with-qt.]) + fi + + # Find rcc (Qt Resource Compiler). + AC_PATH_PROGS([RCC], [rcc], [false], [$QT_PATH:$PATH:$tmp_qt_paths]) + if test x"$UIC" = xfalse; then + AC_MSG_WARN([Cannot find rcc (Qt Resource Compiler) in your PATH. Try using --with-qt.]) + fi + + AC_MSG_CHECKING([whether host operating system is Darwin]) + at_darwin="no" + case $host_os in + darwin*) + at_darwin="yes" + QMAKE_ARGS="-spec macx-g++" + ;; + esac + AC_MSG_RESULT([$at_darwin]) + + # If we don't know the path to Qt, guess it from the path to qmake. + if test x"$QT_PATH" = x; then + QT_PATH=`dirname "$QMAKE"` + fi + if test x"$QT_PATH" = x; then + AC_MSG_ERROR([Cannot find the path to your Qt install. Use --with-qt.]) + fi + AC_SUBST([QT_PATH]) + + # Get ready to build a test-app with Qt. + + # Look for a writable temporary directory. + AC_ARG_VAR([TMPDIR], [A temporary directory with write access @<:@/tmp@:>@]) + if test x"$TMPDIR" = x || test ! -d "$TMPDIR" || test ! -w "$TMPDIR"; then + echo "$as_me:$LINENO: no TMPDIR or bad TMPDIR ($TMPDIR)" \ + >&AS_MESSAGE_LOG_FD + for i in /tmp /var/tmp; do + if test -d "$i" && test -w "$i"; then + TMPDIR=$i + export TMPDIR + echo "$as_me:$LINENO: setting TMPDIR=$TMPDIR" >&AS_MESSAGE_LOG_FD + break + fi + done + fi + + # Kludge!! QMake has a very strange behavior. For instance, if you + # install Qt under your $HOME and run QMake somewhere else under your + # $HOME, it will try to be clever and produce Makefiles with relative + # include paths. In order to avoid this, we will test QMake from a + # temporary directory (usually /tmp). Note that this problem was only + # observed with Qt 4. + my_configure_pwd=`pwd` + my_tmpdir="$TMPDIR/conftest$$.dir" + test -d "$my_tmpdir" || mkdir "$my_tmpdir" + if test -w "$my_tmpdir" && cd "$my_tmpdir" + then + : + else + AC_MSG_ERROR([Cannot cd to or write in $my_tmpdir]) + fi + cat >conftest.h <<_ASEOF +#include <QObject> + +class Foo: public QObject +{ + Q_OBJECT; +public: + Foo(); + ~Foo() {} +public Q_SLOTS: + void setValue(int value); +Q_SIGNALS: + void valueChanged(int newValue); +private: + int value_; +}; +_ASEOF + + cat >conftest.cpp <<_ASEOF +#include "conftest.h" +Foo::Foo() + : value_ (42) +{ + connect(this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); +} + +void Foo::setValue(int value) +{ + value_ = value; +} + +int main() +{ + Foo f; +} +_ASEOF +cp conftest.cpp contest2.cpp + if $QMAKE -project; then :; else + AC_MSG_ERROR([Calling $QMAKE -project failed.]) + fi + + # Find the .pro file generated by qmake. + pro_file='conftest.dir.pro' + test -f $pro_file || pro_file=`echo *.pro` + if test -f "$pro_file"; then :; else + AC_MSG_ERROR([Can't find the .pro file generated by Qmake.]) + fi + +dnl Tweak the value of QT in the .pro if have been the 1st arg. +m4_ifval([$1], [_AT_TWEAK_PRO_FILE([QT], [$1])]) + +dnl Tweak the value of CONFIG in the .pro if have been given a 2nd arg. +m4_ifval([$2], [_AT_TWEAK_PRO_FILE([CONFIG], [$2])]) + +m4_ifval([$3], +[ # Add the extra-settings the user wants to set in the .pro + echo "$3" >>"$pro_file" +]) + + echo "$as_me:$LINENO: Invoking $QMAKE on $pro_file" >&AS_MESSAGE_LOG_FD + sed 's/^/| /' "$pro_file" >&AS_MESSAGE_LOG_FD + + if $QMAKE $QMAKE_ARGS; then :; else + AC_MSG_ERROR([Calling $QMAKE failed.]) + fi + + # This sed filter is applied after an expression of the form: /^FOO.*=/!d; + # It starts by removing the beginning of the line, removing references to + # SUBLIBS, removing unnecessary whitespaces at the beginning, and prefixes + # all variable uses by QT_. + qt_sed_filter='s///; + s/$(SUBLIBS)//g; + s/^ *//; + s/\$(\(@<:@A-Z_@:>@@<:@A-Z_@:>@*\))/$(QT_\1)/g' + + # Find the Makefile (qmake happens to generate a fake Makefile which invokes + # a Makefile.Debug or Makefile.Release). We we have both, we'll pick the + # Makefile.Release. The reason is that the main difference is that release + # uses -Os and debug -g. We can override -Os by passing another -O but we + # usually don't override -g. + if test -f Makefile.Release; then + at_mfile='Makefile.Release' + else + at_mfile='Makefile' + fi + if test -f $at_mfile; then :; else + cd "$my_configure_pwd" + AC_MSG_ERROR([Cannot find the Makefile generated by qmake.]) + fi + + # Find the DEFINES of Qt (should have been named CPPFLAGS). + AC_CACHE_CHECK([for the DEFINES to use with Qt], [at_cv_env_QT_DEFINES], + [at_cv_env_QT_DEFINES=`sed "/^DEFINES@<:@^A-Z@:>@*=/!d;$qt_sed_filter" $at_mfile`]) + AC_SUBST([QT_DEFINES], [$at_cv_env_QT_DEFINES]) + + # Find the INCPATH of Qt. + AC_CACHE_CHECK([for the INCPATH to use with Qt], [at_cv_env_QT_INCPATH], + [at_cv_env_QT_INCPATH=`sed "/^INCPATH@<:@^A-Z@:>@*=/!d;$qt_sed_filter" $at_mfile`]) + AC_SUBST([QT_INCPATH], [$at_cv_env_QT_INCPATH]) + + AC_SUBST([QT_CPPFLAGS], ["$at_cv_env_QT_DEFINES $at_cv_env_QT_INCPATH"]) + + # Find the LFLAGS of Qt (Should have been named LDFLAGS) + AC_CACHE_CHECK([for the LDFLAGS to use with Qt], [at_cv_env_QT_LDFLAGS], + [at_cv_env_QT_LDFLAGS=`sed "/^LFLAGS@<:@^A-Z@:>@*=/!d;$qt_sed_filter" $at_mfile`]) + AC_SUBST([QT_LDFLAGS], [$at_cv_env_QT_LDFLAGS]) + + # Find the LIBS of Qt. + AC_CACHE_CHECK([for the LIBS to use with Qt], [at_cv_env_QT_LIBS], + [at_cv_env_QT_LIBS=`sed "/^LIBS@<:@^A-Z@:>@*=/!d;$qt_sed_filter" $at_mfile` + if test x$at_darwin = xyes; then + # Fix QT_LIBS: as of today Libtool (GNU Libtool 1.5.23a) doesn't handle + # -F properly. The "bug" has been fixed on 22 October 2006 + # by Peter O'Gorman but we provide backward compatibility here. + at_cv_env_QT_LIBS=`echo "$at_cv_env_QT_LIBS" \ + | sed 's/^-F/-Wl,-F/;s/ -F/ -Wl,-F/g'` + fi + ]) + AC_SUBST([QT_LIBS], [$at_cv_env_QT_LIBS]) + + cd "$my_configure_pwd" || echo 'WTF!' + rm -rf "$my_tmpdir" +]) + +# AT_REQUIRE_QT_VERSION(QT_version) +# --------------------------------- +# Check (using qmake) that Qt's version "matches" QT_version. +# Must be run AFTER AT_WITH_QT. Requires autoconf 2.60. +AC_DEFUN([AT_REQUIRE_QT_VERSION], +[ AC_PREREQ([2.60]) + if test x"$QMAKE" = x; then + AC_MSG_ERROR([\$QMAKE is empty. \ +Did you invoke AT@&[EMAIL PROTECTED] before AT@&[EMAIL PROTECTED]) + fi + AC_CACHE_CHECK([for Qt's version], [at_cv_QT_VERSION], + [echo "$as_me:$LINENO: Running $QMAKE --version:" >&AS_MESSAGE_LOG_FD + $QMAKE --version >&AS_MESSAGE_LOG_FD 2>&1 + qmake_version_sed=['/^.*\([0-9]\.[0-9]\.[0-9]\).*$/!d;s//\1/'] + at_cv_QT_VERSION=`$QMAKE --version 2>&1 | sed "$qmake_version_sed"`]) + if test x"$at_cv_QT_VERSION" = x; then + AC_MSG_ERROR([Cannot detect Qt's version.]) + fi + AC_SUBST([QT_VERSION], [$at_cv_QT_VERSION]) + AS_VERSION_COMPARE([$QT_VERSION], [$1], + [AC_MSG_ERROR([This package requires Qt $1 or above.])]) +]) + +# _AT_TWEAK_PRO_FILE(QT_VAR, VALUE) +# --------------------------- +# @internal. Tweak the variable QT_VAR in the .pro. +# VALUE is an IFS-separated list of value and each value is rewritten +# as follows: +# +value => QT_VAR += value +# -value => QT_VAR -= value +# value => QT_VAR += value +AC_DEFUN([_AT_TWEAK_PRO_FILE], +[ # Tweak the value of $1 in the .pro file for $2. + + qt_conf='' + for at_mod in $2; do + at_mod=`echo "$at_mod" | sed 's/^-//; tough + s/^+//; beef + :ough + s/^/$1 -= /;n + :eef + s/^/$1 += /'` + qt_conf="$qt_conf +$at_mod" + done + echo "$qt_conf" | sed 1d >>"$pro_file" +])