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