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