~vcs-imports/samba/main

« back to all changes in this revision

Viewing changes to source/aclocal.m4

  • Committer: jerry
  • Date: 2006-07-14 21:48:39 UTC
  • Revision ID: vcs-imports@canonical.com-20060714214839-586d8c489a8fcead
gutting trunk to move to svn:externals

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
2
 
dnl if the cache file is inconsistent with the current host,
3
 
dnl target and build system types, execute CMD or print a default
4
 
dnl error message.
5
 
AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
6
 
    AC_REQUIRE([AC_CANONICAL_SYSTEM])
7
 
    AC_MSG_CHECKING([config.cache system type])
8
 
    if { test x"${ac_cv_host_system_type+set}" = x"set" &&
9
 
         test x"$ac_cv_host_system_type" != x"$host"; } ||
10
 
       { test x"${ac_cv_build_system_type+set}" = x"set" &&
11
 
         test x"$ac_cv_build_system_type" != x"$build"; } ||
12
 
       { test x"${ac_cv_target_system_type+set}" = x"set" &&
13
 
         test x"$ac_cv_target_system_type" != x"$target"; }; then
14
 
        AC_MSG_RESULT([different])
15
 
        ifelse($#, 1, [$1],
16
 
                [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
17
 
    else
18
 
        AC_MSG_RESULT([same])
19
 
    fi
20
 
    ac_cv_host_system_type="$host"
21
 
    ac_cv_build_system_type="$build"
22
 
    ac_cv_target_system_type="$target"
23
 
])
24
 
 
25
 
 
26
 
dnl test whether dirent has a d_off member
27
 
AC_DEFUN(AC_DIRENT_D_OFF,
28
 
[AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off,
29
 
[AC_TRY_COMPILE([
30
 
#include <unistd.h>
31
 
#include <sys/types.h>
32
 
#include <dirent.h>], [struct dirent d; d.d_off;],
33
 
ac_cv_dirent_d_off=yes, ac_cv_dirent_d_off=no)])
34
 
if test $ac_cv_dirent_d_off = yes; then
35
 
  AC_DEFINE(HAVE_DIRENT_D_OFF,1,[Whether dirent has a d_off member])
36
 
fi
37
 
])
38
 
 
39
 
dnl Mark specified module as shared
40
 
dnl SMB_MODULE(name,static_files,shared_files,subsystem,whatif-static,whatif-shared)
41
 
AC_DEFUN(SMB_MODULE,
42
 
[
43
 
        AC_MSG_CHECKING([how to build $1])
44
 
        if test "$[MODULE_][$1]"; then
45
 
                DEST=$[MODULE_][$1]
46
 
        elif test "$[MODULE_]translit([$4], [A-Z], [a-z])" -a "$[MODULE_DEFAULT_][$1]"; then
47
 
                DEST=$[MODULE_]translit([$4], [A-Z], [a-z])
48
 
        else
49
 
                DEST=$[MODULE_DEFAULT_][$1]
50
 
        fi
51
 
        
52
 
        if test x"$DEST" = xSHARED; then
53
 
                AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module])
54
 
                $4_MODULES="$$4_MODULES $3"
55
 
                AC_MSG_RESULT([shared])
56
 
                [$6]
57
 
                string_shared_modules="$string_shared_modules $1"
58
 
        elif test x"$DEST" = xSTATIC; then
59
 
                [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z])  $1_init();"
60
 
                [decl_static_modules_]translit([$4], [A-Z], [a-z])="$[decl_static_modules_]translit([$4], [A-Z], [a-z]) extern NTSTATUS $1_init(void);"
61
 
                string_static_modules="$string_static_modules $1"
62
 
                $4_STATIC="$$4_STATIC $2"
63
 
                AC_SUBST($4_STATIC)
64
 
                [$5]
65
 
                AC_MSG_RESULT([static])
66
 
        else
67
 
            string_ignored_modules="$string_ignored_modules $1"
68
 
                AC_MSG_RESULT([not])
69
 
        fi
70
 
])
71
 
 
72
 
AC_DEFUN(SMB_SUBSYSTEM,
73
 
[
74
 
        AC_SUBST($1_STATIC)
75
 
        AC_SUBST($1_MODULES)
76
 
        AC_DEFINE_UNQUOTED([static_init_]translit([$1], [A-Z], [a-z]), [{$init_static_modules_]translit([$1], [A-Z], [a-z])[}], [Static init functions])
77
 
        AC_DEFINE_UNQUOTED([static_decl_]translit([$1], [A-Z], [a-z]), [$decl_static_modules_]translit([$1], [A-Z], [a-z]), [Decl of Static init functions])
78
 
        ifelse([$2], , :, [rm -f $2])
79
 
])
80
 
 
81
 
dnl AC_PROG_CC_FLAG(flag)
82
 
AC_DEFUN(AC_PROG_CC_FLAG,
83
 
[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
84
 
[echo 'void f(){}' > conftest.c
85
 
if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
86
 
  ac_cv_prog_cc_$1=yes
87
 
else
88
 
  ac_cv_prog_cc_$1=no
89
 
fi
90
 
rm -f conftest*
91
 
])])
92
 
 
93
 
dnl see if a declaration exists for a function or variable
94
 
dnl defines HAVE_function_DECL if it exists
95
 
dnl AC_HAVE_DECL(var, includes)
96
 
