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