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