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