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