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