Skip to content

Commit c3a170c

Browse files
author
Coos Baakman
committed
make sure the configure script fails if boost libraries are missing
1 parent 22918e4 commit c3a170c

File tree

2 files changed

+118
-9
lines changed

2 files changed

+118
-9
lines changed

configure.ac

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ if test -z "$CPPCHECK"; then
2222
fi
2323

2424
# Checks for libraries.
25-
AX_BOOST_BASE([1.54])
26-
AX_BOOST_DATE_TIME
27-
AX_BOOST_FILESYSTEM
28-
AX_BOOST_IOSTREAMS
29-
AX_BOOST_PROGRAM_OPTIONS
30-
AX_BOOST_REGEX
31-
AX_BOOST_SYSTEM
32-
AX_BOOST_THREAD
33-
AX_BOOST_UNIT_TEST_FRAMEWORK
25+
AX_BOOST_BASE([1.54],,AC_MSG_ERROR([libboost_base not found]))
26+
AX_BOOST_DATE_TIME([1.54],,AC_MSG_ERROR([libboost_date_time not found]))
27+
AX_BOOST_TIMER([1.54],,AC_MSG_ERROR([libboost_timer not found]))
28+
AX_BOOST_FILESYSTEM([1.54],,AC_MSG_ERROR([libboost_filesystem not found]))
29+
AX_BOOST_IOSTREAMS([1.54],,AC_MSG_ERROR([libboost_iostreams not found]))
30+
AX_BOOST_PROGRAM_OPTIONS([1.54],,AC_MSG_ERROR([libboost_options not found]))
31+
AX_BOOST_REGEX([1.54],,AC_MSG_ERROR([libboost_regex not found]))
32+
AX_BOOST_SYSTEM([1.54],,AC_MSG_ERROR([libboost_system not found]))
33+
AX_BOOST_THREAD([1.54],,AC_MSG_ERROR([libboost_thread not found]))
34+
AX_BOOST_UNIT_TEST_FRAMEWORK([1.54],,AC_MSG_ERROR([libboost_unit_test_framework not found]))
3435
AM_CONDITIONAL([HAVE_CPPCHECK], [test -n "$CPPCHECK"])
3536
AC_CHECK_LIB([zeep], [main],,
3637
[AC_MSG_WARN([libzeep not found - fetch-dbrefs is disabled in mkhssp])])

m4/ax_boost_timer.m4

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# SYNOPSIS
2+
#
3+
# AX_BOOST_TIMER
4+
#
5+
# DESCRIPTION
6+
#
7+
# Test for Date_Time library from the Boost C++ libraries. The macro
8+
# requires a preceding call to AX_BOOST_BASE. Further documentation is
9+
# available at <http://randspringer.de/boost/index.html>.
10+
#
11+
# This macro calls:
12+
#
13+
# AC_SUBST(BOOST_TIMER_LIB)
14+
#
15+
# And sets:
16+
#
17+
# HAVE_BOOST_TIMER
18+
#
19+
# LICENSE
20+
#
21+
# Copyright (c) 2019 Coos Baakman <[email protected]>
22+
#
23+
# Copying and distribution of this file, with or without modification, are
24+
# permitted in any medium without royalty provided the copyright notice
25+
# and this notice are preserved. This file is offered as-is, without any
26+
# warranty.
27+
28+
#serial 1
29+
30+
AC_DEFUN([AX_BOOST_TIMER],
31+
[
32+
AC_ARG_WITH([boost-date-time],
33+
AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
34+
[use the Date_Time library from boost - it is possible to specify a certain library for the linker
35+
e.g. --with-boost-date-time=boost_timer-gcc-mt-d-1_33_1 ]),
36+
[
37+
if test "$withval" = "no"; then
38+
want_boost="no"
39+
elif test "$withval" = "yes"; then
40+
want_boost="yes"
41+
ax_boost_user_timer_lib=""
42+
else
43+
want_boost="yes"
44+
ax_boost_user_timer_lib="$withval"
45+
fi
46+
],
47+
[want_boost="yes"]
48+
)
49+
50+
if test "x$want_boost" = "xyes"; then
51+
AC_REQUIRE([AC_PROG_CC])
52+
CPPFLAGS_SAVED="$CPPFLAGS"
53+
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
54+
export CPPFLAGS
55+
56+
LDFLAGS_SAVED="$LDFLAGS"
57+
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
58+
export LDFLAGS
59+
60+
AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
61+
ax_cv_boost_timer,
62+
[AC_LANG_PUSH([C++])
63+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/timer/gregorian/gregorian_types.hpp>]],
64+
[[using namespace boost::gregorian; date d(2002,Jan,10);
65+
return 0;
66+
]])],
67+
ax_cv_boost_timer=yes, ax_cv_boost_timer=no)
68+
AC_LANG_POP([C++])
69+
])
70+
if test "x$ax_cv_boost_timer" = "xyes"; then
71+
AC_DEFINE(HAVE_BOOST_TIMER,,[define if the Boost::Date_Time library is available])
72+
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
73+
if test "x$ax_boost_user_timer_lib" = "x"; then
74+
for libextension in `ls $BOOSTLIBDIR/libboost_timer*.so* $BOOSTLIBDIR/libboost_timer*.dylib* $BOOSTLIBDIR/libboost_timer*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_timer.*\)\.so.*$;\1;' -e 's;^lib\(boost_timer.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_timer.*\)\.a*$;\1;'` ; do
75+
ax_lib=${libextension}
76+
AC_CHECK_LIB($ax_lib, exit,
77+
[BOOST_TIMER_LIB="-l$ax_lib"; AC_SUBST(BOOST_TIMER_LIB) link_timer="yes"; break],
78+
[link_timer="no"])
79+
done
80+
if test "x$link_timer" != "xyes"; then
81+
for libextension in `ls $BOOSTLIBDIR/boost_timer*.dll* $BOOSTLIBDIR/boost_timer*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_timer.*\)\.dll.*$;\1;' -e 's;^\(boost_timer.*\)\.a.*$;\1;'` ; do
82+
ax_lib=${libextension}
83+
AC_CHECK_LIB($ax_lib, exit,
84+
[BOOST_TIMER_LIB="-l$ax_lib"; AC_SUBST(BOOST_TIMER_LIB) link_timer="yes"; break],
85+
[link_timer="no"])
86+
done
87+
fi
88+
89+
else
90+
for ax_lib in $ax_boost_user_timer_lib boost_timer-$ax_boost_user_timer_lib; do
91+
AC_CHECK_LIB($ax_lib, main,
92+
[BOOST_TIMER_LIB="-l$ax_lib"; AC_SUBST(BOOST_TIMER_LIB) link_timer="yes"; break],
93+
[link_timer="no"])
94+
done
95+
96+
fi
97+
if test "x$ax_lib" = "x"; then
98+
AC_MSG_ERROR(Could not find a version of the library!)
99+
fi
100+
if test "x$link_timer" != "xyes"; then
101+
AC_MSG_ERROR(Could not link against $ax_lib !)
102+
fi
103+
fi
104+
105+
CPPFLAGS="$CPPFLAGS_SAVED"
106+
LDFLAGS="$LDFLAGS_SAVED"
107+
fi
108+
])

0 commit comments

Comments
 (0)