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