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