s3: use PICFLAG instead of PIE_FLAGS
[samba.git] / source3 / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl We must use autotools 2.54 or above
4 AC_PREREQ(2.54)
5
6 AC_INIT([Samba],[3],[samba-technical@samba.org])
7
8 AC_CONFIG_SRCDIR([include/includes.h])
9 AC_CONFIG_HEADER(include/config.h)
10 AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
11
12 case "$PATH" in
13     */usr/ucb*)
14         AC_MSG_WARN([\$PATH contains /usr/ucb - build errors may follow])
15         ;;
16 esac 
17
18 builddir=`pwd`
19 AC_SUBST(builddir)
20
21 m4_include(m4/samba_version.m4)
22 m4_include(m4/check_path.m4)
23 m4_include(pkg.m4)
24
25 AC_LIBREPLACE_CC_CHECKS
26
27 m4_include(../lib/tevent/libtevent.m4)
28
29 LIBTEVENT_OBJ0=""
30 for obj in ${TEVENT_OBJ}; do
31         LIBTEVENT_OBJ0="${LIBTEVENT_OBJ0} ${teventdir}/${obj}"
32 done
33 AC_SUBST(LIBTEVENT_OBJ0)
34 LIBS="${LIBS} ${TEVENT_LIBS}"
35
36 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
37 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace"
38 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}"
39 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
40 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
41 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
42
43 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt"
44
45 ## cleanup the $(srcdir) in the Makefile if we are outside of the tree
46 if test "x${srcdir-.}" != "x."; then
47         SAMBA_CPPFLAGS=`echo ${SAMBA_CPPFLAGS} | sed -e "s;${srcdir};\$\(srcdir\);g"`
48 fi
49
50 dnl Unique-to-Samba variables we'll be playing with.
51 AC_SUBST(SAMBA_CPPFLAGS)
52 AC_SUBST(SHELL)
53 AC_SUBST(LDSHFLAGS)
54 AC_SUBST(SONAMEFLAG)
55 AC_SUBST(SHLD)
56 AC_SUBST(MODULE_EXPORTS)
57 AC_SUBST(DSO_EXPORTS)
58 AC_SUBST(HOST_OS)
59 AC_SUBST(PICFLAG)
60 AC_SUBST(PIE_CFLAGS)
61 AC_SUBST(PIE_LDFLAGS)
62 AC_SUBST(RELRO_LDFLAGS)
63 AC_SUBST(SHLIBEXT)
64 AC_SUBST(INSTALLLIBCMD_SH)
65 AC_SUBST(INSTALLLIBCMD_A)
66 AC_SUBST(UNINSTALLLIBCMD_SH)
67 AC_SUBST(UNINSTALLLIBCMD_A)
68
69 AC_SUBST(INSTALL_LIBWBCLIENT)
70 AC_SUBST(UNINSTALL_LIBWBCLIENT)
71 AC_SUBST(LIBWBCLIENT_SHARED_TARGET)
72 AC_SUBST(LIBWBCLIENT_SHARED)
73 AC_SUBST(LIBWBCLIENT_STATIC_TARGET)
74 AC_SUBST(LIBWBCLIENT_STATIC)
75 AC_SUBST(LIBWBCLIENT_SOVER)
76 AC_SUBST(LIBWBCLIENT)
77 AC_SUBST(LIBWBCLIENT_LIBS)
78
79 AC_SUBST(LIBSAMBAUTIL_SHARED)
80
81 AC_SUBST(PRINT_LIBS)
82 AC_SUBST(AUTH_LIBS)
83 AC_SUBST(ACL_LIBS)
84 AC_SUBST(PASSDB_LIBS)
85 AC_SUBST(IDMAP_LIBS)
86 AC_SUBST(KRB5_LIBS)
87 AC_SUBST(UUID_LIBS)
88 AC_SUBST(LDAP_LIBS)
89 AC_SUBST(GPEXT_LIBS)
90 AC_SUBST(PAM_MODULES)
91 AC_SUBST(INSTALL_PAM_MODULES)
92 AC_SUBST(UNINSTALL_PAM_MODULES)
93 AC_SUBST(NSS_MODULES)
94 AC_SUBST(EXTRA_BIN_PROGS)
95 AC_SUBST(CIFSMOUNT_PROGS)
96 AC_SUBST(INSTALL_CIFSMOUNT)
97 AC_SUBST(UNINSTALL_CIFSMOUNT)
98 AC_SUBST(CIFSUMOUNT_PROGS)
99 AC_SUBST(INSTALL_CIFSUMOUNT)
100 AC_SUBST(UNINSTALL_CIFSUMOUNT)
101 AC_SUBST(CIFSUPCALL_PROGS)
102 AC_SUBST(INSTALL_CIFSUPCALL)
103 AC_SUBST(UNINSTALL_CIFSUPCALL)
104 AC_SUBST(EXTRA_SBIN_PROGS)
105 AC_SUBST(EXTRA_ALL_TARGETS)
106 AC_SUBST(CONFIG_LIBS)
107 AC_SUBST(NSCD_LIBS)
108
109 # compile with optimization and without debugging by default, but
110 # allow people to set their own preference.
111 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
112 # if it has no value.  This prevent *very* large debug binaries from occurring
113 # by default.
114 if test "x$debug" = "xyes" ; then
115         CFLAGS="${CFLAGS} -g"
116 fi
117 if test "x$CFLAGS" = x; then
118   CFLAGS="-O"
119 fi
120
121 m4_include(../lib/socket_wrapper/config.m4)
122 m4_include(../lib/nss_wrapper/config.m4)
123 m4_include(../lib/util/time.m4)
124
125 m4_include(m4/swat.m4)
126
127 DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
128
129 # Probe the gcc version for extra CFLAGS. We always stash these in
130 # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
131 # Makefile edit, avoiding the need to re-run configure.
132 if test x"$ac_cv_prog_gcc" = x"yes" ; then
133         DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings"
134         # Add -Wdeclaration-after-statement if compiler supports it
135         AC_CACHE_CHECK(
136           [that the C compiler understands -Wdeclaration-after-statement],
137           samba_cv_HAVE_Wdeclaration_after_statement, [
138           AC_TRY_RUN_STRICT([
139             int main(void)
140             {
141                 return 0;
142             }],[$CFLAGS -Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
143             samba_cv_HAVE_Wdeclaration_after_statement=yes,
144             samba_cv_HAVE_Wdeclaration_after_statement=no,
145             samba_cv_HAVE_Wdeclaration_after_statement=cross)
146        ])
147
148         if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
149             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
150         fi
151
152         #-Werror-implicit-function-declaration
153         AC_CACHE_CHECK(
154           [that the C compiler understands -Werror-implicit-function-declaration],
155           samba_cv_HAVE_Werror_implicit_function_declaration, [
156           AC_TRY_RUN_STRICT([
157             int main(void)
158             {
159                 return 0;
160             }],[$CFLAGS -Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
161             samba_cv_HAVE_Werror_implicit_function_declaration=yes,
162             samba_cv_HAVE_Werror_implicit_function_declaration=no,
163             samba_cv_HAVE_Werror_implicit_function_declaration=cross)
164        ])
165        if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
166             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
167        fi
168
169         # krb5developer is like developer, except we don't get
170         # -Wstrict-prototypes.
171        if test x"$krb5_developer" != x"$yes" ; then
172             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Wstrict-prototypes"
173        fi
174
175        if test x"$picky_developer" = x"yes"; then
176             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Werror"
177        fi
178 fi
179
180 #################################################
181 # check for a shared memory profiling support
182 AC_MSG_CHECKING(whether to use profiling)
183 AC_ARG_WITH(profiling-data,
184 [AS_HELP_STRING([--with-profiling-data], [Include gathering source code profile information (default=no)])],
185 [ case "$withval" in
186   yes)
187     AC_MSG_RESULT(yes)
188     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
189     samba_cv_WITH_PROFILE=yes
190     ;;
191   *)
192     AC_MSG_RESULT(no)
193     samba_cv_WITH_PROFILE=no
194     ;;
195   esac ],
196   AC_MSG_RESULT(no)
197 )
198
199 dnl Checks for programs.
200 merged_build_possible=yes
201
202 AC_PROG_INSTALL
203 AC_PROG_AWK
204 # Check for GNU make
205 m4_include(../m4/check_make.m4)
206 AC_SAMBA_GNU_MAKE([true], [true])
207
208 # Check for perl
209 m4_include(../m4/check_perl.m4)
210 AC_SAMBA_PERL([true], [merged_build_possible=no])
211
212 AC_CHECK_TOOL(AR, ar)
213
214 dnl Check if we (actually our C compiler!) use GNU ld
215 AC_PROG_LD_GNU
216
217 dnl Certain versions of GNU ld the default is not to have the
218 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
219 dnl warnings when building modules.
220 if test "$ac_cv_prog_gnu_ld" = "yes"; then
221         ac_cv_gnu_ld_version=`$CC -Wl,-v /dev/null 2>/dev/null | head -1`
222         AC_MSG_CHECKING(GNU ld release date)
223         changequote(,)dnl
224         ac_cv_gnu_ld_date=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
225         changequote([,])dnl
226         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
227         if test -n "$ac_cv_gnu_ld_date"; then
228         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
229                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
230         fi
231         if test "$ac_cv_gnu_ld_date" -gt 20030101; then
232                 ac_cv_gnu_ld_version_script=yes
233         fi
234         else
235            AC_MSG_CHECKING(GNU ld release version)
236            changequote(,)dnl
237            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | awk '{print $NF}' | sed -n 's,\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
238            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
239            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
240            changequote([,])dnl
241            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
242            AC_MSG_CHECKING(GNU ld release version major)
243            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
244            AC_MSG_CHECKING(GNU ld release version minor)
245            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
246            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
247              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
248            fi
249            if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_ld_vernr_major" = 2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
250              ac_cv_gnu_ld_version_script=yes
251            fi
252         fi
253 fi
254
255 dnl look for executable suffix
256 AC_EXEEXT
257
258 dnl Check if C compiler understands -c and -o at the same time
259 AC_PROG_CC_C_O
260 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
261       BROKEN_CC=
262 else
263       BROKEN_CC=#
264 fi
265 AC_SUBST(BROKEN_CC)
266
267 dnl Check if the C compiler understands -Werror (GNU)
268 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
269  AC_TRY_RUN_STRICT([
270   int main(void)
271   {
272         return 0;
273   }],[$CFLAGS -Werror],[$CPPFLAGS],[$LDFLAGS],
274   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
275 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
276    Werror_FLAGS="-Werror"
277 else
278 dnl Check if the C compiler understands -w2
279 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
280  AC_TRY_RUN_STRICT([
281   int main(void)
282   {
283         return 0;
284   }],[$CFLAGS -w2],[$CPPFLAGS],[$LDFLAGS],
285   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
286 if test x"$samba_cv_HAVE_w2" = x"yes"; then
287    Werror_FLAGS="-w2"
288 else
289 dnl Check if the C compiler understands -errwarn (Sun)
290 AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn, [
291   AC_TRY_RUN_STRICT([
292    int main(void)
293    {
294         return 0;
295    }],[$CFLAGS -errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
296    samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
297 if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
298    Werror_FLAGS="-errwarn=%all"
299 else
300 dnl Check if the C compiler understands -qhalt (IBM)
301 AC_CACHE_CHECK([that the C compiler understands -qhalt],samba_cv_HAVE_qhalt, [
302   AC_TRY_RUN_STRICT([
303    int main(void)
304    {
305         return 0;
306    }],[$CFLAGS -qhalt=w],[$CPPFLAGS],[$LDFLAGS],
307    samba_cv_HAVE_qhalt=yes,samba_cv_HAVE_qhalt=no,samba_cv_HAVE_qhalt=cross)])
308 if test x"$samba_cv_HAVE_qhalt" = x"yes"; then
309    Werror_FLAGS="-qhalt=w"
310 fi
311 fi
312 fi
313 fi
314
315 ############################################
316 # check if the compiler can handle negative enum values
317 # and don't truncate the values to INT_MAX
318 # a runtime test is needed here
319 AC_SUBST(PIDL_ARGS)
320 AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_CC_NEGATIVE_ENUM_VALUES, [
321     AC_TRY_RUN(
322 [
323         #include <stdio.h>
324         enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
325         int main(void) {
326                 enum negative_values v1 = NEGATIVE_VALUE;
327                 unsigned v2 = NEGATIVE_VALUE;
328
329                 if (v1 != 0xFFFFFFFF) {
330                         printf("%u != 0xFFFFFFFF\n", v1);
331                         return 1;
332                 }
333                 if (v2 != 0xFFFFFFFF) {
334                         printf("%u != 0xFFFFFFFF\n", v2);
335                         return 1;
336                 }
337
338                 return 0;
339         }
340 ],
341         samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv__CC_NEGATIVE_ENUM_VALUES=no)])
342 if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
343         AC_MSG_WARN([using --uint-enums for pidl])
344         PIDL_ARGS="$PIDL_ARGS --uint-enums"
345 fi
346
347 dnl Figure out the flags to support named structure initializers
348
349 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
350
351 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
352 AC_MSG_CHECKING(uname -s)
353 AC_MSG_RESULT(${UNAME_S})
354
355 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
356 AC_MSG_CHECKING(uname -r)
357 AC_MSG_RESULT(${UNAME_R})
358
359 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
360 AC_MSG_CHECKING(uname -m)
361 AC_MSG_RESULT(${UNAME_M})
362
363 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
364 AC_MSG_CHECKING(uname -p)
365 AC_MSG_RESULT(${UNAME_P})
366
367 UNAME_I=`(uname -i) 2>/dev/null` || UNAME_I="unknown"
368 AC_MSG_CHECKING(uname -i)
369 AC_MSG_RESULT(${UNAME_I})
370
371 dnl Add #include for broken IRIX header files
372   case "$host_os" in
373         *irix6*)
374                 #TODO add to libreplace
375                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
376                         dnl Fix sensible defaults for MIPSPro compilers. The
377                         dnl error numbers are valid for the 7.3 compilers,
378                         dnl hopefully also valid for the 7.4 series.
379                         dnl
380                         dnl Bugzilla 3801. Force an error on warning 1035
381                         dnl so we don't incorrectly detect stdint.h. This
382                         dnl warning is emitted for #error directives.
383                         CFLAGS="$CFLAGS -diag_error 1035"
384                         dnl 1209: Controlling expression is constant
385                         dnl 1174: Function foo declared but never referenced
386                         dnl 3201: Parameter foo was never referenced
387                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
388                 fi
389         ;;
390 esac
391
392 DYNEXP=
393 AC_SUBST(DYNEXP)
394 LDSHFLAGS_Z_DEFS=
395 AC_SUBST(LDSHFLAGS_Z_DEFS)
396 LDSHFLAGS_Z_NODEFS=
397 AC_SUBST(LDSHFLAGS_Z_NODEFS)
398
399 dnl Add modules that have to be built by default here
400 dnl These have to be built static:
401 default_static_modules=""
402 default_static_modules="$default_static_modules pdb_smbpasswd"
403 default_static_modules="$default_static_modules pdb_tdbsam"
404 default_static_modules="$default_static_modules pdb_wbc_sam"
405 default_static_modules="$default_static_modules rpc_lsarpc"
406 default_static_modules="$default_static_modules rpc_samr"
407 default_static_modules="$default_static_modules rpc_winreg"
408 default_static_modules="$default_static_modules rpc_initshutdown"
409 default_static_modules="$default_static_modules rpc_dssetup"
410 default_static_modules="$default_static_modules rpc_wkssvc"
411 default_static_modules="$default_static_modules rpc_svcctl"
412 default_static_modules="$default_static_modules rpc_ntsvcs"
413 default_static_modules="$default_static_modules rpc_netlogon"
414 default_static_modules="$default_static_modules rpc_netdfs"
415 default_static_modules="$default_static_modules rpc_srvsvc"
416 default_static_modules="$default_static_modules rpc_spoolss"
417 default_static_modules="$default_static_modules rpc_eventlog"
418 default_static_modules="$default_static_modules auth_sam"
419 default_static_modules="$default_static_modules auth_unix"
420 default_static_modules="$default_static_modules auth_winbind"
421 default_static_modules="$default_static_modules auth_wbc"
422 default_static_modules="$default_static_modules auth_server"
423 default_static_modules="$default_static_modules auth_domain"
424 default_static_modules="$default_static_modules auth_builtin"
425 default_static_modules="$default_static_modules auth_netlogond"
426 default_static_modules="$default_static_modules vfs_default"
427 default_static_modules="$default_static_modules nss_info_template"
428
429 dnl These are preferably build shared, and static if dlopen() is not available
430 default_shared_modules=""
431 default_shared_modules="$default_shared_modules vfs_recycle"
432 default_shared_modules="$default_shared_modules vfs_audit"
433 default_shared_modules="$default_shared_modules vfs_extd_audit"
434 default_shared_modules="$default_shared_modules vfs_full_audit"
435 default_shared_modules="$default_shared_modules vfs_netatalk"
436 default_shared_modules="$default_shared_modules vfs_fake_perms"
437 default_shared_modules="$default_shared_modules vfs_default_quota"
438 default_shared_modules="$default_shared_modules vfs_readonly"
439 default_shared_modules="$default_shared_modules vfs_cap"
440 default_shared_modules="$default_shared_modules vfs_expand_msdfs"
441 default_shared_modules="$default_shared_modules vfs_shadow_copy"
442 default_shared_modules="$default_shared_modules vfs_shadow_copy2"
443 default_shared_modules="$default_shared_modules charset_CP850"
444 default_shared_modules="$default_shared_modules charset_CP437"
445 default_shared_modules="$default_shared_modules auth_script"
446 default_shared_modules="$default_shared_modules vfs_readahead"
447 default_shared_modules="$default_shared_modules vfs_xattr_tdb"
448 default_shared_modules="$default_shared_modules vfs_streams_xattr"
449 default_shared_modules="$default_shared_modules vfs_streams_depot"
450 default_shared_modules="$default_shared_modules vfs_acl_xattr"
451 default_shared_modules="$default_shared_modules vfs_acl_tdb"
452 default_shared_modules="$default_shared_modules vfs_smb_traffic_analyzer"
453 default_shared_modules="$default_shared_modules vfs_preopen"
454 default_shared_modules="$default_shared_modules vfs_catia"
455 default_shared_modules="$default_shared_modules vfs_scannedonly"
456 default_shared_modules="$default_shared_modules vfs_crossrename"
457
458 if test "x$developer" = xyes; then
459    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
460    default_shared_modules="$default_shared_modules charset_weird perfcount_test"
461 fi
462
463 #
464 # Config CPPFLAG settings for strange OS's that must be set
465 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
466 # case statement; its first reference must be unconditional.
467 #
468 case "$host_os" in
469     *hpux*)
470 #
471 # Defines needed for HPUX support.
472 # HPUX has bigcrypt but (sometimes?) doesn't use it for
473 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
474 #
475       case `uname -r` in
476                 *9*|*10*|*11)
477                         AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
478                 ;;
479       esac
480       ;;
481
482 #
483 # CRAY Unicos has broken const handling
484        *unicos*)
485           AC_MSG_RESULT([disabling const])
486           CPPFLAGS="$CPPFLAGS -Dconst="
487           ;;
488         
489 #
490 # AIX4.x doesn't even admit to having large
491 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
492 #
493     *aix4*)
494           AC_MSG_RESULT([enabling large file support])
495       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
496           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
497       ;;
498 #
499 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
500 # to the existance of large files..
501 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
502 # recommendations on large file support, however it makes the
503 # compile work using gcc 2.7 and 2.8, whereas using the Sun
504 # recommendation makes the compile fail on gcc2.7. JRA.
505 #
506 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
507 #
508         *solaris*)
509                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
510                 case `uname -r` in
511                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
512                                 AC_MSG_RESULT([no large file support])
513                                 ;;
514                         5.*)
515                         AC_MSG_RESULT([enabling large file support])
516                         if test "$ac_cv_prog_gcc" = yes; then
517                                 ${CC-cc} -v >conftest.c 2>&1
518                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
519                                 rm -fr conftest.c
520                                 case "$ac_cv_gcc_compiler_version_number" in
521                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
522                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
523                                                 LDFLAGS="$LDFLAGS -lthread"
524                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
525                                                 ;;
526                                         *)
527                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
528                                                 LDFLAGS="$LDFLAGS -lthread"
529                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
530                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
531                                                 ;;
532                                 esac
533                         else
534                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
535                                 LDFLAGS="$LDFLAGS -lthread"
536                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
537                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
538                         fi
539                         ;;
540                 esac
541                 ;;
542 #
543 # IRIX uses SYSV printing.  Make sure to set that here
544 #
545         *irix*)
546                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
547                 ;;
548         *freebsd*|*dragonfly*)
549                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
550                 ;;
551 #
552 # VOS may need to have POSIX support and System V compatibility enabled.
553 #
554     *vos*)
555     case "$CPPFLAGS" in
556           *-D_POSIX_C_SOURCE*)
557                 ;;
558           *)
559                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
560                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
561                 ;;
562     esac
563     case "$CPPFLAGS" in
564           *-D_SYSV*|*-D_SVID_SOURCE*)
565                 ;;
566           *)
567                 CPPFLAGS="$CPPFLAGS -D_SYSV"
568                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
569     esac
570     ;;
571 #
572 # Tests needed for SINIX large file support.
573 #
574     *sysv4*)
575       if test $host = mips-sni-sysv4 ; then
576         AC_MSG_CHECKING([for LFS support])
577         old_CPPFLAGS="$CPPFLAGS"
578         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
579         AC_TRY_RUN([
580 #include <unistd.h>
581 main () {
582 #if _LFS64_LARGEFILE == 1
583 exit(0);
584 #else
585 exit(1);
586 #endif
587 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
588         CPPFLAGS="$old_CPPFLAGS"
589         if test x$SINIX_LFS_SUPPORT = xyes ; then
590           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
591                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
592           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
593           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
594           LIBS="`getconf LFS64_LIBS` $LIBS"
595         fi
596       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
597       fi
598     ;;
599
600 # Systems with LFS support.
601 #
602     gnu* | k*bsd*-gnu | kopensolaris*-gnu)
603         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
604         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
605         AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
606         AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
607         ;;
608
609 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
610 #
611     *linux*)
612         AC_MSG_CHECKING([for LFS support])
613         old_CPPFLAGS="$CPPFLAGS"
614         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
615        AC_TRY_RUN([
616 #include <unistd.h>
617 #include <sys/utsname.h>
618 #include <string.h>
619 #include <stdlib.h>
620 main() {
621 #if _LFS64_LARGEFILE == 1
622        struct utsname uts;
623        char *release;
624        int major, minor;
625
626        /* Ensure this is glibc 2.2 or higher */
627 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
628        int libc_major = __GLIBC__;
629        int libc_minor = __GLIBC_MINOR__;
630
631        if (libc_major < 2)
632               exit(1);
633        if (libc_minor < 2)
634               exit(1);
635 #endif
636
637        /* Ensure this is kernel 2.4 or higher */
638
639        uname(&uts);
640        release = strdup(uts.release);
641        major = atoi(strsep(&release, "."));
642        minor = atoi(strsep(&release, "."));
643
644        if (major > 2 || (major == 2 && minor > 3))
645                exit(0);
646        exit(1);
647 #else
648        exit(1);
649 #endif
650 }
651 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
652         CPPFLAGS="$old_CPPFLAGS"
653         if test x$LINUX_LFS_SUPPORT = xyes ; then
654                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
655                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
656                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
657                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
658         fi
659         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
660         ;;
661
662 #
663 # MacOS X is the *only* system that uses compose character in utf8. This
664 # is so horribly broken....
665 #
666     *darwin*)
667         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
668
669 # Add a system specific charset module.
670         default_shared_modules="$default_shared_modules charset_macosxfs"
671
672         ;;
673     *hurd*)
674         AC_MSG_CHECKING([for LFS support])
675         old_CPPFLAGS="$CPPFLAGS"
676         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
677         AC_TRY_RUN([
678 #include <unistd.h>
679 main () {
680 #if _LFS64_LARGEFILE == 1
681 exit(0);
682 #else
683 exit(1);
684 #endif
685 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
686         CPPFLAGS="$old_CPPFLAGS"
687         if test x$GLIBC_LFS_SUPPORT = xyes ; then
688           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
689                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
690           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
691         fi
692       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
693     ;;
694     *qnx*)
695         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
696         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
697         ;;
698
699 esac
700
701 SAVE_CPPFLAGS="${CPPFLAGS}"
702 CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}"
703
704 AC_LIBREPLACE_BROKEN_CHECKS
705 AC_CHECK_FUNCS([syslog],[],[AC_MSG_ERROR([Required function not found])])
706 AC_LIBREPLACE_NETWORK_CHECKS
707
708 CPPFLAGS="${SAVE_CPPFLAGS}"
709
710 LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
711
712 LIBREPLACE_OBJS="${LIBREPLACEOBJ}"
713 AC_SUBST(LIBREPLACE_OBJS)
714
715 LIBREPLACE_LIBS="${LIBREPLACE_NETWORK_LIBS}"
716 AC_SUBST(LIBREPLACE_LIBS)
717
718
719 # add -ldl to the global LIBS
720 LIBS="${LIBS} ${LIBDL} ${LIBREPLACE_NETWORK_LIBS}"
721 AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}"
722
723
724 AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
725 AC_CHECK_HEADERS(unistd.h grp.h sys/id.h memory.h alloca.h)
726 AC_CHECK_HEADERS(limits.h float.h libintl.h)
727 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
728 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h sys/sysctl.h)
729 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
730 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
731 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h)
732 AC_CHECK_HEADERS(sys/sysmacros.h)
733 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
734 AC_CHECK_HEADERS(langinfo.h locale.h)
735 AC_CHECK_HEADERS(xfs/libxfs.h)
736 AC_CHECK_HEADERS(netgroup.h)
737
738 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
739 #if HAVE_RPC_RPC_H
740 #include <rpc/rpc.h>
741 #endif
742 ]])
743
744 ## These fail to compile on IRIX so just check for their presence
745 AC_CHECK_HEADERS(sys/mode.h,,,)
746
747 # Look for Darwin headers
748 old_CPPFLAGS="$CPPFLAGS"
749 CPPFLAGS="-Iinclude $CPPFLAGS"
750 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
751 CPPFLAGS="$old_CPPFLAGS"
752
753 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
754 # subdirectory of headers.
755 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
756
757 #
758 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
759 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
760 #
761 case "$host_os" in
762     *hpux*)
763                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
764                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
765                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
766                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
767                 fi
768         ;;
769 esac
770 AC_CHECK_HEADERS(shadow.h)
771 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
772 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
773
774 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
775 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
776
777 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
778
779 # For experimental utmp support (lastlog on some BSD-like systems)
780 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
781
782 AC_CHECK_SIZEOF(int,cross)
783 AC_CHECK_SIZEOF(long,cross)
784 AC_CHECK_SIZEOF(long long,cross)
785 AC_CHECK_SIZEOF(short,cross)
786
787 AC_C_CONST
788 AC_C_INLINE
789 AC_C_BIGENDIAN
790 AC_C_CHAR_UNSIGNED
791
792 AC_TYPE_SIGNAL
793 AC_TYPE_UID_T
794 AC_TYPE_MODE_T
795 AC_TYPE_OFF_T
796 AC_TYPE_SIZE_T
797 AC_TYPE_PID_T
798 AC_STRUCT_ST_RDEV
799 AC_DIRENT_D_OFF
800 AC_CHECK_TYPE(ssize_t, int)
801 AC_CHECK_TYPE(wchar_t, unsigned short)
802
803 ############################################
804 # for cups support we need libcups, and a handful of header files
805
806 AC_ARG_ENABLE(cups,
807 [AS_HELP_STRING([--enable-cups], [Turn on CUPS support (default=auto)])])
808
809 if test x$enable_cups != xno; then
810         AC_PATH_PROG(CUPS_CONFIG, cups-config)
811
812         if test "x$CUPS_CONFIG" != x; then
813
814                 ac_save_CFLAGS=$CFLAGS
815                 ac_save_LDFLAGS=$LDFLAGS
816                 ac_save_PRINT_LIBS=$PRINT_LIBS
817                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
818                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
819                 PRINT_LIBS="$PRINT_LIBS -lcups"
820                 AC_CHECK_HEADERS(cups/cups.h cups/language.h)
821                 if test x"$ac_cv_header_cups_cups_h" = xyes -a \
822                         x"$ac_cv_header_cups_language_h" = xyes; then
823                         AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
824                         samba_cv_HAVE_CUPS=yes
825                         AC_CHECK_LIB_EXT(cups, PRINT_LIBS, httpConnectEncrypt)
826                 else
827                         AC_MSG_WARN([cups-config around but cups-devel not installed])
828                         CFLAGS=$ac_save_CFLAGS
829                         LDFLAGS=$ac_save_LDFLAGS
830                         PRINT_LIBS=$ac_save_PRINT_LIBS
831                 fi
832
833         elif test x"$enable_cups" = x"yes"; then
834                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
835         fi
836 fi
837
838 AC_ARG_ENABLE(iprint,
839 [AS_HELP_STRING([--enable-iprint], [Turn on iPrint support (default=yes if cups is yes)])])
840
841 if test x$enable_iprint != xno; then
842         if test x"$samba_cv_HAVE_CUPS" = xyes; then
843                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
844         elif test x"$enable_iprint" = x"yes"; then
845                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
846         fi
847 fi
848
849 ############################################
850 # check if the compiler will optimize out function calls
851 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
852     AC_TRY_LINK([
853 #include <stdio.h>],
854 [
855                 if (0) {
856                    this_function_does_not_exist();
857                 } else {
858                   return 1;
859                 }
860
861 ],
862         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
863 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
864    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
865 fi
866
867 #############################################
868 # check for fd passing struct via msg_control
869 AC_CACHE_CHECK([for fd passing via msg_control],samba_cv_msghdr_msg_control, [
870     AC_TRY_COMPILE([
871 #include <sys/types.h>
872 #include <stdlib.h>
873 #include <stddef.h>
874 #include <sys/socket.h>
875 #include <sys/un.h>],
876 [
877         struct msghdr msg;
878         union {
879               struct cmsghdr cm;
880               char control[CMSG_SPACE(sizeof(int))];
881         } control_un;
882         msg.msg_control = control_un.control;
883         msg.msg_controllen = sizeof(control_un.control);
884 ],
885         samba_cv_msghdr_msg_control=yes,samba_cv_msghdr_msg_control=no)])
886 if test x"$samba_cv_msghdr_msg_control" = x"yes"; then
887    AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL,1,
888              [If we can use msg_control for passing file descriptors])
889 fi
890
891 #############################################
892 # check for fd passing struct via msg_acctrights
893 AC_CACHE_CHECK([for fd passing via msg_acctrights],
894                 samba_cv_msghdr_msg_acctrights, [
895     AC_TRY_COMPILE([
896 #include <sys/types.h>
897 #include <stdlib.h>
898 #include <stddef.h>
899 #include <sys/socket.h>
900 #include <sys/un.h>],
901 [
902         struct msghdr msg;
903         int fd;
904         msg.msg_acctrights = (caddr_t) &fd;
905         msg.msg_acctrightslen = sizeof(fd);
906 ],
907         samba_cv_msghdr_msg_acctrights=yes,samba_cv_msghdr_msg_acctrights=no)])
908 if test x"$samba_cv_msghdr_msg_acctrights" = x"yes"; then
909    AC_DEFINE(HAVE_MSGHDR_MSG_ACCTRIGHTS,1,
910              [If we can use msg_acctrights for passing file descriptors])
911 fi
912
913 AC_CHECK_FUNCS(dirfd)
914 if test x"$ac_cv_func_dirfd" = x"yes"; then
915         default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort"
916 fi
917
918 AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [
919     AC_TRY_COMPILE([
920 #include <sys/types.h>
921 #if STDC_HEADERS
922 #include <stdlib.h>
923 #include <stddef.h>
924 #endif
925 #include <signal.h>],[struct sigevent s;],
926         samba_cv_struct_sigevent=yes,samba_cv_struct_sigevent=no)])
927 if test x"$samba_cv_struct_sigevent" = x"yes"; then
928    AC_DEFINE(HAVE_STRUCT_SIGEVENT,1,[Whether we have the struct sigevent])
929    AC_CHECK_MEMBERS([struct sigevent.sigev_value.sival_ptr,struct sigevent.sigev_value.sigval_ptr], , ,
930         [#include <signal.h>])
931 fi
932
933 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
934     AC_TRY_COMPILE([
935 #include <sys/types.h>
936 #if STDC_HEADERS
937 #include <stdlib.h>
938 #include <stddef.h>
939 #endif
940 #if TIME_WITH_SYS_TIME
941 # include <sys/time.h>
942 # include <time.h>
943 #else
944 # if HAVE_SYS_TIME_H
945 #  include <sys/time.h>
946 # else
947 #  include <time.h>
948 # endif
949 #endif
950 ],[struct timespec ts;],
951         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
952 if test x"$samba_cv_struct_timespec" = x"yes"; then
953    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
954 fi
955
956 # and glibc has setresuid under linux but the function does
957 # nothing until kernel 2.1.44! very dumb.
958 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
959     AC_TRY_RUN([#include <errno.h>
960 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
961         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
962 if test x"$samba_cv_have_setresuid" = x"yes"; then
963     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
964 fi
965
966 # Do the same check for setresguid...
967 #
968 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
969     AC_TRY_RUN([#include <unistd.h>
970 #include <errno.h>
971 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
972         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
973 if test x"$samba_cv_have_setresgid" = x"yes"; then
974     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
975 fi
976
977 AC_FUNC_MEMCMP
978
979 ###############################################
980 # Readline included by default unless explicitly asked not to
981 test "${with_readline+set}" != "set" && with_readline=yes
982
983 # test for where we get readline() from
984 AC_MSG_CHECKING(whether to use readline)
985 AC_ARG_WITH(readline,
986 [AS_HELP_STRING([--with-readline[=DIR]], [Look for readline include/libs in DIR (default=auto)])],
987 [  case "$with_readline" in
988   yes)
989     AC_MSG_RESULT(yes)
990
991     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
992     AC_CHECK_HEADERS(readline/history.h)
993
994     AC_CHECK_HEADERS(readline.h readline/readline.h,[
995       for termlib in ncurses curses termcap terminfo termlib tinfo; do
996        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
997       done
998       AC_CHECK_LIB(readline, rl_callback_handler_install,
999        [TERMLIBS="-lreadline $TERMLIBS"
1000        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1001        break], [TERMLIBS=], $TERMLIBS)])
1002     ;;
1003   no)
1004     AC_MSG_RESULT(no)
1005     ;;
1006   *)
1007     AC_MSG_RESULT(yes)
1008
1009     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
1010     # alternate readline path
1011     _ldflags=${LDFLAGS}
1012     _cppflags=${CPPFLAGS}
1013
1014     # Add additional search path
1015     LDFLAGS="-L$with_readline/lib $LDFLAGS"
1016     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1017
1018     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1019     AC_CHECK_HEADERS(readline/history.h)
1020
1021     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1022       for termlib in ncurses curses termcap terminfo termlib; do
1023        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1024       done
1025       AC_CHECK_LIB(readline, rl_callback_handler_install,
1026        [TERMLDFLAGS="-L$with_readline/lib"
1027        TERMCPPFLAGS="-I$with_readline/include"
1028        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1029        TERMLIBS="-lreadline $TERMLIBS"
1030        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1031        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
1032
1033     LDFLAGS=$_ldflags
1034     ;;
1035   esac],
1036   AC_MSG_RESULT(no)
1037 )
1038 AC_SUBST(TERMLIBS)
1039 AC_SUBST(TERMLDFLAGS)
1040
1041 # The readline API changed slightly from readline3 to readline4, so
1042 # code will generate warnings on one of them unless we have a few
1043 # special cases.
1044 AC_CHECK_LIB(readline, rl_completion_matches,
1045              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
1046                         [Do we have rl_completion_matches?])],
1047              [],
1048              [$TERMLIBS])
1049
1050 # not all readline libs have rl_event_hook or history_list
1051 AC_CHECK_DECLS(rl_event_hook, [], [], [#include <readline/readline.h>])
1052 AC_CHECK_LIB(readline, history_list,
1053              [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
1054              [],
1055              [$TERMLIBS])
1056
1057 ###############################################
1058 # test for where we get yp_get_default_domain() from
1059 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1060 AC_CHECK_FUNCS(yp_get_default_domain)
1061
1062 # Check if we have execl, if not we need to compile smbrun.
1063 AC_CHECK_FUNCS(execl)
1064 if test x"$ac_cv_func_execl" = x"no"; then
1065     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1066 fi
1067
1068 AC_CHECK_FUNCS(getcwd fchown chmod fchmod mknod mknod64)
1069 AC_CHECK_FUNCS(strtol)
1070 AC_CHECK_FUNCS(strchr chflags)
1071 AC_CHECK_FUNCS(getrlimit fsync setpgid)
1072 AC_CHECK_FUNCS(fdatasync,,[AC_CHECK_LIB_EXT(rt, LIBS, fdatasync)])
1073 AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
1074 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1075 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
1076 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
1077 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
1078 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
1079 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1080 AC_CHECK_FUNCS(getpwent_r)
1081 AC_CHECK_FUNCS(getdents64)
1082 AC_CHECK_FUNCS(setenv strcasecmp fcvt fcvtl)
1083 AC_CHECK_FUNCS(syslog vsyslog timegm)
1084 AC_CHECK_FUNCS(setlocale nl_langinfo)
1085 AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
1086 AC_CHECK_FUNCS(lutimes futimes utimensat futimens)
1087 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1088 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
1089 AC_CHECK_HEADERS(sys/mman.h)
1090 # setbuffer, shmget, shm_open are needed for smbtorture
1091 AC_CHECK_FUNCS(shmget shm_open)
1092 AC_CHECK_FUNCS(gettext dgettext)
1093 AC_CHECK_FUNCS(bindtextdomain textdomain)
1094 AC_CHECK_FUNCS(strupr)
1095
1096 # Find a method of generating a stack trace
1097 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1098 # libexecinfo provides backtrace_symbols on FreeBSD
1099 AC_SEARCH_LIBS(backtrace_symbols, [execinfo])
1100 AC_CHECK_FUNCS(backtrace_symbols)
1101 AC_CHECK_LIB(exc, trace_back_stack)
1102
1103 # check for sysctlbyname for BSD systems
1104 AC_CHECK_FUNCS(sysctlbyname)
1105
1106 #############################
1107 # check if building with gpfs
1108 AC_CHECK_HEADERS(gpfs_gpl.h)
1109 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
1110     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL headers are available])
1111     default_shared_modules="$default_shared_modules vfs_gpfs"
1112 fi
1113
1114 #############################################
1115 # check if building on Isilon OneFS
1116 printf "%s" "checking for Isilon OneFS... "
1117 save_LIBS="$LIBS"
1118 LIBS="$LIBS -lisi_version"
1119 AC_TRY_LINK([#include <isi_version/isi_version.h>],
1120           [get_isilon_copyright()],
1121           samba_cv_HAVE_ONEFS=yes,
1122           samba_cv_HAVE_ONEFS=no)
1123 echo $samba_cv_HAVE_ONEFS
1124 if test x"$samba_cv_HAVE_ONEFS" = x"yes"; then
1125     AC_DEFINE(HAVE_ONEFS,1,[Whether building on Isilon OneFS])
1126     default_shared_modules="$default_shared_modules vfs_onefs vfs_onefs_shadow_copy perfcount_onefs"
1127     default_static_modules="$default_static_modules"
1128     ONEFS_LIBS="-lisi_acl -lisi_ecs -lisi_event -lisi_util"
1129     # Need to also add general libs for oplocks support
1130     save_LIBS="$save_LIBS -lisi_ecs -lisi_event -lisi_util -ldevstat"
1131 fi
1132 AC_SUBST(ONEFS_LIBS)
1133 LIBS="$save_LIBS"
1134
1135 # Note that all the libunwind symbols in the API are defined to internal
1136 # platform-specific version, so we must include libunwind.h before checking
1137 # any of them.
1138 AC_MSG_CHECKING([for libunwind])
1139 save_LIBS=$LIBS
1140
1141 UNWIND_ARCH="unknown"
1142 if test x"$UNAME_I" != x"unknown"; then
1143         UNWIND_ARCH="$UNAME_I"
1144 elif test x"$UNAME_M" != x"unknown"; then
1145         UNWIND_ARCH="$UNAME_M"
1146 elif test x"$UNAME_P" != x"unknown"; then
1147         UNWIND_ARCH="$UNAME_P"
1148 fi
1149
1150 case "$UNWIND_ARCH" in
1151         unknown)
1152                 # This probably won't link without
1153                 # the platform-specific libunwind.
1154                 LIBS="$LIBS -lunwind"
1155                 ;;
1156         i386|i586|i686)
1157                 # Add the platform-specific libunwind module.
1158                 LIBS="$LIBS -lunwind -lunwind-x86"
1159                 ;;
1160         *)
1161                 # Add the platform-specific libunwind module.
1162                 # based on uname -i, uname -m or uname -p
1163                 LIBS="$LIBS -lunwind -lunwind-$UNWIND_ARCH"
1164                 ;;
1165 esac
1166
1167 AC_TRY_LINK(
1168     [
1169 #ifdef HAVE_LIBUNWIND_H
1170 #include <libunwind.h>
1171 #endif
1172     ],
1173     [
1174         unw_context_t ctx; unw_cursor_t cur;
1175         char buf[256]; unw_word_t off;
1176         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1177         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1178     ],
1179     [
1180         AC_MSG_RESULT(yes)
1181         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1182
1183         # If we have libunwind, test whether we also have libunwind-ptrace
1184         # which would let us unwind arbitrary processes.
1185         save_LIBS=$LIBS
1186         AC_CHECK_HEADERS(libunwind-ptrace.h)
1187         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1188             [
1189                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1190                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1191                     [Whether libunwind-ptrace.a is available.])
1192             ],
1193             [ LIBUNWIND_PTRACE="" ])
1194
1195         LIBS=$save_LIBS
1196     ],
1197     [
1198         AC_MSG_RESULT(no)
1199         LIBS=$save_LIBS
1200     ])
1201
1202 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1203 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1204     AC_CHECK_HEADERS(sys/ptrace.h)
1205     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1206     AC_TRY_LINK(
1207             [
1208 #if HAVE_SYS_TYPES_H
1209 #include <sys/types.h>
1210 #endif
1211 #if HAVE_SYS_PTRACE_H
1212 #include <sys/ptrace.h>
1213 #endif
1214             ],
1215             [
1216                 pid_t me = (pid_t)-1;
1217                 ptrace(PTRACE_ATTACH, me, 0, 0);
1218                 ptrace(PTRACE_DETACH, me, 0, 0);
1219                 return 0;
1220             ],
1221             [
1222                 AC_MSG_RESULT(yes)
1223                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1224                     [Whether the Linux ptrace(2) interface is available.])
1225             ],
1226             [
1227                 AC_MSG_RESULT(no)
1228                 LIBUNWIND_PTRACE=""
1229             ])
1230 fi
1231
1232 AC_SUBST(LIBUNWIND_PTRACE)
1233
1234 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1235 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1236 AC_CHECK_FUNCS(__getcwd _getcwd)
1237 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1238 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1239 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1240 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1241 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1242 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1243 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1244 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1245 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1246 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1247 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1248 AC_CHECK_FUNCS(prctl)
1249
1250 AC_TRY_COMPILE([
1251 #ifdef HAVE_SYS_PRCTL_H
1252 #include <sys/prctl.h>
1253 #endif
1254 ],
1255 [int i; i = prtcl(0); ],
1256 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1257
1258 #
1259 #
1260 #
1261 case "$host_os" in
1262     *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
1263        # glibc <= 2.3.2 has a broken getgrouplist
1264        AC_CACHE_CHECK([for good getgrouplist],samba_cv_linux_getgrouplist_ok,[AC_TRY_RUN([
1265 #include <unistd.h>
1266 #include <sys/utsname.h>
1267 main() {
1268        /* glibc up to 2.3 has a broken getgrouplist */
1269 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1270        int libc_major = __GLIBC__;
1271        int libc_minor = __GLIBC_MINOR__;
1272
1273        if (libc_major < 2)
1274               exit(1);
1275        if ((libc_major == 2) && (libc_minor <= 3))
1276               exit(1);
1277 #endif
1278        exit(0);
1279 }
1280 ], [samba_cv_linux_getgrouplist_ok=yes],
1281    [samba_cv_linux_getgrouplist_ok=no],
1282    [samba_cv_linux_getgrouplist_ok=cross])])
1283        if test x"$samba_cv_linux_getgrouplist_ok" = x"yes"; then
1284           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1285        fi
1286        ;;
1287     *)
1288        AC_CHECK_FUNCS(getgrouplist)
1289        ;;
1290 esac
1291
1292 #
1293 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1294 #
1295
1296 if test x$ac_cv_func_stat64 = xno ; then
1297   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1298   AC_TRY_LINK([
1299 #if defined(HAVE_UNISTD_H)
1300 #include <unistd.h>
1301 #endif
1302 #include <sys/stat.h>
1303 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1304   AC_MSG_RESULT([$ac_cv_func_stat64])
1305   if test x$ac_cv_func_stat64 = xyes ; then
1306     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1307   fi
1308 fi
1309
1310 if test x$ac_cv_func_lstat64 = xno ; then
1311   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1312   AC_TRY_LINK([
1313 #if defined(HAVE_UNISTD_H)
1314 #include <unistd.h>
1315 #endif
1316 #include <sys/stat.h>
1317 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1318   AC_MSG_RESULT([$ac_cv_func_lstat64])
1319   if test x$ac_cv_func_lstat64 = xyes ; then
1320     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1321   fi
1322 fi
1323
1324 if test x$ac_cv_func_fstat64 = xno ; then
1325   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1326   AC_TRY_LINK([
1327 #if defined(HAVE_UNISTD_H)
1328 #include <unistd.h>
1329 #endif
1330 #include <sys/stat.h>
1331 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1332   AC_MSG_RESULT([$ac_cv_func_fstat64])
1333   if test x$ac_cv_func_fstat64 = xyes ; then
1334     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1335   fi
1336 fi
1337
1338 #################################################
1339 # Check whether struct stat has timestamps with sub-second resolution.
1340 #
1341
1342 samba_cv_stat_hires=no
1343 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec], # Linux, Solaris
1344         [samba_cv_stat_hires=yes])
1345 AC_CHECK_MEMBERS([struct stat.st_mtimensec], # BSD, if defined _POSIX_SOURCE
1346         [samba_cv_stat_hires=yes])
1347 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec], # BSD, if not defined _POSIX_SOURCE
1348         [samba_cv_stat_hires=yes])
1349 AC_CHECK_MEMBERS([struct stat.st_mtime_n], # AIX
1350         [samba_cv_stat_hires=yes])
1351 AC_CHECK_MEMBERS([struct stat.st_umtime], # Tru64
1352         [samba_cv_stat_hires=yes])
1353
1354 if test x"$samba_cv_stat_hires" = x"yes" ; then
1355     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1356             [whether struct stat has sub-second timestamps])
1357 fi
1358
1359 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1360 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
1361 AC_CHECK_MEMBERS([struct stat.st_birthtime], AC_CHECK_MEMBERS([struct stat.st_birthtimensec]))
1362
1363
1364 AC_CACHE_CHECK([whether there is DOS flags support in the stat struct], samba_cv_stat_dos_flags,
1365     [
1366         AC_TRY_COMPILE(
1367             [#include <sys/stat.h>],
1368             [
1369                 int a = UF_DOS_ARCHIVE;
1370                 int h = UF_DOS_HIDDEN;
1371                 int r = UF_DOS_RO;
1372                 int s = UF_DOS_SYSTEM;
1373                 int i = UF_DOS_NOINDEX;
1374                 int f = UF_DOS_FLAGS;
1375             ],
1376             samba_cv_stat_dos_flags=yes, samba_cv_stat_dos_flags=no)
1377     ])
1378
1379 if test x"$samba_cv_stat_dos_flags" = x"yes" ; then
1380     AC_DEFINE(HAVE_STAT_DOS_FLAGS, 1, [whether there is DOS flags support in the stat struct])
1381 fi
1382
1383 AC_CACHE_CHECK([whether we can compile with __attribute__((destructor))],
1384                samba_cv_function_attribute_destructor,
1385                [
1386                  AC_COMPILE_IFELSE(
1387                         [
1388                                 __attribute__((destructor))
1389                                 static void cleanup(void) { }
1390                         ],
1391                         samba_cv_function_attribute_destructor=yes)
1392                 ])
1393
1394 if test x"$samba_cv_function_attribute_destructor" = xyes ; then
1395    AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR, 1,
1396              [whether we can compile with __attribute__((destructor))])
1397 fi
1398
1399 #####################################
1400 # needed for SRV lookups
1401 AC_CHECK_LIB(resolv, dn_expand)
1402 AC_CHECK_LIB(resolv, _dn_expand)
1403 AC_CHECK_LIB(resolv, __dn_expand)
1404
1405 #
1406 # Check for the functions putprpwnam, set_auth_parameters,
1407 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1408 # Needed for OSF1 and HPUX.
1409 #
1410
1411 AC_LIBTESTFUNC(security, putprpwnam)
1412 AC_LIBTESTFUNC(sec, putprpwnam)
1413
1414 AC_LIBTESTFUNC(security, set_auth_parameters)
1415 AC_LIBTESTFUNC(sec, set_auth_parameters)
1416
1417 # UnixWare 7.x has its getspnam in -lgen
1418 AC_LIBTESTFUNC(gen, getspnam)
1419
1420 AC_LIBTESTFUNC(security, getspnam)
1421 AC_LIBTESTFUNC(sec, getspnam)
1422
1423 AC_LIBTESTFUNC(security, bigcrypt)
1424 AC_LIBTESTFUNC(sec, bigcrypt)
1425
1426 AC_LIBTESTFUNC(security, getprpwnam)
1427 AC_LIBTESTFUNC(sec, getprpwnam)
1428
1429 AC_CHECK_FUNCS(strsignal)
1430
1431 ############################################
1432 # Check for EA implementations
1433 case "$host_os" in
1434   *osf*)
1435         AC_SEARCH_LIBS(getproplist, [proplist])
1436         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1437         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1438         AC_CHECK_FUNCS(sizeof_proplist_entry)
1439   ;;
1440   *freebsd4* | *dragonfly* )
1441         AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1442   ;;
1443   *solaris*)
1444         AC_CHECK_FUNCS(attropen)
1445   ;;
1446   *)
1447         AC_SEARCH_LIBS(getxattr, [attr])
1448         AC_CHECK_FUNCS(getxattr,[
1449                 AC_CHECK_FUNCS(lgetxattr fgetxattr listxattr llistxattr flistxattr removexattr lremovexattr fremovexattr setxattr lsetxattr fsetxattr)
1450                 ])
1451         AC_CHECK_FUNCS(getea,[
1452                 AC_CHECK_FUNCS(fgetea lgetea listea flistea llistea removeea fremoveea lremoveea setea fsetea lsetea)
1453                 ])
1454         AC_CHECK_FUNCS(attr_get,[
1455                 AC_CHECK_FUNCS(attr_list attr_set attr_remove attr_getf attr_listf attr_setf attr_removef)
1456                 ])
1457         AC_CHECK_FUNCS(extattr_delete_file,[
1458                 AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file extattr_get_link extattr_list_fd extattr_list_file extattr_list_link extattr_set_fd extattr_set_file extattr_set_link)
1459                 ])
1460   ;;
1461 esac
1462
1463 ########################################################
1464 # Do xattr functions take additional options like on Darwin?
1465 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1466         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1467                 old_LIBS=$LIBS
1468                 LIBS="$LIBS $ACL_LIBS"
1469                 AC_TRY_COMPILE([
1470                         #include <sys/types.h>
1471                         #if HAVE_ATTR_XATTR_H
1472                         #include <attr/xattr.h>
1473                         #elif HAVE_SYS_XATTR_H
1474                         #include <sys/xattr.h>
1475                         #endif
1476                 ],[
1477                         getxattr(0, 0, 0, 0, 0, 0);
1478                 ],
1479                 [smb_attr_cv_xattr_add_opt=yes],
1480                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1481         ])
1482         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1483                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1484         fi
1485 fi
1486
1487 AC_DISABLE_STATIC
1488 AC_ENABLE_SHARED
1489
1490 # Set defaults
1491 PIE_CFLAGS=""
1492 PIE_LDFLAGS=""
1493 AC_ARG_ENABLE(pie, [AS_HELP_STRING([--enable-pie], [Turn on pie support if available (default=yes)])])
1494
1495 if test "x$enable_pie" != xno
1496 then
1497         AC_CACHE_CHECK(for -pie and -fPIE, samba_cv_fpie,
1498         [
1499                 cat > conftest.c <<EOF
1500 int foo;
1501 int main () { return 0;}
1502 EOF
1503                 if AC_TRY_COMMAND_NO_STDERR([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c])
1504                 then
1505                         samba_cv_fpie=yes
1506                 else
1507                         samba_cv_fpie=no
1508                 fi
1509                 rm -f conftest*
1510         ])
1511         if test x"${samba_cv_fpie}" = x"yes"
1512         then
1513                 PIE_CFLAGS="-fPIE"
1514                 PIE_LDFLAGS="-pie"
1515         fi
1516 fi
1517
1518 # Set defaults
1519 RELRO_LDFLAGS=""
1520 AC_ARG_ENABLE(relro, [AS_HELP_STRING([--enable-relro], [Turn on Relocations Read-Only (relro) support if available (default=yes)])])
1521
1522 if test "x$enable_relro" != xno
1523 then
1524         AC_CACHE_CHECK([for -Wl,-z,relro], samba_cv_relro,
1525         [
1526                 cat > conftest.c <<EOF
1527 int foo;
1528 main () { return 0;}
1529 EOF
1530                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1531                 then
1532                         samba_cv_relro=yes
1533                 else
1534                         samba_cv_relro=no
1535                 fi
1536                 rm -f conftest*
1537         ])
1538         if test x"${samba_cv_relro}" = x"yes"
1539         then
1540                 RELRO_LDFLAGS="-Wl,-z,relro"
1541         fi
1542 fi
1543
1544 # Set defaults
1545 SYMSEXT="syms"
1546 AC_SUBST(SYMSEXT)
1547
1548 # Assume non-shared by default and override below
1549 BLDSHARED="false"
1550
1551 # these are the defaults, good for lots of systems
1552 HOST_OS="$host_os"
1553 LDSHFLAGS="-shared"
1554 MODULE_EXPORTS=""
1555 SONAMEFLAG="#"
1556 SHLD="\${CC} \${CFLAGS}"
1557 PICFLAG="${PIE_CFLAGS}"
1558 SHLIBEXT="so"
1559 DSO_EXPORTS=""
1560
1561 # this bit needs to be modified for each OS that supports share libs
1562 # You need to specify how to create a shared library and
1563   # how to compile C code to produce PIC object files
1564
1565   AC_MSG_CHECKING([ability to build shared libraries])
1566
1567   # and these are for particular systems
1568   case "$host_os" in
1569                 *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
1570                         case "$host_os" in
1571                                 *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
1572                                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx]) ;;
1573                         esac
1574                         BLDSHARED="true"
1575                         LDSHFLAGS="-shared -Wl,-Bsymbolic"
1576                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1577                                 LDSHFLAGS_Z_NODEFS="-Wl,--allow-shlib-undefined"
1578                         fi
1579                         DYNEXP="-Wl,--export-dynamic"
1580                         PICFLAG="-fPIC"
1581                         SONAMEFLAG="-Wl,-soname="
1582                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1583                         ;;
1584                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1585                         BLDSHARED="true"
1586                         if test "${GCC}" = "yes"; then
1587                                 PICFLAG="-fPIC"
1588                                 SONAMEFLAG="-Wl,-soname="
1589                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1590                                         DYNEXP="-Wl,-E"
1591                                 fi
1592                                 LDSHFLAGS="-shared"
1593                         else
1594                                 PICFLAG="-KPIC"
1595                                 LDSHFLAGS="-G"
1596                         fi
1597                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1598                                 SONAMEFLAG="-Wl,-soname="
1599                         else
1600                                 SONAMEFLAG="-Wl,-h,"
1601                         fi
1602                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1603                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1604                         ;;
1605                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1606                         BLDSHARED="true"
1607                         LDSHFLAGS="-G"
1608                         SONAMEFLAG="-Wl,-h,"
1609                         PICFLAG="-KPIC"   # Is this correct for SunOS
1610                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1611                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1612                         ;;
1613                 *netbsd* | *freebsd* | *dragonfly* )
1614                         BLDSHARED="true"
1615                         LDSHFLAGS="-shared"
1616                         DYNEXP="-Wl,--export-dynamic"
1617                         SONAMEFLAG="-Wl,-soname,"
1618                         PICFLAG="-fPIC -DPIC"
1619                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1620                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1621                         ;;
1622                 *openbsd*)  BLDSHARED="true"
1623                         LDSHFLAGS="-shared"
1624                         DYNEXP="-Wl,-Bdynamic"
1625                         SONAMEFLAG="-Wl,-soname,"
1626                         PICFLAG="-fPIC"
1627                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1628                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1629                         ;;
1630                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1631                         case "$host_os" in
1632                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1633                         ;;
1634                         esac
1635                         BLDSHARED="true"
1636                         LDSHFLAGS="-set_version sgi1.0 -shared"
1637                         SONAMEFLAG="-soname "
1638                         SHLD="\${LD}"
1639                         if test "${GCC}" = "yes"; then
1640                                 PICFLAG="-fPIC"
1641                         else
1642                                 PICFLAG="-KPIC"
1643                         fi
1644                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1645                         ;;
1646                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1647                         BLDSHARED="true"
1648                         # use expfull to export underscored symbols
1649                         # add rtl to remove /lib/crt0.o warning
1650                         LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc,-brtl"
1651                         DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
1652                         PICFLAG="-O2"
1653                         # as AIX code is always position independent...
1654                         # .po will just create compile warnings, use po.o:
1655                         if test "${GCC}" != "yes"; then
1656                                 ## for funky AIX compiler using strncpy()
1657                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000 -qhalt=e"
1658                         fi
1659
1660                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1661                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1662                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1663                         ;;
1664                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1665                         # ia64: 64bit build using gcc with CFLAGS="-mpl64"
1666                         #       64bit build using HP's cc with CFLAGS="+DD64"
1667                         # hppa: 64bit build unsupported by gcc
1668                         #       64bit build using HP's cc with CFLAGS="+DA2.0w"
1669                         # HP-UX 11.00 ld needs PHSS_33034
1670                         BLDSHARED="true"
1671                         if test "${GCC}" = "yes"; then
1672                                 PICFLAG="-fPIC"
1673                                 LDSHFLAGS="-shared"
1674                         else
1675                                 PICFLAG="+z"
1676                                 LDSHFLAGS="-Wl,-B,symbolic,-b"
1677                                 if test "$host_cpu" != "ia64"; then
1678                                         # "don't store literals in read-only memory" (?):
1679                                         PICFLAG="$PICFLAG +ESnolit"
1680                                 fi
1681                         fi
1682                         if test "$host_cpu" = "ia64"; then
1683                                 SHLIBEXT="so"
1684                                 # TODO: does the linker find the right 32/64 bit version of the libs? :
1685                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32:/usr/local/lib/hpux64:/usr/lib/hpux64"
1686                         else
1687                                 SHLIBEXT="sl"
1688                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1689                         fi
1690                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1691                                 SONAMEFLAG="-Wl,-soname="
1692                         else
1693                                 SONAMEFLAG="-Wl,+h,"
1694                         fi
1695                         # PIE/PIC flags at link time are required on HP-UX because
1696                         # linking requires a temporary source file, which is being
1697                         # compiled with the indicated flags - which need to contain
1698                         # PIC flags when we don't support PIE flags:
1699                         if test "$PIE_LDFLAGS" = "" ; then
1700                                 PIE_LDFLAGS=\${PICFLAG}
1701                         fi
1702                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1703                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1704                         ;;
1705                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1706                         BLDSHARED="true"
1707                         LDSHFLAGS="-shared"
1708                         SONAMEFLAG="-Wl,-soname,"
1709                         PICFLAG="-fPIC"
1710                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1711                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1712                         for flags in "-expect_unresolved '*'" "-Wl,-expect_unresolved,'*'" ; do
1713                                 saved_ldflags="$LDFLAGS"
1714                                 AC_MSG_CHECKING([if $flags works])
1715                                 LDFLAGS="$flags $saved_ldflags"
1716                                 AC_TRY_LINK([],[],
1717                                         [AC_MSG_RESULT([yes])
1718                                         LDSHFLAGS_Z_NODEFS=$flags],
1719                                         AC_MSG_RESULT([no]))
1720                                 LDFLAGS="$saved_ldflags"
1721                                 test x"$LDSHFLAGS_Z_NODEFS" != x && break
1722                         done
1723                         ;;
1724                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1725                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1726                         ;;
1727                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1728                         BLDSHARED="true"
1729                         LDSHFLAGS="-shared"
1730                         SONAMEFLAG="-Wl,-soname,"
1731                         PICFLAG="-KPIC"
1732                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1733                         ;;
1734                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1735                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1736                         ;;
1737                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1738                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1739                         ;;
1740                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1741                         case "$host" in
1742                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1743                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1744                                         fi
1745                                         LDSHFLAGS="-G"
1746                                         DYNEXP="-Bexport"
1747                                 ;;
1748                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1749                         esac
1750                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1751                         ;;
1752
1753                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1754                         if [ test "$GCC" != yes ]; then
1755                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1756                         fi
1757                         LDSHFLAGS="-G"
1758                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1759                         ;;
1760                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1761                         BLDSHARED="false"
1762                         LDSHFLAGS=""
1763                         ;;
1764
1765                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1766                         BLDSHARED="true"
1767                         LDSHFLAGS="-dynamiclib -flat_namespace -undefined suppress"
1768                         CFLAGS="$CFLAGS -fno-common"
1769                         SHLD="\${CC}"
1770                         SHLIBEXT="dylib"
1771                         MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
1772                         SHLIBEXT="dylib"
1773                         # Since gcc doesn't fail on unrecognised options, the
1774                         # PIE test incorrectly succeeds. Darwin gcc does not
1775                         # actually support the PIE stuff.
1776                         PIE_LDFLAGS=
1777                         PIE_CFLAGS=
1778                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1779                         ;;
1780
1781                 *)
1782                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1783                         ;;
1784   esac
1785
1786 if test "$enable_shared" != "yes"; then
1787         BLDSHARED=false
1788 fi
1789
1790 if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then
1791         DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\)
1792 fi
1793
1794 if test x"$BLDSHARED" = x"true" ; then
1795         LDFLAGS="$LDFLAGS -L./bin"
1796 fi
1797
1798 AC_MSG_RESULT($BLDSHARED)
1799
1800 for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
1801         saved_ldflags="$LDFLAGS"
1802         AC_MSG_CHECKING([if $flags works])
1803         LDFLAGS="$flags $saved_ldflags"
1804         AC_TRY_LINK([],[],
1805                 [AC_MSG_RESULT([yes])
1806                 LD_AS_NEEDED_FLAG=$flags
1807                 ld_as_needed_flag_found=yes],
1808                 AC_MSG_RESULT([no]))
1809         LDFLAGS="$LD_AS_NEEDED_FLAG $saved_ldflags"
1810         test x"$ld_as_needed_flag_found" = xyes && break
1811 done
1812
1813 # for historical reasons almost all linkers don't complain about unresolved
1814 # symbols in shared libs. Except for the internal samba modules we want to get
1815 # errors when we produce a shared lib with unresolved symbols. On some
1816 # platforms unresolved symbols might be intended, so we might have to add
1817 # platform specific exceptions here.
1818
1819 for flags in "-Wl,-z,defs" "-error_unresolved" "-Wl,-error_unresolved" ; do
1820         saved_ldflags="$LDFLAGS"
1821         AC_MSG_CHECKING([if $flags works])
1822         LDFLAGS="$flags $saved_ldflags"
1823         AC_TRY_LINK([],[],
1824         [AC_MSG_RESULT([yes])
1825         LDSHFLAGS_Z_DEFS=$flags
1826         ldshflags_z_defs_found=yes],
1827         AC_MSG_RESULT([no]))
1828         LDFLAGS=$saved_ldflags
1829         test x"$ldshflags_z_defs_found" = xyes && break
1830 done
1831
1832 AC_MSG_CHECKING([LDSHFLAGS_Z_DEFS])
1833 AC_MSG_RESULT([$LDSHFLAGS_Z_DEFS])
1834 AC_MSG_CHECKING([LDFLAGS])
1835 AC_MSG_RESULT([$LDFLAGS])
1836 AC_MSG_CHECKING([DYNEXP])
1837 AC_MSG_RESULT([$DYNEXP])
1838
1839 #######################################################
1840 # test whether building a shared library actually works
1841 if test $BLDSHARED = true; then
1842
1843 AC_MSG_CHECKING([SHLD])
1844 AC_MSG_RESULT([$SHLD])
1845 AC_MSG_CHECKING([LDSHFLAGS])
1846 AC_MSG_RESULT([$LDSHFLAGS])
1847
1848 AC_MSG_CHECKING([SHLIBEXT])
1849 AC_MSG_RESULT([$SHLIBEXT])
1850 AC_MSG_CHECKING([SONAMEFLAG])
1851 AC_MSG_RESULT([$SONAMEFLAG])
1852
1853 AC_MSG_CHECKING([PICFLAG])
1854 AC_MSG_RESULT([$PICFLAG])
1855
1856 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
1857 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
1858
1859 AC_CACHE_CHECK([whether building shared libraries actually works],
1860                [ac_cv_shlib_works],[
1861    # try building a trivial shared library
1862    ac_cv_shlib_works=no
1863    # The $SHLD and $LDSHFLAGS variables may contain references to other
1864    # variables so they need to be eval'ed.
1865    if AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.o ${srcdir-.}/../tests/shlib.c 1>&AS_MESSAGE_LOG_FD])
1866    then
1867      if AC_TRY_COMMAND([`eval echo "$SHLD $LDSHFLAGS $PICFLAG"` -o "shlib.$SHLIBEXT" shlib.o 1>&AS_MESSAGE_LOG_FD])
1868      then
1869        ac_cv_shlib_works=yes
1870      fi
1871    fi
1872    rm -f "shlib.$SHLIBEXT" shlib.o
1873
1874 ])
1875 if test $ac_cv_shlib_works = no; then
1876    BLDSHARED=false
1877 fi
1878 fi
1879
1880 if test x"$BLDSHARED" != x"true"; then
1881         LDSHFLAGS="shared-libraries-disabled"
1882         SONAMEFLAG="shared-libraries-disabled"
1883         NSSSONAMEVERSIONSUFFIX="shared-libraries-disabled"
1884         SHLD="shared-libraries-disabled"
1885         PICFLAG="${PIE_CFLAGS}"
1886         SHLIBEXT="shared_libraries_disabled"
1887         merged_build_possible=no
1888 fi
1889
1890 AC_MSG_CHECKING([used PICFLAG])
1891 AC_MSG_RESULT([$PICFLAG])
1892
1893 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
1894
1895 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
1896
1897
1898 ###########################################################
1899 #
1900 # Configuration of subsystems / libraries
1901 #
1902 ###########################################################
1903
1904 INSTALLLIBCMD_SH=:
1905 INSTALLLIBCMD_A=:
1906 UNINSTALLLIBCMD_SH=:
1907 UNINSTALLLIBCMD_A=:
1908
1909 if test $BLDSHARED = true; then
1910         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
1911         UNINSTALLLIBCMD_SH="rm -f"
1912 fi
1913 if test $enable_static = yes; then
1914         INSTALLLIBCMD_A="\$(INSTALLCMD)"
1915         UNINSTALLLIBCMD_A="rm -f"
1916 fi
1917
1918 #################################################
1919 # --disable-shared-libs
1920 # can be used to disable the internal use of shared libs altogether
1921 # (this only has an effect when building shared libs is enabled)
1922 #
1923 USESHARED=false
1924 AC_SUBST(USESHARED)
1925
1926 AC_MSG_CHECKING(whether to use shared libraries internally)
1927 AC_ARG_ENABLE([shared-libs],
1928         AS_HELP_STRING([--enable-shared-libs],
1929                 [Use shared libraries internally (default=yes)]),
1930         [enable_shared_libs=$enableval],
1931         [enable_shared_libs=yes])
1932
1933 if test x"$enable_shared_libs" != x"no" ; then
1934         USESHARED=$BLDSHARED
1935 fi
1936
1937 AC_MSG_RESULT([$USESHARED])
1938
1939 if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then
1940         AC_MSG_WARN([--enable-shared-libs: no support for shared libraries])
1941 fi
1942
1943 #################################################
1944 # --with-static-libs=LIBS:
1945 #   link (internal) libs dynamically or statically?
1946 #
1947 # If a subsystem is built as a library then this controls whether they are
1948 # linked into Samba targets statically or dynamically:
1949 #
1950 # * If we build the shared library at all, we link dynamically by default.
1951 #
1952 # * We only link statically if we don't build shared or if the library
1953 #   appears in the --with-static-libs configure option.
1954 #
1955 # Example:
1956 #   --with-static-libs=libtalloc makes use of libtalloc.a instead
1957 #   of linking the dynamic variant with -ltalloc.
1958 #
1959 # NOTE: This option only affects libraries that we do not only build
1960 # but that samba also links against as libraries (as opposed to linking
1961 # the plain object files. - This has to be configured in Makefile.in.
1962 # So in particular it does not harm to give invalid or unknown names here.
1963 #
1964
1965 AC_ARG_WITH([static-libs],
1966         [AS_HELP_STRING([--with-static-libs=LIBS],
1967                 [Comma-separated list of names of (internal) libraries to link statically (instead of dynamically)])],
1968         [AS_IF([test $withval],
1969                 [for lib in `echo $withval | sed -e 's/,/ /g'` ; do
1970                         [lib=`echo $lib | tr '[a-z]' '[A-Z]'`]
1971                         eval LINK_$lib=STATIC
1972                 done], [])],
1973         [])
1974
1975 #
1976 # WORKAROUND:
1977 #   until we have organized other internal subsystems (as util, registry
1978 #   and smbconf) into shared libraries, we CAN NOT link libnetapi
1979 #   dynamically to samba programs.
1980 #
1981 LINK_LIBNETAPI=STATIC
1982
1983 LINK_LIBSMBCLIENT=STATIC
1984
1985 #
1986 #  The library versions are hardcoded here
1987 #  and filled into the LIBFOO_SOVER variable.
1988 #
1989 #  TODO: for talloc and tdb (at least), these should
1990 #  be extracted from their respective source directories
1991 #
1992 AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])],
1993 [ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
1994
1995 if test "x$enable_external_libtalloc" != xno
1996 then
1997         PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.1,
1998                 [ enable_external_libtalloc=yes ],
1999                 [ if test x$enable_external_libtalloc = xyes; then
2000                         AC_MSG_ERROR([Unable to find libtalloc])
2001                   else
2002                         enable_external_libtalloc=no
2003                   fi
2004                 ])
2005 fi
2006
2007 if test "x$enable_external_libtalloc" = xno
2008 then
2009         m4_include(../lib/talloc/libtalloc.m4)
2010         LINK_LIBTALLOC=STATIC
2011         SMB_LIBRARY(talloc, 2)
2012         LIBTALLOC_OBJ0=""
2013         for obj in ${TALLOC_OBJ}; do
2014                 LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
2015         done
2016         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
2017         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TALLOC_CFLAGS}"
2018         AC_SUBST(LIBTALLOC_OBJ0)
2019
2020         TALLOCTORT="bin/talloctort\$(EXEEXT)"
2021         AC_SUBST(TALLOCTORT)
2022 fi
2023
2024
2025 AC_ARG_ENABLE(external_libtdb,
2026         [AS_HELP_STRING([--enable-external-libtdb],
2027                 [Enable external tdb [default=auto]])],
2028                 [ enable_external_libtalloc=$enableval ],
2029                 [ enable_external_libtalloc=auto ])
2030
2031 if test "x$enable_external_libtdb" != xno
2032 then
2033         PKG_CHECK_MODULES(LIBTDB, tdb >= 1.2.2,
2034                 [ enable_external_libtdb=yes ],
2035                 [
2036                 if test x$enable_external_libtdb = xyes; then
2037                         AC_MSG_ERROR([Unable to find libtdb])
2038                 else
2039                         enable_external_libtdb=no
2040                 fi
2041                 ])
2042 fi
2043
2044 AC_SUBST(LIBTDB_OBJ0)
2045 if test "x$enable_external_libtdb" = xno
2046 then
2047         m4_include(../lib/tdb/libtdb.m4)
2048         LINK_LIBTDB=STATIC
2049         SMB_LIBRARY(tdb, 1)
2050         LIBTDB_OBJ0=""
2051         for obj in ${TDB_OBJ}; do
2052                 LIBTDB_OBJ0="${LIBTDB_OBJ0} ${tdbdir}/${obj}"
2053         done
2054         AC_SUBST(LIBTDB_OBJ0)
2055         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
2056         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TDB_CFLAGS}"
2057
2058         TDBBACKUP="bin/tdbbackup\$(EXEEXT)"
2059         AC_SUBST(TDBBACKUP)
2060         TDBDUMP="bin/tdbdump\$(EXEEXT)"
2061         AC_SUBST(TDBDUMP)
2062         TDBTOOL="bin/tdbtool\$(EXEEXT)"
2063         AC_SUBST(TDBTOOL)
2064         TDBTORTURE="bin/tdbtorture\$(EXEEXT)"
2065         AC_SUBST(TDBTORTURE)
2066         ac_cv_have_tdb_err_nesting=yes
2067 else
2068         AC_TRY_COMPILE([#include "tdb.h"],
2069                        [enum TDB_ERROR err = TDB_ERR_NESTING],
2070                        ac_cv_have_tdb_err_nesting=yes,
2071                        ac_cv_have_tdb_err_nesting=no)
2072 fi
2073
2074 if test x"$ac_cv_have_tdb_err_nesting" = xyes; then
2075    AC_DEFINE(HAVE_TDB_ERR_NESTING, 1, [Whether we have TDB_ERR_NESTING])
2076 fi
2077
2078 SMB_LIBRARY(netapi, 0)
2079 SMB_LIBRARY(smbclient, 0)
2080 SMB_LIBRARY(smbsharemodes, 0)
2081 SMB_LIBRARY(addns, 0, no, [undefined API])
2082
2083
2084
2085 ################
2086
2087 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
2088 AC_TRY_RUN([#include <stdio.h>
2089 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
2090 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
2091 if test x"$samba_cv_have_longlong" = x"yes"; then
2092     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
2093     AC_CHECK_TYPE(intptr_t, unsigned long long)
2094 else
2095     AC_CHECK_TYPE(intptr_t, unsigned long)
2096 fi
2097
2098 #
2099 # Check if the compiler supports the LL prefix on long long integers.
2100 # AIX needs this.
2101
2102 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
2103     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
2104         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
2105 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
2106    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
2107 fi
2108
2109
2110 AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
2111 AC_TRY_RUN([#include <time.h>
2112 main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
2113 samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
2114 if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
2115     AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
2116 fi
2117
2118 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
2119 AC_TRY_RUN([#include <stdio.h>
2120 #include <sys/stat.h>
2121 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
2122 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
2123 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
2124     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
2125 fi
2126
2127 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
2128 AC_TRY_RUN([
2129 #if defined(HAVE_UNISTD_H)
2130 #include <unistd.h>
2131 #endif
2132 #include <stdio.h>
2133 #include <sys/stat.h>
2134 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2135 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
2136 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
2137     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
2138 fi
2139
2140 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
2141 AC_TRY_RUN([
2142 #if defined(HAVE_UNISTD_H)
2143 #include <unistd.h>
2144 #endif
2145 #include <stdio.h>
2146 #include <sys/stat.h>
2147 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
2148 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
2149 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
2150     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
2151 fi
2152
2153 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
2154 AC_TRY_RUN([
2155 #if defined(HAVE_UNISTD_H)
2156 #include <unistd.h>
2157 #endif
2158 #include <stdio.h>
2159 #include <sys/stat.h>
2160 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2161 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
2162 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
2163     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
2164 fi
2165
2166 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
2167 AC_TRY_RUN([
2168 #if defined(HAVE_UNISTD_H)
2169 #include <unistd.h>
2170 #endif
2171 #include <stdio.h>
2172 #include <sys/stat.h>
2173 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
2174 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
2175 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
2176     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
2177 fi
2178
2179 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
2180 AC_TRY_RUN([
2181 #if defined(HAVE_UNISTD_H)
2182 #include <unistd.h>
2183 #endif
2184 #include <stdio.h>
2185 #include <sys/stat.h>
2186 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2187 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
2188 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
2189     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
2190 fi
2191
2192 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
2193 AC_TRY_COMPILE([
2194 #if defined(HAVE_UNISTD_H)
2195 #include <unistd.h>
2196 #endif
2197 #include <sys/types.h>
2198 #include <dirent.h>],
2199 [DIR64 de;],
2200 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
2201 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2202     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
2203 fi
2204
2205 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
2206 AC_TRY_COMPILE([
2207 #if defined(HAVE_UNISTD_H)
2208 #include <unistd.h>
2209 #endif
2210 #include <sys/types.h>
2211 #include <dirent.h>],
2212 [struct dirent64 de;],
2213 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
2214 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2215     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
2216 fi
2217
2218 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
2219 AC_TRY_RUN([
2220 #if defined(HAVE_UNISTD_H)
2221 #include <unistd.h>
2222 #endif
2223 #include <sys/types.h>
2224 main() { dev_t dev; int i = major(dev); return 0; }],
2225 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
2226 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
2227     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
2228 fi
2229
2230 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
2231 AC_TRY_RUN([
2232 #if defined(HAVE_UNISTD_H)
2233 #include <unistd.h>
2234 #endif
2235 #include <sys/types.h>
2236 main() { dev_t dev; int i = minor(dev); return 0; }],
2237 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
2238 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
2239     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
2240 fi
2241
2242 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
2243 AC_TRY_RUN([
2244 #if defined(HAVE_UNISTD_H)
2245 #include <unistd.h>
2246 #endif
2247 #include <sys/types.h>
2248 main() { dev_t dev = makedev(1,2); return 0; }],
2249 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
2250 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
2251     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
2252 fi
2253
2254 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
2255 AC_TRY_RUN([#include <stdio.h>
2256 main() { char c; c=250; exit((c > 0)?0:1); }],
2257 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
2258 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
2259     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
2260 fi
2261
2262 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
2263 AC_TRY_COMPILE([#include <sys/types.h>
2264 #include <dirent.h>
2265 void seekdir(DIR *d, long loc) { return; }],[return 0;],
2266 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
2267 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
2268     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2269 fi
2270
2271 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2272 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2273 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2274 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2275     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2276 fi
2277
2278
2279 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
2280
2281     # On some systems (eg. Linux) librt can pull in libpthread. We
2282     # don't want this to happen because libpthreads changes signal delivery
2283     # semantics in ways we are not prepared for. This breaks Linux oplocks
2284     # which rely on signals.
2285
2286     AC_LIBTESTFUNC(rt, clock_gettime,
2287             [
2288                             AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
2289                                 [Whether clock_gettime is available])
2290                             SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
2291                             SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
2292                             SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
2293                         ])
2294
2295 fi
2296
2297 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2298 AC_TRY_RUN([#include <sys/types.h>
2299 #include <dirent.h>
2300 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2301 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2302 di->d_name[0] == 0) exit(0); exit(1);} ],
2303 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2304 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2305     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2306 fi
2307
2308 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2309 AC_TRY_COMPILE([#include <sys/types.h>
2310 #include <utime.h>],
2311 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
2312 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2313 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2314     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2315 fi
2316
2317 ##############
2318 # Check utmp details, but only if our OS offers utmp.h
2319 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2320 dnl  utmp and utmpx come in many flavours
2321 dnl  We need to check for many of them
2322 dnl  But we don't need to do each and every one, because our code uses
2323 dnl  mostly just the utmp (not utmpx) fields.
2324
2325 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx getutxent)
2326
2327 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2328 AC_TRY_COMPILE([#include <sys/types.h>
2329 #include <utmp.h>],
2330 [struct utmp ut;  ut.ut_name[0] = 'a';],
2331 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2332 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2333     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2334 fi
2335
2336 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2337 AC_TRY_COMPILE([#include <sys/types.h>
2338 #include <utmp.h>],
2339 [struct utmp ut;  ut.ut_user[0] = 'a';],
2340 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2341 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2342     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2343 fi
2344
2345 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2346 AC_TRY_COMPILE([#include <sys/types.h>
2347 #include <utmp.h>],
2348 [struct utmp ut;  ut.ut_id[0] = 'a';],
2349 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2350 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2351     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2352 fi
2353
2354 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2355 AC_TRY_COMPILE([#include <sys/types.h>
2356 #include <utmp.h>],
2357 [struct utmp ut;  ut.ut_host[0] = 'a';],
2358 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2359 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2360     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2361 fi
2362
2363 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2364 AC_TRY_COMPILE([#include <sys/types.h>
2365 #include <utmp.h>],
2366 [struct utmp ut;  time_t t; ut.ut_time = t;],
2367 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2368 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2369     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2370 fi
2371
2372 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2373 AC_TRY_COMPILE([#include <sys/types.h>
2374 #include <utmp.h>],
2375 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2376 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2377 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2378     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2379 fi
2380
2381 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2382 AC_TRY_COMPILE([#include <sys/types.h>
2383 #include <utmp.h>],
2384 [struct utmp ut;  ut.ut_type = 0;],
2385 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2386 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2387     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2388 fi
2389
2390 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2391 AC_TRY_COMPILE([#include <sys/types.h>
2392 #include <utmp.h>],
2393 [struct utmp ut;  ut.ut_pid = 0;],
2394 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2395 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2396     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2397 fi
2398
2399 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2400 AC_TRY_COMPILE([#include <sys/types.h>
2401 #include <utmp.h>],
2402 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2403 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2404 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2405     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2406 fi
2407
2408 dnl Look for the IPv6 varient by preference. Many systems have both.
2409 AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
2410 AC_TRY_COMPILE([#include <sys/types.h>
2411 #include <utmp.h>],
2412 [struct utmp ut;  ut.ut_addr_v6[0] = 0;],
2413 samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
2414 if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
2415     AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
2416 fi
2417
2418 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2419 AC_TRY_COMPILE([#include <sys/types.h>
2420 #include <utmp.h>],
2421 [struct utmp ut;  ut.ut_addr = 0;],
2422 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2423 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2424     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2425 fi
2426
2427 if test x$ac_cv_func_pututline = xyes ; then
2428   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2429   AC_TRY_COMPILE([#include <sys/types.h>
2430 #include <utmp.h>],
2431   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2432   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2433   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2434       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2435   fi
2436 fi
2437
2438 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2439 AC_TRY_COMPILE([#include <sys/types.h>
2440 #include <utmpx.h>],
2441 [struct utmpx ux;  ux.ut_syslen = 0;],
2442 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2443 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2444     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2445 fi
2446
2447 fi
2448 # end utmp details
2449
2450
2451 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
2452 AC_ARG_WITH(libiconv,
2453 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
2454 [
2455   if test "$withval" = "no" ; then
2456     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2457   else
2458      if test "$withval" != "yes" ; then
2459         ICONV_PATH_SPEC=yes
2460         ICONV_LOOK_DIRS="$withval"
2461      fi
2462   fi
2463 ])
2464
2465 for i in $ICONV_LOOK_DIRS ; do
2466
2467     save_LIBS="$LIBS"
2468     save_LDFLAGS="$LDFLAGS"
2469     save_CPPFLAGS="$CPPFLAGS"
2470
2471     iconv_current_LIBS=""
2472     iconv_current_LDFLAGS=""
2473     iconv_current_CPPFLAGS=""
2474
2475     ICONV_FOUND="no"
2476     unset libext
2477
2478     #  This is here to handle -withval stuff for --with-libiconv
2479     #  Perhaps we should always add a -L
2480     CPPFLAGS="$save_CPPFLAGS -I$i/include"
2481
2482     # Check lib and lib32 library variants to cater for IRIX ABI-specific
2483     # installation paths. This gets a little tricky since we might have iconv
2484     # in both libiconv and in libc. In this case the jm_ICONV test will always
2485     # succeed when the header is found. To counter this, make sure the
2486     # library directory is there and check the ABI directory first (which
2487     # should be harmless on other systems, but causes tons of linker warnings on
2488     # 64bit Ubuntu systems).
2489     # As the build farm doesn't seem to have any IRIX machines with iconv.h
2490     # installed, I've decided to fix the linker warnings.
2491     # -- Kai
2492     # For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2493     for l in "lib" "lib32" "lib/hpux32"; do
2494         if test -d "$i/$l" ; then
2495                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2496                 LIBS=
2497                 export LDFLAGS LIBS CPPFLAGS
2498                 # Try to find iconv(3)
2499                 jm_ICONV($i/$l)
2500                 if test x"$ICONV_FOUND" = "xyes" ; then
2501                     libext="$l"
2502                     break
2503                 fi
2504         fi
2505     done
2506
2507     if test x"$ICONV_FOUND" = "xyes" ; then
2508         iconv_current_LDFLAGS="-L$i/$libext"
2509         iconv_current_CPPFLAGS="-I$i/include"
2510
2511         if test x"$jm_cv_lib_iconv" != x; then
2512             iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv"
2513         else
2514             # We found iconv in libc.
2515             iconv_current_LIBS=""
2516         fi
2517
2518     fi
2519
2520     if test x"$ICONV_FOUND" = "xyes" ; then
2521
2522         LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS"
2523         CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS"
2524         LIBS="$save_LIBS $iconv_current_LIBS"
2525         export LDFLAGS LIBS CPPFLAGS
2526
2527         default_dos_charset=no
2528         default_display_charset=no
2529         default_unix_charset=no
2530
2531         # check for default dos charset name
2532         for j in CP850 IBM850 ; do
2533             rjs_CHARSET($j)
2534             default_dos_charset="$ICONV_CHARSET"
2535             if test x"$default_dos_charset" = x"$j"; then
2536                 break
2537             fi
2538         done
2539
2540         # check for default display charset name
2541         for j in ASCII 646 ; do
2542             rjs_CHARSET($j)
2543             default_display_charset="$ICONV_CHARSET"
2544             if test x"$default_display_charset" = x"$j"; then
2545                 break
2546             fi
2547         done
2548
2549         # check for default unix charset name
2550         for j in UTF-8 UTF8 ; do
2551             rjs_CHARSET($j)
2552             default_unix_charset="$ICONV_CHARSET"
2553             if test x"$default_unix_charset" = x"$j"; then
2554                 break
2555             fi
2556         done
2557
2558         if test "$default_dos_charset" != "no" -a \
2559                 "$default_dos_charset" != "cross" -a \
2560                 "$default_display_charset" != "no" -a \
2561                 "$default_display_charset" != "cross" -a \
2562                 "$default_unix_charset" != "no" -a \
2563                 "$default_unix_charset" != "cross"
2564         then
2565                 samba_cv_HAVE_NATIVE_ICONV=yes
2566         else
2567             if test "$default_dos_charset" = "cross" -o \
2568                      "$default_display_charset" = "cross" -o \
2569                      "$default_unix_charset" = "cross"
2570             then
2571                     samba_cv_HAVE_NATIVE_ICONV=cross
2572             else
2573                     samba_cv_HAVE_NATIVE_ICONV=no
2574             fi
2575         fi
2576
2577         # At this point, we have a libiconv candidate. We know that
2578         # we have the right headers and libraries, but we don't know
2579         # whether it does the conversions we want. We can't test this
2580         # because we are cross-compiling. This is not necessarily a big
2581         # deal, since we can't guarantee that the results we get now will
2582         # match the results we get at runtime anyway.
2583         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
2584             default_dos_charset="CP850"
2585             default_display_charset="ASCII"
2586             default_unix_charset="UTF-8"
2587             samba_cv_HAVE_NATIVE_ICONV=yes
2588             AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
2589             AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
2590         fi
2591
2592         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
2593
2594             CPPFLAGS=$save_CPPFLAGS
2595             LDFLAGS=$save_LDFLAGS
2596             LIBS=$save_LIBS
2597
2598             if test x"$iconv_current_LIBS" != x; then
2599                 LIBS="$LIBS $iconv_current_LIBS"
2600             fi
2601
2602             # Add the flags we need to CPPFLAGS and LDFLAGS
2603             CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS"
2604             LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS"
2605
2606             # Turn the #defines into string literals
2607             default_dos_charset="\"$default_dos_charset\""
2608             default_display_charset="\"$default_display_charset\""
2609             default_unix_charset="\"$default_unix_charset\""
2610
2611             AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2612             AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2613             AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2614             AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2615
2616            break
2617         fi
2618
2619     # We didn't find a working iconv, so keep going
2620     fi
2621
2622     #  We only need to clean these up here for the next pass through the loop
2623     CPPFLAGS=$save_CPPFLAGS
2624     LDFLAGS=$save_LDFLAGS
2625     LIBS=$save_LIBS
2626     export LDFLAGS LIBS CPPFLAGS
2627 done
2628 unset libext
2629
2630
2631 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2632     AC_MSG_WARN([Sufficient support for iconv function was not found.
2633     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2634    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2635    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2636    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2637 fi
2638
2639
2640 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2641 AC_TRY_RUN([
2642 #include <sys/types.h>
2643 #include <fcntl.h>
2644 #ifndef F_GETLEASE
2645 #define F_GETLEASE      1025
2646 #endif
2647 main() {
2648        int fd = open("/dev/null", O_RDONLY);
2649        return fcntl(fd, F_GETLEASE, 0) == -1;
2650 }
2651 ],
2652 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2653 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2654     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2655 fi
2656
2657 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2658 AC_TRY_RUN([
2659 #include <sys/types.h>
2660 #include <fcntl.h>
2661 #include <signal.h>
2662 #ifndef F_NOTIFY
2663 #define F_NOTIFY 1026
2664 #endif
2665 main() {
2666         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2667 }
2668 ],
2669 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2670 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2671     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2672 fi
2673
2674 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
2675 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h sys/inotify.h)
2676 AC_CHECK_FUNCS(inotify_init)
2677 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
2678 ],
2679 samba_cv_HAVE_INOTIFY=yes,
2680 samba_cv_HAVE_INOTIFY=no,
2681 samba_cv_HAVE_INOTIFY=cross)
2682
2683 if test x"$ac_cv_func_inotify_init" = x"yes" -a x"$ac_cv_header_linux_inotify_h" = x"yes"; then
2684     AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
2685 fi
2686
2687 #################################################
2688 # Check if FAM notifications are available. For FAM info, see
2689 #       http://oss.sgi.com/projects/fam/
2690 #       http://savannah.nongnu.org/projects/fam/
2691 AC_ARG_ENABLE(fam,
2692 [AS_HELP_STRING([--enable-fam], [Turn on FAM support (default=auto)])])
2693
2694 if test x$enable_fam != xno; then
2695     AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2696     if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2697         # On IRIX, libfam requires libC, but other FAM implementations
2698         # might not need it.
2699         AC_CHECK_LIB(fam, FAMOpen2,
2700             [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam";
2701             AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2702             [samba_cv_HAVE_LIBFAM=no])
2703
2704         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2705             samba_fam_xtra=-lC
2706             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2707                 [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC";
2708                 AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2709                 [samba_cv_HAVE_LIBFAM=no])
2710             unset samba_fam_xtra
2711         fi
2712     fi
2713     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2714         default_shared_modules="$default_shared_modules vfs_notify_fam"
2715         AC_TRY_COMPILE([#include <fam.h>],
2716                     [enum FAMCodes code = FAMChanged;],
2717                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2718                         [Whether fam.h contains a typedef for enum FAMCodes]),
2719                     [])
2720     fi
2721
2722     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2723         AC_CHECK_LIB(fam, FAMNoExists,
2724             [AC_DEFINE(HAVE_FAMNOEXISTS, 1, Define to 1 if there is support for FAMNoExists)])
2725     fi
2726
2727     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
2728         AC_MSG_ERROR(FAM support requested but FAM library not available )
2729     fi
2730 fi
2731
2732 AC_SUBST(SMB_FAM_LIBS)
2733
2734 #################################################
2735 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2736
2737
2738 with_dmapi_support=auto
2739 AC_MSG_CHECKING(whether to use DMAPI support)
2740 AC_ARG_WITH(dmapi,
2741 [AS_HELP_STRING([--with-dmapi], [Include DMAPI/XDSM support (default=auto)])],
2742 [ case "$withval" in
2743   yes|no)
2744     with_dmapi_support=$withval
2745     ;;
2746   esac ]
2747 )
2748 AC_MSG_RESULT([$with_dmapi_support])
2749
2750 if test x"$with_dmapi_support" != xno ; then
2751         SMB_CHECK_DMAPI([], [
2752                 AC_MSG_NOTICE(DMAPI support not present)
2753                 if test x"$with_dmapi_support" = xyes ; then
2754                         AC_MSG_ERROR(no DMAPI support found but requested!)
2755                 fi
2756                 ]
2757         )
2758 fi
2759
2760 # Add TSM SM VFS module only if there are both GPFS and DMAPI support
2761 # Theoretically it should work with AIX JFS2 too but this needs testing
2762 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes" && test x"$samba_dmapi_libs" != x"" ; then
2763     default_shared_modules="$default_shared_modules vfs_tsmsm"
2764 fi
2765
2766 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2767 AC_TRY_RUN([
2768 #include <sys/types.h>
2769 #include <fcntl.h>
2770 #include <signal.h>
2771 #include <sys/file.h>
2772 #ifndef LOCK_MAND
2773 #define LOCK_MAND       32
2774 #define LOCK_READ       64
2775 #endif
2776 main() {
2777         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2778 }
2779 ],
2780 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2781 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2782     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2783 fi
2784
2785
2786 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2787 AC_TRY_COMPILE([#include <sys/types.h>
2788 #include <fcntl.h>],
2789 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2790 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2791 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2792     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2793 fi
2794
2795 #################################################
2796 # Check for POSIX capability support
2797
2798 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2799     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2800     [], [])
2801
2802 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2803
2804     ac_save_LIBS=$LIBS
2805     AC_LIBTESTFUNC(cap, cap_get_proc)
2806
2807     AC_CACHE_CHECK([for POSIX capabilities],
2808             samba_cv_HAVE_POSIX_CAPABILITIES,
2809             [
2810                 AC_TRY_RUN([
2811 #include <sys/types.h>
2812 #include <sys/capability.h>
2813 main() {
2814  cap_t cap;
2815  cap_value_t vals[1];
2816  if (!(cap = cap_get_proc()))
2817    exit(1);
2818  vals[0] = CAP_CHOWN;
2819  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2820  cap_set_proc(cap);
2821  exit(0);
2822 }],
2823                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2824                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2825                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2826             ])
2827
2828 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2829     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2830             [Whether POSIX capabilities are available])
2831 else
2832     LIBS=$ac_save_LIBS
2833 fi
2834
2835 fi
2836
2837 #
2838 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2839 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2840 #
2841
2842 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2843 AC_TRY_COMPILE([#include <sys/types.h>
2844 #if defined(HAVE_RPC_RPC_H)
2845 #include <rpc/rpc.h>
2846 #endif],
2847 [int16 testvar;],
2848 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2849 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2850     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2851 fi
2852
2853 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2854 AC_TRY_COMPILE([#include <sys/types.h>
2855 #if defined(HAVE_RPC_RPC_H)
2856 #include <rpc/rpc.h>
2857 #endif],
2858 [uint16 testvar;],
2859 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2860 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2861     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2862 fi
2863
2864 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2865 AC_TRY_COMPILE([#include <sys/types.h>
2866 #if defined(HAVE_RPC_RPC_H)
2867 #include <rpc/rpc.h>
2868 #endif],
2869 [int32 testvar;],
2870 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2871 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2872     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2873 fi
2874
2875 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2876 AC_TRY_COMPILE([#include <sys/types.h>
2877 #if defined(HAVE_RPC_RPC_H)
2878 #include <rpc/rpc.h>
2879 #endif],
2880 [uint32 testvar;],
2881 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2882 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2883     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2884 fi
2885
2886 dnl
2887 dnl Some systems (SCO) have a problem including
2888 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2889 dnl as a #define in <prot.h> and as part of an enum
2890 dnl in <rpc/rpc.h>.
2891 dnl
2892
2893 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2894 AC_TRY_COMPILE([#include <sys/types.h>
2895 #ifdef HAVE_SYS_SECURITY_H
2896 #include <sys/security.h>
2897 #include <prot.h>
2898 #endif  /* HAVE_SYS_SECURITY_H */
2899 #if defined(HAVE_RPC_RPC_H)
2900 #include <rpc/rpc.h>
2901 #endif],
2902 [int testvar;],
2903 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2904 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2905     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2906 fi
2907
2908 AC_MSG_CHECKING([for test routines])
2909 AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
2910            AC_MSG_RESULT(yes),
2911            AC_MSG_ERROR([cant find test code. Aborting config]),
2912            AC_MSG_WARN([cannot run when cross-compiling]))
2913
2914 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2915 AC_TRY_RUN([#include "${srcdir-.}/../tests/ftruncate.c"],
2916            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2917 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2918     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2919 fi
2920
2921 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2922 AC_TRY_RUN([#include "${srcdir-.}/../tests/getgroups.c"],
2923            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2924 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2925     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2926 fi
2927
2928 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
2929 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
2930 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
2931 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
2932 AC_CHECK_FUNCS(getpagesize)
2933
2934 ################################################
2935 # look for a method of setting the effective uid
2936 seteuid=no;
2937
2938 if test $seteuid = no; then
2939 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2940 AC_TRY_RUN([
2941 #define AUTOCONF_TEST 1
2942 #define USE_SETREUID 1
2943 #include "confdefs.h"
2944 #include "${srcdir-.}/lib/util_sec.c"],
2945            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2946 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2947     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2948 fi
2949 fi
2950
2951 # we check for setresuid second as it conflicts with AIO on Linux. 
2952 # see http://samba.org/~tridge/junkcode/aio_uid.c
2953 if test $seteuid = no; then
2954 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2955 AC_TRY_RUN([
2956 #define AUTOCONF_TEST 1
2957 #define USE_SETRESUID 1
2958 #include "confdefs.h"
2959 #include "${srcdir-.}/lib/util_sec.c"],
2960            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2961 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2962     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2963 fi
2964 fi
2965
2966 if test $seteuid = no; then
2967 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2968 AC_TRY_RUN([
2969 #define AUTOCONF_TEST 1
2970 #define USE_SETEUID 1
2971 #include "confdefs.h"
2972 #include "${srcdir-.}/lib/util_sec.c"],
2973            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2974 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2975     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2976 fi
2977 fi
2978
2979 if test $seteuid = no; then
2980 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2981 AC_TRY_RUN([
2982 #define AUTOCONF_TEST 1
2983 #define USE_SETUIDX 1
2984 #include "confdefs.h"
2985 #include "${srcdir-.}/lib/util_sec.c"],
2986            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2987 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2988     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2989 fi
2990 fi
2991
2992 AC_CACHE_CHECK([for the Darwin initgroups system call],
2993         samba_cv_DARWIN_INITGROUPS,
2994         AC_TRY_LINK([
2995 #include <sys/syscall.h>
2996 #include <unistd.h>
2997         ],
2998         [ syscall(SYS_initgroups, 16, NULL, NULL, 0); ],
2999         samba_cv_DARWIN_INITGROUPS=yes,
3000         samba_cv_DARWIN_INITGROUPS=no)
3001 )
3002
3003 if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
3004     AC_DEFINE(HAVE_DARWIN_INITGROUPS, 1,
3005         [Whether to use the Darwin-specific initgroups system call])
3006 fi
3007
3008 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
3009 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock.c"],
3010            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
3011 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
3012     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
3013 fi
3014
3015 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
3016 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock64.c"],
3017            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
3018 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
3019     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
3020
3021 else
3022
3023 dnl
3024 dnl Don't check for 64 bit fcntl locking if we know that the
3025 dnl glibc2.1 broken check has succeeded.
3026 dnl
3027
3028   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
3029   AC_TRY_RUN([
3030 #if defined(HAVE_UNISTD_H)
3031 #include <unistd.h>
3032 #endif
3033 #include <stdio.h>
3034 #include <stdlib.h>
3035
3036 #ifdef HAVE_FCNTL_H
3037 #include <fcntl.h>
3038 #endif
3039
3040 #ifdef HAVE_SYS_FCNTL_H
3041 #include <sys/fcntl.h>
3042 #endif
3043 main() { struct flock64 fl64;
3044 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
3045 exit(0);
3046 #else
3047 exit(1);
3048 #endif
3049 }],
3050        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
3051
3052   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
3053       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
3054   fi
3055 fi
3056
3057 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
3058 AC_CACHE_CHECK([for broken posix_fallocate],samba_cv_HAVE_BROKEN_POSIX_FALLOCATE,[
3059 AC_TRY_COMPILE([
3060   #define _XOPEN_SOURCE 600
3061   #include <stdlib.h>
3062   #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
3063     probably broken posix_fallocate
3064   #endif
3065 ], [
3066 ], 
3067 samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=no,samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=yes)])
3068 if test x"$samba_cv_HAVE_BROKEN_POSIX_FALLOCATE" = xyes; then
3069         AC_DEFINE(HAVE_BROKEN_POSIX_FALLOCATE,, Whether we have a broken posix_fallocate)
3070 fi
3071
3072
3073 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
3074 AC_TRY_COMPILE([#include <sys/types.h>
3075 #include <sys/stat.h>
3076 #include <unistd.h>],
3077 [struct stat st;  st.st_blocks = 0;],
3078 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
3079 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
3080     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
3081 fi
3082
3083 AC_CHECK_TYPES([blksize_t, blkcnt_t], [], [], [[#include <sys/stat.h>]])
3084
3085 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
3086 AC_TRY_COMPILE([#include <sys/types.h>
3087 #include <sys/stat.h>
3088 #include <unistd.h>],
3089 [struct stat st;  st.st_blksize = 0;],
3090 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
3091 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
3092     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
3093 fi
3094
3095 AC_CACHE_CHECK([for st_flags in struct stat],
3096         samba_cv_HAVE_STAT_ST_FLAGS,
3097         [
3098             AC_TRY_COMPILE([#include <sys/types.h>
3099 #include <sys/stat.h>
3100 #include <unistd.h>],
3101             [struct stat st;  st.st_flags = 0;],
3102             samba_cv_HAVE_STAT_ST_FLAGS=yes,
3103             samba_cv_HAVE_STAT_ST_FLAGS=no,
3104             samba_cv_HAVE_STAT_ST_FLAGS=cross)
3105         ])
3106
3107 if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
3108     AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
3109                 [Whether the stat struct has a st_flags member])
3110 fi
3111
3112 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
3113 AC_TRY_COMPILE([
3114 #include <sys/types.h>
3115 #include <sys/acl.h>
3116 #if defined(HAVE_RPCSVC_NIS_H)
3117 #include <rpcsvc/nis.h>
3118 #endif],
3119 [int i;],
3120 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
3121 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
3122         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
3123 fi
3124
3125 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
3126 AC_TRY_RUN([
3127 #include <stdio.h>
3128 #include <limits.h>
3129 #include <signal.h>
3130
3131 void exit_on_core(int ignored) {
3132         exit(1);
3133 }
3134
3135 main() {
3136         char *newpath;
3137         signal(SIGSEGV, exit_on_core);
3138         newpath = realpath("/tmp", NULL);
3139         exit((newpath != NULL) ? 0 : 1);
3140 }
3141 ],
3142 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
3143 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
3144     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
3145 fi
3146
3147 #################################################
3148 # check for AFS clear-text auth support
3149 samba_cv_WITH_AFS=no
3150 AC_MSG_CHECKING(whether to use AFS clear-text auth)
3151 AC_ARG_WITH(afs,
3152 [AS_HELP_STRING([--with-afs], [Include AFS clear-text auth support (default=no)])],
3153 [ case "$withval" in
3154   yes|auto)
3155     AC_MSG_RESULT($withval)
3156     samba_cv_WITH_AFS=$withval
3157     ;;
3158   *)
3159     AC_MSG_RESULT(no)
3160     ;;
3161   esac ],
3162   AC_MSG_RESULT(no)
3163 )
3164
3165 ####################################################
3166 # check for Linux-specific AFS fake-kaserver support
3167 samba_cv_WITH_FAKE_KASERVER=no
3168 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3169 AC_ARG_WITH(fake-kaserver,
3170 [AS_HELP_STRING([--with-fake-kaserver], [Include AFS fake-kaserver support (default=no)])],
3171 [ case "$withval" in
3172   yes|auto)
3173     AC_MSG_RESULT($withval)
3174     samba_cv_WITH_FAKE_KASERVER=$withval
3175     ;;
3176   *)
3177     AC_MSG_RESULT(no)
3178     ;;
3179   esac ],
3180   AC_MSG_RESULT(no)
3181 )
3182
3183 #################################################
3184 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
3185 if test x"$samba_cv_WITH_AFS" != x"no" ||
3186    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
3187
3188     # see if this box has the OpenSSL DES libraries
3189     AC_CHECK_LIB( crypto, DES_pcbc_encrypt, LIBS="$LIBS -lcrypto" , [AC_ERROR(OpenSSL library: libcrypto ot found!)] )
3190
3191     # see if this box has the afs-headers in /usr/include/afs
3192     AC_MSG_CHECKING(for /usr/include/afs)
3193     if test -d /usr/include/afs; then
3194           AC_MSG_RESULT(yes)
3195     else
3196       AC_MSG_RESULT(no)
3197     fi
3198
3199     # check for afs.h
3200     have_afs_headers=no
3201     AC_CHECK_HEADERS(afs.h afs/afs.h)
3202     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
3203         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
3204            test x"$samba_cv_WITH_AFS" = x"auto"; then
3205                 AC_MSG_WARN([AFS cannot be supported without afs.h])
3206         else
3207                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
3208         fi
3209     else
3210         have_afs_headers=yes
3211     fi
3212 fi
3213
3214 FAKE_KASERVER_OBJ=""
3215 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
3216     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
3217     FAKE_KASERVER_OBJ="utils/net_afs.o"
3218 fi
3219 AC_SUBST(FAKE_KASERVER_OBJ)
3220
3221 #################################################
3222 # check whether to compile AFS/NT ACL mapping module
3223 samba_cv_WITH_VFS_AFSACL=no
3224 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
3225 AC_ARG_WITH(vfs-afsacl,
3226 [AS_HELP_STRING([--with-vfs-afsacl], [Include AFS to NT ACL mapping module (default=no)])],
3227 [ case "$withval" in
3228   yes|auto)
3229     AC_MSG_RESULT($withval)
3230     samba_cv_WITH_VFS_AFSACL=yes
3231     ;;
3232   *)
3233     AC_MSG_RESULT(no)
3234     ;;
3235   esac ],
3236   AC_MSG_RESULT(no)
3237 )
3238
3239 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
3240    default_shared_modules="$default_shared_modules vfs_afsacl"
3241 fi
3242         
3243 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
3244     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
3245 fi
3246
3247 #################################################
3248 # check for the DFS clear-text auth system
3249 AC_MSG_CHECKING(whether to use DFS clear-text auth)
3250 AC_ARG_WITH(dfs,
3251 [AS_HELP_STRING([--with-dce-dfs], [Include DCE/DFS clear-text auth support (default=no)])],
3252 [ case "$withval" in
3253   yes)
3254     AC_MSG_RESULT(yes)
3255     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
3256     ;;
3257   *)
3258     AC_MSG_RESULT(no)
3259     ;;
3260   esac ],
3261   AC_MSG_RESULT(no)
3262 )
3263
3264 ########################################################
3265 # Compile with LDAP support?
3266
3267 with_ldap_support=auto
3268 AC_MSG_CHECKING([for LDAP support])
3269
3270 AC_ARG_WITH(ldap,
3271 [AS_HELP_STRING([--with-ldap], [LDAP support (default=auto)])],
3272 [ case "$withval" in
3273     yes|no)
3274         with_ldap_support=$withval
3275         ;;
3276   esac ])
3277
3278 AC_MSG_RESULT($with_ldap_support)
3279
3280 SMBLDAP=""
3281 AC_SUBST(SMBLDAP)
3282 SMBLDAPUTIL=""
3283 AC_SUBST(SMBLDAPUTIL)
3284
3285 if test x"$with_ldap_support" != x"no"; then
3286
3287   ##################################################################
3288   # first test for ldap.h and lber.h
3289   # (ldap.h is required for this test)
3290   AC_CHECK_HEADERS(ldap.h lber.h)
3291
3292   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3293         if test x"$with_ldap_support" = x"yes"; then
3294          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3295         else
3296          AC_MSG_WARN(ldap.h is needed for LDAP support)
3297         fi
3298         
3299         with_ldap_support=no
3300   fi
3301
3302   ##################################################################
3303   # HP/UX does not have ber_tag_t in lber.h - it must be configured as
3304   # unsigned int in include/includes.h
3305   case $host_os in
3306         *hpux*)
3307          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3308          AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
3309         with_ldap_support=yes
3310         ;;
3311         *)
3312         AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
3313         if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
3314                 if test x"$with_ldap_support" = x"yes"; then
3315                 AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
3316                 else
3317                 AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3318                 fi
3319                 with_ldap_support=no
3320         fi
3321         ;;
3322   esac
3323 fi
3324
3325 if test x"$with_ldap_support" != x"no"; then
3326   ac_save_LIBS=$LIBS
3327
3328   ##################################################################
3329   # we might need the lber lib on some systems. To avoid link errors
3330   # this test must be before the libldap test
3331   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3332
3333   ########################################################
3334   # If ber_sockbuf_add_io() is available we can add
3335   # SASL wrapping hooks
3336   AC_CHECK_FUNC_EXT(ber_sockbuf_add_io,$LDAP_LIBS)
3337
3338   AC_CACHE_CHECK([for LDAP_OPT_SOCKBUF],samba_cv_HAVE_LDAP_OPT_SOCKBUF,[
3339                  AC_TRY_COMPILE([#include <ldap.h>],
3340                                 [int val = LDAP_OPT_SOCKBUF;],
3341                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=yes,
3342                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=no)])
3343
3344   if test x"$ac_cv_func_ext_ber_sockbuf_add_io" = x"yes" -a \
3345           x"$samba_cv_HAVE_LDAP_OPT_SOCKBUF" = x"yes"; then
3346         AC_DEFINE(HAVE_LDAP_SASL_WRAPPING, 1, [Support for SASL wrapping])
3347   fi
3348
3349   #######################################################
3350   # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
3351   # ldap logging and print it out in the samba logs
3352   AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
3353                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
3354                  [AC_TRY_COMPILE([#include <lber.h>],
3355                                  [int val = LBER_OPT_LOG_PRINT_FN;],
3356                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
3357                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
3358
3359   if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
3360         AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
3361                   [Support for LDAP/LBER logging interception])
3362   fi
3363
3364   ########################################################
3365   # now see if we can find the ldap libs in standard paths
3366   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3367
3368   ########################################################
3369   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3370   # Check found in pam_ldap 145.
3371   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3372
3373   LIBS="$LIBS $LDAP_LIBS"
3374   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3375     AC_TRY_COMPILE([
3376         #include <lber.h>
3377         #include <ldap.h>],
3378         [ldap_set_rebind_proc(0, 0, 0);],
3379         [smb_ldap_cv_ldap_set_rebind_proc=3],
3380         [smb_ldap_cv_ldap_set_rebind_proc=2]
3381     )
3382   ])
3383
3384   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3385
3386   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3387
3388   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3389     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3390     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3391     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3392     default_shared_modules="$default_shared_modules";
3393     SMBLDAP="lib/smbldap.o"
3394     SMBLDAPUTIL="lib/smbldap_util.o"
3395     with_ldap_support=yes
3396     AC_MSG_CHECKING(whether LDAP support is used)
3397     AC_MSG_RESULT(yes)
3398   else
3399     if test x"$with_ldap_support" = x"yes"; then
3400         AC_MSG_ERROR(libldap is needed for LDAP support)
3401     else
3402         AC_MSG_WARN(libldap is needed for LDAP support)
3403     fi
3404
3405     LDAP_LIBS=""
3406     with_ldap_support=no
3407   fi
3408   LIBS=$ac_save_LIBS
3409 fi
3410
3411
3412 #################################################
3413 # active directory support
3414
3415 with_ads_support=auto
3416 AC_MSG_CHECKING([for Active Directory and krb5 support])
3417
3418 AC_ARG_WITH(ads,
3419 [AS_HELP_STRING([--with-ads], [Active Directory support (default=auto)])],
3420 [ case "$withval" in
3421     yes|no)
3422         with_ads_support="$withval"
3423         ;;
3424   esac ])
3425
3426 AC_MSG_RESULT($with_ads_support)
3427
3428 FOUND_KRB5=no
3429 KRB5_LIBS=""
3430
3431 if test x"$with_ldap_support" != x"yes"; then
3432
3433     if test x"$with_ads_support" = x"yes"; then
3434         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3435     elif test x"$with_ads_support" = x"auto"; then
3436         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3437         with_ads_support=no
3438     fi
3439
3440 else
3441
3442     # Check to see whether there is enough LDAP functionality to be able
3443     # to build AD support.
3444
3445 # HPUX only has ldap_init; ok, we take care of this in smbldap.c
3446 case "$host_os" in
3447         *hpux*)
3448     AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
3449
3450     if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
3451         if test x"$with_ads_support" = x"yes"; then
3452             AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
3453         elif test x"$with_ads_support" = x"auto"; then
3454             AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
3455             with_ads_support=no
3456         fi
3457     fi
3458     ;;
3459         *)
3460     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3461
3462     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3463         if test x"$with_ads_support" = x"yes"; then
3464             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3465         elif test x"$with_ads_support" = x"auto"; then
3466             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3467             with_ads_support=no
3468         fi
3469     fi
3470     ;;
3471 esac
3472
3473
3474     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3475
3476     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3477         if test x"$with_ads_support" = x"yes"; then
3478             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3479         elif test x"$with_ads_support" = x"auto"; then
3480             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3481             with_ads_support=no
3482         fi
3483     fi
3484
3485 fi
3486
3487 if test x"$with_ads_support" != x"no"; then
3488
3489   # Do no harm to the values of CFLAGS and LIBS while testing for
3490   # Kerberos support.
3491
3492   if test x$FOUND_KRB5 = x"no"; then
3493     #################################################
3494     # check for location of Kerberos 5 install
3495     AC_MSG_CHECKING(for kerberos 5 install path)
3496     AC_ARG_WITH(krb5,
3497     [AS_HELP_STRING([--with-krb5=base-dir], [Locate Kerberos 5 support (default=/usr)])],
3498     [ case "$withval" in
3499       no)
3500         AC_MSG_RESULT(no krb5-path given)
3501         ;;
3502       yes)
3503         AC_MSG_RESULT(/usr)
3504         FOUND_KRB5=yes
3505         ;;
3506       *)
3507         AC_MSG_RESULT($withval)
3508         KRB5_CFLAGS="-I$withval/include"
3509         KRB5_CPPFLAGS="-I$withval/include"
3510         KRB5_LDFLAGS="-L$withval/lib"
3511         FOUND_KRB5=yes
3512         if test -x "$withval/bin/krb5-config"; then
3513                 KRB5CONFIG=$withval/bin/krb5-config
3514         fi
3515         ;;
3516       esac ],
3517       AC_MSG_RESULT(no krb5-path given)
3518     )
3519   fi
3520
3521   #################################################
3522   # check for krb5-config from recent MIT and Heimdal kerberos 5
3523   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3524   AC_MSG_CHECKING(for working krb5-config)
3525   if test -x "$KRB5CONFIG" && $KRB5CONFIG --libs gssapi > /dev/null ; then
3526     ac_save_CFLAGS=$CFLAGS
3527     CFLAGS="";export CFLAGS
3528     ac_save_LDFLAGS=$LDFLAGS
3529     LDFLAGS="";export LDFLAGS
3530     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3531     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3532     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3533     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3534     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3535     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3536     FOUND_KRB5=yes
3537     AC_MSG_RESULT(yes)
3538   else
3539     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3540   fi
3541
3542   if test x$FOUND_KRB5 = x"no"; then
3543     #################################################
3544     # see if this box has the SuSE location for the heimdal krb implementation
3545     AC_MSG_CHECKING(for /usr/include/heimdal)
3546     if test -d /usr/include/heimdal; then
3547       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3548           KRB5_CFLAGS="-I/usr/include/heimdal"
3549           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3550           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3551           FOUND_KRB5=yes
3552           AC_MSG_RESULT(yes)
3553       else
3554           KRB5_CFLAGS="-I/usr/include/heimdal"
3555           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3556           FOUND_KRB5=yes
3557           AC_MSG_RESULT(yes)
3558       fi
3559     else
3560       AC_MSG_RESULT(no)
3561     fi
3562   fi
3563
3564   if test x$FOUND_KRB5 = x"no"; then
3565     #################################################
3566     # see if this box has the RedHat location for kerberos
3567     AC_MSG_CHECKING(for /usr/kerberos)
3568     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3569       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3570       KRB5_CFLAGS="-I/usr/kerberos/include"
3571       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3572       FOUND_KRB5=yes
3573       AC_MSG_RESULT(yes)
3574     else
3575       AC_MSG_RESULT(no)
3576     fi
3577   fi
3578
3579   if test x$FOUND_KRB5 = x"no"; then
3580     #################################################
3581     # see if this box has the OpenBSD location for heimdal krb5
3582     AC_MSG_CHECKING(for /usr/include/kerberosV)
3583     if test -d /usr/include/kerberosV; then
3584       KRB5_CPPFLAGS="-I/usr/include/kerberosV"
3585       KRB5_LIBS="-lcrypto"
3586       FOUND_KRB5=yes
3587       AC_MSG_RESULT(yes)
3588     else
3589       AC_MSG_RESULT(no)
3590     fi
3591   fi
3592
3593   ac_save_CFLAGS=$CFLAGS
3594   ac_save_CPPFLAGS=$CPPFLAGS
3595   ac_save_LDFLAGS=$LDFLAGS
3596
3597   # remove needless evil rpath stuff as early as possible:
3598   LIB_REMOVE_USR_LIB(KRB5_LIBS)
3599   LIB_REMOVE_USR_LIB(KRB5_LDFLAGS)
3600   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3601   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3602   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3603
3604   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3605
3606   # now check for krb5.h. Some systems have the libraries without the headers!
3607   # note that this check is done here to allow for different kerberos
3608   # include paths
3609   AC_CHECK_HEADERS(krb5.h)
3610
3611   if test x"$ac_cv_header_krb5_h" = x"no"; then
3612
3613     # Give a warning if AD support was not explicitly requested,
3614     # i.e with_ads_support = auto, otherwise die with an error.
3615
3616     if test x"$with_ads_support" = x"yes"; then
3617       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3618     else
3619       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3620     fi
3621
3622     # Turn off AD support and restore CFLAGS and LIBS variables
3623
3624     with_ads_support="no"
3625
3626     CFLAGS=$ac_save_CFLAGS
3627     CPPFLAGS=$ac_save_CPPFLAGS
3628     LDFLAGS=$ac_save_LDFLAGS
3629   fi
3630   AC_CHECK_HEADERS([krb5/locate_plugin.h], [], [],
3631 [[#ifdef HAVE_KRB5_H
3632  #include <krb5.h>
3633  #endif
3634 ]])
3635
3636   if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
3637         WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
3638         if test x"$BLDSHARED" = x"true" ; then
3639                 EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
3640         fi
3641   fi
3642
3643   # check for new heimdal KRB5_DEPRECATED handling
3644
3645   AC_CACHE_CHECK([for KRB5_DEPRECATED define taking an identifier],
3646                 samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER,[
3647     AC_TRY_COMPILE(
3648       [#define KRB5_DEPRECATED 1
3649       #include <krb5.h>],
3650       [],
3651       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=yes,
3652       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=no)])
3653
3654   if test x"$samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER" = x"yes"; then
3655     AC_DEFINE(HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER, 1,
3656                [Whether to use deprecated krb5 interfaces])
3657   fi
3658 fi
3659
3660 # Now we have determined whether we really want ADS support
3661 use_ads=no
3662 if test x"$with_ads_support" != x"no"; then
3663   use_ads=yes
3664   have_gssapi=no
3665   ac_save_LIBS=$LIBS
3666
3667   # now check for gssapi headers.  This is also done here to allow for
3668   # different kerberos include paths
3669   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
3670
3671   ##################################################################
3672   # we might need the k5crypto and com_err libraries on some systems
3673   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3674   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3675
3676   # Heimdal checks.
3677   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3678   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3679   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3680
3681   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3682   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],have_gssapi=yes)
3683
3684   ########################################################
3685   # now see if we can find the krb5 libs in standard paths
3686   # or as specified above
3687   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3688   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3689
3690   ########################################################
3691   # now see if we can find the gssapi libs in standard paths
3692   if test x"$have_gssapi" != x"yes"; then
3693      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
3694   fi
3695
3696   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3697   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3698   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_enctypes, $KRB5_LIBS)
3699   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3700   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3701   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3702   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
3703   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3704   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
3705   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3706   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
3707   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3708   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
3709   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
3710   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3711   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3712   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3713   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3714   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3715   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
3716   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3717   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3718   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3719   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3720   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3721   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3722   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3723   AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
3724   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3725   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3726   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3727   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3728   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3729   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3730   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3731   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3732   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
3733   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
3734   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
3735   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
3736   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
3737   AC_CHECK_FUNC_EXT(krb5_fwd_tgt_creds, $KRB5_LIBS)
3738   AC_CHECK_FUNC_EXT(krb5_auth_con_set_req_cksumtype, $KRB5_LIBS)
3739   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_alloc, $KRB5_LIBS)
3740   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_set_impersonate, $KRB5_LIBS)
3741   AC_CHECK_FUNC_EXT(krb5_get_creds, $KRB5_LIBS)