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