0df2b7b65c7fc51c404b820c56b891518a37613b
[kamenim/samba.git] / source4 / 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
368 ############################################
369 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
370 AC_SEARCH_LIBS(dlopen, [dl])
371 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
372
373 ############################################
374 # check if the compiler can do immediate structures
375 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
376     AC_TRY_COMPILE([
377 #include <stdio.h>],
378 [
379    typedef struct {unsigned x;} FOOBAR;
380    #define X_FOOBAR(x) ((FOOBAR) { x })
381    #define FOO_ONE X_FOOBAR(1)
382    FOOBAR f = FOO_ONE;   
383    static struct {
384         FOOBAR y; 
385         } f2[] = {
386                 {FOO_ONE}
387         };   
388 ],
389         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
390 if test x"$samba_cv_immediate_structures" = x"yes"; then
391    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
392 fi
393
394 ############################################
395 # check for unix domain sockets
396 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
397     AC_TRY_COMPILE([
398 #include <sys/types.h>
399 #include <stdlib.h>
400 #include <stddef.h>
401 #include <sys/socket.h>
402 #include <sys/un.h>],
403 [
404   struct sockaddr_un sunaddr; 
405   sunaddr.sun_family = AF_UNIX;
406 ],
407         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
408 if test x"$samba_cv_unixsocket" = x"yes"; then
409    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
410 fi
411
412
413 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
414     AC_TRY_COMPILE([
415 #include <sys/types.h>
416 #if STDC_HEADERS
417 #include <stdlib.h>
418 #include <stddef.h>
419 #endif
420 #include <sys/socket.h>],[socklen_t i = 0],
421         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
422 if test x"$samba_cv_socklen_t" = x"yes"; then
423    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
424 fi
425
426 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
427     AC_TRY_COMPILE([
428 #include <sys/types.h>
429 #if STDC_HEADERS
430 #include <stdlib.h>
431 #include <stddef.h>
432 #endif
433 #include <signal.h>],[sig_atomic_t i = 0],
434         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
435 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
436    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
437 fi
438
439 # stupid headers have the functions but no declaration. grrrr.
440 AC_HAVE_DECL(errno, [#include <errno.h>])
441 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
442 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
443 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
444 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
445 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
446 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
447
448 # and glibc has setresuid under linux but the function does
449 # nothing until kernel 2.1.44! very dumb.
450 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
451     AC_TRY_RUN([#include <errno.h>
452 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
453         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
454 if test x"$samba_cv_have_setresuid" = x"yes"; then
455     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
456 fi
457
458 # Do the same check for setresguid...
459 #
460 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
461     AC_TRY_RUN([#include <unistd.h>
462 #include <errno.h>
463 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
464         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
465 if test x"$samba_cv_have_setresgid" = x"yes"; then
466     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
467 fi
468
469 AC_FUNC_MEMCMP
470
471 # The following test taken from the cvs sources
472 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
473 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
474 # libsocket.so which has a bad implementation of gethostbyname (it
475 # only looks in /etc/hosts), so we only look for -lsocket if we need
476 # it.
477 AC_CHECK_FUNCS(connect)
478 if test x"$ac_cv_func_connect" = x"no"; then
479     case "$LIBS" in
480     *-lnsl*) ;;
481     *) AC_CHECK_LIB(nsl_s, printf) ;;
482     esac
483     case "$LIBS" in
484     *-lnsl*) ;;
485     *) AC_CHECK_LIB(nsl, printf) ;;
486     esac
487     case "$LIBS" in
488     *-lsocket*) ;;
489     *) AC_CHECK_LIB(socket, connect) ;;
490     esac
491     case "$LIBS" in
492     *-linet*) ;;
493     *) AC_CHECK_LIB(inet, connect) ;;
494     esac
495     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
496     dnl has been cached.
497     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
498        test x"$ac_cv_lib_inet_connect" = x"yes"; then
499         # ac_cv_func_connect=yes
500         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
501         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
502     fi
503 fi
504
505 ###############################################
506 # test for where we get yp_get_default_domain() from
507 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
508 AC_CHECK_FUNCS(yp_get_default_domain)
509
510 # Check if we have execl, if not we need to compile smbrun.
511 AC_CHECK_FUNCS(execl)
512 if test x"$ac_cv_func_execl" = x"no"; then
513     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
514 fi
515
516 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
517 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
518 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
519 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
520 AC_CHECK_FUNCS(initgroups select rdchk getgrnam getgrent pathconf realpath)
521 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
522 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
523 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
524 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
525 AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm)
526 # setbuffer, shmget, shm_open are needed for smbtorture
527 AC_CHECK_FUNCS(setbuffer shmget shm_open)
528
529 # syscall() is needed for smbwrapper.
530 AC_CHECK_FUNCS(syscall)
531
532 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
533 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
534 AC_CHECK_FUNCS(__getcwd _getcwd)
535 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
536 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
537 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
538 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
539 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
540 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
541 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
542 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
543 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
544 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
545 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
546
547 #
548 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
549 #
550
551 if test x$ac_cv_func_stat64 = xno ; then
552   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
553   AC_TRY_LINK([
554 #if defined(HAVE_UNISTD_H)
555 #include <unistd.h>
556 #endif
557 #include <sys/stat.h>
558 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
559   AC_MSG_RESULT([$ac_cv_func_stat64])
560   if test x$ac_cv_func_stat64 = xyes ; then
561     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
562   fi
563 fi
564
565 if test x$ac_cv_func_lstat64 = xno ; then
566   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
567   AC_TRY_LINK([
568 #if defined(HAVE_UNISTD_H)
569 #include <unistd.h>
570 #endif
571 #include <sys/stat.h>
572 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
573   AC_MSG_RESULT([$ac_cv_func_lstat64])
574   if test x$ac_cv_func_lstat64 = xyes ; then
575     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
576   fi
577 fi
578
579 if test x$ac_cv_func_fstat64 = xno ; then
580   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
581   AC_TRY_LINK([
582 #if defined(HAVE_UNISTD_H)
583 #include <unistd.h>
584 #endif
585 #include <sys/stat.h>
586 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
587   AC_MSG_RESULT([$ac_cv_func_fstat64])
588   if test x$ac_cv_func_fstat64 = xyes ; then
589     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
590   fi
591 fi
592
593 #####################################
594 # we might need the resolv library on some systems
595 AC_CHECK_LIB(resolv, dn_expand)
596
597 #
598 # Check for the functions putprpwnam, set_auth_parameters,
599 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
600 # Needed for OSF1 and HPUX.
601 #
602
603 AC_LIBTESTFUNC(security, putprpwnam)
604 AC_LIBTESTFUNC(sec, putprpwnam)
605
606 AC_LIBTESTFUNC(security, set_auth_parameters)
607 AC_LIBTESTFUNC(sec, set_auth_parameters)
608
609 # UnixWare 7.x has its getspnam in -lgen
610 AC_LIBTESTFUNC(gen, getspnam)
611
612 AC_LIBTESTFUNC(security, getspnam)
613 AC_LIBTESTFUNC(sec, getspnam)
614
615 AC_LIBTESTFUNC(security, bigcrypt)
616 AC_LIBTESTFUNC(sec, bigcrypt)
617
618 AC_LIBTESTFUNC(security, getprpwnam)
619 AC_LIBTESTFUNC(sec, getprpwnam)
620
621 # Assume non-shared by default and override below
622 BLDSHARED="false"
623
624 # these are the defaults, good for lots of systems
625 HOST_OS="$host_os"
626 LDSHFLAGS="-shared"
627 SONAMEFLAG="#"
628 SHLD="\${CC}"
629 PICFLAG=""
630 PICSUFFIX="po"
631 POBAD_CC="#"
632 SHLIBEXT="so"
633
634 if test "$enable_shared" = "yes"; then
635   # this bit needs to be modified for each OS that is suported by
636   # smbwrapper. You need to specify how to created a shared library and
637   # how to compile C code to produce PIC object files
638
639   AC_MSG_CHECKING([ability to build shared libraries])
640
641   # and these are for particular systems
642   case "$host_os" in
643                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
644                         BLDSHARED="true"
645                         LDSHFLAGS="-shared" 
646                         DYNEXP="-Wl,--export-dynamic"
647                         PICFLAG="-fPIC"
648                         SONAMEFLAG="-Wl,-soname="
649                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
650                         ;;
651                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
652                         BLDSHARED="true"
653                         LDSHFLAGS="-G"
654                         SONAMEFLAG="-h "
655                         if test "${GCC}" = "yes"; then
656                                 PICFLAG="-fPIC"
657                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
658                                         DYNEXP="-Wl,-E"
659                                 fi
660                         else
661                                 PICFLAG="-KPIC"
662                                 ## ${CFLAGS} added for building 64-bit shared 
663                                 ## libs using Sun's Compiler
664                                 LDSHFLAGS="-G \${CFLAGS}"
665                                 POBAD_CC=""
666                                 PICSUFFIX="po.o"
667                         fi
668                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
669                         ;;
670                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
671                         BLDSHARED="true"
672                         LDSHFLAGS="-G"
673                         SONAMEFLAG="-Wl,-h,"
674                         PICFLAG="-KPIC"   # Is this correct for SunOS
675                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
676                         ;;
677                 *netbsd* | *freebsd*)  BLDSHARED="true"
678                         LDSHFLAGS="-shared"
679                         DYNEXP="-Wl,--export-dynamic"
680                         SONAMEFLAG="-Wl,-soname,"
681                         PICFLAG="-fPIC -DPIC"
682                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
683                         ;;
684                 *openbsd*)  BLDSHARED="true"
685                         LDSHFLAGS="-shared"
686                         DYNEXP="-Wl,-Bdynamic"
687                         SONAMEFLAG="-Wl,-soname,"
688                         PICFLAG="-fPIC"
689                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
690                         ;;
691                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
692                         case "$host_os" in
693                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
694                         ;;
695                         esac
696                         ATTEMPT_WRAP32_BUILD=yes
697                         BLDSHARED="true"
698                         LDSHFLAGS="-set_version sgi1.0 -shared"
699                         SONAMEFLAG="-soname "
700                         SHLD="\${LD}"
701                         if test "${GCC}" = "yes"; then
702                                 PICFLAG="-fPIC"
703                         else 
704                                 PICFLAG="-KPIC"
705                         fi
706                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
707                         ;;
708                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
709                         BLDSHARED="true"
710                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
711                         DYNEXP="-Wl,-brtl,-bexpall"
712                         PICFLAG="-O2"
713                         if test "${GCC}" != "yes"; then
714                                 ## for funky AIX compiler using strncpy()
715                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
716                         fi
717
718                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
719                         ;;
720                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
721                         SHLIBEXT="sl"
722                         # Use special PIC flags for the native HP-UX compiler.
723                         if test $ac_cv_prog_cc_Ae = yes; then
724                                 BLDSHARED="true"
725                                 SHLD="/usr/bin/ld"
726                                 LDSHFLAGS="-B symbolic -b -z"
727                                 SONAMEFLAG="+h "
728                                 PICFLAG="+z"
729                         fi
730                         DYNEXP="-Wl,-E"
731                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
732                         ;;
733                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
734                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
735                         ;;
736                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
737                         BLDSHARED="true"
738                         LDSHFLAGS="-shared"
739                         SONAMEFLAG="-Wl,-soname,"
740                         PICFLAG="-fPIC"
741                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
742                         ;;
743                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
744                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
745                         ;;
746                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
747                         BLDSHARED="true"
748                         LDSHFLAGS="-shared"
749                         SONAMEFLAG="-Wl,-soname,"
750                         PICFLAG="-KPIC"
751                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
752                         ;;
753                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
754                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
755                         ;;
756                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
757                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
758                         ;;
759                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
760                         case "$host" in
761                                 *-univel-*)     if [ test "$GCC" != yes ]; then
762                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
763                                         fi
764                                         LDSHFLAGS="-G"
765                                         DYNEXP="-Bexport"
766                                 ;;
767                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
768                         esac
769                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
770                         ;;
771
772                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
773                         if [ test "$GCC" != yes ]; then
774                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
775                         fi
776                         LDSHFLAGS="-G"
777                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
778                         ;;
779                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
780                         BLDSHARED="false"
781                         LDSHFLAGS=""
782                         ;;
783                 *)
784                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
785                         ;;
786   esac
787   AC_SUBST(DYNEXP)
788   AC_MSG_RESULT($BLDSHARED)
789   AC_MSG_CHECKING([linker flags for shared libraries])
790   AC_MSG_RESULT([$LDSHFLAGS])
791   AC_MSG_CHECKING([compiler flags for position-independent code])
792   AC_MSG_RESULT([$PICFLAGS])
793 fi
794
795 #######################################################
796 # test whether building a shared library actually works
797 if test $BLDSHARED = true; then
798 AC_CACHE_CHECK([whether building shared libraries actually works], 
799                [ac_cv_shlib_works],[
800    ac_cv_shlib_works=no
801    # try building a trivial shared library
802    if test "$PICSUFFIX" = "po"; then
803      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/build/tests/shlib.c &&
804        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
805        ac_cv_shlib_works=yes
806    else
807      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.$PICSUFFIX ${srcdir-.}/build/tests/shlib.c &&
808        mv shlib.$PICSUFFIX shlib.po &&
809        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
810        ac_cv_shlib_works=yes
811    fi
812    rm -f shlib.so shlib.po
813 ])
814 if test $ac_cv_shlib_works = no; then
815    BLDSHARED=false
816 fi
817 fi
818
819 ################
820
821 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
822 AC_TRY_RUN([#include <stdio.h>
823 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
824 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
825 if test x"$samba_cv_have_longlong" = x"yes"; then
826     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
827 fi
828
829 #
830 # Check if the compiler supports the LL prefix on long long integers.
831 # AIX needs this.
832
833 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
834     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
835         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
836 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
837    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
838 fi
839
840   
841 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
842 AC_TRY_RUN([#include <stdio.h>
843 #include <sys/stat.h>
844 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
845 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
846 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
847     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
848 fi
849
850 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
851 AC_TRY_RUN([
852 #if defined(HAVE_UNISTD_H)
853 #include <unistd.h>
854 #endif
855 #include <stdio.h>
856 #include <sys/stat.h>
857 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
858 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
859 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
860     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
861 fi
862
863 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
864 AC_TRY_RUN([#include <stdio.h>
865 #include <sys/stat.h>
866 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
867 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
868 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
869     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
870 fi
871
872 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
873 AC_TRY_RUN([
874 #if defined(HAVE_UNISTD_H)
875 #include <unistd.h>
876 #endif
877 #include <stdio.h>
878 #include <sys/stat.h>
879 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
880 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
881 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
882     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
883 fi
884
885 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
886 AC_TRY_RUN([
887 #if defined(HAVE_UNISTD_H)
888 #include <unistd.h>
889 #endif
890 #include <stdio.h>
891 #include <sys/stat.h>
892 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
893 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
894 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
895     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
896 fi
897
898 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
899 AC_TRY_COMPILE([
900 #if defined(HAVE_UNISTD_H)
901 #include <unistd.h>
902 #endif
903 #include <sys/types.h>
904 #include <dirent.h>],
905 [struct dirent64 de;],
906 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
907 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
908     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
909 fi
910
911 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
912 AC_TRY_RUN([
913 #if defined(HAVE_UNISTD_H)
914 #include <unistd.h>
915 #endif
916 #include <sys/types.h>
917 main() { dev_t dev; int i = major(dev); return 0; }],
918 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
919 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
920     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
921 fi
922
923 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
924 AC_TRY_RUN([
925 #if defined(HAVE_UNISTD_H)
926 #include <unistd.h>
927 #endif
928 #include <sys/types.h>
929 main() { dev_t dev; int i = minor(dev); return 0; }],
930 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
931 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
932     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
933 fi
934
935 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
936 AC_TRY_RUN([#include <stdio.h>
937 main() { char c; c=250; exit((c > 0)?0:1); }],
938 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
939 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
940     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
941 fi
942
943 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
944 AC_TRY_COMPILE([#include <sys/types.h>
945 #include <sys/socket.h>
946 #include <netinet/in.h>],
947 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
948 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
949 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
950     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
951 fi
952
953 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
954 AC_TRY_COMPILE([#include <sys/types.h>
955 #include <dirent.h>
956 void seekdir(DIR *d, long loc) { return; }],[return 0;],
957 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
958 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
959     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
960 fi
961
962 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
963 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
964 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
965 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
966     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
967 fi
968
969 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
970 AC_TRY_RUN([
971 #include <sys/time.h>
972 #include <unistd.h>
973 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
974            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
975 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
976     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
977 fi
978
979 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE_VA_COPY,[
980 AC_TRY_LINK([#include <stdarg.h>
981 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
982 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
983 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
984     AC_DEFINE(HAVE_VA_COPY,1,[Whether __va_copy() is available])
985 fi
986
987 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
988 AC_TRY_RUN([
989 #include <sys/types.h>
990 #include <stdarg.h>
991 void foo(const char *format, ...) { 
992        va_list ap;
993        int len;
994        char buf[5];
995
996        va_start(ap, format);
997        len = vsnprintf(buf, 0, format, ap);
998        va_end(ap);
999        if (len != 5) exit(1);
1000
1001        va_start(ap, format);
1002        len = vsnprintf(0, 0, format, ap);
1003        va_end(ap);
1004        if (len != 5) exit(1);
1005
1006        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1007
1008        exit(0);
1009 }
1010 main() { foo("hello"); }
1011 ],
1012 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1013 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1014     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1015 fi
1016
1017 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1018 AC_TRY_RUN([#include <sys/types.h>
1019 #include <dirent.h>
1020 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1021 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1022 di->d_name[0] == 0) exit(0); exit(1);} ],
1023 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1024 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1025     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1026 fi
1027
1028 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1029 AC_TRY_COMPILE([#include <sys/types.h>
1030 #include <utime.h>],
1031 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1032 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1033 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1034     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1035 fi
1036
1037 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1038 AC_TRY_RUN([
1039 #include <sys/types.h>
1040 #include <fcntl.h>
1041 #ifndef F_GETLEASE
1042 #define F_GETLEASE      1025
1043 #endif
1044 main() {
1045        int fd = open("/dev/null", O_RDONLY);
1046        return fcntl(fd, F_GETLEASE, 0) == -1;
1047 }
1048 ],
1049 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1050 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1051     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1052 fi
1053
1054 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1055 AC_TRY_RUN([
1056 #include <sys/types.h>
1057 #include <fcntl.h>
1058 #include <signal.h>
1059 #ifndef F_NOTIFY
1060 #define F_NOTIFY 1026
1061 #endif
1062 main() {
1063         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1064 }
1065 ],
1066 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1067 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1068     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1069 fi
1070
1071 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1072 AC_TRY_RUN([
1073 #include <sys/types.h>
1074 #include <fcntl.h>
1075 #include <signal.h>
1076 #include <sys/file.h>
1077 #ifndef LOCK_MAND
1078 #define LOCK_MAND       32
1079 #define LOCK_READ       64
1080 #endif
1081 main() {
1082         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1083 }
1084 ],
1085 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1086 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1087     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1088 fi
1089
1090
1091
1092
1093 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1094 AC_TRY_COMPILE([#include <sys/types.h>
1095 #include <fcntl.h>],
1096 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1097 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1098 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1099     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1100 fi
1101
1102 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1103 AC_TRY_RUN([#include <sys/types.h>
1104 #include <sys/capability.h>
1105 main() {
1106  cap_t cap;
1107  if ((cap = cap_get_proc()) == NULL)
1108    exit(1);
1109  cap->cap_effective |= CAP_NETWORK_MGT;
1110  cap->cap_inheritable |= CAP_NETWORK_MGT;
1111  cap_set_proc(cap);
1112  exit(0);
1113 }
1114 ],
1115 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1116 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1117     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1118 fi
1119
1120 AC_MSG_CHECKING([for test routines])
1121 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
1122            AC_MSG_RESULT(yes),
1123            AC_MSG_ERROR([cant find test code. Aborting config]),
1124            AC_MSG_WARN([cannot run when cross-compiling]))
1125
1126 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1127 AC_TRY_RUN([#include "${srcdir-.}/build/tests/ftruncate.c"],
1128            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1129 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1130     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
1131 fi
1132
1133 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1134 AC_TRY_RUN([#include "${srcdir-.}/build/tests/unixsock.c"],
1135            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1136            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1137            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1138 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1139 then
1140     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1141 fi
1142
1143 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1144 AC_TRY_RUN([#include "${srcdir-.}/build/tests/getgroups.c"],
1145            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1146 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1147     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
1148 fi
1149
1150 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1151 SAVE_CPPFLAGS="$CPPFLAGS"
1152 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
1153 AC_TRY_COMPILE([
1154 #define REPLACE_GETPASS 1
1155 #define NO_CONFIG_H 1
1156 #define main dont_declare_main
1157 #include "${srcdir-.}/lib/getsmbpass.c"
1158 #undef main
1159 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1160 CPPFLAGS="$SAVE_CPPFLAGS"
1161 ])
1162 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1163         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
1164 fi
1165
1166 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1167 AC_TRY_RUN([
1168 #include <stdio.h>
1169 #include <sys/types.h>
1170 #include <netinet/in.h>
1171 #ifdef HAVE_ARPA_INET_H
1172 #include <arpa/inet.h>
1173 #endif
1174 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1175 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1176     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1177 exit(1);}],
1178            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1179 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1180     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
1181 fi
1182
1183 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1184 AC_TRY_RUN([#include <stdlib.h>
1185 #include <sys/types.h>
1186 #include <sys/stat.h>
1187 #include <unistd.h>
1188 main() { 
1189   struct stat st;
1190   char tpl[20]="/tmp/test.XXXXXX"; 
1191   int fd = mkstemp(tpl); 
1192   if (fd == -1) exit(1);
1193   unlink(tpl);
1194   if (fstat(fd, &st) != 0) exit(1);
1195   if ((st.st_mode & 0777) != 0600) exit(1);
1196   exit(0);
1197 }],
1198 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1199 samba_cv_HAVE_SECURE_MKSTEMP=no,
1200 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1201 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1202     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
1203 fi
1204
1205 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1206 AC_TRY_RUN([#include <unistd.h>
1207 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1208 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1209 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1210     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
1211 fi
1212
1213 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1214 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1215            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1216 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1217     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
1218 else
1219     AC_MSG_WARN(running as non-root will disable some tests)
1220 fi
1221
1222 ##################
1223 # look for a method of finding the list of network interfaces
1224 iface=no;
1225 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1226 AC_TRY_RUN([
1227 #define HAVE_IFACE_AIX 1
1228 #define AUTOCONF_TEST 1
1229 #include "confdefs.h"
1230 #include "${srcdir-.}/lib/interfaces.c"],
1231            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1232 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1233     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
1234 fi
1235
1236 if test $iface = no; then
1237 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1238 AC_TRY_RUN([
1239 #define HAVE_IFACE_IFCONF 1
1240 #define AUTOCONF_TEST 1
1241 #include "confdefs.h"
1242 #include "${srcdir-.}/lib/interfaces.c"],
1243            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1244 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1245     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
1246 fi
1247 fi
1248
1249 if test $iface = no; then
1250 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1251 AC_TRY_RUN([
1252 #define HAVE_IFACE_IFREQ 1
1253 #define AUTOCONF_TEST 1
1254 #include "confdefs.h"
1255 #include "${srcdir-.}/lib/interfaces.c"],
1256            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1257 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1258     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
1259 fi
1260 fi
1261
1262
1263 ################################################
1264 # look for a method of setting the effective uid
1265 seteuid=no;
1266 if test $seteuid = no; then
1267 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1268 AC_TRY_RUN([
1269 #define AUTOCONF_TEST 1
1270 #define USE_SETRESUID 1
1271 #include "confdefs.h"
1272 #include "${srcdir-.}/lib/util_sec.c"],
1273            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1274 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1275     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
1276 fi
1277 fi
1278
1279
1280 if test $seteuid = no; then
1281 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1282 AC_TRY_RUN([
1283 #define AUTOCONF_TEST 1
1284 #define USE_SETREUID 1
1285 #include "confdefs.h"
1286 #include "${srcdir-.}/lib/util_sec.c"],
1287            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1288 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1289     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
1290 fi
1291 fi
1292
1293 if test $seteuid = no; then
1294 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1295 AC_TRY_RUN([
1296 #define AUTOCONF_TEST 1
1297 #define USE_SETEUID 1
1298 #include "confdefs.h"
1299 #include "${srcdir-.}/lib/util_sec.c"],
1300            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1301 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1302     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
1303 fi
1304 fi
1305
1306 if test $seteuid = no; then
1307 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1308 AC_TRY_RUN([
1309 #define AUTOCONF_TEST 1
1310 #define USE_SETUIDX 1
1311 #include "confdefs.h"
1312 #include "${srcdir-.}/lib/util_sec.c"],
1313            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1314 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1315     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
1316 fi
1317 fi
1318
1319
1320 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1321 AC_TRY_RUN([#include "${srcdir-.}/build/tests/shared_mmap.c"],
1322            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1323 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1324     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
1325 fi
1326
1327 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1328 AC_TRY_RUN([#include "${srcdir-.}/build/tests/ftruncroot.c"],
1329            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1330 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1331     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
1332 fi
1333
1334 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1335 AC_TRY_RUN([#include "${srcdir-.}/build/tests/fcntl_lock.c"],
1336            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1337 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1338     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
1339 fi
1340
1341 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1342 AC_TRY_RUN([#include "${srcdir-.}/build/tests/fcntl_lock64.c"],
1343            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1344 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1345     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
1346
1347 else
1348
1349 dnl
1350 dnl Don't check for 64 bit fcntl locking if we know that the
1351 dnl glibc2.1 broken check has succeeded.
1352 dnl 
1353
1354   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1355   AC_TRY_RUN([
1356 #if defined(HAVE_UNISTD_H)
1357 #include <unistd.h>
1358 #endif
1359 #include <stdio.h>
1360 #include <stdlib.h>
1361
1362 #ifdef HAVE_FCNTL_H
1363 #include <fcntl.h>
1364 #endif
1365
1366 #ifdef HAVE_SYS_FCNTL_H
1367 #include <sys/fcntl.h>
1368 #endif
1369 main() { struct flock64 fl64;
1370 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1371 exit(0);
1372 #else
1373 exit(1);
1374 #endif
1375 }],
1376        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1377
1378   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1379       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
1380   fi
1381 fi
1382
1383 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1384 AC_TRY_COMPILE([#include <sys/types.h>
1385 #include <sys/stat.h>
1386 #include <unistd.h>],
1387 [struct stat st;  st.st_blocks = 0;],
1388 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1389 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1390     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
1391 fi 
1392
1393 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
1394 AC_TRY_COMPILE([#include <sys/types.h>
1395 #include <sys/stat.h>
1396 #include <unistd.h>],
1397 [struct stat st;  st.st_blksize = 0;],
1398 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
1399 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
1400     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
1401 fi
1402
1403 case "$host_os" in
1404 *linux*)
1405 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1406 AC_TRY_COMPILE([
1407 #ifdef HAVE_SYS_VFS_H
1408 #include <sys/vfs.h>
1409 #endif
1410 #ifdef HAVE_SYS_CAPABILITY_H
1411 #include <sys/capability.h>
1412 #endif
1413 ],[int i;],
1414    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1415 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1416    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
1417 fi
1418 ;;
1419 esac
1420
1421 AC_SUBST(SMBD_EXTRA_OBJS)
1422 AC_SUBST(SMBD_EXTRA_LIBS)
1423
1424 SMB_INCLUDE_M4(libads/config.m4)
1425
1426 ###############################################
1427 # test for where we get crypt() from
1428 AC_SEARCH_LIBS(crypt, [crypt],
1429   [test "$ac_cv_search_crypt" = "none required" || AUTHLIBS="-lcrypt $AUTHLIBS"
1430   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
1431
1432 ##
1433 ## moved after the check for -lcrypt in order to
1434 ## ensure that the necessary libraries are included
1435 ## check checking for truncated salt.  Wrapped by the
1436 ## $with_pam_for_crypt variable as above   --jerry
1437 ##
1438 if test x"$with_pam_for_crypt" != x"yes"; then
1439 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1440 crypt_LIBS="$LIBS"
1441 LIBS="$AUTHLIBS $LIBS"
1442 AC_TRY_RUN([#include "${srcdir-.}/build/tests/crypttest.c"],
1443         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
1444 LIBS="$crypt_LIBS"])
1445 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1446         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
1447 fi
1448 fi
1449
1450 #################################################
1451 # these tests are taken from the GNU fileutils package
1452 AC_CHECKING(how to get filesystem space usage)
1453 space=no
1454
1455 # Test for statvfs64.
1456 if test $space = no; then
1457   # SVR4
1458   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
1459   [AC_TRY_RUN([
1460 #if defined(HAVE_UNISTD_H)
1461 #include <unistd.h>
1462 #endif
1463 #include <sys/types.h>
1464 #include <sys/statvfs.h>
1465   main ()
1466   {
1467     struct statvfs64 fsd;
1468     exit (statvfs64 (".", &fsd));
1469   }],
1470   fu_cv_sys_stat_statvfs64=yes,
1471   fu_cv_sys_stat_statvfs64=no,
1472   fu_cv_sys_stat_statvfs64=cross)])
1473   if test $fu_cv_sys_stat_statvfs64 = yes; then
1474     space=yes
1475     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
1476   fi
1477 fi
1478
1479 # Perform only the link test since it seems there are no variants of the
1480 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
1481 # because that got a false positive on SCO OSR5.  Adding the declaration
1482 # of a `struct statvfs' causes this test to fail (as it should) on such
1483 # systems.  That system is reported to work fine with STAT_STATFS4 which
1484 # is what it gets when this test fails.
1485 if test $space = no; then
1486   # SVR4
1487   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
1488                  [AC_TRY_LINK([#include <sys/types.h>
1489 #include <sys/statvfs.h>],
1490                               [struct statvfs fsd; statvfs (0, &fsd);],
1491                               fu_cv_sys_stat_statvfs=yes,
1492                               fu_cv_sys_stat_statvfs=no)])
1493   if test $fu_cv_sys_stat_statvfs = yes; then
1494     space=yes
1495     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
1496   fi
1497 fi
1498
1499 if test $space = no; then
1500   # DEC Alpha running OSF/1
1501   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
1502   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
1503   [AC_TRY_RUN([
1504 #include <sys/param.h>
1505 #include <sys/types.h>
1506 #include <sys/mount.h>
1507   main ()
1508   {
1509     struct statfs fsd;
1510     fsd.f_fsize = 0;
1511     exit (statfs (".", &fsd, sizeof (struct statfs)));
1512   }],
1513   fu_cv_sys_stat_statfs3_osf1=yes,
1514   fu_cv_sys_stat_statfs3_osf1=no,
1515   fu_cv_sys_stat_statfs3_osf1=no)])
1516   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
1517   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
1518     space=yes
1519     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
1520   fi
1521 fi
1522
1523 if test $space = no; then
1524 # AIX
1525   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
1526 member (AIX, 4.3BSD)])
1527   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
1528   [AC_TRY_RUN([
1529 #ifdef HAVE_SYS_PARAM_H
1530 #include <sys/param.h>
1531 #endif
1532 #ifdef HAVE_SYS_MOUNT_H
1533 #include <sys/mount.h>
1534 #endif
1535 #ifdef HAVE_SYS_VFS_H
1536 #include <sys/vfs.h>
1537 #endif
1538   main ()
1539   {
1540   struct statfs fsd;
1541   fsd.f_bsize = 0;
1542   exit (statfs (".", &fsd));
1543   }],
1544   fu_cv_sys_stat_statfs2_bsize=yes,
1545   fu_cv_sys_stat_statfs2_bsize=no,
1546   fu_cv_sys_stat_statfs2_bsize=no)])
1547   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
1548   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
1549     space=yes
1550     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
1551   fi
1552 fi
1553
1554 if test $space = no; then
1555 # SVR3
1556   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
1557   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
1558   [AC_TRY_RUN([#include <sys/types.h>
1559 #include <sys/statfs.h>
1560   main ()
1561   {
1562   struct statfs fsd;
1563   exit (statfs (".", &fsd, sizeof fsd, 0));
1564   }],
1565     fu_cv_sys_stat_statfs4=yes,
1566     fu_cv_sys_stat_statfs4=no,
1567     fu_cv_sys_stat_statfs4=no)])
1568   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
1569   if test $fu_cv_sys_stat_statfs4 = yes; then
1570     space=yes
1571     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
1572   fi
1573 fi
1574
1575 if test $space = no; then
1576 # 4.4BSD and NetBSD
1577   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
1578 member (4.4BSD and NetBSD)])
1579   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
1580   [AC_TRY_RUN([#include <sys/types.h>
1581 #ifdef HAVE_SYS_PARAM_H
1582 #include <sys/param.h>
1583 #endif
1584 #ifdef HAVE_SYS_MOUNT_H
1585 #include <sys/mount.h>
1586 #endif
1587   main ()
1588   {
1589   struct statfs fsd;
1590   fsd.f_fsize = 0;
1591   exit (statfs (".", &fsd));
1592   }],
1593   fu_cv_sys_stat_statfs2_fsize=yes,
1594   fu_cv_sys_stat_statfs2_fsize=no,
1595   fu_cv_sys_stat_statfs2_fsize=no)])
1596   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
1597   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
1598     space=yes
1599         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
1600   fi
1601 fi
1602
1603 if test $space = no; then
1604   # Ultrix
1605   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
1606   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
1607   [AC_TRY_RUN([#include <sys/types.h>
1608 #ifdef HAVE_SYS_PARAM_H
1609 #include <sys/param.h>
1610 #endif
1611 #ifdef HAVE_SYS_MOUNT_H
1612 #include <sys/mount.h>
1613 #endif
1614 #ifdef HAVE_SYS_FS_TYPES_H
1615 #include <sys/fs_types.h>
1616 #endif
1617   main ()
1618   {
1619   struct fs_data fsd;
1620   /* Ultrix's statfs returns 1 for success,
1621      0 for not mounted, -1 for failure.  */
1622   exit (statfs (".", &fsd) != 1);
1623   }],
1624   fu_cv_sys_stat_fs_data=yes,
1625   fu_cv_sys_stat_fs_data=no,
1626   fu_cv_sys_stat_fs_data=no)])
1627   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
1628   if test $fu_cv_sys_stat_fs_data = yes; then
1629     space=yes
1630     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
1631   fi
1632 fi
1633
1634 #
1635 # As a gating factor for large file support, in order to
1636 # use <4GB files we must have the following minimal support
1637 # available.
1638 # long long, and a 64 bit off_t or off64_t.
1639 # If we don't have all of these then disable large
1640 # file support.
1641 #
1642 AC_MSG_CHECKING([if large file support can be enabled])
1643 AC_TRY_COMPILE([
1644 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
1645 #include <sys/types.h>
1646 #else
1647 __COMPILE_ERROR_
1648 #endif
1649 ],
1650 [int i],
1651 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
1652 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
1653         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
1654 fi
1655 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
1656
1657 #######################################
1658 # Check for comparison_fn_t
1659 AC_CACHE_CHECK([for comparison_fn_t],samba_cv_HAVE_COMPARISON_FN_T,[
1660 AC_TRY_COMPILE([
1661 #include <stdlib.h>
1662 int list_find(const void *needle, 
1663               const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn)
1664 {
1665         return 1;
1666 }
1667 ],[],
1668 samba_cv_HAVE_COMPARISON_FN_T=yes,samba_cv_HAVE_COMPARISON_FN_T=no)
1669 ])
1670 if test x"$samba_cv_HAVE_COMPARISON_FN_T" = x"yes"; then
1671         AC_DEFINE(HAVE_COMPARISON_FN_T,1,[Whether or not we have comparison_fn_t])
1672 fi