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