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