]> git.proxmox.com Git - mirror_spl-debian.git/blobdiff - config/spl-build.m4
Imported Upstream version 0.6.2
[mirror_spl-debian.git] / config / spl-build.m4
index 4cb7e1da29bce1681608273feac4d0ecb1fd75a3..f54c5b166bb8eac72143d7d6988608dcbbecbc60 100644 (file)
@@ -33,6 +33,8 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_TASK_CURR
        SPL_AC_CTL_UNNUMBERED
        SPL_AC_CTL_NAME
+       SPL_AC_VMALLOC_INFO
+       SPL_AC_PDE_DATA
        SPL_AC_FLS64
        SPL_AC_DEVICE_CREATE
        SPL_AC_5ARGS_DEVICE_CREATE
@@ -63,7 +65,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_GET_ZONE_COUNTS
        SPL_AC_USER_PATH_DIR
        SPL_AC_SET_FS_PWD
-       SPL_AC_2ARGS_SET_FS_PWD
+       SPL_AC_SET_FS_PWD_WITH_CONST
        SPL_AC_2ARGS_VFS_UNLINK
        SPL_AC_4ARGS_VFS_RENAME
        SPL_AC_VFS_FSYNC
@@ -71,6 +73,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_INODE_TRUNCATE_RANGE
        SPL_AC_FS_STRUCT_SPINLOCK
        SPL_AC_CRED_STRUCT
+       SPL_AC_KUIDGID_T
        SPL_AC_GROUPS_SEARCH
        SPL_AC_PUT_TASK_STRUCT
        SPL_AC_5ARGS_PROC_HANDLER
@@ -88,6 +91,8 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
        SPL_AC_SHRINK_CONTROL_STRUCT
        SPL_AC_RWSEM_SPINLOCK_IS_RAW
+       SPL_AC_SCHED_RT_HEADER
+       SPL_AC_2ARGS_VFS_GETATTR
 ])
 
 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
@@ -103,7 +108,7 @@ AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
                if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
                        AC_MSG_ERROR([
        *** Please make sure the kernel devel package for your distribution
-       *** is installed.  If your building with a custom kernel make sure the
+       *** is installed.  If you are building with a custom kernel, make sure the
        *** kernel is configured, built, and the '--with-linux=PATH' configure
        *** option refers to the location of the kernel source.])
                fi
