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