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