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