source: trunk/m4/yat.m4 @ 2856

Last change on this file since 2856 was 2856, checked in by Peter, 9 years ago

if test fails, skip downstream tests

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 10.3 KB
Line 
1## $Id: yat.m4 2856 2012-09-26 01:14:52Z peter $
2#
3# serial 8  (yat 0.10)
4#
5# see http://www.gnu.org/software/automake/manual/automake.html#Serials
6#
7# SYNOPSIS
8#
9#   YAT_CHECK_YAT([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
10#
11# DESCRIPTION
12#
13#   Test yat library of a particular version
14#
15#   This macro file can be used by applications to find and use the
16#   yat library.
17#
18#   Note: macros in this file assume that yat-config has been
19#         installed.  yat-config was introduced in yat 0.5 and
20#         consequently these macros do not work with yat 0.4.x (or
21#         older).
22#
23#   This macro calls:
24#
25#     AC_SUBST(YAT_CPPFLAGS)
26#     AC_SUBST(YAT_CXXFLAGS)
27#     AC_SUBST(YAT_LDFLAGS)
28#     AC_SUBST(YAT_LIBS)
29#     AC_SUBST(YAT_LA_FILE)
30#     AC_SUBST(YAT_LT_ADD)
31#
32#   defines:
33#
34#     HAVE_YAT
35#
36#   and sets the following variable:
37#
38#     yat_config:    If yat-config exists, $yat_config refers to it,
39#                    otherwise $yat_config is set to "no".
40#
41#
42#   YAT_CHECK_YAT is split into sub-macros:
43#
44#     YAT_FIND_YAT()
45#     YAT_CHECK_VERSION([MINIMUM-VERSION])
46#     YAT_CHECK_HEADER()
47#     YAT_CHECK_LIB()
48#
49#   so when preferable, you can call any of these instead.
50#
51#
52#   YAT_FIND_YAT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
53#
54#     Finds the yat-config scripts. If there is no --with-yat
55#     specified, it will look in the PATH. Sets a shell variable
56#     $yat_config. $yat_config is required for the other macros and
57#     therefore if YAT_FIND_YAT has not been called, they will call
58#     YAT_FIND_YAT. If --without-yat (or equivalently --with-yat=no)
59#     is given, all tests and actions are turned off.
60#
61#
62#   YAT_CHECK_VERSION([MINIMUM-VERSION=0.5],
63#                     [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
64#
65#     If the version of yat is at least MINIMUM-VERSION, execute
66#     ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND.
67#
68#
69#   YAT_CHECK_HEADER([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
70#
71#     If yat headers are found and compilable, call
72#     AC_SUBST(YAT_CPPFLAGS) and AC_SUBST(YAT_CXXFLAGS), define
73#     HAVE_YAT, execute ACTION-IF-FOUND. If test compilation failed
74#     execute ACTION-IF-NOT-FOUND.
75#
76#
77#   YAT_CHECK_LIB([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
78#
79#     Compile a small program and link it to yat. On success call
80#     AC_SUBST(YAT_LDFLAGS), AC_SUBST(YAT_LIBS), AC_SUBST(YAT_LT_ADD),
81#     and AC_SUBST(YAT_LA_FILE), and define HAVE_YAT, and execute
82#     ACTION-IF-FOUND. On failure execute ACTION-IF-NOT-FOUND.
83#
84#
85#
86# LAST MODIFICATION
87#
88#   $Date: 2012-09-26 01:14:52 +0000 (Wed, 26 Sep 2012) $
89#
90# COPYLEFT
91#
92#   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
93#   Copyright (C) 2009, 2010, 2011, 2012 Peter Johansson
94#
95#   This file is part of the yat library, http://dev.thep.lu.se/yat
96#
97#   The yat library is free software; you can redistribute it and/or
98#   modify it under the terms of the GNU General Public License as
99#   published by the Free Software Foundation; either version 3 of the
100#   License, or (at your option) any later version.
101#
102#   The yat library is distributed in the hope that it will be useful,
103#   but WITHOUT ANY WARRANTY; without even the implied warranty of
104#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
105#   General Public License for more details.
106#
107#   You should have received a copy of the GNU General Public License
108#   along with yat. If not, see <http://www.gnu.org/licenses/>.
109#
110
111AC_DEFUN([YAT_CHECK_YAT],
112[
113AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT
114ac_yat_check_yat_res="yes"
115AC_REQUIRE([YAT_FIND_YAT])  dnl
116YAT_CHECK_VERSION([$1],,[ac_yat_check_yat_res="no"])
117
118AS_IF([test x$ac_yat_check_yat_res = xyes], [
119  YAT_CHECK_HEADER(,[ac_yat_check_yat_res="no"])
120])
121
122AS_IF([test x$ac_yat_check_yat_res = xyes], [
123  YAT_CHECK_LIB(,[ac_yat_check_yat_res="no"])
124])
125
126_YAT_ACTION([test "$ac_yat_check_yat_res" != "no"],[$2],[$3])
127
128]) # YAT_CHECK_YAT
129
130
131AC_DEFUN([YAT_FIND_YAT],
132[
133  AC_PREREQ([2.60]) dnl we use multi-arg AS_IF
134  AC_ARG_WITH([yat],
135     [AS_HELP_STRING([--with-yat=DIR],
136                [prefix for installed yat library or full path to yat-config])],
137     [],
138     [with_yat=yes])
139
140  yat_config=no;
141  yat_ac_want_yat=yes;
142  AS_IF([test "x$with_yat" = "xno"],
143    [yat_ac_want_yat=no],
144    [test "x$with_yat" = "xyes"],
145    [AC_PATH_PROG([yat_config], [yat-config], [no])
146     AS_IF([test "$yat_config" = "no"],
147       [AC_MSG_WARN([
148           the yat-config script installed by yat could not be found. If yat was
149           installed in PREFIX, make sure PREFIX/bin is in your path, or supply
150           the appropriate --with-yat option])
151       ])
152    ],
153    [AC_MSG_NOTICE([looking for yat-config])
154     for p in $with_yat $with_yat/yat-config $with_yat/bin/yat-config ; do
155       AS_IF([test "x$yat_config" = "xno"],
156             [AC_MSG_CHECKING([$p]);
157              AS_IF([test -f "$p" && $p --help > /dev/null 2>&1],
158                    [yat_config=$p;
159                     AC_MSG_RESULT([yes]);],
160                    [AC_MSG_RESULT([no]);])
161             ])
162     done
163     AS_IF([test "$yat_config" = "no"],
164        [AC_MSG_WARN([
165           the --with-yat parameter is incorrect. It must
166           specify an install prefix, or a yat-config file.])
167        ])
168    ])
169
170  _YAT_ACTION([test "$yat_config" != "no"],[$1],[$2])
171
172
173]) # YAT_FIND_YAT
174
175
176
177AC_DEFUN([YAT_CHECK_VERSION],
178[
179  AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT
180  AC_REQUIRE([YAT_FIND_YAT])  dnl
181  if test "$yat_config" != "no"; then
182    m4_pushdef([yat_min_version], [m4_default([$1], [0.5])]) dnl
183    AC_MSG_CHECKING([if version of yat is at least yat_min_version])
184
185    if $yat_config --atleast-version=yat_min_version; then
186      AC_MSG_RESULT([yes])
187      ac_yat_version_ok=yes;
188    else
189      AC_MSG_RESULT([no])
190      ac_yat_version=`$yat_config --version`
191      AC_MSG_WARN([
192       '$yat_config --version' returned $ac_yat_version,
193        but the minimum required version is yat_min_version.])
194    fi
195    m4_popdef([yat_min_version]) dnl
196  fi
197
198  _YAT_ACTION([test "$ac_yat_version_ok" = "yes"],[$2],[$3])
199
200]) # YAT_CHECK_VERSION
201
202
203
204AC_DEFUN([YAT_CHECK_HEADER],
205[
206  AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT
207  AC_REQUIRE([YAT_FIND_YAT])  dnl
208  if test "$yat_config" != "no"; then
209    ac_yat_save_CPPFLAGS=$CPPFLAGS
210    ac_yat_save_CXXFLAGS=$CXXFLAGS
211    YAT_CPPFLAGS=`$yat_config --cppflags`
212    YAT_CXXFLAGS=`$yat_config --cxxflags`
213    CPPFLAGS="$CPPFLAGS $YAT_CPPFLAGS"
214    CXXFLAGS="$CXXFLAGS $YAT_CXXFLAGS"
215    AC_LANG_ASSERT([C++])
216    # checking for Vector, which uses both GSL and Boost
217    AC_CHECK_HEADER([yat/utility/Vector.h],
218                    [ac_yat_ok="yes"],
219                    [ac_yat_ok="no"])
220
221    # checking that version in yat-config and version.h agree
222    AC_MSG_CHECKING([version in $yat_config])
223    yat_config_version=`$yat_config --version`
224    AC_MSG_RESULT([$yat_config_version])
225
226    AC_CACHE_CHECK([version in 'yat/utility/version.h'],
227      [yat_cv_header_version_equal_yat_config],
228      [yat_cv_header_version_equal_yat_config=no
229       AC_COMPILE_IFELSE(
230         [AC_LANG_PROGRAM([@%:@include <yat/utility/version.h>],
231          [ @%:@if YAT_VERSION_AT_LEAST(`$yat_config --version-major`,\
232                                     `$yat_config --version-minor`,\
233                                     `$yat_config --version-patch`)
234            // Versions agree
235            @%:@else
236            @%:@ error yat versions disagree
237            @%:@endif
238          ])
239         ],
240         [yat_cv_header_version_equal_yat_config=yes],
241         [yat_cv_header_version_equal_yat_config=no])
242
243      ])
244
245    AS_IF([test x$yat_cv_header_version_equal_yat_config = xyes], [
246           ac_yat_ok=yes;
247           AC_SUBST(YAT_CPPFLAGS)
248           AC_SUBST(YAT_CXXFLAGS)
249           AC_DEFINE([HAVE_YAT],[1],[define if yat library is available])
250          ], [
251           AC_MSG_WARN([
252           version declared in included yat/utility/version.h is not equal to
253           the one given from yat-config script: $yat_config.])
254           ac_yat_ok=no
255          ])
256
257    # restore FLAGS
258    CPPFLAGS=$ac_yat_save_CPPFLAGS
259    CXXFLAGS=$ac_yat_save_CXXFLAGS
260  fi
261
262  _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2])
263
264]) # YAT_CHECK_HEADER
265
266
267
268AC_DEFUN([YAT_CHECK_LIB],
269[
270  AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT
271  AC_REQUIRE([YAT_FIND_YAT])  dnl
272  if test "$yat_config" != "no"; then
273    ac_yat_save_LDFLAGS=$LDFLAGS
274    ac_yat_save_LIBS=$LIBS
275    YAT_LDFLAGS=`$yat_config --ldflags`
276    YAT_LIBS=`$yat_config --libs`
277    LDFLAGS="$LDFLAGS $YAT_LDFLAGS"
278    LIBS="$LIBS $YAT_LIBS"
279    AC_LANG_ASSERT([C++])
280    AC_CACHE_CHECK([for utility::version(void) in yat],
281                   [yat_cv_lib_yat],
282                   [_YAT_CHECK_LIB_YAT([yat_cv_lib_yat=yes],
283                                       [yat_cv_lib_yat=no])])
284
285    AS_IF([test x$yat_cv_lib_yat = xyes], [
286                    ac_yat_ok="yes";
287                    AC_SUBST(YAT_LDFLAGS)
288                    AC_SUBST(YAT_LIBS)
289                    # be compatible with yat-config 0.5.x
290                    AS_IF([$yat_config --atleast-version=0.6],
291                          [YAT_LA_FILE=`$yat_config --yat-la-file`;],
292                          [YAT_LA_FILE=`$yat_config --link-libtool`;])
293                    AC_SUBST(YAT_LA_FILE)
294                    YAT_LT_ADD=`$yat_config --link-libtool`;
295                    AC_SUBST(YAT_LT_ADD)],
296                   [ac_yat_ok="no";
297                    AC_MSG_RESULT([no])
298                    AC_MSG_WARN([
299           the test program failed to link (or compile). See file config.log for
300           details on what occured.])
301                   ])
302    # restore FLAGS
303    LDFLAGS=$ac_yat_save_LDFLAGS
304    LIBS=$ac_yat_save_LIBS
305  fi
306
307  _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2])
308
309]) # YAT_CHECK_LIB
310
311# Private macros
312#
313# if yat_ac_want_yat = no do nothing
314# if $1 do $2 else do $3
315#
316AC_DEFUN([_YAT_ACTION],
317[
318  AS_IF([test "x$yat_ac_want_yat" = "xno"],[],
319        [$1],[m4_default([$2], [:])],
320        [m4_default([$3], [:])])
321])
322
323
324# _YAT_CHECK_LIB_YAT([ACTION-IF_FOUND], [ACTION-IF-NOT-FOUND])
325#
326AC_DEFUN([_YAT_CHECK_LIB_YAT],
327[
328    AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <string>
329                                      namespace theplu{
330                                      namespace yat{
331                                      namespace utility {
332                                      std::string version(void);
333                                      }}}
334                                    ]],
335                                    [using namespace theplu::yat::utility;
336                                     std::string s=version();])],
337                   [$1], [$2])
338])
Note: See TracBrowser for help on using the repository browser.