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