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