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