1 # ============================================================================
2 # http://www.gnu.org/software/autoconf-archive/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
25 # Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
27 # Copying and distribution of this file, with or without modification, are
28 # permitted in any medium without royalty provided the copyright notice
29 # and this notice are preserved. This file is offered as-is, without any
34 AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
36 AC_ARG_WITH([boost-program-options],
37 AS_HELP_STRING([--with-boost-program-options@<:@=special-lib@:>@],
38 [use the program options library from boost - it is possible to specify a certain library for the linker
39 e.g. --with-boost-program-options=boost_program_options-gcc-mt-1_33_1 ]),
41 if test "$withval" = "no"; then
43 elif test "$withval" = "yes"; then
45 ax_boost_user_program_options_lib=""
48 ax_boost_user_program_options_lib="$withval"
54 if test "x$want_boost" = "xyes"; then
55 AC_REQUIRE([AC_PROG_CC])
57 CPPFLAGS_SAVED="$CPPFLAGS"
58 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60 LDFLAGS_SAVED="$LDFLAGS"
61 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
63 AC_CACHE_CHECK([whether the Boost::Program_Options library is available],
64 ax_cv_boost_program_options,
66 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/program_options/errors.hpp>
68 [[boost::program_options::error err("Error message");
70 ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no)
73 if test "$ax_cv_boost_program_options" = yes; then
74 AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,,[define if the Boost::PROGRAM_OPTIONS library is available])
75 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
76 if test "x$ax_boost_user_program_options_lib" = "x"; then
77 for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.dylib* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.dylib.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.a.*$;\1;'` ; do
78 ax_lib=${libextension}
79 AC_CHECK_LIB($ax_lib, exit,
80 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
81 [link_program_options="no"])
83 if test "x$link_program_options" != "xyes"; then
84 for libextension in `ls $BOOSTLIBDIR/boost_program_options*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.a.*$;\1;'` ; do
85 ax_lib=${libextension}
86 AC_CHECK_LIB($ax_lib, exit,
87 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
88 [link_program_options="no"])
92 for ax_lib in $ax_boost_user_program_options_lib boost_program_options-$ax_boost_user_program_options_lib; do
93 AC_CHECK_LIB($ax_lib, main,
94 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break],
95 [link_program_options="no"])
98 if test "x$ax_lib" = "x"; then
99 AC_MSG_ERROR(Could not find a version of the library!)
101 if test "x$link_program_options" != "xyes"; then
102 AC_MSG_ERROR([Could not link against [$ax_lib] !])
105 CPPFLAGS="$CPPFLAGS_SAVED"
106 LDFLAGS="$LDFLAGS_SAVED"