]> arthur.barton.de Git - netatalk.git/blobdiff - macros/netatalk.m4
initscript: fix
[netatalk.git] / macros / netatalk.m4
index 207c6865691526808ee67b0d4a81df3501a986bb..2d8aac6993ff0b68fba4e4b167dda83077abd7bf 100644 (file)
@@ -145,16 +145,28 @@ AC_ARG_ENABLE(shell-check,
 dnl Check for optional sysv initscript install
 AC_DEFUN([AC_NETATALK_SYSV_STYLE], [
     AC_ARG_WITH(sysv-style,
-                [  --with-sysv-style       use OS specific sysv config [[redhat|suse|gentoo|netbsd|debian]]],
+                [  --with-sysv-style       use OS specific sysv config [[redhat-sysv|redhat-systemd|suse-sysv|suse-systemd|gentoo|netbsd|debian|systemd]]],
                 sysv_style="$withval", sysv_style=none
     )
     case "$sysv_style" in 
     "redhat")
-           AC_MSG_RESULT([enabling redhat-style sysv support])
+           AC_MSG_ERROR([--with-sysv-style=redhat is obsoleted. Use redhat-sysv or redhat-systemd.])
         ;;
+    "redhat-sysv")
+           AC_MSG_RESULT([enabling redhat-style sysv (upstart) configuration])
+           ;;
+    "redhat-systemd")
+           AC_MSG_RESULT([enabling redhat-style systemd support])
+           ;;
     "suse")
-           AC_MSG_RESULT([enabling suse-style sysv support])
+           AC_MSG_ERROR([--with-sysv-style=suse is obsoleted. Use suse-sysv or suse-systemd])
         ;;
+    "suse-sysv")
+           AC_MSG_RESULT([enabling suse-style sysv configuration])
+           ;;
+    "suse-systemd")
+           AC_MSG_RESULT([enabling suse-style systemd support (>=openSUSE12.1)])
+           ;;
     "gentoo")
            AC_MSG_RESULT([enabling gentoo-style sysv support])
         ;;
@@ -164,10 +176,24 @@ AC_DEFUN([AC_NETATALK_SYSV_STYLE], [
     "debian")
            AC_MSG_RESULT([enabling debian-style sysv support])
         ;;
+    "systemd")
+           AC_MSG_RESULT([use general systemd configuration])
+        ;;
     *)
            AC_MSG_RESULT([disabling sysv support])
         ;;
     esac
+    AM_CONDITIONAL(USE_NETBSD, test x$sysv_style = xnetbsd)
+    AM_CONDITIONAL(USE_REDHAT_SYSV, test x$sysv_style = xredhat-sysv)
+    AM_CONDITIONAL(USE_SUSE_SYSV, test x$sysv_style = xsuse-sysv)
+    AM_CONDITIONAL(USE_SHADOWPW, test x$shadowpw = xyes)
+    AM_CONDITIONAL(USE_TRU64, test x$sysv_style = xtru64)
+    AM_CONDITIONAL(USE_SOLARIS, test x$sysv_style = xsolaris)
+    AM_CONDITIONAL(USE_GENTOO, test x$sysv_style = xgentoo)
+    AM_CONDITIONAL(USE_DEBIAN, test x$sysv_style = xdebian)
+    AM_CONDITIONAL(USE_SYSTEMD, test x$sysv_style = xsystemd || test x$sysv_style = xredhat-systemd || test x$sysv_style = xsuse-systemd)
+    AM_CONDITIONAL(USE_UNDEF, test x$sysv_style = xnone)
+
 ])
 
 dnl OS specific configuration
@@ -193,6 +219,14 @@ case "$host_cpu" in
        powerpc|ppc)                            this_cpu=ppc ;;
 esac
 
