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