1
# ===========================================================================
2
# http://autoconf-archive.cryp.to/ax_boost_program_options.html
3
# ===========================================================================
7
# AX_BOOST_PROGRAM_OPTIONS
11
# Test for program options library from the Boost C++ libraries. The macro
12
# requires a preceding call to AX_BOOST_BASE. Further documentation is
13
# available at <http://randspringer.de/boost/index.html>.
17
# AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB)
21
# HAVE_BOOST_PROGRAM_OPTIONS
29
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
31
# Copying and distribution of this file, with or without modification, are
32
# permitted in any medium without royalty provided the copyright notice
33
# and this notice are preserved.
35
AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
37
AC_ARG_WITH([boost-program-options],
38
AS_HELP_STRING([--with-boost-program-options@<:@=special-lib@:>@],
39
[use the program options library from boost - it is possible to specify a certain library for the linker
40
e.g. --with-boost-program-options=boost_program_options-gcc-mt-1_33_1 ]),
42
if test "$withval" = "no"; then
44
elif test "$withval" = "yes"; then
46
ax_boost_user_program_options_lib=""
49
ax_boost_user_program_options_lib="$withval"
55
if test "x$want_boost" = "xyes"; then
56
AC_REQUIRE([AC_PROG_CC])
58
CPPFLAGS_SAVED="$CPPFLAGS"
59
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61
LDFLAGS_SAVED="$LDFLAGS"
62
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64
AC_CACHE_CHECK([whether the Boost::Program_Options library is available],
65
ax_cv_boost_program_options,
67
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/program_options.hpp>
69
[[boost::program_options::options_description generic("Generic options");
71
ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no)
74
if test "$ax_cv_boost_program_options" = yes; then
75
AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,,[define if the Boost::PROGRAM_OPTIONS library is available])
76
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
77
if test "x$ax_boost_user_program_options_lib" = "x"; then
78
for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;' -e 's;^lib\(boost_program_options.*\)\.a*$;\1;'` ; do
79
ax_lib=${libextension}
80
AC_CHECK_LIB($ax_lib, exit,
81
[BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
82
[link_program_options="no"])
84
if test "x$link_program_options" != "xyes"; then
85
for libextension in `ls $BOOSTLIBDIR/boost_program_options*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.dll.*$;\1;' -e 's;^\(boost_program_options.*\)\.a*$;\1;'` ; do
86
ax_lib=${libextension}
87
AC_CHECK_LIB($ax_lib, exit,
88
[BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
89
[link_program_options="no"])
93
for ax_lib in $ax_boost_user_program_options_lib boost_program_options-$ax_boost_user_program_options_lib; do
94
AC_CHECK_LIB($ax_lib, main,
95
[BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
96
[link_program_options="no"])
99
if test "x$link_program_options" != "xyes"; then
100
AC_MSG_ERROR([Could not link against [$ax_lib] !])
103
CPPFLAGS="$CPPFLAGS_SAVED"
104
LDFLAGS="$LDFLAGS_SAVED"