1 | ## $Id: yat.m4 2023 2009-08-05 11:51:20Z 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: 2009-08-05 11:51:20 +0000 (Wed, 05 Aug 2009) $ |
---|
84 | # |
---|
85 | # COPYLEFT |
---|
86 | # |
---|
87 | # Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
---|
88 | # Copyright (C) 2009 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 3 # 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_yat_check_yat_res="yes" |
---|
114 | AC_REQUIRE([YAT_FIND_YAT]) dnl |
---|
115 | YAT_CHECK_VERSION([$1],,[ac_yat_check_yat_res="no"]) |
---|
116 | YAT_CHECK_HEADER(,[ac_yat_check_yat_res="no"]) |
---|
117 | YAT_CHECK_LIB(,[ac_yat_check_yat_res="no"]) |
---|
118 | |
---|
119 | _YAT_ACTION([test "$ac_yat_check_yat_res" != "no"],[$2],[$3]) |
---|
120 | |
---|
121 | ]) # YAT_CHECK_YAT |
---|
122 | |
---|
123 | |
---|
124 | AC_DEFUN([YAT_FIND_YAT], |
---|
125 | [ |
---|
126 | AC_ARG_WITH([yat], |
---|
127 | [AS_HELP_STRING([--with-yat=DIR], |
---|
128 | [prefix for installed yat library or full path to yat-config])], |
---|
129 | [], |
---|
130 | [with_yat=yes]) |
---|
131 | |
---|
132 | yat_config=no; |
---|
133 | yat_ac_want_yat=yes; |
---|
134 | AS_IF([test "x$with_yat" = "xno"], |
---|
135 | [yat_ac_want_yat=no], |
---|
136 | [test "x$with_yat" = "xyes"], |
---|
137 | [AC_PATH_PROG([yat_config], [yat-config], [no]) |
---|
138 | AS_IF([test "$yat_config" = "no"], |
---|
139 | [AC_MSG_WARN([ |
---|
140 | the yat-config script installed by yat could not be found. If yat was |
---|
141 | installed in PREFIX, make sure PREFIX/bin is in your path, or supply |
---|
142 | the appropriate --with-yat option]) |
---|
143 | ]) |
---|
144 | ], |
---|
145 | [AC_MSG_NOTICE([looking for yat-config]) |
---|
146 | for p in $with_yat $with_yat/yat-config $with_yat/bin/yat-config ; do |
---|
147 | AS_IF([test "x$yat_config" = "xno"], |
---|
148 | [AC_MSG_CHECKING([$p]); |
---|
149 | AS_IF([test -f "$p" && $p --help > /dev/null 2>&1], |
---|
150 | [yat_config=$p; |
---|
151 | AC_MSG_RESULT([yes]);], |
---|
152 | [AC_MSG_RESULT([no]);]) |
---|
153 | ]) |
---|
154 | done |
---|
155 | AS_IF([test "$yat_config" = "no"], |
---|
156 | [AC_MSG_WARN([ |
---|
157 | the --with-yat parameter is incorrect. It must |
---|
158 | specify an install prefix, or a yat-config file.]) |
---|
159 | ]) |
---|
160 | ]) |
---|
161 | |
---|
162 | _YAT_ACTION([test "$yat_config" != "no"],[$1],[$2]) |
---|
163 | |
---|
164 | |
---|
165 | ]) # YAT_FIND_YAT |
---|
166 | |
---|
167 | |
---|
168 | |
---|
169 | AC_DEFUN([YAT_CHECK_VERSION], |
---|
170 | [ |
---|
171 | AC_REQUIRE([YAT_FIND_YAT]) dnl |
---|
172 | if test "$yat_config" != "no"; then |
---|
173 | ac_yat_min_version=m4_default([$1], [0.5]) |
---|
174 | AC_MSG_CHECKING(if version of yat is at least $ac_yat_min_version) |
---|
175 | |
---|
176 | if $yat_config --atleast-version=$ac_yat_min_version; then |
---|
177 | AC_MSG_RESULT([yes]) |
---|
178 | ac_yat_version_ok=yes; |
---|
179 | else |
---|
180 | AC_MSG_RESULT([no]) |
---|
181 | ac_yat_version=`$yat_config --version` |
---|
182 | AC_MSG_WARN([ |
---|
183 | '$yat_config --version' returned $ac_yat_version, |
---|
184 | but the minimum required version is $ac_yat_min_version.]) |
---|
185 | fi |
---|
186 | fi |
---|
187 | |
---|
188 | _YAT_ACTION([test "$ac_yat_version_ok" = "yes"],[$2],[$3]) |
---|
189 | |
---|
190 | ]) # YAT_CHECK_VERSION |
---|
191 | |
---|
192 | |
---|
193 | |
---|
194 | AC_DEFUN([YAT_CHECK_HEADER], |
---|
195 | [ |
---|
196 | AC_REQUIRE([YAT_FIND_YAT]) dnl |
---|
197 | if test "$yat_config" != "no"; then |
---|
198 | ac_yat_save_CPPFLAGS=$CPPFLAGS |
---|
199 | ac_yat_save_CXXFLAGS=$CXXFLAGS |
---|
200 | YAT_CPPFLAGS=`$yat_config --cppflags` |
---|
201 | YAT_CXXFLAGS=`$yat_config --cxxflags` |
---|
202 | CPPFLAGS="$CPPFLAGS $YAT_CPPFLAGS" |
---|
203 | CXXFLAGS="$CXXFLAGS $YAT_CXXFLAGS" |
---|
204 | AC_LANG_ASSERT([C++]) |
---|
205 | # checking for Vector, which uses both GSL and Boost |
---|
206 | AC_CHECK_HEADER([yat/utility/Vector.h], |
---|
207 | [ac_yat_ok="yes"], |
---|
208 | [ac_yat_ok="no"]) |
---|
209 | |
---|
210 | # checking that version in yat-config and version.h agree |
---|
211 | AC_MSG_CHECKING([version in $yat_config]) |
---|
212 | yat_config_version=`$yat_config --version` |
---|
213 | AC_MSG_RESULT([$yat_config_version]) |
---|
214 | AC_MSG_CHECKING([YAT_VERSION in <yat/utility/version.h>]) |
---|
215 | AC_COMPILE_IFELSE( |
---|
216 | [AC_LANG_PROGRAM([@%:@include <yat/utility/version.h>], |
---|
217 | [ #if YAT_VERSION_AT_LEAST(`$yat_config --version-major`,\ |
---|
218 | `$yat_config --version-minor`,\ |
---|
219 | `$yat_config --version-patch`) |
---|
220 | // Versions agree |
---|
221 | #else |
---|
222 | # error yat versions disagree |
---|
223 | #endif |
---|
224 | ]) |
---|
225 | ], |
---|
226 | [AC_MSG_RESULT([ok]); |
---|
227 | ac_yat_ok="yes"; |
---|
228 | AC_SUBST(YAT_CPPFLAGS) |
---|
229 | AC_SUBST(YAT_CXXFLAGS) |
---|
230 | AC_DEFINE(HAVE_YAT,,[define if yat library is available])], |
---|
231 | [AC_MSG_RESULT([incorrect]); |
---|
232 | AC_MSG_WARN([ |
---|
233 | version declared in included yat/utility/version.h is not equal to |
---|
234 | the one given from yat-config script: $yat_config.]) |
---|
235 | ac_yat_ok="no"; |
---|
236 | ]) |
---|
237 | |
---|
238 | # restore FLAGS |
---|
239 | CPPFLAGS=$ac_yat_save_CPPFLAGS |
---|
240 | CXXFLAGS=$ac_yat_save_CXXFLAGS |
---|
241 | fi |
---|
242 | |
---|
243 | _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2]) |
---|
244 | |
---|
245 | ]) # YAT_CHECK_HEADER |
---|
246 | |
---|
247 | |
---|
248 | |
---|
249 | AC_DEFUN([YAT_CHECK_LIB], |
---|
250 | [ |
---|
251 | AC_REQUIRE([YAT_FIND_YAT]) dnl |
---|
252 | if test "$yat_config" != "no"; then |
---|
253 | ac_yat_save_LDFLAGS=$LDFLAGS |
---|
254 | ac_yat_save_LIBS=$LIBS |
---|
255 | YAT_LDFLAGS=`$yat_config --ldflags` |
---|
256 | YAT_LIBS=`$yat_config --libs` |
---|
257 | LDFLAGS="$LDFLAGS $YAT_LDFLAGS" |
---|
258 | LIBS="$LIBS $YAT_LIBS" |
---|
259 | AC_LANG_ASSERT([C++]) |
---|
260 | AC_MSG_CHECKING([for utility::version(void) in yat]) |
---|
261 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <string> |
---|
262 | namespace theplu{ |
---|
263 | namespace yat{ |
---|
264 | namespace utility { |
---|
265 | std::string version(void); |
---|
266 | }}} |
---|
267 | ]], |
---|
268 | [using namespace theplu::yat::utility; |
---|
269 | std::string s=version();])], |
---|
270 | [ac_yat_ok="yes"; |
---|
271 | AC_MSG_RESULT([yes]) |
---|
272 | AC_SUBST(YAT_LDFLAGS) |
---|
273 | AC_SUBST(YAT_LIBS) |
---|
274 | # be compatible with yat-config 0.5.x |
---|
275 | AS_IF([$yat_config --atleast-version=0.6], |
---|
276 | [YAT_LA_FILE=`$yat_config --link-libtool`;], |
---|
277 | [YAT_LA_FILE=`$yat_config --yat-la-file`;]) |
---|
278 | AC_SUBST(YAT_LA_FILE)], |
---|
279 | YAT_LT_ADD=`$yat_config --link-libtool`; |
---|
280 | AC_SUBST(YAT_LT_ADD)], |
---|
281 | [ac_yat_ok="no"; |
---|
282 | AC_MSG_RESULT([no]) |
---|
283 | AC_MSG_WARN([ |
---|
284 | the test program failed to link (or compile). See file config.log for |
---|
285 | details on what occured.]) |
---|
286 | ]) |
---|
287 | # restore FLAGS |
---|
288 | LDFLAGS=$ac_yat_save_LDFLAGS |
---|
289 | LIBS=$ac_yat_save_LIBS |
---|
290 | fi |
---|
291 | |
---|
292 | _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2]) |
---|
293 | |
---|
294 | ]) # YAT_CHECK_LIB |
---|
295 | |
---|
296 | # Private macro |
---|
297 | # |
---|
298 | # if yat_ac_want_yat = no do nothing |
---|
299 | # if $1 do $2 else do $3 |
---|
300 | # |
---|
301 | AC_DEFUN([_YAT_ACTION], |
---|
302 | [ |
---|
303 | AS_IF([test "x$yat_ac_want_yat" = "xno"],[], |
---|
304 | [$1],[m4_default([$2], [:])], |
---|
305 | [m4_default([$3], [:])]) |
---|
306 | ]) |
---|