]> arthur.barton.de Git - netatalk.git/blob - configure.ac
Add Solaris senfile() support and enable sendfile on FreeBSD
[netatalk.git] / configure.ac
1 dnl configure.in for netatalk
2
3 AC_INIT(etc/afpd/main.c)
4
5 NETATALK_VERSION=`cat $srcdir/VERSION`
6 AC_SUBST(NETATALK_VERSION)
7
8 AC_CANONICAL_SYSTEM
9 AM_INIT_AUTOMAKE(netatalk, ${NETATALK_VERSION})
10 AM_CONFIG_HEADER(config.h)
11 AM_MAINTAINER_MODE([enable])
12
13 dnl Checks for programs.
14 AC_PROG_AWK
15 AC_PROG_CC
16 AC_PROG_CC_C99
17 AC_PROG_INSTALL
18 AC_PROG_LN_S
19 AC_PROG_MAKE_SET
20 AC_LIBTOOL_DLOPEN
21 AC_PROG_LIBTOOL
22 AC_PROG_PERL
23 AC_PROG_GREP
24 AC_PROG_PS
25
26 AM_PROG_CC_C_O
27
28 dnl Checks for header files.
29 AC_HEADER_DIRENT
30 AC_HEADER_STDC
31 AC_HEADER_SYS_WAIT
32 AC_CHECK_HEADERS(fcntl.h limits.h stdint.h strings.h time.h sys/param.h sys/fcntl.h sys/file.h sys/ioctl.h sys/time.h sys/mnttab.h sys/statvfs.h sys/stat.h sys/vfs.h mntent.h syslog.h unistd.h termios.h sys/termios.h netdb.h sgtty.h ufs/quota.h mount.h statfs.h sys/types.h dlfcn.h errno.h sys/errno.h sys/uio.h langinfo.h locale.h sys/filio.h)
33 AC_CHECK_HEADER(sys/cdefs.h,,
34         AC_MSG_RESULT([enabling generic cdefs.h from tree])
35         CFLAGS="-I\$(top_srcdir)/sys/generic $CFLAGS"
36 )
37 AC_CHECK_HEADERS([sys/mount.h], , , 
38 [#ifdef HAVE_SYS_PARAM_H
39 #include <sys/param.h>
40 #endif
41 ])
42
43 dnl Checks for typedefs, structures, and compiler characteristics.
44 AC_C_CONST
45 AC_TYPE_UID_T
46 AC_C_INLINE
47 AC_TYPE_MODE_T
48 AC_TYPE_OFF_T
49 AC_TYPE_PID_T
50 AC_TYPE_SIZE_T
51 AC_STRUCT_ST_RDEV
52 AC_HEADER_TIME
53 AC_STRUCT_TM
54
55 dnl --------------------------------------------------------------------------
56 dnl check if dlsym needs to add an underscore, uses libtool macros 
57 dnl --------------------------------------------------------------------------
58 AC_LTDL_DLLIB
59 AC_CHECK_FUNCS(dlopen dlsym dlclose)
60 AC_LTDL_DLSYM_USCORE
61 if test x"$libltdl_cv_need_uscore" = xyes; then
62     AC_DEFINE(DLSYM_PREPEND_UNDERSCORE, 1, [BSD compatibility macro])
63 fi
64
65 dnl Checks for library functions.
66 AC_TYPE_GETGROUPS
67 AC_PROG_GCC_TRADITIONAL
68 AC_FUNC_MEMCMP
69 AC_HEADER_MAJOR
70 AC_FUNC_MMAP
71 AC_TYPE_SIGNAL
72 AC_FUNC_UTIME_NULL
73 AC_FUNC_WAIT3
74 AC_CHECK_FUNCS(getcwd gethostname gettimeofday getusershell mkdir rmdir select socket strdup strcasestr strstr strtoul strchr memcpy)
75 AC_CHECK_FUNCS(backtrace_symbols setlocale nl_langinfo strlcpy strlcat setlinebuf dirfd pselect access pread pwrite)
76 AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
77 ac_neta_haveatfuncs=yes
78 AC_CHECK_FUNCS(openat renameat fstatat unlinkat, , ac_neta_haveatfuncs=no)
79 if test x"$ac_neta_haveatfuncs" = x"yes" ; then
80    AC_DEFINE([_ATFILE_SOURCE], 1, AT file source)
81    AC_DEFINE([HAVE_ATFUNCS], 1, whether at funcs are available)
82 fi
83
84 AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, [#include <time.h>])
85
86 AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
87 AC_CHECK_FUNC(connect,,[AC_CHECK_LIB(socket,connect)])
88 dnl search for necessary libs for libpthread stuff
89 AC_SEARCH_LIBS(pthread_sigmask, pthread,, 
90                [AC_MSG_ERROR([cannot find pthread_sigmask in libc or libpthread])])
91 if test x"$ac_cv_search_pthread_sigmask" != x"none required" ; then
92    PTHREAD_LIBS=$ac_cv_search_pthread_sigmask
93 fi
94 AC_SUBST(PTHREAD_LIBS)
95 AC_CACHE_SAVE
96
97 dnl Checks for (v)snprintf
98 NETATALK_SNPRINTF_CHECK
99
100 dnl --------------------------------------------------------------------------
101 dnl 64bit platform check
102 dnl --------------------------------------------------------------------------
103
104 AC_MSG_CHECKING([whether to check for 64bit libraries])
105 # Test if the compiler is in 64bit mode
106 echo 'int i;' > conftest.$ac_ext
107 atalk_cv_cc_64bit_output=no
108 if AC_TRY_EVAL(ac_compile); then
109     case `/usr/bin/file conftest.$ac_objext` in
110     *"ELF 64"*)
111       atalk_cv_cc_64bit_output=yes
112       ;;
113     esac
114 fi
115 rm -rf conftest*
116
117 case $host_cpu:$atalk_cv_cc_64bit_output in
118 powerpc64:yes | s390x:yes | sparc*:yes | x86_64:yes | i386:yes)
119     case $target_os in
120     solaris2*)
121         AC_MSG_RESULT([yes])
122         atalk_libname="lib/64"
123         ;;
124     *bsd* | dragonfly*)
125         AC_MSG_RESULT([no])
126         atalk_libname="lib"
127         ;;
128     *)
129         AC_MSG_RESULT([yes])
130         atalk_libname="lib64"
131         ;;
132     esac
133     ;;
134 *:*)
135     AC_MSG_RESULT([no])
136     atalk_libname="lib"
137     ;;
138 esac
139
140 dnl --------------------------------------------------------------------------
141 dnl specific configuration comes in here:
142 dnl --------------------------------------------------------------------------
143
144
145 netatalk_cv_admin_group=yes
146 AC_MSG_CHECKING([for administrative group support])
147 AC_ARG_ENABLE(admin-group,
148         [  --disable-admin-group   disable admin group],[
149         if test x"$enableval" = x"no"; then
150                 AC_DEFINE(ADMIN_GRP, 0, [Define if the admin group should be enabled])
151                 netatalk_cv_admin_group=no
152                 AC_MSG_RESULT([no])
153         else
154                 AC_DEFINE(ADMIN_GRP, 1, [Define if the admin group should be enabled])
155                 AC_MSG_RESULT([yes])
156         fi],[
157                 AC_DEFINE(ADMIN_GRP, 1, [Define if the admin group should be enabled])
158                 AC_MSG_RESULT([yes])
159         ]
160 )
161
162 NETATALK_AFS_CHECK
163
164 NETATALK_CONFIG_DIRS
165
166 netatalk_cv_with_cracklib=no
167 AC_ARG_WITH(cracklib,
168         [  --with-cracklib=DICT    enable/set location of cracklib dictionary],[
169         if test "x$withval" != "xno" ; then
170                 cracklib="$withval"
171                 AC_CHECK_LIB(crack, main, [
172                         AC_DEFINE(USE_CRACKLIB, 1, [Define if cracklib should be used])
173                         LIBS="$LIBS -lcrack"
174                         if test "$cracklib" = "yes"; then
175                                 cracklib="/usr/$atalk_libname/cracklib_dict"
176                         fi
177                         AC_DEFINE_UNQUOTED(_PATH_CRACKLIB, "$cracklib",
178                                 [path to cracklib dictionary])
179                         AC_MSG_RESULT([setting cracklib dictionary to $cracklib])
180                         netatalk_cv_with_cracklib=yes
181                         ],[
182                         AC_MSG_ERROR([cracklib not found!])
183                         ]
184                 )
185         fi
186         ]
187 )
188 AC_MSG_CHECKING([for cracklib support])
189 AC_MSG_RESULT([$netatalk_cv_with_cracklib])
190
191 netatalk_cv_ddp_enabled=no
192 AC_MSG_CHECKING([whether to enable DDP])
193 AC_ARG_ENABLE(ddp,
194         [  --enable-ddp            enable DDP (AppleTalk)],[
195         if test "$enableval" = "yes"; then 
196                 AC_MSG_RESULT([yes])
197                 netatalk_cv_ddp_enabled=yes
198         else
199                 AC_MSG_RESULT([yes])
200                 AC_DEFINE(NO_DDP, 1, [Define if DDP should be disabled])
201         fi
202         ],[
203                 AC_MSG_RESULT([no])
204                 AC_DEFINE(NO_DDP, 1, [Define if DDP should be disabled])
205         ]
206 )
207
208 AC_MSG_CHECKING([whether to enable debug code])
209 AC_ARG_ENABLE(debug1,
210         [  --enable-debug1         enable debug code],[
211         if test "$enableval" != "no"; then
212                 if test "$enableval" = "yes"; then
213                         AC_DEFINE(DEBUG1, 1, [Define if debugging information should be included])
214                 else
215                         AC_DEFINE_UNQUOTED(DEBUG1, $enableval, [Define if debugging information should be included])
216                 fi 
217                 AC_MSG_RESULT([yes])
218         else
219                 AC_MSG_RESULT([no])
220         fi
221         ],[
222                 AC_MSG_RESULT([no])
223         ]
224 )
225
226 AC_MSG_CHECKING([whether to enable verbose debug code])
227 AC_ARG_ENABLE(debug,
228         [  --enable-debug          enable verbose debug code],[
229         if test "$enableval" != "no"; then
230                 if test "$enableval" = "yes"; then
231                         AC_DEFINE(DEBUG, 1, [Define if verbose debugging information should be included])
232                 else
233                         AC_DEFINE_UNQUOTED(DEBUG, $enableval, [Define if verbose debugging information should be included])
234                 fi 
235                 AC_MSG_RESULT([yes])
236         else
237                 AC_MSG_RESULT([no])
238         AC_DEFINE(NDEBUG, 1, [Disable assertions])
239         fi
240         ],[
241                 AC_MSG_RESULT([no])
242         AC_DEFINE(NDEBUG, 1, [Disable assertions])
243         ]
244 )
245
246 AC_MSG_CHECKING([whether to enable debugging with debuggers])
247 AC_ARG_ENABLE(debugging,
248         [  --enable-debugging      disable SIGALRM timers and DSI tickles (eg for debugging with gdb/dbx/...)],[
249         if test "$enableval" != "no"; then
250                 if test "$enableval" = "yes"; then
251                         AC_DEFINE(DEBUGGING, 1, [Define if you want to disable SIGALRM timers and DSI tickles])
252                 else
253                         AC_DEFINE_UNQUOTED(DEBUGGING, $enableval, [Define if you want to disable SIGALRM timers and DSI tickles])
254                 fi 
255                 AC_MSG_RESULT([yes])
256         else
257                 AC_MSG_RESULT([no])
258         fi
259         ],[
260                 AC_MSG_RESULT([no])
261         ]
262 )
263
264 AC_SYS_LARGEFILE([], AC_MSG_ERROR([AFP 3.x support requires Large File Support.]))
265 AC_CHECK_ICONV
266
267 dnl ----------- A NOTE ABOUT DROPKLUDGE
268 dnl The trouble with this fix is that if you know what the file is called, it
269 dnl can be read from the Unix side.  That's okay for most academic institutions
270 dnl since the students don't have telnet access to the Mac servers.  There is
271 dnl currently no one working on further development/fixes of DROPKLUDGE.
272 dnl -----------
273
274 netatalk_cv_dropkludge=no
275 AC_MSG_CHECKING([whether to enable experimental dropbox support])
276 AC_ARG_ENABLE(dropkludge,
277         [  --enable-dropkludge     enable the experimental dropbox fix (INSECURE!) ],[
278         if test "$enableval" = "yes"; then 
279                 AC_DEFINE(DROPKLUDGE, 1, [Define if you want to use the experimental dropkludge support])
280                 AC_MSG_RESULT([yes])
281                 netatalk_cv_dropkludge=yes
282         else
283                 AC_MSG_RESULT([no])
284         fi
285         ],[
286                 AC_MSG_RESULT([no])
287         ]
288 )
289
290 netatalk_cv_force_uidgid=no
291 AC_MSG_CHECKING([whether to enable forcing of uid/gid per volume])
292 AC_ARG_ENABLE(force-uidgid,
293         [  --enable-force-uidgid   allow forcing of uid/gid per volume (BROKEN) ],[
294         if test "$enableval" = "yes"; then
295                 AC_DEFINE(FORCE_UIDGID, 1, [Define if you want forcing of uid/gid per volume])
296                 AC_MSG_RESULT([enabling forcing of uid/gid per volume])
297                 AC_MSG_RESULT([yes])
298                 netatalk_cv_force_uidgid=yes
299         else
300                 AC_MSG_RESULT([no])
301         fi
302         ],[
303                 AC_MSG_RESULT([no])
304         ]
305 )
306
307 dnl Check for CNID database backends
308 bdb_required=no
309 AC_NETATALK_CNID([bdb_required=yes],[bdb_required=no])
310
311 dnl Check for quota support
312 AC_CHECK_QUOTA
313
314 dnl Check for optional server location protocol support (used by MacOS X)
315 NETATALK_SRVLOC
316
317 dnl Check for optional Zeroconf support
318 NETATALK_ZEROCONF
319
320 dnl Check for PAM libs
321 netatalk_cv_use_pam=no
322 AC_PATH_PAM([
323         use_pam_so=yes
324         compile_pam=yes
325         netatalk_cv_use_pam=yes
326         AC_DEFINE(USE_PAM, 1, [Define to enable PAM support])
327 ])
328
329 netatalk_cv_use_shadowpw=no
330 AC_ARG_WITH(shadow,
331         [  --with-shadow           enable shadow password support [[auto]]],
332         [netatalk_cv_use_shadowpw="$withval"],
333         [netatalk_cv_use_shadowpw=auto]
334 )
335
336 if test "x$netatalk_cv_use_shadowpw" != "xno"; then
337     AC_CHECK_HEADER([shadow.h])
338     if test x"$ac_cv_header_shadow_h" = x"yes"; then
339         netatalk_cv_use_shadowpw=yes
340         AC_DEFINE(SHADOWPW, 1, [Define if shadow passwords should be used])
341     else 
342       if test "x$shadowpw" = "xyes"; then
343         AC_MSG_ERROR([shadow support not available])
344       else
345         netatalk_cv_use_shadowpw=no
346       fi
347     fi 
348 fi
349
350 AC_MSG_CHECKING([whether shadow support should be enabled])
351 if test "x$netatalk_cv_use_shadowpw" = "xyes"; then
352         AC_MSG_RESULT([yes])
353 else
354         AC_MSG_RESULT([no])
355 fi
356         
357         
358         
359 netatalk_cv_use_shellcheck=yes
360 AC_MSG_CHECKING([whether checking for a valid shell should be enabled])
361 AC_ARG_ENABLE(shell-check,
362         [  --disable-shell-check   disable checking for a valid shell],[
363         if test "$enableval" = "no"; then 
364                 AC_DEFINE(DISABLE_SHELLCHECK, 1, [Define if shell check should be disabled])
365                 AC_MSG_RESULT([no])
366                 netatalk_cv_use_shellcheck=no
367         else
368                 AC_MSG_RESULT([yes])
369         fi
370         ],[
371                 AC_MSG_RESULT([yes])
372         ]
373 )
374
375 NETATALK_TCP_WRAPPERS
376
377 AC_MSG_CHECKING([whether system (fcntl) locking should be disabled])
378 AC_ARG_ENABLE(locking,
379         [  --disable-locking       disable system locking],[
380                 if test "$enableval" = "no"; then
381                         AC_DEFINE(DISABLE_LOCKING, 1, [Define if system (fcntl) locking should be disabled])
382                         AC_MSG_RESULT([yes])
383                 else
384                         AC_MSG_RESULT([no])
385                 fi
386                 
387         ],[
388                 AC_MSG_RESULT([no])
389         ]
390
391 )
392
393 AC_ARG_ENABLE(redhat,
394         [  --enable-redhat         obsoleted ],[
395         echo "ERROR: --enable-redhat is obsoleted. Use --enable-redhat-sysv or --enable-redhat-systemd."
396         echo "exit 1"
397         exit 1
398         ]
399 )
400
401 AC_ARG_ENABLE(redhat-sysv,
402         [  --enable-redhat-sysv    use redhat-style sysv (upstart) configuration ],[
403         if test "$enableval" = "yes"; then
404                 sysv_style=redhat-sysv
405         fi
406         AC_MSG_RESULT([enabling redhat-style sysv support])
407         ]
408 )
409
410 AC_ARG_ENABLE(redhat-systemd,
411         [  --enable-redhat-systemd use redhat-style systemd (>=Fedora15) configuration ],[
412         if test "$enableval" = "yes"; then
413                 sysv_style=redhat-systemd
414         fi
415         AC_MSG_RESULT([enabling redhat-style systemd support])
416         ]
417 )
418
419 AC_ARG_ENABLE(suse,
420         [  --enable-suse           use suse-style sysv configuration ],[
421         if test "$enableval" = "yes"; then
422                 sysv_style=suse
423         fi
424         AC_MSG_RESULT([enabling suse-style sysv support])
425         ]
426 )
427
428 AC_ARG_ENABLE(gentoo,
429         [  --enable-gentoo         use gentoo-style sysv configuration ],[
430         if test "$enableval" = "yes"; then
431                 sysv_style=gentoo
432         fi
433         AC_MSG_RESULT([enabling gentoo-style sysv support])
434         ]
435 )
436
437 AC_ARG_ENABLE(netbsd,
438         [  --enable-netbsd         use NetBSD-style rc.d configuration ],
439         if test "x$enableval" = "xyes"; then
440                 sysv_style=netbsd
441         fi
442         AC_MSG_RESULT([enabling NetBSD-style rc.d support])
443 )
444
445 AC_ARG_ENABLE(debian,
446         [  --enable-debian         use debian-style sysv configuration ],[
447         if test "$enableval" = "yes"; then
448                 sysv_style=debian
449         fi
450         AC_MSG_RESULT([enabling debian-style sysv support])
451         ]
452 )
453
454 dnl ----- timelord compilation (disabled by default)
455 AC_MSG_CHECKING([whether timelord should be compiled])
456 compile_timelord=no
457 AC_ARG_ENABLE(timelord,
458         [  --enable-timelord       enable compilation of timelord server],
459         [compile_timelord="$enableval"],
460         [compile_timelord="no"]
461 )
462 AC_MSG_RESULT([$compile_timelord])
463
464 dnl ----- a2boot compilation (disabled by default)
465 AC_MSG_CHECKING([whether a2boot should be compiled])
466 compile_a2boot=no
467 AC_ARG_ENABLE(a2boot,
468         [  --enable-a2boot         enable compilation of Apple2 boot server],
469         [compile_a2boot="$enableval"],
470         [compile_a2boot="no"]
471 )
472 AC_MSG_RESULT([$compile_a2boot])
473
474 AC_ARG_WITH(uams-path,
475         [  --with-uams-path=PATH   path to UAMs [[PKGCONF/uams]]],[
476                 uams_path="$withval"
477         ],[
478                 uams_path="${PKGCONFDIR}/uams"
479         ]
480 )
481
482 NETATALK_AC_CUPS
483
484 dnl check if we can use attribute unused (gcc only) from ethereal
485 AC_MSG_CHECKING(to see if we can add '__attribute__((unused))' to CFLAGS)
486 if test x$GCC != x ; then
487   CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
488   AC_MSG_RESULT(yes)
489 else
490   CFLAGS="-D_U_=\"\" $CFLAGS"
491   AC_MSG_RESULT(no)
492 fi
493
494 dnl --------------------------------------------------------------------------
495 dnl FHS stuff has to be done last because it overrides other defaults
496 dnl --------------------------------------------------------------------------
497
498 AC_MSG_CHECKING([whether to use Filesystem Hierarchy Standard (FHS) compatibility])
499 AC_ARG_ENABLE(fhs,
500         [  --enable-fhs            use Filesystem Hierarchy Standard (FHS) compatibility],[
501         if test "$enableval" = "yes"; then
502                 uams_path="${libdir}/netatalk"
503                 sysconfdir="/etc"
504                 PKGCONFDIR=${sysconfdir}/netatalk
505                 SERVERTEXT="${PKGCONFDIR}/msg"
506                 use_pam_so=yes
507                 mandir="/usr/share/man"
508                 AC_DEFINE(FHS_COMPATIBILITY, 1, [Define if you want compatibily with the FHS])
509                 AC_MSG_RESULT([yes])
510         else
511                 AC_MSG_RESULT([no])
512         fi
513         ],[
514                 AC_MSG_RESULT([no])
515         ]
516 )
517
518 dnl --------------------------------------------------------------------------
519 dnl post-FHS substitutions, etc
520 dnl --------------------------------------------------------------------------
521
522 dnl ***** UAMS_PATH
523 dnl AC_DEFINE_UNQUOTED(UAMS_PATH, "${uams_path}",
524 dnl     [path to UAMs [default=PKGCONF/uams]])
525 UAMS_PATH="${uams_path}"
526 AC_SUBST(UAMS_PATH)
527
528 dnl --------------------------------------------------------------------------
529 dnl drop in includes for top level directory structures here...
530 dnl --------------------------------------------------------------------------
531
532 dnl Note: $(top_srcdir)/include should be added before all other includes
533 dnl       so that includes from that directory a preferred to includes from
534 dnl       /usr/include or similar places.
535 LIBS="$LIBS -L\$(top_srcdir)/libatalk"
536 CFLAGS="-I\$(top_srcdir)/include $CFLAGS -I\$(top_srcdir)/sys"
537
538 AC_DEFINE(OPEN_NOFOLLOW_ERRNO, ELOOP, errno returned by open with O_NOFOLLOW)
539
540 dnl --------------------------------------------------------------------------
541 dnl specific configuration comes in here:
542 dnl --------------------------------------------------------------------------
543
544 dnl ac_cv_target_os is now host_os, ac_cv_target_cpu is now host_cpu
545
546 dnl --------------------- determine operating system from "target"
547 case "$host_os" in
548         *aix*)                          this_os=aix ;;
549         *kfreebsd*-gnu)                 this_os=kfreebsd-gnu ;;
550         *freebsd*)                      this_os=freebsd ;;
551         *hpux11*)                       this_os=hpux11 ;;
552         *irix*)                         this_os=irix ;;
553         *linux*)                        this_os=linux ;;
554         *osx*)                          this_os=macosx ;;
555         *darwin*)                       this_os=macosx ;;
556         *netbsd*)                       this_os=netbsd ;;
557         *openbsd*)                      this_os=openbsd ;;
558         *osf*)                          this_os=tru64 ;;
559         *solaris*)                      this_os=solaris ;;
560 esac
561
562 case "$host_cpu" in
563         i386|i486|i586|i686|k7)         this_cpu=x86 ;;
564         alpha)                                          this_cpu=alpha ;;
565         mips)                                           this_cpu=mips ;;
566         powerpc|ppc)                            this_cpu=ppc ;;
567 esac
568
569 dnl --------------------- GNU source
570 case "$this_os" in
571         linux)  AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
572         ;;
573      kfreebsd-gnu) AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
574         ;;
575 esac
576
577 dnl --------------------- operating system specific flags (port from sys/*)
578
579 dnl ----- AIX specific -----
580 if test x"$this_os" = "xaix"; then
581         AC_MSG_RESULT([ * AIX specific configuration])
582         AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
583
584         dnl This is probably a lie; AIX 4.3 supports a 64-bit long
585         dnl compilation environment.  It's enough to get things defined
586         dnl right in endian.h provided that long long is supported, though.
587         AC_DEFINE(HAVE_32BIT_LONGS, 1, [Define if the data type long has 32 bit])
588 fi
589
590 dnl ----- FreeBSD specific -----
591 if test x"$this_os" = "xfreebsd"; then 
592         AC_MSG_RESULT([ * FreeBSD specific configuration])
593         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
594         AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
595
596     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
597 fi
598
599 dnl ----- GNU/kFreeBSD specific -----
600 if test x"$this_os" = "xkfreebsd-gnu"; then 
601         AC_MSG_RESULT([ * GNU/kFreeBSD specific configuration])
602         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
603         AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
604         AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
605     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
606 fi
607
608 dnl ----- HP-UX 11 specific -----
609 if test x"$this_os" = "xhpux11"; then
610         AC_MSG_RESULT([ * HP-UX 11 specific configuration])
611
612         AC_DEFINE(_ISOC9X_SOURCE, 1, [Compatibility macro])
613         AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
614 fi
615
616 dnl ----- IRIX specific -----
617 if test x"$this_os" = "xirix"; then
618         AC_MSG_RESULT([ * IRIX specific configuration])
619
620         AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
621 fi
622
623 dnl ----- Linux specific -----
624 if test x"$this_os" = "xlinux"; then 
625         AC_MSG_RESULT([ * Linux specific configuration])
626         
627         dnl ----- kernel 2.6 changed struct at_addr to atalk_addr
628         AC_MSG_CHECKING([for struct atalk_addr])
629 dnl     AC_COMPILE_IFELSE([
630         AC_TRY_COMPILE([
631 #include <sys/socket.h>
632 #include <asm/types.h>
633 #include <linux/atalk.h>
634
635         struct atalk_addr foo;
636 ],
637 [ ], [
638                 ac_have_atalk_addr=yes
639                 AC_MSG_RESULT([yes])
640         ], [
641                 AC_MSG_RESULT([no])
642         ])
643
644 if test "x$ac_have_atalk_addr" = "xyes"; then
645         AC_DEFINE(HAVE_ATALK_ADDR, 1, [set if struct at_addr is called atalk_addr])
646 fi
647
648         dnl ----- check if we need the quotactl wrapper
649 #       AC_CHECK_HEADERS(sys/quota.h linux/quota.h)
650 #       AC_CHECK_FUNC(quotactl,,
651 #               AC_DEFINE(NEED_QUOTACTL_WRAPPER, 1, [Define if the quotactl wrapper is needed])
652 #               AC_MSG_RESULT([enabling quotactl wrapper])
653 #       )
654
655         # For quotas on Linux XFS filesystems
656         
657         # For linux > 2.5.56
658         AC_CHECK_HEADERS(linux/dqblk_xfs.h,,
659                 [AC_CHECK_HEADERS(linux/xqm.h linux/xfs_fs.h)
660                 AC_CHECK_HEADERS(xfs/libxfs.h xfs/xqm.h xfs/xfs_fs.h)]
661         )
662
663
664         dnl ----- as far as I can tell, dbtob always does the wrong thing
665         dnl ----- on every single version of linux I've ever played with.
666         dnl ----- see etc/afpd/quota.c
667         AC_DEFINE(HAVE_BROKEN_DBTOB, 1, [Define if dbtob is broken])
668
669
670         dnl ----- Linux/alpha specific -----
671         if test x"$this_cpu" = "xalpha"; then 
672                 AC_MSG_RESULT([enabling gcc memcpy bug workaround])
673                 AC_DEFINE(HAVE_GCC_MEMCPY_BUG, 1, [Define if memcpy is buggy])
674         fi
675         need_dash_r=no
676
677
678 fi
679
680 dnl ----- Mac OSX specific -----
681 if test x"$this_os" = "xmacosx"; then 
682         AC_MSG_RESULT([ * Mac OSX specific configuration])
683         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
684         AC_DEFINE(HAVE_2ARG_DBTOB, 1, [Define if dbtob takes two arguments])
685         dnl AC_DEFINE(NO_DLFCN_H)
686         AC_DEFINE(NO_DDP, 1, [Define if DDP should be disabled])
687         AC_DEFINE(NO_QUOTA_SUPPORT, 1, [Define if Quota support should be disabled])
688         AC_DEFINE(MACOSX_SERVER, 1, [Define if compiling for MacOS X Server])
689 fi
690
691 dnl ----- NetBSD specific -----
692 if test x"$this_os" = "xnetbsd"; then 
693         AC_MSG_RESULT([ * NetBSD specific configuration])
694         AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
695         AC_DEFINE(NETBSD, 1, [Define if OS is NetBSD])
696     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EFTYPE, errno returned by open with O_NOFOLLOW)
697
698         CFLAGS="-I\$(top_srcdir)/sys/netbsd $CFLAGS"
699         need_dash_r=yes 
700
701         dnl ----- NetBSD does not have crypt.h, uses unistd.h -----
702         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
703 fi
704
705 dnl ----- OpenBSD specific -----
706 if test x"$this_os" = "xopenbsd"; then 
707         AC_MSG_RESULT([ * OpenBSD specific configuration])
708     AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
709         dnl ----- OpenBSD does not have crypt.h, uses unistd.h -----
710         AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
711     AC_DEFINE(NO_DDP, 1, [Define if DDP should be disabled])
712 fi
713
714 dnl ----- Solaris specific -----
715 if test x"$this_os" = "xsolaris"; then 
716         AC_MSG_RESULT([ * Solaris specific configuration])
717         AC_DEFINE(__svr4__, 1, [Solaris compatibility macro])
718         AC_DEFINE(_ISOC9X_SOURCE, 1, [Compatibility macro])
719         AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
720         AC_DEFINE(SOLARIS, 1, [Solaris compatibility macro])
721         CFLAGS="-I\$(top_srcdir)/sys/generic $CFLAGS"
722         need_dash_r=yes
723         sysv_style=solaris
724
725         solaris_module=no
726         AC_MSG_CHECKING([if we can build Solaris kernel module])
727         if test -x /usr/ccs/bin/ld && test x"$netatalk_cv_ddp_enabled" = x"yes" ; then
728                 solaris_module=yes
729         fi
730         AC_MSG_RESULT([$solaris_module])
731
732         COMPILE_64BIT_KMODULE=no
733         KCFLAGS=""
734         KLDFLAGS=""
735         COMPILE_KERNEL_GCC=no
736
737         if test "$solaris_module" = "yes"; then
738            dnl Solaris kernel module stuff
739            AC_MSG_CHECKING([if we have to build a 64bit kernel module])
740
741            # check for isainfo, if not found it has to be a 32 bit kernel (<=2.6)       
742            if test -x /usr/bin/isainfo; then
743                 # check for 64 bit platform
744                 if isainfo -kv | grep '^64-bit'; then
745                         COMPILE_64BIT_KMODULE=yes
746                 fi
747            fi
748
749            AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
750
751            if test "${GCC}" = yes; then
752                 COMPILE_KERNEL_GCC=yes
753                 if test "$COMPILE_64BIT_KMODULE" = yes; then
754                 
755                         AC_MSG_CHECKING([if we can build a 64bit kernel module])
756                         
757                         case `$CC --version 2>/dev/null` in
758                         [[12]].* | 3.0.*)
759                                 COMPILE_64BIT_KMODULE=no
760                                 COMPILE_KERNEL_GCC=no   
761                                 solaris_module=no;;
762                         *)
763                                 # use for 64 bit
764                                 KCFLAGS="-m64"
765                                 #KLDFLAGS="-melf64_sparc"
766                                 KLDFLAGS="-64";;
767                         esac    
768                         
769                         AC_MSG_RESULT([$COMPILE_64BIT_KMODULE])
770                         
771                 else
772                         KCFLAGS=""
773                         KLDFLAGS=""
774                 fi
775                 KCFLAGS="$KCFLAGS -D_KERNEL -Wall -Wstrict-prototypes"
776            else
777                 if test "$COMPILE_64BIT_KMODULE" = yes; then
778                 # use Sun CC (for a 64-bit kernel, uncomment " -xarch=v9 -xregs=no%appl ")
779                         KCFLAGS="-xarch=v9 -xregs=no%appl"
780                         KLDFLAGS="-64"
781                 else
782                         KCFLAGS=""
783                         KLDFLAGS=""
784                 fi
785                 KCFLAGS="-D_KERNEL $KCFLAGS -mno-app-regs -munaligned-doubles -fpcc-struct-return"
786            fi
787
788            AC_CACHE_CHECK([for timeout_id_t],netatalk_cv_HAVE_TIMEOUT_ID_T,[
789            AC_TRY_LINK([\
790 #include <sys/stream.h>
791 #include <sys/ddi.h>],
792 [\
793 timeout_id_t dummy;
794 ],
795 netatalk_cv_HAVE_TIMEOUT_ID_T=yes,netatalk_cv_HAVE_TIMEOUT_ID_T=no,netatalk_cv_HAVE_TIMEOUT_ID_T=cross)])
796
797            AC_DEFINE(HAVE_TIMEOUT_ID_T, test x"$netatalk_cv_HAVE_TIMEOUT_ID" = x"yes", [define for timeout_id_t])
798         fi
799
800         AC_SUBST(COMPILE_KERNEL_GCC)
801         AC_SUBST(COMPILE_64BIT_KMODULE)
802         AC_SUBST(KCFLAGS)
803         AC_SUBST(KLDFLAGS)
804 fi
805
806 dnl ----- Tru64 specific -----
807 if test x"$this_os" = "xtru64"; then 
808         AC_MSG_RESULT([ * Tru64 specific configuration])
809         AC_DEFINE(NO_DDP, 1, [Define if DDP should be disabled])
810         AC_DEFINE(HAVE_64BIT_LONGS, 1, [Define if the data type long has 64 bit])
811         dnl AC_DEFINE(USE_MOUNT_H)
812         AC_DEFINE(USE_OLD_RQUOTA, 1, [Define to use old rquota])
813         dnl AC_DEFINE(USE_UFS_QUOTA_H)
814         AC_DEFINE(TRU64, 1, [Define on Tru64 platforms])
815         AC_DEFINE(_OSF_SOURCE, 1, [Define if the *passwd UAMs should be used])
816         AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Define for Berkeley DB 4])
817         AC_CHECK_LIB(security,set_auth_parameters)
818         CFLAGS="-I\$(top_srcdir)/sys/tru64 $CFLAGS"
819         need_dash_r=no
820         sysv_style=tru64
821 fi
822
823 dnl ------ Check for sendfile() --------
824 netatalk_cv_search_sendfile=yes
825 AC_ARG_ENABLE(sendfile,
826     [  --disable-sendfile       disable sendfile syscall],
827     [if test x"$enableval" = x"no"; then
828             netatalk_cv_search_sendfile=no
829         fi]
830 )
831
832 if test x"$netatalk_cv_search_sendfile" = x"yes"; then
833    case "$host_os" in
834    *linux*)
835        AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
836        AC_MSG_CHECKING([for sendfile() syscall])
837        AC_CACHE_CHECK([for sendfile support],
838            [netatalk_cv_HAVE_SENDFILE],
839            [AC_TRY_LINK(
840                [#include <sys/sendfile.h>],
841                [int tofd, fromfd;
842                    off_t offset;
843                    size_t total;
844                    ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);],
845                [netatalk_cv_HAVE_SENDFILE=yes]
846             )]
847         )
848
849         # Try and cope with broken Linux sendfile....
850         AC_CACHE_CHECK([for broken Linux sendfile support],
851             [netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE],
852             [AC_TRY_LINK(
853                 [#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
854                     #undef _FILE_OFFSET_BITS
855                     #endif
856                     #include <sys/sendfile.h>],
857                 [int tofd, fromfd;
858                     off_t offset;
859                     size_t total;
860                     ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);],
861                 [netatalk_cv_HAVE_SENDFILE=yes;
862                     AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether Linux sendfile() is broken])]
863             )]
864         )
865         if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
866             AC_MSG_RESULT(yes);
867         else
868             AC_MSG_RESULT(no);
869         fi
870         ;;
871
872     *solaris*)
873         AC_DEFINE(SENDFILE_FLAVOR_SOLARIS, 1, [Solaris sendfile()])
874         AC_SEARCH_LIBS(sendfile, sendfile)
875         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
876         ;;
877
878     *freebsd*)
879         AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
880         AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
881         ;;
882
883     *)
884         ;;
885
886     esac
887
888     if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
889         AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
890         AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
891     fi
892 fi
893
894 dnl -- check for libgcrypt, if found enables DHX UAM
895 AM_PATH_LIBGCRYPT([1:1.2.3],[neta_cv_compile_dhx2=yes
896                         neta_cv_have_libgcrypt=yes
897                         AC_MSG_NOTICE([Enabling DHX2 UAM])
898                         AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define if the DHX2 modules should be built with libgcrypt])
899                         AC_DEFINE(UAM_DHX2, 1, [Define if the DHX2 UAM modules should be compiled])
900                         ])
901
902 dnl -- look for openssl, if found enables DHX UAM and Randnum UAM
903 AC_PATH_SSL
904
905 dnl Check for Berkeley DB library
906 if test "x$bdb_required" = "xyes"; then
907         AC_PATH_BDB(, [
908                 AC_MSG_RESULT([])
909                 AC_MSG_RESULT([Make sure you have the required Berkeley DB libraries AND headers installed.])
910                 AC_MSG_RESULT([You can download the latest version from http://www.sleepycat.com.])
911                 AC_MSG_RESULT([If you have installed BDB in a non standard location use the])
912                 AC_MSG_RESULT([--with-bdb=/path/to/bdb configure option and make sure])
913                 AC_MSG_RESULT([your linker is configured to check for libraries there.])
914                 AC_MSG_ERROR([Berkeley DB library required but not found!])
915         ])
916 fi
917
918 dnl -- check for crypt
919 AC_CRYPT
920
921 dnl --------------------- check for building PGP UAM module
922
923 AC_MSG_CHECKING([whether the PGP UAM should be build])
924 AC_ARG_ENABLE(pgp-uam,
925         [  --enable-pgp-uam        enable build of PGP UAM module],[
926         if test "$enableval" = "yes"; then 
927                 if test "x$neta_cv_have_openssl" = "xyes"; then 
928                         AC_DEFINE(UAM_PGP, 1, [Define if the PGP UAM module should be compiled])
929                         compile_pgp=yes
930                         AC_MSG_RESULT([yes])
931                 else
932                         AC_MSG_RESULT([no])
933                 fi
934         fi
935         ],[
936                 AC_MSG_RESULT([no])
937         ]
938 )
939
940 dnl --------------------- check for building Kerberos v4 UAM module
941
942 AC_MSG_CHECKING([whether the Kerberos IV UAM should be build])
943 AC_ARG_ENABLE(krb4-uam,
944         [  --enable-krb4-uam       enable build of Kerberos v4 UAM module],[
945         if test "$enableval" = "yes"; then
946                 AC_DEFINE(UAM_KRB4, 1, [Define if the Kerberos 4 UAM module should be compiled])
947                 compile_kerberos=yes
948                 AC_MSG_RESULT([yes])
949         else
950                 AC_MSG_RESULT([no])
951         fi
952         ],[
953                 AC_MSG_RESULT([no])
954         ]
955 )
956
957 dnl --------------------- check for building Kerberos V UAM module
958
959 netatalk_cv_build_krb5_uam=no
960 AC_ARG_ENABLE(krbV-uam,
961         [  --enable-krbV-uam       enable build of Kerberos V UAM module],
962         [
963                 if test x"$enableval" = x"yes"; then
964                         NETATALK_GSSAPI_CHECK([
965                                 netatalk_cv_build_krb5_uam=yes
966                         ],[
967                                 AC_MSG_ERROR([need GSSAPI to build Kerberos V UAM])
968                         ])
969                 fi
970         ]
971         
972 )
973
974 AC_MSG_CHECKING([whether Kerberos V UAM should be build])
975 if test x"$netatalk_cv_build_krb5_uam" = x"yes"; then
976         AC_MSG_RESULT([yes])
977 else
978         AC_MSG_RESULT([no])
979 fi
980 AM_CONDITIONAL(USE_GSSAPI, test x"$netatalk_cv_build_krb5_uam" = x"yes")
981
982 dnl --------------------- overwrite the config files . . . or not.
983
984 AC_MSG_CHECKING([whether configuration files should be overwritten])
985 AC_ARG_ENABLE(overwrite,
986         [  --enable-overwrite      overwrite configuration files during installation],
987         [OVERWRITE_CONFIG="${enable_overwrite}"],
988         [OVERWRITE_CONFIG="no"]
989 )
990 AC_MSG_RESULT([$OVERWRITE_CONFIG])
991
992 dnl --------------------- check for LDAP support, for client-side ACL visibility
993 AC_MSG_CHECKING(for LDAP (necessary for client-side ACL visibility))
994 AC_ARG_WITH(ldap,
995     [AS_HELP_STRING([--with-ldap],
996         [LDAP support (default=auto)])],
997     [ case "$withval" in
998       yes|no)
999           with_ldap="$withval"
1000                   ;;
1001       *)
1002           with_ldap=auto
1003           ;;
1004       esac ])
1005 AC_MSG_RESULT($with_ldap)
1006
1007 if test x"$with_ldap" != x"no" ; then
1008         AC_CHECK_HEADER([ldap.h], with_ldap=yes,
1009         [ if test x"$with_ldap" = x"yes" ; then
1010             AC_MSG_ERROR([Missing LDAP headers])
1011         fi
1012                 with_ldap=no
1013         ])
1014         AC_CHECK_LIB(ldap, ldap_init, with_ldap=yes,
1015         [ if test x"$with_ldap" = x"yes" ; then
1016             AC_MSG_ERROR([Missing LDAP library])
1017         fi
1018                 with_ldap=no
1019         ])
1020 fi
1021
1022 if test x"$with_ldap" = x"yes"; then
1023         AC_DEFINE(HAVE_LDAP,1,[Whether LDAP is available])
1024 fi
1025
1026 dnl --------------------- check for ACL support
1027 AC_MSG_CHECKING(whether to support ACLs)
1028 AC_ARG_WITH(acls,
1029     [AS_HELP_STRING([--with-acls],
1030         [Include ACL support (default=auto)])],
1031     [ case "$withval" in
1032       yes|no)
1033           with_acl_support="$withval"
1034                   ;;
1035       *)
1036           with_acl_support=auto
1037           ;;
1038       esac ],
1039     [with_acl_support=auto])
1040 AC_MSG_RESULT($with_acl_support)
1041
1042 if test x"$with_acl_support" = x"no"; then
1043         AC_MSG_RESULT(Disabling ACL support)
1044         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
1045 else
1046     with_acl_support=yes
1047 fi
1048
1049 if test x"$with_acl_support" = x"yes" ; then
1050         AC_MSG_NOTICE(checking whether ACL support is available:)
1051         case "$host_os" in
1052         *sysv5*)
1053                 AC_MSG_NOTICE(Using UnixWare ACLs)
1054                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
1055                 ;;
1056         *solaris*)
1057                 AC_MSG_NOTICE(Using solaris ACLs)
1058                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
1059                 ACL_LIBS="$ACL_LIBS -lsec"
1060                 ;;
1061         *hpux*)
1062                 AC_MSG_NOTICE(Using HPUX ACLs)
1063                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
1064                 ;;
1065         *irix*)
1066                 AC_MSG_NOTICE(Using IRIX ACLs)
1067                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
1068                 ;;
1069         *aix*)
1070                 AC_MSG_NOTICE(Using AIX ACLs)
1071                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
1072                 ;;
1073         *osf*)
1074                 AC_MSG_NOTICE(Using Tru64 ACLs)
1075                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
1076                 ACL_LIBS="$ACL_LIBS -lpacl"
1077                 ;;
1078         *darwin*)
1079                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
1080                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
1081                 ;;
1082         *)
1083                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
1084                 case "$host_os" in
1085                 *linux*)
1086                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
1087                         ;;
1088                 esac
1089                 AC_CACHE_CHECK([for POSIX ACL support],netatalk_cv_HAVE_POSIX_ACLS,[
1090                         acl_LIBS=$LIBS
1091                         LIBS="$LIBS $ACL_LIBS"
1092                         AC_TRY_LINK([
1093                                 #include <sys/types.h>
1094                                 #include <sys/acl.h>
1095                         ],[
1096                                 acl_t acl;
1097                                 int entry_id;
1098                                 acl_entry_t *entry_p;
1099                                 return acl_get_entry(acl, entry_id, entry_p);
1100                         ],
1101                         [netatalk_cv_HAVE_POSIX_ACLS=yes],
1102                         [netatalk_cv_HAVE_POSIX_ACLS=no
1103                 with_acl_support=no])
1104                         LIBS=$acl_LIBS
1105                 ])
1106                 if test x"$netatalk_cv_HAVE_POSIX_ACLS" = x"yes"; then
1107                         AC_MSG_NOTICE(Using POSIX ACLs)
1108                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
1109                         AC_CACHE_CHECK([for acl_get_perm_np],netatalk_cv_HAVE_ACL_GET_PERM_NP,[
1110                                 acl_LIBS=$LIBS
1111                                 LIBS="$LIBS $ACL_LIBS"
1112                                 AC_TRY_LINK([
1113                                         #include <sys/types.h>
1114                                         #include <sys/acl.h>
1115                                 ],[
1116                                         acl_permset_t permset_d;
1117                                         acl_perm_t perm;
1118                                         return acl_get_perm_np(permset_d, perm);
1119                                 ],
1120                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=yes],
1121                                 [netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
1122                                 LIBS=$acl_LIBS
1123                         ])
1124                         if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
1125                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
1126                         fi
1127
1128                         AC_CACHE_CHECK([for acl_from_mode], netatalk_cv_HAVE_ACL_FROM_MODE,[
1129                                 acl_LIBS=$LIBS
1130                                 LIBS="$LIBS $ACL_LIBS"
1131                 AC_CHECK_FUNCS(acl_from_mode,
1132                                 [netatalk_cv_HAVE_ACL_FROM_MODE=yes],
1133                                 [netatalk_cv_HAVE_ACL_FROM_MODE=no])
1134                                 LIBS=$acl_LIBS
1135                         ])
1136                         if test x"netatalk_cv_HAVE_ACL_FROM_MODE" = x"yes"; then
1137                                 AC_DEFINE(HAVE_ACL_FROM_MODE,1,[Whether acl_from_mode() is available])
1138                         fi
1139
1140
1141                 else
1142                         AC_MSG_NOTICE(ACL support is not avaliable)
1143                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
1144                 fi
1145                 ;;
1146     esac
1147 fi
1148
1149 if test x"$with_acl_support" = x"yes" ; then
1150    AC_CHECK_HEADERS([acl/libacl.h])
1151     AC_DEFINE(HAVE_ACLS,1,[Whether ACLs support is available])
1152     AC_SUBST(ACL_LIBS)
1153 fi
1154
1155 dnl --------------------- check for Extended Attributes support
1156 neta_cv_eas="ad"
1157 neta_cv_eas_sys_found=no
1158 neta_cv_eas_sys_not_found=no
1159
1160 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h sys/ea.h)
1161
1162 case "$this_os" in
1163
1164   *osf*)
1165         AC_SEARCH_LIBS(getproplist, [proplist])
1166         AC_CHECK_FUNCS([getproplist fgetproplist setproplist fsetproplist],
1167                    [neta_cv_eas_sys_found=yes],
1168                    [neta_cv_eas_sys_not_found=yes])
1169         AC_CHECK_FUNCS([delproplist fdelproplist add_proplist_entry get_proplist_entry],,
1170                    [neta_cv_eas_sys_not_found=yes])
1171         AC_CHECK_FUNCS([sizeof_proplist_entry],,
1172                    [neta_cv_eas_sys_not_found=yes])
1173   ;;
1174
1175   *solaris*)
1176         AC_CHECK_FUNCS([attropen],
1177                    [neta_cv_eas_sys_found=yes],
1178                    [neta_cv_eas_sys_not_found=yes])
1179   ;;
1180
1181   'freebsd')
1182     AC_CHECK_FUNCS([extattr_delete_fd extattr_delete_file extattr_delete_link],
1183                    [neta_cv_eas_sys_found=yes],
1184                    [neta_cv_eas_sys_not_found=yes])
1185     AC_CHECK_FUNCS([extattr_get_fd extattr_get_file extattr_get_link],,
1186                    [neta_cv_eas_sys_not_found=yes])
1187     AC_CHECK_FUNCS([extattr_list_fd extattr_list_file extattr_list_link],,
1188                    [neta_cv_eas_sys_not_found=yes])
1189     AC_CHECK_FUNCS([extattr_set_fd extattr_set_file extattr_set_link],,
1190                    [neta_cv_eas_sys_not_found=yes])
1191   ;;
1192
1193   *freebsd4* | *dragonfly* )
1194     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1195   ;;
1196
1197   *)
1198         AC_SEARCH_LIBS(getxattr, [attr])
1199
1200     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
1201        AC_CHECK_FUNCS([getxattr lgetxattr fgetxattr listxattr llistxattr],
1202                       [neta_cv_eas_sys_found=yes],
1203                       [neta_cv_eas_sys_not_found=yes])
1204            AC_CHECK_FUNCS([flistxattr removexattr lremovexattr fremovexattr],,
1205                       [neta_cv_eas_sys_not_found=yes])
1206            AC_CHECK_FUNCS([setxattr lsetxattr fsetxattr],,
1207                       [neta_cv_eas_sys_not_found=yes])
1208     fi
1209
1210     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
1211            AC_CHECK_FUNCS([getea fgetea lgetea listea flistea llistea],
1212                       [neta_cv_eas_sys_found=yes],
1213                       [neta_cv_eas_sys_not_found=yes])
1214            AC_CHECK_FUNCS([removeea fremoveea lremoveea setea fsetea lsetea],,
1215                       [neta_cv_eas_sys_not_found=yes])
1216     fi
1217
1218     if test "x$neta_cv_eas_sys_found" != "xyes" ; then
1219            AC_CHECK_FUNCS([attr_get attr_list attr_set attr_remove],,
1220                       [neta_cv_eas_sys_not_found=yes])
1221        AC_CHECK_FUNCS([attr_getf attr_listf attr_setf attr_removef],,
1222                       [neta_cv_eas_sys_not_found=yes])
1223     fi
1224   ;;
1225 esac
1226
1227 # Do xattr functions take additional options like on Darwin?
1228 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1229         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1230                 old_LIBS=$LIBS
1231                 LIBS="$LIBS $ACL_LIBS"
1232                 AC_TRY_COMPILE([
1233                         #include <sys/types.h>
1234                         #if HAVE_ATTR_XATTR_H
1235                         #include <attr/xattr.h>
1236                         #elif HAVE_SYS_XATTR_H
1237                         #include <sys/xattr.h>
1238                         #endif
1239                 ],[
1240                         getxattr(0, 0, 0, 0, 0, 0);
1241                 ],
1242                 [smb_attr_cv_xattr_add_opt=yes],
1243                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1244         ])
1245         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1246                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1247         fi
1248 fi
1249
1250 if test "x$neta_cv_eas_sys_found" = "xyes" ; then
1251    if test "x$neta_cv_eas_sys_not_found" != "xyes" ; then
1252       neta_cv_eas="$neta_cv_eas | sys"
1253    fi
1254 fi
1255 AC_DEFINE_UNQUOTED(EA_MODULES,["$neta_cv_eas"],[Available Extended Attributes modules])
1256
1257 dnl --------------------- Check if realpath() takes NULL
1258 AC_CACHE_CHECK([if the realpath function allows a NULL argument],
1259     neta_cv_REALPATH_TAKES_NULL, [
1260         AC_TRY_RUN([
1261             #include <stdio.h>
1262             #include <limits.h>
1263             #include <signal.h>
1264
1265             void exit_on_core(int ignored) {
1266                  exit(1);
1267             }
1268
1269             main() {
1270                 char *newpath;
1271                 signal(SIGSEGV, exit_on_core);
1272                 newpath = realpath("/tmp", NULL);
1273                 exit((newpath != NULL) ? 0 : 1);
1274             }],
1275             neta_cv_REALPATH_TAKES_NULL=yes,
1276             neta_cv_REALPATH_TAKES_NULL=no,
1277             neta_cv_REALPATH_TAKES_NULL=cross
1278         )
1279     ]
1280 )
1281
1282 if test x"$neta_cv_REALPATH_TAKES_NULL" = x"yes"; then
1283     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
1284 fi
1285
1286 dnl --------------------- Netatalk Webmin
1287 NETATALK_WEBMIN
1288
1289 dnl --------------------- last minute substitutions
1290
1291 AC_SUBST(LIBS)
1292 AC_SUBST(CFLAGS)
1293 AC_SUBST(OVERWRITE_CONFIG)
1294
1295 AM_CONDITIONAL(SOLARIS_MODULE, test x$solaris_module = xyes)
1296 AM_CONDITIONAL(COMPILE_TIMELORD, test x$compile_timelord = xyes)
1297 AM_CONDITIONAL(COMPILE_A2BOOT, test x$compile_a2boot = xyes)
1298 AM_CONDITIONAL(HAVE_LIBGCRYPT, test x$neta_cv_have_libgcrypt = xyes)
1299 AM_CONDITIONAL(HAVE_OPENSSL, test x$neta_cv_have_openssl = xyes)
1300 AM_CONDITIONAL(HAVE_ACLS, test x"$with_acl_support" = x"yes")
1301 AM_CONDITIONAL(HAVE_LDAP, test x"$with_ldap" = x"yes")
1302 AM_CONDITIONAL(USE_DHX, test x$neta_cv_compile_dhx = xyes)
1303 AM_CONDITIONAL(USE_DHX2, test x$neta_cv_compile_dhx2 = xyes)
1304 AM_CONDITIONAL(USE_RANDNUM, test x$neta_cv_have_openssl = xyes)
1305 AM_CONDITIONAL(USE_KERBEROS, test x$compile_kerberos = xyes)
1306 AM_CONDITIONAL(USE_PAM_SO, test x$use_pam_so = xyes)
1307 AM_CONDITIONAL(USE_PAM, test x$netatalk_cv_install_pam = xyes)
1308 AM_CONDITIONAL(BUILD_PAM, test x$compile_pam = xyes)
1309 AM_CONDITIONAL(USE_PGP, test x$compile_pgp = xyes)
1310 AM_CONDITIONAL(DEFAULT_HOOK, test x$neta_cv_have_libgcrypt != xyes && test x$neta_cv_have_openssl != xyes)
1311 AM_CONDITIONAL(USE_NETBSD, test x$sysv_style = xnetbsd)
1312 AM_CONDITIONAL(USE_REDHAT_SYSV, test x$sysv_style = xredhat-sysv)
1313 AM_CONDITIONAL(USE_REDHAT_SYSTEMD, test x$sysv_style = xredhat-systemd)
1314 AM_CONDITIONAL(USE_SUSE, test x$sysv_style = xsuse)
1315 AM_CONDITIONAL(USE_SHADOWPW, test x$shadowpw = xyes)
1316 AM_CONDITIONAL(USE_TRU64, test x$sysv_style = xtru64)
1317 AM_CONDITIONAL(USE_SOLARIS, test x$sysv_style = xsolaris)
1318 AM_CONDITIONAL(USE_GENTOO, test x$sysv_style = xgentoo)
1319 AM_CONDITIONAL(USE_DEBIAN, test x$sysv_style = xdebian)
1320 AM_CONDITIONAL(USE_UNDEF, test x$sysv_style = x)
1321 AM_CONDITIONAL(USE_BDB, test x$bdb_required = xyes)
1322 AM_CONDITIONAL(USE_APPLETALK, test x$netatalk_cv_ddp_enabled = xyes)
1323 AM_CONDITIONAL(HAVE_ATFUNCS, test x"$ac_neta_haveatfuncs" = x"yes")
1324
1325 dnl --------------------- generate files
1326
1327 AC_OUTPUT([Makefile
1328         bin/Makefile
1329         bin/ad/Makefile
1330         bin/adv1tov2/Makefile
1331         bin/aecho/Makefile
1332         bin/afppasswd/Makefile
1333         bin/cnid/Makefile
1334         bin/cnid/cnid2_create
1335         bin/getzones/Makefile
1336         bin/megatron/Makefile
1337         bin/misc/Makefile
1338         bin/nbp/Makefile
1339         bin/pap/Makefile
1340         bin/psorder/Makefile
1341         bin/uniconv/Makefile
1342         config/Makefile
1343         config/pam/Makefile
1344         contrib/Makefile
1345         contrib/macusers/Makefile
1346         contrib/macusers/macusers
1347         contrib/misc/Makefile
1348         contrib/printing/Makefile
1349         contrib/shell_utils/Makefile
1350         contrib/shell_utils/apple_dump
1351         contrib/shell_utils/asip-status.pl
1352         contrib/timelord/Makefile
1353         contrib/a2boot/Makefile
1354         distrib/Makefile
1355         distrib/config/Makefile
1356         distrib/config/netatalk-config
1357         distrib/initscripts/Makefile
1358         distrib/m4/Makefile
1359         doc/Makefile
1360         etc/Makefile
1361         etc/afpd/Makefile
1362         etc/atalkd/Makefile
1363         etc/cnid_dbd/Makefile
1364         etc/uams/Makefile
1365         etc/uams/uams_krb4/Makefile
1366         etc/papd/Makefile
1367         etc/psf/Makefile
1368         include/Makefile
1369         include/atalk/Makefile
1370         libatalk/Makefile
1371         libatalk/acl/Makefile
1372         libatalk/adouble/Makefile
1373         libatalk/asp/Makefile
1374         libatalk/atp/Makefile
1375         libatalk/bstring/Makefile
1376         libatalk/cnid/Makefile
1377         libatalk/cnid/cdb/Makefile
1378         libatalk/cnid/last/Makefile
1379         libatalk/cnid/dbd/Makefile
1380         libatalk/cnid/tdb/Makefile
1381         libatalk/compat/Makefile
1382         libatalk/dsi/Makefile
1383         libatalk/nbp/Makefile
1384         libatalk/netddp/Makefile
1385         libatalk/util/Makefile
1386         libatalk/tdb/Makefile
1387         libatalk/unicode/Makefile
1388         libatalk/unicode/charsets/Makefile
1389         libatalk/vfs/Makefile
1390         macros/Makefile
1391         man/Makefile
1392         man/man1/Makefile
1393         man/man3/Makefile
1394         man/man4/Makefile
1395         man/man5/Makefile
1396         man/man8/Makefile
1397         sys/Makefile
1398         sys/generic/Makefile
1399         sys/generic/sys/Makefile
1400         sys/netatalk/Makefile
1401         sys/netbsd/Makefile
1402         sys/netbsd/netatalk/Makefile
1403         sys/solaris/Makefile
1404         sys/sunos/Makefile
1405         sys/ultrix/Makefile
1406         test/Makefile
1407         test/afpd/Makefile
1408         ],
1409         [chmod a+x distrib/config/netatalk-config contrib/shell_utils/apple_*]
1410 )
1411
1412 AC_NETATALK_LIBS_SUMMARY
1413 AC_NETATALK_CONFIG_SUMMARY