r18101: Use composite_create function and add monitor function pointer
[jelmer/samba4-debian.git] / source / aclocal.m4
1 dnl AC_PROG_CC_FLAG(flag)
2 AC_DEFUN(AC_PROG_CC_FLAG,
3 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
4 [echo 'void f(){}' > conftest.c
5 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
6   ac_cv_prog_cc_$1=yes
7 else
8   ac_cv_prog_cc_$1=no
9 fi
10 rm -f conftest*
11 ])])
12
13 dnl see if a declaration exists for a function or variable
14 dnl defines HAVE_function_DECL if it exists
15 dnl AC_HAVE_DECL(var, includes)
16 AC_DEFUN(AC_HAVE_DECL,
17 [
18  AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
19     AC_TRY_COMPILE([$2],[int i = (int)$1],
20         ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
21  if test x"$ac_cv_have_$1_decl" = x"yes"; then
22     AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
23  fi
24 ])
25
26
27 # AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
28 #              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
29 #              [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
30 # ------------------------------------------------------
31 #
32 # Use a cache variable name containing both the library and function name,
33 # because the test really is for library $1 defining function $3, not
34 # just for library $1.  Separate tests with the same $1 and different $3s
35 # may have different results.
36 #
37 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
38 # is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
39 # ac_cv_lib_$lib_fun, which is definitely not what was meant.  Hence
40 # the AS_LITERAL_IF indirection.
41 #
42 # FIXME: This macro is extremely suspicious.  It DEFINEs unconditionally,
43 # whatever the FUNCTION, in addition to not being a *S macro.  Note
44 # that the cache does depend upon the function we are looking for.
45 #
46 # It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
47 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
48 # changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
49 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
50 # freedom.
51 AC_DEFUN([AC_CHECK_LIB_EXT],
52 [
53 AH_CHECK_LIB_EXT([$1])
54 ac_check_lib_ext_save_LIBS=$LIBS
55 LIBS="-l$1 $$2 $7 $LIBS"
56 AS_LITERAL_IF([$1],
57       [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
58       [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
59
60 m4_ifval([$3],
61  [
62     AH_CHECK_FUNC_EXT([$3])
63     AS_LITERAL_IF([$1],
64               [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
65               [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
66     AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
67         [AC_TRY_LINK_FUNC($3,
68                  [AS_VAR_SET(ac_Lib_func, yes);
69                   AS_VAR_SET(ac_Lib_ext, yes)],
70                  [AS_VAR_SET(ac_Lib_func, no);
71                   AS_VAR_SET(ac_Lib_ext, no)])
72         ])
73     AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
74         [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
75     AS_VAR_POPDEF([ac_Lib_func])dnl
76  ],[
77     AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
78         [AC_TRY_LINK_FUNC([main],
79                  [AS_VAR_SET(ac_Lib_ext, yes)],
80                  [AS_VAR_SET(ac_Lib_ext, no)])
81         ])
82  ])
83 LIBS=$ac_check_lib_ext_save_LIBS
84
85 AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
86     [m4_default([$4], 
87         [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
88                 case "$$2" in
89                     *-l$1*)
90                         ;;
91                     *)
92                         $2="-l$1 $$2"
93                         ;;
94                 esac])
95                 [$6]
96             ],
97             [$5])dnl
98 AS_VAR_POPDEF([ac_Lib_ext])dnl
99 ])# AC_CHECK_LIB_EXT
100
101 # AH_CHECK_LIB_EXT(LIBNAME)
102 # ---------------------
103 m4_define([AH_CHECK_LIB_EXT],
104 [AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
105              [Define to 1 if you have the `]$1[' library (-l]$1[).])])
106
107 dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS,
108 dnl                    [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
109 dnl                    [OTHER-LIBRARIES])
110 dnl --------------------------------------------------------
111 dnl Search for a library defining FUNC, if it's not already available.
112 AC_DEFUN([AC_SEARCH_LIBS_EXT],
113 [AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1],
114 [
115 ac_func_search_ext_save_LIBS=$LIBS
116 ac_cv_search_ext_$1=no
117 AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
118                [ac_cv_search_ext_$1="none required"])
119 if test "$ac_cv_search_ext_$1" = no; then
120   for ac_lib in $2; do
121     LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS"
122     AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
123                    [ac_cv_search_ext_$1="-l$ac_lib"
124 break])
125   done
126 fi
127 LIBS=$ac_func_search_ext_save_LIBS])
128 AS_IF([test "$ac_cv_search_ext_$1" != no],
129   [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3"
130   $4],
131       [$5])dnl
132 ])
133
134 dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
135 dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
136 AC_DEFUN([AC_CHECK_FUNC_EXT],
137 [
138     AH_CHECK_FUNC_EXT($1)       
139     ac_check_func_ext_save_LIBS=$LIBS
140     LIBS="$2 $LIBS"
141     AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
142     AC_CACHE_CHECK([for $1], ac_var,
143         [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
144                 [AS_VAR_SET(ac_var, yes)],
145                 [AS_VAR_SET(ac_var, no)])])
146     LIBS=$ac_check_func_ext_save_LIBS
147     AS_IF([test AS_VAR_GET(ac_var) = yes], 
148             [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], 
149             [$4])dnl
150 AS_VAR_POPDEF([ac_var])dnl
151 ])# AC_CHECK_FUNC
152
153 # AH_CHECK_FUNC_EXT(FUNCNAME)
154 # ---------------------
155 m4_define([AH_CHECK_FUNC_EXT],
156 [AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
157              [Define to 1 if you have the `]$1[' function.])])
158
159 dnl Define an AC_DEFINE with ifndef guard.
160 dnl AC_N_DEFINE(VARIABLE [, VALUE])
161 define(AC_N_DEFINE,
162 [cat >> confdefs.h <<\EOF
163 [#ifndef] $1
164 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
165 [#endif]
166 EOF
167 ])
168
169 dnl Add an #include
170 dnl AC_ADD_INCLUDE(VARIABLE)
171 define(AC_ADD_INCLUDE,
172 [cat >> confdefs.h <<\EOF
173 [#include] $1
174 EOF
175 ])
176
177 dnl Copied from libtool.m4
178 AC_DEFUN(AC_PROG_LD_GNU,
179 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
180 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
181 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
182   ac_cv_prog_gnu_ld=yes
183 else
184   ac_cv_prog_gnu_ld=no
185 fi])
186 ])
187
188 dnl Removes -I/usr/include/? from given variable
189 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
190   ac_new_flags=""
191   for i in [$]$1; do
192     case [$]i in
193     -I/usr/include|-I/usr/include/) ;;
194     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
195     esac
196   done
197   $1=[$]ac_new_flags
198 ])
199     
200 dnl Removes -L/usr/lib/? from given variable
201 AC_DEFUN(LIB_REMOVE_USR_LIB,[
202   ac_new_flags=""
203   for i in [$]$1; do
204     case [$]i in
205     -L/usr/lib|-L/usr/lib/) ;;
206     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
207     esac
208   done
209   $1=[$]ac_new_flags
210 ])
211
212 m4_include(build/m4/public.m4)
213 m4_include(build/m4/ax_cflags_gcc_option.m4)
214 m4_include(build/m4/ax_cflags_irix_option.m4)
215 m4_include(build/m4/smb_cc_features.m4)