remove unused configure checks and options
[bbaumbach/samba-autobuild/.git] / source4 / configure.in
1 dnl -*- mode: m4-mode -*-
2 dnl Process this file with autoconf to produce a configure script.
3
4 dnl disabled 2.53 requirement - we do work with 2.52 on suse 7.3 for example
5 dnl AC_PREREQ(2.53)
6
7
8 AC_INIT(include/includes.h)
9 AC_CONFIG_HEADER(include/config.h)
10
11 AC_DISABLE_STATIC
12 AC_ENABLE_SHARED
13
14 #################################################
15 # Directory handling stuff to support both the
16 # legacy SAMBA directories and FHS compliant
17 # ones...
18 AC_PREFIX_DEFAULT(/usr/local/samba)
19
20 AC_ARG_WITH(fhs, 
21 [  --with-fhs              Use FHS-compliant paths (default=no)],
22     configdir="${sysconfdir}/samba"
23     lockdir="\${VARDIR}/cache/samba"
24     piddir="\${VARDIR}/run/samba"
25     logfilebase="\${VARDIR}/log/samba"
26     privatedir="\${CONFIGDIR}/private"
27     libdir="\${prefix}/lib/samba"
28     swatdir="\${DATADIR}/samba/swat",
29     configdir="\${LIBDIR}"
30     logfilebase="\${VARDIR}"
31     lockdir="\${VARDIR}/locks"
32     piddir="\${VARDIR}/locks"
33     privatedir="\${prefix}/private"
34     swatdir="\${prefix}/swat")
35
36 #################################################
37 # set private directory location
38 AC_ARG_WITH(privatedir,
39 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
40 [ case "$withval" in
41   yes|no)
42   #
43   # Just in case anybody calls it without argument
44   #
45     AC_MSG_WARN([--with-privatedir called without argument - will use default])
46   ;;
47   * )
48     privatedir="$withval"
49     ;;
50   esac])
51
52 #################################################
53 # set lock directory location
54 AC_ARG_WITH(lockdir,
55 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
56 [ case "$withval" in
57   yes|no)
58   #
59   # Just in case anybody calls it without argument
60   #
61     AC_MSG_WARN([--with-lockdir called without argument - will use default])
62   ;;
63   * )
64     lockdir="$withval"
65     ;;
66   esac])
67
68 #################################################
69 # set pid directory location
70 AC_ARG_WITH(piddir,
71 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
72 [ case "$withval" in
73   yes|no)
74   #
75   # Just in case anybody calls it without argument
76   #
77     AC_MSG_WARN([--with-piddir called without argument - will use default])
78   ;;
79   * )
80     piddir="$withval"
81     ;;
82   esac])
83
84 #################################################
85 # set configuration directory location
86 AC_ARG_WITH(configdir,
87 [  --with-configdir=DIR    Where to put configuration files (\$libdir)],
88 [ case "$withval" in
89   yes|no)
90   #
91   # Just in case anybody does it
92   #
93     AC_MSG_WARN([--with-configdir called without argument - will use default])
94   ;;
95   * )
96     configdir="$withval"
97     ;;
98   esac])
99
100 #################################################
101 # set log directory location
102 AC_ARG_WITH(logfilebase,
103 [  --with-logfilebase=DIR  Where to put log files (\$(VARDIR))],
104 [ case "$withval" in
105   yes|no)
106   #
107   # Just in case anybody does it
108   #
109     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
110   ;;
111   * )
112     logfilebase="$withval"
113     ;;
114   esac])
115
116 AC_SUBST(configdir)
117 AC_SUBST(lockdir)
118 AC_SUBST(piddir)
119 AC_SUBST(logfilebase)
120 AC_SUBST(privatedir)
121 AC_SUBST(bindir)
122 AC_SUBST(sbindir)
123
124 dnl Unique-to-Samba variables we'll be playing with.
125 AC_SUBST(SHELL)
126 AC_SUBST(LDSHFLAGS)
127 AC_SUBST(SONAMEFLAG)
128 AC_SUBST(SHLD)
129 AC_SUBST(HOST_OS)
130 AC_SUBST(PICFLAG)
131 AC_SUBST(PICSUFFIX)
132 AC_SUBST(POBAD_CC)
133 AC_SUBST(SHLIBEXT)
134 AC_SUBST(INSTALLCLIENTCMD_SH)
135 AC_SUBST(INSTALLCLIENTCMD_A)
136 AC_SUBST(LIBSMBCLIENT_SHARED)
137 AC_SUBST(LIBSMBCLIENT)
138 AC_SUBST(PRINTLIBS)
139 AC_SUBST(AUTHLIBS)
140 AC_SUBST(ACLLIBS)
141 AC_SUBST(SHLIB_PROGS)
142 AC_SUBST(SMBWRAPPER)
143 AC_SUBST(EXTRA_BIN_PROGS)
144 AC_SUBST(EXTRA_SBIN_PROGS)
145 AC_SUBST(EXTRA_ALL_TARGETS)
146
147 AC_ARG_ENABLE(debug, 
148 [  --enable-debug          Turn on compiler debugging information (default=no)],
149     [if eval "test x$enable_debug = xyes"; then
150         CFLAGS="${CFLAGS} -gstabs"
151     fi])
152
153 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
154     [if eval "test x$enable_developer = xyes"; then
155         developer=yes
156         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
157     fi])
158
159 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
160     [if eval "test x$enable_krb5developer = xyes"; then
161         developer=yes
162         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
163     fi])
164
165 dnl Checks for programs.
166 AC_PROG_CC
167 AC_PROG_INSTALL
168 AC_PATH_PROG(PERL, perl)
169
170 # compile with optimization and without debugging by default, but
171 # allow people to set their own preference.
172 if test "x$CFLAGS" = x
173 then
174   CFLAGS="-O ${CFLAGS}"
175 fi
176
177 dnl Check if we use GNU ld
178 LD=ld
179 AC_PROG_LD_GNU
180
181 dnl needed before AC_TRY_COMPILE
182 AC_ISC_POSIX
183
184 dnl look for executable suffix
185 AC_EXEEXT
186
187 dnl Check if C compiler understands -c and -o at the same time
188 AC_PROG_CC_C_O
189 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
190       BROKEN_CC=
191 else
192       BROKEN_CC=#
193 fi
194 AC_SUBST(BROKEN_CC)
195
196 AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
197         dnl Check whether the compiler can generate precompiled headers
198         touch conftest.h
199         if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
200                 samba_cv_precompiled_headers=yes
201         else
202                 samba_cv_precompiled_headers=no
203         fi])
204 PCH_AVAILABLE="#"
205 if test x"$samba_cv_precompiled_headers" = x"yes"; then
206         PCH_AVAILABLE=""
207 fi
208 AC_SUBST(PCH_AVAILABLE)
209
210
211 dnl Check if the C compiler understands volatile (it should, being ANSI).
212 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
213     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
214         samba_cv_volatile=yes,samba_cv_volatile=no)])
215 if test x"$samba_cv_volatile" = x"yes"; then
216    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
217 fi
218
219
220 AC_CANONICAL_SYSTEM
221
222 dnl Add #include for broken IRIX header files
223   case "$host_os" in
224         *irix6*) AC_ADD_INCLUDE(<standards.h>)
225         ;;
226 esac
227
228 AC_VALIDATE_CACHE_SYSTEM_TYPE
229
230 DYNEXP=
231
232 #
233 # Config CPPFLAG settings for strange OS's that must be set
234 # before other tests.
235 #
236 case "$host_os" in
237 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
238     *hpux*)
239     
240       AC_PROG_CC_FLAG(Ae)
241       # mmap on HPUX is completely broken...
242       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
243       if test $ac_cv_prog_cc_Ae = yes; then
244         CPPFLAGS="$CPPFLAGS -Ae"
245       fi
246 #
247 # Defines needed for HPUX support.
248 # HPUX has bigcrypt but (sometimes?) doesn't use it for
249 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
250 #
251       case `uname -r` in
252                         *9*|*10*)
253                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
254                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
255                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
256                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
257                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
258                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
259                                 ;;
260                         *11*)
261                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
262                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
263                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
264                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
265                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
266                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
267                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
268                                 ;;
269       esac
270       DYNEXP="-Wl,-E"
271       ;;
272
273 #
274 # CRAY Unicos has broken const handling
275        *unicos*)
276           AC_MSG_RESULT([disabling const])
277           CPPFLAGS="$CPPFLAGS -Dconst="
278           ;;
279         
280 #
281 # AIX4.x doesn't even admit to having large
282 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
283 #
284     *aix4*)
285           AC_MSG_RESULT([enabling large file support])
286       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
287           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
288       ;;    
289 #
290 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
291 # to the existance of large files..
292 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
293 # recommendations on large file support, however it makes the
294 # compile work using gcc 2.7 and 2.8, whereas using the Sun
295 # recommendation makes the compile fail on gcc2.7. JRA.
296 #
297         *solaris*)
298                 case `uname -r` in
299                         5.0*|5.1*|5.2*|5.3*|5.5*)
300                                 AC_MSG_RESULT([no large file support])
301                                 ;;
302                         5.*)
303                         AC_MSG_RESULT([enabling large file support])
304                         if test "$ac_cv_prog_gcc" = yes; then
305                                 ${CC-cc} -v >conftest.c 2>&1
306                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
307                                 rm -fr conftest.c
308                                 case "$ac_cv_gcc_compiler_version_number" in
309                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
310                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
311                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
312                                                 ;;
313                                         *)
314                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
315                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
316                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
317                                                 ;;
318                                 esac
319                         else
320                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
321                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
322                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
323                         fi
324                         ;;
325                 esac
326                 ;;
327 #
328 # VOS may need to have POSIX support and System V compatibility enabled.
329 #
330     *vos*)
331     case "$CPPFLAGS" in
332           *-D_POSIX_C_SOURCE*)
333                 ;;
334           *)
335                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=199506L"
336                 AC_DEFINE(_POSIX_C_SOURCE, 199506L, [Whether to enable POSIX support])
337                 ;;
338     esac
339     case "$CPPFLAGS" in
340           *-D_SYSV*|*-D_SVID_SOURCE*)
341                 ;;
342           *)
343                 CPPFLAGS="$CPPFLAGS -D_SYSV"
344                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
345     esac
346     ;;
347 #
348 # Tests needed for SINIX large file support.
349 #
350     *sysv4*)
351       if test $host = mips-sni-sysv4 ; then
352         AC_MSG_CHECKING([for LFS support])
353         old_CPPFLAGS="$CPPFLAGS"
354         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
355         AC_TRY_RUN([
356 #include <unistd.h>
357 main () {
358 #if _LFS64_LARGEFILE == 1
359 exit(0);
360 #else
361 exit(1);
362 #endif
363 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
364         CPPFLAGS="$old_CPPFLAGS"
365         if test x$SINIX_LFS_SUPPORT = xyes ; then
366           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
367                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
368           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
369           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
370           LIBS="`getconf LFS64_LIBS` $LIBS"
371         fi
372       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
373       fi
374     ;;
375
376 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
377 #
378     *linux*)
379         AC_MSG_CHECKING([for LFS support])
380         old_CPPFLAGS="$CPPFLAGS"
381         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
382        AC_TRY_RUN([
383 #include <unistd.h>
384 #include <sys/utsname.h>
385 #include <string.h>
386 #include <stdlib.h>
387 main() {
388 #if _LFS64_LARGEFILE == 1
389        struct utsname uts;
390        char *release;
391        int major, minor;
392
393        /* Ensure this is glibc 2.2 or higher */
394 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
395        int libc_major = __GLIBC__;
396        int libc_minor = __GLIBC_MINOR__;
397
398        if (libc_major < 2)
399               exit(1);
400        if (libc_minor < 2)
401               exit(1);
402 #endif
403
404        /* Ensure this is kernel 2.4 or higher */
405
406        uname(&uts);
407        release = uts.release;
408        major = atoi(strsep(&release, "."));
409        minor = atoi(strsep(&release, "."));
410
411        if (major > 2 || (major == 2 && minor > 3))
412                exit(0);
413        exit(1);
414 #else
415        exit(1);
416 #endif
417 }
418 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
419         CPPFLAGS="$old_CPPFLAGS"
420         if test x$LINUX_LFS_SUPPORT = xyes ; then
421           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
422                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
423           AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
424           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
425         fi
426        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
427                 ;;
428
429     *hurd*)
430         AC_MSG_CHECKING([for LFS support])
431         old_CPPFLAGS="$CPPFLAGS"
432         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
433         AC_TRY_RUN([
434 #include <unistd.h>
435 main () {
436 #if _LFS64_LARGEFILE == 1
437 exit(0);
438 #else
439 exit(1);
440 #endif
441 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
442         CPPFLAGS="$old_CPPFLAGS"
443         if test x$GLIBC_LFS_SUPPORT = xyes ; then
444           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
445                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
446           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
447         fi
448       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
449     ;;
450
451 esac
452
453 AC_INLINE
454 AC_HEADER_STDC
455 AC_HEADER_DIRENT
456 AC_HEADER_TIME
457 AC_HEADER_SYS_WAIT
458 AC_CHECK_HEADERS(arpa/inet.h sys/select.h fcntl.h sys/fcntl.h sys/time.h)
459 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
460 AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
461 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
462 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
463 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
464 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
465 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h ldap.h lber.h dlfcn.h)
466 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
467
468 #
469 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
470 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
471 #
472 case "$host_os" in
473     *hpux*)
474                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
475                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
476                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
477                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
478                 fi
479         ;;
480 esac
481 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
482 AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
483 AC_CHECK_HEADERS(stropts.h)
484 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
485 AC_CHECK_HEADERS(sys/acl.h)
486
487 AC_CHECK_SIZEOF(int,cross)
488 AC_CHECK_SIZEOF(long,cross)
489 AC_CHECK_SIZEOF(short,cross)
490
491 AC_C_CONST
492 AC_C_INLINE
493 AC_C_BIGENDIAN
494 AC_C_CHAR_UNSIGNED
495
496 AC_TYPE_SIGNAL
497 AC_TYPE_UID_T
498 AC_TYPE_MODE_T
499 AC_TYPE_OFF_T
500 AC_TYPE_SIZE_T
501 AC_TYPE_PID_T
502 AC_STRUCT_ST_RDEV
503 AC_DIRENT_D_OFF
504 AC_CHECK_TYPE(ino_t,unsigned)
505 AC_CHECK_TYPE(loff_t,off_t)
506 AC_CHECK_TYPE(offset_t,loff_t)
507 AC_CHECK_TYPE(ssize_t, int)
508 AC_CHECK_TYPE(wchar_t, unsigned short)
509 AC_CHECK_TYPE(uint_t, unsigned int)
510
511 ############################################
512 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
513 AC_SEARCH_LIBS(dlopen, [dl])
514 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
515
516 ############################################
517 # check if the compiler can do immediate structures
518 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
519     AC_TRY_COMPILE([
520 #include <stdio.h>],
521 [
522    typedef struct {unsigned x;} FOOBAR;
523    #define X_FOOBAR(x) ((FOOBAR) { x })
524    #define FOO_ONE X_FOOBAR(1)
525    FOOBAR f = FOO_ONE;   
526    static struct {
527         FOOBAR y; 
528         } f2[] = {
529                 {FOO_ONE}
530         };   
531 ],
532         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
533 if test x"$samba_cv_immediate_structures" = x"yes"; then
534    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
535 fi
536
537 ############################################
538 # check for unix domain sockets
539 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
540     AC_TRY_COMPILE([
541 #include <sys/types.h>
542 #include <stdlib.h>
543 #include <stddef.h>
544 #include <sys/socket.h>
545 #include <sys/un.h>],
546 [
547   struct sockaddr_un sunaddr; 
548   sunaddr.sun_family = AF_UNIX;
549 ],
550         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
551 if test x"$samba_cv_unixsocket" = x"yes"; then
552    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
553 fi
554
555
556 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
557     AC_TRY_COMPILE([
558 #include <sys/types.h>
559 #if STDC_HEADERS
560 #include <stdlib.h>
561 #include <stddef.h>
562 #endif
563 #include <sys/socket.h>],[socklen_t i = 0],
564         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
565 if test x"$samba_cv_socklen_t" = x"yes"; then
566    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
567 fi
568
569 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
570     AC_TRY_COMPILE([
571 #include <sys/types.h>
572 #if STDC_HEADERS
573 #include <stdlib.h>
574 #include <stddef.h>
575 #endif
576 #include <signal.h>],[sig_atomic_t i = 0],
577         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
578 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
579    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
580 fi
581
582 # stupid headers have the functions but no declaration. grrrr.
583 AC_HAVE_DECL(errno, [#include <errno.h>])
584 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
585 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
586 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
587 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
588 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
589 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
590
591 # and glibc has setresuid under linux but the function does
592 # nothing until kernel 2.1.44! very dumb.
593 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
594     AC_TRY_RUN([#include <errno.h>
595 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
596         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
597 if test x"$samba_cv_have_setresuid" = x"yes"; then
598     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
599 fi
600
601 # Do the same check for setresguid...
602 #
603 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
604     AC_TRY_RUN([#include <unistd.h>
605 #include <errno.h>
606 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
607         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
608 if test x"$samba_cv_have_setresgid" = x"yes"; then
609     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
610 fi
611
612 AC_FUNC_MEMCMP
613
614 ###############################################
615 # Readline included by default unless explicitly asked not to
616 test "${with_readline+set}" != "set" && with_readline=yes
617
618 # test for where we get readline() from
619 AC_MSG_CHECKING(whether to use readline)
620 AC_ARG_WITH(readline,
621 [  --with-readline[=DIR]   Look for readline include/libs in DIR (default=auto) ],
622 [  case "$with_readline" in
623   yes)
624     AC_MSG_RESULT(yes)
625
626     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
627     AC_CHECK_HEADERS(readline/history.h)
628
629     AC_CHECK_HEADERS(readline.h readline/readline.h,[
630       for termlib in ncurses curses termcap terminfo termlib tinfo; do
631        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
632       done
633       AC_CHECK_LIB(readline, rl_callback_handler_install,
634        [TERMLIBS="-lreadline $TERMLIBS"
635        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
636        break], [TERMLIBS=], $TERMLIBS)])
637     ;;
638   no)
639     AC_MSG_RESULT(no)
640     ;;
641   *)
642     AC_MSG_RESULT(yes)
643
644     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
645     # alternate readline path
646     _ldflags=${LDFLAGS}
647     _cppflags=${CPPFLAGS}
648
649     # Add additional search path
650     LDFLAGS="-L$with_readline/lib $LDFLAGS"
651     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
652
653     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
654     AC_CHECK_HEADERS(readline/history.h)
655
656     AC_CHECK_HEADERS(readline.h readline/readline.h,[
657       for termlib in ncurses curses termcap terminfo termlib; do
658        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
659       done
660       AC_CHECK_LIB(readline, rl_callback_handler_install,
661        [TERMLDFLAGS="-L$with_readline/lib"
662        TERMCPPFLAGS="-I$with_readline/include"
663        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
664        TERMLIBS="-lreadline $TERMLIBS"
665        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
666        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
667
668     LDFLAGS=$_ldflags
669     ;;
670   esac],
671   AC_MSG_RESULT(no)
672 )
673 AC_SUBST(TERMLIBS)
674 AC_SUBST(TERMLDFLAGS)
675
676 # The readline API changed slightly from readline3 to readline4, so
677 # code will generate warnings on one of them unless we have a few
678 # special cases.
679 AC_CHECK_LIB(readline, rl_completion_matches,
680              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
681                         [Do we have rl_completion_matches?])],
682              [],
683              [$TERMLIBS])
684
685 # The following test taken from the cvs sources
686 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
687 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
688 # libsocket.so which has a bad implementation of gethostbyname (it
689 # only looks in /etc/hosts), so we only look for -lsocket if we need
690 # it.
691 AC_CHECK_FUNCS(connect)
692 if test x"$ac_cv_func_connect" = x"no"; then
693     case "$LIBS" in
694     *-lnsl*) ;;
695     *) AC_CHECK_LIB(nsl_s, printf) ;;
696     esac
697     case "$LIBS" in
698     *-lnsl*) ;;
699     *) AC_CHECK_LIB(nsl, printf) ;;
700     esac
701     case "$LIBS" in
702     *-lsocket*) ;;
703     *) AC_CHECK_LIB(socket, connect) ;;
704     esac
705     case "$LIBS" in
706     *-linet*) ;;
707     *) AC_CHECK_LIB(inet, connect) ;;
708     esac
709     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
710     dnl has been cached.
711     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
712        test x"$ac_cv_lib_inet_connect" = x"yes"; then
713         # ac_cv_func_connect=yes
714         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
715         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
716     fi
717 fi
718
719 ###############################################
720 # test for where we get yp_get_default_domain() from
721 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
722 AC_CHECK_FUNCS(yp_get_default_domain)
723
724 # Check if we have execl, if not we need to compile smbrun.
725 AC_CHECK_FUNCS(execl)
726 if test x"$ac_cv_func_execl" = x"no"; then
727     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
728 fi
729
730 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
731 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
732 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
733 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
734 AC_CHECK_FUNCS(initgroups select rdchk getgrnam getgrent pathconf realpath)
735 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
736 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
737 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
738 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
739 AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm)
740 # setbuffer, shmget, shm_open are needed for smbtorture
741 AC_CHECK_FUNCS(setbuffer shmget shm_open)
742
743 # syscall() is needed for smbwrapper.
744 AC_CHECK_FUNCS(syscall)
745
746 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
747 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
748 AC_CHECK_FUNCS(__getcwd _getcwd)
749 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
750 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
751 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
752 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
753 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
754 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
755 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
756 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
757 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
758 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
759 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
760
761 #
762 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
763 #
764
765 if test x$ac_cv_func_stat64 = xno ; then
766   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
767   AC_TRY_LINK([
768 #if defined(HAVE_UNISTD_H)
769 #include <unistd.h>
770 #endif
771 #include <sys/stat.h>
772 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
773   AC_MSG_RESULT([$ac_cv_func_stat64])
774   if test x$ac_cv_func_stat64 = xyes ; then
775     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
776   fi
777 fi
778
779 if test x$ac_cv_func_lstat64 = xno ; then
780   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
781   AC_TRY_LINK([
782 #if defined(HAVE_UNISTD_H)
783 #include <unistd.h>
784 #endif
785 #include <sys/stat.h>
786 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
787   AC_MSG_RESULT([$ac_cv_func_lstat64])
788   if test x$ac_cv_func_lstat64 = xyes ; then
789     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
790   fi
791 fi
792
793 if test x$ac_cv_func_fstat64 = xno ; then
794   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
795   AC_TRY_LINK([
796 #if defined(HAVE_UNISTD_H)
797 #include <unistd.h>
798 #endif
799 #include <sys/stat.h>
800 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
801   AC_MSG_RESULT([$ac_cv_func_fstat64])
802   if test x$ac_cv_func_fstat64 = xyes ; then
803     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
804   fi
805 fi
806
807 #####################################
808 # we might need the resolv library on some systems
809 AC_CHECK_LIB(resolv, dn_expand)
810
811 #
812 # Check for the functions putprpwnam, set_auth_parameters,
813 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
814 # Needed for OSF1 and HPUX.
815 #
816
817 AC_LIBTESTFUNC(security, putprpwnam)
818 AC_LIBTESTFUNC(sec, putprpwnam)
819
820 AC_LIBTESTFUNC(security, set_auth_parameters)
821 AC_LIBTESTFUNC(sec, set_auth_parameters)
822
823 # UnixWare 7.x has its getspnam in -lgen
824 AC_LIBTESTFUNC(gen, getspnam)
825
826 AC_LIBTESTFUNC(security, getspnam)
827 AC_LIBTESTFUNC(sec, getspnam)
828
829 AC_LIBTESTFUNC(security, bigcrypt)
830 AC_LIBTESTFUNC(sec, bigcrypt)
831
832 AC_LIBTESTFUNC(security, getprpwnam)
833 AC_LIBTESTFUNC(sec, getprpwnam)
834
835 # Assume non-shared by default and override below
836 BLDSHARED="false"
837
838 # these are the defaults, good for lots of systems
839 HOST_OS="$host_os"
840 LDSHFLAGS="-shared"
841 SONAMEFLAG="#"
842 SHLD="\${CC}"
843 PICFLAG=""
844 PICSUFFIX="po"
845 POBAD_CC="#"
846 SHLIBEXT="so"
847
848 if test "$enable_shared" = "yes"; then
849   # this bit needs to be modified for each OS that is suported by
850   # smbwrapper. You need to specify how to created a shared library and
851   # how to compile C code to produce PIC object files
852
853   AC_MSG_CHECKING([ability to build shared libraries])
854
855   # and these are for particular systems
856   case "$host_os" in
857                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
858                         BLDSHARED="true"
859                         LDSHFLAGS="-shared" 
860                         DYNEXP="-Wl,--export-dynamic"
861                         PICFLAG="-fPIC"
862                         SONAMEFLAG="-Wl,-soname="
863                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
864                         ;;
865                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
866                         BLDSHARED="true"
867                         LDSHFLAGS="-G"
868                         SONAMEFLAG="-h "
869                         if test "${GCC}" = "yes"; then
870                                 PICFLAG="-fPIC"
871                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
872                                         DYNEXP="-Wl,-E"
873                                 fi
874                         else
875                                 PICFLAG="-KPIC"
876                                 ## ${CFLAGS} added for building 64-bit shared 
877                                 ## libs using Sun's Compiler
878                                 LDSHFLAGS="-G \${CFLAGS}"
879                                 POBAD_CC=""
880                                 PICSUFFIX="po.o"
881                         fi
882                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
883                         ;;
884                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
885                         BLDSHARED="true"
886                         LDSHFLAGS="-G"
887                         SONAMEFLAG="-Wl,-h,"
888                         PICFLAG="-KPIC"   # Is this correct for SunOS
889                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
890                         ;;
891                 *netbsd* | *freebsd*)  BLDSHARED="true"
892                         LDSHFLAGS="-shared"
893                         DYNEXP="-Wl,--export-dynamic"
894                         SONAMEFLAG="-Wl,-soname,"
895                         PICFLAG="-fPIC -DPIC"
896                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
897                         ;;
898                 *openbsd*)  BLDSHARED="true"
899                         LDSHFLAGS="-shared"
900                         DYNEXP="-Wl,-Bdynamic"
901                         SONAMEFLAG="-Wl,-soname,"
902                         PICFLAG="-fPIC"
903                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
904                         ;;
905                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
906                         case "$host_os" in
907                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
908                         ;;
909                         esac
910                         ATTEMPT_WRAP32_BUILD=yes
911                         BLDSHARED="true"
912                         LDSHFLAGS="-set_version sgi1.0 -shared"
913                         SONAMEFLAG="-soname "
914                         SHLD="\${LD}"
915                         if test "${GCC}" = "yes"; then
916                                 PICFLAG="-fPIC"
917                         else 
918                                 PICFLAG="-KPIC"
919                         fi
920                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
921                         ;;
922                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
923                         BLDSHARED="true"
924                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
925                         DYNEXP="-Wl,-brtl,-bexpall"
926                         PICFLAG="-O2"
927                         if test "${GCC}" != "yes"; then
928                                 ## for funky AIX compiler using strncpy()
929                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
930                         fi
931
932                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
933                         ;;
934                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
935                         SHLIBEXT="sl"
936                         # Use special PIC flags for the native HP-UX compiler.
937                         if test $ac_cv_prog_cc_Ae = yes; then
938                                 BLDSHARED="true"
939                                 SHLD="/usr/bin/ld"
940                                 LDSHFLAGS="-B symbolic -b -z"
941                                 SONAMEFLAG="+h "
942                                 PICFLAG="+z"
943                         fi
944                         DYNEXP="-Wl,-E"
945                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
946                         ;;
947                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
948                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
949                         ;;
950                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
951                         BLDSHARED="true"
952                         LDSHFLAGS="-shared"
953                         SONAMEFLAG="-Wl,-soname,"
954                         PICFLAG="-fPIC"
955                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
956                         ;;
957                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
958                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
959                         ;;
960                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
961                         BLDSHARED="true"
962                         LDSHFLAGS="-shared"
963                         SONAMEFLAG="-Wl,-soname,"
964                         PICFLAG="-KPIC"
965                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
966                         ;;
967                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
968                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
969                         ;;
970                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
971                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
972                         ;;
973                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
974                         case "$host" in
975                                 *-univel-*)     if [ test "$GCC" != yes ]; then
976                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
977                                         fi
978                                         LDSHFLAGS="-G"
979                                         DYNEXP="-Bexport"
980                                 ;;
981                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
982                         esac
983                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
984                         ;;
985
986                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
987                         if [ test "$GCC" != yes ]; then
988                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
989                         fi
990                         LDSHFLAGS="-G"
991                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
992                         ;;
993                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
994                         BLDSHARED="false"
995                         LDSHFLAGS=""
996                         ;;
997                 *)
998                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
999                         ;;
1000   esac
1001   AC_SUBST(DYNEXP)
1002   AC_MSG_RESULT($BLDSHARED)
1003   AC_MSG_CHECKING([linker flags for shared libraries])
1004   AC_MSG_RESULT([$LDSHFLAGS])
1005   AC_MSG_CHECKING([compiler flags for position-independent code])
1006   AC_MSG_RESULT([$PICFLAGS])
1007 fi
1008
1009 #######################################################
1010 # test whether building a shared library actually works
1011 if test $BLDSHARED = true; then
1012 AC_CACHE_CHECK([whether building shared libraries actually works], 
1013                [ac_cv_shlib_works],[
1014    ac_cv_shlib_works=no
1015    # try building a trivial shared library
1016    if test "$PICSUFFIX" = "po"; then
1017      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/tests/shlib.c &&
1018        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
1019        ac_cv_shlib_works=yes
1020    else
1021      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c &&
1022        mv shlib.$PICSUFFIX shlib.po &&
1023        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
1024        ac_cv_shlib_works=yes
1025    fi
1026    rm -f shlib.so shlib.po
1027 ])
1028 if test $ac_cv_shlib_works = no; then
1029    BLDSHARED=false
1030 fi
1031 fi
1032
1033 ################
1034
1035 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1036 AC_TRY_RUN([#include <stdio.h>
1037 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1038 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1039 if test x"$samba_cv_have_longlong" = x"yes"; then
1040     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1041 fi
1042
1043 #
1044 # Check if the compiler supports the LL prefix on long long integers.
1045 # AIX needs this.
1046
1047 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1048     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1049         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1050 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1051    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1052 fi
1053
1054   
1055 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1056 AC_TRY_RUN([#include <stdio.h>
1057 #include <sys/stat.h>
1058 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1059 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1060 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1061     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1062 fi
1063
1064 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1065 AC_TRY_RUN([
1066 #if defined(HAVE_UNISTD_H)
1067 #include <unistd.h>
1068 #endif
1069 #include <stdio.h>
1070 #include <sys/stat.h>
1071 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1072 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1073 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1074     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1075 fi
1076
1077 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1078 AC_TRY_RUN([#include <stdio.h>
1079 #include <sys/stat.h>
1080 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1081 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1082 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1083     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1084 fi
1085
1086 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1087 AC_TRY_RUN([
1088 #if defined(HAVE_UNISTD_H)
1089 #include <unistd.h>
1090 #endif
1091 #include <stdio.h>
1092 #include <sys/stat.h>
1093 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1094 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1095 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1096     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1097 fi
1098
1099 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1100 AC_TRY_RUN([
1101 #if defined(HAVE_UNISTD_H)
1102 #include <unistd.h>
1103 #endif
1104 #include <stdio.h>
1105 #include <sys/stat.h>
1106 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1107 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1108 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1109     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1110 fi
1111
1112 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1113 AC_TRY_COMPILE([
1114 #if defined(HAVE_UNISTD_H)
1115 #include <unistd.h>
1116 #endif
1117 #include <sys/types.h>
1118 #include <dirent.h>],
1119 [struct dirent64 de;],
1120 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1121 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1122     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1123 fi
1124
1125 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1126 AC_TRY_RUN([
1127 #if defined(HAVE_UNISTD_H)
1128 #include <unistd.h>
1129 #endif
1130 #include <sys/types.h>
1131 main() { dev_t dev; int i = major(dev); return 0; }],
1132 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1133 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1134     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1135 fi
1136
1137 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1138 AC_TRY_RUN([
1139 #if defined(HAVE_UNISTD_H)
1140 #include <unistd.h>
1141 #endif
1142 #include <sys/types.h>
1143 main() { dev_t dev; int i = minor(dev); return 0; }],
1144 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1145 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1146     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1147 fi
1148
1149 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1150 AC_TRY_RUN([#include <stdio.h>
1151 main() { char c; c=250; exit((c > 0)?0:1); }],
1152 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1153 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1154     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1155 fi
1156
1157 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1158 AC_TRY_COMPILE([#include <sys/types.h>
1159 #include <sys/socket.h>
1160 #include <netinet/in.h>],
1161 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1162 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1163 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1164     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1165 fi
1166
1167 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1168 AC_TRY_COMPILE([#include <sys/types.h>
1169 #include <dirent.h>
1170 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1171 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1172 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1173     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
1174 fi
1175
1176 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1177 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1178 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1179 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1180     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
1181 fi
1182
1183 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1184 AC_TRY_RUN([
1185 #include <sys/time.h>
1186 #include <unistd.h>
1187 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1188            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1189 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1190     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
1191 fi
1192
1193 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE_VA_COPY,[
1194 AC_TRY_LINK([#include <stdarg.h>
1195 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
1196 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
1197 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
1198     AC_DEFINE(HAVE_VA_COPY,1,[Whether __va_copy() is available])
1199 fi
1200
1201 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1202 AC_TRY_RUN([
1203 #include <sys/types.h>
1204 #include <stdarg.h>
1205 void foo(const char *format, ...) { 
1206        va_list ap;
1207        int len;
1208        char buf[5];
1209
1210        va_start(ap, format);
1211        len = vsnprintf(buf, 0, format, ap);
1212        va_end(ap);
1213        if (len != 5) exit(1);
1214
1215        va_start(ap, format);
1216        len = vsnprintf(0, 0, format, ap);
1217        va_end(ap);
1218        if (len != 5) exit(1);
1219
1220        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1221
1222        exit(0);
1223 }
1224 main() { foo("hello"); }
1225 ],
1226 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1227 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1228     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1229 fi
1230
1231 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1232 AC_TRY_RUN([#include <sys/types.h>
1233 #include <dirent.h>
1234 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1235 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1236 di->d_name[0] == 0) exit(0); exit(1);} ],
1237 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1238 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1239     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1240 fi
1241
1242 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1243 AC_TRY_COMPILE([#include <sys/types.h>
1244 #include <utime.h>],
1245 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1246 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1247 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1248     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1249 fi
1250
1251 ICONV_LOCATION=standard
1252 LOOK_DIRS="/usr /usr/local /sw"
1253 AC_ARG_WITH(libiconv,
1254 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1255 [
1256   if test "$withval" = "no" ; then
1257     AC_MSG_ERROR(I won't take no for an answer)
1258   else
1259      if test "$withval" != "yes" ; then
1260         LOOK_DIRS="$withval $LOOK_DIRS"
1261      fi
1262   fi
1263 ])
1264
1265 ICONV_FOUND="no"
1266 for i in $LOOK_DIRS ; do
1267     save_LIBS=$LIBS
1268     save_LDFLAGS=$LDFLAGS
1269     save_CPPFLAGS=$CPPFLAGS
1270     CPPFLAGS="-I$i/include"
1271     LDFLAGS="-L$i/lib"
1272     LIBS=
1273     export LDFLAGS LIBS CPPFLAGS
1274 dnl Try to find iconv(3)
1275     jm_ICONV($i)
1276
1277     CPPFLAGS=$save_CPPFLAGS
1278     if test -n "$ICONV_FOUND" ; then
1279         LDFLAGS=$save_LDFLAGS
1280         LIB_ADD_DIR(LDFLAGS, "$i/lib")
1281         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1282         LIBS="$save_LIBS $LIBS"
1283         ICONV_LOCATION=$i
1284         export LDFLAGS LIBS CPPFLAGS
1285         break
1286     else
1287         LDFLAGS=$save_LDFLAGS
1288         LIBS=$save_LIBS
1289         export LDFLAGS LIBS CPPFLAGS
1290     fi
1291 done
1292
1293 ############
1294 # check for iconv in libc
1295 AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1296 AC_TRY_RUN([
1297 #include <iconv.h>
1298 main() {
1299        iconv_t cd = iconv_open("ASCII", "UCS-2LE");
1300        if (cd == 0 || cd == (iconv_t)-1) return -1;
1301        return 0;
1302 }
1303 ],
1304 samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
1305 if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1306     AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
1307 fi
1308
1309 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
1310     AC_MSG_WARN([Sufficient support for iconv function was not found. 
1311     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
1312 fi
1313
1314
1315 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1316 AC_TRY_RUN([
1317 #include <sys/types.h>
1318 #include <fcntl.h>
1319 #ifndef F_GETLEASE
1320 #define F_GETLEASE      1025
1321 #endif
1322 main() {
1323        int fd = open("/dev/null", O_RDONLY);
1324        return fcntl(fd, F_GETLEASE, 0) == -1;
1325 }
1326 ],
1327 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1328 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1329     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1330 fi
1331
1332 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1333 AC_TRY_RUN([
1334 #include <sys/types.h>
1335 #include <fcntl.h>
1336 #include <signal.h>
1337 #ifndef F_NOTIFY
1338 #define F_NOTIFY 1026
1339 #endif
1340 main() {
1341         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1342 }
1343 ],
1344 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1345 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1346     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1347 fi
1348
1349 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1350 AC_TRY_RUN([
1351 #include <sys/types.h>
1352 #include <fcntl.h>
1353 #include <signal.h>
1354 #include <sys/file.h>
1355 #ifndef LOCK_MAND
1356 #define LOCK_MAND       32
1357 #define LOCK_READ       64
1358 #endif
1359 main() {
1360         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1361 }
1362 ],
1363 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1364 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1365     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1366 fi
1367
1368
1369
1370
1371 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1372 AC_TRY_COMPILE([#include <sys/types.h>
1373 #include <fcntl.h>],
1374 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1375 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1376 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1377     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1378 fi
1379
1380 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1381 AC_TRY_RUN([#include <sys/types.h>
1382 #include <sys/capability.h>
1383 main() {
1384  cap_t cap;
1385  if ((cap = cap_get_proc()) == NULL)
1386    exit(1);
1387  cap->cap_effective |= CAP_NETWORK_MGT;
1388  cap->cap_inheritable |= CAP_NETWORK_MGT;
1389  cap_set_proc(cap);
1390  exit(0);
1391 }
1392 ],
1393 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1394 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1395     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1396 fi
1397
1398 #
1399 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1400 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1401 #
1402
1403 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1404 AC_TRY_COMPILE([#include <sys/types.h>
1405 #if defined(HAVE_RPC_RPC_H)
1406 #include <rpc/rpc.h>
1407 #endif],
1408 [int16 testvar;],
1409 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1410 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1411     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
1412 fi
1413
1414 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1415 AC_TRY_COMPILE([#include <sys/types.h>
1416 #if defined(HAVE_RPC_RPC_H)
1417 #include <rpc/rpc.h>
1418 #endif],
1419 [uint16 testvar;],
1420 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1421 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1422     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
1423 fi
1424
1425 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1426 AC_TRY_COMPILE([#include <sys/types.h>
1427 #if defined(HAVE_RPC_RPC_H)
1428 #include <rpc/rpc.h>
1429 #endif],
1430 [int32 testvar;],
1431 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1432 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1433     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
1434 fi
1435
1436 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1437 AC_TRY_COMPILE([#include <sys/types.h>
1438 #if defined(HAVE_RPC_RPC_H)
1439 #include <rpc/rpc.h>
1440 #endif],
1441 [uint32 testvar;],
1442 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1443 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1444     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
1445 fi
1446
1447 dnl
1448 dnl Some systems (SCO) have a problem including
1449 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1450 dnl as a #define in <prot.h> and as part of an enum
1451 dnl in <rpc/rpc.h>.
1452 dnl
1453
1454 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1455 AC_TRY_COMPILE([#include <sys/types.h>
1456 #ifdef HAVE_SYS_SECURITY_H
1457 #include <sys/security.h>
1458 #include <prot.h>
1459 #endif  /* HAVE_SYS_SECURITY_H */
1460 #if defined(HAVE_RPC_RPC_H)
1461 #include <rpc/rpc.h>
1462 #endif],
1463 [int testvar;],
1464 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1465 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1466     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
1467 fi
1468
1469 AC_MSG_CHECKING([for test routines])
1470 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1471            AC_MSG_RESULT(yes),
1472            AC_MSG_ERROR([cant find test code. Aborting config]),
1473            AC_MSG_WARN([cannot run when cross-compiling]))
1474
1475 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1476 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1477            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1478 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1479     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
1480 fi
1481
1482 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1483 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
1484            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1485            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1486            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1487 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1488 then
1489     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1490 fi
1491
1492 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1493 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1494            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1495 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1496     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
1497 fi
1498
1499 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1500 SAVE_CPPFLAGS="$CPPFLAGS"
1501 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
1502 AC_TRY_COMPILE([
1503 #define REPLACE_GETPASS 1
1504 #define NO_CONFIG_H 1
1505 #define main dont_declare_main
1506 #include "${srcdir-.}/lib/getsmbpass.c"
1507 #undef main
1508 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1509 CPPFLAGS="$SAVE_CPPFLAGS"
1510 ])
1511 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1512         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
1513 fi
1514
1515 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1516 AC_TRY_RUN([
1517 #include <stdio.h>
1518 #include <sys/types.h>
1519 #include <netinet/in.h>
1520 #ifdef HAVE_ARPA_INET_H
1521 #include <arpa/inet.h>
1522 #endif
1523 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1524 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1525     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1526 exit(1);}],
1527            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1528 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1529     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
1530 fi
1531
1532 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1533 AC_TRY_RUN([#include <stdlib.h>
1534 #include <sys/types.h>
1535 #include <sys/stat.h>
1536 #include <unistd.h>
1537 main() { 
1538   struct stat st;
1539   char tpl[20]="/tmp/test.XXXXXX"; 
1540   int fd = mkstemp(tpl); 
1541   if (fd == -1) exit(1);
1542   unlink(tpl);
1543   if (fstat(fd, &st) != 0) exit(1);
1544   if ((st.st_mode & 0777) != 0600) exit(1);
1545   exit(0);
1546 }],
1547 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1548 samba_cv_HAVE_SECURE_MKSTEMP=no,
1549 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1550 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1551     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
1552 fi
1553
1554 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1555 AC_TRY_RUN([#include <unistd.h>
1556 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1557 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1558 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1559     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
1560 fi
1561
1562 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1563 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1564            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1565 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1566     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
1567 else
1568     AC_MSG_WARN(running as non-root will disable some tests)
1569 fi
1570
1571 ##################
1572 # look for a method of finding the list of network interfaces
1573 iface=no;
1574 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1575 AC_TRY_RUN([
1576 #define HAVE_IFACE_AIX 1
1577 #define AUTOCONF_TEST 1
1578 #include "confdefs.h"
1579 #include "${srcdir-.}/lib/interfaces.c"],
1580            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1581 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1582     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
1583 fi
1584
1585 if test $iface = no; then
1586 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1587 AC_TRY_RUN([
1588 #define HAVE_IFACE_IFCONF 1
1589 #define AUTOCONF_TEST 1
1590 #include "confdefs.h"
1591 #include "${srcdir-.}/lib/interfaces.c"],
1592            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1593 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1594     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
1595 fi
1596 fi
1597
1598 if test $iface = no; then
1599 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1600 AC_TRY_RUN([
1601 #define HAVE_IFACE_IFREQ 1
1602 #define AUTOCONF_TEST 1
1603 #include "confdefs.h"
1604 #include "${srcdir-.}/lib/interfaces.c"],
1605            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1606 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1607     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
1608 fi
1609 fi
1610
1611
1612 ################################################
1613 # look for a method of setting the effective uid
1614 seteuid=no;
1615 if test $seteuid = no; then
1616 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1617 AC_TRY_RUN([
1618 #define AUTOCONF_TEST 1
1619 #define USE_SETRESUID 1
1620 #include "confdefs.h"
1621 #include "${srcdir-.}/lib/util_sec.c"],
1622            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1623 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1624     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
1625 fi
1626 fi
1627
1628
1629 if test $seteuid = no; then
1630 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1631 AC_TRY_RUN([
1632 #define AUTOCONF_TEST 1
1633 #define USE_SETREUID 1
1634 #include "confdefs.h"
1635 #include "${srcdir-.}/lib/util_sec.c"],
1636            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1637 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1638     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
1639 fi
1640 fi
1641
1642 if test $seteuid = no; then
1643 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1644 AC_TRY_RUN([
1645 #define AUTOCONF_TEST 1
1646 #define USE_SETEUID 1
1647 #include "confdefs.h"
1648 #include "${srcdir-.}/lib/util_sec.c"],
1649            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1650 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1651     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
1652 fi
1653 fi
1654
1655 if test $seteuid = no; then
1656 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1657 AC_TRY_RUN([
1658 #define AUTOCONF_TEST 1
1659 #define USE_SETUIDX 1
1660 #include "confdefs.h"
1661 #include "${srcdir-.}/lib/util_sec.c"],
1662            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1663 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1664     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
1665 fi
1666 fi
1667
1668
1669 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1670 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1671            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1672 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1673     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
1674 fi
1675
1676 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1677 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1678            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1679 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1680     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
1681 fi
1682
1683 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1684 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1685            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1686 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1687     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
1688 fi
1689
1690 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1691 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1692            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1693 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1694     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
1695
1696 else
1697
1698 dnl
1699 dnl Don't check for 64 bit fcntl locking if we know that the
1700 dnl glibc2.1 broken check has succeeded.
1701 dnl 
1702
1703   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1704   AC_TRY_RUN([
1705 #if defined(HAVE_UNISTD_H)
1706 #include <unistd.h>
1707 #endif
1708 #include <stdio.h>
1709 #include <stdlib.h>
1710
1711 #ifdef HAVE_FCNTL_H
1712 #include <fcntl.h>
1713 #endif
1714
1715 #ifdef HAVE_SYS_FCNTL_H
1716 #include <sys/fcntl.h>
1717 #endif
1718 main() { struct flock64 fl64;
1719 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1720 exit(0);
1721 #else
1722 exit(1);
1723 #endif
1724 }],
1725        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1726
1727   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1728       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
1729   fi
1730 fi
1731
1732 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1733 AC_TRY_COMPILE([#include <sys/types.h>
1734 #include <sys/stat.h>
1735 #include <unistd.h>],
1736 [struct stat st;  st.st_blocks = 0;],
1737 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1738 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1739     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
1740 fi 
1741
1742 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
1743 AC_TRY_COMPILE([#include <sys/types.h>
1744 #include <sys/stat.h>
1745 #include <unistd.h>],
1746 [struct stat st;  st.st_blksize = 0;],
1747 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
1748 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
1749     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
1750 fi
1751
1752 case "$host_os" in
1753 *linux*)
1754 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1755 AC_TRY_COMPILE([
1756 #ifdef HAVE_SYS_VFS_H
1757 #include <sys/vfs.h>
1758 #endif
1759 #ifdef HAVE_SYS_CAPABILITY_H
1760 #include <sys/capability.h>
1761 #endif
1762 ],[int i;],
1763    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1764 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1765    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
1766 fi
1767 ;;
1768 esac
1769
1770 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
1771 AC_TRY_COMPILE([#include <sys/acl.h>
1772 #if defined(HAVE_RPCSVC_NIS_H)
1773 #include <rpcsvc/nis.h>
1774 #endif],
1775 [int i;],
1776 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
1777 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
1778         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
1779 fi
1780
1781 #################################################
1782 # check for pthread support
1783 AC_MSG_CHECKING(whether to use pthreads)
1784 AC_ARG_WITH(pthreads,
1785 [  --with-pthreads              Include pthreads (default=no) ],
1786 [ case "$withval" in
1787   yes)
1788     AC_MSG_RESULT(yes)
1789     AC_DEFINE(WITH_PTHREADS,1,[Whether to use pthreads])
1790     SMBD_EXTRA_OBJS="smbd/process_thread.o"
1791     SMBD_EXTRA_LIBS="-lpthread"
1792     ;;
1793   *)
1794     AC_MSG_RESULT(no)
1795     ;;
1796   esac ],
1797   AC_MSG_RESULT(no)
1798 )
1799
1800 AC_SUBST(SMBD_EXTRA_OBJS)
1801 AC_SUBST(SMBD_EXTRA_LIBS)
1802
1803 sinclude(libads/config.m4)
1804 sinclude(passdb/config.m4)
1805
1806 ###############################################
1807 # test for where we get crypt() from
1808 AC_SEARCH_LIBS(crypt, [crypt],
1809   [test "$ac_cv_search_crypt" = "none required" || AUTHLIBS="-lcrypt $AUTHLIBS"
1810   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
1811
1812 ##
1813 ## moved after the check for -lcrypt in order to
1814 ## ensure that the necessary libraries are included
1815 ## check checking for truncated salt.  Wrapped by the
1816 ## $with_pam_for_crypt variable as above   --jerry
1817 ##
1818 if test $with_pam_for_crypt = no; then
1819 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1820 crypt_LIBS="$LIBS"
1821 LIBS="$AUTHLIBS $LIBS"
1822 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
1823         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
1824 LIBS="$crypt_LIBS"])
1825 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1826         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
1827 fi
1828 fi
1829
1830 #################################################
1831 # these tests are taken from the GNU fileutils package
1832 AC_CHECKING(how to get filesystem space usage)
1833 space=no
1834
1835 # Test for statvfs64.
1836 if test $space = no; then
1837   # SVR4
1838   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
1839   [AC_TRY_RUN([
1840 #if defined(HAVE_UNISTD_H)
1841 #include <unistd.h>
1842 #endif
1843 #include <sys/types.h>
1844 #include <sys/statvfs.h>
1845   main ()
1846   {
1847     struct statvfs64 fsd;
1848     exit (statvfs64 (".", &fsd));
1849   }],
1850   fu_cv_sys_stat_statvfs64=yes,
1851   fu_cv_sys_stat_statvfs64=no,
1852   fu_cv_sys_stat_statvfs64=cross)])
1853   if test $fu_cv_sys_stat_statvfs64 = yes; then
1854     space=yes
1855     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
1856   fi
1857 fi
1858
1859 # Perform only the link test since it seems there are no variants of the
1860 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
1861 # because that got a false positive on SCO OSR5.  Adding the declaration
1862 # of a `struct statvfs' causes this test to fail (as it should) on such
1863 # systems.  That system is reported to work fine with STAT_STATFS4 which
1864 # is what it gets when this test fails.
1865 if test $space = no; then
1866   # SVR4
1867   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
1868                  [AC_TRY_LINK([#include <sys/types.h>
1869 #include <sys/statvfs.h>],
1870                               [struct statvfs fsd; statvfs (0, &fsd);],
1871                               fu_cv_sys_stat_statvfs=yes,
1872                               fu_cv_sys_stat_statvfs=no)])
1873   if test $fu_cv_sys_stat_statvfs = yes; then
1874     space=yes
1875     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
1876   fi
1877 fi
1878
1879 if test $space = no; then
1880   # DEC Alpha running OSF/1
1881   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
1882   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
1883   [AC_TRY_RUN([
1884 #include <sys/param.h>
1885 #include <sys/types.h>
1886 #include <sys/mount.h>
1887   main ()
1888   {
1889     struct statfs fsd;
1890     fsd.f_fsize = 0;
1891     exit (statfs (".", &fsd, sizeof (struct statfs)));
1892   }],
1893   fu_cv_sys_stat_statfs3_osf1=yes,
1894   fu_cv_sys_stat_statfs3_osf1=no,
1895   fu_cv_sys_stat_statfs3_osf1=no)])
1896   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
1897   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
1898     space=yes
1899     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
1900   fi
1901 fi
1902
1903 if test $space = no; then
1904 # AIX
1905   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
1906 member (AIX, 4.3BSD)])
1907   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
1908   [AC_TRY_RUN([
1909 #ifdef HAVE_SYS_PARAM_H
1910 #include <sys/param.h>
1911 #endif
1912 #ifdef HAVE_SYS_MOUNT_H
1913 #include <sys/mount.h>
1914 #endif
1915 #ifdef HAVE_SYS_VFS_H
1916 #include <sys/vfs.h>
1917 #endif
1918   main ()
1919   {
1920   struct statfs fsd;
1921   fsd.f_bsize = 0;
1922   exit (statfs (".", &fsd));
1923   }],
1924   fu_cv_sys_stat_statfs2_bsize=yes,
1925   fu_cv_sys_stat_statfs2_bsize=no,
1926   fu_cv_sys_stat_statfs2_bsize=no)])
1927   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
1928   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
1929     space=yes
1930     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
1931   fi
1932 fi
1933
1934 if test $space = no; then
1935 # SVR3
1936   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
1937   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
1938   [AC_TRY_RUN([#include <sys/types.h>
1939 #include <sys/statfs.h>
1940   main ()
1941   {
1942   struct statfs fsd;
1943   exit (statfs (".", &fsd, sizeof fsd, 0));
1944   }],
1945     fu_cv_sys_stat_statfs4=yes,
1946     fu_cv_sys_stat_statfs4=no,
1947     fu_cv_sys_stat_statfs4=no)])
1948   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
1949   if test $fu_cv_sys_stat_statfs4 = yes; then
1950     space=yes
1951     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
1952   fi
1953 fi
1954
1955 if test $space = no; then
1956 # 4.4BSD and NetBSD
1957   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
1958 member (4.4BSD and NetBSD)])
1959   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
1960   [AC_TRY_RUN([#include <sys/types.h>
1961 #ifdef HAVE_SYS_PARAM_H
1962 #include <sys/param.h>
1963 #endif
1964 #ifdef HAVE_SYS_MOUNT_H
1965 #include <sys/mount.h>
1966 #endif
1967   main ()
1968   {
1969   struct statfs fsd;
1970   fsd.f_fsize = 0;
1971   exit (statfs (".", &fsd));
1972   }],
1973   fu_cv_sys_stat_statfs2_fsize=yes,
1974   fu_cv_sys_stat_statfs2_fsize=no,
1975   fu_cv_sys_stat_statfs2_fsize=no)])
1976   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
1977   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
1978     space=yes
1979         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
1980   fi
1981 fi
1982
1983 if test $space = no; then
1984   # Ultrix
1985   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
1986   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
1987   [AC_TRY_RUN([#include <sys/types.h>
1988 #ifdef HAVE_SYS_PARAM_H
1989 #include <sys/param.h>
1990 #endif
1991 #ifdef HAVE_SYS_MOUNT_H
1992 #include <sys/mount.h>
1993 #endif
1994 #ifdef HAVE_SYS_FS_TYPES_H
1995 #include <sys/fs_types.h>
1996 #endif
1997   main ()
1998   {
1999   struct fs_data fsd;
2000   /* Ultrix's statfs returns 1 for success,
2001      0 for not mounted, -1 for failure.  */
2002   exit (statfs (".", &fsd) != 1);
2003   }],
2004   fu_cv_sys_stat_fs_data=yes,
2005   fu_cv_sys_stat_fs_data=no,
2006   fu_cv_sys_stat_fs_data=no)])
2007   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
2008   if test $fu_cv_sys_stat_fs_data = yes; then
2009     space=yes
2010     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
2011   fi
2012 fi
2013
2014 #
2015 # As a gating factor for large file support, in order to
2016 # use <4GB files we must have the following minimal support
2017 # available.
2018 # long long, and a 64 bit off_t or off64_t.
2019 # If we don't have all of these then disable large
2020 # file support.
2021 #
2022 AC_MSG_CHECKING([if large file support can be enabled])
2023 AC_TRY_COMPILE([
2024 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
2025 #include <sys/types.h>
2026 #else
2027 __COMPILE_ERROR_
2028 #endif
2029 ],
2030 [int i],
2031 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
2032 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
2033         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
2034 fi
2035 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
2036
2037 sinclude(nsswitch/config.m4)
2038 sinclude(popt/config.m4)
2039
2040 dnl exclude these modules 
2041 AC_ARG_WITH(exclude-modules,
2042 [  --with-exclude-modules=MODULES Comma-seperated list of names of modules to exclude from build],
2043 [ if test $withval; then
2044         for i in `echo $withval | sed -e's/,/ /g'`
2045         do
2046                 eval MODULE_$i=NOT
2047         done
2048 fi ])
2049
2050 dnl Always built these modules shared
2051 AC_ARG_WITH(shared-modules,
2052 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
2053 [ if test $withval; then
2054         for i in `echo $withval | sed -e's/,/ /g'`
2055         do
2056                 eval MODULE_$i=SHARED
2057         done
2058 fi ])
2059
2060 dnl Always built these modules static
2061 AC_ARG_WITH(static-modules,
2062 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
2063 [ if test $withval; then
2064         for i in `echo $withval | sed -e's/,/ /g'`
2065         do
2066                 eval MODULE_$i=STATIC
2067         done
2068 fi ])
2069
2070 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
2071
2072 sinclude(ntvfs/config.m4)
2073 sinclude(rpc_server/config.m4)
2074
2075 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
2076
2077 #################################################
2078 # do extra things if we are running insure
2079
2080 if test "${ac_cv_prog_CC}" = "insure"; then
2081         CPPFLAGS="$CPPFLAGS -D__INSURE__"
2082 fi
2083
2084 #################################################
2085 # final configure stuff
2086
2087 AC_MSG_CHECKING([configure summary])
2088 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
2089            AC_MSG_RESULT(yes),
2090            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
2091            AC_MSG_WARN([cannot run when cross-compiling]))
2092
2093 builddir=`pwd`
2094 AC_SUBST(builddir)
2095
2096 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
2097 LIB_REMOVE_USR_LIB(LDFLAGS)
2098 LIB_REMOVE_USR_LIB(LIBS)
2099
2100 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
2101 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
2102 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
2103
2104 AC_OUTPUT(include/stamp-h Makefile script/findsmb)