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