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