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