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