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