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