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