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