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