Use m4 macro ACX_PTHREAD for POSIX threads detection.
[m4-moved-to-github.git] / ax_boost_program_options.m4
1 ##### http://autoconf-archive.cryp.to/ax_boost_program_options.html
2 #
3 # SYNOPSIS
4 #
5 #   AX_BOOST_PROGRAM_OPTIONS
6 #
7 # DESCRIPTION
8 #
9 #   Test for program options library from the Boost C++ libraries. The
10 #   macro requires a preceding call to AX_BOOST_BASE. Further
11 #   documentation is available at
12 #   <http://randspringer.de/boost/index.html>.
13 #
14 #   This macro calls:
15 #
16 #     AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB)
17 #
18 #   And sets:
19 #
20 #     HAVE_BOOST_PROGRAM_OPTIONS
21 #
22 # LAST MODIFICATION
23 #
24 #   2006-12-28
25 #
26 # COPYLEFT
27 #
28 #   Copyright (c) 2006 Thomas Porschberg <thomas@randspringer.de>
29 #
30 #   Copying and distribution of this file, with or without
31 #   modification, are permitted in any medium without royalty provided
32 #   the copyright notice and this notice are preserved.
33
34 AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
35 [
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 ]),
40         [
41         if test "$withval" = "no"; then
42                         want_boost="no"
43         elif test "$withval" = "yes"; then
44             want_boost="yes"
45             ax_boost_user_program_options_lib=""
46         else
47                     want_boost="yes"
48                 ax_boost_user_program_options_lib="$withval"
49                 fi
50         ],
51         [want_boost="yes"]
52         )
53
54         if test "x$want_boost" = "xyes"; then
55         AC_REQUIRE([AC_PROG_CC])
56             export want_boost
57                 CPPFLAGS_SAVED="$CPPFLAGS"
58                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
59                 export CPPFLAGS
60                 LDFLAGS_SAVED="$LDFLAGS"
61                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
62                 export LDFLAGS
63                 AC_CACHE_CHECK([whether the Boost::Program_Options library is available],
64                                            ax_cv_boost_program_options,
65                                            [AC_LANG_PUSH(C++)
66                                 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/program_options.hpp>
67                                                           ]],
68                                   [[boost::program_options::options_description generic("Generic options");
69                                    return 0;]]),
70                            ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no)
71                                         AC_LANG_POP([C++])
72                 ])
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                                   BN=boost_program_options
76                 if test "x$ax_boost_user_program_options_lib" = "x"; then
77                                   for ax_lib in $BN $BN-$CC $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
78                                 lib$BN lib$BN-$CC lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
79                                 $BN-mgw $BN-mgw $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
80                                       AC_CHECK_LIB($ax_lib, main,
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                 else
85                   for ax_lib in $ax_boost_user_program_options_lib $BN-$ax_boost_user_program_options_lib; do
86                                       AC_CHECK_LIB($ax_lib, main,
87                                    [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib" AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes" break],
88                                    [link_program_options="no"])
89                   done
90                 fi
91                                 if test "x$link_program_options" = "xno"; then
92                                         AC_MSG_ERROR([Could not link against [$ax_lib] !])
93                                 fi
94                 fi
95                 CPPFLAGS="$CPPFLAGS_SAVED"
96         LDFLAGS="$LDFLAGS_SAVED"
97         fi
98 ])