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