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