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