+dnl --------------------- GNU source
+case "$this_os" in
+       linux)  AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
+        ;;
+     kfreebsd-gnu) AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
+        ;;
+esac
+
 dnl --------------------- operating system specific flags (port from sys/*)
 
 dnl ----- FreeBSD specific -----
@@ -200,7 +234,14 @@ if test x"$this_os" = "xfreebsd"; then
        AC_MSG_RESULT([ * FreeBSD specific configuration])
        AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
        AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
-       AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
+    AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
+fi
+
+dnl ----- GNU/kFreeBSD specific -----
+if test x"$this_os" = "xkfreebsd-gnu"; then 
+       AC_MSG_RESULT([ * GNU/kFreeBSD specific configuration])
+       AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
+       AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
 fi
 
@@ -220,76 +261,9 @@ if test x"$this_os" = "xlinux"; then
        dnl ----- see etc/afpd/quota.c
        AC_DEFINE(HAVE_BROKEN_DBTOB, 1, [Define if dbtob is broken])
 
-       netatalk_cv_linux_sendfile=yes
-       AC_MSG_CHECKING([use sendfile syscall])
-        AC_ARG_ENABLE(sendfile,
-           [  --disable-sendfile       disable linux sendfile syscall],[
-               if test x"$enableval" = x"no"; then
-                       netatalk_cv_linux_sendfile=no
-                       AC_MSG_RESULT([no])
-               else
-                       AC_MSG_RESULT([yes])
-
-               fi
-           ],[
-               AC_MSG_RESULT([yes])
-       ]
-
-       )
-
-       if test x"$netatalk_cv_linux_sendfile" = "xyes"; then 
-           AC_CACHE_CHECK([for linux sendfile support],netatalk_cv_HAVE_SENDFILE,[
-           AC_TRY_LINK([#include <sys/sendfile.h>],
-[\
-int tofd, fromfd;
-off_t offset;
-size_t total;
-ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
-],
-netatalk_cv_HAVE_SENDFILE=yes,netatalk_cv_HAVE_SENDFILE=no)])
-
-# Try and cope with broken Linux sendfile....
-           AC_CACHE_CHECK([for broken linux sendfile support],netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE,[
-           AC_TRY_LINK([\
-#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
-#undef _FILE_OFFSET_BITS
-#endif
-#include <sys/sendfile.h>],
-[\
-int tofd, fromfd;
-off_t offset;
-size_t total;
-ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
-],
-netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE=no,netatalk_cv_HAVE_BROKEN_SENDFILE=cross)])
-
-           if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
-               AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
-               AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
-               AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
-           elif test x"$netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
-               AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
-               AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
-               AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
-           else
-               netatalk_cv_linux_sendfile=no
-               AC_MSG_RESULT(no);
-           fi
-       fi
-
        need_dash_r=no
 fi
 
-dnl ----- Mac OSX specific -----
-if test x"$this_os" = "xmacosx"; then 
-       AC_MSG_RESULT([ * Mac OSX specific configuration])
-       AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
-       AC_DEFINE(HAVE_2ARG_DBTOB, 1, [Define if dbtob takes two arguments])
-       dnl AC_DEFINE(NO_DLFCN_H)
-       AC_DEFINE(NO_QUOTA_SUPPORT, 1, [Define if Quota support should be disabled])
-       AC_DEFINE(MACOSX_SERVER, 1, [Define if compiling for MacOS X Server])
-fi
-
 dnl ----- NetBSD specific -----
 if test x"$this_os" = "xnetbsd"; then 
        AC_MSG_RESULT([ * NetBSD specific configuration])
@@ -307,6 +281,7 @@ fi
 dnl ----- OpenBSD specific -----
 if test x"$this_os" = "xopenbsd"; then 
        AC_MSG_RESULT([ * OpenBSD specific configuration])
+    AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
        dnl ----- OpenBSD does not have crypt.h, uses unistd.h -----
        AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
 fi
@@ -318,6 +293,8 @@ if test x"$this_os" = "xsolaris"; then
        AC_DEFINE(_ISOC9X_SOURCE, 1, [Compatibility macro])
        AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
        AC_DEFINE(SOLARIS, 1, [Solaris compatibility macro])
+    AC_DEFINE(_XOPEN_SOURCE, 600, [Solaris compilation environment])
+    AC_DEFINE(__EXTENSIONS__,  1, [Solaris compilation environment])
        CFLAGS="-I\$(top_srcdir)/sys/generic $CFLAGS"
        need_dash_r=yes
        sysv_style=solaris
@@ -594,13 +571,27 @@ if test x"$with_acl_support" = x"yes" ; then
                                        acl_perm_t perm;
                                        return acl_get_perm_np(permset_d, perm);
                                ],
-                               [samba_cv_HAVE_ACL_GET_PERM_NP=yes],
-                               [samba_cv_HAVE_ACL_GET_PERM_NP=no])
+                               [netatalk_cv_HAVE_ACL_GET_PERM_NP=yes],
+                               [netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
                                LIBS=$acl_LIBS
                        ])
-                       if test x"netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
+                       if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
                                AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
                        fi
+
+
+                       AC_CACHE_CHECK([for acl_from_mode], netatalk_cv_HAVE_ACL_FROM_MODE,[
+                               acl_LIBS=$LIBS
+                               LIBS="$LIBS $ACL_LIBS"
+                AC_CHECK_FUNCS(acl_from_mode,
+                               [netatalk_cv_HAVE_ACL_FROM_MODE=yes],
+                               [netatalk_cv_HAVE_ACL_FROM_MODE=no])
+                               LIBS=$acl_LIBS
+                       ])
+                       if test x"netatalk_cv_HAVE_ACL_FROM_MODE" = x"yes"; then
+                               AC_DEFINE(HAVE_ACL_FROM_MODE,1,[Whether acl_from_mode() is available])
+                       fi
+
                else
                        AC_MSG_NOTICE(ACL support is not avaliable)
                        AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
@@ -610,6 +601,7 @@ if test x"$with_acl_support" = x"yes" ; then
 fi
 
 if test x"$with_acl_support" = x"yes" ; then
+   AC_CHECK_HEADERS([acl/libacl.h])
     AC_DEFINE(HAVE_ACLS,1,[Whether ACLs support is available])
     AC_SUBST(ACL_LIBS)
 fi
@@ -638,7 +630,7 @@ case "$this_os" in
 
   *solaris*)
        AC_CHECK_FUNCS([attropen],
-                   [neta_cv_eas_sys_found=yes],
+                   [neta_cv_eas_sys_found=yes; AC_DEFINE(HAVE_EAFD, 1, [extattr API has full fledged fds for EAs])],
                    [neta_cv_eas_sys_not_found=yes])
   ;;
 
@@ -719,8 +711,125 @@ fi
 AC_DEFINE_UNQUOTED(EA_MODULES,["$neta_cv_eas"],[Available Extended Attributes modules])
 ])
 
-AC_DEFUN([AC_NETATALK_], [
+dnl Check for libsmbsharemodes from Samba for Samba/Netatalk access/deny/share modes interop
+dnl Defines "neta_cv_have_smbshmd" to "yes" or "no"
+dnl AC_SUBST's "SMB_SHAREMODES_CFLAGS" and "SMB_SHAREMODES_LDFLAGS"
+dnl AM_CONDITIONAL's "USE_SMB_SHAREMODES"
+AC_DEFUN([AC_NETATALK_SMB_SHAREMODES], [
+    neta_cv_have_smbshmd=no
+    AC_ARG_WITH(smbsharemodes-lib,
+                [  --with-smbsharemodes-lib=PATH        PATH to libsmbsharemodes lib from Samba],
+                [SMB_SHAREMODES_LDFLAGS="-L$withval -lsmbsharemodes"]
+    )
+    AC_ARG_WITH(smbsharemodes-include,
+                [  --with-smbsharemodes-include=PATH    PATH to libsmbsharemodes header from Samba],
+                [SMB_SHAREMODES_CFLAGS="-I$withval"]
+    )
+    AC_ARG_WITH(smbsharemodes,
+                [AS_HELP_STRING([--with-smbsharemodes],[Samba interop (default is yes)])],
+                [use_smbsharemodes=$withval],
+                [use_smbsharemodes=yes]
+    )
+
+    if test x"$use_smbsharemodes" = x"yes" ; then
+        AC_MSG_CHECKING([whether to enable Samba/Netatalk access/deny/share-modes interop])
+
+        saved_CFLAGS="$CFLAGS"
+        saved_LDFLAGS="$LDFLAGS"
+        CFLAGS="$SMB_SHAREMODES_CFLAGS $CFLAGS"
+        LDFLAGS="$SMB_SHAREMODES_LDFLAGS $LDFLAGS"
+
+        AC_LINK_IFELSE(
+            [#include <unistd.h>
+             #include <stdio.h>
+             #include <sys/time.h>
+             #include <time.h>
+             #include <stdint.h>
+             /* From messages.h */
+             struct server_id {
+                 pid_t pid;
+             };
+             #include "smb_share_modes.h"
+             int main(void) { (void)smb_share_mode_db_open(""); return 0;}],
+            [neta_cv_have_smbshmd=yes]
+        )
+
+        AC_MSG_RESULT($neta_cv_have_smbshmd)
+        AC_SUBST(SMB_SHAREMODES_CFLAGS, [$SMB_SHAREMODES_CFLAGS])
+        AC_SUBST(SMB_SHAREMODES_LDFLAGS, [$SMB_SHAREMODES_LDFLAGS])
+        CFLAGS="$saved_CFLAGS"
+        LDFLAGS="$saved_LDFLAGS"
+    fi
+
+    AM_CONDITIONAL(USE_SMB_SHAREMODES, test x"$neta_cv_have_smbshmd" = x"yes")
 ])
 
