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