]> arthur.barton.de Git - netatalk.git/blob - macros/netatalk.m4
Merge master
[netatalk.git] / macros / netatalk.m4
1 dnl Kitchen sink for configuration macros
2
3 dnl Check for optional admin group support
4 AC_DEFUN([AC_NETATALK_ADMIN_GROUP], [
5     netatalk_cv_admin_group=yes
6     AC_MSG_CHECKING([for administrative group support])
7     AC_ARG_ENABLE(admin-group,
8             [  --disable-admin-group   disable admin group],[
9             if test x"$enableval" = x"no"; then
10                          AC_DEFINE(ADMIN_GRP, 0, [Define if the admin group should be enabled])
11                          netatalk_cv_admin_group=no
12                          AC_MSG_RESULT([no])
13                 else
14                          AC_DEFINE(ADMIN_GRP, 1, [Define if the admin group should be enabled])
15                          AC_MSG_RESULT([yes])
16             fi],[
17                 AC_DEFINE(ADMIN_GRP, 1, [Define if the admin group should be enabled])
18                 AC_MSG_RESULT([yes])
19         ])
20 ])
21
22 dnl Check for optional cracklib support
23 AC_DEFUN([AC_NETATALK_CRACKLIB], [
24 netatalk_cv_with_cracklib=no
25 AC_ARG_WITH(cracklib,
26         [  --with-cracklib=DICT    enable/set location of cracklib dictionary],[
27         if test "x$withval" != "xno" ; then
28                 cracklib="$withval"
29                 AC_CHECK_LIB(crack, main, [
30                         AC_DEFINE(USE_CRACKLIB, 1, [Define if cracklib should be used])
31                         LIBS="$LIBS -lcrack"
32                         if test "$cracklib" = "yes"; then
33                                 cracklib="/usr/$atalk_libname/cracklib_dict"
34                         fi
35                         AC_DEFINE_UNQUOTED(_PATH_CRACKLIB, "$cracklib",
36                                 [path to cracklib dictionary])
37                         AC_MSG_RESULT([setting cracklib dictionary to $cracklib])
38                         netatalk_cv_with_cracklib=yes
39                         ],[
40                         AC_MSG_ERROR([cracklib not found!])
41                         ]
42                 )
43         fi
44         ]
45 )
46 AC_MSG_CHECKING([for cracklib support])
47 AC_MSG_RESULT([$netatalk_cv_with_cracklib])
48 ])
49
50 dnl Check whether to enable debug code
51 AC_DEFUN([AC_NETATALK_DEBUG], [
52 AC_MSG_CHECKING([whether to enable verbose debug code])
53 AC_ARG_ENABLE(debug,
54         [  --enable-debug          enable verbose debug code],[
55         if test "$enableval" != "no"; then
56                 if test "$enableval" = "yes"; then
57                         AC_DEFINE(DEBUG, 1, [Define if verbose debugging information should be included])
58                 else
59                         AC_DEFINE_UNQUOTED(DEBUG, $enableval, [Define if verbose debugging information should be included])
60                 fi 
61                 AC_MSG_RESULT([yes])
62         else
63                 AC_MSG_RESULT([no])
64         AC_DEFINE(NDEBUG, 1, [Disable assertions])
65         fi
66         ],[
67                 AC_MSG_RESULT([no])
68         AC_DEFINE(NDEBUG, 1, [Disable assertions])
69         ]
70 )
71 ])
72
73 dnl Check whethe to disable tickle SIGALARM stuff, which eases debugging
74 AC_DEFUN([AC_NETATALK_DEBUGGING], [
75 AC_MSG_CHECKING([whether to enable debugging with debuggers])
76 AC_ARG_ENABLE(debugging,
77         [  --enable-debugging      disable SIGALRM timers and DSI tickles (eg for debugging with gdb/dbx/...)],[
78         if test "$enableval" != "no"; then
79                 if test "$enableval" = "yes"; then
80                         AC_DEFINE(DEBUGGING, 1, [Define if you want to disable SIGALRM timers and DSI tickles])
81                 else
82                         AC_DEFINE_UNQUOTED(DEBUGGING, $enableval, [Define if you want to disable SIGALRM timers and DSI tickles])
83                 fi 
84                 AC_MSG_RESULT([yes])
85         else
86                 AC_MSG_RESULT([no])
87         fi
88         ],[
89                 AC_MSG_RESULT([no])
90         ]
91 )
92
93 ])
94
95 dnl Check for optional shadow password support
96 AC_DEFUN([AC_NETATALK_SHADOW], [
97 netatalk_cv_use_shadowpw=no
98 AC_ARG_WITH(shadow,
99         [  --with-shadow           enable shadow password support [[auto]]],
100         [netatalk_cv_use_shadowpw="$withval"],
101         [netatalk_cv_use_shadowpw=auto]
102 )
103
104 if test "x$netatalk_cv_use_shadowpw" != "xno"; then
105     AC_CHECK_HEADER([shadow.h])
106     if test x"$ac_cv_header_shadow_h" = x"yes"; then
107         netatalk_cv_use_shadowpw=yes
108         AC_DEFINE(SHADOWPW, 1, [Define if shadow passwords should be used])
109     else 
110       if test "x$shadowpw" = "xyes"; then
111         AC_MSG_ERROR([shadow support not available])
112       else
113         netatalk_cv_use_shadowpw=no
114       fi
115     fi 
116 fi
117
118 AC_MSG_CHECKING([whether shadow support should be enabled])
119 if test "x$netatalk_cv_use_shadowpw" = "xyes"; then
120         AC_MSG_RESULT([yes])
121 else
122         AC_MSG_RESULT([no])
123 fi
124 ])
125
126 dnl Check for optional valid-shell-check support
127 AC_DEFUN([AC_NETATALK_SHELL_CHECK], [
128 netatalk_cv_use_shellcheck=yes
129 AC_MSG_CHECKING([whether checking for a valid shell should be enabled])
130 AC_ARG_ENABLE(shell-check,
131         [  --disable-shell-check   disable checking for a valid shell],[
132         if test "$enableval" = "no"; then 
133                 AC_DEFINE(DISABLE_SHELLCHECK, 1, [Define if shell check should be disabled])
134                 AC_MSG_RESULT([no])
135                 netatalk_cv_use_shellcheck=no
136         else
137                 AC_MSG_RESULT([yes])
138         fi
139         ],[
140                 AC_MSG_RESULT([yes])
141         ]
142 )
143 ])
144
145 dnl Check for optional sysv initscript install
146 AC_DEFUN([AC_NETATALK_SYSV_STYLE], [
147     AC_ARG_WITH(sysv-style,
148                 [  --with-sysv-style       use OS specific sysv config [[redhat-sysv|redhat-systemd|suse|gentoo|netbsd|debian]]],
149                 sysv_style="$withval", sysv_style=none
150     )
151     case "$sysv_style" in 
152     "redhat")
153             AC_MSG_ERROR([--enable-redhat is obsoleted. Use --enable-redhat-sysv or --enable-redhat-systemd.])
154         ;;
155     "redhat-sysv")
156             AC_MSG_RESULT([enabling redhat-style sysv (upstart) configuration])
157             ;;
158     "redhat-systemd")
159             AC_MSG_RESULT([enabling redhat-style systemd support])
160             ;;
161     "suse")
162             AC_MSG_RESULT([enabling suse-style sysv support])
163         ;;
164     "gentoo")
165             AC_MSG_RESULT([enabling gentoo-style sysv support])
166         ;;
167     "netbsd")
168             AC_MSG_RESULT([enabling netbsd-style sysv support])
169         ;;
170     "debian")
171             AC_MSG_RESULT([enabling debian-style sysv support])
172         ;;
173     *)
174             AC_MSG_RESULT([disabling sysv support])
175         ;;
176     esac
177 ])
178
179 dnl OS specific configuration
180 AC_DEFUN([AC_NETATALK_OS_SPECIFIC], [
181 case "$host_os" in
182         *aix*)                          this_os=aix ;;
183         *freebsd*)                      this_os=freebsd ;;
184         *hpux11*)                       this_os=hpux11 ;;
185         *irix*)                         this_os=irix ;;
186         *linux*)                        this_os=linux ;;
187         *osx*)                          this_os=macosx ;;
188         *darwin*)                       this_os=macosx ;;
189         *netbsd*)                       this_os=netbsd ;;
190         *openbsd*)                      this_os=openbsd ;;
191         *osf*)                          this_os=tru64 ;;
192         *solaris*)                      this_os=solaris ;;
193 esac
194
195 case "$host_cpu" in
196         i386|i486|i586|i686|k7)         this_cpu=x86 ;;
197         alpha)                                          this_cpu=alpha ;;
198         mips)                                           this_cpu=mips ;;
199         powerpc|ppc)                            this_cpu=ppc ;;
200 esac
201
202 dnl --------------------- operating system specific flags (port from sys/*)
203
204 dnl ----- FreeBSD specific -----
205 if test x"$this_os" = "xfreebsd"; then 
206         AC_MSG_RESULT([ * FreeBSD specific configuration])
207         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
208         AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
209         AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
210     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
211 fi
212
213 dnl ----- Linux specific -----
214 if test x"$this_os" = "xlinux"; then 
215         AC_MSG_RESULT([ * Linux specific configuration])
216         
217         dnl ----- check if we need the quotactl wrapper
218     AC_CHECK_HEADERS(linux/dqblk_xfs.h,,
219                 [AC_CHECK_HEADERS(linux/xqm.h linux/xfs_fs.h)
220                 AC_CHECK_HEADERS(xfs/libxfs.h xfs/xqm.h xfs/xfs_fs.h)]
221         )
222
223
224         dnl ----- as far as I can tell, dbtob always does the wrong thing
225         dnl ----- on every single version of linux I've ever played with.
226         dnl ----- see etc/afpd/quota.c
227         AC_DEFINE(HAVE_BROKEN_DBTOB, 1, [Define if dbtob is broken])
228
229         netatalk_cv_linux_sendfile=yes
230         AC_MSG_CHECKING([use sendfile syscall])
231         AC_ARG_ENABLE(sendfile,
232             [  --disable-sendfile       disable linux sendfile syscall],[
233                 if test x"$enableval" = x"no"; then
234                         netatalk_cv_linux_sendfile=no
235                         AC_MSG_RESULT([no])
236                 else
237                         AC_MSG_RESULT([yes])
238
239                 fi
240             ],[
241                 AC_MSG_RESULT([yes])
242         ]
243
244        )
245
246         if test x"$netatalk_cv_linux_sendfile" = "xyes"; then 
247             AC_CACHE_CHECK([for linux sendfile support],netatalk_cv_HAVE_SENDFILE,[
248             AC_TRY_LINK([#include <sys/sendfile.h>],
249 [\
250 int tofd, fromfd;
251 off_t offset;
252 size_t total;
253 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
254 ],
255 netatalk_cv_HAVE_SENDFILE=yes,netatalk_cv_HAVE_SENDFILE=no)])
256
257 # Try and cope with broken Linux sendfile....
258             AC_CACHE_CHECK([for broken linux sendfile support],netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE,[
259             AC_TRY_LINK([\
260 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
261 #undef _FILE_OFFSET_BITS
262 #endif
263 #include <sys/sendfile.h>],
264 [\
265 int tofd, fromfd;
266 off_t offset;
267 size_t total;
268 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
269 ],
270 netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE=no,netatalk_cv_HAVE_BROKEN_SENDFILE=cross)])
271
272             if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
273                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
274                 AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
275                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
276             elif test x"$netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
277                 AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
278                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
279                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
280             else
281                 netatalk_cv_linux_sendfile=no
282                 AC_MSG_RESULT(no);
283             fi
284         fi
285
286         need_dash_r=no
287 fi
288
289 dnl ----- Mac OSX specific -----
290 if test x"$this_os" = "xmacosx"; then 
291         AC_MSG_RESULT([ * Mac OSX specific configuration])
292         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
293         AC_DEFINE(HAVE_2ARG_DBTOB, 1, [Define if dbtob takes two arguments])
294         dnl AC_DEFINE(NO_DLFCN_H)
295         AC_DEFINE(NO_QUOTA_SUPPORT, 1, [Define if Quota support should be disabled])
296         AC_DEFINE(MACOSX_SERVER, 1, [Define if compiling for MacOS X Server])
297     AC_DEFINE(NO_DDP, 1, [Define if DDP should be disabled])
298 fi
299
300 dnl ----- NetBSD specific -----
301 if test x"$this_os" = "xnetbsd"; then 
302         AC_MSG_RESULT([ * NetBSD specific configuration])
303         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
304         AC_DEFINE(NETBSD, 1, [Define if OS is NetBSD])
305     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EFTYPE, errno returned by open with O_NOFOLLOW)
306
307         CFLAGS="-I\$(top_srcdir)/sys/netbsd $CFLAGS"
308         need_dash_r=yes 
309
310         dnl ----- NetBSD does not have crypt.h, uses unistd.h -----
311         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
312 fi
313
314 dnl ----- OpenBSD specific -----
315 if test x"$this_os" = "xopenbsd"; then 
316         AC_MSG_RESULT([ * OpenBSD specific configuration])
317         dnl ----- OpenBSD does not have crypt.h, uses unistd.h -----
318         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
319 fi
320
321 dnl ----- Solaris specific -----
322 if test x"$this_os" = "xsolaris"; then 
323         AC_MSG_RESULT([ * Solaris specific configuration])
324         AC_DEFINE(__svr4__, 1, [Solaris compatibility macro])
325         AC_DEFINE(_ISOC9X_SOURCE, 1, [Compatibility macro])
326         AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
327         AC_DEFINE(SOLARIS, 1, [Solaris compatibility macro])
328         CFLAGS="-I\$(top_srcdir)/sys/generic $CFLAGS"
329         need_dash_r=yes
330         sysv_style=solaris
331
332         solaris_module=no
333         AC_MSG_CHECKING([if we can build Solaris kernel module])
334         if test -x /usr/ccs/bin/ld && test x"$netatalk_cv_ddp_enabled" = x"yes" ; then
335                 solaris_module=yes
336         fi
337         AC_MSG_RESULT([$solaris_module])
338
339         COMPILE_64BIT_KMODULE=no
340         KCFLAGS=""
341         KLDFLAGS=""
342         COMPILE_KERNEL_GCC=no
343
344         if test "$solaris_module" = "yes"; then
345            dnl Solaris kernel module stuff
346            AC_MSG_CHECKING([if we have to build a 64bit kernel module])
347
348            # check for isainfo, if not found it has to be a 32 bit kernel (<=2.6)       
349            if test -x /usr/bin/isainfo; then
350                 # check for 64 bit platform
351                 if isainfo -kv | grep '^64-bit'; then
352                         COMPILE_64BIT_KMODULE=yes
353                 fi
354            fi
355
356            AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
357
358            if test "${GCC}" = yes; then
359                 COMPILE_KERNEL_GCC=yes
360                 if test "$COMPILE_64BIT_KMODULE" = yes; then
361                 
362                         AC_MSG_CHECKING([if we can build a 64bit kernel module])
363                         
364                         case `$CC --version 2>/dev/null` in
365                         [[12]].* | 3.0.*)
366                                 COMPILE_64BIT_KMODULE=no
367                                 COMPILE_KERNEL_GCC=no   
368                                 solaris_module=no;;
369                         *)
370                                 # use for 64 bit
371                                 KCFLAGS="-m64"
372                                 #KLDFLAGS="-melf64_sparc"
373                                 KLDFLAGS="-64";;
374                         esac    
375                         
376                         AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
377                         
378                 else
379                         KCFLAGS=""
380                         KLDFLAGS=""
381                 fi
382                 KCFLAGS="$KCFLAGS -D_KERNEL -Wall -Wstrict-prototypes"
383            else
384                 if test "$COMPILE_64BIT_KMODULE" = yes; then
385                 # use Sun CC (for a 64-bit kernel, uncomment " -xarch=v9 -xregs=no%appl ")
386                         KCFLAGS="-xarch=v9 -xregs=no%appl"
387                         KLDFLAGS="-64"
388                 else
389                         KCFLAGS=""
390                         KLDFLAGS=""
391                 fi
392                 KCFLAGS="-D_KERNEL $KCFLAGS -mno-app-regs -munaligned-doubles -fpcc-struct-return"
393            fi
394
395            AC_CACHE_CHECK([for timeout_id_t],netatalk_cv_HAVE_TIMEOUT_ID_T,[
396            AC_TRY_LINK([\
397 #include <sys/stream.h>
398 #include <sys/ddi.h>],
399 [\
400 timeout_id_t dummy;
401 ],
402 netatalk_cv_HAVE_TIMEOUT_ID_T=yes,netatalk_cv_HAVE_TIMEOUT_ID_T=no,netatalk_cv_HAVE_TIMEOUT_ID_T=cross)])
403
404            AC_DEFINE(HAVE_TIMEOUT_ID_T, test x"$netatalk_cv_HAVE_TIMEOUT_ID" = x"yes", [define for timeout_id_t])
405         fi
406
407         AC_SUBST(COMPILE_KERNEL_GCC)
408         AC_SUBST(COMPILE_64BIT_KMODULE)
409         AC_SUBST(KCFLAGS)
410         AC_SUBST(KLDFLAGS)
411 fi
412
413 ])
414
415 dnl Check for building PGP UAM module
416 AC_DEFUN([AC_NETATALK_PGP_UAM], [
417 AC_MSG_CHECKING([whether the PGP UAM should be build])
418 AC_ARG_ENABLE(pgp-uam,
419         [  --enable-pgp-uam        enable build of PGP UAM module],[
420         if test "$enableval" = "yes"; then 
421                 if test "x$neta_cv_have_openssl" = "xyes"; then 
422                         AC_DEFINE(UAM_PGP, 1, [Define if the PGP UAM module should be compiled])
423                         compile_pgp=yes
424                         AC_MSG_RESULT([yes])
425                 else
426                         AC_MSG_RESULT([no])
427                 fi
428         fi
429         ],[
430                 AC_MSG_RESULT([no])
431         ]
432 )
433 ])
434
435 dnl Check for building Kerberos V UAM module
436 AC_DEFUN([AC_NETATALK_KRB5_UAM], [
437 netatalk_cv_build_krb5_uam=no
438 AC_ARG_ENABLE(krbV-uam,
439         [  --enable-krbV-uam       enable build of Kerberos V UAM module],
440         [
441                 if test x"$enableval" = x"yes"; then
442                         NETATALK_GSSAPI_CHECK([
443                                 netatalk_cv_build_krb5_uam=yes
444                         ],[
445                                 AC_MSG_ERROR([need GSSAPI to build Kerberos V UAM])
446                         ])
447                 fi
448         ]
449         
450 )
451
452 AC_MSG_CHECKING([whether Kerberos V UAM should be build])
453 if test x"$netatalk_cv_build_krb5_uam" = x"yes"; then
454         AC_MSG_RESULT([yes])
455 else
456         AC_MSG_RESULT([no])
457 fi
458 AM_CONDITIONAL(USE_GSSAPI, test x"$netatalk_cv_build_krb5_uam" = x"yes")
459 ])
460
461 dnl Check for overwrite the config files or not
462 AC_DEFUN([AC_NETATALK_OVERWRITE_CONFIG], [
463 AC_MSG_CHECKING([whether configuration files should be overwritten])
464 AC_ARG_ENABLE(overwrite,
465         [  --enable-overwrite      overwrite configuration files during installation],
466         [OVERWRITE_CONFIG="${enable_overwrite}"],
467         [OVERWRITE_CONFIG="no"]
468 )
469 AC_MSG_RESULT([$OVERWRITE_CONFIG])
470 AC_SUBST(OVERWRITE_CONFIG)
471 ])
472
473 dnl Check for LDAP support, for client-side ACL visibility
474 AC_DEFUN([AC_NETATALK_LDAP], [
475 AC_MSG_CHECKING(for LDAP (necessary for client-side ACL visibility))
476 AC_ARG_WITH(ldap,
477     [AS_HELP_STRING([--with-ldap],
478         [LDAP support (default=auto)])],
479     [ case "$withval" in
480       yes|no)
481           with_ldap="$withval"
482                   ;;
483       *)
484           with_ldap=auto
485           ;;
486       esac ])
487 AC_MSG_RESULT($with_ldap)
488
489 if test x"$with_ldap" != x"no" ; then
490         AC_CHECK_HEADER([ldap.h], with_ldap=yes,
491         [ if test x"$with_ldap" = x"yes" ; then
492             AC_MSG_ERROR([Missing LDAP headers])
493         fi
494                 with_ldap=no
495         ])
496         AC_CHECK_LIB(ldap, ldap_init, with_ldap=yes,
497         [ if test x"$with_ldap" = x"yes" ; then
498             AC_MSG_ERROR([Missing LDAP library])
499         fi
500                 with_ldap=no
501         ])
502 fi
503
504 if test x"$with_ldap" = x"yes"; then
505         AC_DEFINE(HAVE_LDAP,1,[Whether LDAP is available])
506 fi
507 ])
508
509 dnl Check for ACL support
510 AC_DEFUN([AC_NETATALK_ACL], [
511 AC_MSG_CHECKING(whether to support ACLs)
512 AC_ARG_WITH(acls,
513     [AS_HELP_STRING([--with-acls],
514         [Include ACL support (default=auto)])],
515     [ case "$withval" in
516       yes|no)
517           with_acl_support="$withval"
518                   ;;
519       *)
520           with_acl_support=auto
521           ;;
522       esac ],
523     [with_acl_support=auto])
524 AC_MSG_RESULT($with_acl_support)
525
526 if test x"$with_acl_support" = x"no"; then
527         AC_MSG_RESULT(Disabling ACL support)
528         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
529 else
530     with_acl_support=yes
531 fi
532
533 if test x"$with_acl_support" = x"yes" ; then
534         AC_MSG_NOTICE(checking whether ACL support is available:)
535         case "$host_os" in
536         *sysv5*)
537                 AC_MSG_NOTICE(Using UnixWare ACLs)
538                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
539                 ;;
540         *solaris*)
541                 AC_MSG_NOTICE(Using solaris ACLs)
542                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
543                 ACL_LIBS="$ACL_LIBS -lsec"
544                 ;;
545         *hpux*)
546                 AC_MSG_NOTICE(Using HPUX ACLs)
547                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
548                 ;;
549         *irix*)
550                 AC_MSG_NOTICE(Using IRIX ACLs)
551                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
552                 ;;
553         *aix*)
554                 AC_MSG_NOTICE(Using AIX ACLs)
555                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
556                 ;;
557         *osf*)
558                 AC_MSG_NOTICE(Using Tru64 ACLs)
559                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
560                 ACL_LIBS="$ACL_LIBS -lpacl"
561                 ;;
562         *darwin*)
563                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
564                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
565                 ;;
566         *)
567                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
568                 case "$host_os" in
569                 *linux*)
570                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
571                         ;;
572                 esac
573                 AC_CACHE_CHECK([for POSIX ACL support],netatalk_cv_HAVE_POSIX_ACLS,[
574                         acl_LIBS=$LIBS
575                         LIBS="$LIBS $ACL_LIBS"
576                         AC_TRY_LINK([
577                                 #include <sys/types.h>
578                                 #include <sys/acl.h>
579                         ],[
580                                 acl_t acl;
581                                 int entry_id;
582                                 acl_entry_t *entry_p;
583                                 return acl_get_entry(acl, entry_id, entry_p);
584                         ],
585                         [netatalk_cv_HAVE_POSIX_ACLS=yes],
586                         [netatalk_cv_HAVE_POSIX_ACLS=no
587                 with_acl_support=no])
588                         LIBS=$acl_LIBS
589                 ])
590                 if test x"$netatalk_cv_HAVE_POSIX_ACLS" = x"yes"; then
591                         AC_MSG_NOTICE(Using POSIX ACLs)
592                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
593                         AC_CACHE_CHECK([for acl_get_perm_np],netatalk_cv_HAVE_ACL_GET_PERM_NP,[
594                                 acl_LIBS=$LIBS
595                                 LIBS="$LIBS $ACL_LIBS"
596                                 AC_TRY_LINK([
597                                         #include <sys/types.h>
598                                         #include <sys/acl.h>
599                                 ],[
600                                         acl_permset_t permset_d;
601                                         acl_perm_t perm;
602                                         return acl_get_perm_np(permset_d, perm);
603                                 ],
604                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=yes],
605                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
606                                 LIBS=$acl_LIBS
607                         ])
608                         if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
609                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
610                         fi
611
612
613                        AC_CACHE_CHECK([for acl_from_mode], netatalk_cv_HAVE_ACL_FROM_MODE,[
614                                acl_LIBS=$LIBS
615                                LIBS="$LIBS $ACL_LIBS"
616                 AC_CHECK_FUNCS(acl_from_mode,
617                                [netatalk_cv_HAVE_ACL_FROM_MODE=yes],
618                                [netatalk_cv_HAVE_ACL_FROM_MODE=no])
619                                LIBS=$acl_LIBS
620                        ])
621                        if test x"netatalk_cv_HAVE_ACL_FROM_MODE" = x"yes"; then
622                                AC_DEFINE(HAVE_ACL_FROM_MODE,1,[Whether acl_from_mode() is available])
623                        fi
624
625                 else
626                         AC_MSG_NOTICE(ACL support is not avaliable)
627                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
628                 fi
629                 ;;
630     esac
631 fi
632
633 if test x"$with_acl_support" = x"yes" ; then
634    AC_CHECK_HEADERS([acl/libacl.h])
635     AC_DEFINE(HAVE_ACLS,1,[Whether ACLs support is available])
636     AC_SUBST(ACL_LIBS)
637 fi
638 ])
639
640 dnl Check for Extended Attributes support
641 AC_DEFUN([AC_NETATALK_EXTENDED_ATTRIBUTES], [
642 neta_cv_eas="ad"
643 neta_cv_eas_sys_found=no
644 neta_cv_eas_sys_not_found=no
645
646 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h sys/ea.h)
647
648 case "$this_os" in
649
650   *osf*)
651         AC_SEARCH_LIBS(getproplist, [proplist])
652         AC_CHECK_FUNCS([getproplist fgetproplist setproplist fsetproplist],
653                    [neta_cv_eas_sys_found=yes],
654                    [neta_cv_eas_sys_not_found=yes])
655         AC_CHECK_FUNCS([delproplist fdelproplist add_proplist_entry get_proplist_entry],,
656                    [neta_cv_eas_sys_not_found=yes])
657         AC_CHECK_FUNCS([sizeof_proplist_entry],,
658                    [neta_cv_eas_sys_not_found=yes])
659   ;;
660
661   *solaris*)
662         AC_CHECK_FUNCS([attropen],
663                    [neta_cv_eas_sys_found=yes],
664                    [neta_cv_eas_sys_not_found=yes])
665   ;;
666
667   'freebsd')
668     AC_CHECK_FUNCS([extattr_delete_fd extattr_delete_file extattr_delete_link],
669                    [neta_cv_eas_sys_found=yes],
670                    [neta_cv_eas_sys_not_found=yes])
671     AC_CHECK_FUNCS([extattr_get_fd extattr_get_file extattr_get_link],,
672                    [neta_cv_eas_sys_not_found=yes])
673     AC_CHECK_FUNCS([extattr_list_fd extattr_list_file extattr_list_link],,
674                    [neta_cv_eas_sys_not_found=yes])
675     AC_CHECK_FUNCS([extattr_set_fd extattr_set_file extattr_set_link],,
676                    [neta_cv_eas_sys_not_found=yes])
677   ;;
678
679   *freebsd4* | *dragonfly* )
680     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
681   ;;
682
683   *)
684         AC_SEARCH_LIBS(getxattr, [attr])
685
686     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
687        AC_CHECK_FUNCS([getxattr lgetxattr fgetxattr listxattr llistxattr],
688                       [neta_cv_eas_sys_found=yes],
689                       [neta_cv_eas_sys_not_found=yes])
690            AC_CHECK_FUNCS([flistxattr removexattr lremovexattr fremovexattr],,
691                       [neta_cv_eas_sys_not_found=yes])
692            AC_CHECK_FUNCS([setxattr lsetxattr fsetxattr],,
693                       [neta_cv_eas_sys_not_found=yes])
694     fi
695
696     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
697            AC_CHECK_FUNCS([getea fgetea lgetea listea flistea llistea],
698                       [neta_cv_eas_sys_found=yes],
699                       [neta_cv_eas_sys_not_found=yes])
700            AC_CHECK_FUNCS([removeea fremoveea lremoveea setea fsetea lsetea],,
701                       [neta_cv_eas_sys_not_found=yes])
702     fi
703
704     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
705            AC_CHECK_FUNCS([attr_get attr_list attr_set attr_remove],,
706                       [neta_cv_eas_sys_not_found=yes])
707        AC_CHECK_FUNCS([attr_getf attr_listf attr_setf attr_removef],,
708                       [neta_cv_eas_sys_not_found=yes])
709     fi
710   ;;
711 esac
712
713 # Do xattr functions take additional options like on Darwin?
714 if test x"$ac_cv_func_getxattr" = x"yes" ; then
715         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
716                 old_LIBS=$LIBS
717                 LIBS="$LIBS $ACL_LIBS"
718                 AC_TRY_COMPILE([
719                         #include <sys/types.h>
720                         #if HAVE_ATTR_XATTR_H
721                         #include <attr/xattr.h>
722                         #elif HAVE_SYS_XATTR_H
723                         #include <sys/xattr.h>
724                         #endif
725                 ],[
726                         getxattr(0, 0, 0, 0, 0, 0);
727                 ],
728                 [smb_attr_cv_xattr_add_opt=yes],
729                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
730         ])
731         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
732                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
733         fi
734 fi
735
736 if test "x$neta_cv_eas_sys_found" = "xyes" ; then
737    if test "x$neta_cv_eas_sys_not_found" != "xyes" ; then
738       neta_cv_eas="$neta_cv_eas | sys"
739    fi
740 fi
741 AC_DEFINE_UNQUOTED(EA_MODULES,["$neta_cv_eas"],[Available Extended Attributes modules])
742 ])
743
744 dnl Check for libsmbsharemodes from Samba for Samba/Netatalk access/deny/share modes interop
745 dnl Defines "neta_cv_have_smbshmd" to "yes" or "no"
746 dnl AC_SUBST's "SMB_SHAREMODES_CFLAGS" and "SMB_SHAREMODES_LDFLAGS"
747 dnl AM_CONDITIONAL's "USE_SMB_SHAREMODES"
748 AC_DEFUN([AC_NETATALK_SMB_SHAREMODES], [
749     neta_cv_have_smbshmd=no
750     AC_ARG_WITH(smbsharemodes-lib,
751                 [  --with-smbsharemodes-lib=PATH        PATH to libsmbsharemodes lib from Samba],
752                 [SMB_SHAREMODES_LDFLAGS="-L$withval -lsmbsharemodes"]
753     )
754     AC_ARG_WITH(smbsharemodes-include,
755                 [  --with-smbsharemodes-include=PATH    PATH to libsmbsharemodes header from Samba],
756                 [SMB_SHAREMODES_CFLAGS="-I$withval"]
757     )
758     AC_ARG_WITH(smbsharemodes,
759                 [AS_HELP_STRING([--with-smbsharemodes],[Samba interop (default is yes)])],
760                 [use_smbsharemodes=$withval],
761                 [use_smbsharemodes=yes]
762     )
763
764     if test x"$use_smbsharemodes" = x"yes" ; then
765         AC_MSG_CHECKING([whether to enable Samba/Netatalk access/deny/share-modes interop])
766
767         saved_CFLAGS="$CFLAGS"
768         saved_LDFLAGS="$LDFLAGS"
769         CFLAGS="$SMB_SHAREMODES_CFLAGS $CFLAGS"
770         LDFLAGS="$SMB_SHAREMODES_LDFLAGS $LDFLAGS"
771
772         AC_LINK_IFELSE(
773             [#include <unistd.h>
774              #include <stdio.h>
775              #include <sys/time.h>
776              #include <time.h>
777              #include <stdint.h>
778              /* From messages.h */
779              struct server_id {
780                  pid_t pid;
781              };
782              #include "smb_share_modes.h"
783              int main(void) { (void)smb_share_mode_db_open(""); return 0;}],
784             [neta_cv_have_smbshmd=yes]
785         )
786
787         AC_MSG_RESULT($neta_cv_have_smbshmd)
788         AC_SUBST(SMB_SHAREMODES_CFLAGS, [$SMB_SHAREMODES_CFLAGS])
789         AC_SUBST(SMB_SHAREMODES_LDFLAGS, [$SMB_SHAREMODES_LDFLAGS])
790         CFLAGS="$saved_CFLAGS"
791         LDFLAGS="$saved_LDFLAGS"
792     fi
793
794     AM_CONDITIONAL(USE_SMB_SHAREMODES, test x"$neta_cv_have_smbshmd" = x"yes")
795 ])