-AC_DEFUN([AC_NETATALK_], [
+dnl ------ Check for sendfile() --------
+AC_DEFUN([AC_NETATALK_SENDFILE], [
+netatalk_cv_search_sendfile=yes
+AC_ARG_ENABLE(sendfile,
+    [  --disable-sendfile       disable sendfile syscall],
+    [if test x"$enableval" = x"no"; then
+            netatalk_cv_search_sendfile=no
+        fi]
+)
+
+if test x"$netatalk_cv_search_sendfile" = x"yes"; then
+   case "$host_os" in
+   *linux*)
+        AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
+        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
+        ;;
+
+    *solaris*)
+        AC_DEFINE(SENDFILE_FLAVOR_SOLARIS, 1, [Solaris sendfile()])
+        AC_SEARCH_LIBS(sendfile, sendfile)
+        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
+        ;;
+
+    *freebsd*)
+        AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
+        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
+        ;;
+
+    *)
+        ;;
+
+    esac
+
+    if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
+        AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
+    fi
+fi
 ])
+
+dnl --------------------- Check if realpath() takes NULL
+AC_DEFUN([AC_NETATALK_REALPATH], [
+AC_CACHE_CHECK([if the realpath function allows a NULL argument],
+    neta_cv_REALPATH_TAKES_NULL, [
+        AC_TRY_RUN([
+            #include <stdio.h>
+            #include <limits.h>
+            #include <signal.h>
+
+            void exit_on_core(int ignored) {
+                 exit(1);
+            }
+
+            main() {
+                char *newpath;
+                signal(SIGSEGV, exit_on_core);
+                newpath = realpath("/tmp", NULL);
+                exit((newpath != NULL) ? 0 : 1);
+            }],
+            neta_cv_REALPATH_TAKES_NULL=yes,
+            neta_cv_REALPATH_TAKES_NULL=no,
+            neta_cv_REALPATH_TAKES_NULL=cross
+        )
+    ]
+)
+
+if test x"$neta_cv_REALPATH_TAKES_NULL" = x"yes"; then
+    AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
+fi
+])
\ No newline at end of file