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