Add init/term methods.
[shibboleth/resolver.git] / acinclude.m4
1 dnl @synopsis AC_CXX_NAMESPACES
2 dnl
3 dnl If the compiler can prevent names clashes using namespaces, define
4 dnl HAVE_NAMESPACES.
5 dnl
6 dnl @author Luc Maisonobe
7 dnl
8 AC_DEFUN([AC_CXX_NAMESPACES],
9 [AC_CACHE_CHECK(whether the compiler implements namespaces,
10 ac_cv_cxx_namespaces,
11 [AC_LANG_SAVE
12  AC_LANG_CPLUSPLUS
13  AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
14                 [using namespace Outer::Inner; return i;],
15  ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
16  AC_LANG_RESTORE
17 ])
18 if test "$ac_cv_cxx_namespaces" = yes; then
19   AC_DEFINE(HAVE_NAMESPACES,1,[define if the compiler implements namespaces])
20 fi
21 ])
22
23
24 dnl
25 dnl @author Luc Maisonobe
26 dnl
27 AC_DEFUN([AC_CXX_REQUIRE_STL],
28 [AC_CACHE_CHECK(whether the compiler supports Standard Template Library,
29 ac_cv_cxx_have_stl,
30 [AC_REQUIRE([AC_CXX_NAMESPACES])
31  AC_LANG_SAVE
32  AC_LANG_CPLUSPLUS
33  AC_TRY_COMPILE([#include <list>
34 #include <deque>
35 #ifdef HAVE_NAMESPACES
36 using namespace std;
37 #endif],[list<int> x; x.push_back(5);
38 list<int>::iterator iter = x.begin(); if (iter != x.end()) ++iter; return 0;],
39  ac_cv_cxx_have_stl=yes, ac_cv_cxx_have_stl=no)
40  AC_LANG_RESTORE
41 ])
42 if test "x_$ac_cv_cxx_have_stl" != x_yes; then
43   AC_MSG_ERROR([C++ Standard Template Libary unsupported])
44 fi
45 ])
46
47 dnl@synopsys YAD_CHECK_INCLUDE_LIB(INCLUDE, LIBRARY, CODE
48 dnl              [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
49 dnl              [, OTHER-LIBRARIES]]])
50 dnl 
51 dnl same as the AC_CHECK_LIB except of the following:
52 dnl      - You sholud specify include part of test.
53 dnl      - You can test any code for linking, not just function calls.
54 dnl
55 dnl@author Alexandr Yanovets <yad@gradsoft.kiev.ua>
56 dnl
57 AC_DEFUN(YAD_CHECK_INCLUDE_LIB,
58 [AC_MSG_CHECKING([for $3 in -l$2])
59 dnl Use a cache variable name containing both the library and function name,
60 dnl because the test really is for library $2 defining function $3, not
61 dnl just for library $2.  Separate tests with the same $2 and different $3s
62 dnl may have different results.
63 ac_lib_var=`echo $2['_']include | sed 'y%./+-%__p_%'`
64 AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
65 [yad_check_lib_save_LIBS="$LIBS"
66 LIBS="-l$2 $6 $LIBS"
67 AC_TRY_LINK(dnl
68             [$1],
69             [$3],
70             eval "ac_cv_lib_$ac_lib_var=yes",
71             eval "ac_cv_lib_$ac_lib_var=no")
72 LIBS="$yad_check_lib_save_LIBS"
73 ])dnl
74 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
75   AC_MSG_RESULT(yes)
76   ifelse([$4], ,
77 [changequote(, )dnl
78   ac_tr_lib=HAVE_LIB`echo $2 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
79     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
80 changequote([, ])dnl
81   AC_DEFINE_UNQUOTED($ac_tr_lib)
82   LIBS="-l$2 $LIBS"
83 ], [$4])
84 else
85   AC_MSG_RESULT(no)
86 ifelse([$5], , , [$5
87 ])dnl
88 fi
89 ])
90