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