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