AC_DEFUN(AC_HAVE_DECL,
97
 
[
98
 
 AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
99
 
    AC_TRY_COMPILE([$2],[int i = (int)$1],
100
 
        ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
101
 
 if test x"$ac_cv_have_$1_decl" = x"yes"; then
102
 
    AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
103
 
 fi
104
 
])
105
 
 
106
 
 
107
 
dnl AC_LIBTESTFUNC(lib, function, [actions if found], [actions if not found])
108
 
dnl Check for a function in a library, but don't keep adding the same library
109
 
dnl to the LIBS variable.  Check whether the function is available in the
110
 
dnl current LIBS before adding the library which prevents us spuriously
111
 
dnl adding libraries for symbols that are in libc.
112
 
dnl
113
 
dnl On success, the default actions ensure that HAVE_FOO is defined. The lib
114
 
dnl is always added to $LIBS if it was found to be necessary. The caller
115
 
dnl can use SMB_LIB_REMOVE to strp this if necessary.
116
 
AC_DEFUN([AC_LIBTESTFUNC],
117
 
[
118
 
  AC_CHECK_FUNCS($2,
119
 
      [
120
 
        # $2 was found in libc or existing $LIBS
121
 
        ifelse($3, [],
122
 
            [
123
 
                AC_DEFINE(translit([HAVE_$2], [a-z], [A-Z]), 1,
124
 
                    [Whether $2 is available])
125
 
            ],
126
 
            [
127
 
                $3
128
 
            ])
129
 
      ],
130
 
      [
131
 
        # $2 was not found, try adding lib$1
132
 
        case " $LIBS " in
133
 
          *\ -l$1\ *)
134
 
            ifelse($4, [],
135
 
                [
136
 
                    # $2 was not found and we already had lib$1
137
 
                    # nothing to do here by default
138
 
                    true
139
 
                ],
140
 
                [ $4 ])
141
 
            ;;
142
 
          *)
143
 
            # $2 was not found, try adding lib$1
144
 
            AC_CHECK_LIB($1, $2,
145
 
              [
146
 
                LIBS="-l$1 $LIBS"
147
 
                ifelse($3, [],
148
 
                    [
149
 
                        AC_DEFINE(translit([HAVE_$2], [a-z], [A-Z]), 1,
150
 
                            [Whether $2 is available])
151
 
                    ],
152
 
                    [
153
 
                        $3
154
 
                    ])
155
 
              ],
156
 
              [
157
 
                ifelse($4, [],
158
 
                    [
159
 
                        # $2 was not found in lib$1
160
 
                        # nothing to do here by default
161
 
                        true
162
 
                    ],
163
 
                    [ $4 ])
164
 
              ])
165
 
          ;;
166
 
        esac
167
 
      ])
168
 
])
169
 
 
170
 
# AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
171
 
#              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
172
 
#              [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
173
 
# ------------------------------------------------------
174
 
#
175
 
# Use a cache variable name containing both the library and function name,
176
 
# because the test really is for library $1 defining function $3, not
177
 
# just for library $1.  Separate tests with the same $1 and different $3s
178
 
# may have different results.
179
 
#
180
 
# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
181
 
# is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
182
 
# ac_cv_lib_$lib_fun, which is definitely not what was meant.  Hence
183
 
# the AS_LITERAL_IF indirection.
184
 
#
185
 
# FIXME: This macro is extremely suspicious.  It DEFINEs unconditionally,
186
 
# whatever the FUNCTION, in addition to not being a *S macro.  Note
187
 
# that the cache does depend upon the function we are looking for.
188
 
#
189
 
# It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
190
 
# `ac_save_LIBS': there are many macros which don't want to see `LIBS'
191
 
# changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
192
 
# And ``ac_save_LIBS' is too tempting a name, so let's leave them some
193
 
# freedom.
194
 
AC_DEFUN([AC_CHECK_LIB_EXT],
195
 
[
196
 
AH_CHECK_LIB_EXT([$1])
197
 
ac_check_lib_ext_save_LIBS=$LIBS
198
 
LIBS="-l$1 $$2 $7 $LIBS"
199
 
AS_LITERAL_IF([$1],
200
 
      [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
201
 
      [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
202
 
 
203
 
m4_ifval([$3],
204
 
 [
205
 
    AH_CHECK_FUNC_EXT([$3])
206
 
    AS_LITERAL_IF([$1],
207
 
              [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
208
 
              [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
209
 
    AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
210
 
        [AC_TRY_LINK_FUNC($3,
211
 
                 [AS_VAR_SET(ac_Lib_func, yes);
212
 
                  AS_VAR_SET(ac_Lib_ext, yes)],
213
 
                 [AS_VAR_SET(ac_Lib_func, no);
214
 
                  AS_VAR_SET(ac_Lib_ext, no)])
215
 
        ])
216
 
    AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
217
 
        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
218
 
    AS_VAR_POPDEF([ac_Lib_func])dnl
219
 
 ],[
220
 
    AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
221
 
        [AC_TRY_LINK_FUNC([main],
222
 
                 [AS_VAR_SET(ac_Lib_ext, yes)],
223
 
                 [AS_VAR_SET(ac_Lib_ext, no)])
224
 
        ])
225
 
 ])
226
 
LIBS=$ac_check_lib_ext_save_LIBS
227
 
 
228
 
AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
229
 
    [m4_default([$4], 
230
 
        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
231
 
                case "$$2" in
232
 
                    *-l$1*)
233
 
                        ;;
234
 
                    *)
235
 
                        $2="-l$1 $$2"
236
 
                        ;;
237
 
                esac])
238
 
                [$6]
239
 
            ],
240
 
            [$5])dnl
241
 
AS_VAR_POPDEF([ac_Lib_ext])dnl
242
 
])# AC_CHECK_LIB_EXT
243
 
 
244
 
# AH_CHECK_LIB_EXT(LIBNAME)
245
 
# ---------------------
246
 
