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