fixed typo
[ira/wip.git] / source3 / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(include/includes.h)
3 AC_CONFIG_HEADER(include/config.h)
4 # we want to be compatibe with older versions of Samba
5 AC_PREFIX_DEFAULT(/usr/local/samba)
6
7 dnl Unique-to-Samba variables we'll be playing with.
8 AC_SUBST(SHELL)
9 AC_SUBST(RUNPROG)
10 AC_SUBST(MPROGS)
11 AC_SUBST(LDSHFLAGS)
12 AC_SUBST(SHLD)
13 AC_SUBST(HOST_OS)
14 AC_SUBST(PAM_MOD)
15 AC_SUBST(WRAP)
16 AC_SUBST(WRAP32)
17 AC_SUBST(PICFLAG)
18 AC_SUBST(PICSUFFIX)
19 AC_SUBST(POBAD_CC)
20 AC_SUBST(SHLIBEXT)
21 AC_SUBST(BLDSHARED)
22
23 # compile with optimisation and without debugging by default
24 CFLAGS="-O ${CFLAGS}"
25
26 AC_ARG_ENABLE(debug, [  --enable-debug        turn on debugging [default=no]],
27     [if eval "test x$enable_debug = xyes"; then
28         CFLAGS="${CFLAGS} -g"
29     fi])
30
31
32 dnl Checks for programs.
33 AC_PROG_CC
34 AC_PROG_INSTALL
35 AC_PROG_AWK
36
37 dnl Check if C compiler understands -c and -o at the same time
38 AC_PROG_CC_C_O
39 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
40       BROKEN_CC=
41 else
42       BROKEN_CC=#
43 fi
44 AC_SUBST(BROKEN_CC)
45
46 dnl Check if the C compiler understands volatile (it should, being ANSI).
47 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
48     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
49         samba_cv_volatile=yes,samba_cv_volatile=no)])
50 if test x"$samba_cv_volatile" = x"yes"; then
51    AC_DEFINE(HAVE_VOLATILE)
52 fi
53
54
55 #################################################
56 # set codepage directory location
57 AC_ARG_WITH(codepagedir,
58 [  --with-codepagedir=DIR  Where to put codepage files (\$libdir/codepages)],
59 [ case "$withval" in
60   yes|no)
61   #
62   # Just in case anybody does it
63   #
64     AC_MSG_WARN([--with-codepagedir called without argument - will use default])
65   ;;
66   * )
67     codepagedir="$withval"
68     ;;
69   esac])
70
71
72 AC_CANONICAL_SYSTEM
73
74 dnl Add #include for broken IRIX header files
75   case "$host_os" in
76         *irix6*) AC_ADD_INCLUDE(<standards.h>)
77         ;;
78 esac
79
80 AC_VALIDATE_CACHE_SYSTEM_TYPE
81
82 #
83 # Config CPPFLAG settings for strange OS's that must be set
84 # before other tests.
85 #
86 case "$host_os" in
87 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
88     *hpux*)
89       AC_PROG_CC_FLAG(Ae)
90       # mmap on HPUX is completely broken...
91       AC_DEFINE(MMAP_BLACKLIST)
92       if test $ac_cv_prog_cc_Ae = yes; then
93         CPPFLAGS="$CPPFLAGS -Ae"
94       fi
95 #
96 # Defines needed for HPUX support.
97 # HPUX has bigcrypt but (sometimes?) doesn't use it for
98 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
99 #
100       case `uname -r` in
101                         *9*|*10*)
102                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE"
103                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
104                                 ;;
105                         *11*)
106                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE"
107                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
108                                 ;;
109       esac
110       ;;
111 #
112 # AIX4.x doesn't even admit to having large
113 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
114 #
115     *aix4*)
116           AC_MSG_RESULT([enabling large file support])
117       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
118       ;;    
119 #
120 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
121 # to the existance of large files..
122 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
123 # recommendations on large file support, however it makes the
124 # compile work using gcc 2.7 and 2.8, whereas using the Sun
125 # recommendation makes the compile fail on gcc2.7. JRA.
126 #
127         *solaris*)
128                 case `uname -r` in
129                         5.6*|5.7*)
130                         AC_MSG_RESULT([enabling large file support])
131                         if test "$ac_cv_prog_gcc" = yes; then
132                                 ${CC-cc} -v >conftest.c 2>&1
133                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
134                                 rm -fr conftest.c
135                                 case "$ac_cv_gcc_compiler_version_number" in
136                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
137                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
138                                                 ;;
139                                         *)
140                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
141                                                 ;;
142                                 esac
143                         else
144                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
145                         fi
146                         ;;
147                 esac
148                 ;;
149 #
150 # Tests needed for SINIX large file support.
151 #
152     *sysv4*)
153       if test $host = mips-sni-sysv4 ; then
154         AC_MSG_CHECKING([for LFS support])
155         old_CPPFLAGS="$CPPFLAGS"
156         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
157         AC_TRY_RUN([
158 #include <unistd.h>
159 main () {
160 #if _LFS64_LARGEFILE == 1
161 exit(0);
162 #else
163 exit(1);
164 #endif
165 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
166         CPPFLAGS="$old_CPPFLAGS"
167         if test x$SINIX_LFS_SUPPORT = xyes ; then
168           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
169           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
170           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
171           LIBS="`getconf LFS64_LIBS` $LIBS"
172         fi
173       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
174       fi
175     ;;
176
177 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
178 #
179     *linux*)
180         AC_MSG_CHECKING([for LFS support])
181         old_CPPFLAGS="$CPPFLAGS"
182         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
183        AC_TRY_RUN([
184 #include <unistd.h>
185 #include <sys/utsname.h>
186 main() {
187 #if _LFS64_LARGEFILE == 1
188        struct utsname uts;
189        char *release;
190        int major, minor;
191
192        /* Ensure this is glibc 2.2 or higher */
193 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
194        int libc_major = __GLIBC__;
195        int libc_minor = __GLIBC_MINOR__;
196
197        if (libc_major < 2)
198               exit(1);
199        if (libc_minor < 2)
200               exit(1);
201 #endif
202
203        /* Ensure this is kernel 2.4 or higher */
204
205        uname(&uts);
206        release = uts.release;
207        major = atoi(strsep(&release, "."));
208        minor = atoi(strsep(&release, "."));
209
210        if (major > 2 || (major == 2 && minor > 3))
211                exit(0);
212        exit(1);
213 #else
214        exit(1);
215 #endif
216 }
217 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
218         CPPFLAGS="$old_CPPFLAGS"
219         if test x$LINUX_LFS_SUPPORT = xyes ; then
220           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
221         fi
222        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
223                 ;;
224
225     *hurd*)
226         AC_MSG_CHECKING([for LFS support])
227         old_CPPFLAGS="$CPPFLAGS"
228         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
229         AC_TRY_RUN([
230 #include <unistd.h>
231 main () {
232 #if _LFS64_LARGEFILE == 1
233 exit(0);
234 #else
235 exit(1);
236 #endif
237 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
238         CPPFLAGS="$old_CPPFLAGS"
239         if test x$GLIBC_LFS_SUPPORT = xyes ; then
240           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
241         fi
242       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
243     ;;
244
245 esac
246
247 AC_INLINE
248 AC_HEADER_STDC
249 AC_HEADER_DIRENT
250 AC_HEADER_TIME
251 AC_HEADER_SYS_WAIT
252 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
253 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
254 AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
255 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
256 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
257 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
258 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
259 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h)
260
261 #
262 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
263 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
264 #
265 case "$host_os" in
266     *hpux*)
267                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
268                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
269                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
270                    AC_DEFINE(HAVE_SHADOW_H)
271                 fi
272         ;;
273 esac
274 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
275 AC_CHECK_HEADERS(nss.h nss_common.h sys/security.h security/pam_appl.h security/pam_modules.h)
276 AC_CHECK_HEADERS(stropts.h poll.h)
277 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
278 AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
279
280 # For experimental utmp support (lastlog on some BSD-like systems)
281 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
282  
283 # For quotas on Veritas VxFS filesystems
284 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
285
286 AC_CHECK_SIZEOF(int,cross)
287 AC_CHECK_SIZEOF(long,cross)
288 AC_CHECK_SIZEOF(short,cross)
289
290 AC_C_CONST
291 AC_C_INLINE
292 AC_C_BIGENDIAN
293 AC_C_CHAR_UNSIGNED
294
295 AC_TYPE_SIGNAL
296 AC_TYPE_UID_T
297 AC_TYPE_MODE_T
298 AC_TYPE_OFF_T
299 AC_TYPE_SIZE_T
300 AC_TYPE_PID_T
301 AC_STRUCT_ST_RDEV
302 AC_DIRENT_D_OFF
303 AC_CHECK_TYPE(ino_t,unsigned)
304 AC_CHECK_TYPE(loff_t,off_t)
305 AC_CHECK_TYPE(offset_t,loff_t)
306 AC_CHECK_TYPE(ssize_t, int)
307 AC_CHECK_TYPE(wchar_t, unsigned short)
308
309 ############################################
310 # for cups support we need libcups, and a handful of header files
311
312 AC_CHECK_LIB(cups,httpConnect)
313
314 # I wonder if there is a nicer way of doing this?
315
316 if test x"$ac_cv_lib_cups_httpConnect" = x"yes"; then
317         AC_CHECK_HEADERS(cups/cups.h cups/language.h)
318         if x"$ac_cv_header_cups_cups_h" = x"yes"; then
319                 if x"$ac_cv_header_cups_language_h" = x"yes"; then
320                         AC_DEFINE(HAVE_CUPS)
321                 fi
322         fi
323 fi
324
325 ############################################
326 # we need libdl for PAM and the new VFS code
327 AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl";
328         AC_DEFINE(HAVE_LIBDL)])
329
330 ############################################
331 # check for unix domain sockets
332 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
333     AC_TRY_COMPILE([
334 #include <sys/types.h>
335 #include <stdlib.h>
336 #include <stddef.h>
337 #include <sys/socket.h>
338 #include <sys/un.h>],
339 [
340   struct sockaddr_un sunaddr; 
341   sunaddr.sun_family = AF_UNIX;
342 ],
343         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
344 if test x"$samba_cv_unixsocket" = x"yes"; then
345    AC_DEFINE(HAVE_UNIXSOCKET)
346 fi
347
348
349 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
350     AC_TRY_COMPILE([
351 #include <sys/types.h>
352 #if STDC_HEADERS
353 #include <stdlib.h>
354 #include <stddef.h>
355 #endif
356 #include <sys/socket.h>],[socklen_t i = 0],
357         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
358 if test x"$samba_cv_socklen_t" = x"yes"; then
359    AC_DEFINE(HAVE_SOCKLEN_T_TYPE)
360 fi
361
362 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
363     AC_TRY_COMPILE([
364 #include <sys/types.h>
365 #if STDC_HEADERS
366 #include <stdlib.h>
367 #include <stddef.h>
368 #endif
369 #include <signal.h>],[sig_atomic_t i = 0],
370         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
371 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
372    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE)
373 fi
374
375 # stupid headers have the functions but no declaration. grrrr.
376 AC_HAVE_DECL(errno, [#include <errno.h>])
377 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
378 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
379 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
380 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
381 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
382 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
383
384 # and glibc has setresuid under linux but the function does
385 # nothing until kernel 2.1.44! very dumb.
386 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
387     AC_TRY_RUN([#include <errno.h>
388 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
389         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
390 if test x"$samba_cv_have_setresuid" = x"yes"; then
391     AC_DEFINE(HAVE_SETRESUID)
392 fi
393
394 # Do the same check for setresguid...
395 #
396 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
397     AC_TRY_RUN([#include <unistd.h>
398 #include <errno.h>
399 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
400         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
401 if test x"$samba_cv_have_setresgid" = x"yes"; then
402     AC_DEFINE(HAVE_SETRESGID)
403 fi
404
405 AC_FUNC_MEMCMP
406
407 ###############################################
408 # test for where we get crypt() from
409 AC_CHECK_FUNCS(crypt)
410 if test x"$ac_cv_func_crypt" = x"no"; then
411     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
412         AC_DEFINE(HAVE_CRYPT)])
413 fi
414
415
416 ###############################################
417 # Readline included by default unless explicitly asked not to
418 test "${with_readline+set}" != "set" && with_readline=yes
419
420 # test for where we get readline() from
421 AC_MSG_CHECKING(whether to use readline)
422 AC_ARG_WITH(readline,
423 [  --with-readline[=DIR]   Look for readline include/libs in DIR (default=auto) ],
424 [  case "$with_readline" in
425   yes)
426     AC_MSG_RESULT(yes)
427
428     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
429     AC_CHECK_HEADERS(readline/history.h)
430
431     AC_CHECK_HEADERS(readline.h readline/readline.h,[
432       for termlib in ncurses curses termcap terminfo termlib; do
433        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
434       done
435       AC_CHECK_LIB(readline, rl_callback_handler_install,
436        [TERMLIBS="-lreadline $TERMLIBS"
437        AC_DEFINE(HAVE_LIBREADLINE)
438        break], [TERMLIBS=], $TERMLIBS)])
439     ;;
440   no)
441     AC_MSG_RESULT(no)
442     ;;
443   *)
444     AC_MSG_RESULT(yes)
445
446     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
447     # alternate readline path
448     _ldflags=${LDFLAGS}
449     _cppflags=${CPPFLAGS}
450
451     # Add additional search path
452     LDFLAGS="-L$with_readline/lib $LDFLAGS"
453     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
454
455     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
456     AC_CHECK_HEADERS(readline/history.h)
457
458     AC_CHECK_HEADERS(readline.h readline/readline.h,[
459       for termlib in ncurses curses termcap terminfo termlib; do
460        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
461       done
462       AC_CHECK_LIB(readline, rl_callback_handler_install,
463        [TERMLDFLAGS="-L$with_readline/lib"
464        TERMCPPFLAGS="-I$with_readline/include"
465        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
466        TERMLIBS="-lreadline $TERMLIBS"
467        AC_DEFINE(HAVE_LIBREADLINE)
468        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
469
470     LDFLAGS=$_ldflags
471     ;;
472   esac],
473   AC_MSG_RESULT(no)
474 )
475 AC_SUBST(TERMLIBS)
476 AC_SUBST(TERMLDFLAGS)
477
478 # The following test taken from the cvs sources
479 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
480 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
481 # libsocket.so which has a bad implementation of gethostbyname (it
482 # only looks in /etc/hosts), so we only look for -lsocket if we need
483 # it.
484 AC_CHECK_FUNCS(connect)
485 if test x"$ac_cv_func_connect" = x"no"; then
486     case "$LIBS" in
487     *-lnsl*) ;;
488     *) AC_CHECK_LIB(nsl_s, printf) ;;
489     esac
490     case "$LIBS" in
491     *-lnsl*) ;;
492     *) AC_CHECK_LIB(nsl, printf) ;;
493     esac
494     case "$LIBS" in
495     *-lsocket*) ;;
496     *) AC_CHECK_LIB(socket, connect) ;;
497     esac
498     case "$LIBS" in
499     *-linet*) ;;
500     *) AC_CHECK_LIB(inet, connect) ;;
501     esac
502     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
503     dnl has been cached.
504     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
505        test x"$ac_cv_lib_inet_connect" = x"yes"; then
506         # ac_cv_func_connect=yes
507         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
508         AC_DEFINE(HAVE_CONNECT)
509     fi
510 fi
511
512 ###############################################
513 # test for where we get get_yp_default_domain() from
514 AC_CHECK_FUNCS(yp_get_default_domain)
515 if test x"$ac_cv_func_yp_get_default_domain" = x"no"; then
516         AC_CHECK_LIB(nsl, yp_get_default_domain, [LIBS="$LIBS -lnsl";
517         AC_DEFINE(HAVE_YP_GET_DEFAULT_DOMAIN)]) 
518 fi
519
520 # Check if we have execl, if not we need to compile smbrun.
521 AC_CHECK_FUNCS(execl)
522 if test x"$ac_cv_func_execl" = x"no"; then
523     RUNPROG="bin/smbrun"
524 else
525     RUNPROG=""
526 fi
527
528 AC_CHECK_FUNCS(waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod chroot)
529 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset)
530 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
531 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr setnetgrent getnetgrent endnetgrent)
532 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
533 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
534 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
535 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
536 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
537 # setbuffer is needed for smbtorture
538 AC_CHECK_FUNCS(setbuffer)
539
540 # syscall() is needed for smbwrapper.
541 AC_CHECK_FUNCS(syscall)
542
543 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
544 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
545 AC_CHECK_FUNCS(__getcwd _getcwd)
546 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
547 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
548 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
549 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
550 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
551 AC_CHECK_FUNCS(_write __write _fork __fork)
552 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
553 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
554 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
555 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
556 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
557
558 #
559 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
560 #
561
562 if test x$ac_cv_func_stat64 = xno ; then
563   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
564   AC_TRY_LINK([
565 #if defined(HAVE_UNISTD_H)
566 #include <unistd.h>
567 #endif
568 #include <sys/stat.h>
569 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
570   AC_MSG_RESULT([$ac_cv_func_stat64])
571   if test x$ac_cv_func_stat64 = xyes ; then
572     AC_DEFINE(HAVE_STAT64)
573   fi
574 fi
575
576 if test x$ac_cv_func_lstat64 = xno ; then
577   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
578   AC_TRY_LINK([
579 #if defined(HAVE_UNISTD_H)
580 #include <unistd.h>
581 #endif
582 #include <sys/stat.h>
583 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
584   AC_MSG_RESULT([$ac_cv_func_lstat64])
585   if test x$ac_cv_func_lstat64 = xyes ; then
586     AC_DEFINE(HAVE_LSTAT64)
587   fi
588 fi
589
590 if test x$ac_cv_func_fstat64 = xno ; then
591   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
592   AC_TRY_LINK([
593 #if defined(HAVE_UNISTD_H)
594 #include <unistd.h>
595 #endif
596 #include <sys/stat.h>
597 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
598   AC_MSG_RESULT([$ac_cv_func_fstat64])
599   if test x$ac_cv_func_fstat64 = xyes ; then
600     AC_DEFINE(HAVE_FSTAT64)
601   fi
602 fi
603
604 #
605 # If no strcasecmp, check for it in some known places
606 # It is in -lresolv on ReliantUNIX and UnixWare
607 #   -lresolve *must* follow -lnsl for name resolution to work properly
608 #
609
610 if test x$ac_cv_func_strcasecmp = xno ; then
611         AC_CHECK_LIB(resolv,strcasecmp,[LIBS="$LIBS -lresolv"]
612                 AC_DEFINE(HAVE_STRCASECMP))
613 fi
614
615 #
616 # Check for the functions putprpwnam, set_auth_parameters,
617 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
618 # Needed for OSF1 and HPUX.
619 #
620
621 AC_LIBTESTFUNC(security, putprpwnam)
622 AC_LIBTESTFUNC(sec, putprpwnam)
623
624 AC_LIBTESTFUNC(security, set_auth_parameters)
625 AC_LIBTESTFUNC(sec, set_auth_parameters)
626
627 # UnixWare 7.x has its getspnam in -lgen
628 AC_LIBTESTFUNC(gen, getspnam)
629
630 AC_LIBTESTFUNC(security, getspnam)
631 AC_LIBTESTFUNC(sec, getspnam)
632
633 AC_LIBTESTFUNC(security, bigcrypt)
634 AC_LIBTESTFUNC(sec, bigcrypt)
635
636 AC_LIBTESTFUNC(security, getprpwnam)
637 AC_LIBTESTFUNC(sec, getprpwnam)
638
639 # this bit needs to be modified for each OS that is suported by
640 # smbwrapper. You need to specify how to created a shared library and
641 # how to compile C code to produce PIC object files
642
643 # these are the defaults, good for lots of systems
644 HOST_OS="$host_os"
645 LDSHFLAGS="-shared"
646 SHLD="\${CC}"
647 PICFLAG=""
648 PICSUFFIX="po"
649 POBAD_CC="#"
650 SHLIBEXT="so"
651 BLDSHARED="false"
652
653 # and these are for particular systems
654 case "$host_os" in
655                 *linux*)   AC_DEFINE(LINUX)
656                         BLDSHARED="true"
657                         LDSHFLAGS="-shared" 
658                         PICFLAG="-fPIC"
659                 ;;
660                 *solaris*) AC_DEFINE(SUNOS5)
661                         BLDSHARED="true"
662                         LDSHFLAGS="-Wl,-h,\$@.so -G"
663                         if test "${ac_cv_prog_CC}" = "gcc"; then
664                                 PICFLAG="-fPIC"
665                         else
666                                 PICFLAG="-KPIC -xO4"
667                                 POBAD_CC=""
668                                 PICSUFFIX="po.o"
669                         fi
670                 ;;
671                 *sunos*) AC_DEFINE(SUNOS4)
672                         BLDSHARED="true"
673                         LDSHFLAGS="-Wl,-h,\$@ -G"
674                         PICFLAG="-KPIC -O2"   # Is this correct for SunOS
675                 ;;
676                 *bsd*)  BLDSHARED="true"
677                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
678                         PICFLAG="-fPIC -O2"
679                 ;;
680                 *irix*) AC_DEFINE(IRIX)
681                         case "$host_os" in
682                         *irix6*) AC_DEFINE(IRIX6)
683                         ;;
684                         esac
685                         ATTEMPT_WRAP32_BUILD=yes
686                         BLDSHARED="true"
687                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
688                         if test "${ac_cv_prog_CC}" = "gcc"; then
689                                 PICFLAG="-fPIC"
690                         else 
691                                 PICFLAG="-KPIC"
692                         fi
693                 ;;
694                 *aix*) AC_DEFINE(AIX)
695                         BLDSHARED="true"
696                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
697                         PICFLAG="-O2 -qmaxmem=6000"
698                 ;;
699                 *hpux*) AC_DEFINE(HPUX)
700                         SHLIBEXT="sl"
701                         # Use special PIC flags for the native HP-UX compiler.
702                         if test $ac_cv_prog_cc_Ae = yes; then
703                                 #BLDSHARED="true"
704                                 LDSHFLAGS="-b -z +h \$@"
705                                 PICFLAG="+z"
706                         fi
707                 ;;
708                 *qnx*) AC_DEFINE(QNX);;
709                 *osf*) AC_DEFINE(OSF1)
710                         BLDSHARED="true"
711                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
712                         PICFLAG="-fPIC"
713                 ;;
714                 *sco*) AC_DEFINE(SCO);;
715                 *unixware*) AC_DEFINE(UNIXWARE)
716                         BLDSHARED="true"
717                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
718                         PICFLAG="-KPIC"
719                 ;;
720                 *next2*) AC_DEFINE(NEXT2);;
721                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
722                 *sysv4*)
723                         case "$host" in
724                                 *-univel-*)     if [ test "$GCC" != yes ]; then
725                                                                         AC_DEFINE(HAVE_MEMSET)
726                                                                 fi
727                                                                 LDSHFLAGS="-G"
728                                 ;;
729                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX);;
730                         esac
731                         ;;
732                 *sysv5*)
733                         if [ test "$GCC" != yes ]; then
734                                 AC_DEFINE(HAVE_MEMSET)
735                         fi
736                         LDSHFLAGS="-G"
737                         ;;
738 esac
739
740 ################
741
742 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
743 AC_TRY_RUN([#include <stdio.h>
744 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
745 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
746 if test x"$samba_cv_have_longlong" = x"yes"; then
747     AC_DEFINE(HAVE_LONGLONG)
748 fi
749
750 #
751 # Check if the compiler supports the LL prefix on long long integers.
752 # AIX needs this.
753
754 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
755     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
756         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
757 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
758    AC_DEFINE(COMPILER_SUPPORTS_LL)
759 fi
760
761   
762 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
763 AC_TRY_RUN([#include <stdio.h>
764 #include <sys/stat.h>
765 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
766 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
767 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
768     AC_DEFINE(SIZEOF_OFF_T,8)
769 fi
770
771 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
772 AC_TRY_RUN([
773 #if defined(HAVE_UNISTD_H)
774 #include <unistd.h>
775 #endif
776 #include <stdio.h>
777 #include <sys/stat.h>
778 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
779 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
780 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
781     AC_DEFINE(HAVE_OFF64_T)
782 fi
783
784 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
785 AC_TRY_RUN([#include <stdio.h>
786 #include <sys/stat.h>
787 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
788 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
789 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
790     AC_DEFINE(SIZEOF_INO_T,8)
791 fi
792
793 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
794 AC_TRY_RUN([
795 #if defined(HAVE_UNISTD_H)
796 #include <unistd.h>
797 #endif
798 #include <stdio.h>
799 #include <sys/stat.h>
800 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
801 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
802 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
803     AC_DEFINE(HAVE_INO64_T)
804 fi
805
806 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
807 AC_TRY_COMPILE([
808 #if defined(HAVE_UNISTD_H)
809 #include <unistd.h>
810 #endif
811 #include <sys/types.h>
812 #include <dirent.h>],
813 [struct dirent64 de;],
814 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
815 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes"; then
816     AC_DEFINE(HAVE_STRUCT_DIRENT64)
817 fi
818
819 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
820 AC_TRY_RUN([#include <stdio.h>
821 main() { char c; c=250; exit((c > 0)?0:1); }],
822 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
823 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
824     AC_DEFINE(HAVE_UNSIGNED_CHAR)
825 fi
826
827 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
828 AC_TRY_COMPILE([#include <sys/types.h>
829 #include <sys/socket.h>
830 #include <netinet/in.h>],
831 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
832 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
833 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
834     AC_DEFINE(HAVE_SOCK_SIN_LEN)
835 fi
836
837 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
838 AC_TRY_COMPILE([#include <sys/types.h>
839 #include <dirent.h>
840 void seekdir(DIR *d, long loc) { return; }],[return 0;],
841 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
842 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
843     AC_DEFINE(SEEKDIR_RETURNS_VOID)
844 fi
845
846 AC_CACHE_CHECK([for __FILE__ macro],samba_cv_HAVE_FILE_MACRO,[
847 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FILE__);],
848 samba_cv_HAVE_FILE_MACRO=yes,samba_cv_HAVE_FILE_MACRO=no)])
849 if test x"$samba_cv_HAVE_FILE_MACRO" = x"yes"; then
850     AC_DEFINE(HAVE_FILE_MACRO)
851 fi
852
853 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
854 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
855 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
856 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
857     AC_DEFINE(HAVE_FUNCTION_MACRO)
858 fi
859
860 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
861 AC_TRY_RUN([
862 #include <sys/time.h>
863 #include <unistd.h>
864 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
865            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
866 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
867     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
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(0, 0, format, ap);
881        va_end(ap);
882        if (len != 5) exit(1);
883
884        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
885
886        exit(0);
887 }
888 main() { foo("hello"); }
889 ],
890 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
891 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
892     AC_DEFINE(HAVE_C99_VSNPRINTF)
893 fi
894
895 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
896 AC_TRY_RUN([#include <sys/types.h>
897 #include <dirent.h>
898 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
899 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
900 di->d_name[0] == 0) exit(0); exit(1);} ],
901 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
902 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
903     AC_DEFINE(HAVE_BROKEN_READDIR)
904 fi
905
906 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
907 AC_TRY_COMPILE([#include <sys/types.h>
908 #include <utime.h>],
909 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
910 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
911 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
912     AC_DEFINE(HAVE_UTIMBUF)
913 fi
914
915 dnl  utmp and utmpx come in many flavours
916 dnl  We need to check for many of them
917 dnl  But we don't need to do each and every one, because our code uses
918 dnl  mostly just the utmp (not utmpx) fields.
919
920 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
921
922 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
923 AC_TRY_COMPILE([#include <sys/types.h>
924 #include <utmp.h>],
925 [struct utmp ut;  ut.ut_name[0] = 'a';],
926 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
927 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
928     AC_DEFINE(HAVE_UT_UT_NAME)
929 fi 
930
931 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
932 AC_TRY_COMPILE([#include <sys/types.h>
933 #include <utmp.h>],
934 [struct utmp ut;  ut.ut_user[0] = 'a';],
935 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
936 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
937     AC_DEFINE(HAVE_UT_UT_USER)
938 fi 
939
940 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
941 AC_TRY_COMPILE([#include <sys/types.h>
942 #include <utmp.h>],
943 [struct utmp ut;  ut.ut_id[0] = 'a';],
944 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
945 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
946     AC_DEFINE(HAVE_UT_UT_ID)
947 fi 
948
949 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
950 AC_TRY_COMPILE([#include <sys/types.h>
951 #include <utmp.h>],
952 [struct utmp ut;  ut.ut_host[0] = 'a';],
953 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
954 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
955     AC_DEFINE(HAVE_UT_UT_HOST)
956 fi 
957
958 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
959 AC_TRY_COMPILE([#include <sys/types.h>
960 #include <utmp.h>],
961 [struct utmp ut;  time_t t; ut.ut_time = t;],
962 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
963 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
964     AC_DEFINE(HAVE_UT_UT_TIME)
965 fi 
966
967 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
968 AC_TRY_COMPILE([#include <sys/types.h>
969 #include <utmp.h>],
970 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
971 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
972 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
973     AC_DEFINE(HAVE_UT_UT_TV)
974 fi 
975
976 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
977 AC_TRY_COMPILE([#include <sys/types.h>
978 #include <utmp.h>],
979 [struct utmp ut;  ut.ut_type = 0;],
980 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
981 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
982     AC_DEFINE(HAVE_UT_UT_TYPE)
983 fi 
984
985 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
986 AC_TRY_COMPILE([#include <sys/types.h>
987 #include <utmp.h>],
988 [struct utmp ut;  ut.ut_pid = 0;],
989 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
990 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
991     AC_DEFINE(HAVE_UT_UT_PID)
992 fi 
993
994 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
995 AC_TRY_COMPILE([#include <sys/types.h>
996 #include <utmp.h>],
997 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
998 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
999 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1000     AC_DEFINE(HAVE_UT_UT_EXIT)
1001 fi 
1002
1003 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1004 AC_TRY_COMPILE([#include <sys/types.h>
1005 #include <utmp.h>],
1006 [struct utmp ut;  ut.ut_addr = 0;],
1007 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1008 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1009     AC_DEFINE(HAVE_UT_UT_ADDR)
1010 fi 
1011
1012 if test x$ac_cv_func_pututline = xyes ; then
1013   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1014   AC_TRY_COMPILE([#include <sys/types.h>
1015 #include <utmp.h>],
1016   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1017   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1018   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1019       AC_DEFINE(PUTUTLINE_RETURNS_UTMP)
1020   fi
1021 fi
1022
1023 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1024 AC_TRY_COMPILE([#include <sys/types.h>
1025 #include <utmpx.h>],
1026 [struct utmpx ux;  ux.ut_syslen = 0;],
1027 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1028 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1029     AC_DEFINE(HAVE_UX_UT_SYSLEN)
1030 fi 
1031
1032
1033 #################################################
1034 # check for libiconv support
1035 AC_MSG_CHECKING(whether to use libiconv)
1036 AC_ARG_WITH(libiconv,
1037 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1038 [ case "$withval" in
1039   no)
1040     AC_MSG_RESULT(no)
1041     ;;
1042   *)
1043     AC_MSG_RESULT(yes)
1044     CFLAGS="$CFLAGS -I$withval/include"
1045     LDFLAGS="$LDFLAGS -L$withval/lib"
1046     AC_CHECK_LIB(iconv, iconv_open)
1047     ;;
1048   esac ],
1049   AC_MSG_RESULT(no)
1050 )
1051
1052
1053 ############
1054 # check for iconv in libc
1055 AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1056 AC_TRY_RUN([
1057 #include <iconv.h>
1058 main() {
1059        iconv_t cd = iconv_open("ASCII", "UCS-2LE");
1060        if (cd == 0 || cd == (iconv_t)-1) return -1;
1061        return 0;
1062 }
1063 ],
1064 samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
1065 if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1066     AC_DEFINE(HAVE_NATIVE_ICONV)
1067 fi
1068
1069
1070 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1071 AC_TRY_RUN([
1072 #include <sys/types.h>
1073 #include <fcntl.h>
1074 #ifndef F_GETLEASE
1075 #define F_GETLEASE      1025
1076 #endif
1077 main() {
1078        int fd = open("/dev/null", O_RDONLY);
1079        return fcntl(fd, F_GETLEASE, 0) == -1;
1080 }
1081 ],
1082 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1083 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1084     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX)
1085 fi
1086
1087 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1088 AC_TRY_RUN([
1089 #include <sys/types.h>
1090 #include <fcntl.h>
1091 #include <signal.h>
1092 #ifndef F_NOTIFY
1093 #define F_NOTIFY 1026
1094 #endif
1095 main() {
1096         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1097 }
1098 ],
1099 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1100 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1101     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY)
1102 fi
1103
1104 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1105 AC_TRY_RUN([
1106 #include <sys/types.h>
1107 #include <fcntl.h>
1108 #include <signal.h>
1109 #include <sys/file.h>
1110 #ifndef LOCK_MAND
1111 #define LOCK_MAND       32
1112 #define LOCK_READ       64
1113 #endif
1114 main() {
1115         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1116 }
1117 ],
1118 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1119 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1120     AC_DEFINE(HAVE_KERNEL_SHARE_MODES)
1121 fi
1122
1123
1124
1125
1126 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1127 AC_TRY_COMPILE([#include <sys/types.h>
1128 #include <fcntl.h>],
1129 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1130 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1131 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1132     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX)
1133 fi
1134
1135 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1136 AC_TRY_RUN([#include <sys/types.h>
1137 #include <sys/capability.h>
1138 main() {
1139  cap_t cap;
1140  if ((cap = cap_get_proc()) == NULL)
1141    exit(1);
1142  cap->cap_effective |= CAP_NETWORK_MGT;
1143  cap->cap_inheritable |= CAP_NETWORK_MGT;
1144  cap_set_proc(cap);
1145  exit(0);
1146 }
1147 ],
1148 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1149 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1150     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES)
1151 fi
1152
1153 #
1154 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1155 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1156 #
1157
1158 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1159 AC_TRY_COMPILE([#include <sys/types.h>
1160 #if defined(HAVE_RPC_RPC_H)
1161 #include <rpc/rpc.h>
1162 #endif],
1163 [int16 testvar;],
1164 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1165 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1166     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H)
1167 fi
1168
1169 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1170 AC_TRY_COMPILE([#include <sys/types.h>
1171 #if defined(HAVE_RPC_RPC_H)
1172 #include <rpc/rpc.h>
1173 #endif],
1174 [uint16 testvar;],
1175 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1176 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1177     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H)
1178 fi
1179
1180 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1181 AC_TRY_COMPILE([#include <sys/types.h>
1182 #if defined(HAVE_RPC_RPC_H)
1183 #include <rpc/rpc.h>
1184 #endif],
1185 [int32 testvar;],
1186 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1187 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1188     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H)
1189 fi
1190
1191 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1192 AC_TRY_COMPILE([#include <sys/types.h>
1193 #if defined(HAVE_RPC_RPC_H)
1194 #include <rpc/rpc.h>
1195 #endif],
1196 [uint32 testvar;],
1197 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1198 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1199     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H)
1200 fi
1201
1202 dnl
1203 dnl Some systems (SCO) have a problem including
1204 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1205 dnl as a #define in <prot.h> and as part of an enum
1206 dnl in <rpc/rpc.h>.
1207 dnl
1208
1209 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1210 AC_TRY_COMPILE([#include <sys/types.h>
1211 #ifdef HAVE_SYS_SECURITY_H
1212 #include <sys/security.h>
1213 #include <prot.h>
1214 #endif  /* HAVE_SYS_SECURITY_H */
1215 #if defined(HAVE_RPC_RPC_H)
1216 #include <rpc/rpc.h>
1217 #endif],
1218 [int testvar;],
1219 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1220 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1221     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT)
1222 fi
1223
1224 AC_MSG_CHECKING([for test routines])
1225 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1226            AC_MSG_RESULT(yes),
1227            AC_MSG_ERROR([cant find test code. Aborting config]),
1228            AC_MSG_WARN([cannot run when cross-compiling]))
1229
1230 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1231 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1232            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1233 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1234     AC_DEFINE(HAVE_FTRUNCATE_EXTEND)
1235 fi
1236
1237 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1238 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
1239            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1240            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1241            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1242 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1243 then
1244     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1245 fi
1246
1247 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1248 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1249            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1250 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1251     AC_DEFINE(HAVE_BROKEN_GETGROUPS)
1252 fi
1253
1254 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1255 SAVE_CPPFLAGS="$CPPFLAGS"
1256 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/smbwrapper"
1257 AC_TRY_COMPILE([
1258 #define REPLACE_GETPASS 1
1259 #define NO_CONFIG_H 1
1260 #define main dont_declare_main
1261 #include "${srcdir-.}/lib/getsmbpass.c"
1262 #undef main
1263 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1264 CPPFLAGS="$SAVE_CPPFLAGS"
1265 ])
1266 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1267         AC_DEFINE(REPLACE_GETPASS)
1268 fi
1269
1270 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1271 AC_TRY_RUN([
1272 #include <stdio.h>
1273 #include <sys/types.h>
1274 #include <netinet/in.h>
1275 #ifdef HAVE_ARPA_INET_H
1276 #include <arpa/inet.h>
1277 #endif
1278 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1279 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1280     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1281 exit(1);}],
1282            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1283 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1284     AC_DEFINE(REPLACE_INET_NTOA)
1285 fi
1286
1287 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1288 AC_TRY_RUN([#include <stdlib.h>
1289 #include <sys/types.h>
1290 #include <sys/stat.h>
1291 #include <unistd.h>
1292 main() { 
1293   struct stat st;
1294   char tpl[20]="/tmp/test.XXXXXX"; 
1295   int fd = mkstemp(tpl); 
1296   if (fd == -1) exit(1);
1297   unlink(tpl);
1298   if (fstat(fd, &st) != 0) exit(1);
1299   if ((st.st_mode & 0777) != 0600) exit(1);
1300   exit(0);
1301 }],
1302 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1303 samba_cv_HAVE_SECURE_MKSTEMP=no,
1304 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1305 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1306     AC_DEFINE(HAVE_SECURE_MKSTEMP)
1307 fi
1308
1309 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1310 AC_TRY_RUN([#include <unistd.h>
1311 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1312 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1313 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1314     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX)
1315 fi
1316
1317 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1318 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1319            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1320 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1321     AC_DEFINE(HAVE_ROOT)
1322 else
1323     AC_MSG_WARN(running as non-root will disable some tests)
1324 fi
1325
1326 ##################
1327 # look for a method of finding the list of network interfaces
1328 iface=no;
1329 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1330 AC_TRY_RUN([
1331 #define HAVE_IFACE_AIX 1
1332 #define AUTOCONF_TEST 1
1333 #include "confdefs.h"
1334 #include "${srcdir-.}/lib/interfaces.c"],
1335            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1336 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1337     iface=yes;AC_DEFINE(HAVE_IFACE_AIX)
1338 fi
1339
1340 if test $iface = no; then
1341 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1342 AC_TRY_RUN([
1343 #define HAVE_IFACE_IFCONF 1
1344 #define AUTOCONF_TEST 1
1345 #include "confdefs.h"
1346 #include "${srcdir-.}/lib/interfaces.c"],
1347            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1348 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1349     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF)
1350 fi
1351 fi
1352
1353 if test $iface = no; then
1354 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1355 AC_TRY_RUN([
1356 #define HAVE_IFACE_IFREQ 1
1357 #define AUTOCONF_TEST 1
1358 #include "confdefs.h"
1359 #include "${srcdir-.}/lib/interfaces.c"],
1360            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1361 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1362     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ)
1363 fi
1364 fi
1365
1366
1367 ################################################
1368 # look for a method of setting the effective uid
1369 seteuid=no;
1370 if test $seteuid = no; then
1371 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1372 AC_TRY_RUN([
1373 #define AUTOCONF_TEST 1
1374 #define USE_SETRESUID 1
1375 #include "confdefs.h"
1376 #include "${srcdir-.}/lib/util_sec.c"],
1377            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1378 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1379     seteuid=yes;AC_DEFINE(USE_SETRESUID)
1380 fi
1381 fi
1382
1383
1384 if test $seteuid = no; then
1385 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1386 AC_TRY_RUN([
1387 #define AUTOCONF_TEST 1
1388 #define USE_SETREUID 1
1389 #include "confdefs.h"
1390 #include "${srcdir-.}/lib/util_sec.c"],
1391            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1392 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1393     seteuid=yes;AC_DEFINE(USE_SETREUID)
1394 fi
1395 fi
1396
1397 if test $seteuid = no; then
1398 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1399 AC_TRY_RUN([
1400 #define AUTOCONF_TEST 1
1401 #define USE_SETEUID 1
1402 #include "confdefs.h"
1403 #include "${srcdir-.}/lib/util_sec.c"],
1404            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1405 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1406     seteuid=yes;AC_DEFINE(USE_SETEUID)
1407 fi
1408 fi
1409
1410 if test $seteuid = no; then
1411 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1412 AC_TRY_RUN([
1413 #define AUTOCONF_TEST 1
1414 #define USE_SETUIDX 1
1415 #include "confdefs.h"
1416 #include "${srcdir-.}/lib/util_sec.c"],
1417            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1418 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1419     seteuid=yes;AC_DEFINE(USE_SETUIDX)
1420 fi
1421 fi
1422
1423
1424 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1425 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1426            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1427 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1428     AC_DEFINE(HAVE_MMAP)
1429 fi
1430
1431 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1432 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1433            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1434 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1435     AC_DEFINE(FTRUNCATE_NEEDS_ROOT)
1436 fi
1437
1438 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1439 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1440            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1441 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1442     AC_DEFINE(HAVE_FCNTL_LOCK)
1443 fi
1444
1445 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1446 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1447            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1448 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1449     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS)
1450
1451 else
1452
1453 dnl
1454 dnl Don't check for 64 bit fcntl locking if we know that the
1455 dnl glibc2.1 broken check has succeeded.
1456 dnl 
1457
1458   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1459   AC_TRY_RUN([
1460 #if defined(HAVE_UNISTD_H)
1461 #include <unistd.h>
1462 #endif
1463 #include <stdio.h>
1464 #include <stdlib.h>
1465
1466 #ifdef HAVE_FCNTL_H
1467 #include <fcntl.h>
1468 #endif
1469
1470 #ifdef HAVE_SYS_FCNTL_H
1471 #include <sys/fcntl.h>
1472 #endif
1473 main() { struct flock64 fl64;
1474 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1475 exit(0);
1476 #else
1477 exit(1);
1478 #endif
1479 }],
1480        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1481
1482   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1483       AC_DEFINE(HAVE_STRUCT_FLOCK64)
1484   fi
1485 fi
1486
1487 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
1488 AC_TRY_COMPILE([#include <sys/acl.h>
1489 #if defined(HAVE_RPCSVC_NIS_H)
1490 #include <rpcsvc/nis.h>
1491 #endif],
1492 [return 0;],
1493 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
1494 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
1495     AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES)
1496 fi
1497
1498
1499 #################################################
1500 # check for smbwrapper support
1501 AC_MSG_CHECKING(whether to use smbwrapper)
1502 AC_ARG_WITH(smbwrapper,
1503 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
1504 [ case "$withval" in
1505   yes)
1506     AC_MSG_RESULT(yes)
1507     AC_DEFINE(WITH_SMBWRAPPER)
1508         WRAP="bin/smbsh bin/smbwrapper.$SHLIBEXT"
1509
1510         if test x$ATTEMPT_WRAP32_BUILD = x; then
1511                 WRAP32=""
1512         else
1513                         WRAP32=bin/smbwrapper.32.$SHLIBEXT
1514         fi
1515
1516 # Conditions under which smbwrapper should not be built.
1517
1518         if test x$PICFLAG = x; then
1519            echo No support for PIC code - disabling smbwrapper and smbsh
1520            WRAP=""
1521            WRAP32=""
1522         elif test x$ac_cv_func_syscall = xno; then
1523            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
1524            WRAP=""
1525            WRAP32=""
1526         fi
1527     ;;
1528   *)
1529     AC_MSG_RESULT(no)
1530     ;;
1531   esac ],
1532   AC_MSG_RESULT(no)
1533 )
1534
1535 #################################################
1536 # check for the AFS filesystem
1537 AC_MSG_CHECKING(whether to use AFS)
1538 AC_ARG_WITH(afs,
1539 [  --with-afs              Include AFS support (default=no) ],
1540 [ case "$withval" in
1541   yes)
1542     AC_MSG_RESULT(yes)
1543     AC_DEFINE(WITH_AFS)
1544     ;;
1545   *)
1546     AC_MSG_RESULT(no)
1547     ;;
1548   esac ],
1549   AC_MSG_RESULT(no)
1550 )
1551
1552
1553 #################################################
1554 # check for the DFS auth system
1555 AC_MSG_CHECKING(whether to use DFS auth)
1556 AC_ARG_WITH(dfs,
1557 [  --with-dce-dfs          Include DCE/DFS support (default=no)],
1558 [ case "$withval" in
1559   yes)
1560     AC_MSG_RESULT(yes)
1561     AC_DEFINE(WITH_DFS)
1562     ;;
1563   *)
1564     AC_MSG_RESULT(no)
1565     ;;
1566   esac ],
1567   AC_MSG_RESULT(no)
1568 )
1569
1570 #################################################
1571 # check for Kerberos IV auth system
1572 AC_MSG_CHECKING(whether to use Kerberos IV)
1573 AC_ARG_WITH(krb4,
1574 [  --with-krb4=base-dir    Include Kerberos IV support (default=no)],
1575 [ case "$withval" in
1576   yes)
1577     AC_MSG_RESULT(yes)
1578     AC_DEFINE(KRB4_AUTH)
1579     AC_CHECK_LIB(resolv, dn_expand)
1580     LIBS="$LIBS -lkrb -ldes"
1581     CFLAGS="$CFLAGS -I$withval/include"
1582     LDFLAGS="$LDFLAGS -L$withval/lib"
1583     ;;
1584   *)
1585     AC_MSG_RESULT(no)
1586     ;;
1587   esac ],
1588   AC_MSG_RESULT(no)
1589 )
1590
1591 #################################################
1592 # check for Kerberos 5 auth system
1593 AC_MSG_CHECKING(whether to use Kerberos 5)
1594 AC_ARG_WITH(krb5,
1595 [  --with-krb5=base-dir    Include Kerberos 5 support (default=no)],
1596 [ case "$withval" in
1597   yes)
1598     AC_MSG_RESULT(yes)
1599     AC_DEFINE(KRB5_AUTH)
1600     LIBS="$LIBS -ldes425 -lkrb5 -lcrypto -lcom_err"
1601     CFLAGS="$CFLAGS -I$withval/include"
1602     LDFLAGS="$LDFLAGS -L$withval/lib"
1603     ;;
1604   *)
1605     AC_MSG_RESULT(no)
1606     ;;
1607   esac ],
1608   AC_MSG_RESULT(no)
1609 )
1610
1611 #################################################
1612 # check for automount support
1613 AC_MSG_CHECKING(whether to use AUTOMOUNT)
1614 AC_ARG_WITH(automount,
1615 [  --with-automount        Include AUTOMOUNT support (default=no)],
1616 [ case "$withval" in
1617   yes)
1618     AC_MSG_RESULT(yes)
1619     AC_DEFINE(WITH_AUTOMOUNT)
1620     ;;
1621   *)
1622     AC_MSG_RESULT(no)
1623     ;;
1624   esac ],
1625   AC_MSG_RESULT(no)
1626 )
1627
1628 #################################################
1629 # check for smbmount support
1630 AC_MSG_CHECKING(whether to use SMBMOUNT)
1631 AC_ARG_WITH(smbmount,
1632 [  --with-smbmount         Include SMBMOUNT (Linux only) support (default=no)],
1633 [ case "$withval" in
1634   yes)
1635     AC_MSG_RESULT(yes)
1636     AC_DEFINE(WITH_SMBMOUNT)
1637     MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
1638     ;;
1639   *)
1640     AC_MSG_RESULT(no)
1641     MPROGS=
1642     ;;
1643   esac ],
1644   AC_MSG_RESULT(no)
1645   MPROGS=
1646 )
1647
1648
1649 #################################################
1650 # check for a PAM password database
1651 with_pam_for_crypt=no
1652 AC_MSG_CHECKING(whether to use PAM password database)
1653 AC_ARG_WITH(pam,
1654 [  --with-pam              Include PAM password database support (default=no)],
1655 [ case "$withval" in
1656   yes)
1657     AC_MSG_RESULT(yes)
1658     AC_DEFINE(WITH_PAM)
1659     LIBS="$LIBS -lpam"
1660     with_pam_for_crypt=yes
1661     ;;
1662   *)
1663     AC_MSG_RESULT(no)
1664     ;;
1665   esac ],
1666   AC_MSG_RESULT(no)
1667 )
1668
1669 # we can't build a pam module if we don't have pam.
1670 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM)])
1671
1672 #################################################
1673 # check for pam_smbpass support
1674 AC_MSG_CHECKING(whether to use pam_smbpass)
1675 AC_ARG_WITH(pam_smbpass,
1676 [  --with-pam_smbpass      Include the smbpass PAM module (default=no)],
1677 [ case "$withval" in
1678   yes)
1679     AC_MSG_RESULT(yes)
1680
1681 # Conditions under which pam_smbpass should not be built.
1682
1683        if test x$PICFLAG = x; then
1684           AC_MSG_RESULT([No support for PIC code - disabling pam_smbpass])
1685           PAM_MOD=""
1686        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
1687           AC_MSG_RESULT([No libpam found -- disabling pam_smbpass])
1688           PAM_MOD=""
1689        else
1690           AC_DEFINE(WITH_PAM_SMBPASS)
1691           PAM_MOD="bin/pam_smbpass.so"
1692        fi
1693     ;;
1694   *)
1695     AC_MSG_RESULT(no)
1696     ;;
1697   esac ],
1698   AC_MSG_RESULT(no)
1699 )
1700
1701
1702 ###############################################
1703 # test for where we get crypt() from, but only
1704 # if not using PAM
1705 if test $with_pam_for_crypt = no; then
1706 AC_CHECK_FUNCS(crypt)
1707 if test x"$ac_cv_func_crypt" = x"no"; then
1708     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
1709         AC_DEFINE(HAVE_CRYPT)])
1710 fi
1711 fi
1712
1713 ##
1714 ## moved after the check for -lcrypt in order to
1715 ## ensure that the necessary libraries are included
1716 ## check checking for truncated salt.  Wrapped by the
1717 ## $with_pam_for_crypt variable as above   --jerry
1718 ##
1719 if test $with_pam_for_crypt = no; then
1720 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1721 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
1722         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
1723 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1724         AC_DEFINE(HAVE_TRUNCATED_SALT)
1725 fi
1726 fi
1727
1728
1729 #################################################
1730 # check for a TDB password database
1731 AC_MSG_CHECKING(whether to use TDB password database)
1732 AC_ARG_WITH(tdbsam,
1733 [  --with-tdbsam           Include experimental TDB password database (default=no)],
1734 [ case "$withval" in
1735   yes)
1736     AC_MSG_RESULT(yes)
1737     AC_DEFINE(WITH_TDBPWD)
1738 #    AC_MSG_ERROR([TDB password database not supported in this version.])
1739     ;;
1740   *)
1741     AC_MSG_RESULT(no)
1742     ;;
1743   esac ],
1744   AC_MSG_RESULT(no)
1745 )
1746
1747 #################################################
1748 # check for a LDAP password database
1749 AC_MSG_CHECKING(whether to use LDAP password database)
1750 AC_ARG_WITH(ldap,
1751 [  --with-ldapsam          Include Experimental LDAP-Sam support (default=no)],
1752 [ case "$withval" in
1753   yes)
1754     AC_MSG_RESULT(yes)
1755     AC_DEFINE(WITH_LDAP)
1756     AC_MSG_ERROR([LDAP password database not supported in this version.])
1757     ;;
1758   *)
1759     AC_MSG_RESULT(no)
1760     ;;
1761   esac ],
1762   AC_MSG_RESULT(no)
1763 )
1764
1765 #################################################
1766 # commented out by --jerry
1767 # check for a NISPLUS password database
1768 #AC_MSG_CHECKING(whether to use NISPLUS password database)
1769 #AC_ARG_WITH(nisplus,
1770 #[  --with-nisplus     Include NISPLUS password database support
1771 #[ case "$withval" in
1772 #  yes)
1773 #    AC_MSG_RESULT(yes)
1774 #    AC_DEFINE(WITH_NISPLUS)
1775 #    ;;
1776 #  *)
1777 #    AC_MSG_RESULT(no)
1778 #    ;;
1779 #  esac ],
1780 #  AC_MSG_RESULT(no)
1781 #)
1782
1783 #################################################
1784 # check for a NISPLUS_HOME support 
1785 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
1786 AC_ARG_WITH(nisplus-home,
1787 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
1788 [ case "$withval" in
1789   yes)
1790     AC_MSG_RESULT(yes)
1791     AC_DEFINE(WITH_NISPLUS_HOME)
1792     ;;
1793   *)
1794     AC_MSG_RESULT(no)
1795     ;;
1796   esac ],
1797   AC_MSG_RESULT(no)
1798 )
1799
1800 #################################################
1801 # check for the secure socket layer
1802 AC_MSG_CHECKING(whether to use SSL)
1803 AC_ARG_WITH(ssl,
1804 [  --with-ssl              Include SSL support (default=no)
1805   --with-sslinc=DIR       Where the SSL includes are (defaults to /usr/local/ssl)],
1806 [ case "$withval" in
1807   yes)
1808     AC_MSG_RESULT(yes)
1809     AC_DEFINE(WITH_SSL)
1810     withval="/usr/local/ssl"     # default
1811
1812     if test "${with_sslinc+set}" = set; then
1813
1814         withval="$with_sslinc"
1815         case "$withval" in
1816         yes|no)
1817           echo "configure: warning: --with-sslinc called without argument - will use default" 1>&w
1818           CFLAGS="-I/usr/local/ssl/include $CFLAGS"
1819           LIBS="-lssl -lcrypto $LIBS"
1820           LDFLAGS="=L/usr/local/ssl/lib $LDFLAGS"
1821         ;;
1822         * )
1823           CFLAGS="-I${withval} $CFLAGS"
1824           LIBS="-lssl -lcrypto $LIBS"
1825           LDFLAGS="-L${withval}/lib $LDFLAGS"
1826         ;;
1827         esac
1828
1829     else
1830
1831         CFLAGS="-I/usr/local/ssl/include $CFLAGS"   
1832         LIBS="-lssl -lcrypto $LIBS"
1833         LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
1834
1835     fi
1836
1837     if test ! -d ${withval}; then
1838       echo "configure: error: called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config" 1>&2
1839       exit 1
1840     fi 
1841
1842     CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS"  # Damn, SSLeay defines its own
1843
1844     ;;
1845   *)
1846     AC_MSG_RESULT(no)
1847     ;;
1848   esac ],
1849   AC_MSG_RESULT(no)
1850 )
1851
1852 #################################################
1853 # check for syslog logging
1854 AC_MSG_CHECKING(whether to use syslog logging)
1855 AC_ARG_WITH(syslog,
1856 [  --with-syslog           Include experimental SYSLOG support (default=no)],
1857 [ case "$withval" in
1858   yes)
1859     AC_MSG_RESULT(yes)
1860     AC_DEFINE(WITH_SYSLOG)
1861     ;;
1862   *)
1863     AC_MSG_RESULT(no)
1864     ;;
1865   esac ],
1866   AC_MSG_RESULT(no)
1867 )
1868
1869 #################################################
1870 # check for a shared memory profiling support
1871 AC_MSG_CHECKING(whether to use profiling)
1872 AC_ARG_WITH(profile,
1873 [  --with-profiling-data   Include gathering source code profile information (default=no)],
1874 [ case "$withval" in
1875   yes)
1876     AC_MSG_RESULT(yes)
1877     AC_DEFINE(WITH_PROFILE)
1878     ;;
1879   *)
1880     AC_MSG_RESULT(no)
1881     ;;
1882   esac ],
1883   AC_MSG_RESULT(no)
1884 )
1885
1886
1887 #################################################
1888 # check for experimental disk-quotas support
1889 QUOTAOBJS=smbd/noquotas.o
1890
1891 AC_MSG_CHECKING(whether to support disk-quotas)
1892 AC_ARG_WITH(quotas,
1893 [  --with-quotas           Include experimental disk-quota support (default=no)],
1894 [ case "$withval" in
1895   yes)
1896     AC_MSG_RESULT(yes)
1897     QUOTAOBJS=smbd/quotas.o
1898     ;;
1899   *)
1900     AC_MSG_RESULT(no)
1901     ;;
1902   esac ],
1903   AC_MSG_RESULT(no)
1904 )
1905 AC_SUBST(QUOTAOBJS)
1906
1907 #################################################
1908 # check for experimental utmp accounting
1909
1910 AC_MSG_CHECKING(whether to support utmp accounting)
1911 AC_ARG_WITH(utmp,
1912 [  --with-utmp             Include experimental utmp accounting (default=no)],
1913 [ case "$withval" in
1914   yes)
1915     AC_MSG_RESULT(yes)
1916     AC_DEFINE(WITH_UTMP)
1917     ;;
1918   *)
1919     AC_MSG_RESULT(no)
1920     ;;
1921   esac ],
1922   AC_MSG_RESULT(no)
1923 )
1924
1925 #################################################
1926 # check for MS Dfs support
1927
1928 AC_MSG_CHECKING(whether to support Microsoft Dfs)
1929 AC_ARG_WITH(msdfs,
1930 [  --with-msdfs            Include MS Dfs support (default=no)],
1931 [ case "$withval" in
1932   yes)
1933      AC_MSG_RESULT(yes)
1934      AC_DEFINE(WITH_MSDFS)
1935      ;;
1936   *)
1937     AC_MSG_RESULT(no)
1938     ;;
1939   esac ],
1940   AC_MSG_RESULT(no)
1941 )
1942
1943 #################################################
1944 # set private directory location
1945 AC_ARG_WITH(privatedir,
1946 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
1947 [ case "$withval" in
1948   yes|no)
1949   #
1950   # Just in case anybody calls it without argument
1951   #
1952     AC_MSG_WARN([--with-privatedir called without argument - will use default])
1953     privatedir='${prefix}/private'
1954   ;;
1955   * )
1956     privatedir="$withval"
1957     ;;
1958   esac
1959   AC_SUBST(privatedir)],
1960   [privatedir='${prefix}/private'
1961    AC_SUBST(privatedir)]
1962 )
1963
1964 #################################################
1965 # set lock directory location
1966 AC_ARG_WITH(lockdir,
1967 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
1968 [ case "$withval" in
1969   yes|no)
1970   #
1971   # Just in case anybody calls it without argument
1972   #
1973     AC_MSG_WARN([--with-lockdir called without argument - will use default])
1974     lockdir='$(VARDIR)/locks'
1975   ;;
1976   * )
1977     lockdir="$withval"
1978     ;;
1979   esac
1980   AC_SUBST(lockdir)],
1981   [lockdir='$(VARDIR)/locks'
1982    AC_SUBST(lockdir)]
1983 )
1984
1985 #################################################
1986 # set SWAT directory location
1987 AC_ARG_WITH(swatdir,
1988 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
1989 [ case "$withval" in
1990   yes|no)
1991   #
1992   # Just in case anybody does it
1993   #
1994     AC_MSG_WARN([--with-swatdir called without argument - will use default])
1995     swatdir='${prefix}/swat'
1996   ;;
1997   * )
1998     swatdir="$withval"
1999     ;;
2000   esac
2001   AC_SUBST(swatdir)],
2002   [swatdir='${prefix}/swat'
2003    AC_SUBST(swatdir)]
2004 )
2005
2006 #################################################
2007 # these tests are taken from the GNU fileutils package
2008 AC_CHECKING(how to get filesystem space usage)
2009 space=no
2010
2011 # Test for statvfs64.
2012 if test $space = no; then
2013   # SVR4
2014   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
2015   [AC_TRY_RUN([
2016 #if defined(HAVE_UNISTD_H)
2017 #include <unistd.h>
2018 #endif
2019 #include <sys/types.h>
2020 #include <sys/statvfs.h>
2021   main ()
2022   {
2023     struct statvfs64 fsd;
2024     exit (statvfs64 (".", &fsd));
2025   }],
2026   fu_cv_sys_stat_statvfs64=yes,
2027   fu_cv_sys_stat_statvfs64=no,
2028   fu_cv_sys_stat_statvfs64=cross)])
2029   if test $fu_cv_sys_stat_statvfs64 = yes; then
2030     space=yes
2031     AC_DEFINE(STAT_STATVFS64)
2032   fi
2033 fi
2034
2035 # Perform only the link test since it seems there are no variants of the
2036 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
2037 # because that got a false positive on SCO OSR5.  Adding the declaration
2038 # of a `struct statvfs' causes this test to fail (as it should) on such
2039 # systems.  That system is reported to work fine with STAT_STATFS4 which
2040 # is what it gets when this test fails.
2041 if test $space = no; then
2042   # SVR4
2043   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
2044                  [AC_TRY_LINK([#include <sys/types.h>
2045 #include <sys/statvfs.h>],
2046                               [struct statvfs fsd; statvfs (0, &fsd);],
2047                               fu_cv_sys_stat_statvfs=yes,
2048                               fu_cv_sys_stat_statvfs=no)])
2049   if test $fu_cv_sys_stat_statvfs = yes; then
2050     space=yes
2051     AC_DEFINE(STAT_STATVFS)
2052   fi
2053 fi
2054
2055 if test $space = no; then
2056   # DEC Alpha running OSF/1
2057   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
2058   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
2059   [AC_TRY_RUN([
2060 #include <sys/param.h>
2061 #include <sys/types.h>
2062 #include <sys/mount.h>
2063   main ()
2064   {
2065     struct statfs fsd;
2066     fsd.f_fsize = 0;
2067     exit (statfs (".", &fsd, sizeof (struct statfs)));
2068   }],
2069   fu_cv_sys_stat_statfs3_osf1=yes,
2070   fu_cv_sys_stat_statfs3_osf1=no,
2071   fu_cv_sys_stat_statfs3_osf1=no)])
2072   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
2073   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
2074     space=yes
2075     AC_DEFINE(STAT_STATFS3_OSF1)
2076   fi
2077 fi
2078
2079 if test $space = no; then
2080 # AIX
2081   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
2082 member (AIX, 4.3BSD)])
2083   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
2084   [AC_TRY_RUN([
2085 #ifdef HAVE_SYS_PARAM_H
2086 #include <sys/param.h>
2087 #endif
2088 #ifdef HAVE_SYS_MOUNT_H
2089 #include <sys/mount.h>
2090 #endif
2091 #ifdef HAVE_SYS_VFS_H
2092 #include <sys/vfs.h>
2093 #endif
2094   main ()
2095   {
2096   struct statfs fsd;
2097   fsd.f_bsize = 0;
2098   exit (statfs (".", &fsd));
2099   }],
2100   fu_cv_sys_stat_statfs2_bsize=yes,
2101   fu_cv_sys_stat_statfs2_bsize=no,
2102   fu_cv_sys_stat_statfs2_bsize=no)])
2103   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
2104   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
2105     space=yes
2106     AC_DEFINE(STAT_STATFS2_BSIZE)
2107   fi
2108 fi
2109
2110 if test $space = no; then
2111 # SVR3
2112   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
2113   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
2114   [AC_TRY_RUN([#include <sys/types.h>
2115 #include <sys/statfs.h>
2116   main ()
2117   {
2118   struct statfs fsd;
2119   exit (statfs (".", &fsd, sizeof fsd, 0));
2120   }],
2121     fu_cv_sys_stat_statfs4=yes,
2122     fu_cv_sys_stat_statfs4=no,
2123     fu_cv_sys_stat_statfs4=no)])
2124   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
2125   if test $fu_cv_sys_stat_statfs4 = yes; then
2126     space=yes
2127     AC_DEFINE(STAT_STATFS4)
2128   fi
2129 fi
2130
2131 if test $space = no; then
2132 # 4.4BSD and NetBSD
2133   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
2134 member (4.4BSD and NetBSD)])
2135   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
2136   [AC_TRY_RUN([#include <sys/types.h>
2137 #ifdef HAVE_SYS_PARAM_H
2138 #include <sys/param.h>
2139 #endif
2140 #ifdef HAVE_SYS_MOUNT_H
2141 #include <sys/mount.h>
2142 #endif
2143   main ()
2144   {
2145   struct statfs fsd;
2146   fsd.f_fsize = 0;
2147   exit (statfs (".", &fsd));
2148   }],
2149   fu_cv_sys_stat_statfs2_fsize=yes,
2150   fu_cv_sys_stat_statfs2_fsize=no,
2151   fu_cv_sys_stat_statfs2_fsize=no)])
2152   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
2153   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
2154     space=yes
2155     AC_DEFINE(STAT_STATFS2_FSIZE)
2156   fi
2157 fi
2158
2159 if test $space = no; then
2160   # Ultrix
2161   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
2162   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
2163   [AC_TRY_RUN([#include <sys/types.h>
2164 #ifdef HAVE_SYS_PARAM_H
2165 #include <sys/param.h>
2166 #endif
2167 #ifdef HAVE_SYS_MOUNT_H
2168 #include <sys/mount.h>
2169 #endif
2170 #ifdef HAVE_SYS_FS_TYPES_H
2171 #include <sys/fs_types.h>
2172 #endif
2173   main ()
2174   {
2175   struct fs_data fsd;
2176   /* Ultrix's statfs returns 1 for success,
2177      0 for not mounted, -1 for failure.  */
2178   exit (statfs (".", &fsd) != 1);
2179   }],
2180   fu_cv_sys_stat_fs_data=yes,
2181   fu_cv_sys_stat_fs_data=no,
2182   fu_cv_sys_stat_fs_data=no)])
2183   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
2184   if test $fu_cv_sys_stat_fs_data = yes; then
2185     space=yes
2186     AC_DEFINE(STAT_STATFS2_FS_DATA)
2187   fi
2188 fi
2189
2190 #
2191 # As a gating factor for large file support, in order to
2192 # use <4GB files we must have the following minimal support
2193 # available.
2194 # long long, and a 64 bit off_t or off64_t.
2195 # If we don't have all of these then disable large
2196 # file support.
2197 #
2198 AC_MSG_CHECKING([if large file support can be enabled])
2199 AC_TRY_COMPILE([
2200 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
2201 #include <sys/types.h>
2202 #else
2203 __COMPILE_ERROR_
2204 #endif
2205 ],
2206 [int i],
2207 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
2208 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
2209     AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
2210 fi
2211 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
2212
2213 AC_ARG_WITH(spinlocks, 
2214 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
2215 if test "x$with_spinlocks" = "xyes"; then
2216     AC_DEFINE(USE_SPINLOCKS)
2217
2218     case "$host_cpu" in
2219         sparc)
2220             AC_DEFINE(SPARC_SPINLOCKS)
2221             ;;
2222
2223         i386|i486|i586|i686)
2224             AC_DEFINE(INTEL_SPINLOCKS)
2225             ;;
2226
2227         mips)
2228             AC_DEFINE(MIPS_SPINLOCKS)
2229             ;;
2230
2231         powerpc)
2232             AC_DEFINE(POWERPC_SPINLOCKS)
2233             ;;
2234     esac
2235 fi
2236
2237 #################################################
2238 # check for ACL support
2239
2240 AC_MSG_CHECKING(whether to support ACLs)
2241 AC_ARG_WITH(acl-support,
2242 [  --with-acl-support      Include ACL support (default=no)],
2243 [ case "$withval" in
2244   yes)
2245
2246         case "$host_os" in
2247         *sysv5*)
2248             AC_MSG_RESULT(Using UnixWare ACLs)
2249             AC_DEFINE(HAVE_UNIXWARE_ACLS)
2250             ;;
2251         *solaris*)
2252             AC_MSG_RESULT(Using solaris ACLs)
2253             AC_DEFINE(HAVE_SOLARIS_ACLS)
2254             ;;
2255                 *irix*)
2256                         AC_MSG_RESULT(Using IRIX ACLs)
2257                         AC_DEFINE(HAVE_IRIX_ACLS)
2258                         ;;
2259                 *aix*)
2260                         AC_MSG_RESULT(Using AIX ACLs)
2261                         AC_DEFINE(HAVE_AIX_ACLS)
2262                         ;;
2263                 *osf*)
2264                         AC_MSG_RESULT(Using Tru64 ACLs)
2265                         AC_DEFINE(HAVE_TRU64_ACLS)
2266                         LIBS="$LIBS -lpacl"
2267                         ;;
2268         *)
2269                         AC_CHECK_LIB(acl,acl_get_file)
2270                         AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
2271                         AC_TRY_LINK([#include <sys/types.h>
2272 #include <sys/acl.h>],
2273 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
2274 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)])
2275                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
2276                                 AC_MSG_RESULT(Using posix ACLs)
2277                                 AC_DEFINE(HAVE_POSIX_ACLS)
2278                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
2279                                 AC_TRY_LINK([#include <sys/types.h>
2280 #include <sys/acl.h>],
2281 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
2282 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
2283                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
2284                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP)
2285                                 fi
2286                         fi
2287             ;;
2288         esac
2289         ;;
2290   *)
2291     AC_MSG_RESULT(no)
2292     AC_DEFINE(HAVE_NO_ACLS)
2293     ;;
2294   esac ],
2295   AC_DEFINE(HAVE_NO_ACLS)
2296   AC_MSG_RESULT(no)
2297 )
2298
2299 #################################################
2300 # Check whether winbind is supported on this platform.  If so we need to
2301 # build and install client programs (WINBIND_TARGETS), sbin programs
2302 # (WINBIND_STARGETS) and shared libraries (WINBIND_LTARGETS).
2303
2304 AC_MSG_CHECKING(whether to build winbind)
2305
2306 # Initially, the value of $host_os decides whether winbind is supported
2307
2308 case "$host_os" in 
2309         *linux*|*solaris*)
2310                 HAVE_WINBIND=yes
2311                 ;;
2312         *)
2313                 HAVE_WINBIND=no
2314                 winbind_no_reason=", unsupported on $host_os"
2315                 ;;
2316 esac
2317
2318 # Check the setting of --with-winbindd
2319
2320 AC_ARG_WITH(winbind,
2321 [  --with-winbind          Build winbind (default, if supported by OS)],
2322
2323   case "$withval" in
2324         yes)
2325                 HAVE_WINBIND=yes
2326                 ;;
2327         no)
2328                 HAVE_WINBIND=no
2329                 winbind_reason=""
2330                 ;;
2331   esac ],
2332 )
2333
2334 # We need unix domain sockets for winbind
2335
2336 if test x"$HAVE_WINBIND" = x"yes"; then
2337         if test x"$samba_cv_unixsocket" = x"no"; then
2338                 winbind_no_reason=", no unix domain socket support on $host_os"
2339                 HAVE_WINBIND=no
2340         fi
2341 fi
2342
2343 # Display test results
2344
2345 if test x"$HAVE_WINBIND" = x"yes"; then
2346
2347         AC_MSG_RESULT(yes)
2348
2349         WINBIND_TARGETS="\$(WINBIND_PROGS)"
2350         WINBIND_STARGETS="\$(WINBIND_SPROGS)"
2351         WINBIND_LTARGETS="\$(WINBIND_LPROGS)"
2352
2353         case "$with_pam" in
2354                 yes)
2355                         WINBIND_PAM_PROGS="\$(WINBIND_PAM_PROGS)"
2356                 ;;
2357         esac
2358 else
2359         AC_MSG_RESULT(no$winbind_no_reason)
2360
2361         WINBIND_TARGETS=""
2362         WINBIND_STARGETS=""
2363         WINBIND_LTARGETS=""
2364         WINBIND_PAM_PROGS=""
2365 fi
2366
2367 # Substitution time!
2368
2369 AC_SUBST(WINBIND_TARGETS)
2370 AC_SUBST(WINBIND_STARGETS)
2371 AC_SUBST(WINBIND_LTARGETS)
2372 AC_SUBST(WINBIND_PAM_PROGS)
2373
2374 #################################################
2375 # final configure stuff
2376
2377 echo "checking configure summary"
2378 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
2379            echo "configure OK";,
2380            AC_MSG_ERROR([summary failure. Aborting config]),:)
2381
2382 builddir=`pwd`
2383 AC_SUBST(builddir)
2384
2385 AC_OUTPUT(include/stamp-h Makefile)