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