Add a serial to autotroll.m4 and log it.
[autotroll.git] / build-aux / qscintilla2.m4
blob83842d02a75f83b6df94fff31ea023800801acf4
1 # M4 macros to build Qt apps that use qscintilla2 with the autotools
2 # (Autoconf/Automake).
3 # This file is part of AutoTroll.
4 # Copyright (C) 2006  Benoit Sigoure <tsuna@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 # This file relies on values (QT_*) defined by AutoTroll.
38 # Although it is not *required* to use AutoTroll along with this file, doing
39 # so provides better results since QScintilla is often located where Qt is.
41 # WITH_QSCINTILLA2()
42 # ------------------
43 # Check whether QsciScintilla2 is installed and usable.
44 # Defines $(QSCINTILLA2_LDFLAGS) which must be used before the Qt flags (if
45 # any).
46 AC_DEFUN([WITH_QSCINTILLA2],
47 [ AC_REQUIRE([AC_PROG_CXX])
48   AC_REQUIRE([AC_EXEEXT])
50   AC_ARG_WITH([qscintilla2],
51               [AS_HELP_STRING([--with-qscintilla2].
52                  [LDFLAGS to use for qscintilla2 @<:@-lqscintilla2 + Same as Qt@:>@])],
53               [QSCINTILLA2_LDFLAGS=$withval], [QSCINTILLA2_LDFLAGS='-lqscintilla2'])
55   # FIXME: Can we use a macro from autoconf to make something similar?
56   AC_CACHE_CHECK([for lib qscintilla2], [qt_cv_lqscintilla2],
57   [qt_cv_lqscintilla2=no
58   if mkdir conftest.dir && cd conftest.dir; then :; else
59     AC_MSG_ERROR([Cannot mkdir conftest.dir or cd to that directory.])
60   fi
61   cat >conftest.cpp <<_ASEOF
62 #include <Qsci/qsciscintilla.h>
63 #ifdef main  // Temporary work-around for Windows: Qt #defines main qMain
64 # undef main // but for some reason *I* can't link Qt apps because the linker
65 #endif       // fails to find it. To be FIXME'd.
66 struct Test: public QsciScintilla
70 int main ()
72   Test t;
74 _ASEOF
75   cat >Makefile <<_ASEOF
76 CXX = $CXX
77 QT_DEFINES = $QT_DEFINES
78 QT_CPPFLAGS = $QT_CPPFLAGS
79 AM@&t@?_CPPFLAGS = $AM@&t@?_CPPFLAGS
80 CPPFLAGS = $CPPFLAGS
81 QT_CXXFLAGS = $QT_CXXFLAGS
82 AM@&t@?_CXXFLAGS = $AM@&t@?_CXXFLAGS
83 CXXFLAGS = $CXXFLAGS
84 QT_LDFLAGS = $QT_LDFLAGS
85 LDFLAGS = $LDFLAGS
86 QSCINTILLA2_LDFLAGS = $QSCINTILLA2_LDFLAGS
87 QT_LIBS = $QT_LIBS
88 LIBS = $LIBS
90 all: conftest$EXEEXT
92 conftest$EXEEXT: conftest.cpp
93         $CXX $QT_CPPFLAGS $AM_CPPFLAGS $CPPFLAGS \
94           $MY_QT_CXXFLAGS $AM_CXXFLAGS $CXXFLAGS \
95           conftest.cpp -o conftest$EXEEXT \
96           $QT_LDFLAGS $LDFLAGS \
97           $QSCINTILLA2_LDFLAGS $QT_LIBS $LIBS
98 _ASEOF
100   : ${MAKE=make}
101   echo "$as_me:$LINENO: running $MAKE to check that qscintilla2 works:" \
102     >&AS_MESSAGE_LOG_FD
103   if $MAKE >&AS_MESSAGE_LOG_FD 2>&1;
104   then
105     if test x"$QT_LIBS" != x; then
106       qt_cv_lqscintilla2="$QSCINTILLA2_LDFLAGS + Qt stuff"
107     else
108       qt_cv_lqscintilla2="$QSCINTILLA2_LDFLAGS"
109     fi
110   fi
111   if test x"$qt_cv_lqscintilla2" = xno; then
112     echo "$as_me:$LINENO: failed program was:" >&AS_MESSAGE_LOG_FD
113     sed 's/^/| /' conftest.cpp >&AS_MESSAGE_LOG_FD
114     echo "$as_me:$LINENO: tried to compile with the following Makefile:" \
115       >&AS_MESSAGE_LOG_FD
116     sed 's/^/| /' Makefile >&AS_MESSAGE_LOG_FD
117   fi
118   cd .. && rm -rf conftest.dir
119   ])dnl End of AC_CACHE_CHECK for -lqscintilla2
121   if test x"$qt_cv_lqscintilla2" = xno; then
122     AC_MSG_ERROR([Cannot link with -lqscintilla2.])
123   fi
124   AC_SUBST([QSCINTILLA2_LDFLAGS])