]> arthur.barton.de Git - netatalk.git/blob - macros/netatalk.m4
Merge branch-allea
[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 AC_DEFUN([AC_NETATALK_KERBEROS], [
493 AC_MSG_CHECKING([for Kerberos 5 (necessary for GetSrvrInfo:DirectoryNames support)])
494 AC_ARG_WITH([kerberos],
495     [AS_HELP_STRING([--with-kerberos], [Kerberos 5 support (default=auto)])],
496     [],
497     [with_kerberos=auto])
498 AC_MSG_RESULT($with_kerberos)
499
500 if test x"$with_kerberos" != x"no"; then
501    have_krb5_header="no"
502    AC_CHECK_HEADERS([krb5/krb5.h krb5.h], [have_krb5_header="yes"; break])
503    if test x"$have_krb5_header" = x"no" && test x"$with_kerberos" != x"auto"; then
504       AC_MSG_FAILURE([--with-kerberos was given, but no headers found])
505    fi
506
507    AC_PATH_PROG([KRB5_CONFIG], [krb5-config])
508    AC_MSG_CHECKING([for krb5-config])
509    if test -x "$KRB5_CONFIG"; then
510       AC_MSG_RESULT([$KRB5_CONFIG])
511       CFLAGS="$CFLAGS `$KRB5_CONFIG --cflags krb5`"
512       LIBS="`$KRB5_CONFIG --libs krb5` $LIBS"
513       with_kerberos="yes"
514    else
515       AC_MSG_RESULT([not found])
516       if test x"$with_kerberos" != x"auto"; then
517          AC_MSG_FAILURE([--with-kerberos was given, but krb5-config could not be found])
518       fi
519    fi
520 fi
521
522 if test x"$with_kerberos" = x"yes"; then
523    AC_DEFINE([HAVE_KERBEROS], [1], [Define if Kerberos 5 is available])
524 fi
525 ])
526
527 dnl Check for overwrite the config files or not
528 AC_DEFUN([AC_NETATALK_OVERWRITE_CONFIG], [
529 AC_MSG_CHECKING([whether configuration files should be overwritten])
530 AC_ARG_ENABLE(overwrite,
531         [  --enable-overwrite      overwrite configuration files during installation],
532         [OVERWRITE_CONFIG="${enable_overwrite}"],
533         [OVERWRITE_CONFIG="no"]
534 )
535 AC_MSG_RESULT([$OVERWRITE_CONFIG])
536 AC_SUBST(OVERWRITE_CONFIG)
537 ])
538
539 dnl Check for LDAP support, for client-side ACL visibility
540 AC_DEFUN([AC_NETATALK_LDAP], [
541 AC_MSG_CHECKING(for LDAP (necessary for client-side ACL visibility))
542 AC_ARG_WITH(ldap,
543     [AS_HELP_STRING([--with-ldap],
544         [LDAP support (default=auto)])],
545     [ case "$withval" in
546       yes|no)
547           with_ldap="$withval"
548                   ;;
549       *)
550           with_ldap=auto
551           ;;
552       esac ])
553 AC_MSG_RESULT($with_ldap)
554
555 if test x"$with_ldap" != x"no" ; then
556         AC_CHECK_HEADER([ldap.h], with_ldap=yes,
557         [ if test x"$with_ldap" = x"yes" ; then
558             AC_MSG_ERROR([Missing LDAP headers])
559         fi
560                 with_ldap=no
561         ])
562         AC_CHECK_LIB(ldap, ldap_init, with_ldap=yes,
563         [ if test x"$with_ldap" = x"yes" ; then
564             AC_MSG_ERROR([Missing LDAP library])
565         fi
566                 with_ldap=no
567         ])
568 fi
569
570 if test x"$with_ldap" = x"yes"; then
571         AC_DEFINE(HAVE_LDAP,1,[Whether LDAP is available])
572 fi
573 ])
574
575 dnl Check for ACL support
576 AC_DEFUN([AC_NETATALK_ACL], [
577 AC_MSG_CHECKING(whether to support ACLs)
578 AC_ARG_WITH(acls,
579     [AS_HELP_STRING([--with-acls],
580         [Include ACL support (default=auto)])],
581     [ case "$withval" in
582       yes|no)
583           with_acl_support="$withval"
584                   ;;
585       *)
586           with_acl_support=auto
587           ;;
588       esac ],
589     [with_acl_support=auto])
590 AC_MSG_RESULT($with_acl_support)
591
592 if test x"$with_acl_support" = x"no"; then
593         AC_MSG_RESULT(Disabling ACL support)
594         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
595 else
596     with_acl_support=yes
597 fi
598
599 if test x"$with_acl_support" = x"yes" ; then
600         AC_MSG_NOTICE(checking whether ACL support is available:)
601         case "$host_os" in
602         *sysv5*)
603                 AC_MSG_NOTICE(Using UnixWare ACLs)
604                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
605                 ;;
606         *solaris*)
607                 AC_MSG_NOTICE(Using solaris ACLs)
608                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
609                 ACL_LIBS="$ACL_LIBS -lsec"
610                 ;;
611         *hpux*)
612                 AC_MSG_NOTICE(Using HPUX ACLs)
613                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
614                 ;;
615         *irix*)
616                 AC_MSG_NOTICE(Using IRIX ACLs)
617                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
618                 ;;
619         *aix*)
620                 AC_MSG_NOTICE(Using AIX ACLs)
621                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
622                 ;;
623         *osf*)
624                 AC_MSG_NOTICE(Using Tru64 ACLs)
625                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
626                 ACL_LIBS="$ACL_LIBS -lpacl"
627                 ;;
628         *darwin*)
629                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
630                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
631                 ;;
632         *)
633                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
634                 case "$host_os" in
635                 *linux*)
636                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
637                         ;;
638                 esac
639                 AC_CACHE_CHECK([for POSIX ACL support],netatalk_cv_HAVE_POSIX_ACLS,[
640                         acl_LIBS=$LIBS
641                         LIBS="$LIBS $ACL_LIBS"
642                         AC_TRY_LINK([
643                                 #include <sys/types.h>
644                                 #include <sys/acl.h>
645                         ],[
646                                 acl_t acl;
647                                 int entry_id;
648                                 acl_entry_t *entry_p;
649                                 return acl_get_entry(acl, entry_id, entry_p);
650                         ],
651                         [netatalk_cv_HAVE_POSIX_ACLS=yes],
652                         [netatalk_cv_HAVE_POSIX_ACLS=no
653                 with_acl_support=no])
654                         LIBS=$acl_LIBS
655                 ])
656                 if test x"$netatalk_cv_HAVE_POSIX_ACLS" = x"yes"; then
657                         AC_MSG_NOTICE(Using POSIX ACLs)
658                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
659                         AC_CACHE_CHECK([for acl_get_perm_np],netatalk_cv_HAVE_ACL_GET_PERM_NP,[
660                                 acl_LIBS=$LIBS
661                                 LIBS="$LIBS $ACL_LIBS"
662                                 AC_TRY_LINK([
663                                         #include <sys/types.h>
664                                         #include <sys/acl.h>
665                                 ],[
666                                         acl_permset_t permset_d;
667                                         acl_perm_t perm;
668                                         return acl_get_perm_np(permset_d, perm);
669                                 ],
670                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=yes],
671                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
672                                 LIBS=$acl_LIBS
673                         ])
674                         if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
675                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
676                         fi
677
678
679                        AC_CACHE_CHECK([for acl_from_mode], netatalk_cv_HAVE_ACL_FROM_MODE,[
680                                acl_LIBS=$LIBS
681                                LIBS="$LIBS $ACL_LIBS"
682                 AC_CHECK_FUNCS(acl_from_mode,
683                                [netatalk_cv_HAVE_ACL_FROM_MODE=yes],
684                                [netatalk_cv_HAVE_ACL_FROM_MODE=no])
685                                LIBS=$acl_LIBS
686                        ])
687                        if test x"netatalk_cv_HAVE_ACL_FROM_MODE" = x"yes"; then
688                                AC_DEFINE(HAVE_ACL_FROM_MODE,1,[Whether acl_from_mode() is available])
689                        fi
690
691                 else
692                         AC_MSG_NOTICE(ACL support is not avaliable)
693                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
694                 fi
695                 ;;
696     esac
697 fi
698
699 if test x"$with_acl_support" = x"yes" ; then
700    AC_CHECK_HEADERS([acl/libacl.h])
701     AC_DEFINE(HAVE_ACLS,1,[Whether ACLs support is available])
702     AC_SUBST(ACL_LIBS)
703 fi
704 ])
705
706 dnl Check for Extended Attributes support
707 AC_DEFUN([AC_NETATALK_EXTENDED_ATTRIBUTES], [
708 neta_cv_eas="ad"
709 neta_cv_eas_sys_found=no
710 neta_cv_eas_sys_not_found=no
711
712 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h sys/ea.h)
713
714 case "$this_os" in
715
716   *osf*)
717         AC_SEARCH_LIBS(getproplist, [proplist])
718         AC_CHECK_FUNCS([getproplist fgetproplist setproplist fsetproplist],
719                    [neta_cv_eas_sys_found=yes],
720                    [neta_cv_eas_sys_not_found=yes])
721         AC_CHECK_FUNCS([delproplist fdelproplist add_proplist_entry get_proplist_entry],,
722                    [neta_cv_eas_sys_not_found=yes])
723         AC_CHECK_FUNCS([sizeof_proplist_entry],,
724                    [neta_cv_eas_sys_not_found=yes])
725   ;;
726
727   *solaris*)
728         AC_CHECK_FUNCS([attropen],
729                    [neta_cv_eas_sys_found=yes; AC_DEFINE(HAVE_EAFD, 1, [extattr API has full fledged fds for EAs])],
730                    [neta_cv_eas_sys_not_found=yes])
731   ;;
732
733   'freebsd')
734     AC_CHECK_FUNCS([extattr_delete_fd extattr_delete_file extattr_delete_link],
735                    [neta_cv_eas_sys_found=yes],
736                    [neta_cv_eas_sys_not_found=yes])
737     AC_CHECK_FUNCS([extattr_get_fd extattr_get_file extattr_get_link],,
738                    [neta_cv_eas_sys_not_found=yes])
739     AC_CHECK_FUNCS([extattr_list_fd extattr_list_file extattr_list_link],,
740                    [neta_cv_eas_sys_not_found=yes])
741     AC_CHECK_FUNCS([extattr_set_fd extattr_set_file extattr_set_link],,
742                    [neta_cv_eas_sys_not_found=yes])
743   ;;
744
745   *freebsd4* | *dragonfly* )
746     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
747   ;;
748
749   *)
750         AC_SEARCH_LIBS(getxattr, [attr])
751
752     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
753        AC_CHECK_FUNCS([getxattr lgetxattr fgetxattr listxattr llistxattr],
754                       [neta_cv_eas_sys_found=yes],
755                       [neta_cv_eas_sys_not_found=yes])
756            AC_CHECK_FUNCS([flistxattr removexattr lremovexattr fremovexattr],,
757                       [neta_cv_eas_sys_not_found=yes])
758            AC_CHECK_FUNCS([setxattr lsetxattr fsetxattr],,
759                       [neta_cv_eas_sys_not_found=yes])
760     fi
761
762     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
763            AC_CHECK_FUNCS([getea fgetea lgetea listea flistea llistea],
764                       [neta_cv_eas_sys_found=yes],
765                       [neta_cv_eas_sys_not_found=yes])
766            AC_CHECK_FUNCS([removeea fremoveea lremoveea setea fsetea lsetea],,
767                       [neta_cv_eas_sys_not_found=yes])
768     fi
769
770     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
771            AC_CHECK_FUNCS([attr_get attr_list attr_set attr_remove],,
772                       [neta_cv_eas_sys_not_found=yes])
773        AC_CHECK_FUNCS([attr_getf attr_listf attr_setf attr_removef],,
774                       [neta_cv_eas_sys_not_found=yes])
775     fi
776   ;;
777 esac
778
779 # Do xattr functions take additional options like on Darwin?
780 if test x"$ac_cv_func_getxattr" = x"yes" ; then
781         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
782                 old_LIBS=$LIBS
783                 LIBS="$LIBS $ACL_LIBS"
784                 AC_TRY_COMPILE([
785                         #include <sys/types.h>
786                         #if HAVE_ATTR_XATTR_H
787                         #include <attr/xattr.h>
788                         #elif HAVE_SYS_XATTR_H
789                         #include <sys/xattr.h>
790                         #endif
791                 ],[
792                         getxattr(0, 0, 0, 0, 0, 0);
793                 ],
794                 [smb_attr_cv_xattr_add_opt=yes],
795                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
796         ])
797         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
798                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
799         fi
800 fi
801
802 if test "x$neta_cv_eas_sys_found" = "xyes" ; then
803    if test "x$neta_cv_eas_sys_not_found" != "xyes" ; then
804       neta_cv_eas="$neta_cv_eas | sys"
805    fi
806 fi
807 AC_DEFINE_UNQUOTED(EA_MODULES,["$neta_cv_eas"],[Available Extended Attributes modules])
808 ])
809
810 dnl Check for libsmbsharemodes from Samba for Samba/Netatalk access/deny/share modes interop
811 dnl Defines "neta_cv_have_smbshmd" to "yes" or "no"
812 dnl AC_SUBST's "SMB_SHAREMODES_CFLAGS" and "SMB_SHAREMODES_LDFLAGS"
813 dnl AM_CONDITIONAL's "USE_SMB_SHAREMODES"
814 AC_DEFUN([AC_NETATALK_SMB_SHAREMODES], [
815     neta_cv_have_smbshmd=no
816     AC_ARG_WITH(smbsharemodes-lib,
817                 [  --with-smbsharemodes-lib=PATH        PATH to libsmbsharemodes lib from Samba],
818                 [SMB_SHAREMODES_LDFLAGS="-L$withval -lsmbsharemodes"]
819     )
820     AC_ARG_WITH(smbsharemodes-include,
821                 [  --with-smbsharemodes-include=PATH    PATH to libsmbsharemodes header from Samba],
822                 [SMB_SHAREMODES_CFLAGS="-I$withval"]
823     )
824     AC_ARG_WITH(smbsharemodes,
825                 [AS_HELP_STRING([--with-smbsharemodes],[Samba interop (default is yes)])],
826                 [use_smbsharemodes=$withval],
827                 [use_smbsharemodes=yes]
828     )
829
830     if test x"$use_smbsharemodes" = x"yes" ; then
831         AC_MSG_CHECKING([whether to enable Samba/Netatalk access/deny/share-modes interop])
832
833         saved_CFLAGS="$CFLAGS"
834         saved_LDFLAGS="$LDFLAGS"
835         CFLAGS="$SMB_SHAREMODES_CFLAGS $CFLAGS"
836         LDFLAGS="$SMB_SHAREMODES_LDFLAGS $LDFLAGS"
837
838         AC_LINK_IFELSE(
839             [#include <unistd.h>
840              #include <stdio.h>
841              #include <sys/time.h>
842              #include <time.h>
843              #include <stdint.h>
844              /* From messages.h */
845              struct server_id {
846                  pid_t pid;
847              };
848              #include "smb_share_modes.h"
849              int main(void) { (void)smb_share_mode_db_open(""); return 0;}],
850             [neta_cv_have_smbshmd=yes]
851         )
852
853         AC_MSG_RESULT($neta_cv_have_smbshmd)
854         AC_SUBST(SMB_SHAREMODES_CFLAGS, [$SMB_SHAREMODES_CFLAGS])
855         AC_SUBST(SMB_SHAREMODES_LDFLAGS, [$SMB_SHAREMODES_LDFLAGS])
856         CFLAGS="$saved_CFLAGS"
857         LDFLAGS="$saved_LDFLAGS"
858     fi
859
860     AM_CONDITIONAL(USE_SMB_SHAREMODES, test x"$neta_cv_have_smbshmd" = x"yes")
861 ])
862
863 dnl ------ Check for sendfile() --------
864 AC_DEFUN([AC_NETATALK_SENDFILE], [
865 netatalk_cv_search_sendfile=yes
866 AC_ARG_ENABLE(sendfile,
867     [  --disable-sendfile       disable sendfile syscall],
868     [if test x"$enableval" = x"no"; then
869             netatalk_cv_search_sendfile=no
870         fi]
871 )
872
873 if test x"$netatalk_cv_search_sendfile" = x"yes"; then
874    case "$host_os" in
875    *linux*)
876         AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
877         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
878         ;;
879
880     *solaris*)
881         AC_DEFINE(SENDFILE_FLAVOR_SOLARIS, 1, [Solaris sendfile()])
882         AC_SEARCH_LIBS(sendfile, sendfile)
883         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
884         ;;
885
886     *freebsd*)
887         AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
888         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
889         ;;
890
891     *)
892         ;;
893
894     esac
895
896     if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
897         AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
898     fi
899 fi
900 ])
901
902 dnl --------------------- Check if realpath() takes NULL
903 AC_DEFUN([AC_NETATALK_REALPATH], [
904 AC_CACHE_CHECK([if the realpath function allows a NULL argument],
905     neta_cv_REALPATH_TAKES_NULL, [
906         AC_TRY_RUN([
907             #include <stdio.h>
908             #include <limits.h>
909             #include <signal.h>
910
911             void exit_on_core(int ignored) {
912                  exit(1);
913             }
914
915             main() {
916                 char *newpath;
917                 signal(SIGSEGV, exit_on_core);
918                 newpath = realpath("/tmp", NULL);
919                 exit((newpath != NULL) ? 0 : 1);
920             }],
921             neta_cv_REALPATH_TAKES_NULL=yes,
922             neta_cv_REALPATH_TAKES_NULL=no,
923             neta_cv_REALPATH_TAKES_NULL=cross
924         )
925     ]
926 )
927
928 if test x"$neta_cv_REALPATH_TAKES_NULL" = x"yes"; then
929     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
930 fi
931 ])