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