source: trunk/samba/source/m4/aclocal.m4@ 138

Last change on this file since 138 was 138, checked in by Paul Smedley, 17 years ago

Update source to 3.2.0 GA level

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