source: trunk/server/source3/m4/aclocal.m4@ 745

Last change on this file since 745 was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

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