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