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