root/trunk/m4/ax_boost_program_options.m4

Revision 69, 4.4 KB (checked in by mirko, 5 months ago)

Andreas Moog patches

Line 
1# ===========================================================================
2#        http://autoconf-archive.cryp.to/ax_boost_program_options.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_BOOST_PROGRAM_OPTIONS
8#
9# DESCRIPTION
10#
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>.
14#
15#   This macro calls:
16#
17#     AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB)
18#
19#   And sets:
20#
21#     HAVE_BOOST_PROGRAM_OPTIONS
22#
23# LAST MODIFICATION
24#
25#   2008-04-12
26#
27# COPYLEFT
28#
29#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
30#
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.
34
35AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
36[
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 ]),
41        [
42        if test "$withval" = "no"; then
43                        want_boost="no"
44        elif test "$withval" = "yes"; then
45            want_boost="yes"
46            ax_boost_user_program_options_lib=""
47        else
48                    want_boost="yes"
49                ax_boost_user_program_options_lib="$withval"
50                fi
51        ],
52        [want_boost="yes"]
53        )
54
55        if test "x$want_boost" = "xyes"; then
56        AC_REQUIRE([AC_PROG_CC])
57            export want_boost
58                CPPFLAGS_SAVED="$CPPFLAGS"
59                CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60                export CPPFLAGS
61                LDFLAGS_SAVED="$LDFLAGS"
62                LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
63                export LDFLAGS
64                AC_CACHE_CHECK([whether the Boost::Program_Options library is available],
65                                           ax_cv_boost_program_options,
66                                           [AC_LANG_PUSH(C++)
67                                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/program_options.hpp>
68                                                          ]],
69                                  [[boost::program_options::options_description generic("Generic options");
70                                   return 0;]])],
71                           ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no)
72                                        AC_LANG_POP([C++])
73                ])
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"])
83                                done
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"])
90                                done
91                fi
92                else
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"])
97                  done
98                fi
99                                if test "x$link_program_options" != "xyes"; then
100                                        AC_MSG_ERROR([Could not link against [$ax_lib] !])
101                                fi
102                fi
103                CPPFLAGS="$CPPFLAGS_SAVED"
104        LDFLAGS="$LDFLAGS_SAVED"
105        fi
106])
Note: See TracBrowser for help on using the browser.