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