@@ -154,7 +159,7 @@ AC_DEFUN([SPL_AC_KERNEL], [
        if test ! -d "$kernelsrc"; then
                AC_MSG_ERROR([
        *** Please make sure the kernel devel package for your distribution
-       *** is installed then try again.  If that fails you can specify the
+       *** is installed and then try again.  If that fails, you can specify the
        *** location of the kernel source with the '--with-linux=PATH' option.])
        fi
 
@@ -227,9 +232,14 @@ AC_DEFUN([SPL_AC_CONFIG_USER], [])
 
 dnl #
 dnl # Check for rpm+rpmbuild to build RPM packages.  If these tools
-dnl # are missing it is non-fatal but you will not be able to build
+dnl # are missing, it is non-fatal, but you will not be able to build
 dnl # RPM packages and will be warned if you try too.
 dnl #
+dnl # By default, the generic spec file will be used because it requires
+dnl # minimal dependencies.  Distribution specific spec files can be
+dnl # placed under the 'rpm/<distribution>' directory and enabled using
+dnl # the --with-spec=<distribution> configure option.
+dnl #
 AC_DEFUN([SPL_AC_RPM], [
        RPM=rpm
        RPMBUILD=rpmbuild
@@ -254,6 +264,25 @@ AC_DEFUN([SPL_AC_RPM], [
                AC_MSG_RESULT([$HAVE_RPMBUILD])
        ])
 
+       RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
+       RPM_DEFINE_UTIL=
+       RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
+       RPM_DEFINE_DKMS=
+
+       SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
+       SRPM_DEFINE_UTIL=
+       SRPM_DEFINE_KMOD=
+       SRPM_DEFINE_DKMS=
+
+       RPM_SPEC_DIR="rpm/generic"
+       AC_ARG_WITH([spec],
+               AS_HELP_STRING([--with-spec=SPEC],
+               [Spec files 'generic|fedora']),
+               [RPM_SPEC_DIR="rpm/$withval"])
+
+       AC_MSG_CHECKING([whether spec files are available])
+       AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
+
        AC_SUBST(HAVE_RPM)
        AC_SUBST(RPM)
        AC_SUBST(RPM_VERSION)
@@ -261,6 +290,16 @@ AC_DEFUN([SPL_AC_RPM], [
        AC_SUBST(HAVE_RPMBUILD)
        AC_SUBST(RPMBUILD)
        AC_SUBST(RPMBUILD_VERSION)
+
+       AC_SUBST(RPM_SPEC_DIR)
+       AC_SUBST(RPM_DEFINE_UTIL)
+       AC_SUBST(RPM_DEFINE_KMOD)
+       AC_SUBST(RPM_DEFINE_DKMS)
+       AC_SUBST(RPM_DEFINE_COMMON)
+       AC_SUBST(SRPM_DEFINE_UTIL)
+       AC_SUBST(SRPM_DEFINE_KMOD)
+       AC_SUBST(SRPM_DEFINE_DKMS)
+       AC_SUBST(SRPM_DEFINE_COMMON)
 ])
 
 dnl #
@@ -302,48 +341,6 @@ AC_DEFUN([SPL_AC_DPKG], [
        AC_SUBST(DPKGBUILD_VERSION)
 ])
 
-dnl #
-dnl # Check for pacman+makepkg to build Arch Linux packages.  If these
-dnl # tools are missing it is non-fatal but you will not be able to
-dnl # build Arch Linux packages and will be warned if you try too.
-dnl #
-AC_DEFUN([SPL_AC_PACMAN], [
-       PACMAN=pacman
-       MAKEPKG=makepkg
-
-       AC_MSG_CHECKING([whether $PACMAN is available])
-       tmp=$($PACMAN --version 2>/dev/null)
-       AS_IF([test -n "$tmp"], [
-               PACMAN_VERSION=$(echo $tmp |
-                                $AWK '/Pacman/ { print $[3] }' |
-                                $SED 's/^v//')
-               HAVE_PACMAN=yes
-               AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
-       ],[
-               HAVE_PACMAN=no
-               AC_MSG_RESULT([$HAVE_PACMAN])
-       ])
-
-       AC_MSG_CHECKING([whether $MAKEPKG is available])
-       tmp=$($MAKEPKG --version 2>/dev/null)
-       AS_IF([test -n "$tmp"], [
-               MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
-               HAVE_MAKEPKG=yes
-               AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
-       ],[
-               HAVE_MAKEPKG=no
-               AC_MSG_RESULT([$HAVE_MAKEPKG])
-       ])
-
-       AC_SUBST(HAVE_PACMAN)
-       AC_SUBST(PACMAN)
-       AC_SUBST(PACMAN_VERSION)
-
-       AC_SUBST(HAVE_MAKEPKG)
-       AC_SUBST(MAKEPKG)
-       AC_SUBST(MAKEPKG_VERSION)
-])
-
 dnl #
 dnl # Until native packaging for various different packing systems
 dnl # can be added the least we can do is attempt to use alien to
@@ -406,7 +403,7 @@ AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
                redhat)     DEFAULT_PACKAGE=rpm  ;;
                fedora)     DEFAULT_PACKAGE=rpm  ;;
                gentoo)     DEFAULT_PACKAGE=tgz  ;;
-               arch)       DEFAULT_PACKAGE=arch ;;
+               arch)       DEFAULT_PACKAGE=tgz  ;;
                sles)       DEFAULT_PACKAGE=rpm  ;;
                slackware)  DEFAULT_PACKAGE=tgz  ;;
                lunar)      DEFAULT_PACKAGE=tgz  ;;
@@ -427,8 +424,6 @@ AC_DEFUN([SPL_AC_PACKAGE], [
        SPL_AC_RPM
        SPL_AC_DPKG
        SPL_AC_ALIEN
-
-       AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
 ])
 
 AC_DEFUN([SPL_AC_LICENSE], [
@@ -1365,6 +1360,43 @@ AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
        ])
 ])
 
