]> arthur.barton.de Git - netatalk.git/blob - macros/netatalk.m4
small fix of configure summary
[netatalk.git] / macros / netatalk.m4
1 dnl Kitchen sink for configuration macros
2
3 dnl Whether to enable developer build
4 AC_DEFUN([AC_DEVELOPER], [
5     AC_MSG_CHECKING([whether to enable developer build])
6     AC_ARG_ENABLE(
7         developer,
8         AS_HELP_STRING([--enable-developer], [whether to enable developer build (ABI checking)]),
9         enable_dev=$enableval,
10         enable_dev=no
11     )
12     AC_MSG_RESULT([$enable_dev])
13     AM_CONDITIONAL(DEVELOPER, test x"$enable_dev" = x"yes")
14 ])
15
16 dnl Whether to disable bundled libevent
17 AC_DEFUN([AC_NETATALK_LIBEVENT], [
18     AC_MSG_CHECKING([whether to disable bundled libevent (define CPPFLAGS and LDFLAGS otherwise appropiately to pick up installed version)])
19     AC_ARG_ENABLE(
20         bundled-libevent,
21         [AS_HELP_STRING([--disable-bundled-libevent],[whether the bundled version of libevent shall not be used (define CPPFLAGS and LDFLAGS otherwise appropiately to pick up installed version)
22         ])],
23         use_bundled_libevent=$enableval,
24         use_bundled_libevent=yes
25     )
26
27     if test x"$use_bundled_libevent" = x"yes" ; then
28         AC_CONFIG_SUBDIRS([libevent])
29     fi
30     AM_CONDITIONAL(USE_BUILTIN_LIBEVENT, test x"$use_bundled_libevent" = x"yes")
31 ])
32
33 dnl Filesystem Hierarchy Standard (FHS) compatibility
34 AC_DEFUN([AC_NETATALK_FHS], [
35 AC_MSG_CHECKING([whether to use Filesystem Hierarchy Standard (FHS) compatibility])
36 AC_ARG_ENABLE(fhs,
37         [  --enable-fhs            use Filesystem Hierarchy Standard (FHS) compatibility],[
38         if test "$enableval" = "yes"; then
39                 bindir="/bin"
40                 sbindir="/sbin"
41                 sysconfdir="/etc"
42                 libdir="/lib"
43                 localstatedir="/var"
44                 mandir="/usr/share/man"
45                 uams_path="${libdir}/netatalk"
46                 PKGCONFDIR="${sysconfdir}"
47                 SERVERTEXT="${localstatedir}/netatalk/msg"
48                 use_pam_so=yes
49                 AC_DEFINE(FHS_COMPATIBILITY, 1, [Define if you want compatibily with the FHS])
50                 AC_MSG_RESULT([yes])
51         else
52                 AC_MSG_RESULT([no])
53         fi
54         ],[
55                 AC_MSG_RESULT([no])
56         ]
57 )])
58
59 dnl 64bit platform check
60 AC_DEFUN([AC_NETATALK_64BIT_LIBS], [
61 AC_MSG_CHECKING([whether to check for 64bit libraries])
62 # Test if the compiler is in 64bit mode
63 echo 'int i;' > conftest.$ac_ext
64 atalk_cv_cc_64bit_output=no
65 if AC_TRY_EVAL(ac_compile); then
66     case `/usr/bin/file conftest.$ac_objext` in
67     *"ELF 64"*)
68       atalk_cv_cc_64bit_output=yes
69       ;;
70     esac
71 fi
72 rm -rf conftest*
73
74 case $host_cpu:$atalk_cv_cc_64bit_output in
75 powerpc64:yes | s390x:yes | sparc*:yes | x86_64:yes | i386:yes)
76     case $target_os in
77     solaris2*)
78         AC_MSG_RESULT([yes])
79         atalk_libname="lib/64"
80         ;;
81     *bsd* | dragonfly*)
82         AC_MSG_RESULT([no])
83         atalk_libname="lib"
84         ;;
85     *)
86         AC_MSG_RESULT([yes])
87         atalk_libname="lib64"
88         ;;
89     esac
90     ;;
91 *:*)
92     AC_MSG_RESULT([no])
93     atalk_libname="lib"
94     ;;
95 esac
96 ])
97
98 dnl Check for optional admin group support
99 AC_DEFUN([AC_NETATALK_ADMIN_GROUP], [
100     netatalk_cv_admin_group=yes
101     AC_MSG_CHECKING([for administrative group support])
102     AC_ARG_ENABLE(admin-group,
103             [  --disable-admin-group   disable admin group],[
104             if test x"$enableval" = x"no"; then
105                          AC_DEFINE(ADMIN_GRP, 0, [Define if the admin group should be enabled])
106                          netatalk_cv_admin_group=no
107                          AC_MSG_RESULT([no])
108                 else
109                          AC_DEFINE(ADMIN_GRP, 1, [Define if the admin group should be enabled])
110                          AC_MSG_RESULT([yes])
111             fi],[
112                 AC_DEFINE(ADMIN_GRP, 1, [Define if the admin group should be enabled])
113                 AC_MSG_RESULT([yes])
114         ])
115 ])
116
117 dnl Check for optional cracklib support
118 AC_DEFUN([AC_NETATALK_CRACKLIB], [
119 netatalk_cv_with_cracklib=no
120 AC_ARG_WITH(cracklib,
121         [  --with-cracklib[[=DICT]]  enable/set location of cracklib dictionary [[no]]],[
122         if test "x$withval" != "xno" ; then
123                 cracklib="$withval"
124                 AC_CHECK_LIB(crack, main, [
125                         AC_DEFINE(USE_CRACKLIB, 1, [Define if cracklib should be used])
126                         LIBS="$LIBS -lcrack"
127                         if test "$cracklib" = "yes"; then
128                                 cracklib="/usr/$atalk_libname/cracklib_dict"
129                         fi
130                         AC_DEFINE_UNQUOTED(_PATH_CRACKLIB, "$cracklib",
131                                 [path to cracklib dictionary])
132                         AC_MSG_RESULT([setting cracklib dictionary to $cracklib])
133                         netatalk_cv_with_cracklib=yes
134                         ],[
135                         AC_MSG_ERROR([cracklib not found!])
136                         ]
137                 )
138         fi
139         ]
140 )
141 AC_MSG_CHECKING([for cracklib support])
142 AC_MSG_RESULT([$netatalk_cv_with_cracklib])
143 ])
144
145 dnl Check whether to enable debug code
146 AC_DEFUN([AC_NETATALK_DEBUG], [
147 AC_MSG_CHECKING([whether to enable verbose debug code])
148 AC_ARG_ENABLE(debug,
149         [  --enable-debug          enable verbose debug code],[
150         if test "$enableval" != "no"; then
151                 if test "$enableval" = "yes"; then
152                         AC_DEFINE(DEBUG, 1, [Define if verbose debugging information should be included])
153                 else
154                         AC_DEFINE_UNQUOTED(DEBUG, $enableval, [Define if verbose debugging information should be included])
155                 fi 
156                 AC_MSG_RESULT([yes])
157         else
158                 AC_MSG_RESULT([no])
159         AC_DEFINE(NDEBUG, 1, [Disable assertions])
160         fi
161         ],[
162                 AC_MSG_RESULT([no])
163         AC_DEFINE(NDEBUG, 1, [Disable assertions])
164         ]
165 )
166 ])
167
168 dnl Check whethe to disable tickle SIGALARM stuff, which eases debugging
169 AC_DEFUN([AC_NETATALK_DEBUGGING], [
170 AC_MSG_CHECKING([whether to enable debugging with debuggers])
171 AC_ARG_ENABLE(debugging,
172         [  --enable-debugging      disable SIGALRM timers and DSI tickles (eg for debugging with gdb/dbx/...)],[
173         if test "$enableval" != "no"; then
174                 if test "$enableval" = "yes"; then
175                         AC_DEFINE(DEBUGGING, 1, [Define if you want to disable SIGALRM timers and DSI tickles])
176                 else
177                         AC_DEFINE_UNQUOTED(DEBUGGING, $enableval, [Define if you want to disable SIGALRM timers and DSI tickles])
178                 fi 
179                 AC_MSG_RESULT([yes])
180         else
181                 AC_MSG_RESULT([no])
182         fi
183         ],[
184                 AC_MSG_RESULT([no])
185         ]
186 )
187
188 ])
189
190 dnl Check for optional shadow password support
191 AC_DEFUN([AC_NETATALK_SHADOW], [
192 netatalk_cv_use_shadowpw=no
193 AC_ARG_WITH(shadow,
194         [  --with-shadow           enable shadow password support [[auto]]],
195         [netatalk_cv_use_shadowpw="$withval"],
196         [netatalk_cv_use_shadowpw=auto]
197 )
198
199 if test "x$netatalk_cv_use_shadowpw" != "xno"; then
200     AC_CHECK_HEADER([shadow.h])
201     if test x"$ac_cv_header_shadow_h" = x"yes"; then
202         netatalk_cv_use_shadowpw=yes
203         AC_DEFINE(SHADOWPW, 1, [Define if shadow passwords should be used])
204     else 
205       if test "x$shadowpw" = "xyes"; then
206         AC_MSG_ERROR([shadow support not available])
207       else
208         netatalk_cv_use_shadowpw=no
209       fi
210     fi 
211 fi
212
213 AC_MSG_CHECKING([whether shadow support should be enabled])
214 if test "x$netatalk_cv_use_shadowpw" = "xyes"; then
215         AC_MSG_RESULT([yes])
216 else
217         AC_MSG_RESULT([no])
218 fi
219 ])
220
221 dnl Check for optional valid-shell-check support
222 AC_DEFUN([AC_NETATALK_SHELL_CHECK], [
223 netatalk_cv_use_shellcheck=yes
224 AC_MSG_CHECKING([whether checking for a valid shell should be enabled])
225 AC_ARG_ENABLE(shell-check,
226         [  --disable-shell-check   disable checking for a valid shell],[
227         if test "$enableval" = "no"; then 
228                 AC_DEFINE(DISABLE_SHELLCHECK, 1, [Define if shell check should be disabled])
229                 AC_MSG_RESULT([no])
230                 netatalk_cv_use_shellcheck=no
231         else
232                 AC_MSG_RESULT([yes])
233         fi
234         ],[
235                 AC_MSG_RESULT([yes])
236         ]
237 )
238 ])
239
240 dnl Check for optional sysv initscript install
241 AC_DEFUN([AC_NETATALK_INIT_STYLE], [
242     AC_ARG_WITH(init-style,
243                 [  --with-init-style       use OS specific init config [[redhat-sysv|redhat-systemd|suse-sysv|suse-systemd|gentoo|netbsd|debian|solaris|systemd]]],
244                 init_style="$withval", init_style=none
245     )
246     case "$init_style" in 
247     "redhat")
248             AC_MSG_ERROR([--with-init-style=redhat is obsoleted. Use redhat-sysv or redhat-systemd.])
249         ;;
250     "redhat-sysv")
251             AC_MSG_RESULT([enabling redhat-style sysv initscript support])
252             ;;
253     "redhat-systemd")
254             AC_MSG_RESULT([enabling redhat-style systemd support])
255             ;;
256     "suse")
257             AC_MSG_ERROR([--with-init-style=suse is obsoleted. Use suse-sysv or suse-systemd.])
258         ;;
259     "suse-sysv")
260             AC_MSG_RESULT([enabling suse-style sysv initscript support])
261             ;;
262     "suse-systemd")
263             AC_MSG_RESULT([enabling suse-style systemd support (>=openSUSE12.1)])
264             ;;
265     "gentoo")
266             AC_MSG_RESULT([enabling gentoo-style initscript support])
267         ;;
268     "netbsd")
269             AC_MSG_RESULT([enabling netbsd-style initscript support])
270         ;;
271     "debian")
272             AC_MSG_RESULT([enabling debian-style initscript support])
273         ;;
274     "solaris")
275             AC_MSG_RESULT([enabling solaris-style SMF support])
276         ;;
277     "systemd")
278             AC_MSG_RESULT([enabling general systemd support])
279         ;;
280     "none")
281             AC_MSG_RESULT([disabling init-style support])
282         ;;
283     *)
284             AC_MSG_ERROR([illegal init-style])
285         ;;
286     esac
287     AM_CONDITIONAL(USE_NETBSD, test x$init_style = xnetbsd)
288     AM_CONDITIONAL(USE_REDHAT_SYSV, test x$init_style = xredhat-sysv)
289     AM_CONDITIONAL(USE_SUSE_SYSV, test x$init_style = xsuse-sysv)
290     AM_CONDITIONAL(USE_SOLARIS, test x$init_style = xsolaris)
291     AM_CONDITIONAL(USE_GENTOO, test x$init_style = xgentoo)
292     AM_CONDITIONAL(USE_DEBIAN, test x$init_style = xdebian)
293     AM_CONDITIONAL(USE_SYSTEMD, test x$init_style = xsystemd || test x$init_style = xredhat-systemd || test x$init_style = xsuse-systemd)
294     AM_CONDITIONAL(USE_UNDEF, test x$init_style = xnone)
295
296 ])
297
298 dnl OS specific configuration
299 AC_DEFUN([AC_NETATALK_OS_SPECIFIC], [
300 case "$host_os" in
301         *aix*)                          this_os=aix ;;
302         *freebsd*)                      this_os=freebsd ;;
303         *hpux11*)                       this_os=hpux11 ;;
304         *irix*)                         this_os=irix ;;
305         *linux*)                        this_os=linux ;;
306         *osx*)                          this_os=macosx ;;
307         *darwin*)                       this_os=macosx ;;
308         *netbsd*)                       this_os=netbsd ;;
309         *openbsd*)                      this_os=openbsd ;;
310         *osf*)                          this_os=tru64 ;;
311         *solaris*)                      this_os=solaris ;;
312 esac
313
314 case "$host_cpu" in
315         i386|i486|i586|i686|k7)         this_cpu=x86 ;;
316         alpha)                                          this_cpu=alpha ;;
317         mips)                                           this_cpu=mips ;;
318         powerpc|ppc)                            this_cpu=ppc ;;
319 esac
320
321 dnl --------------------- GNU source
322 case "$this_os" in
323         linux)  AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
324         ;;
325      kfreebsd-gnu) AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
326         ;;
327 esac
328
329 dnl --------------------- operating system specific flags (port from sys/*)
330
331 dnl ----- FreeBSD specific -----
332 if test x"$this_os" = "xfreebsd"; then 
333         AC_MSG_RESULT([ * FreeBSD specific configuration])
334         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
335         AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
336     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
337 fi
338
339 dnl ----- GNU/kFreeBSD specific -----
340 if test x"$this_os" = "xkfreebsd-gnu"; then 
341         AC_MSG_RESULT([ * GNU/kFreeBSD specific configuration])
342         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
343         AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
344     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
345 fi
346
347 dnl ----- Linux specific -----
348 if test x"$this_os" = "xlinux"; then 
349         AC_MSG_RESULT([ * Linux specific configuration])
350         
351         dnl ----- check if we need the quotactl wrapper
352     AC_CHECK_HEADERS(linux/dqblk_xfs.h,,
353                 [AC_CHECK_HEADERS(linux/xqm.h linux/xfs_fs.h)
354                 AC_CHECK_HEADERS(xfs/libxfs.h xfs/xqm.h xfs/xfs_fs.h)]
355         )
356
357
358         dnl ----- as far as I can tell, dbtob always does the wrong thing
359         dnl ----- on every single version of linux I've ever played with.
360         dnl ----- see etc/afpd/quota.c
361         AC_DEFINE(HAVE_BROKEN_DBTOB, 1, [Define if dbtob is broken])
362
363         need_dash_r=no
364 fi
365
366 dnl ----- NetBSD specific -----
367 if test x"$this_os" = "xnetbsd"; then 
368         AC_MSG_RESULT([ * NetBSD specific configuration])
369         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
370         AC_DEFINE(NETBSD, 1, [Define if OS is NetBSD])
371     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EFTYPE, errno returned by open with O_NOFOLLOW)
372
373         CFLAGS="-I\$(top_srcdir)/sys/netbsd $CFLAGS"
374         need_dash_r=yes 
375
376         dnl ----- NetBSD does not have crypt.h, uses unistd.h -----
377         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
378 fi
379
380 dnl ----- OpenBSD specific -----
381 if test x"$this_os" = "xopenbsd"; then 
382         AC_MSG_RESULT([ * OpenBSD specific configuration])
383     AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
384         dnl ----- OpenBSD does not have crypt.h, uses unistd.h -----
385         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
386 fi
387
388 dnl ----- Solaris specific -----
389 if test x"$this_os" = "xsolaris"; then 
390         AC_MSG_RESULT([ * Solaris specific configuration])
391         AC_DEFINE(__svr4__, 1, [Solaris compatibility macro])
392         AC_DEFINE(_ISOC9X_SOURCE, 1, [Compatibility macro])
393         AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
394         AC_DEFINE(SOLARIS, 1, [Solaris compatibility macro])
395     AC_DEFINE(_XOPEN_SOURCE, 600, [Solaris compilation environment])
396     AC_DEFINE(__EXTENSIONS__,  1, [Solaris compilation environment])
397         CFLAGS="-I\$(top_srcdir)/sys/generic $CFLAGS"
398         need_dash_r=yes
399         init_style=solaris
400
401         solaris_module=no
402         AC_MSG_CHECKING([if we can build Solaris kernel module])
403         if test -x /usr/ccs/bin/ld && test x"$netatalk_cv_ddp_enabled" = x"yes" ; then
404                 solaris_module=yes
405         fi
406         AC_MSG_RESULT([$solaris_module])
407
408         COMPILE_64BIT_KMODULE=no
409         KCFLAGS=""
410         KLDFLAGS=""
411         COMPILE_KERNEL_GCC=no
412
413         if test "$solaris_module" = "yes"; then
414            dnl Solaris kernel module stuff
415            AC_MSG_CHECKING([if we have to build a 64bit kernel module])
416
417            # check for isainfo, if not found it has to be a 32 bit kernel (<=2.6)       
418            if test -x /usr/bin/isainfo; then
419                 # check for 64 bit platform
420                 if isainfo -kv | grep '^64-bit'; then
421                         COMPILE_64BIT_KMODULE=yes
422                 fi
423            fi
424
425            AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
426
427            if test "${GCC}" = yes; then
428                 COMPILE_KERNEL_GCC=yes
429                 if test "$COMPILE_64BIT_KMODULE" = yes; then
430                 
431                         AC_MSG_CHECKING([if we can build a 64bit kernel module])
432                         
433                         case `$CC --version 2>/dev/null` in
434                         [[12]].* | 3.0.*)
435                                 COMPILE_64BIT_KMODULE=no
436                                 COMPILE_KERNEL_GCC=no   
437                                 solaris_module=no;;
438                         *)
439                                 # use for 64 bit
440                                 KCFLAGS="-m64"
441                                 #KLDFLAGS="-melf64_sparc"
442                                 KLDFLAGS="-64";;
443                         esac    
444                         
445                         AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
446                         
447                 else
448                         KCFLAGS=""
449                         KLDFLAGS=""
450                 fi
451                 KCFLAGS="$KCFLAGS -D_KERNEL -Wall -Wstrict-prototypes"
452            else
453                 if test "$COMPILE_64BIT_KMODULE" = yes; then
454                 # use Sun CC (for a 64-bit kernel, uncomment " -xarch=v9 -xregs=no%appl ")
455                         KCFLAGS="-xarch=v9 -xregs=no%appl"
456                         KLDFLAGS="-64"
457                 else
458                         KCFLAGS=""
459                         KLDFLAGS=""
460                 fi
461                 KCFLAGS="-D_KERNEL $KCFLAGS -mno-app-regs -munaligned-doubles -fpcc-struct-return"
462            fi
463
464            AC_CACHE_CHECK([for timeout_id_t],netatalk_cv_HAVE_TIMEOUT_ID_T,[
465            AC_LINK_IFELSE([AC_LANG_PROGRAM([[\
466 #include <sys/stream.h>
467 #include <sys/ddi.h>]], [[\
468 timeout_id_t dummy;
469 ]])],[netatalk_cv_HAVE_TIMEOUT_ID_T=yes],[netatalk_cv_HAVE_TIMEOUT_ID_T=no])])
470
471            AC_DEFINE(HAVE_TIMEOUT_ID_T, test x"$netatalk_cv_HAVE_TIMEOUT_ID" = x"yes", [define for timeout_id_t])
472         fi
473
474         AC_SUBST(COMPILE_KERNEL_GCC)
475         AC_SUBST(COMPILE_64BIT_KMODULE)
476         AC_SUBST(KCFLAGS)
477         AC_SUBST(KLDFLAGS)
478 fi
479
480 dnl Whether to run ldconfig after installing libraries
481 AC_PATH_PROG(NETA_LDCONFIG, ldconfig, , [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/usr/bin])
482 echo NETA_LDCONFIG = $NETA_LDCONFIG
483 AM_CONDITIONAL(RUN_LDCONFIG, test x"$this_os" = x"linux" -a x"$NETA_LDCONFIG" != x"")
484 ])
485
486 dnl Check for building PGP UAM module
487 AC_DEFUN([AC_NETATALK_PGP_UAM], [
488 AC_MSG_CHECKING([whether the PGP UAM should be build])
489 AC_ARG_ENABLE(pgp-uam,
490         [  --enable-pgp-uam        enable build of PGP UAM module],[
491         if test "$enableval" = "yes"; then 
492                 if test "x$neta_cv_have_openssl" = "xyes"; then 
493                         AC_DEFINE(UAM_PGP, 1, [Define if the PGP UAM module should be compiled])
494                         compile_pgp=yes
495                         AC_MSG_RESULT([yes])
496                 else
497                         AC_MSG_RESULT([no])
498                 fi
499         fi
500         ],[
501                 AC_MSG_RESULT([no])
502         ]
503 )
504 ])
505
506 dnl Check for building Kerberos V UAM module
507 AC_DEFUN([AC_NETATALK_KRB5_UAM], [
508 netatalk_cv_build_krb5_uam=no
509 AC_ARG_ENABLE(krbV-uam,
510         [  --enable-krbV-uam       enable build of Kerberos V UAM module],
511         [
512                 if test x"$enableval" = x"yes"; then
513                         NETATALK_GSSAPI_CHECK([
514                                 netatalk_cv_build_krb5_uam=yes
515                         ],[
516                                 AC_MSG_ERROR([need GSSAPI to build Kerberos V UAM])
517                         ])
518                 fi
519         ]
520         
521 )
522
523 AC_MSG_CHECKING([whether Kerberos V UAM should be build])
524 if test x"$netatalk_cv_build_krb5_uam" = x"yes"; then
525         AC_MSG_RESULT([yes])
526 else
527         AC_MSG_RESULT([no])
528 fi
529 AM_CONDITIONAL(USE_GSSAPI, test x"$netatalk_cv_build_krb5_uam" = x"yes")
530 ])
531
532 dnl Check if we can directly use Kerberos 5 API, used for reading keytabs
533 dnl and automatically construction DirectoryService names from that, instead
534 dnl of requiring special configuration in afp.conf
535 AC_DEFUN([AC_NETATALK_KERBEROS], [
536 AC_MSG_CHECKING([for Kerberos 5 (necessary for GetSrvrInfo:DirectoryNames support)])
537 AC_ARG_WITH([kerberos],
538     [AS_HELP_STRING([--with-kerberos], [Kerberos 5 support (default=auto)])],
539     [],
540     [with_kerberos=auto])
541 AC_MSG_RESULT($with_kerberos)
542
543 if test x"$with_kerberos" != x"no"; then
544    have_krb5_header="no"
545    AC_CHECK_HEADERS([krb5/krb5.h krb5.h], [have_krb5_header="yes"; break])
546    if test x"$have_krb5_header" = x"no" && test x"$with_kerberos" != x"auto"; then
547       AC_MSG_FAILURE([--with-kerberos was given, but no headers found])
548    fi
549
550    AC_PATH_PROG([KRB5_CONFIG], [krb5-config])
551    AC_MSG_CHECKING([for krb5-config])
552    if test -x "$KRB5_CONFIG"; then
553       AC_MSG_RESULT([$KRB5_CONFIG])
554       KRB5_CFLAGS="`$KRB5_CONFIG --cflags krb5`"
555       KRB5_LIBS="`$KRB5_CONFIG --libs krb5`"
556       AC_SUBST(KRB5_CFLAGS)
557       AC_SUBST(KRB5_LIBS)
558       with_kerberos="yes"
559    else
560       AC_MSG_RESULT([not found])
561       if test x"$with_kerberos" != x"auto"; then
562          AC_MSG_FAILURE([--with-kerberos was given, but krb5-config could not be found])
563       fi
564    fi
565 fi
566
567 if test x"$with_kerberos" = x"yes"; then
568    AC_DEFINE([HAVE_KERBEROS], [1], [Define if Kerberos 5 is available])
569 fi
570
571 dnl Check for krb5_free_unparsed_name and krb5_free_error_message
572 save_CFLAGS="$CFLAGS"
573 save_LIBS="$LIBS"
574 CFLAGS="$KRB5_CFLAGS"
575 LIBS="$KRB5_LIBS"
576 AC_CHECK_FUNCS([krb5_free_unparsed_name krb5_free_error_message])
577 CFLAGS="$save_CFLAGS"
578 LIBS="$save_LIBS"
579 ])
580
581 dnl Check for overwrite the config files or not
582 AC_DEFUN([AC_NETATALK_OVERWRITE_CONFIG], [
583 AC_MSG_CHECKING([whether configuration files should be overwritten])
584 AC_ARG_ENABLE(overwrite,
585         [  --enable-overwrite      overwrite configuration files during installation],
586         [OVERWRITE_CONFIG="${enable_overwrite}"],
587         [OVERWRITE_CONFIG="no"]
588 )
589 AC_MSG_RESULT([$OVERWRITE_CONFIG])
590 AC_SUBST(OVERWRITE_CONFIG)
591 ])
592
593 dnl Check for LDAP support, for client-side ACL visibility
594 AC_DEFUN([AC_NETATALK_LDAP], [
595 AC_MSG_CHECKING(for LDAP (necessary for client-side ACL visibility))
596 AC_ARG_WITH(ldap,
597     [AS_HELP_STRING([--with-ldap],
598         [LDAP support (default=auto)])],
599         netatalk_cv_ldap=$withval,
600         netatalk_cv_ldap=auto
601         )
602 AC_MSG_RESULT($netatalk_cv_ldap)
603
604 save_CFLAGS="$CFLAGS"
605 save_LDFLAGS="$LDFLAGS"
606 save_LIBS="$LIBS"
607 CFLAGS=""
608 LDFLAGS=""
609 LIBS=""
610 LDAP_CFLAGS=""
611 LDAP_LDFLAGS=""
612 LDAP_LIBS=""
613
614 if test x"$netatalk_cv_ldap" != x"no" ; then
615    if test x"$netatalk_cv_ldap" != x"yes" -a x"$netatalk_cv_ldap" != x"auto"; then
616        CFLAGS="-I$netatalk_cv_ldap/include"
617        LDFLAGS="-L$netatalk_cv_ldap/lib"
618    fi
619         AC_CHECK_HEADER([ldap.h], netatalk_cv_ldap=yes,
620         [ if test x"$netatalk_cv_ldap" = x"yes" ; then
621             AC_MSG_ERROR([Missing LDAP headers])
622         fi
623                 netatalk_cv_ldap=no
624         ])
625         AC_CHECK_LIB(ldap, ldap_init, netatalk_cv_ldap=yes,
626         [ if test x"$netatalk_cv_ldap" = x"yes" ; then
627             AC_MSG_ERROR([Missing LDAP library])
628         fi
629                 netatalk_cv_ldap=no
630         ])
631 fi
632
633 if test x"$netatalk_cv_ldap" = x"yes"; then
634     LDAP_CFLAGS="$CFLAGS"
635     LDAP_LDFLAGS="$LDFLAGS"
636     LDAP_LIBS="-lldap"
637         AC_DEFINE(HAVE_LDAP,1,[Whether LDAP is available])
638 fi
639
640 AC_SUBST(LDAP_CFLAGS)
641 AC_SUBST(LDAP_LDFLAGS)
642 AC_SUBST(LDAP_LIBS)
643 CFLAGS="$save_CFLAGS"
644 LDLFLAGS="$save_LDLFLAGS"
645 LIBS="$save_LIBS"
646 ])
647
648 dnl Check for ACL support
649 AC_DEFUN([AC_NETATALK_ACL], [
650 AC_MSG_CHECKING(whether to support ACLs)
651 AC_ARG_WITH(acls,
652     [AS_HELP_STRING([--with-acls],
653         [Include ACL support (default=auto)])],
654     [ case "$withval" in
655       yes|no)
656           with_acl_support="$withval"
657                   ;;
658       *)
659           with_acl_support=auto
660           ;;
661       esac ],
662     [with_acl_support=auto])
663 AC_MSG_RESULT($with_acl_support)
664
665 if test x"$with_acl_support" = x"no"; then
666         AC_MSG_RESULT(Disabling ACL support)
667         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
668 else
669     with_acl_support=yes
670 fi
671
672 if test x"$with_acl_support" = x"yes" ; then
673         AC_MSG_NOTICE(checking whether ACL support is available:)
674         case "$host_os" in
675         *sysv5*)
676                 AC_MSG_NOTICE(Using UnixWare ACLs)
677                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
678                 ;;
679         *solaris*)
680                 AC_MSG_NOTICE(Using solaris ACLs)
681                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
682                 ACL_LIBS="$ACL_LIBS -lsec"
683                 ;;
684         *hpux*)
685                 AC_MSG_NOTICE(Using HPUX ACLs)
686                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
687                 ;;
688         *irix*)
689                 AC_MSG_NOTICE(Using IRIX ACLs)
690                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
691                 ;;
692         *aix*)
693                 AC_MSG_NOTICE(Using AIX ACLs)
694                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
695                 ;;
696         *osf*)
697                 AC_MSG_NOTICE(Using Tru64 ACLs)
698                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
699                 ACL_LIBS="$ACL_LIBS -lpacl"
700                 ;;
701         *darwin*)
702                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
703                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
704                 ;;
705         *)
706                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
707                 case "$host_os" in
708                 *linux*)
709                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
710                         ;;
711                 esac
712                 AC_CACHE_CHECK([for POSIX ACL support],netatalk_cv_HAVE_POSIX_ACLS,[
713                         acl_LIBS=$LIBS
714                         LIBS="$LIBS $ACL_LIBS"
715                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
716                                 #include <sys/types.h>
717                                 #include <sys/acl.h>
718                         ]], [[
719                                 acl_t acl;
720                                 int entry_id;
721                                 acl_entry_t *entry_p;
722                                 return acl_get_entry(acl, entry_id, entry_p);
723                         ]])],[netatalk_cv_HAVE_POSIX_ACLS=yes],[netatalk_cv_HAVE_POSIX_ACLS=no
724                 with_acl_support=no])
725                         LIBS=$acl_LIBS
726                 ])
727                 if test x"$netatalk_cv_HAVE_POSIX_ACLS" = x"yes"; then
728                         AC_MSG_NOTICE(Using POSIX ACLs)
729                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
730                         AC_CACHE_CHECK([for acl_get_perm_np],netatalk_cv_HAVE_ACL_GET_PERM_NP,[
731                                 acl_LIBS=$LIBS
732                                 LIBS="$LIBS $ACL_LIBS"
733                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
734                                         #include <sys/types.h>
735                                         #include <sys/acl.h>
736                                 ]], [[
737                                         acl_permset_t permset_d;
738                                         acl_perm_t perm;
739                                         return acl_get_perm_np(permset_d, perm);
740                                 ]])],[netatalk_cv_HAVE_ACL_GET_PERM_NP=yes],[netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
741                                 LIBS=$acl_LIBS
742                         ])
743                         if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
744                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
745                         fi
746
747
748                        AC_CACHE_CHECK([for acl_from_mode], netatalk_cv_HAVE_ACL_FROM_MODE,[
749                                acl_LIBS=$LIBS
750                                LIBS="$LIBS $ACL_LIBS"
751                 AC_CHECK_FUNCS(acl_from_mode,
752                                [netatalk_cv_HAVE_ACL_FROM_MODE=yes],
753                                [netatalk_cv_HAVE_ACL_FROM_MODE=no])
754                                LIBS=$acl_LIBS
755                        ])
756                        if test x"netatalk_cv_HAVE_ACL_FROM_MODE" = x"yes"; then
757                                AC_DEFINE(HAVE_ACL_FROM_MODE,1,[Whether acl_from_mode() is available])
758                        fi
759
760                 else
761                         AC_MSG_NOTICE(ACL support is not avaliable)
762                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
763                 fi
764                 ;;
765     esac
766 fi
767
768 if test x"$with_acl_support" = x"yes" ; then
769    AC_CHECK_HEADERS([acl/libacl.h])
770     AC_DEFINE(HAVE_ACLS,1,[Whether ACLs support is available])
771     AC_SUBST(ACL_LIBS)
772 fi
773 ])
774
775 dnl Check for Extended Attributes support
776 AC_DEFUN([AC_NETATALK_EXTENDED_ATTRIBUTES], [
777 neta_cv_eas="ad"
778 neta_cv_eas_sys_found=no
779 neta_cv_eas_sys_not_found=no
780
781 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h sys/ea.h)
782
783 case "$this_os" in
784
785   *osf*)
786         AC_SEARCH_LIBS(getproplist, [proplist])
787         AC_CHECK_FUNCS([getproplist fgetproplist setproplist fsetproplist],
788                    [neta_cv_eas_sys_found=yes],
789                    [neta_cv_eas_sys_not_found=yes])
790         AC_CHECK_FUNCS([delproplist fdelproplist add_proplist_entry get_proplist_entry],,
791                    [neta_cv_eas_sys_not_found=yes])
792         AC_CHECK_FUNCS([sizeof_proplist_entry],,
793                    [neta_cv_eas_sys_not_found=yes])
794   ;;
795
796   *solaris*)
797         AC_CHECK_FUNCS([attropen],
798                    [neta_cv_eas_sys_found=yes; AC_DEFINE(HAVE_EAFD, 1, [extattr API has full fledged fds for EAs])],
799                    [neta_cv_eas_sys_not_found=yes])
800   ;;
801
802   'freebsd')
803     AC_CHECK_FUNCS([extattr_delete_fd extattr_delete_file extattr_delete_link],
804                    [neta_cv_eas_sys_found=yes],
805                    [neta_cv_eas_sys_not_found=yes])
806     AC_CHECK_FUNCS([extattr_get_fd extattr_get_file extattr_get_link],,
807                    [neta_cv_eas_sys_not_found=yes])
808     AC_CHECK_FUNCS([extattr_list_fd extattr_list_file extattr_list_link],,
809                    [neta_cv_eas_sys_not_found=yes])
810     AC_CHECK_FUNCS([extattr_set_fd extattr_set_file extattr_set_link],,
811                    [neta_cv_eas_sys_not_found=yes])
812   ;;
813
814   *freebsd4* | *dragonfly* )
815     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
816   ;;
817
818   *)
819         AC_SEARCH_LIBS(getxattr, [attr])
820
821     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
822        AC_CHECK_FUNCS([getxattr lgetxattr fgetxattr listxattr llistxattr],
823                       [neta_cv_eas_sys_found=yes],
824                       [neta_cv_eas_sys_not_found=yes])
825            AC_CHECK_FUNCS([flistxattr removexattr lremovexattr fremovexattr],,
826                       [neta_cv_eas_sys_not_found=yes])
827            AC_CHECK_FUNCS([setxattr lsetxattr fsetxattr],,
828                       [neta_cv_eas_sys_not_found=yes])
829     fi
830
831     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
832            AC_CHECK_FUNCS([getea fgetea lgetea listea flistea llistea],
833                       [neta_cv_eas_sys_found=yes],
834                       [neta_cv_eas_sys_not_found=yes])
835            AC_CHECK_FUNCS([removeea fremoveea lremoveea setea fsetea lsetea],,
836                       [neta_cv_eas_sys_not_found=yes])
837     fi
838
839     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
840            AC_CHECK_FUNCS([attr_get attr_list attr_set attr_remove],,
841                       [neta_cv_eas_sys_not_found=yes])
842        AC_CHECK_FUNCS([attr_getf attr_listf attr_setf attr_removef],,
843                       [neta_cv_eas_sys_not_found=yes])
844     fi
845   ;;
846 esac
847
848 # Do xattr functions take additional options like on Darwin?
849 if test x"$ac_cv_func_getxattr" = x"yes" ; then
850         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
851                 old_LIBS=$LIBS
852                 LIBS="$LIBS $ACL_LIBS"
853                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
854                         #include <sys/types.h>
855                         #if HAVE_ATTR_XATTR_H
856                         #include <attr/xattr.h>
857                         #elif HAVE_SYS_XATTR_H
858                         #include <sys/xattr.h>
859                         #endif
860                 ]], [[
861                         getxattr(0, 0, 0, 0, 0, 0);
862                 ]])],[smb_attr_cv_xattr_add_opt=yes],[smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
863         ])
864         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
865                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
866         fi
867 fi
868
869 if test "x$neta_cv_eas_sys_found" = "xyes" ; then
870    if test "x$neta_cv_eas_sys_not_found" != "xyes" ; then
871       neta_cv_eas="$neta_cv_eas | sys"
872    fi
873 fi
874 AC_DEFINE_UNQUOTED(EA_MODULES,["$neta_cv_eas"],[Available Extended Attributes modules])
875 ])
876
877 dnl Check for libsmbsharemodes from Samba for Samba/Netatalk access/deny/share modes interop
878 dnl Defines "neta_cv_have_smbshmd" to "yes" or "no"
879 dnl AC_SUBST's "SMB_SHAREMODES_CFLAGS" and "SMB_SHAREMODES_LDFLAGS"
880 dnl AM_CONDITIONAL's "USE_SMB_SHAREMODES"
881 AC_DEFUN([AC_NETATALK_SMB_SHAREMODES], [
882     neta_cv_have_smbshmd=no
883     AC_ARG_WITH(smbsharemodes-lib,
884                 [  --with-smbsharemodes-lib=PATH        PATH to libsmbsharemodes lib from Samba],
885                 [SMB_SHAREMODES_LDFLAGS="-L$withval -lsmbsharemodes"]
886     )
887     AC_ARG_WITH(smbsharemodes-include,
888                 [  --with-smbsharemodes-include=PATH    PATH to libsmbsharemodes header from Samba],
889                 [SMB_SHAREMODES_CFLAGS="-I$withval"]
890     )
891     AC_ARG_WITH(smbsharemodes,
892                 [AS_HELP_STRING([--with-smbsharemodes],[Samba interop (default is yes)])],
893                 [use_smbsharemodes=$withval],
894                 [use_smbsharemodes=yes]
895     )
896
897     if test x"$use_smbsharemodes" = x"yes" ; then
898         AC_MSG_CHECKING([whether to enable Samba/Netatalk access/deny/share-modes interop])
899
900         saved_CFLAGS="$CFLAGS"
901         saved_LDFLAGS="$LDFLAGS"
902         CFLAGS="$SMB_SHAREMODES_CFLAGS $CFLAGS"
903         LDFLAGS="$SMB_SHAREMODES_LDFLAGS $LDFLAGS"
904
905         AC_LINK_IFELSE(
906             [#include <unistd.h>
907              #include <stdio.h>
908              #include <sys/time.h>
909              #include <time.h>
910              #include <stdint.h>
911              /* From messages.h */
912              struct server_id {
913                  pid_t pid;
914              };
915              #include "smb_share_modes.h"
916              int main(void) { (void)smb_share_mode_db_open(""); return 0;}],
917             [neta_cv_have_smbshmd=yes]
918         )
919
920         AC_MSG_RESULT($neta_cv_have_smbshmd)
921         AC_SUBST(SMB_SHAREMODES_CFLAGS, [$SMB_SHAREMODES_CFLAGS])
922         AC_SUBST(SMB_SHAREMODES_LDFLAGS, [$SMB_SHAREMODES_LDFLAGS])
923         CFLAGS="$saved_CFLAGS"
924         LDFLAGS="$saved_LDFLAGS"
925     fi
926
927     AM_CONDITIONAL(USE_SMB_SHAREMODES, test x"$neta_cv_have_smbshmd" = x"yes")
928 ])
929
930 dnl ------ Check for sendfile() --------
931 AC_DEFUN([AC_NETATALK_SENDFILE], [
932 netatalk_cv_search_sendfile=yes
933 AC_ARG_ENABLE(sendfile,
934     [  --disable-sendfile       disable sendfile syscall],
935     [if test x"$enableval" = x"no"; then
936             netatalk_cv_search_sendfile=no
937         fi]
938 )
939
940 if test x"$netatalk_cv_search_sendfile" = x"yes"; then
941    case "$host_os" in
942    *linux*)
943         AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
944         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
945         ;;
946
947     *solaris*)
948         AC_DEFINE(SENDFILE_FLAVOR_SOLARIS, 1, [Solaris sendfile()])
949         AC_SEARCH_LIBS(sendfile, sendfile)
950         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
951         AC_CHECK_FUNCS([sendfilev])
952         ;;
953
954     *freebsd*)
955         AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
956         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
957         ;;
958
959     *)
960         ;;
961
962     esac
963
964     if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
965         AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
966     fi
967 fi
968 ])
969
970 dnl --------------------- Check if realpath() takes NULL
971 AC_DEFUN([AC_NETATALK_REALPATH], [
972 AC_CACHE_CHECK([if the realpath function allows a NULL argument],
973     neta_cv_REALPATH_TAKES_NULL, [
974         AC_RUN_IFELSE([AC_LANG_SOURCE([[
975             #include <stdio.h>
976             #include <limits.h>
977             #include <signal.h>
978
979             void exit_on_core(int ignored) {
980                  exit(1);
981             }
982
983             main() {
984                 char *newpath;
985                 signal(SIGSEGV, exit_on_core);
986                 newpath = realpath("/tmp", NULL);
987                 exit((newpath != NULL) ? 0 : 1);
988             }]])],[neta_cv_REALPATH_TAKES_NULL=yes],[neta_cv_REALPATH_TAKES_NULL=no],[neta_cv_REALPATH_TAKES_NULL=cross
989         ])
990     ]
991 )
992
993 if test x"$neta_cv_REALPATH_TAKES_NULL" = x"yes"; then
994     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
995 fi
996 ])