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