]> arthur.barton.de Git - netatalk.git/blob - macros/netatalk.m4
Merge remote branch 'netafp/master' into branch-allea
[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     AC_DEFINE(NO_DDP, 1, [Define if DDP should be disabled])
292 fi
293
294 dnl ----- NetBSD specific -----
295 if test x"$this_os" = "xnetbsd"; then 
296         AC_MSG_RESULT([ * NetBSD specific configuration])
297         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
298         AC_DEFINE(NETBSD, 1, [Define if OS is NetBSD])
299     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EFTYPE, errno returned by open with O_NOFOLLOW)
300
301         CFLAGS="-I\$(top_srcdir)/sys/netbsd $CFLAGS"
302         need_dash_r=yes 
303
304         dnl ----- NetBSD does not have crypt.h, uses unistd.h -----
305         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
306 fi
307
308 dnl ----- OpenBSD specific -----
309 if test x"$this_os" = "xopenbsd"; then 
310         AC_MSG_RESULT([ * OpenBSD specific configuration])
311         dnl ----- OpenBSD does not have crypt.h, uses unistd.h -----
312         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
313 fi
314
315 dnl ----- Solaris specific -----
316 if test x"$this_os" = "xsolaris"; then 
317         AC_MSG_RESULT([ * Solaris specific configuration])
318         AC_DEFINE(__svr4__, 1, [Solaris compatibility macro])
319         AC_DEFINE(_ISOC9X_SOURCE, 1, [Compatibility macro])
320         AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
321         AC_DEFINE(SOLARIS, 1, [Solaris compatibility macro])
322         CFLAGS="-I\$(top_srcdir)/sys/generic $CFLAGS"
323         need_dash_r=yes
324         sysv_style=solaris
325
326         solaris_module=no
327         AC_MSG_CHECKING([if we can build Solaris kernel module])
328         if test -x /usr/ccs/bin/ld && test x"$netatalk_cv_ddp_enabled" = x"yes" ; then
329                 solaris_module=yes
330         fi
331         AC_MSG_RESULT([$solaris_module])
332
333         COMPILE_64BIT_KMODULE=no
334         KCFLAGS=""
335         KLDFLAGS=""
336         COMPILE_KERNEL_GCC=no
337
338         if test "$solaris_module" = "yes"; then
339            dnl Solaris kernel module stuff
340            AC_MSG_CHECKING([if we have to build a 64bit kernel module])
341
342            # check for isainfo, if not found it has to be a 32 bit kernel (<=2.6)       
343            if test -x /usr/bin/isainfo; then
344                 # check for 64 bit platform
345                 if isainfo -kv | grep '^64-bit'; then
346                         COMPILE_64BIT_KMODULE=yes
347                 fi
348            fi
349
350            AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
351
352            if test "${GCC}" = yes; then
353                 COMPILE_KERNEL_GCC=yes
354                 if test "$COMPILE_64BIT_KMODULE" = yes; then
355                 
356                         AC_MSG_CHECKING([if we can build a 64bit kernel module])
357                         
358                         case `$CC --version 2>/dev/null` in
359                         [[12]].* | 3.0.*)
360                                 COMPILE_64BIT_KMODULE=no
361                                 COMPILE_KERNEL_GCC=no   
362                                 solaris_module=no;;
363                         *)
364                                 # use for 64 bit
365                                 KCFLAGS="-m64"
366                                 #KLDFLAGS="-melf64_sparc"
367                                 KLDFLAGS="-64";;
368                         esac    
369                         
370                         AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
371                         
372                 else
373                         KCFLAGS=""
374                         KLDFLAGS=""
375                 fi
376                 KCFLAGS="$KCFLAGS -D_KERNEL -Wall -Wstrict-prototypes"
377            else
378                 if test "$COMPILE_64BIT_KMODULE" = yes; then
379                 # use Sun CC (for a 64-bit kernel, uncomment " -xarch=v9 -xregs=no%appl ")
380                         KCFLAGS="-xarch=v9 -xregs=no%appl"
381                         KLDFLAGS="-64"
382                 else
383                         KCFLAGS=""
384                         KLDFLAGS=""
385                 fi
386                 KCFLAGS="-D_KERNEL $KCFLAGS -mno-app-regs -munaligned-doubles -fpcc-struct-return"
387            fi
388
389            AC_CACHE_CHECK([for timeout_id_t],netatalk_cv_HAVE_TIMEOUT_ID_T,[
390            AC_TRY_LINK([\
391 #include <sys/stream.h>
392 #include <sys/ddi.h>],
393 [\
394 timeout_id_t dummy;
395 ],
396 netatalk_cv_HAVE_TIMEOUT_ID_T=yes,netatalk_cv_HAVE_TIMEOUT_ID_T=no,netatalk_cv_HAVE_TIMEOUT_ID_T=cross)])
397
398            AC_DEFINE(HAVE_TIMEOUT_ID_T, test x"$netatalk_cv_HAVE_TIMEOUT_ID" = x"yes", [define for timeout_id_t])
399         fi
400
401         AC_SUBST(COMPILE_KERNEL_GCC)
402         AC_SUBST(COMPILE_64BIT_KMODULE)
403         AC_SUBST(KCFLAGS)
404         AC_SUBST(KLDFLAGS)
405 fi
406
407 ])
408
409 dnl Check for building PGP UAM module
410 AC_DEFUN([AC_NETATALK_PGP_UAM], [
411 AC_MSG_CHECKING([whether the PGP UAM should be build])
412 AC_ARG_ENABLE(pgp-uam,
413         [  --enable-pgp-uam        enable build of PGP UAM module],[
414         if test "$enableval" = "yes"; then 
415                 if test "x$neta_cv_have_openssl" = "xyes"; then 
416                         AC_DEFINE(UAM_PGP, 1, [Define if the PGP UAM module should be compiled])
417                         compile_pgp=yes
418                         AC_MSG_RESULT([yes])
419                 else
420                         AC_MSG_RESULT([no])
421                 fi
422         fi
423         ],[
424                 AC_MSG_RESULT([no])
425         ]
426 )
427 ])
428
429 dnl Check for building Kerberos V UAM module
430 AC_DEFUN([AC_NETATALK_KRB5_UAM], [
431 netatalk_cv_build_krb5_uam=no
432 AC_ARG_ENABLE(krbV-uam,
433         [  --enable-krbV-uam       enable build of Kerberos V UAM module],
434         [
435                 if test x"$enableval" = x"yes"; then
436                         NETATALK_GSSAPI_CHECK([
437                                 netatalk_cv_build_krb5_uam=yes
438                         ],[
439                                 AC_MSG_ERROR([need GSSAPI to build Kerberos V UAM])
440                         ])
441                 fi
442         ]
443         
444 )
445
446 AC_MSG_CHECKING([whether Kerberos V UAM should be build])
447 if test x"$netatalk_cv_build_krb5_uam" = x"yes"; then
448         AC_MSG_RESULT([yes])
449 else
450         AC_MSG_RESULT([no])
451 fi
452 AM_CONDITIONAL(USE_GSSAPI, test x"$netatalk_cv_build_krb5_uam" = x"yes")
453 ])
454
455 dnl Check for overwrite the config files or not
456 AC_DEFUN([AC_NETATALK_OVERWRITE_CONFIG], [
457 AC_MSG_CHECKING([whether configuration files should be overwritten])
458 AC_ARG_ENABLE(overwrite,
459         [  --enable-overwrite      overwrite configuration files during installation],
460         [OVERWRITE_CONFIG="${enable_overwrite}"],
461         [OVERWRITE_CONFIG="no"]
462 )
463 AC_MSG_RESULT([$OVERWRITE_CONFIG])
464 AC_SUBST(OVERWRITE_CONFIG)
465 ])
466
467 dnl Check for LDAP support, for client-side ACL visibility
468 AC_DEFUN([AC_NETATALK_LDAP], [
469 AC_MSG_CHECKING(for LDAP (necessary for client-side ACL visibility))
470 AC_ARG_WITH(ldap,
471     [AS_HELP_STRING([--with-ldap],
472         [LDAP support (default=auto)])],
473     [ case "$withval" in
474       yes|no)
475           with_ldap="$withval"
476                   ;;
477       *)
478           with_ldap=auto
479           ;;
480       esac ])
481 AC_MSG_RESULT($with_ldap)
482
483 if test x"$with_ldap" != x"no" ; then
484         AC_CHECK_HEADER([ldap.h], with_ldap=yes,
485         [ if test x"$with_ldap" = x"yes" ; then
486             AC_MSG_ERROR([Missing LDAP headers])
487         fi
488                 with_ldap=no
489         ])
490         AC_CHECK_LIB(ldap, ldap_init, with_ldap=yes,
491         [ if test x"$with_ldap" = x"yes" ; then
492             AC_MSG_ERROR([Missing LDAP library])
493         fi
494                 with_ldap=no
495         ])
496 fi
497
498 if test x"$with_ldap" = x"yes"; then
499         AC_DEFINE(HAVE_LDAP,1,[Whether LDAP is available])
500 fi
501 ])
502
503 dnl Check for ACL support
504 AC_DEFUN([AC_NETATALK_ACL], [
505 AC_MSG_CHECKING(whether to support ACLs)
506 AC_ARG_WITH(acls,
507     [AS_HELP_STRING([--with-acls],
508         [Include ACL support (default=auto)])],
509     [ case "$withval" in
510       yes|no)
511           with_acl_support="$withval"
512                   ;;
513       *)
514           with_acl_support=auto
515           ;;
516       esac ],
517     [with_acl_support=auto])
518 AC_MSG_RESULT($with_acl_support)
519
520 if test x"$with_acl_support" = x"no"; then
521         AC_MSG_RESULT(Disabling ACL support)
522         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
523 else
524     with_acl_support=yes
525 fi
526
527 if test x"$with_acl_support" = x"yes" ; then
528         AC_MSG_NOTICE(checking whether ACL support is available:)
529         case "$host_os" in
530         *sysv5*)
531                 AC_MSG_NOTICE(Using UnixWare ACLs)
532                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
533                 ;;
534         *solaris*)
535                 AC_MSG_NOTICE(Using solaris ACLs)
536                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
537                 ACL_LIBS="$ACL_LIBS -lsec"
538                 ;;
539         *hpux*)
540                 AC_MSG_NOTICE(Using HPUX ACLs)
541                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
542                 ;;
543         *irix*)
544                 AC_MSG_NOTICE(Using IRIX ACLs)
545                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
546                 ;;
547         *aix*)
548                 AC_MSG_NOTICE(Using AIX ACLs)
549                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
550                 ;;
551         *osf*)
552                 AC_MSG_NOTICE(Using Tru64 ACLs)
553                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
554                 ACL_LIBS="$ACL_LIBS -lpacl"
555                 ;;
556         *darwin*)
557                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
558                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
559                 ;;
560         *)
561                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
562                 case "$host_os" in
563                 *linux*)
564                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
565                         ;;
566                 esac
567                 AC_CACHE_CHECK([for POSIX ACL support],netatalk_cv_HAVE_POSIX_ACLS,[
568                         acl_LIBS=$LIBS
569                         LIBS="$LIBS $ACL_LIBS"
570                         AC_TRY_LINK([
571                                 #include <sys/types.h>
572                                 #include <sys/acl.h>
573                         ],[
574                                 acl_t acl;
575                                 int entry_id;
576                                 acl_entry_t *entry_p;
577                                 return acl_get_entry(acl, entry_id, entry_p);
578                         ],
579                         [netatalk_cv_HAVE_POSIX_ACLS=yes],
580                         [netatalk_cv_HAVE_POSIX_ACLS=no
581                 with_acl_support=no])
582                         LIBS=$acl_LIBS
583                 ])
584                 if test x"$netatalk_cv_HAVE_POSIX_ACLS" = x"yes"; then
585                         AC_MSG_NOTICE(Using POSIX ACLs)
586                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
587                         AC_CACHE_CHECK([for acl_get_perm_np],netatalk_cv_HAVE_ACL_GET_PERM_NP,[
588                                 acl_LIBS=$LIBS
589                                 LIBS="$LIBS $ACL_LIBS"
590                                 AC_TRY_LINK([
591                                         #include <sys/types.h>
592                                         #include <sys/acl.h>
593                                 ],[
594                                         acl_permset_t permset_d;
595                                         acl_perm_t perm;
596                                         return acl_get_perm_np(permset_d, perm);
597                                 ],
598                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=yes],
599                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
600                                 LIBS=$acl_LIBS
601                         ])
602                         if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
603                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
604                         fi
605
606
607                        AC_CACHE_CHECK([for acl_from_mode], netatalk_cv_HAVE_ACL_FROM_MODE,[
608                                acl_LIBS=$LIBS
609                                LIBS="$LIBS $ACL_LIBS"
610                 AC_CHECK_FUNCS(acl_from_mode,
611                                [netatalk_cv_HAVE_ACL_FROM_MODE=yes],
612                                [netatalk_cv_HAVE_ACL_FROM_MODE=no])
613                                LIBS=$acl_LIBS
614                        ])
615                        if test x"netatalk_cv_HAVE_ACL_FROM_MODE" = x"yes"; then
616                                AC_DEFINE(HAVE_ACL_FROM_MODE,1,[Whether acl_from_mode() is available])
617                        fi
618
619                 else
620                         AC_MSG_NOTICE(ACL support is not avaliable)
621                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
622                 fi
623                 ;;
624     esac
625 fi
626
627 if test x"$with_acl_support" = x"yes" ; then
628    AC_CHECK_HEADERS([acl/libacl.h])
629     AC_DEFINE(HAVE_ACLS,1,[Whether ACLs support is available])
630     AC_SUBST(ACL_LIBS)
631 fi
632 ])
633
634 dnl Check for Extended Attributes support
635 AC_DEFUN([AC_NETATALK_EXTENDED_ATTRIBUTES], [
636 neta_cv_eas="ad"
637 neta_cv_eas_sys_found=no
638 neta_cv_eas_sys_not_found=no
639
640 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h sys/ea.h)
641
642 case "$this_os" in
643
644   *osf*)
645         AC_SEARCH_LIBS(getproplist, [proplist])
646         AC_CHECK_FUNCS([getproplist fgetproplist setproplist fsetproplist],
647                    [neta_cv_eas_sys_found=yes],
648                    [neta_cv_eas_sys_not_found=yes])
649         AC_CHECK_FUNCS([delproplist fdelproplist add_proplist_entry get_proplist_entry],,
650                    [neta_cv_eas_sys_not_found=yes])
651         AC_CHECK_FUNCS([sizeof_proplist_entry],,
652                    [neta_cv_eas_sys_not_found=yes])
653   ;;
654
655   *solaris*)
656         AC_CHECK_FUNCS([attropen],
657                    [neta_cv_eas_sys_found=yes],
658                    [neta_cv_eas_sys_not_found=yes])
659   ;;
660
661   'freebsd')
662     AC_CHECK_FUNCS([extattr_delete_fd extattr_delete_file extattr_delete_link],
663                    [neta_cv_eas_sys_found=yes],
664                    [neta_cv_eas_sys_not_found=yes])
665     AC_CHECK_FUNCS([extattr_get_fd extattr_get_file extattr_get_link],,
666                    [neta_cv_eas_sys_not_found=yes])
667     AC_CHECK_FUNCS([extattr_list_fd extattr_list_file extattr_list_link],,
668                    [neta_cv_eas_sys_not_found=yes])
669     AC_CHECK_FUNCS([extattr_set_fd extattr_set_file extattr_set_link],,
670                    [neta_cv_eas_sys_not_found=yes])
671   ;;
672
673   *freebsd4* | *dragonfly* )
674     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
675   ;;
676
677   *)
678         AC_SEARCH_LIBS(getxattr, [attr])
679
680     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
681        AC_CHECK_FUNCS([getxattr lgetxattr fgetxattr listxattr llistxattr],
682                       [neta_cv_eas_sys_found=yes],
683                       [neta_cv_eas_sys_not_found=yes])
684            AC_CHECK_FUNCS([flistxattr removexattr lremovexattr fremovexattr],,
685                       [neta_cv_eas_sys_not_found=yes])
686            AC_CHECK_FUNCS([setxattr lsetxattr fsetxattr],,
687                       [neta_cv_eas_sys_not_found=yes])
688     fi
689
690     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
691            AC_CHECK_FUNCS([getea fgetea lgetea listea flistea llistea],
692                       [neta_cv_eas_sys_found=yes],
693                       [neta_cv_eas_sys_not_found=yes])
694            AC_CHECK_FUNCS([removeea fremoveea lremoveea setea fsetea lsetea],,
695                       [neta_cv_eas_sys_not_found=yes])
696     fi
697
698     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
699            AC_CHECK_FUNCS([attr_get attr_list attr_set attr_remove],,
700                       [neta_cv_eas_sys_not_found=yes])
701        AC_CHECK_FUNCS([attr_getf attr_listf attr_setf attr_removef],,
702                       [neta_cv_eas_sys_not_found=yes])
703     fi
704   ;;
705 esac
706
707 # Do xattr functions take additional options like on Darwin?
708 if test x"$ac_cv_func_getxattr" = x"yes" ; then
709         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
710                 old_LIBS=$LIBS
711                 LIBS="$LIBS $ACL_LIBS"
712                 AC_TRY_COMPILE([
713                         #include <sys/types.h>
714                         #if HAVE_ATTR_XATTR_H
715                         #include <attr/xattr.h>
716                         #elif HAVE_SYS_XATTR_H
717                         #include <sys/xattr.h>
718                         #endif
719                 ],[
720                         getxattr(0, 0, 0, 0, 0, 0);
721                 ],
722                 [smb_attr_cv_xattr_add_opt=yes],
723                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
724         ])
725         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
726                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
727         fi
728 fi
729
730 if test "x$neta_cv_eas_sys_found" = "xyes" ; then
731    if test "x$neta_cv_eas_sys_not_found" != "xyes" ; then
732       neta_cv_eas="$neta_cv_eas | sys"
733    fi
734 fi
735 AC_DEFINE_UNQUOTED(EA_MODULES,["$neta_cv_eas"],[Available Extended Attributes modules])
736 ])
737
738 dnl Check for libsmbsharemodes from Samba for Samba/Netatalk access/deny/share modes interop
739 dnl Defines "neta_cv_have_smbshmd" to "yes" or "no"
740 dnl AC_SUBST's "SMB_SHAREMODES_CFLAGS" and "SMB_SHAREMODES_LDFLAGS"
741 dnl AM_CONDITIONAL's "USE_SMB_SHAREMODES"
742 AC_DEFUN([AC_NETATALK_SMB_SHAREMODES], [
743     neta_cv_have_smbshmd=no
744     AC_ARG_WITH(smbsharemodes-lib,
745                 [  --with-smbsharemodes-lib=PATH        PATH to libsmbsharemodes lib from Samba],
746                 [SMB_SHAREMODES_LDFLAGS="-L$withval -lsmbsharemodes"]
747     )
748     AC_ARG_WITH(smbsharemodes-include,
749                 [  --with-smbsharemodes-include=PATH    PATH to libsmbsharemodes header from Samba],
750                 [SMB_SHAREMODES_CFLAGS="-I$withval"]
751     )
752     AC_ARG_WITH(smbsharemodes,
753                 [AS_HELP_STRING([--with-smbsharemodes],[Samba interop (default is yes)])],
754                 [use_smbsharemodes=$withval],
755                 [use_smbsharemodes=yes]
756     )
757
758     if test x"$use_smbsharemodes" = x"yes" ; then
759         AC_MSG_CHECKING([whether to enable Samba/Netatalk access/deny/share-modes interop])
760
761         saved_CFLAGS="$CFLAGS"
762         saved_LDFLAGS="$LDFLAGS"
763         CFLAGS="$SMB_SHAREMODES_CFLAGS $CFLAGS"
764         LDFLAGS="$SMB_SHAREMODES_LDFLAGS $LDFLAGS"
765
766         AC_LINK_IFELSE(
767             [#include <unistd.h>
768              #include <stdio.h>
769              #include <sys/time.h>
770              #include <time.h>
771              #include <stdint.h>
772              /* From messages.h */
773              struct server_id {
774                  pid_t pid;
775              };
776              #include "smb_share_modes.h"
777              int main(void) { (void)smb_share_mode_db_open(""); return 0;}],
778             [neta_cv_have_smbshmd=yes]
779         )
780
781         AC_MSG_RESULT($neta_cv_have_smbshmd)
782         AC_SUBST(SMB_SHAREMODES_CFLAGS, [$SMB_SHAREMODES_CFLAGS])
783         AC_SUBST(SMB_SHAREMODES_LDFLAGS, [$SMB_SHAREMODES_LDFLAGS])
784         CFLAGS="$saved_CFLAGS"
785         LDFLAGS="$saved_LDFLAGS"
786     fi
787
788     AM_CONDITIONAL(USE_SMB_SHAREMODES, test x"$neta_cv_have_smbshmd" = x"yes")
789 ])