Commits

Ville Suoranta authored e17b8bfe4f4 Merge
Add 'casatools/' from commit '67c4308561d50faf7c05cbb9ff7cfc6259b8ba6b'

git-subtree-dir: casatools git-subtree-mainline: eea230e82bd2625d8e2d87bd2ccae981bd84eb18 git-subtree-split: 67c4308561d50faf7c05cbb9ff7cfc6259b8ba6b

casatools/ac/m4/m4_ax_boost_base.m4

Added
1 +# ===========================================================================
2 +# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
3 +# ===========================================================================
4 +#
5 +# SYNOPSIS
6 +#
7 +# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
8 +#
9 +# DESCRIPTION
10 +#
11 +# Test for the Boost C++ libraries of a particular version (or newer)
12 +#
13 +# If no path to the installed boost library is given the macro searchs
14 +# under /usr, /usr/local, /opt and /opt/local and evaluates the
15 +# $BOOST_ROOT environment variable. Further documentation is available at
16 +# <http://randspringer.de/boost/index.html>.
17 +#
18 +# This macro sets:
19 +#
20 +# HAVE_BOOST
21 +#
22 +# and defines (shell variables) BOOST_INCLUDE_PATH and BOOST_LIBRARY_PATH
23 +#
24 +# LICENSE
25 +#
26 +# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
27 +# Copyright (c) 2009 Peter Adolphs
28 +# Copyright (c) 2015 Associated Universities Inc.
29 +#
30 +# Copying and distribution of this file, with or without modification, are
31 +# permitted in any medium without royalty provided the copyright notice
32 +# and this notice are preserved. This file is offered as-is, without any
33 +# warranty.
34 +
35 +#serial 26
36 +
37 +AC_DEFUN([AX_BOOST_BASE],
38 +[
39 +HAVE_BOOST=0
40 +AC_SUBST(HAVE_BOOST)
41 +AC_ARG_WITH([boost],
42 + [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
43 + [use Boost library from a standard location (ARG=yes),
44 + from the specified location (ARG=<path>),
45 + or disable it (ARG=no)
46 + @<:@ARG=yes@:>@ ])],
47 + [
48 + if test "$withval" = "no"; then
49 + want_boost="no"
50 + elif test "$withval" = "yes"; then
51 + want_boost="yes"
52 + ac_boost_path=""
53 + else
54 + want_boost="yes"
55 + ac_boost_path="$withval"
56 + fi
57 + ],
58 + [want_boost="yes"])
59 +
60 +
61 +AC_ARG_WITH([boost-libdir],
62 + AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
63 + [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
64 + [
65 + if test -d "$withval"
66 + then
67 + ac_boost_lib_path="$withval"
68 + else
69 + AC_MSG_ERROR(--with-boost-libdir expected directory name)
70 + fi
71 + ],
72 + [ac_boost_lib_path=""]
73 +)
74 +
75 +if test "x$want_boost" = "xyes"; then
76 + boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
77 + boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
78 + boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
79 + boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
80 + boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
81 + if test "x$boost_lib_version_req_sub_minor" = "x" ; then
82 + boost_lib_version_req_sub_minor="0"
83 + fi
84 + WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
85 + AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
86 + succeeded=no
87 +
88 + dnl On 64-bit systems check for system libraries in both lib64 and lib.
89 + dnl The former is specified by FHS, but e.g. Debian does not adhere to
90 + dnl this (as it rises problems for generic multi-arch support).
91 + dnl The last entry in the list is chosen by default when no libraries
92 + dnl are found, e.g. when only header-only libraries are installed!
93 + libsubdirs="lib"
94 + ax_arch=`uname -m`
95 + case $ax_arch in
96 + x86_64)
97 + libsubdirs="lib64 libx32 lib lib64"
98 + ;;
99 + ppc64|s390x|sparc64|aarch64|ppc64le)
100 + libsubdirs="lib64 lib lib64 ppc64le"
101 + ;;
102 + esac
103 +
104 + dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give
105 + dnl them priority over the other paths since, if libs are found there, they
106 + dnl are almost assuredly the ones desired.
107 + AC_REQUIRE([AX_CANONICAL_NAME])
108 + libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs"
109 +
110 + case ${host_cpu} in
111 + i?86)
112 + libsubdirs="lib/i386-${host_os} $libsubdirs"
113 + ;;
114 + esac
115 +
116 + dnl first we check the system location for boost libraries
117 + dnl this location ist chosen if boost libraries are installed with the --layout=system option
118 + dnl or if you install boost with RPM
119 + if test "$ac_boost_path" != ""; then
120 + BOOST_INCLUDE_PATH="$ac_boost_path/include"
121 + for ac_boost_path_tmp in $libsubdirs; do
122 + if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
123 + BOOST_LIBRARY_PATH="$ac_boost_path/$ac_boost_path_tmp"
124 + break
125 + fi
126 + done
127 + elif test "$cross_compiling" != yes; then
128 + for ac_boost_path_tmp in /opt/casa/03 /opt/casa/02 /opt/casa/01 /usr /usr/local /opt /opt/local ; do
129 + if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
130 + for libsubdir in $libsubdirs ; do
131 + if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
132 + done
133 + BOOST_LIBRARY_PATH="$ac_boost_path_tmp/$libsubdir"
134 + BOOST_INCLUDE_PATH="$ac_boost_path_tmp/include"
135 + break;
136 + fi
137 + done
138 + fi
139 +
140 + dnl overwrite ld flags if we have required special directory with
141 + dnl --with-boost-libdir parameter
142 + if test "$ac_boost_lib_path" != ""; then
143 + BOOST_LIBRARY_PATH="$ac_boost_lib_path"
144 + fi
145 +
146 + CPPFLAGS_SAVED="$CPPFLAGS"
147 + CPPFLAGS="$CPPFLAGS -I$BOOST_INCLUDE_PATH"
148 + export CPPFLAGS
149 +
150 + LDFLAGS_SAVED="$LDFLAGS"
151 + LDFLAGS="$LDFLAGS -L$BOOST_LIBRARY_PATH"
152 + export LDFLAGS
153 +
154 + AC_REQUIRE([AC_PROG_CXX])
155 + AC_LANG_PUSH(C++)
156 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
157 + @%:@include <boost/version.hpp>
158 + ]], [[
159 + #if BOOST_VERSION >= $WANT_BOOST_VERSION
160 + // Everything is okay
161 + #else
162 + # error Boost version is too old
163 + #endif
164 + ]])],[
165 + AC_MSG_RESULT(yes)
166 + succeeded=yes
167 + found_system=yes
168 + ],[
169 + ])
170 + AC_LANG_POP([C++])
171 +
172 +
173 +
174 + dnl if we found no boost with system layout we search for boost libraries
175 + dnl built and installed without the --layout=system option or for a staged(not installed) version
176 + if test "x$succeeded" != "xyes"; then
177 + CPPFLAGS="$CPPFLAGS_SAVED"
178 + LDFLAGS="$LDFLAGS_SAVED"
179 + BOOST_INCLUDE_PATH=
180 + BOOST_LIBRARY_PATH=
181 + _version=0
182 + if test "$ac_boost_path" != ""; then
183 + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
184 + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
185 + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
186 + V_CHECK=`expr $_version_tmp \> $_version`
187 + if test "$V_CHECK" = "1" ; then
188 + _version=$_version_tmp
189 + fi
190 + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
191 + BOOST_INCLUDE_PATH="$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
192 + done
193 + dnl if nothing found search for layout used in Windows distributions
194 + if test -z "$BOOST_INCLUDE_PATH"; then
195 + if test -d "$ac_boost_path/boost" && test -r "$ac_boost_path/boost"; then
196 + BOOST_INCLUDE_PATH="$ac_boost_path"
197 + fi
198 + fi
199 + fi
200 + else
201 + if test "$cross_compiling" != yes; then
202 + for ac_boost_path in /opt/casa/03 /opt/casa/02 /opt/casa/01 /usr /usr/local /opt /opt/local ; do
203 + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
204 + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
205 + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
206 + V_CHECK=`expr $_version_tmp \> $_version`
207 + if test "$V_CHECK" = "1" ; then
208 + _version=$_version_tmp
209 + best_path=$ac_boost_path
210 + fi
211 + done
212 + fi
213 + done
214 +
215 + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
216 + BOOST_INCLUDE_PATH="$best_path/include/boost-$VERSION_UNDERSCORE"
217 + if test "$ac_boost_lib_path" = ""; then
218 + for libsubdir in $libsubdirs ; do
219 + if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
220 + done
221 + BOOST_LIBRARY_PATH="$best_path/$libsubdir"
222 + fi
223 + fi
224 +
225 + if test "x$BOOST_ROOT" != "x"; then
226 + for libsubdir in $libsubdirs ; do
227 + if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
228 + done
229 + if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
230 + version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
231 + stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
232 + stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
233 + V_CHECK=`expr $stage_version_shorten \>\= $_version`
234 + if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
235 + AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
236 + BOOST_INCLUDE_PATH="$BOOST_ROOT"
237 + BOOST_LIBRARY_PATH="$BOOST_ROOT/stage/$libsubdir"
238 + fi
239 + fi
240 + fi
241 + fi
242 +
243 + CPPFLAGS="$CPPFLAGS -I$BOOST_INCLUDE_PATH"
244 + export CPPFLAGS
245 + LDFLAGS="$LDFLAGS -L$BOOST_LIBRARY_PATH"
246 + export LDFLAGS
247 +
248 + AC_LANG_PUSH(C++)
249 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
250 + @%:@include <boost/version.hpp>
251 + ]], [[
252 + #if BOOST_VERSION >= $WANT_BOOST_VERSION
253 + // Everything is okay
254 + #else
255 + # error Boost version is too old
256 + #endif
257 + ]])],[
258 + AC_MSG_RESULT(yes)
259 + succeeded=yes
260 + found_system=yes
261 + ],[
262 + ])
263 + AC_LANG_POP([C++])
264 + fi
265 +
266 + if test "$succeeded" != "yes" ; then
267 + if test "$_version" = "0" ; then
268 + AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
269 + else
270 + AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
271 + fi
272 + # execute ACTION-IF-NOT-FOUND (if present):
273 + ifelse([$3], , :, [$3])
274 + else
275 + HAVE_BOOST=1
276 + # execute ACTION-IF-FOUND (if present):
277 + ifelse([$2], , :, [$2])
278 + fi
279 +
280 + CPPFLAGS="$CPPFLAGS_SAVED"
281 + LDFLAGS="$LDFLAGS_SAVED"
282 +fi
283 +
284 +])

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut