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