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