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