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