+dnl #
+dnl # 3.10 API change,
+dnl # struct vmalloc_info is now declared in linux/vmalloc.h
+dnl #
+AC_DEFUN([SPL_AC_VMALLOC_INFO], [
+       AC_MSG_CHECKING([whether struct vmalloc_info is declared])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/vmalloc.h>
+               struct vmalloc_info { void *a; };
+       ],[
+               return 0;
+       ],[
+               AC_MSG_RESULT(no)
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
+       ])
+])
+
+dnl #
+dnl # 3.10 API change,
+dnl # PDE is replaced by PDE_DATA
+dnl #
+AC_DEFUN([SPL_AC_PDE_DATA], [
+       AC_MSG_CHECKING([whether PDE_DATA() is available])
+       SPL_LINUX_TRY_COMPILE_SYMBOL([
+               #include <linux/proc_fs.h>
+       ], [
+               PDE_DATA(NULL);
+       ], [PDE_DATA], [], [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
 dnl #
 dnl # 2.6.17 API change
 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
@@ -1714,23 +1746,43 @@ AC_DEFUN([SPL_AC_SET_FS_PWD],
 ])
 
 dnl #
-dnl # 2.6.25 API change,
-dnl # Simplied API by replacing mnt+dentry args with a single path arg.
+dnl # 3.9 API change
+dnl # set_fs_pwd takes const struct path *
 dnl #
-AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
-       [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
+AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
+       [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/sched.h>
+               #include <linux/spinlock.h>
                #include <linux/fs_struct.h>
+               #include <linux/path.h>
+               void (*const set_fs_pwd_func)
+                       (struct fs_struct *, const struct path *)
+                       = set_fs_pwd;
        ],[
-               set_fs_pwd(NULL, NULL);
+               return 0;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
-                         [set_fs_pwd() wants 2 args])
-       ],[
-               AC_MSG_RESULT(no)
+               AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
+                       [set_fs_pwd() needs const path *])
+       ],[
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/spinlock.h>
+                       #include <linux/fs_struct.h>
+                       #include <linux/path.h>
+                       void (*const set_fs_pwd_func)
+                               (struct fs_struct *, struct path *)
+                               = set_fs_pwd;
+               ],[
+                       return 0;
+               ],[
+                       AC_MSG_RESULT(no)
+               ],[
+                       AC_MSG_ERROR(unknown)
+               ])
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 dnl #
@@ -1815,6 +1867,36 @@ AC_DEFUN([SPL_AC_CRED_STRUCT], [
        ])
 ])
 
+
+dnl #
+dnl # User namespaces, use kuid_t in place of uid_t
+dnl # where available. Not strictly a user namespaces thing
+dnl # but it should prevent surprises
+dnl #
+AC_DEFUN([SPL_AC_KUIDGID_T], [
+       AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/uidgid.h>
+       ], [
+               kuid_t userid = KUIDT_INIT(0);
+               kgid_t groupid = KGIDT_INIT(0);
+       ],[
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/uidgid.h>
+               ], [
+                       kuid_t userid = 0;
+                       kgid_t groupid = 0;
+               ],[
+                       AC_MSG_RESULT(yes; optional)
+               ],[
+                       AC_MSG_RESULT(yes; mandatory)
+                       AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
+               ])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
 dnl #
 dnl # Custom SPL patch may export this symbol.
 dnl #
@@ -1822,8 +1904,15 @@ AC_DEFUN([SPL_AC_GROUPS_SEARCH],
        [AC_MSG_CHECKING([whether groups_search() is available])
        SPL_LINUX_TRY_COMPILE_SYMBOL([
                #include <linux/cred.h>
+               #ifdef HAVE_KUIDGID_T
+               #include <linux/uidgid.h>
+               #endif
        ], [
+               #ifdef HAVE_KUIDGID_T
+               groups_search(NULL, KGIDT_INIT(0));
+               #else
                groups_search(NULL, 0);
+               #endif
        ], [groups_search], [], [
                AC_MSG_RESULT(yes)
                AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
@@ -2261,3 +2350,53 @@ AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
        ])
        EXTRA_KCFLAGS="$tmp_flags"
 ])
+
+dnl #
+dnl # 3.9 API change,
+dnl # Moved things from linux/sched.h to linux/sched/rt.h
+dnl #
+AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
+       [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/sched.h>
+               #include <linux/sched/rt.h>
+       ],[
+               return 0;
+       ],[
+               AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
+               AC_MSG_RESULT(yes)
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
+dnl #
+dnl # 3.9 API change,
+dnl # vfs_getattr() uses 2 args
+dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
+dnl #
+AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
+       AC_MSG_CHECKING([whether vfs_getattr() wants])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/fs.h>
+       ],[
+               vfs_getattr((struct path *) NULL,
+                       (struct kstat *)NULL);
+       ],[
+               AC_MSG_RESULT(2 args)
+               AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
+                         [vfs_getattr wants 2 args])
+       ],[
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/fs.h>
+               ],[
+                       vfs_getattr((struct vfsmount *)NULL,
+                               (struct dentry *)NULL,
+                               (struct kstat *)NULL);
+               ],[
+                       AC_MSG_RESULT(3 args)
+               ],[
+                       AC_MSG_ERROR(unknown)
+               ])
+       ])
+])