global change from samba.anu.edu.au to samba.org
[samba.git] / source3 / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(include/includes.h)
3 AC_CONFIG_HEADER(include/config.h)
4 # we want to be compatibe with older versions of Samba
5 AC_PREFIX_DEFAULT(/usr/local/samba)
6
7 dnl Unique-to-Samba variables we'll be playing with.
8 AC_SUBST(SHELL)
9 AC_SUBST(MPROGS)
10 AC_SUBST(LDSHFLAGS)
11 AC_SUBST(HOST_OS)
12 AC_SUBST(WRAP)
13 AC_SUBST(WRAP32)
14 AC_SUBST(PICFLAG)
15
16 # compile with optimisation and without debugging by default
17 CFLAGS=${CFLAGS-"-O"}
18
19 dnl Checks for programs.
20 AC_PROG_CC
21 AC_PROG_INSTALL
22 AC_PROG_AWK
23
24 AC_CANONICAL_SYSTEM
25 AC_VALIDATE_CACHE_SYSTEM_TYPE
26 SAMBA_MAINTAINER_MODE
27
28 #
29 # Config CPPFLAG settings for strange OS's that must be set
30 # before other tests.
31 #
32 case "$host_os" in
33 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
34     *hpux*)
35       AC_PROG_CC_FLAG(Ae)
36       if test $ac_cv_prog_cc_Ae = yes; then
37         CPPFLAGS="$CPPFLAGS -Ae"
38       fi
39       ;;
40 #
41 # AIX4.x is *so* broken. It doesn't even admit to having large
42 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
43 #
44     *aix4*)
45       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
46       ;;    
47 esac
48
49 AC_INLINE
50 AC_HEADER_STDC
51 AC_HEADER_DIRENT
52 AC_HEADER_TIME
53 AC_HEADER_SYS_WAIT
54 AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
55 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/route.h net/if.h)
56 AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h sys/param.h ctype.h )
57 AC_CHECK_HEADERS(sys/wait.h sys/resource.h sys/ioctl.h sys/mode.h)
58 AC_CHECK_HEADERS(sys/filio.h string.h strings.h stdlib.h sys/socket.h)
59 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h)
60 AC_CHECK_HEADERS(sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
61 AC_CHECK_HEADERS(shadow.h netinet/tcp.h sys/security.h security/pam_appl.h)
62 AC_CHECK_HEADERS(stropts.h poll.h readline.h history.h readline/readline.h)
63 AC_CHECK_HEADERS(readline/history.h sys/capability.h syscall.h sys/syscall.h)
64 AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
65
66 AC_CHECK_SIZEOF(int,cross)
67 AC_CHECK_SIZEOF(long,cross)
68 AC_CHECK_SIZEOF(short,cross)
69
70 AC_C_CONST
71 AC_C_INLINE
72 AC_C_BIGENDIAN
73 AC_C_CHAR_UNSIGNED
74
75 AC_TYPE_SIGNAL
76 AC_TYPE_UID_T
77 AC_TYPE_MODE_T
78 AC_TYPE_OFF_T
79 AC_TYPE_SIZE_T
80 AC_TYPE_PID_T
81 AC_STRUCT_ST_RDEV
82 AC_DIRENT_D_OFF
83 AC_CHECK_TYPE(ino_t,unsigned)
84 AC_CHECK_TYPE(loff_t,off_t)
85 AC_CHECK_TYPE(offset_t,loff_t)
86 AC_CHECK_TYPE(ssize_t, int)
87
88 AC_CACHE_CHECK([for errno in errno.h],samba_cv_errno, [
89     AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
90         samba_cv_errno=yes,samba_cv_have_errno_decl=no)])
91 if test x"$samba_cv_errno" = x"yes"; then
92    AC_DEFINE(HAVE_ERRNO_DECL)
93 fi
94
95 # stupid glibc has the functions but no declaration. grrrr.
96 AC_CACHE_CHECK([for setresuid declaration],samba_cv_have_setresuid_decl,[
97     AC_TRY_COMPILE([#include <unistd.h>],[int i = (int)setresuid],
98         samba_cv_have_setresuid_decl=yes,samba_cv_have_setresuid_decl=no)])
99 if test x"$samba_cv_have_setresuid_decl" = x"yes"; then
100     AC_DEFINE(HAVE_SETRESUID_DECL)
101 fi
102
103 # stupid glibc has the functions but no declaration. grrrr.
104 AC_CACHE_CHECK([for crypt declaration],samba_cv_have_crypt_decl,[
105     AC_TRY_COMPILE([#include <unistd.h>],[int i = (int)crypt],
106         samba_cv_have_crypt_decl=yes,samba_cv_have_crypt_decl=no)])
107 if test x"$samba_cv_have_crypt_decl" = x"yes"; then
108     AC_DEFINE(HAVE_CRYPT_DECL)
109 fi
110
111 # and glibc has setresuid under linux but the function does
112 # nothing until kernel 2.1.44! very dumb.
113 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
114     AC_TRY_RUN([#include <errno.h>
115 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
116         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
117 if test x"$samba_cv_have_setresuid" = x"yes"; then
118     AC_DEFINE(HAVE_SETRESUID)
119 fi
120
121 AC_FUNC_MEMCMP
122
123 ###############################################
124 # test for where we get crypt() from
125 AC_CHECK_FUNCS(crypt)
126 if test x"$ac_cv_func_crypt" = x"no"; then
127     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
128         AC_DEFINE(HAVE_CRYPT)])
129 fi
130
131
132 ###############################################
133 # test for where we get pam_authenticate() from
134 # might need libdl for this to work
135 if test "$ac_cv_header_security_pam_appl_h" = "yes"; then
136   AC_CHECK_LIB(dl,main)
137 fi
138 AC_CHECK_FUNCS(pam_authenticate)
139 if test x"$ac_cv_func_pam_authenticate" = x"no"; then
140     AC_CHECK_LIB(pam, pam_authenticate, [LIBS="$LIBS -lpam"
141         AC_DEFINE(HAVE_PAM_AUTHENTICATE)])
142 fi
143
144
145 ###############################################
146 # test for where we get readline() from
147 if test "$ac_cv_header_readline_h" = "yes" ||
148    test "$ac_cv_header_readline_readline_h" = "yes"; then
149   AC_CHECK_LIB(readline,readline)
150 fi
151
152
153 # The following test taken from the cvs sources
154 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
155 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
156 # libsocket.so which has a bad implementation of gethostbyname (it
157 # only looks in /etc/hosts), so we only look for -lsocket if we need
158 # it.
159 AC_CHECK_FUNCS(connect)
160 if test x"$ac_cv_func_connect" = x"no"; then
161     case "$LIBS" in
162     *-lnsl*) ;;
163     *) AC_CHECK_LIB(nsl_s, printf) ;;
164     esac
165     case "$LIBS" in
166     *-lnsl*) ;;
167     *) AC_CHECK_LIB(nsl, printf) ;;
168     esac
169     case "$LIBS" in
170     *-lsocket*) ;;
171     *) AC_CHECK_LIB(socket, connect) ;;
172     esac
173     case "$LIBS" in
174     *-linet*) ;;
175     *) AC_CHECK_LIB(inet, connect) ;;
176     esac
177     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
178     dnl has been cached.
179     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
180        test x"$ac_cv_lib_inet_connect" = x"yes"; then
181         # ac_cv_func_connect=yes
182         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
183         AC_DEFINE(HAVE_CONNECT)
184     fi
185 fi
186
187
188 AC_CHECK_FUNCS(waitpid getcwd strdup strerror chown chmod chroot)
189 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync execl bzero memset)
190 AC_CHECK_FUNCS(memmove vsnprintf snprintf setsid glob strpbrk pipe crypt16 getauthuid)
191 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr setnetgrent getnetgrent endnetgrent)
192 AC_CHECK_FUNCS(initgroups select rdchk getgrnam pathconf putprpwnam)
193 AC_CHECK_FUNCS(setuidx setgroups mktime rename ftruncate stat64 fstat64 lstat64 fopen64)
194 AC_CHECK_FUNCS(set_auth_parameters atexit grantpt getspnam dup2 lseek64 ftruncate64)
195 AC_CHECK_FUNCS(fseek64 ftell64 bigcrypt getprpwnam setluid yp_get_default_domain getpwanam)
196 AC_CHECK_FUNCS(srandom random srand rand setenv mmap64)
197 # syscall() is needed for smbwrapper.
198 AC_CHECK_FUNCS(syscall)
199
200 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
201 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
202 AC_CHECK_FUNCS(__getcwd _getcwd)
203 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
204 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
205 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
206 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
207 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
208 AC_CHECK_FUNCS(_write __write _fork __fork)
209 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
210 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
211 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
212 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
213 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
214
215 #
216 # Check for the functions putprpwnam, set_auth_parameters,
217 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
218 # Needed for OSF1 and HPUX.
219 #
220
221 if test x"$ac_cv_func_putprpwnam" = x"no"; then
222     case "$LIBS" in
223     *-lsecurity*) ;;
224     *) AC_CHECK_LIB(security, putprpwnam) ;;
225     esac
226     case "$LIBS" in
227     *-lsec*) ;;
228     *) AC_CHECK_LIB(sec, putprpwnam) ;;
229     esac
230     if test x"$ac_cv_lib_security_putprpwnam" = x"yes" ||
231        test x"$ac_cv_lib_sec_putprpwnam" = x"yes"; then
232         AC_DEFINE(HAVE_PUTPRPWNAM)
233     fi
234 fi
235
236 if test x"$ac_cv_func_set_auth_parameters" = x"no"; then
237     case "$LIBS" in
238     *-lsecurity*) ;;
239     *) AC_CHECK_LIB(security, set_auth_parameters) ;;
240     esac
241     case "$LIBS" in
242     *-lsec*) ;;
243     *) AC_CHECK_LIB(sec, set_auth_parameters) ;;
244     esac
245     if test x"$ac_cv_lib_security_set_auth_parameters" = x"yes" ||
246        test x"$ac_cv_lib_sec_set_auth_parameters" = x"yes"; then
247         AC_DEFINE(HAVE_SET_AUTH_PARAMETERS)
248     fi
249 fi
250
251 if test x"$ac_cv_func_getspnam" = x"no"; then
252     case "$LIBS" in
253     *-lsecurity*) ;;
254     *) AC_CHECK_LIB(security, getspnam) ;;
255     esac
256     case "$LIBS" in
257     *-lsec*) ;;
258     *) AC_CHECK_LIB(sec, getspnam) ;;
259     esac
260     if test x"$ac_cv_lib_security_getspnam" = x"yes" ||
261        test x"$ac_cv_lib_sec_getspnam" = x"yes"; then
262         AC_DEFINE(HAVE_GETSPNAM)
263     fi
264 fi
265
266 if test x"$ac_cv_func_bigcrypt" = x"no"; then
267     case "$LIBS" in
268     *-lsecurity*) ;;
269     *) AC_CHECK_LIB(security, bigcrypt) ;;
270     esac
271     case "$LIBS" in
272     *-lsec*) ;;
273     *) AC_CHECK_LIB(sec, bigcrypt) ;;
274     esac
275     if test x"$ac_cv_lib_security_bigcrypt" = x"yes" ||
276        test x"$ac_cv_lib_sec_bigcrypt" = x"yes"; then
277         AC_DEFINE(HAVE_BIGCRYPT)
278     fi
279 fi
280
281 if test x"$ac_cv_func_getprpwnam" = x"no"; then
282     case "$LIBS" in
283     *-lsecurity*) ;;
284     *) AC_CHECK_LIB(security, getprpwnam) ;;
285     esac
286     case "$LIBS" in
287     *-lsec*) ;;
288     *) AC_CHECK_LIB(sec, getprpwnam) ;;
289     esac
290     if test x"$ac_cv_lib_security_getprpwnam" = x"yes" ||
291        test x"$ac_cv_lib_sec_getprpwnam" = x"yes"; then
292         AC_DEFINE(HAVE_GETPRPWNAM)
293     fi
294 fi
295
296 # this bit needs to be modified for each OS that is suported by
297 # smbwrapper. You need to specify how to created a shared library and
298 # how to compile C code to produce PIC object files
299
300 # these are the defaults, good for lots of systems
301 HOST_OS="$host_os"
302 LDSHFLAGS="-shared"
303
304 # and these are for particular systems
305 case "$host_os" in
306                 *linux*)   AC_DEFINE(LINUX);;
307                 *solaris*) AC_DEFINE(SUNOS5)
308                                         LDSHFLAGS="-G"
309                 ;;
310                 *sunos*) AC_DEFINE(SUNOS4)
311                                         LDSHFLAGS=""
312                 ;;
313                 *bsd*) LDSHFLAGS="-shared -Bshareable"
314                 ;;
315                 *irix*) AC_DEFINE(IRIX)
316                         ATTEMPT_WRAP32_BUILD=yes
317                 ;;
318                 *aix*) AC_DEFINE(AIX);;
319                 *hpux*) AC_DEFINE(HPUX);;
320                 *qnx*) AC_DEFINE(QNX);;
321                 *osf*) AC_DEFINE(OSF1);;
322                 *sco*) AC_DEFINE(SCO);;
323                 *next2*) AC_DEFINE(NEXT2);;
324                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
325                 *sysv4.2*) AC_CHECK_LIB(resolv, strcasecmp);;
326 esac
327
328 # try to work out how to produce pic code with this compiler
329 PICFLAG=""
330 AC_PROG_CC_FLAG(fpic)
331 if test $ac_cv_prog_cc_fpic = yes; then
332    PICFLAG="-fpic";
333 fi
334 if test x$PICFLAG = x; then
335   AC_PROG_CC_FLAG(Kpic)
336   if test $ac_cv_prog_cc_Kpic = yes; then
337     PICFLAG="-Kpic";
338   fi 
339 fi
340 if test x$PICFLAG = x; then
341   AC_PROG_CC_FLAG(KPIC)
342   if test $ac_cv_prog_cc_KPIC = yes; then
343     PICFLAG="-KPIC";
344   fi 
345 fi
346
347 ################
348
349 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
350 AC_TRY_RUN([#include <stdio.h>
351 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
352 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
353 if test x"$samba_cv_have_longlong" = x"yes"; then
354     AC_DEFINE(HAVE_LONGLONG)
355 fi
356
357 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
358 AC_TRY_RUN([#include <stdio.h>
359 #include <sys/stat.h>
360 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
361 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
362 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
363     AC_DEFINE(SIZEOF_OFF_T,8)
364 fi
365
366 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
367 AC_TRY_RUN([#include <stdio.h>
368 #include <sys/stat.h>
369 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
370 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
371 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
372     AC_DEFINE(HAVE_OFF64_T)
373 fi
374
375 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
376 AC_TRY_RUN([#include <stdio.h>
377 #include <sys/stat.h>
378 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
379 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
380 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
381     AC_DEFINE(SIZEOF_INO_T,8)
382 fi
383
384 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
385 AC_TRY_RUN([#include <stdio.h>
386 #include <sys/stat.h>
387 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
388 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
389 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
390     AC_DEFINE(HAVE_INO64_T)
391 fi
392
393 AC_CACHE_CHECK([for union semun],samba_cv_HAVE_UNION_SEMUN,[
394 AC_TRY_RUN([
395 #include <sys/types.h>
396 #include <sys/ipc.h>
397 #include <sys/sem.h>
398 main() { union semun ss; exit(0); }],
399 samba_cv_HAVE_UNION_SEMUN=yes,samba_cv_HAVE_UNION_SEMUN=no,samba_cv_HAVE_UNION_SEMUN=cross)])
400 if test x"$samba_cv_HAVE_UNION_SEMUN" = x"yes"; then
401     AC_DEFINE(HAVE_UNION_SEMUN)
402 fi
403
404 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
405 AC_TRY_RUN([#include <stdio.h>
406 main() { char c; c=250; exit((c > 0)?0:1); }],
407 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
408 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
409     AC_DEFINE(HAVE_UNSIGNED_CHAR)
410 fi
411
412 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
413 AC_TRY_COMPILE([#include <sys/types.h>
414 #include <sys/socket.h>
415 #include <netinet/in.h>],
416 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
417 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
418 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
419     AC_DEFINE(HAVE_SOCK_SIN_LEN)
420 fi
421
422 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
423 AC_TRY_COMPILE([#include <sys/types.h>
424 #include <dirent.h>
425 void seekdir(DIR *d, long loc) { return; }],[return 0;],
426 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
427 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
428     AC_DEFINE(SEEKDIR_RETURNS_VOID)
429 fi
430
431 AC_CACHE_CHECK([for __FILE__ macro],samba_cv_HAVE_FILE_MACRO,[
432 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FILE__);],
433 samba_cv_HAVE_FILE_MACRO=yes,samba_cv_HAVE_FILE_MACRO=no)])
434 if test x"$samba_cv_HAVE_FILE_MACRO" = x"yes"; then
435     AC_DEFINE(HAVE_FILE_MACRO)
436 fi
437
438 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
439 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
440 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
441 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
442     AC_DEFINE(HAVE_FUNCTION_MACRO)
443 fi
444
445 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
446 AC_TRY_RUN([
447 #include <sys/time.h>
448 #include <unistd.h>
449 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
450            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
451 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
452     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
453 fi
454
455
456 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
457 AC_TRY_RUN([#include <sys/types.h>
458 #include <dirent.h>
459 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
460 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
461 di->d_name[0] == 0) exit(0); exit(1);} ],
462 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
463 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
464     AC_DEFINE(HAVE_BROKEN_READDIR)
465 fi
466
467 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
468 AC_TRY_COMPILE([#include <sys/types.h>
469 #include <utime.h>],
470 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
471 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
472 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
473     AC_DEFINE(HAVE_UTIMBUF)
474 fi
475
476 AC_CACHE_CHECK([for kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS,[
477 AC_TRY_COMPILE([#include <sys/types.h>
478 #include <fcntl.h>],
479 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
480 samba_cv_HAVE_KERNEL_OPLOCKS=yes,samba_cv_HAVE_KERNEL_OPLOCKS=no)])
481 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS" = x"yes"; then
482     AC_DEFINE(HAVE_KERNEL_OPLOCKS)
483 fi
484
485 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
486 AC_TRY_RUN([#include <sys/types.h>
487 #include <sys/capability.h>
488 main() {
489  cap_t cap;
490  if ((cap = cap_get_proc()) == NULL)
491    exit(1);
492  cap->cap_effective |= CAP_NETWORK_MGT;
493  cap->cap_inheritable |= CAP_NETWORK_MGT;
494  cap_set_proc(cap);
495  exit(0);
496 }
497 ],
498 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
499 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
500     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES)
501 fi
502
503 #
504 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
505 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
506 #
507
508 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
509 AC_TRY_COMPILE([#include <sys/types.h>
510 #if defined(HAVE_RPC_RPC_H)
511 #include <rpc/rpc.h>
512 #endif],
513 [int16 testvar;],
514 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
515 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
516     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H)
517 fi
518
519 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
520 AC_TRY_COMPILE([#include <sys/types.h>
521 #if defined(HAVE_RPC_RPC_H)
522 #include <rpc/rpc.h>
523 #endif],
524 [uint16 testvar;],
525 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
526 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
527     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H)
528 fi
529
530 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
531 AC_TRY_COMPILE([#include <sys/types.h>
532 #if defined(HAVE_RPC_RPC_H)
533 #include <rpc/rpc.h>
534 #endif],
535 [int32 testvar;],
536 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
537 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
538     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H)
539 fi
540
541 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
542 AC_TRY_COMPILE([#include <sys/types.h>
543 #if defined(HAVE_RPC_RPC_H)
544 #include <rpc/rpc.h>
545 #endif],
546 [uint32 testvar;],
547 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
548 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
549     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H)
550 fi
551
552 AC_MSG_CHECKING([for test routines])
553 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
554            AC_MSG_RESULT(yes),
555            AC_MSG_ERROR([cant find test code. Aborting config]),
556            AC_MSG_WARN([cannot run when cross-compiling]))
557
558 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
559 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
560            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
561 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
562     AC_DEFINE(HAVE_FTRUNCATE_EXTEND)
563 fi
564
565 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
566 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
567            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
568 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
569     AC_DEFINE(HAVE_BROKEN_GETGROUPS)
570 fi
571
572 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
573 SAVE_CPPFLAGS="$CPPFLAGS"
574 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/include -I${srcdir-.}/ubiqx"
575 AC_TRY_COMPILE([
576 #define REPLACE_GETPASS 1
577 #define NO_CONFIG_H 1
578 #define main dont_declare_main
579 #include "${srcdir-.}/lib/getsmbpass.c"
580 #undef main
581 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
582 CPPFLAGS="$SAVE_CPPFLAGS"
583 ])
584 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
585         AC_DEFINE(REPLACE_GETPASS)
586 fi
587
588 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
589 AC_TRY_RUN([
590 #include <stdio.h>
591 #include <sys/types.h>
592 #include <netinet/in.h>
593 #include <arpa/inet.h>
594 main() { struct in_addr ip; ip.s_addr = 0x12345678;
595 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
596     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
597 exit(1);}],
598            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
599 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
600     AC_DEFINE(REPLACE_INET_NTOA)
601 fi
602
603 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
604 AC_TRY_RUN([main() { exit(getuid() != 0); }],
605            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
606 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
607     AC_DEFINE(HAVE_ROOT)
608 else
609     AC_MSG_WARN(running as non-root will disable some tests)
610 fi
611
612 netmask=no;
613 AC_CACHE_CHECK([for netmask ifconf],samba_cv_HAVE_NETMASK_IFCONF,[
614 AC_TRY_RUN([
615 #define HAVE_NETMASK_IFCONF 1
616 #define AUTOCONF 1
617 #include "${srcdir-.}/lib/netmask.c"],
618            samba_cv_HAVE_NETMASK_IFCONF=yes,samba_cv_HAVE_NETMASK_IFCONF=no,samba_cv_HAVE_NETMASK_IFCONF=cross)])
619 if test x"$samba_cv_HAVE_NETMASK_IFCONF" = x"yes"; then
620     netmask=yes;AC_DEFINE(HAVE_NETMASK_IFCONF)
621 fi
622
623 if test $netmask = no; then
624 AC_CACHE_CHECK([for netmask ifreq],samba_cv_HAVE_NETMASK_IFREQ,[
625 AC_TRY_RUN([
626 #define HAVE_NETMASK_IFREQ 1
627 #define AUTOCONF 1
628 #include "${srcdir-.}/lib/netmask.c"],
629            samba_cv_HAVE_NETMASK_IFREQ=yes,samba_cv_HAVE_NETMASK_IFREQ=no,samba_cv_HAVE_NETMASK_IFREQ=cross)])
630 if test x"$samba_cv_HAVE_NETMASK_IFREQ" = x"yes"; then
631     netmask=yes;AC_DEFINE(HAVE_NETMASK_IFREQ)
632 fi
633 fi
634
635 if test $netmask = no; then
636 AC_CACHE_CHECK([for netmask AIX],samba_cv_HAVE_NETMASK_AIX,[
637 AC_TRY_RUN([
638 #define HAVE_NETMASK_AIX 1
639 #define AUTOCONF 1
640 #include "${srcdir-.}/lib/netmask.c"],
641            samba_cv_HAVE_NETMASK_AIX=yes,samba_cv_HAVE_NETMASK_AIX=no,samba_cv_HAVE_NETMASK_AIX=cross)])
642 if test x"$samba_cv_HAVE_NETMASK_AIX" = x"yes"; then
643     netmask=yes;AC_DEFINE(HAVE_NETMASK_AIX)
644 fi
645 fi
646
647 AC_CACHE_CHECK([for trapdoor seteuid],samba_cv_HAVE_TRAPDOOR_UID,[
648 AC_TRY_RUN([#include "${srcdir-.}/tests/trapdoor.c"],
649            samba_cv_HAVE_TRAPDOOR_UID=no,samba_cv_HAVE_TRAPDOOR_UID=yes,:)])
650 if test x"$samba_cv_HAVE_TRAPDOOR_UID" = x"yes"; then
651     AC_DEFINE(HAVE_TRAPDOOR_UID)
652 fi
653
654 AC_CACHE_CHECK([for shared mmap],samba_cv_HAVE_SHARED_MMAP,[
655 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
656            samba_cv_HAVE_SHARED_MMAP=yes,samba_cv_HAVE_SHARED_MMAP=no,samba_cv_HAVE_SHARED_MMAP=cross)])
657 if test x"$samba_cv_HAVE_SHARED_MMAP" = x"yes"; then
658     AC_DEFINE(HAVE_SHARED_MMAP)
659 fi
660
661 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
662 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
663            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
664 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
665     AC_DEFINE(HAVE_FCNTL_LOCK)
666 fi
667
668 AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
669 AC_TRY_RUN([
670 #include <stdio.h>
671 #include <stdlib.h>
672
673 #ifdef HAVE_FCNTL_H
674 #include <fcntl.h>
675 #endif
676
677 #ifdef HAVE_SYS_FCNTL_H
678 #include <sys/fcntl.h>
679 #endif
680 main() { struct flock64 fl64;
681 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
682 exit(0);
683 #else
684 exit(1);
685 #endif
686 }],
687        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
688 if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
689     AC_DEFINE(HAVE_STRUCT_FLOCK64)
690 fi
691
692 AC_CACHE_CHECK([for sysv ipc],samba_cv_HAVE_SYSV_IPC,[
693 AC_TRY_RUN([#include "${srcdir-.}/tests/sysv_ipc.c"],
694            samba_cv_HAVE_SYSV_IPC=yes,samba_cv_HAVE_SYSV_IPC=no,samba_cv_HAVE_SYSV_IPC=cross)])
695 if test x"$samba_cv_HAVE_SYSV_IPC" = x"yes"; then
696     AC_DEFINE(HAVE_SYSV_IPC)
697 fi
698
699 #################################################
700 # check for smbwrapper support
701 AC_MSG_CHECKING(whether to use smbwrapper)
702 AC_ARG_WITH(smbwrapper,
703 [  --with-smbwrapper     Include SMB wrapper support
704   --without-smbwrapper  Don't include SMB wrapper support (default)],
705 [ case "$withval" in
706   yes)
707     AC_MSG_RESULT(yes)
708     AC_DEFINE(WITH_SMBWRAPPER)
709         WRAP="bin/smbsh bin/smbwrapper.so"
710
711         if test x$ATTEMPT_WRAP32_BUILD = x; then
712                 WRAP32=""
713         else
714                         WRAP32=bin/smbwrapper.32.so
715         fi
716
717 # Conditions under which smbwrapper should not be built.
718
719         if test x$PICFLAG = x; then
720            echo No support for PIC code - disabling smbwrapper and smbsh
721            WRAP=""
722            WRAP32=""
723         elif test x$ac_cv_func_syscall = xno; then
724            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
725            WRAP=""
726            WRAP32=""
727         fi
728     ;;
729   *)
730     AC_MSG_RESULT(no)
731     ;;
732   esac ],
733   AC_MSG_RESULT(no)
734 )
735
736 #################################################
737 # check for the AFS filesystem
738 AC_MSG_CHECKING(whether to use AFS)
739 AC_ARG_WITH(afs,
740 [  --with-afs     Include AFS support
741   --without-afs  Don't include AFS support (default)],
742 [ case "$withval" in
743   yes)
744     AC_MSG_RESULT(yes)
745     AC_DEFINE(WITH_AFS)
746     ;;
747   *)
748     AC_MSG_RESULT(no)
749     ;;
750   esac ],
751   AC_MSG_RESULT(no)
752 )
753
754
755 #################################################
756 # check for the DFS auth system
757 AC_MSG_CHECKING(whether to use DFS auth)
758 AC_ARG_WITH(dfs,
759 [  --with-dfs     Include DFS support
760   --without-dfs  Don't include DFS support (default)],
761 [ case "$withval" in
762   yes)
763     AC_MSG_RESULT(yes)
764     AC_DEFINE(WITH_DFS)
765     ;;
766   *)
767     AC_MSG_RESULT(no)
768     ;;
769   esac ],
770   AC_MSG_RESULT(no)
771 )
772
773 #################################################
774 # check for Kerberos IV auth system
775 AC_MSG_CHECKING(whether to use Kerberos IV)
776 AC_ARG_WITH(krb4,
777 [  --with-krb4=base-dir     Include Kerberos IV support
778   --whithout-krb4          Don't include Kerbers IV support (default)],
779 [   AC_MSG_RESULT(yes)
780     AC_DEFINE(KRB4_AUTH)
781     AC_CHECK_LIB(resolv, dn_expand)
782     LIBS="$LIBS -lkrb -ldes"
783     CFLAGS="$CFLAGS -I$withval/include"
784     LDFLAGS="$LDFLAGS -L$withval/lib"],
785   AC_MSG_RESULT(no)
786 )
787
788 #################################################
789 # check for automount support
790 AC_MSG_CHECKING(whether to use AUTOMOUNT)
791 AC_ARG_WITH(automount,
792 [  --with-automount     Include AUTOMOUNT support
793   --without-automount  Don't include AUTOMOUNT support (default)],
794 [ case "$withval" in
795   yes)
796     AC_MSG_RESULT(yes)
797     AC_DEFINE(WITH_AUTOMOUNT)
798     ;;
799   *)
800     AC_MSG_RESULT(no)
801     ;;
802   esac ],
803   AC_MSG_RESULT(no)
804 )
805
806 #################################################
807 # check for smbmount support
808 AC_MSG_CHECKING(whether to use SMBMOUNT)
809 AC_ARG_WITH(smbmount,
810 [  --with-smbmount     Include SMBMOUNT (Linux only) support
811   --without-smbmount  Don't include SMBMOUNT support (default)],
812 [ case "$withval" in
813   yes)
814     AC_MSG_RESULT(yes)
815     AC_DEFINE(WITH_SMBMOUNT)
816     MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
817     ;;
818   *)
819     AC_MSG_RESULT(no)
820     MPROGS=
821     ;;
822   esac ],
823   AC_MSG_RESULT(no)
824   MPROGS=
825 )
826
827 #################################################
828 # check for a LDAP password database
829 AC_MSG_CHECKING(whether to use LDAP password database)
830 AC_ARG_WITH(ldap,
831 [  --with-ldap     Include LDAP support
832   --without-ldap  Don't include LDAP support (default)],
833 [ case "$withval" in
834   yes)
835     AC_MSG_RESULT(yes)
836     AC_DEFINE(WITH_LDAP)
837     ;;
838   *)
839     AC_MSG_RESULT(no)
840     ;;
841   esac ],
842   AC_MSG_RESULT(no)
843 )
844
845 #################################################
846 # check for a NISPLUS password database
847 AC_MSG_CHECKING(whether to use NISPLUS password database)
848 AC_ARG_WITH(nisplus,
849 [  --with-nisplus     Include NISPLUS password database support
850   --without-nisplus  Don't include NISPLUS password database support (default)],
851 [ case "$withval" in
852   yes)
853     AC_MSG_RESULT(yes)
854     AC_DEFINE(WITH_NISPLUS)
855     ;;
856   *)
857     AC_MSG_RESULT(no)
858     ;;
859   esac ],
860   AC_MSG_RESULT(no)
861 )
862
863 #################################################
864 # check for a NISPLUS_HOME support 
865 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
866 AC_ARG_WITH(nisplus-home,
867 [  --with-nisplus-home     Include NISPLUS_HOME support
868   --without-nisplus-home  Don't include NISPLUS_HOME support (default)],
869 [ case "$withval" in
870   yes)
871     AC_MSG_RESULT(yes)
872     AC_DEFINE(WITH_NISPLUS_HOME)
873     ;;
874   *)
875     AC_MSG_RESULT(no)
876     ;;
877   esac ],
878   AC_MSG_RESULT(no)
879 )
880
881 #################################################
882 # check for the secure socket layer
883 AC_MSG_CHECKING(whether to use SSL)
884 AC_ARG_WITH(ssl,
885 [  --with-ssl     Include SSL support
886   --without-ssl  Don't include SSL support (default)],
887 [ case "$withval" in
888   yes)
889     AC_MSG_RESULT(yes)
890     AC_DEFINE(WITH_SSL)
891     ;;
892   *)
893     AC_MSG_RESULT(no)
894     ;;
895   esac ],
896   AC_MSG_RESULT(no)
897 )
898
899 #################################################
900 # check for experimental mmap support
901 AC_MSG_CHECKING(whether to use MMAP)
902 AC_ARG_WITH(mmap,
903 [  --with-mmap     Include experimental MMAP support
904   --without-mmap  Don't include MMAP support (default)],
905 [ case "$withval" in
906   yes)
907     AC_MSG_RESULT(yes)
908     AC_DEFINE(WITH_MMAP)
909     ;;
910   *)
911     AC_MSG_RESULT(no)
912     ;;
913   esac ],
914   AC_MSG_RESULT(no)
915 )
916
917 #################################################
918 # check for syslog logging
919 AC_MSG_CHECKING(whether to use syslog logging)
920 AC_ARG_WITH(syslog,
921 [  --with-syslog     Include experimental SYSLOG support
922   --without-syslog  Don't include SYSLOG support (default)],
923 [ case "$withval" in
924   yes)
925     AC_MSG_RESULT(yes)
926     AC_DEFINE(WITH_SYSLOG)
927     ;;
928   *)
929     AC_MSG_RESULT(no)
930     ;;
931   esac ],
932   AC_MSG_RESULT(no)
933 )
934
935 #################################################
936 # check for experimental netatalk resource fork support
937 AC_MSG_CHECKING(whether to support netatalk)
938 AC_ARG_WITH(netatalk,
939 [  --with-netatalk     Include experimental Netatalk support
940   --without-netatalk  Don't include experimental Netatalk support (default)],
941 [ case "$withval" in
942   yes)
943     AC_MSG_RESULT(yes)
944     AC_DEFINE(WITH_NETATALK)
945     ;;
946   *)
947     AC_MSG_RESULT(no)
948     ;;
949   esac ],
950   AC_MSG_RESULT(no)
951 )
952
953 #################################################
954 # check for experimental disk-quotas support
955 QUOTAOBJS=noquotas.o
956
957 AC_MSG_CHECKING(whether to support disk-quotas)
958 AC_ARG_WITH(quotas,
959 [  --with-quotas     Include experimental disk-quota support
960   --without-quotas  Don't include experimental disk-quota support (default)],
961 [ case "$withval" in
962   yes)
963     AC_MSG_RESULT(yes)
964     QUOTAOBJS=quotas.o
965     ;;
966   *)
967     AC_MSG_RESULT(no)
968     ;;
969   esac ],
970   AC_MSG_RESULT(no)
971 )
972 AC_SUBST(QUOTAOBJS)
973
974 #################################################
975 # these tests are taken from the GNU fileutils package
976 AC_CHECKING(how to get filesystem space usage)
977 space=no
978
979 # Test for statvfs64.
980 if test $space = no; then
981   # SVR4
982   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
983   [AC_TRY_RUN([
984 #include <sys/types.h>
985 #include <sys/statvfs.h>
986   main ()
987   {
988     struct statvfs64 fsd;
989     exit (statfs64 (".", &fsd));
990   }],
991   fu_cv_sys_stat_statvfs64=yes,
992   fu_cv_sys_stat_statvfs64=no,
993   fu_cv_sys_stat_statvfs64=cross)])
994   if test $fu_cv_sys_stat_statvfs64 = yes; then
995     space=yes
996     AC_DEFINE(STAT_STATVFS64)
997   fi
998 fi
999
1000 # Perform only the link test since it seems there are no variants of the
1001 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
1002 # because that got a false positive on SCO OSR5.  Adding the declaration
1003 # of a `struct statvfs' causes this test to fail (as it should) on such
1004 # systems.  That system is reported to work fine with STAT_STATFS4 which
1005 # is what it gets when this test fails.
1006 if test $space = no; then
1007   # SVR4
1008   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
1009                  [AC_TRY_LINK([#include <sys/types.h>
1010 #include <sys/statvfs.h>],
1011                               [struct statvfs fsd; statvfs (0, &fsd);],
1012                               fu_cv_sys_stat_statvfs=yes,
1013                               fu_cv_sys_stat_statvfs=no)])
1014   if test $fu_cv_sys_stat_statvfs = yes; then
1015     space=yes
1016     AC_DEFINE(STAT_STATVFS)
1017   fi
1018 fi
1019
1020 if test $space = no; then
1021   # DEC Alpha running OSF/1
1022   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
1023   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
1024   [AC_TRY_RUN([
1025 #include <sys/param.h>
1026 #include <sys/types.h>
1027 #include <sys/mount.h>
1028   main ()
1029   {
1030     struct statfs fsd;
1031     fsd.f_fsize = 0;
1032     exit (statfs (".", &fsd, sizeof (struct statfs)));
1033   }],
1034   fu_cv_sys_stat_statfs3_osf1=yes,
1035   fu_cv_sys_stat_statfs3_osf1=no,
1036   fu_cv_sys_stat_statfs3_osf1=no)])
1037   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
1038   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
1039     space=yes
1040     AC_DEFINE(STAT_STATFS3_OSF1)
1041   fi
1042 fi
1043
1044 if test $space = no; then
1045 # AIX
1046   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
1047 member (AIX, 4.3BSD)])
1048   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
1049   [AC_TRY_RUN([
1050 #ifdef HAVE_SYS_PARAM_H
1051 #include <sys/param.h>
1052 #endif
1053 #ifdef HAVE_SYS_MOUNT_H
1054 #include <sys/mount.h>
1055 #endif
1056 #ifdef HAVE_SYS_VFS_H
1057 #include <sys/vfs.h>
1058 #endif
1059   main ()
1060   {
1061   struct statfs fsd;
1062   fsd.f_bsize = 0;
1063   exit (statfs (".", &fsd));
1064   }],
1065   fu_cv_sys_stat_statfs2_bsize=yes,
1066   fu_cv_sys_stat_statfs2_bsize=no,
1067   fu_cv_sys_stat_statfs2_bsize=no)])
1068   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
1069   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
1070     space=yes
1071     AC_DEFINE(STAT_STATFS2_BSIZE)
1072   fi
1073 fi
1074
1075 if test $space = no; then
1076 # SVR3
1077   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
1078   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
1079   [AC_TRY_RUN([#include <sys/types.h>
1080 #include <sys/statfs.h>
1081   main ()
1082   {
1083   struct statfs fsd;
1084   exit (statfs (".", &fsd, sizeof fsd, 0));
1085   }],
1086     fu_cv_sys_stat_statfs4=yes,
1087     fu_cv_sys_stat_statfs4=no,
1088     fu_cv_sys_stat_statfs4=no)])
1089   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
1090   if test $fu_cv_sys_stat_statfs4 = yes; then
1091     space=yes
1092     AC_DEFINE(STAT_STATFS4)
1093   fi
1094 fi
1095
1096 if test $space = no; then
1097 # 4.4BSD and NetBSD
1098   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
1099 member (4.4BSD and NetBSD)])
1100   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
1101   [AC_TRY_RUN([#include <sys/types.h>
1102 #ifdef HAVE_SYS_PARAM_H
1103 #include <sys/param.h>
1104 #endif
1105 #ifdef HAVE_SYS_MOUNT_H
1106 #include <sys/mount.h>
1107 #endif
1108   main ()
1109   {
1110   struct statfs fsd;
1111   fsd.f_fsize = 0;
1112   exit (statfs (".", &fsd));
1113   }],
1114   fu_cv_sys_stat_statfs2_fsize=yes,
1115   fu_cv_sys_stat_statfs2_fsize=no,
1116   fu_cv_sys_stat_statfs2_fsize=no)])
1117   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
1118   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
1119     space=yes
1120     AC_DEFINE(STAT_STATFS2_FSIZE)
1121   fi
1122 fi
1123
1124 if test $space = no; then
1125   # Ultrix
1126   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
1127   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
1128   [AC_TRY_RUN([#include <sys/types.h>
1129 #ifdef HAVE_SYS_PARAM_H
1130 #include <sys/param.h>
1131 #endif
1132 #ifdef HAVE_SYS_MOUNT_H
1133 #include <sys/mount.h>
1134 #endif
1135 #ifdef HAVE_SYS_FS_TYPES_H
1136 #include <sys/fs_types.h>
1137 #endif
1138   main ()
1139   {
1140   struct fs_data fsd;
1141   /* Ultrix's statfs returns 1 for success,
1142      0 for not mounted, -1 for failure.  */
1143   exit (statfs (".", &fsd) != 1);
1144   }],
1145   fu_cv_sys_stat_fs_data=yes,
1146   fu_cv_sys_stat_fs_data=no,
1147   fu_cv_sys_stat_fs_data=no)])
1148   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
1149   if test $fu_cv_sys_stat_fs_data = yes; then
1150     space=yes
1151     AC_DEFINE(STAT_STATFS2_FS_DATA)
1152   fi
1153 fi
1154
1155 echo "checking configure summary"
1156 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
1157            echo "configure OK";,
1158            AC_MSG_ERROR([summary failure. Aborting config]),:)
1159
1160 builddir=`pwd`
1161 AC_SUBST(builddir)
1162
1163 AC_OUTPUT(include/stamp-h Makefile)