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