- we now specify the object files in the subsystems config.m4 file
[ira/wip.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 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 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1252 AC_TRY_RUN([
1253 #include <sys/types.h>
1254 #include <fcntl.h>
1255 #ifndef F_GETLEASE
1256 #define F_GETLEASE      1025
1257 #endif
1258 main() {
1259        int fd = open("/dev/null", O_RDONLY);
1260        return fcntl(fd, F_GETLEASE, 0) == -1;
1261 }
1262 ],
1263 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1264 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1265     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1266 fi
1267
1268 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1269 AC_TRY_RUN([
1270 #include <sys/types.h>
1271 #include <fcntl.h>
1272 #include <signal.h>
1273 #ifndef F_NOTIFY
1274 #define F_NOTIFY 1026
1275 #endif
1276 main() {
1277         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1278 }
1279 ],
1280 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1281 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1282     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1283 fi
1284
1285 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1286 AC_TRY_RUN([
1287 #include <sys/types.h>
1288 #include <fcntl.h>
1289 #include <signal.h>
1290 #include <sys/file.h>
1291 #ifndef LOCK_MAND
1292 #define LOCK_MAND       32
1293 #define LOCK_READ       64
1294 #endif
1295 main() {
1296         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1297 }
1298 ],
1299 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1300 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1301     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1302 fi
1303
1304
1305
1306
1307 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1308 AC_TRY_COMPILE([#include <sys/types.h>
1309 #include <fcntl.h>],
1310 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1311 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1312 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1313     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1314 fi
1315
1316 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1317 AC_TRY_RUN([#include <sys/types.h>
1318 #include <sys/capability.h>
1319 main() {
1320  cap_t cap;
1321  if ((cap = cap_get_proc()) == NULL)
1322    exit(1);
1323  cap->cap_effective |= CAP_NETWORK_MGT;
1324  cap->cap_inheritable |= CAP_NETWORK_MGT;
1325  cap_set_proc(cap);
1326  exit(0);
1327 }
1328 ],
1329 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1330 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1331     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1332 fi
1333
1334 #
1335 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1336 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1337 #
1338
1339 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1340 AC_TRY_COMPILE([#include <sys/types.h>
1341 #if defined(HAVE_RPC_RPC_H)
1342 #include <rpc/rpc.h>
1343 #endif],
1344 [int16 testvar;],
1345 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1346 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1347     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
1348 fi
1349
1350 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1351 AC_TRY_COMPILE([#include <sys/types.h>
1352 #if defined(HAVE_RPC_RPC_H)
1353 #include <rpc/rpc.h>
1354 #endif],
1355 [uint16 testvar;],
1356 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1357 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1358     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
1359 fi
1360
1361 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1362 AC_TRY_COMPILE([#include <sys/types.h>
1363 #if defined(HAVE_RPC_RPC_H)
1364 #include <rpc/rpc.h>
1365 #endif],
1366 [int32 testvar;],
1367 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1368 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1369     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
1370 fi
1371
1372 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1373 AC_TRY_COMPILE([#include <sys/types.h>
1374 #if defined(HAVE_RPC_RPC_H)
1375 #include <rpc/rpc.h>
1376 #endif],
1377 [uint32 testvar;],
1378 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1379 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1380     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
1381 fi
1382
1383 dnl
1384 dnl Some systems (SCO) have a problem including
1385 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1386 dnl as a #define in <prot.h> and as part of an enum
1387 dnl in <rpc/rpc.h>.
1388 dnl
1389
1390 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1391 AC_TRY_COMPILE([#include <sys/types.h>
1392 #ifdef HAVE_SYS_SECURITY_H
1393 #include <sys/security.h>
1394 #include <prot.h>
1395 #endif  /* HAVE_SYS_SECURITY_H */
1396 #if defined(HAVE_RPC_RPC_H)
1397 #include <rpc/rpc.h>
1398 #endif],
1399 [int testvar;],
1400 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1401 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1402     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
1403 fi
1404
1405 AC_MSG_CHECKING([for test routines])
1406 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1407            AC_MSG_RESULT(yes),
1408            AC_MSG_ERROR([cant find test code. Aborting config]),
1409            AC_MSG_WARN([cannot run when cross-compiling]))
1410
1411 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1412 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1413            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1414 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1415     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
1416 fi
1417
1418 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1419 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
1420            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1421            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1422            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1423 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1424 then
1425     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1426 fi
1427
1428 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1429 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1430            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1431 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1432     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
1433 fi
1434
1435 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1436 SAVE_CPPFLAGS="$CPPFLAGS"
1437 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
1438 AC_TRY_COMPILE([
1439 #define REPLACE_GETPASS 1
1440 #define NO_CONFIG_H 1
1441 #define main dont_declare_main
1442 #include "${srcdir-.}/lib/getsmbpass.c"
1443 #undef main
1444 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1445 CPPFLAGS="$SAVE_CPPFLAGS"
1446 ])
1447 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1448         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
1449 fi
1450
1451 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1452 AC_TRY_RUN([
1453 #include <stdio.h>
1454 #include <sys/types.h>
1455 #include <netinet/in.h>
1456 #ifdef HAVE_ARPA_INET_H
1457 #include <arpa/inet.h>
1458 #endif
1459 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1460 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1461     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1462 exit(1);}],
1463            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1464 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1465     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
1466 fi
1467
1468 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1469 AC_TRY_RUN([#include <stdlib.h>
1470 #include <sys/types.h>
1471 #include <sys/stat.h>
1472 #include <unistd.h>
1473 main() { 
1474   struct stat st;
1475   char tpl[20]="/tmp/test.XXXXXX"; 
1476   int fd = mkstemp(tpl); 
1477   if (fd == -1) exit(1);
1478   unlink(tpl);
1479   if (fstat(fd, &st) != 0) exit(1);
1480   if ((st.st_mode & 0777) != 0600) exit(1);
1481   exit(0);
1482 }],
1483 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1484 samba_cv_HAVE_SECURE_MKSTEMP=no,
1485 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1486 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1487     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
1488 fi
1489
1490 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1491 AC_TRY_RUN([#include <unistd.h>
1492 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1493 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1494 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1495     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
1496 fi
1497
1498 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1499 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1500            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1501 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1502     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
1503 else
1504     AC_MSG_WARN(running as non-root will disable some tests)
1505 fi
1506
1507 ##################
1508 # look for a method of finding the list of network interfaces
1509 iface=no;
1510 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1511 AC_TRY_RUN([
1512 #define HAVE_IFACE_AIX 1
1513 #define AUTOCONF_TEST 1
1514 #include "confdefs.h"
1515 #include "${srcdir-.}/lib/interfaces.c"],
1516            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1517 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1518     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
1519 fi
1520
1521 if test $iface = no; then
1522 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1523 AC_TRY_RUN([
1524 #define HAVE_IFACE_IFCONF 1
1525 #define AUTOCONF_TEST 1
1526 #include "confdefs.h"
1527 #include "${srcdir-.}/lib/interfaces.c"],
1528            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1529 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1530     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
1531 fi
1532 fi
1533
1534 if test $iface = no; then
1535 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1536 AC_TRY_RUN([
1537 #define HAVE_IFACE_IFREQ 1
1538 #define AUTOCONF_TEST 1
1539 #include "confdefs.h"
1540 #include "${srcdir-.}/lib/interfaces.c"],
1541            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1542 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1543     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
1544 fi
1545 fi
1546
1547
1548 ################################################
1549 # look for a method of setting the effective uid
1550 seteuid=no;
1551 if test $seteuid = no; then
1552 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1553 AC_TRY_RUN([
1554 #define AUTOCONF_TEST 1
1555 #define USE_SETRESUID 1
1556 #include "confdefs.h"
1557 #include "${srcdir-.}/lib/util_sec.c"],
1558            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1559 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1560     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
1561 fi
1562 fi
1563
1564
1565 if test $seteuid = no; then
1566 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1567 AC_TRY_RUN([
1568 #define AUTOCONF_TEST 1
1569 #define USE_SETREUID 1
1570 #include "confdefs.h"
1571 #include "${srcdir-.}/lib/util_sec.c"],
1572            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1573 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1574     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
1575 fi
1576 fi
1577
1578 if test $seteuid = no; then
1579 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1580 AC_TRY_RUN([
1581 #define AUTOCONF_TEST 1
1582 #define USE_SETEUID 1
1583 #include "confdefs.h"
1584 #include "${srcdir-.}/lib/util_sec.c"],
1585            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1586 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1587     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
1588 fi
1589 fi
1590
1591 if test $seteuid = no; then
1592 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1593 AC_TRY_RUN([
1594 #define AUTOCONF_TEST 1
1595 #define USE_SETUIDX 1
1596 #include "confdefs.h"
1597 #include "${srcdir-.}/lib/util_sec.c"],
1598            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1599 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1600     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
1601 fi
1602 fi
1603
1604
1605 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1606 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1607            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1608 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1609     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
1610 fi
1611
1612 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1613 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1614            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1615 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1616     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
1617 fi
1618
1619 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1620 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1621            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1622 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1623     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
1624 fi
1625
1626 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1627 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1628            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1629 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1630     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
1631
1632 else
1633
1634 dnl
1635 dnl Don't check for 64 bit fcntl locking if we know that the
1636 dnl glibc2.1 broken check has succeeded.
1637 dnl 
1638
1639   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1640   AC_TRY_RUN([
1641 #if defined(HAVE_UNISTD_H)
1642 #include <unistd.h>
1643 #endif
1644 #include <stdio.h>
1645 #include <stdlib.h>
1646
1647 #ifdef HAVE_FCNTL_H
1648 #include <fcntl.h>
1649 #endif
1650
1651 #ifdef HAVE_SYS_FCNTL_H
1652 #include <sys/fcntl.h>
1653 #endif
1654 main() { struct flock64 fl64;
1655 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1656 exit(0);
1657 #else
1658 exit(1);
1659 #endif
1660 }],
1661        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1662
1663   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1664       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
1665   fi
1666 fi
1667
1668 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1669 AC_TRY_COMPILE([#include <sys/types.h>
1670 #include <sys/stat.h>
1671 #include <unistd.h>],
1672 [struct stat st;  st.st_blocks = 0;],
1673 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1674 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1675     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
1676 fi 
1677
1678 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
1679 AC_TRY_COMPILE([#include <sys/types.h>
1680 #include <sys/stat.h>
1681 #include <unistd.h>],
1682 [struct stat st;  st.st_blksize = 0;],
1683 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
1684 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
1685     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
1686 fi
1687
1688 case "$host_os" in
1689 *linux*)
1690 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1691 AC_TRY_COMPILE([
1692 #ifdef HAVE_SYS_VFS_H
1693 #include <sys/vfs.h>
1694 #endif
1695 #ifdef HAVE_SYS_CAPABILITY_H
1696 #include <sys/capability.h>
1697 #endif
1698 ],[int i;],
1699    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1700 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1701    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
1702 fi
1703 ;;
1704 esac
1705
1706 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
1707 AC_TRY_COMPILE([#include <sys/acl.h>
1708 #if defined(HAVE_RPCSVC_NIS_H)
1709 #include <rpcsvc/nis.h>
1710 #endif],
1711 [int i;],
1712 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
1713 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
1714         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
1715 fi
1716
1717 AC_SUBST(SMBD_EXTRA_OBJS)
1718 AC_SUBST(SMBD_EXTRA_LIBS)
1719
1720 sinclude(libads/config.m4)
1721 sinclude(passdb/config.m4)
1722
1723 ###############################################
1724 # test for where we get crypt() from
1725 AC_SEARCH_LIBS(crypt, [crypt],
1726   [test "$ac_cv_search_crypt" = "none required" || AUTHLIBS="-lcrypt $AUTHLIBS"
1727   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
1728
1729 ##
1730 ## moved after the check for -lcrypt in order to
1731 ## ensure that the necessary libraries are included
1732 ## check checking for truncated salt.  Wrapped by the
1733 ## $with_pam_for_crypt variable as above   --jerry
1734 ##
1735 if test x"$with_pam_for_crypt" != x"yes"; then
1736 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1737 crypt_LIBS="$LIBS"
1738 LIBS="$AUTHLIBS $LIBS"
1739 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
1740         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
1741 LIBS="$crypt_LIBS"])
1742 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1743         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
1744 fi
1745 fi
1746
1747 #################################################
1748 # these tests are taken from the GNU fileutils package
1749 AC_CHECKING(how to get filesystem space usage)
1750 space=no
1751
1752 # Test for statvfs64.
1753 if test $space = no; then
1754   # SVR4
1755   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
1756   [AC_TRY_RUN([
1757 #if defined(HAVE_UNISTD_H)
1758 #include <unistd.h>
1759 #endif
1760 #include <sys/types.h>
1761 #include <sys/statvfs.h>
1762   main ()
1763   {
1764     struct statvfs64 fsd;
1765     exit (statvfs64 (".", &fsd));
1766   }],
1767   fu_cv_sys_stat_statvfs64=yes,
1768   fu_cv_sys_stat_statvfs64=no,
1769   fu_cv_sys_stat_statvfs64=cross)])
1770   if test $fu_cv_sys_stat_statvfs64 = yes; then
1771     space=yes
1772     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
1773   fi
1774 fi
1775
1776 # Perform only the link test since it seems there are no variants of the
1777 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
1778 # because that got a false positive on SCO OSR5.  Adding the declaration
1779 # of a `struct statvfs' causes this test to fail (as it should) on such
1780 # systems.  That system is reported to work fine with STAT_STATFS4 which
1781 # is what it gets when this test fails.
1782 if test $space = no; then
1783   # SVR4
1784   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
1785                  [AC_TRY_LINK([#include <sys/types.h>
1786 #include <sys/statvfs.h>],
1787                               [struct statvfs fsd; statvfs (0, &fsd);],
1788                               fu_cv_sys_stat_statvfs=yes,
1789                               fu_cv_sys_stat_statvfs=no)])
1790   if test $fu_cv_sys_stat_statvfs = yes; then
1791     space=yes
1792     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
1793   fi
1794 fi
1795
1796 if test $space = no; then
1797   # DEC Alpha running OSF/1
1798   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
1799   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
1800   [AC_TRY_RUN([
1801 #include <sys/param.h>
1802 #include <sys/types.h>
1803 #include <sys/mount.h>
1804   main ()
1805   {
1806     struct statfs fsd;
1807     fsd.f_fsize = 0;
1808     exit (statfs (".", &fsd, sizeof (struct statfs)));
1809   }],
1810   fu_cv_sys_stat_statfs3_osf1=yes,
1811   fu_cv_sys_stat_statfs3_osf1=no,
1812   fu_cv_sys_stat_statfs3_osf1=no)])
1813   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
1814   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
1815     space=yes
1816     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
1817   fi
1818 fi
1819
1820 if test $space = no; then
1821 # AIX
1822   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
1823 member (AIX, 4.3BSD)])
1824   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
1825   [AC_TRY_RUN([
1826 #ifdef HAVE_SYS_PARAM_H
1827 #include <sys/param.h>
1828 #endif
1829 #ifdef HAVE_SYS_MOUNT_H
1830 #include <sys/mount.h>
1831 #endif
1832 #ifdef HAVE_SYS_VFS_H
1833 #include <sys/vfs.h>
1834 #endif
1835   main ()
1836   {
1837   struct statfs fsd;
1838   fsd.f_bsize = 0;
1839   exit (statfs (".", &fsd));
1840   }],
1841   fu_cv_sys_stat_statfs2_bsize=yes,
1842   fu_cv_sys_stat_statfs2_bsize=no,
1843   fu_cv_sys_stat_statfs2_bsize=no)])
1844   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
1845   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
1846     space=yes
1847     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
1848   fi
1849 fi
1850
1851 if test $space = no; then
1852 # SVR3
1853   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
1854   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
1855   [AC_TRY_RUN([#include <sys/types.h>
1856 #include <sys/statfs.h>
1857   main ()
1858   {
1859   struct statfs fsd;
1860   exit (statfs (".", &fsd, sizeof fsd, 0));
1861   }],
1862     fu_cv_sys_stat_statfs4=yes,
1863     fu_cv_sys_stat_statfs4=no,
1864     fu_cv_sys_stat_statfs4=no)])
1865   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
1866   if test $fu_cv_sys_stat_statfs4 = yes; then
1867     space=yes
1868     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
1869   fi
1870 fi
1871
1872 if test $space = no; then
1873 # 4.4BSD and NetBSD
1874   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
1875 member (4.4BSD and NetBSD)])
1876   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
1877   [AC_TRY_RUN([#include <sys/types.h>
1878 #ifdef HAVE_SYS_PARAM_H
1879 #include <sys/param.h>
1880 #endif
1881 #ifdef HAVE_SYS_MOUNT_H
1882 #include <sys/mount.h>
1883 #endif
1884   main ()
1885   {
1886   struct statfs fsd;
1887   fsd.f_fsize = 0;
1888   exit (statfs (".", &fsd));
1889   }],
1890   fu_cv_sys_stat_statfs2_fsize=yes,
1891   fu_cv_sys_stat_statfs2_fsize=no,
1892   fu_cv_sys_stat_statfs2_fsize=no)])
1893   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
1894   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
1895     space=yes
1896         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
1897   fi
1898 fi
1899
1900 if test $space = no; then
1901   # Ultrix
1902   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
1903   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
1904   [AC_TRY_RUN([#include <sys/types.h>
1905 #ifdef HAVE_SYS_PARAM_H
1906 #include <sys/param.h>
1907 #endif
1908 #ifdef HAVE_SYS_MOUNT_H
1909 #include <sys/mount.h>
1910 #endif
1911 #ifdef HAVE_SYS_FS_TYPES_H
1912 #include <sys/fs_types.h>
1913 #endif
1914   main ()
1915   {
1916   struct fs_data fsd;
1917   /* Ultrix's statfs returns 1 for success,
1918      0 for not mounted, -1 for failure.  */
1919   exit (statfs (".", &fsd) != 1);
1920   }],
1921   fu_cv_sys_stat_fs_data=yes,
1922   fu_cv_sys_stat_fs_data=no,
1923   fu_cv_sys_stat_fs_data=no)])
1924   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
1925   if test $fu_cv_sys_stat_fs_data = yes; then
1926     space=yes
1927     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
1928   fi
1929 fi
1930
1931 #
1932 # As a gating factor for large file support, in order to
1933 # use <4GB files we must have the following minimal support
1934 # available.
1935 # long long, and a 64 bit off_t or off64_t.
1936 # If we don't have all of these then disable large
1937 # file support.
1938 #
1939 AC_MSG_CHECKING([if large file support can be enabled])
1940 AC_TRY_COMPILE([
1941 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
1942 #include <sys/types.h>
1943 #else
1944 __COMPILE_ERROR_
1945 #endif
1946 ],
1947 [int i],
1948 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
1949 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
1950         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
1951 fi
1952 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
1953
1954 sinclude(nsswitch/config.m4)
1955 sinclude(popt/config.m4)
1956
1957 dnl exclude these modules 
1958 AC_ARG_WITH(exclude-modules,
1959 [  --with-exclude-modules=MODULES Comma-seperated list of names of modules to exclude from build],
1960 [ if test $withval; then
1961         for i in `echo $withval | sed -e's/,/ /g'`
1962         do
1963                 eval MODULE_$i=NOT
1964         done
1965 fi ])
1966
1967 dnl Always built these modules shared
1968 AC_ARG_WITH(shared-modules,
1969 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
1970 [ if test $withval; then
1971         for i in `echo $withval | sed -e's/,/ /g'`
1972         do
1973                 eval MODULE_$i=SHARED
1974         done
1975 fi ])
1976
1977 dnl Always built these modules static
1978 AC_ARG_WITH(static-modules,
1979 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
1980 [ if test $withval; then
1981         for i in `echo $withval | sed -e's/,/ /g'`
1982         do
1983                 eval MODULE_$i=STATIC
1984         done
1985 fi ])
1986
1987 sinclude(lib/iconv.m4)
1988 sinclude(smbd/process_model.m4)
1989 sinclude(ntvfs/config.m4)
1990 sinclude(rpc_server/config.m4)
1991
1992 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
1993
1994 #################################################
1995 # do extra things if we are running insure
1996
1997 if test "${ac_cv_prog_CC}" = "insure"; then
1998         CPPFLAGS="$CPPFLAGS -D__INSURE__"
1999 fi
2000
2001 #################################################
2002 # final configure stuff
2003
2004 AC_MSG_CHECKING([configure summary])
2005 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
2006            AC_MSG_RESULT(yes),
2007            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
2008            AC_MSG_WARN([cannot run when cross-compiling]))
2009
2010 builddir=`pwd`
2011 AC_SUBST(builddir)
2012
2013 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
2014 LIB_REMOVE_USR_LIB(LDFLAGS)
2015 LIB_REMOVE_USR_LIB(LIBS)
2016
2017 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
2018 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
2019 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
2020
2021 AC_OUTPUT(include/stamp-h Makefile)