m4_define([AH_CHECK_LIB_EXT],
247
 
[AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
248
 
             [Define to 1 if you have the `]$1[' library (-l]$1[).])])
249
 
 
250
 
# AC_CHECK_FUNCS_EXT(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
251
 
# -----------------------------------------------------------------
252
 
dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
253
 
dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
254
 
AC_DEFUN([AC_CHECK_FUNC_EXT],
255
 
[
256
 
    AH_CHECK_FUNC_EXT($1)       
257
 
    ac_check_func_ext_save_LIBS=$LIBS
258
 
    LIBS="$2 $LIBS"
259
 
    AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
260
 
    AC_CACHE_CHECK([for $1], ac_var,
261
 
        [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
262
 
                [AS_VAR_SET(ac_var, yes)],
263
 
                [AS_VAR_SET(ac_var, no)])])
264
 
    LIBS=$ac_check_func_ext_save_LIBS
265
 
    AS_IF([test AS_VAR_GET(ac_var) = yes], 
266
 
            [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], 
267
 
            [$4])dnl
268
 
AS_VAR_POPDEF([ac_var])dnl
269
 
])# AC_CHECK_FUNC
270
 
 
271
 
# AH_CHECK_FUNC_EXT(FUNCNAME)
272
 
# ---------------------
273
 
m4_define([AH_CHECK_FUNC_EXT],
274
 
[AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
275
 
             [Define to 1 if you have the `]$1[' function.])])
276
 
 
277
 
dnl Define an AC_DEFINE with ifndef guard.
278
 
dnl AC_N_DEFINE(VARIABLE [, VALUE])
279
 
define(AC_N_DEFINE,
280
 
[cat >> confdefs.h <<\EOF
281
 
[#ifndef] $1
282
 
[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
283
 
[#endif]
284
 
EOF
285
 
])
286
 
 
287
 
dnl Add an #include
288
 
dnl AC_ADD_INCLUDE(VARIABLE)
289
 
define(AC_ADD_INCLUDE,
290
 
[cat >> confdefs.h <<\EOF
291
 
[#include] $1
292
 
EOF
293
 
])
294
 
 
295
 
dnl Copied from libtool.m4
296
 
AC_DEFUN(AC_PROG_LD_GNU,
297
 
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
298
 
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
299
 
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
300
 
  ac_cv_prog_gnu_ld=yes
301
 
else
302
 
  ac_cv_prog_gnu_ld=no
303
 
fi])
304
 
])
305
 
 
306
 
# Configure paths for LIBXML2
307
 
# Toshio Kuratomi 2001-04-21
308
 
# Adapted from:
309
 
# Configure paths for GLIB
310
 
# Owen Taylor     97-11-3
311
 
 
312
 
dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
313
 
dnl Test for XML, and define XML_CFLAGS and XML_LIBS
314
 
dnl
315
 
AC_DEFUN(AM_PATH_XML2,[ 
316
 
AC_ARG_WITH(xml-prefix,
317
 
            [  --with-xml-prefix=PFX   Prefix where libxml is installed (optional)],
318
 
            xml_config_prefix="$withval", xml_config_prefix="")
319
 
AC_ARG_WITH(xml-exec-prefix,
320
 
            [  --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
321
 
            xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
322
 
AC_ARG_ENABLE(xmltest,
323
 
              [  --disable-xmltest       Do not try to compile and run a test LIBXML program],,
324
 
              enable_xmltest=yes)
325
 
 
326
 
  if test x$xml_config_exec_prefix != x ; then
327
 
     xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
328
 
     if test x${XML2_CONFIG+set} != xset ; then
329
 
        XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
330
 
     fi
331
 
  fi
332
 
  if test x$xml_config_prefix != x ; then
333
 
     xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
334
 
     if test x${XML2_CONFIG+set} != xset ; then
335
 
        XML2_CONFIG=$xml_config_prefix/bin/xml2-config
336
 
     fi
337
 
  fi
338
 
 
339
 
  AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
340
 
  min_xml_version=ifelse([$1], ,2.0.0,[$1])
341
 
  AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
342
 
  no_xml=""
343
 
  if test "$XML2_CONFIG" = "no" ; then
344
 
    no_xml=yes
345
 
  else
346
 
    XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
347
 
    XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
348
 
    xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
349
 
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
350
 
    xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
351
 
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
352
 
    xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
353
 
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
354
 
    if test "x$enable_xmltest" = "xyes" ; then
355
 
      ac_save_CFLAGS="$CFLAGS"
356
 
      ac_save_LIBS="$LIBS"
357
 
      CFLAGS="$CFLAGS $XML_CFLAGS"
358
 
      LIBS="$XML_LIBS $LIBS"
359
 
dnl
360
 
dnl Now check if the installed libxml is sufficiently new.
361
 
dnl (Also sanity checks the results of xml2-config to some extent)
362
 
dnl
363
 
      rm -f conf.xmltest
364
 
      AC_TRY_RUN([
365
 
#include <stdlib.h>
366
 
#include <stdio.h>
367
 
#include <string.h>
368
 
#include <libxml/xmlversion.h>
369
 
 
370
 
int 
371
 
main()
372
 
{
373
 
  int xml_major_version, xml_minor_version, xml_micro_version;
374
 
  int major, minor, micro;
375
 
  char *tmp_version;
376
 
 
377
 
  system("touch conf.xmltest");
378
 
 
379
 
  /* Capture xml2-config output via autoconf/configure variables */
380
 
  /* HP/UX 9 (%@#!) writes to sscanf strings */
381
 
  tmp_version = (char *)strdup("$min_xml_version");
382
 
  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
383
 
     printf("%s, bad version string from xml2-config\n", "$min_xml_version");
384
 
     exit(1);
385
 
   }
386
 
   free(tmp_version);
387
 
 
388
 
   /* Capture the version information from the header files */
389
 
   tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
390
 
   if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
391
 
     printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
392
 
     exit(1);
393
 
   }
394
 
   free(tmp_version);
395
 
 
396
 
 /* Compare xml2-config output to the libxml headers */
397
 
  if ((xml_major_version != $xml_config_major_version) ||
398
 
      (xml_minor_version != $xml_config_minor_version) ||
399
 
      (xml_micro_version != $xml_config_micro_version))
400
 
    {
401
 
      printf("*** libxml header files (version %d.%d.%d) do not match\n",
402
 
         xml_major_version, xml_minor_version, xml_micro_version);
403
 
      printf("*** xml2-config (version %d.%d.%d)\n",
404
 
         $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
405
 
      return 1;
406
 
    } 
407
 
/* Compare the headers to the library to make sure we match */
408
 
  /* Less than ideal -- doesn't provide us with return value feedback, 
409
 
   * only exits if there's a serious mismatch between header and library.
410
 
   */
411
 
    LIBXML_TEST_VERSION;
412
 
 
413
 
    /* Test that the library is greater than our minimum version */
414
 
    if ((xml_major_version > major) ||
415
 
        ((xml_major_version == major) && (xml_minor_version > minor)) ||
416
 
        ((xml_major_version == major) && (xml_minor_version == minor) &&
417
 
        (xml_micro_version >= micro)))
418
 
      {
419
 
        return 0;
420
 
       }
421
 
     else
422
 
      {
423
 
        printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
424
 
               xml_major_version, xml_minor_version, xml_micro_version);
425
 
        printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
426
 
           major, minor, micro);
427
 
        printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
428
 
        printf("***\n");
429
 
        printf("*** If you have already installed a sufficiently new version, this error\n");
430
 
        printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
431
 
        printf("*** being found. The easiest way to fix this is to remove the old version\n");
432
 
        printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
433
 
        printf("*** correct copy of xml2-config. (In this case, you will have to\n");
434
 
        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
435
 
        printf("*** so that the correct libraries are found at run-time))\n");
436
 
    }
437
 
  return 1;
438
 
}
439
 
],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
440
 
       CFLAGS="$ac_save_CFLAGS"
441
 
       LIBS="$ac_save_LIBS"
442
 
     fi
443
 
  fi
444
 
 
445
 
  if test "x$no_xml" = x ; then
446
 
     AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
447
 
     ifelse([$2], , :, [$2])     
448
 
  else
449
 
     AC_MSG_RESULT(no)
450
 
     if test "$XML2_CONFIG" = "no" ; then
451
 
       echo "*** The xml2-config script installed by LIBXML could not be found"
452
 
       echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
453
 
       echo "*** your path, or set the XML2_CONFIG environment variable to the"
454
 
       echo "*** full path to xml2-config."
455
 
     else
456
 
       if test -f conf.xmltest ; then
457
 
        :
458
 
       else
459
 
          echo "*** Could not run libxml test program, checking why..."
460
 
          CFLAGS="$CFLAGS $XML_CFLAGS"
461
 
          LIBS="$LIBS $XML_LIBS"
462
 
          AC_TRY_LINK([
463
 
#include <libxml/xmlversion.h>
464
 
#include <stdio.h>
465
 
],      [ LIBXML_TEST_VERSION; return 0;],
466
 
        [ echo "*** The test program compiled, but did not run. This usually means"
467
 
          echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
468
 
          echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
469
 
          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
470
 
          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
471
 
          echo "*** is required on your system"
472
 
          echo "***"
473
 
          echo "*** If you have an old version installed, it is best to remove it, although"
474
 
          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
475
 
        [ echo "*** The test program failed to compile or link. See the file config.log for the"
476
 
          echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
477
 
          echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
478
 
          echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
479
 
          CFLAGS="$ac_save_CFLAGS"
480
 
          LIBS="$ac_save_LIBS"
481
 
       fi
482
 
     fi
483
 
 
484
 
     XML_CFLAGS=""
485
 
     XML_LIBS=""
486
 
     ifelse([$3], , :, [$3])
487
 
  fi
488
 
  AC_SUBST(XML_CFLAGS)
489
 
  AC_SUBST(XML_LIBS)
490
 
  rm -f conf.xmltest
491
 
])
492
 
 
493
 
# =========================================================================
494
 
# AM_PATH_MYSQL : MySQL library
495
 
 
496
 
dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
497
 
dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS
498
 
dnl
499
 
AC_DEFUN(AM_PATH_MYSQL,
500
 
[dnl
501
 
dnl Get the cflags and libraries from the mysql_config script
502
 
dnl
503
 
AC_ARG_WITH(mysql-prefix,[  --with-mysql-prefix=PFX   Prefix where MYSQL is installed (optional)],
504
 
            mysql_prefix="$withval", mysql_prefix="")
505
 
AC_ARG_WITH(mysql-exec-prefix,[  --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)],
506
 
            mysql_exec_prefix="$withval", mysql_exec_prefix="")
507
 
 
508
 
  if test x$mysql_exec_prefix != x ; then
509
 
     mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix"
510
 
     if test x${MYSQL_CONFIG+set} != xset ; then
511
 
        MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config
512
 
     fi
513
 
  fi
514
 
  if test x$mysql_prefix != x ; then
515
 
     mysql_args="$mysql_args --prefix=$mysql_prefix"
516
 
     if test x${MYSQL_CONFIG+set} != xset ; then
517
 
        MYSQL_CONFIG=$mysql_prefix/bin/mysql_config
518
 
     fi
519
 
  fi
520
 
 
521
 
  AC_REQUIRE([AC_CANONICAL_TARGET])
522
 
  AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
523
 
  AC_MSG_CHECKING(for MYSQL)
524
 
  no_mysql=""
525
 
  if test "$MYSQL_CONFIG" = "no" ; then
526
 
    MYSQL_CFLAGS=""
527
 
    MYSQL_LIBS=""
528
 
    AC_MSG_RESULT(no)
529
 
     ifelse([$2], , :, [$2])
530
 
  else
531
 
    MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"`
532
 
    MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"`
533
 
    AC_MSG_RESULT(yes)
534
 
    ifelse([$1], , :, [$1])
535
 
  fi
536
 
  AC_SUBST(MYSQL_CFLAGS)
537
 
  AC_SUBST(MYSQL_LIBS)
538
 
])
539
 
 
540
 
# =========================================================================
541
 
# AM_PATH_PGSQL : pgSQL library
542
 
 
543
 
dnl AM_PATH_PGSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
544
 
dnl Test for PGSQL, and define PGSQL_CFLAGS and PGSQL_LIBS
545
 
dnl
546
 
AC_DEFUN(AM_PATH_PGSQL,
547
 
[dnl
548
 
dnl Get the cflags and libraries from the pg_config script
549
 
dnl
550
 
AC_ARG_WITH(pgsql-prefix,[  --with-pgsql-prefix=PFX   Prefix where PostgreSQL is installed (optional)],
551
 
            pgsql_prefix="$withval", pgsql_prefix="")
552
 
AC_ARG_WITH(pgsql-exec-prefix,[  --with-pgsql-exec-prefix=PFX Exec prefix where PostgreSQL is installed (optional)],
553
 
            pgsql_exec_prefix="$withval", pgsql_exec_prefix="")
554
 
 
555
 
  if test x$pgsql_exec_prefix != x ; then
556
 
     if test x${PGSQL_CONFIG+set} != xset ; then
557
 
        PGSQL_CONFIG=$pgsql_exec_prefix/bin/pg_config
558
 
     fi
559
 
  fi
560
 
  if test x$pgsql_prefix != x ; then
561
 
     if test x${PGSQL_CONFIG+set} != xset ; then
562
 
        PGSQL_CONFIG=$pgsql_prefix/bin/pg_config
563
 
     fi
564
 
  fi
565
 
 
566
 
  AC_REQUIRE([AC_CANONICAL_TARGET])
567
 
  AC_PATH_PROG(PGSQL_CONFIG, pg_config, no, [$PATH:/usr/lib/postgresql/bin])
568
 
  AC_MSG_CHECKING(for PGSQL)
569
 
  no_pgsql=""
570
 
  if test "$PGSQL_CONFIG" = "no" ; then
571
 
    PGSQL_CFLAGS=""
572
 
    PGSQL_LIBS=""
573
 
    AC_MSG_RESULT(no)
574
 
     ifelse([$2], , :, [$2])
575
 
  else
576
 
    PGSQL_CFLAGS=-I`$PGSQL_CONFIG --includedir`
577
 
    PGSQL_LIBS="-lpq -L`$PGSQL_CONFIG --libdir`"
578
 
    AC_MSG_RESULT(yes)
579
 
    ifelse([$1], , :, [$1])
580
 
  fi
581
 
  AC_SUBST(PGSQL_CFLAGS)
582
 
  AC_SUBST(PGSQL_LIBS)
583
 
])
584
 
 
585
 
dnl Removes -I/usr/include/? from given variable
586
 
AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
587
 
  ac_new_flags=""
588
 
  for i in [$]$1; do
589
 
    case [$]i in
590
 
    -I/usr/include|-I/usr/include/) ;;
591
 
    *) ac_new_flags="[$]ac_new_flags [$]i" ;;
592
 
    esac
593
 
  done
594
 
  $1=[$]ac_new_flags
595
 
])
596
 
    
597
 
dnl Removes -L/usr/lib/? from given variable
598
 
AC_DEFUN(LIB_REMOVE_USR_LIB,[
599
 
  ac_new_flags=""
600
 
  for i in [$]$1; do
601
 
    case [$]i in
602
 
    -L/usr/lib|-L/usr/lib/) ;;
603
 
    *) ac_new_flags="[$]ac_new_flags [$]i" ;;
604
 
    esac
605
 
  done
606
 
  $1=[$]ac_new_flags
607
 
])
608
 
 
609
 
