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