r3417: BUG 350: patch from Matt Selsky <selsky@columbia.edu> to use autoconf feature...
[ira/wip.git] / source3 / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl We must use autotools 2.53 or above
4 AC_PREREQ(2.53)
5 AC_INIT(include/includes.h)
6 AC_CONFIG_HEADER(include/config.h)
7
8 AC_DISABLE_STATIC
9 AC_ENABLE_SHARED
10
11 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
12 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
13
14 SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
15 if test -n "${SAMBA_VERSION_SVN_REVISION}";then
16         echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
17 fi
18
19 #################################################
20 # Directory handling stuff to support both the
21 # legacy SAMBA directories and FHS compliant
22 # ones...
23 AC_PREFIX_DEFAULT(/usr/local/samba)
24
25 lockdir="\${VARDIR}/locks"
26 piddir="\${VARDIR}/locks"
27 mandir="\${prefix}/man"
28 logfilebase="\${VARDIR}"
29 privatedir="\${prefix}/private"
30 libdir="\${prefix}/lib"
31 configdir="\${LIBDIR}"
32 swatdir="\${prefix}/swat"
33
34 AC_ARG_WITH(fhs, 
35 [  --with-fhs              Use FHS-compliant paths (default=no)],
36 [ case "$withval" in
37   yes)
38     lockdir="\${VARDIR}/lib/samba"
39     piddir="\${VARDIR}/run"
40     mandir="\${prefix}/share/man"
41     logfilebase="\${VARDIR}/log/samba"
42     privatedir="\${CONFIGDIR}/private"
43     libdir="\${prefix}/lib/samba"
44     configdir="${sysconfdir}/samba"
45     swatdir="\${DATADIR}/samba/swat"
46     ;;
47   esac])
48
49 #################################################
50 # set private directory location
51 AC_ARG_WITH(privatedir,
52 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
53 [ case "$withval" in
54   yes|no)
55   #
56   # Just in case anybody calls it without argument
57   #
58     AC_MSG_WARN([--with-privatedir called without argument - will use default])
59   ;;
60   * )
61     privatedir="$withval"
62     ;;
63   esac])
64
65 #################################################
66 # set lock directory location
67 AC_ARG_WITH(lockdir,
68 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
69 [ case "$withval" in
70   yes|no)
71   #
72   # Just in case anybody calls it without argument
73   #
74     AC_MSG_WARN([--with-lockdir called without argument - will use default])
75   ;;
76   * )
77     lockdir="$withval"
78     ;;
79   esac])
80
81 #################################################
82 # set pid directory location
83 AC_ARG_WITH(piddir,
84 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
85 [ case "$withval" in
86   yes|no)
87   #
88   # Just in case anybody calls it without argument
89   #
90     AC_MSG_WARN([--with-piddir called without argument - will use default])
91   ;;
92   * )
93     piddir="$withval"
94     ;;
95   esac])
96
97 #################################################
98 # set SWAT directory location
99 AC_ARG_WITH(swatdir,
100 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
101 [ case "$withval" in
102   yes|no)
103   #
104   # Just in case anybody does it
105   #
106     AC_MSG_WARN([--with-swatdir called without argument - will use default])
107   ;;
108   * )
109     swatdir="$withval"
110     ;;
111   esac])
112
113 #################################################
114 # set configuration directory location
115 AC_ARG_WITH(configdir,
116 [  --with-configdir=DIR    Where to put configuration files ($libdir)],
117 [ case "$withval" in
118   yes|no)
119   #
120   # Just in case anybody does it
121   #
122     AC_MSG_WARN([--with-configdir called without argument - will use default])
123   ;;
124   * )
125     configdir="$withval"
126     ;;
127   esac])
128
129 #################################################
130 # set log directory location
131 AC_ARG_WITH(logfilebase,
132 [  --with-logfilebase=DIR  Where to put log files ($VARDIR)],
133 [ case "$withval" in
134   yes|no)
135   #
136   # Just in case anybody does it
137   #
138     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
139   ;;
140   * )
141     logfilebase="$withval"
142     ;;
143   esac])
144
145 #################################################
146 # set lib directory location
147 AC_ARG_WITH(libdir,
148 [  --with-libdir=DIR       Where to put libdir ($libdir)],
149 [ case "$withval" in
150   yes|no)
151   #
152   # Just in case anybody does it
153   #
154     AC_MSG_WARN([--with-libdir without argument - will use default])
155   ;;
156   * )
157     libdir="$withval"
158     ;;
159   esac])
160
161 #################################################
162 # set lib directory location
163 AC_ARG_WITH(mandir,
164 [  --with-mandir=DIR       Where to put man pages ($mandir)],
165 [ case "$withval" in
166   yes|no)
167   #
168   # Just in case anybody does it
169   #
170     AC_MSG_WARN([--with-mandir without argument - will use default])
171   ;;
172   * )
173     mandir="$withval"
174     ;;
175   esac])
176
177 AC_ARG_WITH(cfenc,
178 [  --with-cfenc=HEADERDIR  Use internal CoreFoundation encoding API
179                           for optimization (Mac OS X/Darwin only)],
180 [
181 # May be in source $withval/CoreFoundation/StringEncodings.subproj.
182 # Should have been in framework $withval/CoreFoundation.framework/Headers.
183 for d in \
184     $withval/CoreFoundation/StringEncodings.subproj \
185     $withval/StringEncodings.subproj \
186     $withval/CoreFoundation.framework/Headers \
187     $withval/Headers \
188     $withval
189 do
190     if test -r $d/CFStringEncodingConverter.h; then
191         ln -sfh $d include/CoreFoundation
192     fi
193 done
194 ])
195
196 AC_SUBST(configdir)
197 AC_SUBST(lockdir)
198 AC_SUBST(piddir)
199 AC_SUBST(logfilebase)
200 AC_SUBST(privatedir)
201 AC_SUBST(swatdir)
202 AC_SUBST(bindir)
203 AC_SUBST(sbindir)
204
205 dnl Unique-to-Samba variables we'll be playing with.
206 AC_SUBST(SHELL)
207 AC_SUBST(LDSHFLAGS)
208 AC_SUBST(SONAMEFLAG)
209 AC_SUBST(SHLD)
210 AC_SUBST(HOST_OS)
211 AC_SUBST(PICFLAGS)
212 AC_SUBST(PICSUFFIX)
213 AC_SUBST(SHLIBEXT)
214 AC_SUBST(INSTALLCLIENT)
215 AC_SUBST(INSTALLCLIENTCMD_SH)
216 AC_SUBST(INSTALLCLIENTCMD_A)
217 AC_SUBST(LIBSMBCLIENT_SHARED)
218 AC_SUBST(LIBSMBCLIENT)
219 AC_SUBST(PRINT_LIBS)
220 AC_SUBST(AUTH_LIBS)
221 AC_SUBST(ACL_LIBS)
222 AC_SUBST(PASSDB_LIBS)
223 AC_SUBST(IDMAP_LIBS)
224 AC_SUBST(KRB5_LIBS)
225 AC_SUBST(LDAP_LIBS)
226 AC_SUBST(SHLIB_PROGS)
227 AC_SUBST(SMBWRAPPER)
228 AC_SUBST(EXTRA_BIN_PROGS)
229 AC_SUBST(EXTRA_SBIN_PROGS)
230 AC_SUBST(EXTRA_ALL_TARGETS)
231
232 AC_ARG_ENABLE(debug, 
233 [  --enable-debug          Turn on compiler debugging information (default=no)],
234     [if eval "test x$enable_debug = xyes"; then
235         CFLAGS="${CFLAGS} -g"
236     fi])
237
238 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
239     [if eval "test x$enable_developer = xyes"; then
240         developer=yes
241         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
242     fi])
243
244 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
245     [if eval "test x$enable_krb5developer = xyes"; then
246         developer=yes
247         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
248     fi])
249
250 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
251
252 if test "x$enable_dmalloc" = xyes
253 then
254         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
255         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
256                   [Define to check invariants around some common functions])
257         LIBS="$LIBS -ldmalloc"  
258 fi
259
260 dnl Checks for programs.
261
262 ##
263 ## for some reason this macro resets the CFLAGS
264 ## so save and restore
265 ##
266 OLD_CFLAGS=${CFLAGS}
267 AC_PROG_CC
268 CFLAGS=${OLD_CFLAGS}
269
270 OLD_CFLAGS=${CFLAGS}
271 AC_PROG_CPP
272 CFLAGS=${OLD_CFLAGS}
273
274 AC_PROG_INSTALL
275 AC_PROG_AWK
276 AC_PATH_PROG(PERL, perl)
277
278 AC_CHECK_TOOL(AR, ar)
279
280 # compile with optimization and without debugging by default, but
281 # allow people to set their own preference.
282 if test "x$CFLAGS" = x
283 then
284   CFLAGS="-O ${CFLAGS}"
285 fi
286
287 dnl Check if we use GNU ld
288 LD=ld
289 AC_PROG_LD_GNU
290
291 dnl Certain versions of GNU ld the default is not to have the 
292 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
293 dnl warnings when building modules.
294 if test "$ac_cv_prog_gnu_ld" = "yes"; then
295         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
296         AC_MSG_CHECKING(GNU ld release date)
297         changequote(,)dnl
298         ac_cv_gnu_ld_date=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
299         changequote([,])dnl
300         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
301         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
302                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
303         fi
304 fi
305
306 dnl needed before AC_TRY_COMPILE
307 AC_ISC_POSIX
308
309 dnl look for executable suffix
310 AC_EXEEXT
311
312 dnl Check if C compiler understands -c and -o at the same time
313 AC_PROG_CC_C_O
314 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
315       BROKEN_CC=
316 else
317       BROKEN_CC=#
318 fi
319 AC_SUBST(BROKEN_CC)
320
321 dnl Check if the C compiler understands -Werror
322 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
323  AC_TRY_RUN_STRICT([
324   int main(void)
325   {
326         return 0;
327   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
328   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
329 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
330    Werror_FLAGS="-Werror"
331 else 
332 dnl Check if the C compiler understands -w2
333 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
334  AC_TRY_RUN_STRICT([
335   int main(void)
336   {
337         return 0;
338   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
339   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
340 if test x"$samba_cv_HAVE_w2" = x"yes"; then
341    Werror_FLAGS="-w2"
342 fi
343 fi
344
345 dnl Check if the C compiler understands volatile (it should, being ANSI).
346 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
347     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
348         samba_cv_volatile=yes,samba_cv_volatile=no)])
349 if test x"$samba_cv_volatile" = x"yes"; then
350    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
351 fi
352
353 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
354 AC_MSG_CHECKING(uname -s)
355 AC_MSG_RESULT(${UNAME_S})
356
357 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
358 AC_MSG_CHECKING(uname -r)
359 AC_MSG_RESULT(${UNAME_R})
360
361 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
362 AC_MSG_CHECKING(uname -m)
363 AC_MSG_RESULT(${UNAME_M})
364
365 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
366 AC_MSG_CHECKING(uname -p)
367 AC_MSG_RESULT(${UNAME_P})
368
369 AC_CANONICAL_SYSTEM
370
371 dnl Add #include for broken IRIX header files
372   case "$host_os" in
373         *irix6*) AC_ADD_INCLUDE(<standards.h>)
374         ;;
375 esac
376
377 AC_VALIDATE_CACHE_SYSTEM_TYPE
378
379 DYNEXP=
380
381 dnl Add modules that have to be built by default here
382 dnl These have to be built static:
383 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
384
385 dnl These are preferably build shared, and static if dlopen() is not available
386 default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437"
387
388 if test "x$developer" = xyes; then
389    default_static_modules="$default_static_modules rpc_echo"
390    default_shared_modules="$default_shared_modules charset_weird"
391 fi
392
393 #
394 # Config CPPFLAG settings for strange OS's that must be set
395 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
396 # case statement; its first reference must be unconditional.
397 #
398 case "$host_os" in
399 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
400     *hpux*)
401     
402       AC_PROG_CC_FLAG(Ae)
403       # mmap on HPUX is completely broken...
404       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
405       if test $ac_cv_prog_cc_Ae = yes; then
406         CPPFLAGS="$CPPFLAGS -Ae"
407       fi
408 #
409 # Defines needed for HPUX support.
410 # HPUX has bigcrypt but (sometimes?) doesn't use it for
411 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
412 #
413       case `uname -r` in
414                         *9*|*10*)
415                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
416                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
417                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
418                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
419                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
420                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
421                                 ;;
422                         *11*)
423                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
424                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
425                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
426                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
427                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
428                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
429                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
430                                 ;;
431       esac
432       ;;
433
434 #
435 # CRAY Unicos has broken const handling
436        *unicos*)
437           AC_MSG_RESULT([disabling const])
438           CPPFLAGS="$CPPFLAGS -Dconst="
439           ;;
440         
441 #
442 # AIX4.x doesn't even admit to having large
443 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
444 #
445     *aix4*)
446           AC_MSG_RESULT([enabling large file support])
447       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
448           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
449       ;;    
450 #
451 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
452 # to the existance of large files..
453 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
454 # recommendations on large file support, however it makes the
455 # compile work using gcc 2.7 and 2.8, whereas using the Sun
456 # recommendation makes the compile fail on gcc2.7. JRA.
457 #
458 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
459 #
460         *solaris*)
461                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
462                 case `uname -r` in
463                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
464                                 AC_MSG_RESULT([no large file support])
465                                 ;;
466                         5.*)
467                         AC_MSG_RESULT([enabling large file support])
468                         if test "$ac_cv_prog_gcc" = yes; then
469                                 ${CC-cc} -v >conftest.c 2>&1
470                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
471                                 rm -fr conftest.c
472                                 case "$ac_cv_gcc_compiler_version_number" in
473                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
474                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
475                                                 LDFLAGS="$LDFLAGS -lthread"
476                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
477                                                 ;;
478                                         *)
479                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
480                                                 LDFLAGS="$LDFLAGS -lthread"
481                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
482                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
483                                                 ;;
484                                 esac
485                         else
486                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
487                                 LDFLAGS="$LDFLAGS -lthread"
488                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
489                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
490                         fi
491                         ;;
492                 esac
493                 ;;
494 #
495 # IRIX uses SYSV printing.  Make sure to set that here
496 #
497         *irix*)
498                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
499                 ;;
500         *freebsd*|*DragonFly*)
501                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
502                 ;;
503 #
504 # VOS may need to have POSIX support and System V compatibility enabled.
505 #
506     *vos*)
507     case "$CPPFLAGS" in
508           *-D_POSIX_C_SOURCE*)
509                 ;;
510           *)
511                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
512                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
513                 ;;
514     esac
515     case "$CPPFLAGS" in
516           *-D_SYSV*|*-D_SVID_SOURCE*)
517                 ;;
518           *)
519                 CPPFLAGS="$CPPFLAGS -D_SYSV"
520                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
521     esac
522     ;;
523 #
524 # Tests needed for SINIX large file support.
525 #
526     *sysv4*)
527       if test $host = mips-sni-sysv4 ; then
528         AC_MSG_CHECKING([for LFS support])
529         old_CPPFLAGS="$CPPFLAGS"
530         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
531         AC_TRY_RUN([
532 #include <unistd.h>
533 main () {
534 #if _LFS64_LARGEFILE == 1
535 exit(0);
536 #else
537 exit(1);
538 #endif
539 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
540         CPPFLAGS="$old_CPPFLAGS"
541         if test x$SINIX_LFS_SUPPORT = xyes ; then
542           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
543                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
544           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
545           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
546           LIBS="`getconf LFS64_LIBS` $LIBS"
547         fi
548       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
549       fi
550     ;;
551
552 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
553 #
554     *linux*)
555         AC_MSG_CHECKING([for LFS support])
556         old_CPPFLAGS="$CPPFLAGS"
557         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
558        AC_TRY_RUN([
559 #include <unistd.h>
560 #include <sys/utsname.h>
561 #include <string.h>
562 #include <stdlib.h>
563 main() {
564 #if _LFS64_LARGEFILE == 1
565        struct utsname uts;
566        char *release;
567        int major, minor;
568
569        /* Ensure this is glibc 2.2 or higher */
570 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
571        int libc_major = __GLIBC__;
572        int libc_minor = __GLIBC_MINOR__;
573
574        if (libc_major < 2)
575               exit(1);
576        if (libc_minor < 2)
577               exit(1);
578 #endif
579
580        /* Ensure this is kernel 2.4 or higher */
581
582        uname(&uts);
583        release = strdup(uts.release);
584        major = atoi(strsep(&release, "."));
585        minor = atoi(strsep(&release, "."));
586
587        if (major > 2 || (major == 2 && minor > 3))
588                exit(0);
589        exit(1);
590 #else
591        exit(1);
592 #endif
593 }
594 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
595         CPPFLAGS="$old_CPPFLAGS"
596         if test x$LINUX_LFS_SUPPORT = xyes ; then
597                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
598                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
599                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
600                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
601         fi
602         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
603         ;;
604
605 #
606 # MacOS X is the *only* system that uses compose character in utf8. This
607 # is so horribly broken....
608 #
609     *darwin*)
610         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
611 # Add Fink directories for various packages, like dlcompat.
612 # Note: iconv does that explicitly below, but other packages
613 # don't.
614         CPPFLAGS="$CPPFLAGS -I/sw/include"
615         LDFLAGS="$LDFLAGS -L/sw/lib"
616
617 # If we have dlsym_prepend_underscore (from Fink's dlcompat),
618 # use that instead of plain dlsym.
619
620         AC_CHECK_LIB(dl,dlopen)
621         AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
622
623 # Add a system specific charset module.
624
625         default_shared_modules="$default_shared_modules charset_macosxfs"
626         ;;
627     *hurd*)
628         AC_MSG_CHECKING([for LFS support])
629         old_CPPFLAGS="$CPPFLAGS"
630         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
631         AC_TRY_RUN([
632 #include <unistd.h>
633 main () {
634 #if _LFS64_LARGEFILE == 1
635 exit(0);
636 #else
637 exit(1);
638 #endif
639 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
640         CPPFLAGS="$old_CPPFLAGS"
641         if test x$GLIBC_LFS_SUPPORT = xyes ; then
642           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
643                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
644           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
645         fi
646       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
647     ;;
648
649 esac
650
651 AC_INLINE
652 AC_HEADER_STDC
653 AC_HEADER_DIRENT
654 AC_HEADER_TIME
655 AC_HEADER_SYS_WAIT
656 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
657 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h)
658 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
659 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
660 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
661 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
662 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
663 AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
664 AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
665 AC_CHECK_HEADERS(langinfo.h locale.h)
666
667 # Look for Darwin headers
668 old_CPPFLAGS="$CPPFLAGS"
669 CPPFLAGS="-Iinclude $CPPFLAGS"
670 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
671 CPPFLAGS="$old_CPPFLAGS"
672
673 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
674 # subdirectory of headers.
675 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
676
677 #
678 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
679 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
680 #
681 case "$host_os" in
682     *hpux*)
683                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
684                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
685                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
686                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
687                 fi
688         ;;
689 esac
690 AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
691 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
692 AC_CHECK_HEADERS(stropts.h poll.h)
693 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
694 AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/cdefs.h glob.h)
695 # These faile to compile on Solaris so just check for their presence
696 AC_CHECK_HEADERS(security/pam_modules.h net/if.h netinet/ip.h, [], [], -)
697
698 # For experimental utmp support (lastlog on some BSD-like systems)
699 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
700  
701 AC_CHECK_SIZEOF(int,cross)
702 AC_CHECK_SIZEOF(long,cross)
703 AC_CHECK_SIZEOF(short,cross)
704
705 AC_C_CONST
706 AC_C_INLINE
707 AC_C_BIGENDIAN
708 AC_C_CHAR_UNSIGNED
709
710 AC_TYPE_SIGNAL
711 AC_TYPE_UID_T
712 AC_TYPE_MODE_T
713 AC_TYPE_OFF_T
714 AC_TYPE_SIZE_T
715 AC_TYPE_PID_T
716 AC_STRUCT_ST_RDEV
717 AC_DIRENT_D_OFF
718 AC_CHECK_TYPE(ino_t,unsigned)
719 AC_CHECK_TYPE(loff_t,off_t)
720 AC_CHECK_TYPE(offset_t,loff_t)
721 AC_CHECK_TYPE(ssize_t, int)
722 AC_CHECK_TYPE(wchar_t, unsigned short)
723
724 ############################################
725 # for cups support we need libcups, and a handful of header files
726
727 AC_ARG_ENABLE(cups,
728 [  --enable-cups           Turn on CUPS support (default=auto)])
729
730 if test x$enable_cups != xno; then
731         AC_PATH_PROG(CUPS_CONFIG, cups-config)
732
733         if test "x$CUPS_CONFIG" != x; then
734                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
735                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
736                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
737                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
738         elif test x"$enable_cups" = x"yes"; then
739                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
740         fi
741 fi
742
743 ############################################
744 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
745 AC_SEARCH_LIBS(dlopen, [dl])
746 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
747
748 ############################################
749 # check if the compiler can do immediate structures
750 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
751     AC_TRY_COMPILE([
752 #include <stdio.h>],
753 [
754    typedef struct {unsigned x;} FOOBAR;
755    #define X_FOOBAR(x) ((FOOBAR) { x })
756    #define FOO_ONE X_FOOBAR(1)
757    FOOBAR f = FOO_ONE;   
758    static struct {
759         FOOBAR y; 
760         } f2[] = {
761                 {FOO_ONE}
762         };   
763 ],
764         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
765 if test x"$samba_cv_immediate_structures" = x"yes"; then
766    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
767 fi
768
769 ############################################
770 # check if the compiler can do immediate structures
771 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
772     AC_TRY_LINK([
773 #include <stdio.h>],
774 [
775                 if (0) {
776                    this_function_does_not_exist();
777                 } else {
778                   return 1;
779                 }
780
781 ],
782         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
783 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
784    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
785 fi
786
787 ############################################
788 # check for unix domain sockets
789 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
790     AC_TRY_COMPILE([
791 #include <sys/types.h>
792 #include <stdlib.h>
793 #include <stddef.h>
794 #include <sys/socket.h>
795 #include <sys/un.h>],
796 [
797   struct sockaddr_un sunaddr; 
798   sunaddr.sun_family = AF_UNIX;
799 ],
800         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
801 if test x"$samba_cv_unixsocket" = x"yes"; then
802    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
803 fi
804
805
806 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
807     AC_TRY_COMPILE([
808 #include <sys/types.h>
809 #if STDC_HEADERS
810 #include <stdlib.h>
811 #include <stddef.h>
812 #endif
813 #include <sys/socket.h>],[socklen_t i = 0],
814         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
815 if test x"$samba_cv_socklen_t" = x"yes"; then
816    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
817 fi
818
819 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
820     AC_TRY_COMPILE([
821 #include <sys/types.h>
822 #if STDC_HEADERS
823 #include <stdlib.h>
824 #include <stddef.h>
825 #endif
826 #include <signal.h>],[sig_atomic_t i = 0],
827         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
828 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
829    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
830 fi
831
832 # stupid headers have the functions but no declaration. grrrr.
833 AC_HAVE_DECL(errno, [#include <errno.h>])
834 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
835 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
836 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
837 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
838 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
839 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
840
841 # and glibc has setresuid under linux but the function does
842 # nothing until kernel 2.1.44! very dumb.
843 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
844     AC_TRY_RUN([#include <errno.h>
845 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
846         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
847 if test x"$samba_cv_have_setresuid" = x"yes"; then
848     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
849 fi
850
851 # Do the same check for setresguid...
852 #
853 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
854     AC_TRY_RUN([#include <unistd.h>
855 #include <errno.h>
856 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
857         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
858 if test x"$samba_cv_have_setresgid" = x"yes"; then
859     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
860 fi
861
862 AC_FUNC_MEMCMP
863
864 ###############################################
865 # Readline included by default unless explicitly asked not to
866 test "${with_readline+set}" != "set" && with_readline=yes
867
868 # test for where we get readline() from
869 AC_MSG_CHECKING(whether to use readline)
870 AC_ARG_WITH(readline,
871 [  --with-readline[=DIR]     Look for readline include/libs in DIR (default=auto) ],
872 [  case "$with_readline" in
873   yes)
874     AC_MSG_RESULT(yes)
875
876     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
877     AC_CHECK_HEADERS(readline/history.h)
878
879     AC_CHECK_HEADERS(readline.h readline/readline.h,[
880       for termlib in ncurses curses termcap terminfo termlib tinfo; do
881        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
882       done
883       AC_CHECK_LIB(readline, rl_callback_handler_install,
884        [TERMLIBS="-lreadline $TERMLIBS"
885        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
886        break], [TERMLIBS=], $TERMLIBS)])
887     ;;
888   no)
889     AC_MSG_RESULT(no)
890     ;;
891   *)
892     AC_MSG_RESULT(yes)
893
894     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
895     # alternate readline path
896     _ldflags=${LDFLAGS}
897     _cppflags=${CPPFLAGS}
898
899     # Add additional search path
900     LDFLAGS="-L$with_readline/lib $LDFLAGS"
901     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
902
903     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
904     AC_CHECK_HEADERS(readline/history.h)
905
906     AC_CHECK_HEADERS(readline.h readline/readline.h,[
907       for termlib in ncurses curses termcap terminfo termlib; do
908        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
909       done
910       AC_CHECK_LIB(readline, rl_callback_handler_install,
911        [TERMLDFLAGS="-L$with_readline/lib"
912        TERMCPPFLAGS="-I$with_readline/include"
913        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
914        TERMLIBS="-lreadline $TERMLIBS"
915        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
916        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
917
918     LDFLAGS=$_ldflags
919     ;;
920   esac],
921   AC_MSG_RESULT(no)
922 )
923 AC_SUBST(TERMLIBS)
924 AC_SUBST(TERMLDFLAGS)
925
926 # The readline API changed slightly from readline3 to readline4, so
927 # code will generate warnings on one of them unless we have a few
928 # special cases.
929 AC_CHECK_LIB(readline, rl_completion_matches,
930              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
931                         [Do we have rl_completion_matches?])],
932              [],
933              [$TERMLIBS])
934
935 # The following test taken from the cvs sources
936 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
937 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
938 # libsocket.so which has a bad implementation of gethostbyname (it
939 # only looks in /etc/hosts), so we only look for -lsocket if we need
940 # it.
941 AC_CHECK_FUNCS(connect)
942 if test x"$ac_cv_func_connect" = x"no"; then
943     case "$LIBS" in
944     *-lnsl*) ;;
945     *) AC_CHECK_LIB(nsl_s, printf) ;;
946     esac
947     case "$LIBS" in
948     *-lnsl*) ;;
949     *) AC_CHECK_LIB(nsl, printf) ;;
950     esac
951     case "$LIBS" in
952     *-lsocket*) ;;
953     *) AC_CHECK_LIB(socket, connect) ;;
954     esac
955     case "$LIBS" in
956     *-linet*) ;;
957     *) AC_CHECK_LIB(inet, connect) ;;
958     esac
959     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
960     dnl has been cached.
961     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
962        test x"$ac_cv_lib_inet_connect" = x"yes"; then
963         # ac_cv_func_connect=yes
964         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
965         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
966     fi
967 fi
968
969 ###############################################
970 # test for where we get yp_get_default_domain() from
971 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
972 AC_CHECK_FUNCS(yp_get_default_domain)
973
974 # Check if we have execl, if not we need to compile smbrun.
975 AC_CHECK_FUNCS(execl)
976 if test x"$ac_cv_func_execl" = x"no"; then
977     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
978 fi
979
980 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
981 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
982 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
983 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
984 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
985 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
986 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
987 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
988 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
989 AC_CHECK_FUNCS(syslog vsyslog timegm)
990 AC_CHECK_FUNCS(setlocale nl_langinfo)
991 # setbuffer, shmget, shm_open are needed for smbtorture
992 AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
993 AC_CHECK_HEADERS(libexc.h)
994 AC_CHECK_LIB(exc, trace_back_stack)
995
996 # syscall() is needed for smbwrapper.
997 AC_CHECK_FUNCS(syscall)
998
999 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1000 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1001 AC_CHECK_FUNCS(__getcwd _getcwd)
1002 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1003 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1004 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1005 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1006 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
1007 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1008 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1009 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1010 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1011 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1012 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1013
1014 #
1015
1016 #
1017 case "$host_os" in
1018     *linux*)
1019        # glibc <= 2.3.2 has a broken getgrouplist
1020        AC_TRY_RUN([
1021 #include <unistd.h>
1022 #include <sys/utsname.h>
1023 main() {
1024        /* glibc up to 2.3 has a broken getgrouplist */
1025 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1026        int libc_major = __GLIBC__;
1027        int libc_minor = __GLIBC_MINOR__;
1028
1029        if (libc_major < 2)
1030               exit(1);
1031        if ((libc_major == 2) && (libc_minor <= 3))
1032               exit(1);
1033 #endif
1034        exit(0);
1035 }
1036 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1037        if test x"$linux_getgrouplist_ok" = x"yes"; then
1038           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1039        fi
1040        ;;
1041     *)
1042        AC_CHECK_FUNCS(getgrouplist)
1043        ;;
1044 esac
1045
1046 #
1047 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1048 #
1049
1050 if test x$ac_cv_func_stat64 = xno ; then
1051   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1052   AC_TRY_LINK([
1053 #if defined(HAVE_UNISTD_H)
1054 #include <unistd.h>
1055 #endif
1056 #include <sys/stat.h>
1057 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1058   AC_MSG_RESULT([$ac_cv_func_stat64])
1059   if test x$ac_cv_func_stat64 = xyes ; then
1060     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1061   fi
1062 fi
1063
1064 if test x$ac_cv_func_lstat64 = xno ; then
1065   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1066   AC_TRY_LINK([
1067 #if defined(HAVE_UNISTD_H)
1068 #include <unistd.h>
1069 #endif
1070 #include <sys/stat.h>
1071 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1072   AC_MSG_RESULT([$ac_cv_func_lstat64])
1073   if test x$ac_cv_func_lstat64 = xyes ; then
1074     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1075   fi
1076 fi
1077
1078 if test x$ac_cv_func_fstat64 = xno ; then
1079   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1080   AC_TRY_LINK([
1081 #if defined(HAVE_UNISTD_H)
1082 #include <unistd.h>
1083 #endif
1084 #include <sys/stat.h>
1085 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1086   AC_MSG_RESULT([$ac_cv_func_fstat64])
1087   if test x$ac_cv_func_fstat64 = xyes ; then
1088     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1089   fi
1090 fi
1091
1092 #####################################
1093 # we might need the resolv library on some systems
1094 AC_CHECK_LIB(resolv, dn_expand)
1095
1096 #
1097 # Check for the functions putprpwnam, set_auth_parameters,
1098 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1099 # Needed for OSF1 and HPUX.
1100 #
1101
1102 AC_LIBTESTFUNC(security, putprpwnam)
1103 AC_LIBTESTFUNC(sec, putprpwnam)
1104
1105 AC_LIBTESTFUNC(security, set_auth_parameters)
1106 AC_LIBTESTFUNC(sec, set_auth_parameters)
1107
1108 # UnixWare 7.x has its getspnam in -lgen
1109 AC_LIBTESTFUNC(gen, getspnam)
1110
1111 AC_LIBTESTFUNC(security, getspnam)
1112 AC_LIBTESTFUNC(sec, getspnam)
1113
1114 AC_LIBTESTFUNC(security, bigcrypt)
1115 AC_LIBTESTFUNC(sec, bigcrypt)
1116
1117 AC_LIBTESTFUNC(security, getprpwnam)
1118 AC_LIBTESTFUNC(sec, getprpwnam)
1119
1120 ############################################
1121 # Check if we have libattr
1122 AC_SEARCH_LIBS(getxattr, [attr])
1123 AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1124 AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1125 AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1126 AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1127 AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1128
1129 # Assume non-shared by default and override below
1130 BLDSHARED="false"
1131
1132 # these are the defaults, good for lots of systems
1133 HOST_OS="$host_os"
1134 LDSHFLAGS="-shared"
1135 SONAMEFLAG="#"
1136 SHLD="\${CC} \${CFLAGS}"
1137 PICFLAGS=""
1138 PICSUFFIX="po"
1139 SHLIBEXT="so"
1140
1141 if test "$enable_shared" = "yes"; then
1142   # this bit needs to be modified for each OS that is suported by
1143   # smbwrapper. You need to specify how to created a shared library and
1144   # how to compile C code to produce PIC object files
1145
1146   AC_MSG_CHECKING([ability to build shared libraries])
1147
1148   # and these are for particular systems
1149   case "$host_os" in
1150                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1151                         BLDSHARED="true"
1152                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1153                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
1154                         else
1155                                 LDSHFLAGS="-shared -Wl,-Bsymbolic" 
1156                         fi
1157                         DYNEXP="-Wl,--export-dynamic"
1158                         PICFLAGS="-fPIC"
1159                         SONAMEFLAG="-Wl,-soname="
1160                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1161                         ;;
1162                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1163                         BLDSHARED="true"
1164                         LDSHFLAGS="-G"
1165                         SONAMEFLAG="-h "
1166                         if test "${GCC}" = "yes"; then
1167                                 PICFLAGS="-fPIC"
1168                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1169                                         DYNEXP="-Wl,-E"
1170                                 fi
1171                         else
1172                                 PICFLAGS="-KPIC"
1173                                 ## ${CFLAGS} added for building 64-bit shared 
1174                                 ## libs using Sun's Compiler
1175                                 LDSHFLAGS="-G \${CFLAGS}"
1176                                 PICSUFFIX="po.o"
1177                         fi
1178                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1179                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1180                         ;;
1181                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1182                         BLDSHARED="true"
1183                         LDSHFLAGS="-G"
1184                         SONAMEFLAG="-Wl,-h,"
1185                         PICFLAGS="-KPIC"   # Is this correct for SunOS
1186                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1187                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1188                         ;;
1189                 *netbsd* | *freebsd* | *DragonFly* )  
1190                         BLDSHARED="true"
1191                         LDSHFLAGS="-shared"
1192                         DYNEXP="-Wl,--export-dynamic"
1193                         SONAMEFLAG="-Wl,-soname,"
1194                         PICFLAGS="-fPIC -DPIC"
1195                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1196                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1197                         ;;
1198                 *openbsd*)  BLDSHARED="true"
1199                         LDSHFLAGS="-shared"
1200                         DYNEXP="-Wl,-Bdynamic"
1201                         SONAMEFLAG="-Wl,-soname,"
1202                         PICFLAGS="-fPIC"
1203                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1204                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1205                         ;;
1206                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1207                         case "$host_os" in
1208                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1209                         ;;
1210                         esac
1211                         BLDSHARED="true"
1212                         LDSHFLAGS="-set_version sgi1.0 -shared"
1213                         SONAMEFLAG="-soname "
1214                         SHLD="\${LD}"
1215                         if test "${GCC}" = "yes"; then
1216                                 PICFLAGS="-fPIC"
1217                         else 
1218                                 PICFLAGS="-KPIC"
1219                         fi
1220                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1221                         ;;
1222                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1223                         BLDSHARED="true"
1224                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
1225                         DYNEXP="-Wl,-brtl,-bexpall"
1226                         PICFLAGS="-O2"
1227                         if test "${GCC}" != "yes"; then
1228                                 ## for funky AIX compiler using strncpy()
1229                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1230                         fi
1231
1232                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1233                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1234                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1235                         ;;
1236                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1237                         SHLIBEXT="sl"
1238                         # Use special PIC flags for the native HP-UX compiler.
1239                         if test $ac_cv_prog_cc_Ae = yes; then
1240                                 BLDSHARED="true"
1241                                 SHLD="cc"
1242                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1243                                 SONAMEFLAG="-Wl,+h "
1244                                 PICFLAGS="+z"
1245                         elif test "${GCC}" = "yes"; then
1246                                 PICFLAGS="-fPIC"
1247                         fi
1248                         DYNEXP="-Wl,-E"
1249                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1250                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1251                         ;;
1252                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1253                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1254                         ;;
1255                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1256                         BLDSHARED="true"
1257                         LDSHFLAGS="-shared"
1258                         SONAMEFLAG="-Wl,-soname,"
1259                         PICFLAGS="-fPIC"
1260                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1261                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1262                         ;;
1263                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1264                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1265                         ;;
1266                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1267                         BLDSHARED="true"
1268                         LDSHFLAGS="-shared"
1269                         SONAMEFLAG="-Wl,-soname,"
1270                         PICFLAGS="-KPIC"
1271                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1272                         ;;
1273                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1274                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1275                         ;;
1276                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1277                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1278                         ;;
1279                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1280                         case "$host" in
1281                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1282                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1283                                         fi
1284                                         LDSHFLAGS="-G"
1285                                         DYNEXP="-Bexport"
1286                                 ;;
1287                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1288                         esac
1289                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1290                         ;;
1291
1292                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1293                         if [ test "$GCC" != yes ]; then
1294                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1295                         fi
1296                         LDSHFLAGS="-G"
1297                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1298                         ;;
1299                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1300                         BLDSHARED="false"
1301                         LDSHFLAGS=""
1302                         ;;
1303
1304                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1305                         BLDSHARED="true"
1306                         LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
1307                         SHLIBEXT="dylib"
1308                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1309                         ;;
1310
1311                 *)
1312                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1313                         ;;
1314   esac
1315   AC_SUBST(DYNEXP)
1316   AC_MSG_RESULT($BLDSHARED)
1317   AC_MSG_CHECKING([linker flags for shared libraries])
1318   AC_MSG_RESULT([$LDSHFLAGS])
1319   AC_MSG_CHECKING([compiler flags for position-independent code])
1320   AC_MSG_RESULT([$PICFLAGS])
1321 fi
1322
1323 #######################################################
1324 # test whether building a shared library actually works
1325 if test $BLDSHARED = true; then
1326 AC_CACHE_CHECK([whether building shared libraries actually works], 
1327                [ac_cv_shlib_works],[
1328    # try building a trivial shared library
1329    ac_cv_shlib_works=no
1330    # The $SHLD and $LDSHFLAGS variables may contain references to other
1331    # variables so they need to be eval'ed.
1332    $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o \
1333         shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c && \
1334    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1335         shlib.$PICSUFFIX && ac_cv_shlib_works=yes
1336    rm -f "shlib.$SHLIBEXT" shlib.$PICSUFFIX
1337 ])
1338 if test $ac_cv_shlib_works = no; then
1339    BLDSHARED=false
1340 fi
1341 fi
1342
1343 ################
1344
1345 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1346 AC_TRY_RUN([#include <stdio.h>
1347 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1348 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1349 if test x"$samba_cv_have_longlong" = x"yes"; then
1350     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1351 fi
1352
1353 #
1354 # Check if the compiler supports the LL prefix on long long integers.
1355 # AIX needs this.
1356
1357 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1358     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1359         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1360 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1361    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1362 fi
1363
1364   
1365 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1366 AC_TRY_RUN([#include <stdio.h>
1367 #include <sys/stat.h>
1368 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1369 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1370 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1371     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1372 fi
1373
1374 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1375 AC_TRY_RUN([
1376 #if defined(HAVE_UNISTD_H)
1377 #include <unistd.h>
1378 #endif
1379 #include <stdio.h>
1380 #include <sys/stat.h>
1381 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1382 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1383 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1384     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1385 fi
1386
1387 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1388 AC_TRY_RUN([#include <stdio.h>
1389 #include <sys/stat.h>
1390 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1391 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1392 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1393     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1394 fi
1395
1396 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1397 AC_TRY_RUN([
1398 #if defined(HAVE_UNISTD_H)
1399 #include <unistd.h>
1400 #endif
1401 #include <stdio.h>
1402 #include <sys/stat.h>
1403 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1404 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1405 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1406     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1407 fi
1408
1409 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1410 AC_TRY_RUN([
1411 #if defined(HAVE_UNISTD_H)
1412 #include <unistd.h>
1413 #endif
1414 #include <stdio.h>
1415 #include <sys/stat.h>
1416 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1417 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1418 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1419     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1420 fi
1421
1422 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1423 AC_TRY_COMPILE([
1424 #if defined(HAVE_UNISTD_H)
1425 #include <unistd.h>
1426 #endif
1427 #include <sys/types.h>
1428 #include <dirent.h>],
1429 [struct dirent64 de;],
1430 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1431 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1432     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1433 fi
1434
1435 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1436 AC_TRY_RUN([
1437 #if defined(HAVE_UNISTD_H)
1438 #include <unistd.h>
1439 #endif
1440 #include <sys/types.h>
1441 main() { dev_t dev; int i = major(dev); return 0; }],
1442 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1443 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1444     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1445 fi
1446
1447 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1448 AC_TRY_RUN([
1449 #if defined(HAVE_UNISTD_H)
1450 #include <unistd.h>
1451 #endif
1452 #include <sys/types.h>
1453 main() { dev_t dev; int i = minor(dev); return 0; }],
1454 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1455 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1456     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1457 fi
1458
1459 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
1460 AC_TRY_RUN([
1461 #if defined(HAVE_UNISTD_H)
1462 #include <unistd.h>
1463 #endif
1464 #include <sys/types.h>
1465 main() { dev_t dev = makedev(1,2); return 0; }],
1466 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
1467 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
1468     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
1469 fi
1470
1471 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1472 AC_TRY_RUN([#include <stdio.h>
1473 main() { char c; c=250; exit((c > 0)?0:1); }],
1474 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1475 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1476     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1477 fi
1478
1479 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1480 AC_TRY_COMPILE([#include <sys/types.h>
1481 #include <sys/socket.h>
1482 #include <netinet/in.h>],
1483 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1484 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1485 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1486     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1487 fi
1488
1489 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1490 AC_TRY_COMPILE([#include <sys/types.h>
1491 #include <dirent.h>
1492 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1493 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1494 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1495     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
1496 fi
1497
1498 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1499 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1500 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1501 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1502     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
1503 fi
1504
1505 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1506 AC_TRY_RUN([
1507 #include <sys/time.h>
1508 #include <unistd.h>
1509 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1510            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1511 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1512     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
1513 fi
1514
1515 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
1516 AC_TRY_LINK([#include <stdarg.h>
1517 va_list ap1,ap2;], [va_copy(ap1,ap2);],
1518 samba_cv_HAVE_VA_COPY=yes,
1519 samba_cv_HAVE_VA_COPY=no)])
1520 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
1521     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
1522 else
1523     AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
1524     AC_TRY_LINK([#include <stdarg.h>
1525     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
1526     samba_cv_HAVE___VA_COPY=yes,
1527     samba_cv_HAVE___VA_COPY=no)])
1528     if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
1529         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
1530     fi
1531 fi
1532
1533 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1534 AC_TRY_RUN([
1535 #include <sys/types.h>
1536 #include <stdarg.h>
1537 void foo(const char *format, ...) { 
1538        va_list ap;
1539        int len;
1540        char buf[5];
1541
1542        va_start(ap, format);
1543        len = vsnprintf(buf, 0, format, ap);
1544        va_end(ap);
1545        if (len != 5) exit(1);
1546
1547        va_start(ap, format);
1548        len = vsnprintf(0, 0, format, ap);
1549        va_end(ap);
1550        if (len != 5) exit(1);
1551
1552        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1553
1554        exit(0);
1555 }
1556 main() { foo("hello"); }
1557 ],
1558 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1559 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1560     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1561 fi
1562
1563 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1564 AC_TRY_RUN([#include <sys/types.h>
1565 #include <dirent.h>
1566 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1567 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1568 di->d_name[0] == 0) exit(0); exit(1);} ],
1569 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1570 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1571     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1572 fi
1573
1574 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1575 AC_TRY_COMPILE([#include <sys/types.h>
1576 #include <utime.h>],
1577 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1578 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1579 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1580     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1581 fi
1582
1583 ##############
1584 # Check utmp details, but only if our OS offers utmp.h
1585 if test x"$ac_cv_header_utmp_h" = x"yes"; then
1586 dnl  utmp and utmpx come in many flavours
1587 dnl  We need to check for many of them
1588 dnl  But we don't need to do each and every one, because our code uses
1589 dnl  mostly just the utmp (not utmpx) fields.
1590
1591 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1592
1593 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1594 AC_TRY_COMPILE([#include <sys/types.h>
1595 #include <utmp.h>],
1596 [struct utmp ut;  ut.ut_name[0] = 'a';],
1597 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1598 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1599     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
1600 fi 
1601
1602 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1603 AC_TRY_COMPILE([#include <sys/types.h>
1604 #include <utmp.h>],
1605 [struct utmp ut;  ut.ut_user[0] = 'a';],
1606 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1607 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1608     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
1609 fi 
1610
1611 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1612 AC_TRY_COMPILE([#include <sys/types.h>
1613 #include <utmp.h>],
1614 [struct utmp ut;  ut.ut_id[0] = 'a';],
1615 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1616 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1617     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
1618 fi 
1619
1620 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1621 AC_TRY_COMPILE([#include <sys/types.h>
1622 #include <utmp.h>],
1623 [struct utmp ut;  ut.ut_host[0] = 'a';],
1624 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1625 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1626     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
1627 fi 
1628
1629 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1630 AC_TRY_COMPILE([#include <sys/types.h>
1631 #include <utmp.h>],
1632 [struct utmp ut;  time_t t; ut.ut_time = t;],
1633 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1634 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1635     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
1636 fi 
1637
1638 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1639 AC_TRY_COMPILE([#include <sys/types.h>
1640 #include <utmp.h>],
1641 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1642 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1643 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1644     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
1645 fi 
1646
1647 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1648 AC_TRY_COMPILE([#include <sys/types.h>
1649 #include <utmp.h>],
1650 [struct utmp ut;  ut.ut_type = 0;],
1651 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1652 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1653     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
1654 fi 
1655
1656 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1657 AC_TRY_COMPILE([#include <sys/types.h>
1658 #include <utmp.h>],
1659 [struct utmp ut;  ut.ut_pid = 0;],
1660 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1661 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1662     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
1663 fi 
1664
1665 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1666 AC_TRY_COMPILE([#include <sys/types.h>
1667 #include <utmp.h>],
1668 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1669 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1670 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1671     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
1672 fi 
1673
1674 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1675 AC_TRY_COMPILE([#include <sys/types.h>
1676 #include <utmp.h>],
1677 [struct utmp ut;  ut.ut_addr = 0;],
1678 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1679 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1680     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
1681 fi 
1682
1683 if test x$ac_cv_func_pututline = xyes ; then
1684   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1685   AC_TRY_COMPILE([#include <sys/types.h>
1686 #include <utmp.h>],
1687   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1688   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1689   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1690       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
1691   fi
1692 fi
1693
1694 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1695 AC_TRY_COMPILE([#include <sys/types.h>
1696 #include <utmpx.h>],
1697 [struct utmpx ux;  ux.ut_syslen = 0;],
1698 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1699 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1700     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
1701 fi 
1702
1703 fi
1704 # end utmp details
1705
1706
1707 ICONV_LOCATION=standard
1708 LOOK_DIRS="/usr /usr/local /sw /opt"
1709 AC_ARG_WITH(libiconv,
1710 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1711 [
1712   if test "$withval" = "no" ; then
1713     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
1714   else
1715      if test "$withval" != "yes" ; then
1716         ICONV_PATH_SPEC=yes
1717         LOOK_DIRS="$withval"
1718      fi
1719   fi
1720 ])
1721
1722 for i in $LOOK_DIRS ; do
1723     save_LIBS=$LIBS
1724     save_LDFLAGS=$LDFLAGS
1725     save_CPPFLAGS=$CPPFLAGS
1726     ICONV_FOUND="no"
1727     unset libext
1728     CPPFLAGS="$CPPFLAGS -I$i/include"
1729 dnl This is here to handle -withval stuff for --with-libiconv
1730 dnl Perhaps we should always add a -L
1731
1732 dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
1733 dnl installation paths. This gets a little tricky since we might have iconv
1734 dnl in both libiconv and in libc. In this case the jm_ICONV test will always
1735 dnl succeed when the header is found. To counter this, make sure the 
1736 dnl library directory is there and check the ABI directory first (which
1737 dnl should be harmless on other systems.
1738     for l in "lib32" "lib" ; do
1739         if test -d "$i/$l" ; then
1740                 LDFLAGS="$save_LDFLAGS -L$i/$l"
1741                 LIBS=
1742                 export LDFLAGS LIBS CPPFLAGS
1743 dnl Try to find iconv(3)
1744                 jm_ICONV($i/$l)
1745                 if test x"$ICONV_FOUND" = "xyes" ; then
1746                     libext="$l"
1747                     break;
1748                 fi
1749         fi
1750     done
1751
1752     if test x"$ICONV_FOUND" = "xyes" ; then
1753         LDFLAGS=$save_LDFLAGS
1754         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1755         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1756         LIBS="$save_LIBS"
1757         ICONV_LOCATION=$i
1758         export LDFLAGS LIBS CPPFLAGS
1759 dnl Now, check for a working iconv ... we want to do it here because
1760 dnl there might be a working iconv further down the list of LOOK_DIRS
1761
1762         ############
1763         # check for iconv in libc
1764         ic_save_LIBS="$LIBS"
1765         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
1766            LIBS="$LIBS -L$ICONV_LOCATION/$libext"
1767         fi
1768         if test x"$jm_cv_lib_iconv" != x; then
1769            LIBS="$LIBS -l$jm_cv_lib_iconv"
1770         fi
1771 dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1772         default_dos_charset=no
1773         default_display_charset=no
1774         default_unix_charset=no
1775
1776         # check for default dos charset name
1777         for j in CP850 IBM850 ; do
1778             rjs_CHARSET($j)
1779             if test x"$ICONV_CHARSET" = x"$j"; then
1780                 default_dos_charset="\"$j\""
1781                 break
1782             fi
1783         done
1784         # check for default display charset name
1785         for j in ASCII 646 ; do
1786             rjs_CHARSET($j)
1787             if test x"$ICONV_CHARSET" = x"$j"; then
1788                 default_display_charset="\"$j\""
1789                 break
1790             fi
1791         done
1792         # check for default unix charset name
1793         for j in UTF-8 UTF8 ; do
1794             rjs_CHARSET($j)
1795             if test x"$ICONV_CHARSET" = x"$j"; then
1796                 default_unix_charset="\"$j\""
1797                 break
1798             fi
1799         done
1800         
1801         if test "$default_dos_charset" != "no" -a \
1802                 "$default_dos_charset" != "cross" -a \
1803                 "$default_display_charset" != "no" -a \ 
1804                 "$default_display_charset" != "cross" -a \
1805                 "$default_unix_charset" != "no" -a \
1806                 "$default_unix_charset" != "cross"
1807         then
1808                 samba_cv_HAVE_NATIVE_ICONV=yes
1809         else if test "$default_dos_charset" = "cross" -o \
1810                      "$default_display_charset" = "cross" -o \
1811                      "$default_unix_charset" = "cross"
1812         then
1813                 samba_cv_HAVE_NATIVE_ICONV=cross
1814         else
1815                 samba_cv_HAVE_NATIVE_ICONV=no
1816         fi
1817         fi
1818 dnl ])
1819
1820         LIBS="$ic_save_LIBS"
1821         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1822            CPPFLAGS=$save_CPPFLAGS
1823            LDFLAGS=$save_LDFLAGS
1824            LIBS=$save_LIBS
1825            if test x"$jm_cv_lib_iconv" != x; then
1826               LIBS="$LIBS -l$jm_cv_lib_iconv"
1827            fi
1828            dnl Add the flags we need to CPPFLAGS and LDFLAGS
1829            CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1830            LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1831            export CPPFLAGS
1832            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
1833            AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
1834            AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
1835            AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
1836            break
1837         fi
1838 dnl We didn't find a working iconv, so keep going
1839     fi
1840 dnl We only need to clean these up here for the next pass through the loop
1841     CPPFLAGS=$save_CPPFLAGS
1842     LDFLAGS=$save_LDFLAGS
1843     LIBS=$save_LIBS
1844     export LDFLAGS LIBS CPPFLAGS
1845 done
1846 unset libext
1847
1848
1849 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
1850     AC_MSG_WARN([Sufficient support for iconv function was not found. 
1851     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
1852    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
1853    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
1854    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
1855 fi
1856
1857
1858 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1859 AC_TRY_RUN([
1860 #include <sys/types.h>
1861 #include <fcntl.h>
1862 #ifndef F_GETLEASE
1863 #define F_GETLEASE      1025
1864 #endif
1865 main() {
1866        int fd = open("/dev/null", O_RDONLY);
1867        return fcntl(fd, F_GETLEASE, 0) == -1;
1868 }
1869 ],
1870 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1871 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1872     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1873 fi
1874
1875 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1876 AC_TRY_RUN([
1877 #include <sys/types.h>
1878 #include <fcntl.h>
1879 #include <signal.h>
1880 #ifndef F_NOTIFY
1881 #define F_NOTIFY 1026
1882 #endif
1883 main() {
1884         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1885 }
1886 ],
1887 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1888 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1889     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1890 fi
1891
1892 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1893 AC_TRY_RUN([
1894 #include <sys/types.h>
1895 #include <fcntl.h>
1896 #include <signal.h>
1897 #include <sys/file.h>
1898 #ifndef LOCK_MAND
1899 #define LOCK_MAND       32
1900 #define LOCK_READ       64
1901 #endif
1902 main() {
1903         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1904 }
1905 ],
1906 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1907 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1908     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1909 fi
1910
1911
1912
1913
1914 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1915 AC_TRY_COMPILE([#include <sys/types.h>
1916 #include <fcntl.h>],
1917 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1918 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1919 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1920     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1921 fi
1922
1923 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1924 AC_TRY_RUN([#include <sys/types.h>
1925 #include <sys/capability.h>
1926 main() {
1927  cap_t cap;
1928  if ((cap = cap_get_proc()) == NULL)
1929    exit(1);
1930  cap->cap_effective |= CAP_NETWORK_MGT;
1931  cap->cap_inheritable |= CAP_NETWORK_MGT;
1932  cap_set_proc(cap);
1933  exit(0);
1934 }
1935 ],
1936 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1937 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1938     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1939 fi
1940
1941 #
1942 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1943 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1944 #
1945
1946 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1947 AC_TRY_COMPILE([#include <sys/types.h>
1948 #if defined(HAVE_RPC_RPC_H)
1949 #include <rpc/rpc.h>
1950 #endif],
1951 [int16 testvar;],
1952 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1953 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1954     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
1955 fi
1956
1957 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1958 AC_TRY_COMPILE([#include <sys/types.h>
1959 #if defined(HAVE_RPC_RPC_H)
1960 #include <rpc/rpc.h>
1961 #endif],
1962 [uint16 testvar;],
1963 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1964 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1965     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
1966 fi
1967
1968 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1969 AC_TRY_COMPILE([#include <sys/types.h>
1970 #if defined(HAVE_RPC_RPC_H)
1971 #include <rpc/rpc.h>
1972 #endif],
1973 [int32 testvar;],
1974 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1975 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1976     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
1977 fi
1978
1979 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1980 AC_TRY_COMPILE([#include <sys/types.h>
1981 #if defined(HAVE_RPC_RPC_H)
1982 #include <rpc/rpc.h>
1983 #endif],
1984 [uint32 testvar;],
1985 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1986 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1987     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
1988 fi
1989
1990 dnl
1991 dnl Some systems (SCO) have a problem including
1992 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1993 dnl as a #define in <prot.h> and as part of an enum
1994 dnl in <rpc/rpc.h>.
1995 dnl
1996
1997 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1998 AC_TRY_COMPILE([#include <sys/types.h>
1999 #ifdef HAVE_SYS_SECURITY_H
2000 #include <sys/security.h>
2001 #include <prot.h>
2002 #endif  /* HAVE_SYS_SECURITY_H */
2003 #if defined(HAVE_RPC_RPC_H)
2004 #include <rpc/rpc.h>
2005 #endif],
2006 [int testvar;],
2007 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2008 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2009     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2010 fi
2011
2012 AC_MSG_CHECKING([for test routines])
2013 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2014            AC_MSG_RESULT(yes),
2015            AC_MSG_ERROR([cant find test code. Aborting config]),
2016            AC_MSG_WARN([cannot run when cross-compiling]))
2017
2018 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2019 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2020            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2021 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2022     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2023 fi
2024
2025 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2026 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2027            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2028            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2029            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2030 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2031 then
2032     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2033 fi
2034
2035 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2036 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2037            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2038 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2039     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2040 fi
2041
2042 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
2043 SAVE_CPPFLAGS="$CPPFLAGS"
2044 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
2045 AC_TRY_COMPILE([
2046 #define REPLACE_GETPASS 1
2047 #define NO_PROTO_H 1
2048 #define NO_CONFIG_H 1
2049 #define main dont_declare_main
2050 #include "${srcdir-.}/lib/getsmbpass.c"
2051 #undef main
2052 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
2053 CPPFLAGS="$SAVE_CPPFLAGS"
2054 ])
2055 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
2056         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
2057 fi
2058
2059 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
2060 AC_TRY_RUN([
2061 #include <stdio.h>
2062 #include <sys/types.h>
2063 #include <netinet/in.h>
2064 #ifdef HAVE_ARPA_INET_H
2065 #include <arpa/inet.h>
2066 #endif
2067 main() { struct in_addr ip; ip.s_addr = 0x12345678;
2068 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
2069     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
2070 exit(1);}],
2071            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
2072 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
2073     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
2074 fi
2075
2076 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
2077 AC_TRY_RUN([#include <stdlib.h>
2078 #include <sys/types.h>
2079 #include <sys/stat.h>
2080 #include <unistd.h>
2081 main() { 
2082   struct stat st;
2083   char tpl[20]="/tmp/test.XXXXXX"; 
2084   int fd = mkstemp(tpl); 
2085   if (fd == -1) exit(1);
2086   unlink(tpl);
2087   if (fstat(fd, &st) != 0) exit(1);
2088   if ((st.st_mode & 0777) != 0600) exit(1);
2089   exit(0);
2090 }],
2091 samba_cv_HAVE_SECURE_MKSTEMP=yes,
2092 samba_cv_HAVE_SECURE_MKSTEMP=no,
2093 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
2094 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
2095     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
2096 fi
2097
2098 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
2099 AC_TRY_RUN([#include <unistd.h>
2100 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
2101 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
2102 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
2103     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
2104 fi
2105
2106 AC_CACHE_CHECK([for sysconf(_SC_NPROC_ONLN)],samba_cv_SYSCONF_SC_NPROC_ONLN,[
2107 AC_TRY_RUN([#include <unistd.h>
2108 main() { exit(sysconf(_SC_NPROC_ONLN) == -1 ? 1 : 0); }],
2109 samba_cv_SYSCONF_SC_NPROC_ONLN=yes,samba_cv_SYSCONF_SC_NPROC_ONLN=no,samba_cv_SYSCONF_SC_NPROC_ONLN=cross)])
2110 if test x"$samba_cv_SYSCONF_SC_NPROC_ONLN" = x"yes"; then
2111     AC_DEFINE(SYSCONF_SC_NPROC_ONLN,1,[Whether sysconf(_SC_NPROC_ONLN) is available])
2112 fi
2113
2114 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
2115 AC_TRY_RUN([main() { exit(getuid() != 0); }],
2116            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
2117 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
2118     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
2119 else
2120     AC_MSG_WARN(running as non-root will disable some tests)
2121 fi
2122
2123 ##################
2124 # look for a method of finding the list of network interfaces
2125 iface=no;
2126 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
2127 AC_TRY_RUN([
2128 #define HAVE_IFACE_AIX 1
2129 #define AUTOCONF_TEST 1
2130 #include "confdefs.h"
2131 #include "${srcdir-.}/lib/interfaces.c"],
2132            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
2133 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
2134     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
2135 fi
2136
2137 if test $iface = no; then
2138 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
2139 AC_TRY_RUN([
2140 #define HAVE_IFACE_IFCONF 1
2141 #define AUTOCONF_TEST 1
2142 #include "confdefs.h"
2143 #include "${srcdir-.}/lib/interfaces.c"],
2144            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
2145 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
2146     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
2147 fi
2148 fi
2149
2150 if test $iface = no; then
2151 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
2152 AC_TRY_RUN([
2153 #define HAVE_IFACE_IFREQ 1
2154 #define AUTOCONF_TEST 1
2155 #include "confdefs.h"
2156 #include "${srcdir-.}/lib/interfaces.c"],
2157            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
2158 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
2159     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
2160 fi
2161 fi
2162
2163
2164 ################################################
2165 # look for a method of setting the effective uid
2166 seteuid=no;
2167 if test $seteuid = no; then
2168 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2169 AC_TRY_RUN([
2170 #define AUTOCONF_TEST 1
2171 #define USE_SETRESUID 1
2172 #include "confdefs.h"
2173 #include "${srcdir-.}/lib/util_sec.c"],
2174            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2175 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2176     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2177 fi
2178 fi
2179
2180
2181 if test $seteuid = no; then
2182 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2183 AC_TRY_RUN([
2184 #define AUTOCONF_TEST 1
2185 #define USE_SETREUID 1
2186 #include "confdefs.h"
2187 #include "${srcdir-.}/lib/util_sec.c"],
2188            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2189 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2190     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2191 fi
2192 fi
2193
2194 if test $seteuid = no; then
2195 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2196 AC_TRY_RUN([
2197 #define AUTOCONF_TEST 1
2198 #define USE_SETEUID 1
2199 #include "confdefs.h"
2200 #include "${srcdir-.}/lib/util_sec.c"],
2201            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2202 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2203     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2204 fi
2205 fi
2206
2207 if test $seteuid = no; then
2208 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2209 AC_TRY_RUN([
2210 #define AUTOCONF_TEST 1
2211 #define USE_SETUIDX 1
2212 #include "confdefs.h"
2213 #include "${srcdir-.}/lib/util_sec.c"],
2214            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2215 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2216     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2217 fi
2218 fi
2219
2220
2221 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
2222 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
2223            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
2224 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
2225     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
2226 fi
2227
2228 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
2229 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
2230            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
2231 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
2232     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
2233 fi
2234
2235 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2236 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2237            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2238 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2239     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2240 fi
2241
2242 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2243 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2244            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2245 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2246     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2247
2248 else
2249
2250 dnl
2251 dnl Don't check for 64 bit fcntl locking if we know that the
2252 dnl glibc2.1 broken check has succeeded.
2253 dnl 
2254
2255   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2256   AC_TRY_RUN([
2257 #if defined(HAVE_UNISTD_H)
2258 #include <unistd.h>
2259 #endif
2260 #include <stdio.h>
2261 #include <stdlib.h>
2262
2263 #ifdef HAVE_FCNTL_H
2264 #include <fcntl.h>
2265 #endif
2266
2267 #ifdef HAVE_SYS_FCNTL_H
2268 #include <sys/fcntl.h>
2269 #endif
2270 main() { struct flock64 fl64;
2271 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2272 exit(0);
2273 #else
2274 exit(1);
2275 #endif
2276 }],
2277        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2278
2279   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2280       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2281   fi
2282 fi
2283
2284 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2285 AC_TRY_COMPILE([#include <sys/types.h>
2286 #include <sys/stat.h>
2287 #include <unistd.h>],
2288 [struct stat st;  st.st_blocks = 0;],
2289 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2290 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2291     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2292 fi 
2293
2294 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2295 AC_TRY_COMPILE([#include <sys/types.h>
2296 #include <sys/stat.h>
2297 #include <unistd.h>],
2298 [struct stat st;  st.st_blksize = 0;],
2299 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2300 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2301     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2302 fi
2303
2304 case "$host_os" in
2305 *linux*)
2306 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
2307 AC_TRY_COMPILE([
2308 #ifdef HAVE_SYS_VFS_H
2309 #include <sys/vfs.h>
2310 #endif
2311 #ifdef HAVE_SYS_CAPABILITY_H
2312 #include <sys/capability.h>
2313 #endif
2314 ],[int i;],
2315    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
2316 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
2317    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
2318 fi
2319 ;;
2320 esac
2321
2322 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2323 AC_TRY_COMPILE([
2324 #include <sys/types.h>
2325 #include <sys/acl.h>
2326 #if defined(HAVE_RPCSVC_NIS_H)
2327 #include <rpcsvc/nis.h>
2328 #endif],
2329 [int i;],
2330 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2331 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2332         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2333 fi
2334
2335 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2336 AC_TRY_RUN([
2337 #include <stdio.h>
2338 #include <limits.h>
2339 main() {
2340         char *newpath = realpath("/tmp", NULL);
2341         exit ((newpath != NULL) ? 0 : 1);
2342 }
2343 ],
2344 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2345 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2346     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2347 fi
2348
2349 #################################################
2350 # check for smbwrapper support
2351 AC_MSG_CHECKING(whether to use smbwrapper)
2352 AC_ARG_WITH(smbwrapper,
2353 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
2354 [ case "$withval" in
2355   yes)
2356     AC_MSG_RESULT(yes)
2357     AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
2358         WRAPPROG="bin/smbsh\$(EXEEXT)"
2359         WRAP="bin/smbwrapper.$SHLIBEXT"
2360
2361 # Conditions under which smbwrapper should not be built.
2362
2363         if test x$PICFLAGS = x; then
2364            echo No support for PIC code - disabling smbwrapper and smbsh
2365            WRAPPROG=""
2366            WRAP=""
2367         elif test x$ac_cv_func_syscall = xno; then
2368            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
2369            WRAPPROG=""
2370            WRAP=""
2371         fi
2372         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP"
2373         SMBWRAPPER="$WRAPPROG $WRAP"
2374     ;;
2375   *)
2376     AC_MSG_RESULT(no)
2377     ;;
2378   esac ],
2379   AC_MSG_RESULT(no)
2380 )
2381
2382 #################################################
2383 # check for AFS clear-text auth support
2384 samba_cv_WITH_AFS=no
2385 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2386 AC_ARG_WITH(afs,
2387 [  --with-afs              Include AFS clear-text auth support (default=no) ],
2388 [ case "$withval" in
2389   yes|auto)
2390     AC_MSG_RESULT($withval)
2391     samba_cv_WITH_AFS=$withval
2392     ;;
2393   *)
2394     AC_MSG_RESULT(no)
2395     ;;
2396   esac ],
2397   AC_MSG_RESULT(no)
2398 )
2399
2400 ####################################################
2401 # check for Linux-specific AFS fake-kaserver support
2402 samba_cv_WITH_FAKE_KASERVER=no
2403 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2404 AC_ARG_WITH(fake-kaserver,
2405 [  --with-fake-kaserver    Include AFS fake-kaserver support (default=no) ],
2406 [ case "$withval" in
2407   yes|auto)
2408     AC_MSG_RESULT($withval)
2409     samba_cv_WITH_FAKE_KASERVER=$withval
2410     ;;
2411   *)
2412     AC_MSG_RESULT(no)
2413     ;;
2414   esac ],
2415   AC_MSG_RESULT(no)
2416 )
2417
2418 #################################################
2419 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
2420 if test x"$samba_cv_WITH_AFS" != x"no" ||
2421    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
2422
2423     # see if this box has the afs-headers in /usr/include/afs
2424     AC_MSG_CHECKING(for /usr/include/afs)
2425     if test -d /usr/include/afs; then
2426           CFLAGS="$CFLAGS -I/usr/include/afs"
2427           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
2428           AC_MSG_RESULT(yes)
2429     else
2430       AC_MSG_RESULT(no)
2431     fi
2432    
2433     # check for afs.h
2434     have_afs_headers=no
2435     AC_CHECK_HEADERS(afs.h afs/afs.h)
2436     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
2437         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
2438            test x"$samba_cv_WITH_AFS" = x"auto"; then
2439                 AC_MSG_WARN([AFS cannot be supported without afs.h])
2440         else
2441                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
2442         fi
2443     else
2444         have_afs_headers=yes
2445     fi
2446 fi
2447
2448 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
2449     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
2450 fi
2451
2452 #################################################
2453 # check whether to compile AFS/NT ACL mapping module
2454 samba_cv_WITH_VFS_AFSACL=no
2455 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2456 AC_ARG_WITH(vfs-afsacl,
2457 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
2458 [ case "$withval" in
2459   yes|auto)
2460     AC_MSG_RESULT($withval)
2461     samba_cv_WITH_VFS_AFSACL=yes
2462     ;;
2463   *)
2464     AC_MSG_RESULT(no)
2465     ;;
2466   esac ],
2467   AC_MSG_RESULT(no)
2468 )
2469
2470 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
2471    default_shared_modules="$default_shared_modules vfs_afsacl"
2472 fi
2473         
2474 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
2475     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
2476 fi
2477
2478 #################################################
2479 # check for the DFS clear-text auth system
2480 AC_MSG_CHECKING(whether to use DFS clear-text auth)
2481 AC_ARG_WITH(dfs,
2482 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
2483 [ case "$withval" in
2484   yes)
2485     AC_MSG_RESULT(yes)
2486     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
2487     ;;
2488   *)
2489     AC_MSG_RESULT(no)
2490     ;;
2491   esac ],
2492   AC_MSG_RESULT(no)
2493 )
2494
2495 ########################################################
2496 # Compile with LDAP support?
2497
2498 with_ldap_support=auto
2499 AC_MSG_CHECKING([for LDAP support])
2500
2501 AC_ARG_WITH(ldap,
2502 [  --with-ldap             LDAP support (default yes)],
2503 [ case "$withval" in
2504     yes|no)
2505         with_ldap_support=$withval
2506         ;;
2507   esac ])
2508
2509 AC_MSG_RESULT($with_ldap_support)
2510
2511 SMBLDAP=""
2512 AC_SUBST(SMBLDAP)
2513 if test x"$with_ldap_support" != x"no"; then
2514
2515   ##################################################################
2516   # first test for ldap.h and lber.h
2517   # (ldap.h is required for this test)
2518   AC_CHECK_HEADERS(ldap.h lber.h)
2519   
2520   if test x"$ac_cv_header_ldap_h" != x"yes"; then
2521         if test x"$with_ldap_support" = x"yes"; then
2522          AC_MSG_ERROR(ldap.h is needed for LDAP support)
2523         else
2524          AC_MSG_WARN(ldap.h is needed for LDAP support)
2525         fi
2526         
2527         with_ldap_support=no
2528   fi
2529 fi
2530
2531 if test x"$with_ldap_support" != x"no"; then
2532   ac_save_LIBS=$LIBS
2533
2534   ##################################################################
2535   # we might need the lber lib on some systems. To avoid link errors
2536   # this test must be before the libldap test
2537   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
2538
2539   ########################################################
2540   # now see if we can find the ldap libs in standard paths
2541   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
2542
2543   AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
2544   
2545   ########################################################
2546   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
2547   # Check found in pam_ldap 145.
2548   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
2549
2550   LIBS="$LIBS $LDAP_LIBS"
2551   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
2552     AC_TRY_COMPILE([
2553         #include <lber.h>
2554         #include <ldap.h>], 
2555         [ldap_set_rebind_proc(0, 0, 0);], 
2556         [smb_ldap_cv_ldap_set_rebind_proc=3], 
2557         [smb_ldap_cv_ldap_set_rebind_proc=2]
2558     ) 
2559   ])
2560   
2561   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
2562
2563   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS) 
2564   
2565   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
2566     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
2567     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
2568     SMBLDAP="lib/smbldap.o"
2569     with_ldap_support=yes
2570     AC_MSG_CHECKING(whether LDAP support is used)
2571     AC_MSG_RESULT(yes)
2572   else
2573     if test x"$with_ldap_support" = x"yes"; then
2574         AC_MSG_ERROR(libldap is needed for LDAP support)
2575     else
2576         AC_MSG_WARN(libldap is needed for LDAP support)
2577     fi
2578     
2579     LDAP_LIBS=""
2580     with_ldap_support=no
2581   fi
2582   LIBS=$ac_save_LIBS
2583 fi
2584
2585
2586 #################################################
2587 # active directory support
2588
2589 with_ads_support=auto
2590 AC_MSG_CHECKING([for Active Directory and krb5 support])
2591
2592 AC_ARG_WITH(ads,
2593 [  --with-ads              Active Directory support (default auto)],
2594 [ case "$withval" in
2595     yes|no)
2596         with_ads_support="$withval"
2597         ;;
2598   esac ])
2599
2600 AC_MSG_RESULT($with_ads_support)
2601
2602 FOUND_KRB5=no
2603 KRB5_LIBS=""
2604
2605 if test x"$with_ldap_support" != x"yes"; then
2606     if test x"$with_ads_support" = x"yes"; then
2607         AC_MSG_ERROR(Active Directory Support requires LDAP support)
2608     elif test x"$with_ads_support" != x"no"; then
2609         AC_MSG_WARN(Active Directory Support requires LDAP support)
2610     fi
2611     with_ads_support=no
2612 fi
2613
2614 if test x"$with_ads_support" != x"no"; then
2615
2616   # Do no harm to the values of CFLAGS and LIBS while testing for
2617   # Kerberos support.
2618
2619   #################################################
2620   # check for krb5-config from recent MIT and Heimdal kerberos 5
2621   AC_PATH_PROG(KRB5_CONFIG, krb5-config)
2622   AC_MSG_CHECKING(for working krb5-config)
2623   if test -x "$KRB5_CONFIG"; then
2624     ac_save_CFLAGS=$CFLAGS
2625     CFLAGS="";export CFLAGS
2626     ac_save_LDFLAGS=$LDFLAGS
2627     LDFLAGS="";export LDFLAGS
2628     KRB5_LIBS="`$KRB5_CONFIG --libs gssapi`"
2629     KRB5_CFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`" 
2630     KRB5_CPPFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`"
2631     CFLAGS=$ac_save_CFLAGS;export CFLAGS
2632     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
2633     FOUND_KRB5=yes
2634     AC_MSG_RESULT(yes)
2635   else
2636     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
2637   fi
2638   
2639   if test x$FOUND_KRB5 = x"no"; then
2640     #################################################
2641     # check for location of Kerberos 5 install
2642     AC_MSG_CHECKING(for kerberos 5 install path)
2643     AC_ARG_WITH(krb5,
2644     [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
2645     [ case "$withval" in
2646       no)
2647         AC_MSG_RESULT(no krb5-path given)
2648         ;;
2649       yes)
2650         AC_MSG_RESULT(/usr)
2651         FOUND_KRB5=yes
2652         ;;
2653       *)
2654         AC_MSG_RESULT($withval)
2655         KRB5_CFLAGS="-I$withval/include"
2656         KRB5_CPPFLAGS="-I$withval/include"
2657         KRB5_LDFLAGS="-L$withval/lib"
2658         FOUND_KRB5=yes
2659         ;;
2660       esac ],
2661       AC_MSG_RESULT(no krb5-path given)
2662     )
2663   fi
2664
2665   if test x$FOUND_KRB5 = x"no"; then
2666     #################################################
2667     # see if this box has the SuSE location for the heimdal krb implementation
2668     AC_MSG_CHECKING(for /usr/include/heimdal)
2669     if test -d /usr/include/heimdal; then
2670       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
2671           KRB5_CFLAGS="-I/usr/include/heimdal"
2672           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2673           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
2674           AC_MSG_RESULT(yes)
2675       else
2676           KRB5_CFLAGS="-I/usr/include/heimdal"
2677           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2678           AC_MSG_RESULT(yes)
2679       fi
2680     else
2681       AC_MSG_RESULT(no)
2682     fi
2683   fi
2684
2685   if test x$FOUND_KRB5 = x"no"; then
2686     #################################################
2687     # see if this box has the RedHat location for kerberos
2688     AC_MSG_CHECKING(for /usr/kerberos)
2689     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
2690       KRB5_LDFLAGS="-L/usr/kerberos/lib"
2691       KRB5_CFLAGS="-I/usr/kerberos/include"
2692       KRB5_CPPFLAGS="-I/usr/kerberos/include"
2693       AC_MSG_RESULT(yes)
2694     else
2695       AC_MSG_RESULT(no)
2696     fi
2697   fi
2698
2699   ac_save_CFLAGS=$CFLAGS
2700   ac_save_CPPFLAGS=$CPPFLAGS
2701   ac_save_LDFLAGS=$LDFLAGS
2702
2703   CFLAGS="$CFLAGS $KRB5_CFLAGS"
2704   CPPFLAGS="$CPPFLAGS $KRB5_CPPFLAGS"
2705   LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
2706
2707   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
2708
2709   # now check for krb5.h. Some systems have the libraries without the headers!
2710   # note that this check is done here to allow for different kerberos
2711   # include paths
2712   AC_CHECK_HEADERS(krb5.h)
2713
2714   if test x"$ac_cv_header_krb5_h" = x"no"; then
2715
2716     # Give a warning if AD support was not explicitly requested,
2717     # i.e with_ads_support = auto, otherwise die with an error.
2718
2719     if test x"$with_ads_support" = x"yes"; then
2720       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
2721     else
2722       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
2723     fi
2724
2725     # Turn off AD support and restore CFLAGS and LIBS variables
2726
2727     with_ads_support="no"
2728     
2729     CFLAGS=$ac_save_CFLAGS
2730     CPPFLAGS=$ac_save_CPPFLAGS
2731     LDFLAGS=$ac_save_LDFLAGS
2732   fi
2733 fi
2734
2735 # Now we have determined whether we really want ADS support
2736
2737 if test x"$with_ads_support" != x"no"; then
2738   ac_save_LIBS=$LIBS
2739
2740   # now check for gssapi headers.  This is also done here to allow for
2741   # different kerberos include paths
2742   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
2743
2744   ##################################################################
2745   # we might need the k5crypto and com_err libraries on some systems
2746   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
2747   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
2748
2749   # Heimdal checks.
2750   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
2751   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
2752   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
2753
2754   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
2755   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],
2756                                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2757
2758   ########################################################
2759   # now see if we can find the krb5 libs in standard paths
2760   # or as specified above
2761   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
2762   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
2763
2764   ########################################################
2765   # now see if we can find the gssapi libs in standard paths
2766   AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
2767             AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2768
2769   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
2770   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
2771   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
2772   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
2773   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
2774   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
2775   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
2776   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
2777   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
2778   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
2779   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
2780   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
2781   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
2782   AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
2783   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
2784   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
2785   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
2786   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
2787   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
2788   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
2789   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
2790   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
2791
2792   LIBS="$LIBS $KRB5_LIBS"
2793   
2794   AC_CACHE_CHECK([for addrtype in krb5_address],
2795                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
2796     AC_TRY_COMPILE([#include <krb5.h>],
2797       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
2798       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
2799       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
2800
2801   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
2802     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
2803                [Whether the krb5_address struct has a addrtype property])
2804   fi
2805
2806   AC_CACHE_CHECK([for addr_type in krb5_address],
2807                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
2808     AC_TRY_COMPILE([#include <krb5.h>],
2809       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
2810       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
2811       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
2812
2813   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
2814     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
2815               [Whether the krb5_address struct has a addr_type property])
2816   fi
2817
2818   AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
2819                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
2820                  [AC_TRY_COMPILE([#include <krb5.h>],
2821     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
2822     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
2823
2824   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
2825     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
2826               [Whether the krb5_ticket struct has a enc_part2 property])
2827   fi
2828
2829   AC_CACHE_CHECK([for keyblock in krb5_creds],
2830                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
2831     AC_TRY_COMPILE([#include <krb5.h>],
2832       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
2833       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
2834       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
2835
2836   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
2837     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
2838               [Whether the krb5_creds struct has a keyblock property])
2839   fi
2840
2841   AC_CACHE_CHECK([for session in krb5_creds],
2842                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
2843     AC_TRY_COMPILE([#include <krb5.h>],
2844       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
2845       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
2846       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
2847
2848   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
2849     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
2850               [Whether the krb5_creds struct has a session property])
2851   fi
2852
2853   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
2854                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
2855     AC_TRY_COMPILE([#include <krb5.h>],
2856       [krb5_keyblock key; key.keyvalue.data = NULL;],
2857       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
2858       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
2859
2860   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
2861     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
2862               [Whether the krb5_keyblock struct has a keyvalue property])
2863   fi
2864
2865   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
2866                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
2867     AC_TRY_COMPILE([#include <krb5.h>],
2868       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
2869       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
2870       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
2871   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
2872                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
2873     AC_TRY_COMPILE([#include <krb5.h>],
2874       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
2875       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
2876       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
2877 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
2878 # w.r.t. arcfour and windows, so we must not enable it here
2879   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
2880           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
2881     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
2882               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
2883   fi
2884
2885   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
2886                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
2887     AC_TRY_COMPILE([#include <krb5.h>],
2888       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
2889       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
2890       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
2891
2892   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
2893     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
2894               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
2895   fi
2896
2897   AC_CACHE_CHECK([for KV5M_KEYTAB],
2898                  samba_cv_HAVE_KV5M_KEYTAB,[
2899     AC_TRY_COMPILE([#include <krb5.h>],
2900       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
2901       samba_cv_HAVE_KV5M_KEYTAB=yes,
2902       samba_cv_HAVE_KV5M_KEYTAB=no)])
2903
2904   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
2905       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
2906              [Whether the KV5M_KEYTAB option is available])
2907   fi
2908
2909   AC_CACHE_CHECK([for the krb5_princ_component macro],
2910                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
2911     AC_TRY_LINK([#include <krb5.h>],
2912       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
2913       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
2914       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
2915
2916   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
2917     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
2918                [Whether krb5_princ_component is available])
2919   fi
2920
2921   AC_CACHE_CHECK([for key in krb5_keytab_entry],
2922                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
2923     AC_TRY_COMPILE([#include <krb5.h>],
2924       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
2925       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
2926       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
2927
2928   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
2929     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
2930               [Whether krb5_keytab_entry has key member])
2931   fi
2932
2933   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
2934                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
2935     AC_TRY_COMPILE([#include <krb5.h>],
2936       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
2937       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
2938       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
2939
2940   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
2941     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
2942               [Whether krb5_keytab_entry has keyblock member])
2943   fi
2944
2945   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
2946     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
2947     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
2948     AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
2949     AC_MSG_RESULT(yes)
2950   else
2951     if test x"$with_ads_support" = x"yes"; then
2952         AC_MSG_ERROR(libkrb5 is needed for Active Directory support)
2953     else
2954         AC_MSG_WARN(libkrb5 is needed for Active Directory support)
2955     fi
2956     KRB5_LIBS=""
2957     with_ads_support=no 
2958   fi
2959
2960   AC_CACHE_CHECK([for WRFILE: keytab support],
2961                 samba_cv_HAVE_WRFILE_KEYTAB,[
2962     AC_TRY_RUN([
2963 #include<krb5.h>
2964   main()
2965   {
2966     krb5_context context;
2967     krb5_keytab keytab;
2968
2969     krb5_init_context(&context);
2970     if (krb5_kt_resolve(context, "WRFILE:api", &keytab))
2971       exit(0);
2972     exit(1);
2973   }],
2974   samba_cv_HAVE_WRFILE_KEYTAB=no,
2975   samba_cv_HAVE_WRFILE_KEYTAB=yes)])
2976
2977   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
2978       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
2979                [Whether the WRFILE:-keytab is supported])
2980   fi
2981
2982   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
2983                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
2984     AC_TRY_COMPILE([#include <krb5.h>],
2985     [
2986     krb5_context context;
2987     krb5_principal principal;
2988     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
2989     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
2990     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
2991
2992   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
2993     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
2994               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
2995   fi
2996
2997 LIBS="$ac_save_LIBS"
2998 fi
2999
3000 ########################################################
3001 # Compile experimental passdb backends?
3002 # (pdb_xml, pdb_mysql, pdb_pgsql)
3003 AC_MSG_CHECKING(whether to build experimental passdb libraries)
3004 AC_ARG_WITH(expsam,
3005 [  --with-expsam=<list>    Include experimental passdb libraries (default=no)]
3006 [                          Valid choices include (comma separated list): ]
3007 [                              xml, mysql & pgsql],
3008 [ expsam_pdb_modules=`echo "$withval" | sed 's/,/ /g'`
3009   if test "z$expsam_pdb_modules" = "zyes"; then
3010     expsam_pdb_modules="xml mysql pgsql"
3011   fi
3012   AC_MSG_RESULT($expsam_pdb_modules)
3013   for i in $expsam_pdb_modules
3014   do 
3015     case "$i" in
3016     xml|all|yes)
3017       ## pdb_xml
3018           AM_PATH_XML2([2.0.0],[default_shared_modules="$default_shared_modules pdb_xml"],[AC_MSG_ERROR([Can't find XML libraries while XML support is requested])])
3019       CFLAGS="$CFLAGS $XML_CFLAGS"
3020       ;;
3021     mysql|all|yes)
3022       ## pdb_mysql
3023           AM_PATH_MYSQL([default_shared_modules="$default_shared_modules pdb_mysql"],[AC_MSG_ERROR([Can't find MySQL libraries while MySQL support is requested])])
3024       CFLAGS="$CFLAGS $MYSQL_CFLAGS"
3025       ;;
3026      pgsql|all|yes)
3027       ## pdb_pgsql
3028       AM_PATH_PGSQL([default_shared_modules="$default_shared_modules pdb_pgsql"],[])
3029       CFLAGS="$CFLAGS $PGSQL_CFLAGS"
3030       ;;
3031     no)
3032       ;;
3033     *)
3034       echo "Unknown module name \"$i\"!  Exiting..."
3035       exit 1
3036       ;;
3037     esac
3038   done ],
3039   AC_MSG_RESULT(no)
3040 )
3041
3042 #################################################
3043 # check for automount support
3044 AC_MSG_CHECKING(whether to use automount)
3045 AC_ARG_WITH(automount,
3046 [  --with-automount        Include automount support (default=no)],
3047 [ case "$withval" in
3048   yes)
3049     AC_MSG_RESULT(yes)
3050     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
3051     ;;
3052   *)
3053     AC_MSG_RESULT(no)
3054     ;;
3055   esac ],
3056   AC_MSG_RESULT(no)
3057 )
3058
3059 #################################################
3060 # check for smbmount support
3061 AC_MSG_CHECKING(whether to use smbmount)
3062 AC_ARG_WITH(smbmount,
3063 [  --with-smbmount         Include smbmount (Linux only) support (default=no)],
3064 [ case "$withval" in
3065   yes)
3066         case "$host_os" in
3067         *linux*)
3068                 AC_MSG_RESULT(yes)
3069                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
3070                 EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
3071                 ;;
3072         *)
3073                 AC_MSG_ERROR(not on a linux system!)
3074                 ;;
3075         esac
3076     ;;
3077   *)
3078     AC_MSG_RESULT(no)
3079     ;;
3080   esac ],
3081   AC_MSG_RESULT(no)
3082 )
3083
3084
3085
3086 #################################################
3087 # check for a PAM clear-text auth, accounts, password and session support
3088 with_pam_for_crypt=no
3089 AC_MSG_CHECKING(whether to use PAM)
3090 AC_ARG_WITH(pam,
3091 [  --with-pam              Include PAM support (default=no)],
3092 [ case "$withval" in
3093   yes)
3094     AC_MSG_RESULT(yes)
3095     if test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3096        if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
3097           if test x"$ac_cv_header_security__pam_macros_h" = x"no"; then
3098              AC_MSG_ERROR(--with-pam specified but no PAM headers found)
3099           fi
3100        fi
3101     fi
3102     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
3103     AUTH_LIBS="$AUTH_LIBS -lpam"
3104     with_pam_for_crypt=yes
3105     ;;
3106   *)
3107     AC_MSG_RESULT(no)
3108     ;;
3109   esac ],
3110   AC_MSG_RESULT(no)
3111 )
3112
3113 # we can't build a pam module if we don't have pam.
3114 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
3115
3116 #################################################
3117 # check for pam_smbpass support
3118 AC_MSG_CHECKING(whether to use pam_smbpass)
3119 AC_ARG_WITH(pam_smbpass,
3120 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
3121 [ case "$withval" in
3122   yes)
3123     AC_MSG_RESULT(yes)
3124
3125        # Conditions under which pam_smbpass should not be built.
3126
3127        if test x$PICFLAGS = x; then
3128           AC_MSG_ERROR([No support for PIC code])
3129        elif test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3130           AC_MSG_ERROR([No security/pam_appl.h found])
3131        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
3132           AC_MSG_ERROR([No libpam found])
3133        else
3134           AUTH_LIBS="$AUTH_LIBS -lpam"
3135           SHLIB_PROGS="$SHLIB_PROGS bin/pam_smbpass.$SHLIBEXT"
3136        fi
3137     ;;
3138   *)
3139     AC_MSG_RESULT(no)
3140     ;;
3141   esac ],
3142   AC_MSG_RESULT(no)
3143 )
3144
3145
3146 ###############################################
3147 # test for where we get crypt() from
3148 AC_SEARCH_LIBS(crypt, [crypt],
3149   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
3150   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
3151
3152 ##
3153 ## moved after the check for -lcrypt in order to
3154 ## ensure that the necessary libraries are included
3155 ## check checking for truncated salt.  Wrapped by the
3156 ## $with_pam_for_crypt variable as above   --jerry
3157 ##
3158 if test $with_pam_for_crypt = no; then
3159 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
3160 crypt_LIBS="$LIBS"
3161 LIBS="$AUTH_LIBS $LIBS"
3162 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
3163         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
3164 LIBS="$crypt_LIBS"])
3165 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
3166         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
3167 fi
3168 fi
3169
3170
3171 ########################################################################################
3172 ##
3173 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
3174 ##
3175 ########################################################################################
3176
3177 #################################################
3178 # check for a LDAP password database configuration backwards compatibility
3179 AC_MSG_CHECKING(whether to use LDAP SAM 2.2 compatible configuration)
3180 AC_ARG_WITH(ldapsam,
3181 [  --with-ldapsam          Include LDAP SAM 2.2 compatible configuration (default=no)],
3182 [ case "$withval" in
3183   yes)
3184     AC_MSG_RESULT(yes)
3185     AC_DEFINE(WITH_LDAP_SAMCONFIG,1,[Whether to include 2.2 compatible LDAP SAM configuration])
3186     ;;
3187   *)
3188     AC_MSG_RESULT(no)
3189     ;;
3190   esac ],
3191   AC_MSG_RESULT(no)
3192 )
3193
3194 ########################################################################################
3195 ##
3196 ## END OF TESTS FOR SAM BACKENDS.  
3197 ##
3198 ########################################################################################
3199
3200 #################################################
3201 # check for a NISPLUS_HOME support 
3202 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
3203 AC_ARG_WITH(nisplus-home,
3204 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
3205 [ case "$withval" in
3206   yes)
3207     AC_MSG_RESULT(yes)
3208     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
3209     ;;
3210   *)
3211     AC_MSG_RESULT(no)
3212     ;;
3213   esac ],
3214   AC_MSG_RESULT(no)
3215 )
3216
3217 #################################################
3218 # check for syslog logging
3219 AC_MSG_CHECKING(whether to use syslog logging)
3220 AC_ARG_WITH(syslog,
3221 [  --with-syslog           Include experimental SYSLOG support (default=no)],
3222 [ case "$withval" in
3223   yes)
3224     AC_MSG_RESULT(yes)
3225     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
3226     ;;
3227   *)
3228     AC_MSG_RESULT(no)
3229     ;;
3230   esac ],
3231   AC_MSG_RESULT(no)
3232 )
3233
3234 #################################################
3235 # check for a shared memory profiling support
3236 AC_MSG_CHECKING(whether to use profiling)
3237 AC_ARG_WITH(profiling-data,
3238 [  --with-profiling-data   Include gathering source code profile information (default=no)],
3239 [ case "$withval" in
3240   yes)
3241     AC_MSG_RESULT(yes)
3242     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
3243     ;;
3244   *)
3245     AC_MSG_RESULT(no)
3246     ;;
3247   esac ],
3248   AC_MSG_RESULT(no)
3249 )
3250
3251
3252 #################################################
3253 # check for experimental disk-quotas support
3254
3255 samba_cv_WITH_QUOTAS=auto
3256 samba_cv_TRY_QUOTAS=no
3257 samba_cv_RUN_QUOTA_TESTS=auto
3258 samba_cv_WITH_SYS_QUOTAS=auto
3259 samba_cv_TRY_SYS_QUOTAS=no
3260 samba_cv_SYSQUOTA_FOUND=no;
3261
3262 AC_MSG_CHECKING(whether to try disk-quotas support)
3263 AC_ARG_WITH(quotas,
3264 [  --with-quotas           Include disk-quota support (default=no)],
3265 [ case "$withval" in
3266   yes)
3267     AC_MSG_RESULT(yes)
3268     samba_cv_WITH_QUOTAS=yes
3269     samba_cv_TRY_QUOTAS=yes
3270     samba_cv_RUN_QUOTA_TESTS=yes
3271     #set sys quotas to auto in this case
3272     samba_cv_TRY_SYS_QUOTAS=auto
3273     ;;
3274   auto)
3275     AC_MSG_RESULT(auto)
3276     samba_cv_WITH_QUOTAS=auto
3277     samba_cv_TRY_QUOTAS=auto
3278     samba_cv_RUN_QUOTA_TESTS=auto
3279     #set sys quotas to auto in this case
3280     samba_cv_TRY_SYS_QUOTAS=auto
3281     ;;
3282   no)
3283     AC_MSG_RESULT(no)
3284     samba_cv_WITH_QUOTAS=no
3285     samba_cv_TRY_QUOTAS=no
3286     samba_cv_RUN_QUOTA_TESTS=no
3287     ;;
3288   *)
3289     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3290     ;;
3291   esac ],
3292   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3293 )
3294
3295 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
3296 AC_ARG_WITH(sys-quotas,
3297 [  --with-sys-quotas       Include lib/sysquotas.c support (default=auto)],
3298 [ case "$withval" in
3299   yes)
3300     AC_MSG_RESULT(yes)
3301     samba_cv_WITH_SYS_QUOTAS=yes
3302     samba_cv_TRY_SYS_QUOTAS=yes
3303     samba_cv_RUN_QUOTA_TESTS=yes
3304     ;;
3305   auto)
3306     AC_MSG_RESULT(auto)
3307     samba_cv_WITH_SYS_QUOTAS=auto
3308     samba_cv_TRY_SYS_QUOTAS=auto
3309     samba_cv_RUN_QUOTA_TESTS=auto
3310     ;;
3311   no)
3312     AC_MSG_RESULT(no)
3313     samba_cv_WITH_SYS_QUOTAS=no
3314     samba_cv_TRY_SYS_QUOTAS=no
3315     ;;
3316   *)
3317     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3318     ;;
3319   esac ],
3320   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3321 )
3322
3323 if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
3324 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
3325   case "$host_os" in
3326         *linux*)
3327             AC_MSG_RESULT(yes)
3328             samba_cv_TRY_SYS_QUOTAS=yes
3329             samba_cv_RUN_QUOTA_TESTS=yes
3330             samba_cv_SYSQUOTA_FOUND=yes
3331             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
3332             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
3333             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
3334             samba_cv_found_xfs_header=yes
3335             ;;
3336         *)
3337             AC_MSG_RESULT(no)
3338             samba_cv_TRY_SYS_QUOTAS=no
3339             ;;
3340   esac
3341 fi
3342
3343 #############################################
3344 # only check for quota stuff if --with-quotas
3345 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
3346
3347 # some broken header files need this
3348 AC_CHECK_HEADER(asm/types.h,[
3349             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
3350             AC_ADD_INCLUDE(<asm/types.h>)
3351             ])
3352
3353 # For quotas on Veritas VxFS filesystems
3354 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
3355
3356 # For sys/quota.h and linux/quota.h
3357 AC_CHECK_HEADERS(sys/quota.h)
3358
3359 if test x"$samba_cv_found_xfs_header" != x"yes"; then
3360 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
3361 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
3362 AC_TRY_COMPILE([
3363 #include "confdefs.h"
3364 #ifdef HAVE_SYS_TYPES_H
3365 #include <sys/types.h>
3366 #endif
3367 #ifdef HAVE_ASM_TYPES_H
3368 #include <asm/types.h>
3369 #endif
3370 #include <sys/quota.h>
3371 ],[int i = Q_XGETQUOTA;],
3372 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
3373 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
3374         samba_cv_found_xfs_header=yes
3375 fi
3376 fi
3377
3378 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX 
3379 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
3380 AC_TRY_COMPILE([
3381 #include "confdefs.h"
3382 #ifdef HAVE_SYS_QUOTA_H
3383 #include <sys/quota.h>
3384 #endif
3385 ],[
3386 struct dqblk D;
3387 D.dqb_fsoftlimit = 0;],
3388 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
3389 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
3390         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
3391 fi
3392
3393 ##################
3394 # look for a working quota system
3395
3396 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3397 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
3398 AC_TRY_RUN_STRICT([
3399 #define HAVE_QUOTACTL_4A 1
3400 #define AUTOCONF_TEST 1
3401 #include "confdefs.h"
3402 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3403            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
3404 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
3405     samba_cv_SYSQUOTA_FOUND=yes;
3406     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
3407     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
3408 fi
3409 fi
3410
3411 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3412 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
3413 AC_TRY_RUN_STRICT([
3414 #define HAVE_QUOTACTL_4B 1
3415 #define AUTOCONF_TEST 1
3416 #include "confdefs.h"
3417 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3418            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
3419 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
3420     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
3421     samba_cv_SYSQUOTA_FOUND=yes;
3422     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
3423     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
3424 fi
3425 fi
3426
3427 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3428 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
3429 AC_TRY_RUN_STRICT([
3430 #define HAVE_QUOTACTL_3 1
3431 #define AUTOCONF_TEST 1
3432 #include "confdefs.h"
3433 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3434            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
3435 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
3436     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
3437     samba_cv_SYSQUOTA_FOUND=yes;
3438     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
3439     samba_cv_sysquotas_file="lib/sysquotas_3.c"
3440 fi
3441 fi
3442
3443 #################################################
3444 # check for mntent.h and struct mntent
3445 AC_CHECK_HEADERS(mntent.h)
3446 #################################################
3447 # check for setmntent,getmntent,endmntent
3448 AC_CHECK_FUNCS(setmntent getmntent endmntent)
3449
3450 #################################################
3451 # check for devnm.h and struct mntent
3452 AC_CHECK_HEADERS(devnm.h)
3453 #################################################
3454 # check for devnm
3455 AC_CHECK_FUNCS(devnm)
3456
3457 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
3458     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3459         # if --with-sys-quotas=yes then build it 
3460         # you have can use the get/set quota command smb.conf
3461         # options then
3462         samba_cv_SYSQUOTA_FOUND=auto
3463     fi
3464     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
3465         # if --with-sys-quotas=yes then build it 
3466         # you have can use the get/set quota command smb.conf
3467         # options then
3468         samba_cv_TRY_SYS_QUOTAS=auto
3469     fi
3470 fi
3471
3472 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
3473 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
3474 SAVE_CPPFLAGS="$CPPFLAGS"
3475 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3476 AC_TRY_COMPILE([
3477 #include "confdefs.h"
3478 #define NO_PROTO_H 1
3479 #define NO_CONFIG_H 1
3480 #define HAVE_SYS_QUOTAS 1
3481 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
3482 #include "${srcdir-.}/lib/sysquotas.c"
3483 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
3484 CPPFLAGS="$SAVE_CPPFLAGS"
3485 ])
3486 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
3487 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
3488     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then 
3489         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3490         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
3491         samba_cv_WE_USE_SYS_QUOTAS=yes
3492         AC_MSG_RESULT(yes)
3493     else
3494         AC_MSG_RESULT(no)
3495     fi
3496 fi
3497 fi
3498
3499 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
3500 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
3501 SAVE_CPPFLAGS="$CPPFLAGS"
3502 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3503 AC_TRY_COMPILE([
3504 #include "confdefs.h"
3505 #define NO_PROTO_H 1
3506 #define NO_CONFIG_H 1
3507 #define HAVE_SYS_QUOTAS 1
3508 #define HAVE_XFS_QUOTAS 1
3509 #include "${srcdir-.}/lib/sysquotas_xfs.c"
3510 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
3511 CPPFLAGS="$SAVE_CPPFLAGS"
3512 ])
3513 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
3514     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
3515         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
3516     fi
3517 fi
3518 fi
3519
3520 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
3521 SAVE_CPPFLAGS="$CPPFLAGS"
3522 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3523 AC_TRY_COMPILE([
3524 #include "confdefs.h"
3525 #define NO_PROTO_H 1
3526 #define NO_CONFIG_H 1
3527 #include "${srcdir-.}/smbd/quotas.c"
3528 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
3529 CPPFLAGS="$SAVE_CPPFLAGS"
3530 ])
3531 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
3532 AC_MSG_CHECKING(whether to use the old quota support)
3533     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
3534       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
3535         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3536         AC_MSG_RESULT(yes)
3537       else
3538         AC_MSG_RESULT(no)
3539       fi
3540     else
3541       AC_MSG_RESULT(no)
3542     fi
3543 fi
3544
3545 ####################
3546 # End of quota check samba_cv_RUN_QUOTA_TESTS
3547 fi
3548
3549 #################################################
3550 # check for experimental utmp accounting
3551
3552 AC_MSG_CHECKING(whether to support utmp accounting)
3553 WITH_UTMP=yes
3554 AC_ARG_WITH(utmp,
3555 [  --with-utmp             Include utmp accounting (default, if supported by OS)],
3556 [ case "$withval" in
3557   no)
3558                 WITH_UTMP=no
3559                 ;;
3560   *)
3561                 WITH_UTMP=yes
3562                 ;;
3563   esac ],
3564 )
3565
3566 # utmp requires utmp.h
3567 # Note similar check earlier, when checking utmp details.
3568
3569 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
3570         utmp_no_reason=", no utmp.h on $host_os"
3571         WITH_UTMP=no
3572 fi
3573
3574 # Display test results
3575
3576 if test x"$WITH_UTMP" = x"yes"; then
3577         AC_MSG_RESULT(yes)
3578         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
3579 else
3580         AC_MSG_RESULT(no$utmp_no_reason)
3581 fi
3582
3583 #################################################
3584 # choose native language(s) of man pages
3585 AC_MSG_CHECKING(chosen man pages' language(s))
3586 AC_ARG_WITH(manpages-langs,
3587 [  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
3588 [ case "$withval" in
3589   yes|no)
3590     AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
3591     manlangs="en"
3592   ;;
3593   *)
3594     manlangs="$withval"
3595   ;;
3596   esac
3597
3598   AC_MSG_RESULT($manlangs)
3599   manlangs=`echo $manlangs | sed "s/,/ /g"`   # replacing commas with spaces to produce a list
3600   AC_SUBST(manlangs)],
3601
3602   [manlangs="en"
3603   AC_MSG_RESULT($manlangs)
3604   AC_SUBST(manlangs)]
3605 )
3606
3607 #################################################
3608 # should we build libsmbclient?
3609
3610 INSTALLCLIENTCMD_SH=:
3611 INSTALLCLIENTCMD_A=:
3612 INSTALLCLIENT=
3613 LIBSMBCLIENT_SHARED=
3614 LIBSMBCLIENT=
3615 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
3616 AC_ARG_WITH(libsmbclient,
3617 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
3618 [ case "$withval" in
3619   no) 
3620      AC_MSG_RESULT(no)
3621      ;;
3622   *)
3623      if test $BLDSHARED = true; then
3624         INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3625         ## build the static version of libsmbclient as well
3626         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3627         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3628         LIBSMBCLIENT=libsmbclient
3629         AC_MSG_RESULT(yes)
3630      else
3631         enable_static=yes
3632         AC_MSG_RESULT(no shared library support -- will supply static library)
3633      fi
3634      if test $enable_static = yes; then
3635         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3636         LIBSMBCLIENT=libsmbclient
3637      fi
3638      INSTALLCLIENT=installclientlib
3639      ;;
3640   esac ],
3641 [
3642 # if unspecified, default is to built it iff possible.
3643   if test $BLDSHARED = true; then
3644      INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3645      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3646      LIBSMBCLIENT=libsmbclient
3647      AC_MSG_RESULT(yes)
3648    else
3649      enable_static=yes
3650      AC_MSG_RESULT(no shared library support -- will supply static library)
3651    fi
3652    if test $enable_static = yes; then
3653      INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3654      LIBSMBCLIENT=libsmbclient
3655   fi]
3656   INSTALLCLIENT=installclientlib
3657 )
3658
3659
3660 #################################################
3661 # these tests are taken from the GNU fileutils package
3662 AC_CHECKING(how to get filesystem space usage)
3663 space=no
3664
3665 # Test for statvfs64.
3666 if test $space = no; then
3667   # SVR4
3668   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,