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