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