r890: convert samba4 to use [u]int8_t instead of [u]int8
[jelmer/samba4-debian.git] / source / build / m4 / rewrite.m4
1 dnl Checks for programs.
2
3 AC_PATH_PROG(PERL, perl)
4 if test x"$PERL" = x""; then
5         AC_MSG_WARN([No version of perl was not found!])
6         AC_MSG_ERROR([Please Install perl from http://www.perl.com/])
7 fi
8 if test x"$debug" = x"yes";then
9         PERL="$PERL -W"
10 fi
11
12 AC_PROG_CC
13 AC_PROG_INSTALL
14
15 # compile with optimization and without debugging by default, but
16 # allow people to set their own preference.
17 if test "x$CFLAGS" = x
18 then
19   CFLAGS="-O ${CFLAGS}"
20 fi
21
22 dnl Check if we use GNU ld
23 LD=ld
24 AC_PROG_LD_GNU
25
26 dnl needed before AC_TRY_COMPILE
27 AC_ISC_POSIX
28
29 dnl look for executable suffix
30 AC_EXEEXT
31
32 dnl Check if C compiler understands -c and -o at the same time
33 AC_PROG_CC_C_O
34 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
35       BROKEN_CC=
36 else
37       BROKEN_CC=#
38 fi
39 AC_SUBST(BROKEN_CC)
40
41 AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
42         dnl Check whether the compiler can generate precompiled headers
43         touch conftest.h
44         if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
45                 samba_cv_precompiled_headers=yes
46         else
47                 samba_cv_precompiled_headers=no
48         fi])
49 PCH_AVAILABLE="#"
50 if test x"$samba_cv_precompiled_headers" = x"yes"; then
51         PCH_AVAILABLE=""
52 fi
53 AC_SUBST(PCH_AVAILABLE)
54
55
56 dnl Check if the C compiler understands volatile (it should, being ANSI).
57 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
58     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
59         samba_cv_volatile=yes,samba_cv_volatile=no)])
60 if test x"$samba_cv_volatile" = x"yes"; then
61    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
62 fi
63
64
65 AC_CANONICAL_SYSTEM
66
67 dnl Add #include for broken IRIX header files
68   case "$host_os" in
69         *irix6*) AC_ADD_INCLUDE(<standards.h>)
70         ;;
71 esac
72
73 AC_VALIDATE_CACHE_SYSTEM_TYPE
74
75 DYNEXP=
76
77 AC_HEADER_STDC
78 AC_CHECK_HEADERS(stdbool.h)
79
80 AC_CHECK_SIZEOF(short,cross)
81 AC_CHECK_SIZEOF(int,cross)
82 AC_CHECK_SIZEOF(long,cross)
83 AC_CHECK_SIZEOF(long long,cross)
84 if test x"$ac_cv_type_long_long" != x"yes";then
85     AC_MSG_ERROR([Sorry we need type 'long long'])
86 fi
87 if test $ac_cv_sizeof_long_long -lt 8;then
88     AC_MSG_ERROR([Sorry we need sizeof(long long) >= 8])
89 fi
90 AC_CHECK_TYPE(_Bool)
91
92 #
93 # Config CPPFLAG settings for strange OS's that must be set
94 # before other tests.
95 #
96 case "$host_os" in
97 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
98     *hpux*)
99     
100       AC_PROG_CC_FLAG(Ae)
101       # mmap on HPUX is completely broken...
102       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
103       if test $ac_cv_prog_cc_Ae = yes; then
104         CPPFLAGS="$CPPFLAGS -Ae"
105       fi
106 #
107 # Defines needed for HPUX support.
108 # HPUX has bigcrypt but (sometimes?) doesn't use it for
109 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
110 #
111       case `uname -r` in
112                         *9*|*10*)
113                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
114                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
115                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
116                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
117                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
118                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
119                                 ;;
120                         *11*)
121                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
122                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
123                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
124                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
125                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
126                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
127                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
128                                 ;;
129       esac
130       DYNEXP="-Wl,-E"
131       ;;
132
133 #
134 # CRAY Unicos has broken const handling
135        *unicos*)
136           AC_MSG_RESULT([disabling const])
137           CPPFLAGS="$CPPFLAGS -Dconst="
138           ;;
139         
140 #
141 # AIX4.x doesn't even admit to having large
142 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
143 #
144     *aix4*)
145           AC_MSG_RESULT([enabling large file support])
146       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
147           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
148       ;;    
149 #
150 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
151 # to the existance of large files..
152 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
153 # recommendations on large file support, however it makes the
154 # compile work using gcc 2.7 and 2.8, whereas using the Sun
155 # recommendation makes the compile fail on gcc2.7. JRA.
156 #
157         *solaris*)
158                 case `uname -r` in
159                         5.0*|5.1*|5.2*|5.3*|5.5*)
160                                 AC_MSG_RESULT([no large file support])
161                                 ;;
162                         5.*)
163                         AC_MSG_RESULT([enabling large file support])
164                         if test "$ac_cv_prog_gcc" = yes; then
165                                 ${CC-cc} -v >conftest.c 2>&1
166                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
167                                 rm -fr conftest.c
168                                 case "$ac_cv_gcc_compiler_version_number" in
169                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
170                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
171                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
172                                                 ;;
173                                         *)
174                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
175                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
176                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
177                                                 ;;
178                                 esac
179                         else
180                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
181                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
182                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
183                         fi
184                         ;;
185                 esac
186                 ;;
187 #
188 # VOS may need to have POSIX support and System V compatibility enabled.
189 #
190     *vos*)
191     case "$CPPFLAGS" in
192           *-D_POSIX_C_SOURCE*)
193                 ;;
194           *)
195                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=199506L"
196                 AC_DEFINE(_POSIX_C_SOURCE, 199506L, [Whether to enable POSIX support])
197                 ;;
198     esac
199     case "$CPPFLAGS" in
200           *-D_SYSV*|*-D_SVID_SOURCE*)
201                 ;;
202           *)
203                 CPPFLAGS="$CPPFLAGS -D_SYSV"
204                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
205     esac
206     ;;
207 #
208 # Tests needed for SINIX large file support.
209 #
210     *sysv4*)
211       if test $host = mips-sni-sysv4 ; then
212         AC_MSG_CHECKING([for LFS support])
213         old_CPPFLAGS="$CPPFLAGS"
214         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
215         AC_TRY_RUN([
216 #include <unistd.h>
217 main () {
218 #if _LFS64_LARGEFILE == 1
219 exit(0);
220 #else
221 exit(1);
222 #endif
223 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
224         CPPFLAGS="$old_CPPFLAGS"
225         if test x$SINIX_LFS_SUPPORT = xyes ; then
226           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
227                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
228           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
229           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
230           LIBS="`getconf LFS64_LIBS` $LIBS"
231         fi
232       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
233       fi
234     ;;
235
236 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
237 #
238     *linux*)
239         AC_MSG_CHECKING([for LFS support])
240         old_CPPFLAGS="$CPPFLAGS"
241         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
242        AC_TRY_RUN([
243 #include <unistd.h>
244 #include <sys/utsname.h>
245 #include <string.h>
246 #include <stdlib.h>
247 main() {
248 #if _LFS64_LARGEFILE == 1
249        struct utsname uts;
250        char *release;
251        int major, minor;
252
253        /* Ensure this is glibc 2.2 or higher */
254 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
255        int libc_major = __GLIBC__;
256        int libc_minor = __GLIBC_MINOR__;
257
258        if (libc_major < 2)
259               exit(1);
260        if (libc_minor < 2)
261               exit(1);
262 #endif
263
264        /* Ensure this is kernel 2.4 or higher */
265
266        uname(&uts);
267        release = uts.release;
268        major = atoi(strsep(&release, "."));
269        minor = atoi(strsep(&release, "."));
270
271        if (major > 2 || (major == 2 && minor > 3))
272                exit(0);
273        exit(1);
274 #else
275        exit(1);
276 #endif
277 }
278 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
279         CPPFLAGS="$old_CPPFLAGS"
280         if test x$LINUX_LFS_SUPPORT = xyes ; then
281           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
282                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
283           AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
284           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
285         fi
286        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
287                 ;;
288
289     *hurd*)
290         AC_MSG_CHECKING([for LFS support])
291         old_CPPFLAGS="$CPPFLAGS"
292         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
293         AC_TRY_RUN([
294 #include <unistd.h>
295 main () {
296 #if _LFS64_LARGEFILE == 1
297 exit(0);
298 #else
299 exit(1);
300 #endif
301 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
302         CPPFLAGS="$old_CPPFLAGS"
303         if test x$GLIBC_LFS_SUPPORT = xyes ; then
304           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
305                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
306           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
307         fi
308       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
309     ;;
310
311 esac
312
313
314 AC_HEADER_DIRENT
315 AC_HEADER_TIME
316 AC_HEADER_SYS_WAIT
317 AC_CHECK_HEADERS(arpa/inet.h sys/select.h fcntl.h sys/fcntl.h sys/time.h)
318 AC_CHECK_HEADERS(utime.h grp.h sys/id.h limits.h memory.h net/if.h)
319 AC_CHECK_HEADERS(compat.h)
320 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
321 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
322 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
323 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
324 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h dlfcn.h)
325 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
326
327 #
328 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
329 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
330 #
331 case "$host_os" in
332     *hpux*)
333                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
334                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
335                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
336                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
337                 fi
338         ;;
339 esac
340
341 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
342 AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
343 AC_CHECK_HEADERS(stropts.h)
344 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
345 AC_CHECK_HEADERS(sys/acl.h)
346
347
348 AC_C_CONST
349 AC_C_INLINE
350 AC_C_BIGENDIAN
351 AC_C_CHAR_UNSIGNED
352
353 AC_TYPE_SIGNAL
354 AC_TYPE_UID_T
355 AC_TYPE_MODE_T
356 AC_TYPE_OFF_T
357 AC_TYPE_SIZE_T
358 AC_TYPE_PID_T
359 AC_STRUCT_ST_RDEV
360 AC_DIRENT_D_OFF
361 AC_CHECK_TYPE(ino_t,unsigned)
362 AC_CHECK_TYPE(loff_t,off_t)
363 AC_CHECK_TYPE(offset_t,loff_t)
364 AC_CHECK_TYPE(ssize_t, int)
365 AC_CHECK_TYPE(wchar_t, unsigned short)
366 AC_CHECK_TYPE(uint_t, unsigned int)
367 AC_CHECK_TYPE(int8_t, signed char)
368 AC_CHECK_TYPE(uint8_t, unsigned char)
369 AC_CHECK_TYPE(int16_t, short)
370 AC_CHECK_TYPE(uint16_t, unsigned short)
371 AC_CHECK_TYPE(int32_t, long)
372 AC_CHECK_TYPE(uint32_t, unsigned long)
373 AC_CHECK_TYPE(int64_t, long long)
374 AC_CHECK_TYPE(uint64_t, unsigned long long)
375
376 ############################################
377 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
378 AC_SEARCH_LIBS(dlopen, [dl])
379 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
380
381 ############################################
382 # check if the compiler can do immediate structures
383 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
384     AC_TRY_COMPILE([
385 #include <stdio.h>],
386 [
387    typedef struct {unsigned x;} FOOBAR;
388    #define X_FOOBAR(x) ((FOOBAR) { x })
389    #define FOO_ONE X_FOOBAR(1)
390    FOOBAR f = FOO_ONE;   
391    static struct {
392         FOOBAR y; 
393         } f2[] = {
394                 {FOO_ONE}
395         };   
396 ],
397         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
398 if test x"$samba_cv_immediate_structures" = x"yes"; then
399    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
400 fi
401
402 ############################################
403 # check for unix domain sockets
404 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
405     AC_TRY_COMPILE([
406 #include <sys/types.h>
407 #include <stdlib.h>
408 #include <stddef.h>
409 #include <sys/socket.h>
410 #include <sys/un.h>],
411 [
412   struct sockaddr_un sunaddr; 
413   sunaddr.sun_family = AF_UNIX;
414 ],
415         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
416 if test x"$samba_cv_unixsocket" = x"yes"; then
417    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
418 fi
419
420
421 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
422     AC_TRY_COMPILE([
423 #include <sys/types.h>
424 #if STDC_HEADERS
425 #include <stdlib.h>
426 #include <stddef.h>
427 #endif
428 #include <sys/socket.h>],[socklen_t i = 0],
429         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
430 if test x"$samba_cv_socklen_t" = x"yes"; then
431    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
432 fi
433
434 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
435     AC_TRY_COMPILE([
436 #include <sys/types.h>
437 #if STDC_HEADERS
438 #include <stdlib.h>
439 #include <stddef.h>
440 #endif
441 #include <signal.h>],[sig_atomic_t i = 0],
442         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
443 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
444    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
445 fi
446
447 # stupid headers have the functions but no declaration. grrrr.
448 AC_HAVE_DECL(errno, [#include <errno.h>])
449 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
450 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
451 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
452 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
453 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
454 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
455
456 # and glibc has setresuid under linux but the function does
457 # nothing until kernel 2.1.44! very dumb.
458 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
459     AC_TRY_RUN([#include <errno.h>
460 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
461         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
462 if test x"$samba_cv_have_setresuid" = x"yes"; then
463     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
464 fi
465
466 # Do the same check for setresguid...
467 #
468 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
469     AC_TRY_RUN([#include <unistd.h>
470 #include <errno.h>
471 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
472         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
473 if test x"$samba_cv_have_setresgid" = x"yes"; then
474     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
475 fi
476
477 AC_FUNC_MEMCMP
478
479 # The following test taken from the cvs sources
480 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
481 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
482 # libsocket.so which has a bad implementation of gethostbyname (it
483 # only looks in /etc/hosts), so we only look for -lsocket if we need
484 # it.
485 AC_CHECK_FUNCS(connect)
486 if test x"$ac_cv_func_connect" = x"no"; then
487     case "$LIBS" in
488     *-lnsl*) ;;
489     *) AC_CHECK_LIB(nsl_s, printf) ;;
490     esac
491     case "$LIBS" in
492     *-lnsl*) ;;
493     *) AC_CHECK_LIB(nsl, printf) ;;
494     esac
495     case "$LIBS" in
496     *-lsocket*) ;;
497     *) AC_CHECK_LIB(socket, connect) ;;
498     esac
499     case "$LIBS" in
500     *-linet*) ;;
501     *) AC_CHECK_LIB(inet, connect) ;;
502     esac
503     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
504     dnl has been cached.
505     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
506        test x"$ac_cv_lib_inet_connect" = x"yes"; then
507         # ac_cv_func_connect=yes
508         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
509         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
510     fi
511 fi
512
513 ###############################################
514 # test for where we get yp_get_default_domain() from
515 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
516 AC_CHECK_FUNCS(yp_get_default_domain)
517
518 # Check if we have execl, if not we need to compile smbrun.
519 AC_CHECK_FUNCS(execl)
520 if test x"$ac_cv_func_execl" = x"no"; then
521     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
522 fi
523
524 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
525 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
526 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
527 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
528 AC_CHECK_FUNCS(initgroups select rdchk getgrnam getgrent pathconf realpath)
529 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
530 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
531 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
532 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
533 AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm)
534 # setbuffer, shmget, shm_open are needed for smbtorture
535 AC_CHECK_FUNCS(setbuffer shmget shm_open)
536
537 # syscall() is needed for smbwrapper.
538 AC_CHECK_FUNCS(syscall)
539
540 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
541 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
542 AC_CHECK_FUNCS(__getcwd _getcwd)
543 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
544 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
545 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
546 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
547 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
548 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
549 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
550 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
551 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
552 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
553 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
554
555 #
556 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
557 #
558
559 if test x$ac_cv_func_stat64 = xno ; then
560   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
561   AC_TRY_LINK([
562 #if defined(HAVE_UNISTD_H)
563 #include <unistd.h>
564 #endif
565 #include <sys/stat.h>
566 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
567   AC_MSG_RESULT([$ac_cv_func_stat64])
568   if test x$ac_cv_func_stat64 = xyes ; then
569     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
570   fi
571 fi
572
573 if test x$ac_cv_func_lstat64 = xno ; then
574   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
575   AC_TRY_LINK([
576 #if defined(HAVE_UNISTD_H)
577 #include <unistd.h>
578 #endif
579 #include <sys/stat.h>
580 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
581   AC_MSG_RESULT([$ac_cv_func_lstat64])
582   if test x$ac_cv_func_lstat64 = xyes ; then
583     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
584   fi
585 fi
586
587 if test x$ac_cv_func_fstat64 = xno ; then
588   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
589   AC_TRY_LINK([
590 #if defined(HAVE_UNISTD_H)
591 #include <unistd.h>
592 #endif
593 #include <sys/stat.h>
594 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
595   AC_MSG_RESULT([$ac_cv_func_fstat64])
596   if test x$ac_cv_func_fstat64 = xyes ; then
597     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
598   fi
599 fi
600
601 #####################################
602 # we might need the resolv library on some systems
603 AC_CHECK_LIB(resolv, dn_expand)
604
605 #
606 # Check for the functions putprpwnam, set_auth_parameters,
607 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
608 # Needed for OSF1 and HPUX.
609 #
610
611 AC_LIBTESTFUNC(security, putprpwnam)
612 AC_LIBTESTFUNC(sec, putprpwnam)
613
614 AC_LIBTESTFUNC(security, set_auth_parameters)
615 AC_LIBTESTFUNC(sec, set_auth_parameters)
616
617 # UnixWare 7.x has its getspnam in -lgen
618 AC_LIBTESTFUNC(gen, getspnam)
619
620 AC_LIBTESTFUNC(security, getspnam)
621 AC_LIBTESTFUNC(sec, getspnam)
622
623 AC_LIBTESTFUNC(security, bigcrypt)
624 AC_LIBTESTFUNC(sec, bigcrypt)
625
626 AC_LIBTESTFUNC(security, getprpwnam)
627 AC_LIBTESTFUNC(sec, getprpwnam)
628
629 # Assume non-shared by default and override below
630 BLDSHARED="false"
631
632 # these are the defaults, good for lots of systems
633 HOST_OS="$host_os"
634 LDSHFLAGS="-shared"
635 SONAMEFLAG="#"
636 SHLD="\${CC}"
637 PICFLAG=""
638 PICSUFFIX="po"
639 POBAD_CC="#"
640 SHLIBEXT="so"
641
642 if test "$enable_shared" = "yes"; then
643   # this bit needs to be modified for each OS that is suported by
644   # smbwrapper. You need to specify how to created a shared library and
645   # how to compile C code to produce PIC object files
646
647   AC_MSG_CHECKING([ability to build shared libraries])
648
649   # and these are for particular systems
650   case "$host_os" in
651                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
652                         BLDSHARED="true"
653                         LDSHFLAGS="-shared" 
654                         DYNEXP="-Wl,--export-dynamic"
655                         PICFLAG="-fPIC"
656                         SONAMEFLAG="-Wl,-soname="
657                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
658                         ;;
659                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
660                         BLDSHARED="true"
661                         LDSHFLAGS="-G"
662                         SONAMEFLAG="-h "
663                         if test "${GCC}" = "yes"; then
664                                 PICFLAG="-fPIC"
665                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
666                                         DYNEXP="-Wl,-E"
667                                 fi
668                         else
669                                 PICFLAG="-KPIC"
670                                 ## ${CFLAGS} added for building 64-bit shared 
671                                 ## libs using Sun's Compiler
672                                 LDSHFLAGS="-G \${CFLAGS}"
673                                 POBAD_CC=""
674                                 PICSUFFIX="po.o"
675                         fi
676                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
677                         ;;
678                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
679                         BLDSHARED="true"
680                         LDSHFLAGS="-G"
681                         SONAMEFLAG="-Wl,-h,"
682                         PICFLAG="-KPIC"   # Is this correct for SunOS
683                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
684                         ;;
685                 *netbsd* | *freebsd*)  BLDSHARED="true"
686                         LDSHFLAGS="-shared"
687                         DYNEXP="-Wl,--export-dynamic"
688                         SONAMEFLAG="-Wl,-soname,"
689                         PICFLAG="-fPIC -DPIC"
690                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
691                         ;;
692                 *openbsd*)  BLDSHARED="true"
693                         LDSHFLAGS="-shared"
694                         DYNEXP="-Wl,-Bdynamic"
695                         SONAMEFLAG="-Wl,-soname,"
696                         PICFLAG="-fPIC"
697                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
698                         ;;
699                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
700                         case "$host_os" in
701                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
702                         ;;
703                         esac
704                         ATTEMPT_WRAP32_BUILD=yes
705                         BLDSHARED="true"
706                         LDSHFLAGS="-set_version sgi1.0 -shared"
707                         SONAMEFLAG="-soname "
708                         SHLD="\${LD}"
709                         if test "${GCC}" = "yes"; then
710                                 PICFLAG="-fPIC"
711                         else 
712                                 PICFLAG="-KPIC"
713                         fi
714                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
715                         ;;
716                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
717                         BLDSHARED="true"
718                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
719                         DYNEXP="-Wl,-brtl,-bexpall"
720                         PICFLAG="-O2"
721                         if test "${GCC}" != "yes"; then
722                                 ## for funky AIX compiler using strncpy()
723                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
724                         fi
725
726                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
727                         ;;
728                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
729                         SHLIBEXT="sl"
730                         # Use special PIC flags for the native HP-UX compiler.
731                         if test $ac_cv_prog_cc_Ae = yes; then
732                                 BLDSHARED="true"
733                                 SHLD="/usr/bin/ld"
734                                 LDSHFLAGS="-B symbolic -b -z"
735                                 SONAMEFLAG="+h "
736                                 PICFLAG="+z"
737                         fi
738                         DYNEXP="-Wl,-E"
739                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
740                         ;;
741                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
742                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
743                         ;;
744                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
745                         BLDSHARED="true"
746                         LDSHFLAGS="-shared"
747                         SONAMEFLAG="-Wl,-soname,"
748                         PICFLAG="-fPIC"
749                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
750                         ;;
751                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
752                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
753                         ;;
754                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
755                         BLDSHARED="true"
756                         LDSHFLAGS="-shared"
757                         SONAMEFLAG="-Wl,-soname,"
758                         PICFLAG="-KPIC"
759                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
760                         ;;
761                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
762                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
763                         ;;
764                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
765                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
766                         ;;
767                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
768                         case "$host" in
769                                 *-univel-*)     if [ test "$GCC" != yes ]; then
770                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
771                                         fi
772                                         LDSHFLAGS="-G"
773                                         DYNEXP="-Bexport"
774                                 ;;
775                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
776                         esac
777                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
778                         ;;
779
780                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
781                         if [ test "$GCC" != yes ]; then
782                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
783                         fi
784                         LDSHFLAGS="-G"
785                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
786                         ;;
787                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
788                         BLDSHARED="false"
789                         LDSHFLAGS=""
790                         ;;
791                 *)
792                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
793                         ;;
794   esac
795   AC_SUBST(DYNEXP)
796   AC_MSG_RESULT($BLDSHARED)
797   AC_MSG_CHECKING([linker flags for shared libraries])
798   AC_MSG_RESULT([$LDSHFLAGS])
799   AC_MSG_CHECKING([compiler flags for position-independent code])
800   AC_MSG_RESULT([$PICFLAGS])
801 fi
802
803 #######################################################
804 # test whether building a shared library actually works
805 if test $BLDSHARED = true; then
806 AC_CACHE_CHECK([whether building shared libraries actually works], 
807                [ac_cv_shlib_works],[
808    ac_cv_shlib_works=no
809    # try building a trivial shared library
810    if test "$PICSUFFIX" = "po"; then
811      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/build/tests/shlib.c &&
812        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
813        ac_cv_shlib_works=yes
814    else
815      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.$PICSUFFIX ${srcdir-.}/build/tests/shlib.c &&
816        mv shlib.$PICSUFFIX shlib.po &&
817        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
818        ac_cv_shlib_works=yes
819    fi
820    rm -f shlib.so shlib.po
821 ])
822 if test $ac_cv_shlib_works = no; then
823    BLDSHARED=false
824 fi
825 fi
826
827 ################
828
829 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
830 AC_TRY_RUN([#include <stdio.h>
831 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
832 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
833 if test x"$samba_cv_have_longlong" = x"yes"; then
834     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
835 fi
836
837 #
838 # Check if the compiler supports the LL prefix on long long integers.
839 # AIX needs this.
840
841 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
842     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
843         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
844 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
845    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
846 fi
847
848   
849 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
850 AC_TRY_RUN([#include <stdio.h>
851 #include <sys/stat.h>
852 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
853 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
854 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
855     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
856 fi
857
858 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
859 AC_TRY_RUN([
860 #if defined(HAVE_UNISTD_H)
861 #include <unistd.h>
862 #endif
863 #include <stdio.h>
864 #include <sys/stat.h>
865 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
866 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
867 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
868     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
869 fi
870
871 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
872 AC_TRY_RUN([#include <stdio.h>
873 #include <sys/stat.h>
874 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
875 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
876 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
877     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
878 fi
879
880 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
881 AC_TRY_RUN([
882 #if defined(HAVE_UNISTD_H)
883 #include <unistd.h>
884 #endif
885 #include <stdio.h>
886 #include <sys/stat.h>
887 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
888 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
889 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
890     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
891 fi
892
893 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
894 AC_TRY_RUN([
895 #if defined(HAVE_UNISTD_H)
896 #include <unistd.h>
897 #endif
898 #include <stdio.h>
899 #include <sys/stat.h>
900 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
901 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
902 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
903     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
904 fi
905
906 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
907 AC_TRY_COMPILE([
908 #if defined(HAVE_UNISTD_H)
909 #include <unistd.h>
910 #endif
911 #include <sys/types.h>
912 #include <dirent.h>],
913 [struct dirent64 de;],
914 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
915 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
916     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
917 fi
918
919 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
920 AC_TRY_RUN([
921 #if defined(HAVE_UNISTD_H)
922 #include <unistd.h>
923 #endif
924 #include <sys/types.h>
925 main() { dev_t dev; int i = major(dev); return 0; }],
926 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
927 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
928     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
929 fi
930
931 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
932 AC_TRY_RUN([
933 #if defined(HAVE_UNISTD_H)
934 #include <unistd.h>
935 #endif
936 #include <sys/types.h>
937 main() { dev_t dev; int i = minor(dev); return 0; }],
938 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
939 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
940     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
941 fi
942
943 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
944 AC_TRY_RUN([#include <stdio.h>
945 main() { char c; c=250; exit((c > 0)?0:1); }],
946 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
947 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
948     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
949 fi
950
951 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
952 AC_TRY_COMPILE([#include <sys/types.h>
953 #include <sys/socket.h>
954 #include <netinet/in.h>],
955 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
956 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
957 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
958     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
959 fi
960
961 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
962 AC_TRY_COMPILE([#include <sys/types.h>
963 #include <dirent.h>
964 void seekdir(DIR *d, long loc) { return; }],[return 0;],
965 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
966 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
967     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
968 fi
969
970 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
971 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
972 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
973 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
974     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
975 fi
976
977 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
978 AC_TRY_RUN([
979 #include <sys/time.h>
980 #include <unistd.h>
981 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
982            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
983 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
984     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
985 fi
986
987 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE_VA_COPY,[
988 AC_TRY_LINK([#include <stdarg.h>
989 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
990 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
991 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
992     AC_DEFINE(HAVE_VA_COPY,1,[Whether __va_copy() is available])
993 fi
994
995 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
996 AC_TRY_RUN([
997 #include <sys/types.h>
998 #include <stdarg.h>
999 void foo(const char *format, ...) { 
1000        va_list ap;
1001        int len;
1002        char buf[5];
1003
1004        va_start(ap, format);
1005        len = vsnprintf(buf, 0, format, ap);
1006        va_end(ap);
1007        if (len != 5) exit(1);
1008
1009        va_start(ap, format);
1010        len = vsnprintf(0, 0, format, ap);
1011        va_end(ap);
1012        if (len != 5) exit(1);
1013
1014        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1015
1016        exit(0);
1017 }
1018 main() { foo("hello"); }
1019 ],
1020 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1021 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1022     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1023 fi
1024
1025 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1026 AC_TRY_RUN([#include <sys/types.h>
1027 #include <dirent.h>
1028 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1029 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1030 di->d_name[0] == 0) exit(0); exit(1);} ],
1031 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1032 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1033     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1034 fi
1035
1036 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1037 AC_TRY_COMPILE([#include <sys/types.h>
1038 #include <utime.h>],
1039 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1040 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1041 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1042     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1043 fi
1044
1045 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1046 AC_TRY_RUN([
1047 #include <sys/types.h>
1048 #include <fcntl.h>
1049 #ifndef F_GETLEASE
1050 #define F_GETLEASE      1025
1051 #endif
1052 main() {
1053        int fd = open("/dev/null", O_RDONLY);
1054        return fcntl(fd, F_GETLEASE, 0) == -1;
1055 }
1056 ],
1057 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1058 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1059     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1060 fi
1061
1062 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1063 AC_TRY_RUN([
1064 #include <sys/types.h>
1065 #include <fcntl.h>
1066 #include <signal.h>
1067 #ifndef F_NOTIFY
1068 #define F_NOTIFY 1026
1069 #endif
1070 main() {
1071         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1072 }
1073 ],
1074 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1075 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1076     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1077 fi
1078
1079 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1080 AC_TRY_RUN([
1081 #include <sys/types.h>
1082 #include <fcntl.h>
1083 #include <signal.h>
1084 #include <sys/file.h>
1085 #ifndef LOCK_MAND
1086 #define LOCK_MAND       32
1087 #define LOCK_READ       64
1088 #endif
1089 main() {
1090         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1091 }
1092 ],
1093 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1094 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1095     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1096 fi
1097
1098
1099
1100
1101 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1102 AC_TRY_COMPILE([#include <sys/types.h>
1103 #include <fcntl.h>],
1104 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1105 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1106 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1107     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1108 fi
1109
1110 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1111 AC_TRY_RUN([#include <sys/types.h>
1112 #include <sys/capability.h>
1113 main() {
1114  cap_t cap;
1115  if ((cap = cap_get_proc()) == NULL)
1116    exit(1);
1117  cap->cap_effective |= CAP_NETWORK_MGT;
1118  cap->cap_inheritable |= CAP_NETWORK_MGT;
1119  cap_set_proc(cap);
1120  exit(0);
1121 }
1122 ],
1123 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1124 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1125     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1126 fi
1127
1128 AC_MSG_CHECKING([for test routines])
1129 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
1130            AC_MSG_RESULT(yes),
1131            AC_MSG_ERROR([cant find test code. Aborting config]),
1132            AC_MSG_WARN([cannot run when cross-compiling]))
1133
1134 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1135 AC_TRY_RUN([#include "${srcdir-.}/build/tests/ftruncate.c"],
1136            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1137 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1138     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
1139 fi
1140
1141 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1142 AC_TRY_RUN([#include "${srcdir-.}/build/tests/unixsock.c"],
1143            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1144            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1145            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1146 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1147 then
1148     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1149 fi
1150
1151 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1152 AC_TRY_RUN([#include "${srcdir-.}/build/tests/getgroups.c"],
1153            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1154 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1155     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
1156 fi
1157
1158 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1159 SAVE_CPPFLAGS="$CPPFLAGS"
1160 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
1161 AC_TRY_COMPILE([
1162 #define REPLACE_GETPASS 1
1163 #define NO_CONFIG_H 1
1164 #define main dont_declare_main
1165 #include "${srcdir-.}/lib/getsmbpass.c"
1166 #undef main
1167 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1168 CPPFLAGS="$SAVE_CPPFLAGS"
1169 ])
1170 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1171         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
1172 fi
1173
1174 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1175 AC_TRY_RUN([
1176 #include <stdio.h>
1177 #include <sys/types.h>
1178 #include <netinet/in.h>
1179 #ifdef HAVE_ARPA_INET_H
1180 #include <arpa/inet.h>
1181 #endif
1182 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1183 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1184     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1185 exit(1);}],
1186            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1187 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1188     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
1189 fi
1190
1191 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1192 AC_TRY_RUN([#include <stdlib.h>
1193 #include <sys/types.h>
1194 #include <sys/stat.h>
1195 #include <unistd.h>
1196 main() { 
1197   struct stat st;
1198   char tpl[20]="/tmp/test.XXXXXX"; 
1199   int fd = mkstemp(tpl); 
1200   if (fd == -1) exit(1);
1201   unlink(tpl);
1202   if (fstat(fd, &st) != 0) exit(1);
1203   if ((st.st_mode & 0777) != 0600) exit(1);
1204   exit(0);
1205 }],
1206 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1207 samba_cv_HAVE_SECURE_MKSTEMP=no,
1208 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1209 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1210     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
1211 fi
1212
1213 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1214 AC_TRY_RUN([#include <unistd.h>
1215 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1216 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1217 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1218     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
1219 fi
1220
1221 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1222 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1223            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1224 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1225     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
1226 else
1227     AC_MSG_WARN(running as non-root will disable some tests)
1228 fi
1229
1230 ##################
1231 # look for a method of finding the list of network interfaces
1232 iface=no;
1233 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1234 AC_TRY_RUN([
1235 #define HAVE_IFACE_AIX 1
1236 #define AUTOCONF_TEST 1
1237 #include "confdefs.h"
1238 #include "${srcdir-.}/lib/interfaces.c"],
1239            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1240 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1241     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
1242 fi
1243
1244 if test $iface = no; then
1245 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1246 AC_TRY_RUN([
1247 #define HAVE_IFACE_IFCONF 1
1248 #define AUTOCONF_TEST 1
1249 #include "confdefs.h"
1250 #include "${srcdir-.}/lib/interfaces.c"],
1251            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1252 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1253     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
1254 fi
1255 fi
1256
1257 if test $iface = no; then
1258 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1259 AC_TRY_RUN([
1260 #define HAVE_IFACE_IFREQ 1
1261 #define AUTOCONF_TEST 1
1262 #include "confdefs.h"
1263 #include "${srcdir-.}/lib/interfaces.c"],
1264            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1265 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1266     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
1267 fi
1268 fi
1269
1270
1271 ################################################
1272 # look for a method of setting the effective uid
1273 seteuid=no;
1274 if test $seteuid = no; then
1275 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1276 AC_TRY_RUN([
1277 #define AUTOCONF_TEST 1
1278 #define USE_SETRESUID 1
1279 #include "confdefs.h"
1280 #include "${srcdir-.}/lib/util_sec.c"],
1281            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1282 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1283     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
1284 fi
1285 fi
1286
1287
1288 if test $seteuid = no; then
1289 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1290 AC_TRY_RUN([
1291 #define AUTOCONF_TEST 1
1292 #define USE_SETREUID 1
1293 #include "confdefs.h"
1294 #include "${srcdir-.}/lib/util_sec.c"],
1295            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1296 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1297     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
1298 fi
1299 fi
1300
1301 if test $seteuid = no; then
1302 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1303 AC_TRY_RUN([
1304 #define AUTOCONF_TEST 1
1305 #define USE_SETEUID 1
1306 #include "confdefs.h"
1307 #include "${srcdir-.}/lib/util_sec.c"],
1308            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1309 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1310     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
1311 fi
1312 fi
1313
1314 if test $seteuid = no; then
1315 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1316 AC_TRY_RUN([
1317 #define AUTOCONF_TEST 1
1318 #define USE_SETUIDX 1
1319 #include "confdefs.h"
1320 #include "${srcdir-.}/lib/util_sec.c"],
1321            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1322 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1323     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
1324 fi
1325 fi
1326
1327
1328 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1329 AC_TRY_RUN([#include "${srcdir-.}/build/tests/shared_mmap.c"],
1330            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1331 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1332     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
1333 fi
1334
1335 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1336 AC_TRY_RUN([#include "${srcdir-.}/build/tests/ftruncroot.c"],
1337            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1338 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1339     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
1340 fi
1341
1342 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1343 AC_TRY_RUN([#include "${srcdir-.}/build/tests/fcntl_lock.c"],
1344            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1345 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1346     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
1347 fi
1348
1349 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1350 AC_TRY_RUN([#include "${srcdir-.}/build/tests/fcntl_lock64.c"],
1351            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1352 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1353     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
1354
1355 else
1356
1357 dnl
1358 dnl Don't check for 64 bit fcntl locking if we know that the
1359 dnl glibc2.1 broken check has succeeded.
1360 dnl 
1361
1362   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1363   AC_TRY_RUN([
1364 #if defined(HAVE_UNISTD_H)
1365 #include <unistd.h>
1366 #endif
1367 #include <stdio.h>
1368 #include <stdlib.h>
1369
1370 #ifdef HAVE_FCNTL_H
1371 #include <fcntl.h>
1372 #endif
1373
1374 #ifdef HAVE_SYS_FCNTL_H
1375 #include <sys/fcntl.h>
1376 #endif
1377 main() { struct flock64 fl64;
1378 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1379 exit(0);
1380 #else
1381 exit(1);
1382 #endif
1383 }],
1384        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1385
1386   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1387       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
1388   fi
1389 fi
1390
1391 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1392 AC_TRY_COMPILE([#include <sys/types.h>
1393 #include <sys/stat.h>
1394 #include <unistd.h>],
1395 [struct stat st;  st.st_blocks = 0;],
1396 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1397 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1398     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
1399 fi 
1400
1401 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
1402 AC_TRY_COMPILE([#include <sys/types.h>
1403 #include <sys/stat.h>
1404 #include <unistd.h>],
1405 [struct stat st;  st.st_blksize = 0;],
1406 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
1407 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
1408     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
1409 fi
1410
1411 case "$host_os" in
1412 *linux*)
1413 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1414 AC_TRY_COMPILE([
1415 #ifdef HAVE_SYS_VFS_H
1416 #include <sys/vfs.h>
1417 #endif
1418 #ifdef HAVE_SYS_CAPABILITY_H
1419 #include <sys/capability.h>
1420 #endif
1421 ],[int i;],
1422    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1423 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1424    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
1425 fi
1426 ;;
1427 esac
1428
1429 AC_SUBST(SMBD_EXTRA_OBJS)
1430 AC_SUBST(SMBD_EXTRA_LIBS)
1431
1432 SMB_INCLUDE_M4(libads/config.m4)
1433
1434 ###############################################
1435 # test for where we get crypt() from
1436 AC_SEARCH_LIBS(crypt, [crypt],
1437   [test "$ac_cv_search_crypt" = "none required" || AUTHLIBS="-lcrypt $AUTHLIBS"
1438   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
1439
1440 ##
1441 ## moved after the check for -lcrypt in order to
1442 ## ensure that the necessary libraries are included
1443 ## check checking for truncated salt.  Wrapped by the
1444 ## $with_pam_for_crypt variable as above   --jerry
1445 ##
1446 if test x"$with_pam_for_crypt" != x"yes"; then
1447 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1448 crypt_LIBS="$LIBS"
1449 LIBS="$AUTHLIBS $LIBS"
1450 AC_TRY_RUN([#include "${srcdir-.}/build/tests/crypttest.c"],
1451         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
1452 LIBS="$crypt_LIBS"])
1453 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1454         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
1455 fi
1456 fi
1457
1458 #################################################
1459 # these tests are taken from the GNU fileutils package
1460 AC_CHECKING(how to get filesystem space usage)
1461 space=no
1462
1463 # Test for statvfs64.
1464 if test $space = no; then
1465   # SVR4
1466   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
1467   [AC_TRY_RUN([
1468 #if defined(HAVE_UNISTD_H)
1469 #include <unistd.h>
1470 #endif
1471 #include <sys/types.h>
1472 #include <sys/statvfs.h>
1473   main ()
1474   {
1475     struct statvfs64 fsd;
1476     exit (statvfs64 (".", &fsd));
1477   }],
1478   fu_cv_sys_stat_statvfs64=yes,
1479   fu_cv_sys_stat_statvfs64=no,
1480   fu_cv_sys_stat_statvfs64=cross)])
1481   if test $fu_cv_sys_stat_statvfs64 = yes; then
1482     space=yes
1483     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
1484   fi
1485 fi
1486
1487 # Perform only the link test since it seems there are no variants of the
1488 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
1489 # because that got a false positive on SCO OSR5.  Adding the declaration
1490 # of a `struct statvfs' causes this test to fail (as it should) on such
1491 # systems.  That system is reported to work fine with STAT_STATFS4 which
1492 # is what it gets when this test fails.
1493 if test $space = no; then
1494   # SVR4
1495   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
1496                  [AC_TRY_LINK([#include <sys/types.h>
1497 #include <sys/statvfs.h>],
1498                               [struct statvfs fsd; statvfs (0, &fsd);],
1499                               fu_cv_sys_stat_statvfs=yes,
1500                               fu_cv_sys_stat_statvfs=no)])
1501   if test $fu_cv_sys_stat_statvfs = yes; then
1502     space=yes
1503     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
1504   fi
1505 fi
1506
1507 if test $space = no; then
1508   # DEC Alpha running OSF/1
1509   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
1510   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
1511   [AC_TRY_RUN([
1512 #include <sys/param.h>
1513 #include <sys/types.h>
1514 #include <sys/mount.h>
1515   main ()
1516   {
1517     struct statfs fsd;
1518     fsd.f_fsize = 0;
1519     exit (statfs (".", &fsd, sizeof (struct statfs)));
1520   }],
1521   fu_cv_sys_stat_statfs3_osf1=yes,
1522   fu_cv_sys_stat_statfs3_osf1=no,
1523   fu_cv_sys_stat_statfs3_osf1=no)])
1524   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
1525   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
1526     space=yes
1527     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
1528   fi
1529 fi
1530
1531 if test $space = no; then
1532 # AIX
1533   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
1534 member (AIX, 4.3BSD)])
1535   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
1536   [AC_TRY_RUN([
1537 #ifdef HAVE_SYS_PARAM_H
1538 #include <sys/param.h>
1539 #endif
1540 #ifdef HAVE_SYS_MOUNT_H
1541 #include <sys/mount.h>
1542 #endif
1543 #ifdef HAVE_SYS_VFS_H
1544 #include <sys/vfs.h>
1545 #endif
1546   main ()
1547   {
1548   struct statfs fsd;
1549   fsd.f_bsize = 0;
1550   exit (statfs (".", &fsd));
1551   }],
1552   fu_cv_sys_stat_statfs2_bsize=yes,
1553   fu_cv_sys_stat_statfs2_bsize=no,
1554   fu_cv_sys_stat_statfs2_bsize=no)])
1555   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
1556   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
1557     space=yes
1558     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
1559   fi
1560 fi
1561
1562 if test $space = no; then
1563 # SVR3
1564   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
1565   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
1566   [AC_TRY_RUN([#include <sys/types.h>
1567 #include <sys/statfs.h>
1568   main ()
1569   {
1570   struct statfs fsd;
1571   exit (statfs (".", &fsd, sizeof fsd, 0));
1572   }],
1573     fu_cv_sys_stat_statfs4=yes,
1574     fu_cv_sys_stat_statfs4=no,
1575     fu_cv_sys_stat_statfs4=no)])
1576   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
1577   if test $fu_cv_sys_stat_statfs4 = yes; then
1578     space=yes
1579     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
1580   fi
1581 fi
1582
1583 if test $space = no; then
1584 # 4.4BSD and NetBSD
1585   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
1586 member (4.4BSD and NetBSD)])
1587   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
1588   [AC_TRY_RUN([#include <sys/types.h>
1589 #ifdef HAVE_SYS_PARAM_H
1590 #include <sys/param.h>
1591 #endif
1592 #ifdef HAVE_SYS_MOUNT_H
1593 #include <sys/mount.h>
1594 #endif
1595   main ()
1596   {
1597   struct statfs fsd;
1598   fsd.f_fsize = 0;
1599   exit (statfs (".", &fsd));
1600   }],
1601   fu_cv_sys_stat_statfs2_fsize=yes,
1602   fu_cv_sys_stat_statfs2_fsize=no,
1603   fu_cv_sys_stat_statfs2_fsize=no)])
1604   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
1605   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
1606     space=yes
1607         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
1608   fi
1609 fi
1610
1611 if test $space = no; then
1612   # Ultrix
1613   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
1614   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
1615   [AC_TRY_RUN([#include <sys/types.h>
1616 #ifdef HAVE_SYS_PARAM_H
1617 #include <sys/param.h>
1618 #endif
1619 #ifdef HAVE_SYS_MOUNT_H
1620 #include <sys/mount.h>
1621 #endif
1622 #ifdef HAVE_SYS_FS_TYPES_H
1623 #include <sys/fs_types.h>
1624 #endif
1625   main ()
1626   {
1627   struct fs_data fsd;
1628   /* Ultrix's statfs returns 1 for success,
1629      0 for not mounted, -1 for failure.  */
1630   exit (statfs (".", &fsd) != 1);
1631   }],
1632   fu_cv_sys_stat_fs_data=yes,
1633   fu_cv_sys_stat_fs_data=no,
1634   fu_cv_sys_stat_fs_data=no)])
1635   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
1636   if test $fu_cv_sys_stat_fs_data = yes; then
1637     space=yes
1638     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
1639   fi
1640 fi
1641
1642 #
1643 # As a gating factor for large file support, in order to
1644 # use <4GB files we must have the following minimal support
1645 # available.
1646 # long long, and a 64 bit off_t or off64_t.
1647 # If we don't have all of these then disable large
1648 # file support.
1649 #
1650 AC_MSG_CHECKING([if large file support can be enabled])
1651 AC_TRY_COMPILE([
1652 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
1653 #include <sys/types.h>
1654 #else
1655 __COMPILE_ERROR_
1656 #endif
1657 ],
1658 [int i],
1659 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
1660 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
1661         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
1662 fi
1663 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
1664
1665 #######################################
1666 # Check for comparison_fn_t
1667 AC_CACHE_CHECK([for comparison_fn_t],samba_cv_HAVE_COMPARISON_FN_T,[
1668 AC_TRY_COMPILE([
1669 #include <stdlib.h>
1670 int list_find(const void *needle, 
1671               const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn)
1672 {
1673         return 1;
1674 }
1675 ],[],
1676 samba_cv_HAVE_COMPARISON_FN_T=yes,samba_cv_HAVE_COMPARISON_FN_T=no)
1677 ])
1678 if test x"$samba_cv_HAVE_COMPARISON_FN_T" = x"yes"; then
1679         AC_DEFINE(HAVE_COMPARISON_FN_T,1,[Whether or not we have comparison_fn_t])
1680 fi