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