dnl From Bruno Haible.
610
 
 
611
 
AC_DEFUN(jm_ICONV,
612
 
[
613
 
  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
614
 
  dnl those with the standalone portable libiconv installed).
615
 
  AC_MSG_CHECKING(for iconv in $1)
616
 
    jm_cv_func_iconv="no"
617
 
    jm_cv_lib_iconv=""
618
 
    jm_cv_giconv=no
619
 
    jm_save_LIBS="$LIBS"
620
 
 
621
 
    dnl Check for include in funny place but no lib needed
622
 
    if test "$jm_cv_func_iconv" != yes; then 
623
 
      AC_TRY_LINK([#include <stdlib.h>
624
 
#include <giconv.h>],
625
 
        [iconv_t cd = iconv_open("","");
626
 
         iconv(cd,NULL,NULL,NULL,NULL);
627
 
         iconv_close(cd);],
628
 
         jm_cv_func_iconv=yes
629
 
         jm_cv_include="giconv.h"
630
 
         jm_cv_giconv="yes"
631
 
         jm_cv_lib_iconv="")
632
 
 
633
 
      dnl Standard iconv.h include, lib in glibc or libc ...
634
 
      if test "$jm_cv_func_iconv" != yes; then
635
 
        AC_TRY_LINK([#include <stdlib.h>
636
 
#include <iconv.h>],
637
 
          [iconv_t cd = iconv_open("","");
638
 
           iconv(cd,NULL,NULL,NULL,NULL);
639
 
           iconv_close(cd);],
640
 
           jm_cv_include="iconv.h"
641
 
           jm_cv_func_iconv=yes
642
 
           jm_cv_lib_iconv="")
643
 
 
644
 
          if test "$jm_cv_lib_iconv" != yes; then
645
 
            jm_save_LIBS="$LIBS"
646
 
            LIBS="$LIBS -lgiconv"
647
 
            AC_TRY_LINK([#include <stdlib.h>
648
 
#include <giconv.h>],
649
 
              [iconv_t cd = iconv_open("","");
650
 
               iconv(cd,NULL,NULL,NULL,NULL);
651
 
               iconv_close(cd);],
652
 
              jm_cv_lib_iconv=yes
653
 
              jm_cv_func_iconv=yes
654
 
              jm_cv_include="giconv.h"
655
 
              jm_cv_giconv=yes
656
 
              jm_cv_lib_iconv="giconv")
657
 
 
658
 
           LIBS="$jm_save_LIBS"
659
 
 
660
 
        if test "$jm_cv_func_iconv" != yes; then
661
 
          jm_save_LIBS="$LIBS"
662
 
          LIBS="$LIBS -liconv"
663
 
          AC_TRY_LINK([#include <stdlib.h>
664
 
#include <iconv.h>],
665
 
            [iconv_t cd = iconv_open("","");
666
 
             iconv(cd,NULL,NULL,NULL,NULL);
667
 
             iconv_close(cd);],
668
 
            jm_cv_include="iconv.h"
669
 
            jm_cv_func_iconv=yes
670
 
            jm_cv_lib_iconv="iconv")
671
 
          LIBS="$jm_save_LIBS"
672
 
        fi
673
 
      fi
674
 
    fi
675
 
  fi
676
 
  if test "$jm_cv_func_iconv" = yes; then
677
 
    if test "$jm_cv_giconv" = yes; then
678
 
      AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
679
 
      AC_MSG_RESULT(yes)
680
 
      ICONV_FOUND=yes
681
 
    else
682
 
      if test "$jm_cv_biconv" = yes; then
683
 
        AC_DEFINE(HAVE_BICONV, 1, [What header to include for iconv() function: biconv.h])
684
 
        AC_MSG_RESULT(yes)
685
 
        ICONV_FOUND=yes
686
 
      else 
687
 
        AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
688
 
        AC_MSG_RESULT(yes)
689
 
        ICONV_FOUND=yes
690
 
      fi
691
 
    fi
692
 
  else
693
 
    AC_MSG_RESULT(no)
694
 
  fi
695
 
])
696
 
 
697
 
AC_DEFUN(rjs_CHARSET,[
698
 
  dnl Find out if we can convert from $1 to UCS2-LE
699
 
  AC_MSG_CHECKING([can we convert from $1 to UCS2-LE?])
700
 
  AC_TRY_RUN([
701
 
#include <$jm_cv_include>
702
 
main(){
703
 
    iconv_t cd = iconv_open("$1", "UCS-2LE");
704
 
    if (cd == 0 || cd == (iconv_t)-1) {
705
 
        return -1;
706
 
    }
707
 
    return 0;
708
 
}
709
 
  ],ICONV_CHARSET=$1,ICONV_CHARSET=no,ICONV_CHARSET=cross)
710
 
  AC_MSG_RESULT($ICONV_CHARSET)
711
 
])
712
 
 
713
 
dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
714
 
dnl This function doesn't add -I/usr/include into CFLAGS
715
 
AC_DEFUN(CFLAGS_ADD_DIR,[
716
 
if test "$2" != "/usr/include" ; then
717
 
    $1="$$1 -I$2"
718
 
fi
719
 
])
720
 
 
721
 
dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
722
 
dnl This function doesn't add -L/usr/lib into LDFLAGS
723
 
AC_DEFUN(LIB_ADD_DIR,[
724
 
if test "$2" != "/usr/lib" ; then
725
 
    $1="$$1 -L$2"
726
 
fi
727
 
])
728
 
 
729
 
dnl AC_ENABLE_SHARED - implement the --enable-shared flag
730
 
dnl Usage: AC_ENABLE_SHARED[(DEFAULT)]
731
 
dnl   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
732
 
dnl   `yes'.
733
 
AC_DEFUN([AC_ENABLE_SHARED],
734
 
[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
735
 
AC_ARG_ENABLE(shared,
736
 
changequote(<<, >>)dnl
737
 
<<  --enable-shared[=PKGS]    build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
738
 
changequote([, ])dnl
739
 
[p=${PACKAGE-default}
740
 
case $enableval in
741
 
yes) enable_shared=yes ;;
742
 
no) enable_shared=no ;;
743
 
*)
744
 
  enable_shared=no
745
 
  # Look at the argument we got.  We use all the common list separators.
746
 
  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
747
 
  for pkg in $enableval; do
748
 
    if test "X$pkg" = "X$p"; then
749
 
      enable_shared=yes
750
 
    fi
751
 
 
752
 
  done
753
 
  IFS="$ac_save_ifs"
754
 
  ;;
755
 
esac],
756
 
enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
757
 
])
758
 
 
759
 
dnl AC_ENABLE_STATIC - implement the --enable-static flag
760
 
dnl Usage: AC_ENABLE_STATIC[(DEFAULT)]
761
 
dnl   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
762
 
dnl   `yes'.
763
 
AC_DEFUN([AC_ENABLE_STATIC],
764
 
[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
765
 
AC_ARG_ENABLE(static,
766
 
changequote(<<, >>)dnl
767
 
<<  --enable-static[=PKGS]    build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
768
 
changequote([, ])dnl
769
 
[p=${PACKAGE-default}
770
 
case $enableval in
771
 
yes) enable_static=yes ;;
772
 
no) enable_static=no ;;
773
 
*)
774
 
  enable_static=no
775
 
  # Look at the argument we got.  We use all the common list separators.
776
 
  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
777
 
  for pkg in $enableval; do
778
 
    if test "X$pkg" = "X$p"; then
779
 
      enable_static=yes
780
 
    fi
781
 
  done
782
 
  IFS="$ac_save_ifs"
783
 
  ;;
784
 
esac],
785
 
enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
786
 
])
787
 
 
788
 
dnl AC_DISABLE_STATIC - set the default static flag to --disable-static
789
 
AC_DEFUN([AC_DISABLE_STATIC],
790
 
[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
791
 
AC_ENABLE_STATIC(no)])
792
 
 
793
 
dnl AC_TRY_RUN_STRICT(PROGRAM,CFLAGS,CPPFLAGS,LDFLAGS,
794
 
dnl             [ACTION-IF-TRUE],[ACTION-IF-FALSE],
795
 
dnl             [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR])
796
 
AC_DEFUN( [AC_TRY_RUN_STRICT],
797
 
[
798
 
        old_CFLAGS="$CFLAGS";
799
 
        CFLAGS="$2";
800
 
        export CFLAGS;
801
 
        old_CPPFLAGS="$CPPFLAGS";
802
 
        CPPFLAGS="$3";
803
 
        export CPPFLAGS;
804
 
        old_LDFLAGS="$LDFLAGS";
805
 
        LDFLAGS="$4";
806
 
        export LDFLAGS;
807
 
        AC_TRY_RUN([$1],[$5],[$6],[$7])
808
 
        CFLAGS="$old_CFLAGS";
809
 
        old_CFLAGS="";
810
 
        export CFLAGS;
811
 
        CPPFLAGS="$old_CPPFLAGS";
812
 
        old_CPPFLAGS="";
813
 
        export CPPFLAGS;
814
 
        LDFLAGS="$old_LDFLAGS";
815
 
        old_LDFLAGS="";
816
 
        export LDFLAGS;
817
 
])
818
 
 
819
 
dnl SMB_CHECK_SYSCONF(varname)
820
 
dnl Tests whether the sysconf(3) variable "varname" is available.
821
 
AC_DEFUN([SMB_CHECK_SYSCONF],
822
 
[
823
 
    AC_CACHE_CHECK([for sysconf($1)],
824
 
        samba_cv_SYSCONF$1,
825
 
        [
826
 
            AC_TRY_LINK([#include <unistd.h>],
827
 
                [ return sysconf($1) == -1 ? 1 : 0; ],
828
 
                [ samba_cv_SYSCONF$1=yes ],
829
 
                [ samba_cv_SYSCONF$1=no ])
830
 
        ])
831
 
 
832
 
    if test x"$samba_cv_SYSCONF$1" = x"yes" ; then
833
 
        AC_DEFINE(SYSCONF$1, 1, [Whether sysconf($1) is available])
834
 
    fi
835
 
])
836
 
 
837
 
dnl SMB_IS_LIBPTHREAD_LINKED([actions if true], [actions if false])
838
 
dnl Test whether the current LIBS results in libpthread being present.
839
 
dnl Execute the corresponding user action list.
840
 
AC_DEFUN([SMB_IS_LIBPTHREAD_LINKED],
841
 
[
842
 
    AC_MSG_CHECKING(if libpthread is linked)
843
 
    AC_TRY_LINK([],
844
 
        [return pthread_create(0, 0, 0, 0);],
845
 
        [
846
 
            AC_MSG_RESULT(yes)
847
 
            $1
848
 
        ],
849
 
        [
850
 
            AC_MSG_RESULT(no)
851
 
            $2
852
 
        ])
853
 
])
854
 
 
855
 
dnl SMB_REMOVE_LIB(lib)
856
 
dnl Remove the given library from $LIBS
857
 
AC_DEFUN([SMB_REMOVELIB],
858
 
[
859
 
    LIBS=`echo $LIBS | sed -es/-l$1//g`
860
 
])
861
 
 
862
 
dnl SMB_CHECK_DMAPI([actions if true], [actions if false])
863
 
dnl Check whether DMAPI is available and is a version that we know
864
 
dnl how to deal with. The default truth action is to set samba_dmapi_libs
865
 
dnl to the list of necessary libraries, and to define USE_DMAPI.
866
 
AC_DEFUN([SMB_CHECK_DMAPI],
867
 
[
868
 
    samba_dmapi_libs=""
869
 
 
870
 
    if test x"$samba_dmapi_libs" = x"" ; then
871
 
        AC_CHECK_LIB(dm, dm_get_eventlist,
872
 
                [ samba_dmapi_libs="-ldm"], [])
873
 
    fi
874
 
 
875
 
    if test x"$samba_dmapi_libs" = x"" ; then
876
 
        AC_CHECK_LIB(jfsdm, dm_get_eventlist,
877
 
                [samba_dmapi_libs="-ljfsdm"], [])
878
 
    fi
879
 
 
880
 
    if test x"$samba_dmapi_libs" = x"" ; then
881
 
        AC_CHECK_LIB(xdsm, dm_get_eventlist,
882
 
                [samba_dmapi_libs="-lxdsm"], [])
883
 
    fi
884
 
 
885
 
    # Only bother to test ehaders if we have a candidate DMAPI library
886
 
    if test x"$samba_dmapi_libs" != x"" ; then
887
 
        AC_CHECK_HEADERS(sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h)
888
 
    fi
889
 
 
890
 
    if test x"$samba_dmapi_libs" != x"" ; then
891
 
        samba_dmapi_save_LIBS="$LIBS"
892
 
        LIBS="$LIBS $samba_dmapi_libs"
893
 
        AC_TRY_LINK(
894
 
                [
895
 
#include <time.h>      /* needed by Tru64 */
896
 
#include <sys/types.h> /* needed by AIX */
897
 
#ifdef HAVE_XFS_DMAPI_H
898
 
#include <xfs/dmapi.h>
899
 
#elif defined(HAVE_SYS_DMI_H)
900
 
#include <sys/dmi.h>
901
 
#elif defined(HAVE_SYS_JFSDMAPI_H)
902
 
#include <sys/jfsdmapi.h>
903
 
#elif defined(HAVE_SYS_DMAPI_H)
904
 
#include <sys/dmapi.h>
905
 
#endif
906
 
                ],
907
 
                [
908
 
/* This link test is designed to fail on IRI 6.4, but should
909
 
 * succeed on Linux, IRIX 6.5 and AIX.
910
 
 */
911
 
        char * version;
912
 
        dm_eventset_t events;
913
 
        /* This doesn't take an argument on IRIX 6.4. */
914
 
        dm_init_service(&version);
915
 
        /* IRIX 6.4 expects events to be a pointer. */
916
 
        DMEV_ISSET(DM_EVENT_READ, events);
917
 
                ],
918
 
                [
919
 
                    true # DMAPI link test succeeded
920
 
                ],
921
 
                [
922
 
                    # DMAPI link failure
923
 
                    samba_dmapi_libs=
924
 
                ])
925
 
        LIBS="$samba_dmapi_save_LIBS"
926
 
    fi
927
 
 
928
 
    if test x"$samba_dmapi_libs" = x"" ; then
929
 
        # DMAPI detection failure actions begin
930
 
        ifelse($2, [],
931
 
            [
932
 
                AC_ERROR(Failed to detect a supported DMAPI implementation)
933
 
            ],
934
 
            [
935
 
                $2
936
 
            ])
937
 
        # DMAPI detection failure actions end
938
 
    else
939
 
        # DMAPI detection success actions start
940
 
        ifelse($1, [],
941
 
            [
942
 
                AC_DEFINE(USE_DMAPI, 1,
943
 
                    [Whether we should build DMAPI integration components])
944
 
                AC_MSG_NOTICE(Found DMAPI support in $samba_dmapi_libs)
945
 
            ],
946
 
            [
947
 
                $1
948
 
            ])
949
 
        # DMAPI detection success actions end
950
 
    fi
951
 
 
952
 
])
953
 
 
954
 
dnl SMB_CHECK_CLOCK_ID(clockid)
955
 
dnl Test whether the specified clock_gettime clock ID is available. If it
956
 
dnl is, we define HAVE_clockid
957
 
AC_DEFUN([SMB_CHECK_CLOCK_ID],
958
 
[
959
 
    AC_MSG_CHECKING(for $1)
960
 
    AC_TRY_LINK([
961
 
#if TIME_WITH_SYS_TIME
962
 
# include <sys/time.h>
963
 
# include <time.h>
964
 
#else
965
 
# if HAVE_SYS_TIME_H
966
 
#  include <sys/time.h>
967
 
# else
968
 
#  include <time.h>
969
 
# endif
970
 
#endif
971
 
    ],
972
 
    [
973
 
clockid_t clk = $1;
974
 
    ],
975
 
    [
976
 
        AC_MSG_RESULT(yes)
977
 
        AC_DEFINE(HAVE_$1, 1,
978
 
            [Whether the clock_gettime clock ID $1 is available])
979
 
    ],
980
 
    [
981
 
        AC_MSG_RESULT(no)
982
 
    ])
983
 
])
984
 
 
985
 
dnl SMB_IF_RTSIGNAL_BUG([actions if true],
986
 
dnl                     [actions if false],
987
 
dnl                     [actions if cross compiling])
988
 
dnl Test whether we can call sigaction with RT_SIGNAL_NOTIFY and
989
 
dnl RT_SIGNAL_LEASE (also RT_SIGNAL_AIO for good measure, though
990
 
dnl I don't believe that triggers any bug.
991
 
dnl
992
 
dnl See the samba-technical thread titled "Failed to setup
993
 
dnl RT_SIGNAL_NOTIFY handler" for details on the bug in question.
994
 
AC_DEFUN([SMB_IF_RTSIGNAL_BUG],
995
 
[
996
 
    rt_signal_notify_works=yes
997
 
    rt_signal_lease_works=yes
998
 
    rt_signal_aio_works=yes
999
 
 
1000
 
    AC_MSG_CHECKING(if sigaction works with realtime signals)
1001
 
    AC_TRY_RUN(
1002
 
        [
1003
 
#include <sys/types.h>
1004
 
#include <fcntl.h>
1005
 
#include <signal.h>
1006
 
 
1007
 
/* from smbd/notify_kernel.c */
1008
 
#ifndef RT_SIGNAL_NOTIFY
1009
 
#define RT_SIGNAL_NOTIFY (SIGRTMIN+2)
1010
 
#endif
1011
 
 
1012
 
/* from smbd/aio.c */
1013
 
#ifndef RT_SIGNAL_AIO
1014
 
#define RT_SIGNAL_AIO (SIGRTMIN+3)
1015
 
#endif
1016
 
 
1017
 
/* from smbd/oplock_linux.c */
1018
 
#ifndef RT_SIGNAL_LEASE
1019
 
#define RT_SIGNAL_LEASE (SIGRTMIN+1)
1020
 
#endif
1021
 
 
1022
 
static void signal_handler(int sig, siginfo_t *info, void *unused)
1023
 
{
1024
 
    int do_nothing = 0;
1025
 
}
1026
 
 
1027
 
int main(void)
1028
 
{
1029
 
    int result = 0;
1030
 
    struct sigaction act = {0};
1031
 
 
1032
 
    act.sa_sigaction = signal_handler;
1033
 
    act.sa_flags = SA_SIGINFO;
1034
 
    sigemptyset( &act.sa_mask );
1035
 
 
1036
 
    if (sigaction(RT_SIGNAL_LEASE, &act, 0) != 0) {
1037
 
            /* Failed to setup RT_SIGNAL_LEASE handler */
1038
 
            result += 1;
1039
 
    }
1040
 
 
1041
 
    if (sigaction(RT_SIGNAL_NOTIFY, &act, 0) != 0) {
1042
 
            /* Failed to setup RT_SIGNAL_NOTIFY handler */
1043
 
            result += 10;
1044
 
    }
1045
 
 
1046
 
    if (sigaction(RT_SIGNAL_AIO, &act, 0) != 0) {
1047
 
            /* Failed to setup RT_SIGNAL_AIO handler */
1048
 
            result += 100;
1049
 
    }
1050
 
 
1051
 
    /* zero on success */
1052
 
    return result;
1053
 
}
1054
 
        ],
1055
 
        [
1056
 
            AC_MSG_RESULT(yes)
1057
 
            $2
1058
 
        ],
1059
 
        [
1060
 
            AC_MSG_RESULT(no)
1061
 
            case "$ac_status" in
1062
 
                1|11|101|111)  rt_signal_lease_ok=no ;;
1063
 
            esac
1064
 
            case "$ac_status" in
1065
 
                10|11|110|111)  rt_signal_notify_ok=no ;;
1066
 
            esac
1067
 
            case "$ac_status" in
1068
 
                100|110|101|111)  rt_signal_aio_ok=no ;;
1069
 
            esac
1070
 
            $2
1071
 
        ],
1072
 
        [
1073
 
            AC_MSG_RESULT(cross)
1074
 
            $3
1075
 
        ])
1076
 
])
1077