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