source: branches/samba-3.5.x/source3/m4/aclocal.m4@ 738

Last change on this file since 738 was 480, checked in by Silvan Scherrer, 15 years ago

Samba Server 3.5: trunk update to 3.5.4

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