r17995: Ensure we create the domain-specific krb5 files in a
[Samba/nascimento.git] / source3 / aclocal.m4
blobb0f1f6c44d150863fcf6da731002e4b650cc07e5
1 dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
2 dnl if the cache file is inconsistent with the current host,
3 dnl target and build system types, execute CMD or print a default
4 dnl error message.
5 AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
6     AC_REQUIRE([AC_CANONICAL_SYSTEM])
7     AC_MSG_CHECKING([config.cache system type])
8     if { test x"${ac_cv_host_system_type+set}" = x"set" &&
9          test x"$ac_cv_host_system_type" != x"$host"; } ||
10        { test x"${ac_cv_build_system_type+set}" = x"set" &&
11          test x"$ac_cv_build_system_type" != x"$build"; } ||
12        { test x"${ac_cv_target_system_type+set}" = x"set" &&
13          test x"$ac_cv_target_system_type" != x"$target"; }; then
14         AC_MSG_RESULT([different])
15         ifelse($#, 1, [$1],
16                 [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
17     else
18         AC_MSG_RESULT([same])
19     fi
20     ac_cv_host_system_type="$host"
21     ac_cv_build_system_type="$build"
22     ac_cv_target_system_type="$target"
26 dnl test whether dirent has a d_off member
27 AC_DEFUN(AC_DIRENT_D_OFF,
28 [AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off,
29 [AC_TRY_COMPILE([
30 #include <unistd.h>
31 #include <sys/types.h>
32 #include <dirent.h>], [struct dirent d; d.d_off;],
33 ac_cv_dirent_d_off=yes, ac_cv_dirent_d_off=no)])
34 if test $ac_cv_dirent_d_off = yes; then
35   AC_DEFINE(HAVE_DIRENT_D_OFF,1,[Whether dirent has a d_off member])
39 dnl Mark specified module as shared
40 dnl SMB_MODULE(name,static_files,shared_files,subsystem,whatif-static,whatif-shared)
41 AC_DEFUN(SMB_MODULE,
43         AC_MSG_CHECKING([how to build $1])
44         if test "$[MODULE_][$1]"; then
45                 DEST=$[MODULE_][$1]
46         elif test "$[MODULE_]translit([$4], [A-Z], [a-z])" -a "$[MODULE_DEFAULT_][$1]"; then
47                 DEST=$[MODULE_]translit([$4], [A-Z], [a-z])
48         else
49                 DEST=$[MODULE_DEFAULT_][$1]
50         fi
51         
52         if test x"$DEST" = xSHARED; then
53                 AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module])
54                 $4_MODULES="$$4_MODULES $3"
55                 AC_MSG_RESULT([shared])
56                 [$6]
57                 string_shared_modules="$string_shared_modules $1"
58         elif test x"$DEST" = xSTATIC; then
59                 [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z])  $1_init();"
60                 [decl_static_modules_]translit([$4], [A-Z], [a-z])="$[decl_static_modules_]translit([$4], [A-Z], [a-z]) extern NTSTATUS $1_init(void);"
61                 string_static_modules="$string_static_modules $1"
62                 $4_STATIC="$$4_STATIC $2"
63                 AC_SUBST($4_STATIC)
64                 [$5]
65                 AC_MSG_RESULT([static])
66         else
67             string_ignored_modules="$string_ignored_modules $1"
68                 AC_MSG_RESULT([not])
69         fi
72 AC_DEFUN(SMB_SUBSYSTEM,
74         AC_SUBST($1_STATIC)
75         AC_SUBST($1_MODULES)
76         AC_DEFINE_UNQUOTED([static_init_]translit([$1], [A-Z], [a-z]), [{$init_static_modules_]translit([$1], [A-Z], [a-z])[}], [Static init functions])
77         AC_DEFINE_UNQUOTED([static_decl_]translit([$1], [A-Z], [a-z]), [$decl_static_modules_]translit([$1], [A-Z], [a-z]), [Decl of Static init functions])
78         ifelse([$2], , :, [rm -f $2])
81 dnl AC_PROG_CC_FLAG(flag)
82 AC_DEFUN(AC_PROG_CC_FLAG,
83 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
84 [echo 'void f(){}' > conftest.c
85 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
86   ac_cv_prog_cc_$1=yes
87 else
88   ac_cv_prog_cc_$1=no
90 rm -f conftest*
91 ])])
93 dnl see if a declaration exists for a function or variable
94 dnl defines HAVE_function_DECL if it exists
95 dnl AC_HAVE_DECL(var, includes)
96 AC_DEFUN(AC_HAVE_DECL,
98  AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
99     AC_TRY_COMPILE([$2],[int i = (int)$1],
100         ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
101  if test x"$ac_cv_have_$1_decl" = x"yes"; then
102     AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
103  fi
107 dnl AC_LIBTESTFUNC(lib, function, [actions if found], [actions if not found])
108 dnl Check for a function in a library, but don't keep adding the same library
109 dnl to the LIBS variable.  Check whether the function is available in the
110 dnl current LIBS before adding the library which prevents us spuriously
111 dnl adding libraries for symbols that are in libc.
113 dnl On success, the default actions ensure that HAVE_FOO is defined. The lib
114 dnl is always added to $LIBS if it was found to be necessary. The caller
115 dnl can use SMB_LIB_REMOVE to strp this if necessary.
116 AC_DEFUN([AC_LIBTESTFUNC],
118   AC_CHECK_FUNCS($2,
119       [
120         # $2 was found in libc or existing $LIBS
121         ifelse($3, [],
122             [
123                 AC_DEFINE(translit([HAVE_$2], [a-z], [A-Z]), 1,
124                     [Whether $2 is available])
125             ],
126             [
127                 $3
128             ])
129       ],
130       [
131         # $2 was not found, try adding lib$1
132         case " $LIBS " in
133           *\ -l$1\ *)
134             ifelse($4, [],
135                 [
136                     # $2 was not found and we already had lib$1
137                     # nothing to do here by default
138                     true
139                 ],
140                 [ $4 ])
141             ;;
142           *)
143             # $2 was not found, try adding lib$1
144             AC_CHECK_LIB($1, $2,
145               [
146                 LIBS="-l$1 $LIBS"
147                 ifelse($3, [],
148                     [
149                         AC_DEFINE(translit([HAVE_$2], [a-z], [A-Z]), 1,
150                             [Whether $2 is available])
151                     ],
152                     [
153                         $3
154                     ])
155               ],
156               [
157                 ifelse($4, [],
158                     [
159                         # $2 was not found in lib$1
160                         # nothing to do here by default
161                         true
162                     ],
163                     [ $4 ])
164               ])
165           ;;
166         esac
167       ])
170 # AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
171 #              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
172 #              [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
173 # ------------------------------------------------------
175 # Use a cache variable name containing both the library and function name,
176 # because the test really is for library $1 defining function $3, not
177 # just for library $1.  Separate tests with the same $1 and different $3s
178 # may have different results.
180 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
181 # is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
182 # ac_cv_lib_$lib_fun, which is definitely not what was meant.  Hence
183 # the AS_LITERAL_IF indirection.
185 # FIXME: This macro is extremely suspicious.  It DEFINEs unconditionally,
186 # whatever the FUNCTION, in addition to not being a *S macro.  Note
187 # that the cache does depend upon the function we are looking for.
189 # It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
190 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
191 # changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
192 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
193 # freedom.
194 AC_DEFUN([AC_CHECK_LIB_EXT],
196 AH_CHECK_LIB_EXT([$1])
197 ac_check_lib_ext_save_LIBS=$LIBS
198 LIBS="-l$1 $$2 $7 $LIBS"
199 AS_LITERAL_IF([$1],
200       [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
201       [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
203 m4_ifval([$3],
205     AH_CHECK_FUNC_EXT([$3])
206     AS_LITERAL_IF([$1],
207               [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
208               [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
209     AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
210         [AC_TRY_LINK_FUNC($3,
211                  [AS_VAR_SET(ac_Lib_func, yes);
212                   AS_VAR_SET(ac_Lib_ext, yes)],
213                  [AS_VAR_SET(ac_Lib_func, no);
214                   AS_VAR_SET(ac_Lib_ext, no)])
215         ])
216     AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
217         [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
218     AS_VAR_POPDEF([ac_Lib_func])dnl
219  ],[
220     AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
221         [AC_TRY_LINK_FUNC([main],
222                  [AS_VAR_SET(ac_Lib_ext, yes)],
223                  [AS_VAR_SET(ac_Lib_ext, no)])
224         ])
225  ])
226 LIBS=$ac_check_lib_ext_save_LIBS
228 AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
229     [m4_default([$4], 
230         [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
231                 case "$$2" in
232                     *-l$1*)
233                         ;;
234                     *)
235                         $2="-l$1 $$2"
236                         ;;
237                 esac])
238                 [$6]
239             ],
240             [$5])dnl
241 AS_VAR_POPDEF([ac_Lib_ext])dnl
242 ])# AC_CHECK_LIB_EXT
244 # AH_CHECK_LIB_EXT(LIBNAME)
245 # ---------------------
246 m4_define([AH_CHECK_LIB_EXT],
247 [AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
248              [Define to 1 if you have the `]$1[' library (-l]$1[).])])
250 # AC_CHECK_FUNCS_EXT(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
251 # -----------------------------------------------------------------
252 dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
253 dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
254 AC_DEFUN([AC_CHECK_FUNC_EXT],
256     AH_CHECK_FUNC_EXT($1)       
257     ac_check_func_ext_save_LIBS=$LIBS
258     LIBS="$2 $LIBS"
259     AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
260     AC_CACHE_CHECK([for $1], ac_var,
261         [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
262                 [AS_VAR_SET(ac_var, yes)],
263                 [AS_VAR_SET(ac_var, no)])])
264     LIBS=$ac_check_func_ext_save_LIBS
265     AS_IF([test AS_VAR_GET(ac_var) = yes], 
266             [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], 
267             [$4])dnl
268 AS_VAR_POPDEF([ac_var])dnl
269 ])# AC_CHECK_FUNC
271 # AH_CHECK_FUNC_EXT(FUNCNAME)
272 # ---------------------
273 m4_define([AH_CHECK_FUNC_EXT],
274 [AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
275              [Define to 1 if you have the `]$1[' function.])])
277 dnl Define an AC_DEFINE with ifndef guard.
278 dnl AC_N_DEFINE(VARIABLE [, VALUE])
279 define(AC_N_DEFINE,
280 [cat >> confdefs.h <<\EOF
281 [#ifndef] $1
282 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
283 [#endif]
287 dnl Add an #include
288 dnl AC_ADD_INCLUDE(VARIABLE)
289 define(AC_ADD_INCLUDE,
290 [cat >> confdefs.h <<\EOF
291 [#include] $1
295 dnl Copied from libtool.m4
296 AC_DEFUN(AC_PROG_LD_GNU,
297 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
298 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
299 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
300   ac_cv_prog_gnu_ld=yes
301 else
302   ac_cv_prog_gnu_ld=no
303 fi])
306 dnl Removes -I/usr/include/? from given variable
307 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
308   ac_new_flags=""
309   for i in [$]$1; do
310     case [$]i in
311     -I/usr/include|-I/usr/include/) ;;
312     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
313     esac
314   done
315   $1=[$]ac_new_flags
317     
318 dnl Removes -L/usr/lib/? from given variable
319 AC_DEFUN(LIB_REMOVE_USR_LIB,[
320   ac_new_flags=""
321   for i in [$]$1; do
322     case [$]i in
323     -L/usr/lib|-L/usr/lib/) ;;
324     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
325     esac
326   done
327   $1=[$]ac_new_flags
330 dnl From Bruno Haible.
332 AC_DEFUN(jm_ICONV,
334   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
335   dnl those with the standalone portable libiconv installed).
336   AC_MSG_CHECKING(for iconv in $1)
337     jm_cv_func_iconv="no"
338     jm_cv_lib_iconv=""
339     jm_cv_giconv=no
340     jm_save_LIBS="$LIBS"
342     dnl Check for include in funny place but no lib needed
343     if test "$jm_cv_func_iconv" != yes; then 
344       AC_TRY_LINK([#include <stdlib.h>
345 #include <giconv.h>],
346         [iconv_t cd = iconv_open("","");
347          iconv(cd,NULL,NULL,NULL,NULL);
348          iconv_close(cd);],
349          jm_cv_func_iconv=yes
350          jm_cv_include="giconv.h"
351          jm_cv_giconv="yes"
352          jm_cv_lib_iconv="")
354       dnl Standard iconv.h include, lib in glibc or libc ...
355       if test "$jm_cv_func_iconv" != yes; then
356         AC_TRY_LINK([#include <stdlib.h>
357 #include <iconv.h>],
358           [iconv_t cd = iconv_open("","");
359            iconv(cd,NULL,NULL,NULL,NULL);
360            iconv_close(cd);],
361            jm_cv_include="iconv.h"
362            jm_cv_func_iconv=yes
363            jm_cv_lib_iconv="")
365           if test "$jm_cv_lib_iconv" != yes; then
366             jm_save_LIBS="$LIBS"
367             LIBS="$LIBS -lgiconv"
368             AC_TRY_LINK([#include <stdlib.h>
369 #include <giconv.h>],
370               [iconv_t cd = iconv_open("","");
371                iconv(cd,NULL,NULL,NULL,NULL);
372                iconv_close(cd);],
373               jm_cv_lib_iconv=yes
374               jm_cv_func_iconv=yes
375               jm_cv_include="giconv.h"
376               jm_cv_giconv=yes
377               jm_cv_lib_iconv="giconv")
379            LIBS="$jm_save_LIBS"
381         if test "$jm_cv_func_iconv" != yes; then
382           jm_save_LIBS="$LIBS"
383           LIBS="$LIBS -liconv"
384           AC_TRY_LINK([#include <stdlib.h>
385 #include <iconv.h>],
386             [iconv_t cd = iconv_open("","");
387              iconv(cd,NULL,NULL,NULL,NULL);
388              iconv_close(cd);],
389             jm_cv_include="iconv.h"
390             jm_cv_func_iconv=yes
391             jm_cv_lib_iconv="iconv")
392           LIBS="$jm_save_LIBS"
393         fi
394       fi
395     fi
396   fi
397   if test "$jm_cv_func_iconv" = yes; then
398     if test "$jm_cv_giconv" = yes; then
399       AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
400       AC_MSG_RESULT(yes)
401       ICONV_FOUND=yes
402     else
403       if test "$jm_cv_biconv" = yes; then
404         AC_DEFINE(HAVE_BICONV, 1, [What header to include for iconv() function: biconv.h])
405         AC_MSG_RESULT(yes)
406         ICONV_FOUND=yes
407       else 
408         AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
409         AC_MSG_RESULT(yes)
410         ICONV_FOUND=yes
411       fi
412     fi
413   else
414     AC_MSG_RESULT(no)
415   fi
418 AC_DEFUN(rjs_CHARSET,[
419   dnl Find out if we can convert from $1 to UCS2-LE
420   AC_MSG_CHECKING([can we convert from $1 to UCS2-LE?])
421   AC_TRY_RUN([
422 #include <$jm_cv_include>
423 main(){
424     iconv_t cd = iconv_open("$1", "UCS-2LE");
425     if (cd == 0 || cd == (iconv_t)-1) {
426         return -1;
427     }
428     return 0;
430   ],ICONV_CHARSET=$1,ICONV_CHARSET=no,ICONV_CHARSET=cross)
431   AC_MSG_RESULT($ICONV_CHARSET)
434 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
435 dnl This function doesn't add -I/usr/include into CFLAGS
436 AC_DEFUN(CFLAGS_ADD_DIR,[
437 if test "$2" != "/usr/include" ; then
438     $1="$$1 -I$2"
442 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
443 dnl This function doesn't add -L/usr/lib into LDFLAGS
444 AC_DEFUN(LIB_ADD_DIR,[
445 if test "$2" != "/usr/lib" ; then
446     $1="$$1 -L$2"
450 dnl AC_ENABLE_SHARED - implement the --enable-shared flag
451 dnl Usage: AC_ENABLE_SHARED[(DEFAULT)]
452 dnl   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
453 dnl   `yes'.
454 AC_DEFUN([AC_ENABLE_SHARED],
455 [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
456 AC_ARG_ENABLE(shared,
457 changequote(<<, >>)dnl
458 <<  --enable-shared[=PKGS]    build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
459 changequote([, ])dnl
460 [p=${PACKAGE-default}
461 case $enableval in
462 yes) enable_shared=yes ;;
463 no) enable_shared=no ;;
465   enable_shared=no
466   # Look at the argument we got.  We use all the common list separators.
467   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
468   for pkg in $enableval; do
469     if test "X$pkg" = "X$p"; then
470       enable_shared=yes
471     fi
473   done
474   IFS="$ac_save_ifs"
475   ;;
476 esac],
477 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
480 dnl AC_ENABLE_STATIC - implement the --enable-static flag
481 dnl Usage: AC_ENABLE_STATIC[(DEFAULT)]
482 dnl   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
483 dnl   `yes'.
484 AC_DEFUN([AC_ENABLE_STATIC],
485 [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
486 AC_ARG_ENABLE(static,
487 changequote(<<, >>)dnl
488 <<  --enable-static[=PKGS]    build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
489 changequote([, ])dnl
490 [p=${PACKAGE-default}
491 case $enableval in
492 yes) enable_static=yes ;;
493 no) enable_static=no ;;
495   enable_static=no
496   # Look at the argument we got.  We use all the common list separators.
497   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
498   for pkg in $enableval; do
499     if test "X$pkg" = "X$p"; then
500       enable_static=yes
501     fi
502   done
503   IFS="$ac_save_ifs"
504   ;;
505 esac],
506 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
509 dnl AC_DISABLE_STATIC - set the default static flag to --disable-static
510 AC_DEFUN([AC_DISABLE_STATIC],
511 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
512 AC_ENABLE_STATIC(no)])
514 dnl AC_TRY_RUN_STRICT(PROGRAM,CFLAGS,CPPFLAGS,LDFLAGS,
515 dnl             [ACTION-IF-TRUE],[ACTION-IF-FALSE],
516 dnl             [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR])
517 AC_DEFUN( [AC_TRY_RUN_STRICT],
519         old_CFLAGS="$CFLAGS";
520         CFLAGS="$2";
521         export CFLAGS;
522         old_CPPFLAGS="$CPPFLAGS";
523         CPPFLAGS="$3";
524         export CPPFLAGS;
525         old_LDFLAGS="$LDFLAGS";
526         LDFLAGS="$4";
527         export LDFLAGS;
528         AC_TRY_RUN([$1],[$5],[$6],[$7])
529         CFLAGS="$old_CFLAGS";
530         old_CFLAGS="";
531         export CFLAGS;
532         CPPFLAGS="$old_CPPFLAGS";
533         old_CPPFLAGS="";
534         export CPPFLAGS;
535         LDFLAGS="$old_LDFLAGS";
536         old_LDFLAGS="";
537         export LDFLAGS;
540 dnl SMB_CHECK_SYSCONF(varname)
541 dnl Tests whether the sysconf(3) variable "varname" is available.
542 AC_DEFUN([SMB_CHECK_SYSCONF],
544     AC_CACHE_CHECK([for sysconf($1)],
545         samba_cv_SYSCONF$1,
546         [
547             AC_TRY_LINK([#include <unistd.h>],
548                 [ return sysconf($1) == -1 ? 1 : 0; ],
549                 [ samba_cv_SYSCONF$1=yes ],
550                 [ samba_cv_SYSCONF$1=no ])
551         ])
553     if test x"$samba_cv_SYSCONF$1" = x"yes" ; then
554         AC_DEFINE(SYSCONF$1, 1, [Whether sysconf($1) is available])
555     fi
558 dnl SMB_IS_LIBPTHREAD_LINKED([actions if true], [actions if false])
559 dnl Test whether the current LIBS results in libpthread being present.
560 dnl Execute the corresponding user action list.
561 AC_DEFUN([SMB_IS_LIBPTHREAD_LINKED],
563     AC_MSG_CHECKING(if libpthread is linked)
564     AC_TRY_LINK([],
565         [return pthread_create(0, 0, 0, 0);],
566         [
567             AC_MSG_RESULT(yes)
568             $1
569         ],
570         [
571             AC_MSG_RESULT(no)
572             $2
573         ])
576 dnl SMB_REMOVE_LIB(lib)
577 dnl Remove the given library from $LIBS
578 AC_DEFUN([SMB_REMOVELIB],
580     LIBS=`echo $LIBS | sed -es/-l$1//g`
583 dnl SMB_CHECK_DMAPI([actions if true], [actions if false])
584 dnl Check whether DMAPI is available and is a version that we know
585 dnl how to deal with. The default truth action is to set samba_dmapi_libs
586 dnl to the list of necessary libraries, and to define USE_DMAPI.
587 AC_DEFUN([SMB_CHECK_DMAPI],
589     samba_dmapi_libs=""
591     if test x"$samba_dmapi_libs" = x"" ; then
592         AC_CHECK_LIB(dm, dm_get_eventlist,
593                 [ samba_dmapi_libs="-ldm"], [])
594     fi
596     if test x"$samba_dmapi_libs" = x"" ; then
597         AC_CHECK_LIB(jfsdm, dm_get_eventlist,
598                 [samba_dmapi_libs="-ljfsdm"], [])
599     fi
601     if test x"$samba_dmapi_libs" = x"" ; then
602         AC_CHECK_LIB(xdsm, dm_get_eventlist,
603                 [samba_dmapi_libs="-lxdsm"], [])
604     fi
606     # Only bother to test ehaders if we have a candidate DMAPI library
607     if test x"$samba_dmapi_libs" != x"" ; then
608         AC_CHECK_HEADERS(sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h)
609     fi
611     if test x"$samba_dmapi_libs" != x"" ; then
612         samba_dmapi_save_LIBS="$LIBS"
613         LIBS="$LIBS $samba_dmapi_libs"
614         AC_TRY_LINK(
615                 [
616 #include <time.h>      /* needed by Tru64 */
617 #include <sys/types.h> /* needed by AIX */
618 #ifdef HAVE_XFS_DMAPI_H
619 #include <xfs/dmapi.h>
620 #elif defined(HAVE_SYS_DMI_H)
621 #include <sys/dmi.h>
622 #elif defined(HAVE_SYS_JFSDMAPI_H)
623 #include <sys/jfsdmapi.h>
624 #elif defined(HAVE_SYS_DMAPI_H)
625 #include <sys/dmapi.h>
626 #endif
627                 ],
628                 [
629 /* This link test is designed to fail on IRI 6.4, but should
630  * succeed on Linux, IRIX 6.5 and AIX.
631  */
632         char * version;
633         dm_eventset_t events;
634         /* This doesn't take an argument on IRIX 6.4. */
635         dm_init_service(&version);
636         /* IRIX 6.4 expects events to be a pointer. */
637         DMEV_ISSET(DM_EVENT_READ, events);
638                 ],
639                 [
640                     true # DMAPI link test succeeded
641                 ],
642                 [
643                     # DMAPI link failure
644                     samba_dmapi_libs=
645                 ])
646         LIBS="$samba_dmapi_save_LIBS"
647     fi
649     if test x"$samba_dmapi_libs" = x"" ; then
650         # DMAPI detection failure actions begin
651         ifelse($2, [],
652             [
653                 AC_ERROR(Failed to detect a supported DMAPI implementation)
654             ],
655             [
656                 $2
657             ])
658         # DMAPI detection failure actions end
659     else
660         # DMAPI detection success actions start
661         ifelse($1, [],
662             [
663                 AC_DEFINE(USE_DMAPI, 1,
664                     [Whether we should build DMAPI integration components])
665                 AC_MSG_NOTICE(Found DMAPI support in $samba_dmapi_libs)
666             ],
667             [
668                 $1
669             ])
670         # DMAPI detection success actions end
671     fi
675 dnl SMB_CHECK_CLOCK_ID(clockid)
676 dnl Test whether the specified clock_gettime clock ID is available. If it
677 dnl is, we define HAVE_clockid
678 AC_DEFUN([SMB_CHECK_CLOCK_ID],
680     AC_MSG_CHECKING(for $1)
681     AC_TRY_LINK([
682 #if TIME_WITH_SYS_TIME
683 # include <sys/time.h>
684 # include <time.h>
685 #else
686 # if HAVE_SYS_TIME_H
687 #  include <sys/time.h>
688 # else
689 #  include <time.h>
690 # endif
691 #endif
692     ],
693     [
694 clockid_t clk = $1;
695     ],
696     [
697         AC_MSG_RESULT(yes)
698         AC_DEFINE(HAVE_$1, 1,
699             [Whether the clock_gettime clock ID $1 is available])
700     ],
701     [
702         AC_MSG_RESULT(no)
703     ])
706 dnl SMB_IF_RTSIGNAL_BUG([actions if true],
707 dnl                     [actions if false],
708 dnl                     [actions if cross compiling])
709 dnl Test whether we can call sigaction with RT_SIGNAL_NOTIFY and
710 dnl RT_SIGNAL_LEASE (also RT_SIGNAL_AIO for good measure, though
711 dnl I don't believe that triggers any bug.
713 dnl See the samba-technical thread titled "Failed to setup
714 dnl RT_SIGNAL_NOTIFY handler" for details on the bug in question.
715 AC_DEFUN([SMB_IF_RTSIGNAL_BUG],
717     rt_signal_notify_works=yes
718     rt_signal_lease_works=yes
719     rt_signal_aio_works=yes
721     AC_MSG_CHECKING(if sigaction works with realtime signals)
722     AC_TRY_RUN(
723         [
724 #include <sys/types.h>
725 #include <fcntl.h>
726 #include <signal.h>
728 /* from smbd/notify_kernel.c */
729 #ifndef RT_SIGNAL_NOTIFY
730 #define RT_SIGNAL_NOTIFY (SIGRTMIN+2)
731 #endif
733 /* from smbd/aio.c */
734 #ifndef RT_SIGNAL_AIO
735 #define RT_SIGNAL_AIO (SIGRTMIN+3)
736 #endif
738 /* from smbd/oplock_linux.c */
739 #ifndef RT_SIGNAL_LEASE
740 #define RT_SIGNAL_LEASE (SIGRTMIN+1)
741 #endif
743 static void signal_handler(int sig, siginfo_t *info, void *unused)
745     int do_nothing = 0;
748 int main(void)
750     int result = 0;
751     struct sigaction act = {0};
753     act.sa_sigaction = signal_handler;
754     act.sa_flags = SA_SIGINFO;
755     sigemptyset( &act.sa_mask );
757     if (sigaction(RT_SIGNAL_LEASE, &act, 0) != 0) {
758             /* Failed to setup RT_SIGNAL_LEASE handler */
759             result += 1;
760     }
762     if (sigaction(RT_SIGNAL_NOTIFY, &act, 0) != 0) {
763             /* Failed to setup RT_SIGNAL_NOTIFY handler */
764             result += 10;
765     }
767     if (sigaction(RT_SIGNAL_AIO, &act, 0) != 0) {
768             /* Failed to setup RT_SIGNAL_AIO handler */
769             result += 100;
770     }
772     /* zero on success */
773     return result;
775         ],
776         [
777             AC_MSG_RESULT(yes)
778             $2
779         ],
780         [
781             AC_MSG_RESULT(no)
782             case "$ac_status" in
783                 1|11|101|111)  rt_signal_lease_ok=no ;;
784             esac
785             case "$ac_status" in
786                 10|11|110|111)  rt_signal_notify_ok=no ;;
787             esac
788             case "$ac_status" in
789                 100|110|101|111)  rt_signal_aio_ok=no ;;
790             esac
791             $2
792         ],
793         [
794             AC_MSG_RESULT(cross)
795             $3
796         ])