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