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