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