Merge commit 'refs/top-bases/linux-have-libdiskmgt' into linux-have-libdiskmgt

This commit is contained in:
Brian Behlendorf 2009-07-01 11:09:52 -07:00
commit 78f7e07b9a
11 changed files with 662 additions and 406 deletions

2
META
View File

@ -1,6 +1,6 @@
Meta: 1 Meta: 1
Name: zfs Name: zfs
Branch: 1.0 Branch: 1.0
Version: 0.4.3 Version: 0.4.4
Release: 1 Release: 1
Release-Tags: relext Release-Tags: relext

View File

@ -1,8 +1,18 @@
SUBDIRS = config doc scripts lib cmd module include $(top_srcdir)/config/rpm.am
if CONFIG_USER
USER_DIR = config doc scripts lib cmd
endif
if CONFIG_KERNEL
KERNEL_DIR = module
endif
SUBDIRS = $(USER_DIR) $(KERNEL_DIR)
AUTOMAKE_OPTIONS = foreign dist-zip AUTOMAKE_OPTIONS = foreign dist-zip
EXTRA_DIST = autogen.sh zfs.spec.in META DISCLAIMER GIT EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in
EXTRA_DIST += META DISCLAIMER GIT
EXTRA_DIST += OPENSOLARIS.LICENSE ZFS.RELEASE EXTRA_DIST += OPENSOLARIS.LICENSE ZFS.RELEASE
noinst_HEADERS = zfs_config.h zfs_unconfig.h
distclean-local:: distclean-local::
-$(RM) -R autom4te*.cache -$(RM) -R autom4te*.cache
@ -16,10 +26,13 @@ distclean-local::
-o -name '.script-config' \) \ -o -name '.script-config' \) \
-type f -print | xargs $(RM) -type f -print | xargs $(RM)
if CONFIG_KERNEL
install-data-local: install-data-local:
/bin/mkdir -p $(DESTDIR)/$(LINUX)/include/zfs instdest=$(DESTDIR)/${prefix}/src/zfs-$(ZFS_META_VERSION); \
$(INSTALL) module/Module.symvers $(DESTDIR)/$(LINUX)/include/zfs for instfile in $(noinst_HEADERS) module/$(LINUX_SYMBOLS); do \
$(INSTALL) zfs_config.h $(DESTDIR)/$(LINUX)/include/zfs $(INSTALL) -D $$instfile $$instdest/$$instfile; \
done
endif
ctags: ctags:
$(RM) $(top_srcdir)/tags $(RM) $(top_srcdir)/tags
@ -31,27 +44,22 @@ etags:
tags: ctags etags tags: ctags etags
rpm-local: srpm-modules:
mkdir -p $(rpmbuild)/TMP && \ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common
mkdir -p $(rpmbuild)/BUILD && \
mkdir -p $(rpmbuild)/RPMS && \
mkdir -p $(rpmbuild)/SRPMS && \
mkdir -p $(rpmbuild)/SPECS && cp $(PACKAGE).spec $(rpmbuild)/SPECS && \
mkdir -p $(rpmbuild)/SOURCES && cp $(distdir).tar.gz $(rpmbuild)/SOURCES
srpm: dist srpm-utils:
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common
$(MAKE) $(AM_MAKEFLAGS) rpmbuild="$$rpmbuild" rpm-local || exit 1; \
/usr/bin/rpmbuild --define "_tmppath $$rpmbuild/TMP" --define "_topdir $$rpmbuild" --define "build_src_rpm 1" --define "dist %{nil}" --nodeps -bs $$rpmbuild/SPECS/$(PACKAGE).spec || exit 1; \
cp $$rpmbuild/SRPMS/$(distdir)-$(ZFS_META_RELEASE).src.rpm . || exit 1;\
$(RM) -R $$rpmbuild
# Use 'make rpm LINUX_VERSION=2.x.y-z' to rebuild the source RPM srpm: srpm-modules srpm-utils
# against any installed kernel-devel-2.x.y-z package. This will
# override the LINUX_VERSION detected at configure time. rpm-modules: srpm-modules
rpm: srpm $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
$(MAKE) $(AM_MAKEFLAGS) rpmbuild="$$rpmbuild" rpm-local || exit 1; \ rpm-utils: srpm-utils
/usr/bin/rpmbuild --define "_tmppath $$rpmbuild/TMP" --define "_topdir $$rpmbuild" --define "dist %{nil}" --define "require_kver $(LINUX_VERSION)" --nodeps --rebuild $(distdir)-$(ZFS_META_RELEASE).src.rpm || exit 1; \ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common
cp $$rpmbuild/RPMS/*/* . || exit 1; \
$(RM) -R $$rpmbuild rpm-modules: srpm-modules
rpm-utils: srpm-utils
rpm: rpm-modules rpm-utils

View File

@ -2,6 +2,10 @@ dnl #
dnl # Default ZFS kernel configuration dnl # Default ZFS kernel configuration
dnl # dnl #
AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL
ZFS_AC_SPL
ZFS_AC_CONFIG_KERNEL_BIO_ARGS
dnl # Kernel build make options dnl # Kernel build make options
dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build
KERNELMAKE_PARAMS= KERNELMAKE_PARAMS=
@ -10,14 +14,312 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
dnl # compiler options are added by the kernel build system. dnl # compiler options are added by the kernel build system.
KERNELCPPFLAGS="$KERNELCPPFLAGS -Werror -DHAVE_SPL -D_KERNEL" KERNELCPPFLAGS="$KERNELCPPFLAGS -Werror -DHAVE_SPL -D_KERNEL"
KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\""
KERNELCPPFLAGS="$KERNELCPPFLAGS -I$splsrc -I$splsrc/include -I$TOPDIR" KERNELCPPFLAGS="$KERNELCPPFLAGS -I$TOPDIR -I$SPL -I$SPL/include"
if test "$kernelbuild" != "$kernelsrc"; then if test "$LINUX_OBJ" != "$LINUX"; then
KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild" KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
fi fi
AC_SUBST(KERNELMAKE_PARAMS) AC_SUBST(KERNELMAKE_PARAMS)
AC_SUBST(KERNELCPPFLAGS) AC_SUBST(KERNELCPPFLAGS)
])
ZFS_AC_CONFIG_KERNEL_BIO_ARGS
dnl #
dnl # Detect name used more Module.symvers file
dnl #
AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
AC_MSG_CHECKING([kernel file name for module symbols])
if grep -q Modules.symvers $LINUX/scripts/Makefile.modpost; then
LINUX_SYMBOLS=Modules.symvers
else
LINUX_SYMBOLS=Module.symvers
fi
AC_MSG_RESULT($LINUX_SYMBOLS)
AC_SUBST(LINUX_SYMBOLS)
])
dnl #
dnl # Detect the kernel to be built against
dnl #
AC_DEFUN([ZFS_AC_KERNEL], [
AC_ARG_WITH([linux],
AS_HELP_STRING([--with-linux=PATH],
[Path to kernel source]),
[kernelsrc="$withval"])
AC_ARG_WITH(linux-obj,
AS_HELP_STRING([--with-linux-obj=PATH],
[Path to kernel build objects]),
[kernelbuild="$withval"])
AC_MSG_CHECKING([kernel source directory])
if test -z "$kernelsrc"; then
sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
2>/dev/null | grep -v obj | tail -1`
if test -e $sourcelink; then
kernelsrc=`readlink -f ${sourcelink}`
else
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Please specify the location of the kernel source
*** with the '--with-linux=PATH' option])
fi
else
if test "$kernelsrc" = "NONE"; then
kernsrcver=NONE
fi
fi
AC_MSG_RESULT([$kernelsrc])
AC_MSG_CHECKING([kernel build directory])
if test -z "$kernelbuild"; then
if test -d ${kernelsrc}-obj; then
kernelbuild=${kernelsrc}-obj/`arch`/`arch`
elif test -d `dirname ${kernelsrc}`/build-`arch`; then
kernelbuild=`dirname ${kernelsrc}`/build-`arch`
else
kernelbuild=${kernelsrc}
fi
fi
AC_MSG_RESULT([$kernelbuild])
AC_MSG_CHECKING([kernel source version])
if test -r $kernelbuild/include/linux/version.h &&
fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
kernsrcver=`(echo "#include <linux/version.h>";
echo "kernsrcver=UTS_RELEASE") |
cpp -I $kernelbuild/include |
grep "^kernsrcver=" | cut -d \" -f 2`
elif test -r $kernelbuild/include/linux/utsrelease.h &&
fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
kernsrcver=`(echo "#include <linux/utsrelease.h>";
echo "kernsrcver=UTS_RELEASE") |
cpp -I $kernelbuild/include |
grep "^kernsrcver=" | cut -d \" -f 2`
fi
if test -z "$kernsrcver"; then
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Cannot determine the version of the linux kernel source.
*** Please prepare the kernel before running this script])
fi
AC_MSG_RESULT([$kernsrcver])
LINUX=${kernelsrc}
LINUX_OBJ=${kernelbuild}
LINUX_VERSION=${kernsrcver}
AC_SUBST(LINUX)
AC_SUBST(LINUX_OBJ)
AC_SUBST(LINUX_VERSION)
ZFS_AC_MODULE_SYMVERS
])
dnl #
dnl # Detect name used for the additional SPL Module.symvers file
dnl #
AC_DEFUN([ZFS_AC_SPL_MODULE_SYMVERS], [
AC_MSG_CHECKING([spl file name for module symbols])
if test -r $SPL_OBJ/Module.symvers; then
SPL_SYMBOLS=Module.symvers
elif test -r $SPL_OBJ/Modules.symvers; then
SPL_SYMBOLS=Modules.symvers
else
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Cannot find extra Module{s}.symvers in the spl source.
*** Please prepare the spl source before running this script])
fi
AC_MSG_RESULT([$SPL_SYMBOLS])
AC_SUBST(SPL_SYMBOLS)
])
dnl #
dnl # Detect the SPL module to be built against
dnl #
AC_DEFUN([ZFS_AC_SPL], [
AC_ARG_WITH([spl],
AS_HELP_STRING([--with-spl=PATH],
[Path to spl source]),
[splsrc="$withval"])
AC_ARG_WITH([spl-obj],
AS_HELP_STRING([--with-spl-obj=PATH],
[Path to spl build objects]),
[splbuild="$withval"])
AC_MSG_CHECKING([spl source directory])
if test -z "$splsrc"; then
sourcelink=`ls -1d /usr/src/spl-*/${LINUX_VERSION} \
2>/dev/null | tail -1`
if test -e $sourcelink; then
splsrc=`readlink -f ${sourcelink}`
else
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Please specify the location of the spl source
*** with the '--with-spl=PATH' option])
fi
else
if test "$splsrc" = "NONE"; then
splbuild=NONE
splsrcver=NONE
fi
fi
AC_MSG_RESULT([$splsrc])
AC_MSG_CHECKING([spl build directory])
if test -z "$splbuild"; then
if test -d ${splsrc}/module; then
splbuild=${splsrc}/module
else
splbuild=${splsrc}
fi
fi
AC_MSG_RESULT([$splbuild])
AC_MSG_CHECKING([spl source version])
if test -r $splsrc/spl_config.h &&
fgrep -q SPL_META_VERSION $splsrc/spl_config.h; then
splsrcver=`(echo "#include <spl_config.h>";
echo "splsrcver=SPL_META_VERSION") |
cpp -I $splsrc |
grep "^splsrcver=" | cut -d \" -f 2`
fi
if test -z "$splsrcver"; then
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Cannot determine the version of the spl source.
*** Please prepare the spl source before running this script])
fi
AC_MSG_RESULT([$splsrcver])
SPL=${splsrc}
SPL_OBJ=${splbuild}
SPL_VERSION=${splsrcver}
AC_SUBST(SPL)
AC_SUBST(SPL_OBJ)
AC_SUBST(SPL_VERSION)
ZFS_AC_SPL_MODULE_SYMVERS
])
dnl #
dnl # ZFS_LINUX_CONFTEST
dnl #
AC_DEFUN([ZFS_LINUX_CONFTEST], [
cat >conftest.c <<_ACEOF
$1
_ACEOF
])
dnl #
dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
dnl #
m4_define([ZFS_LANG_PROGRAM], [
$1
int
main (void)
{
dnl Do *not* indent the following line: there may be CPP directives.
dnl Don't move the `;' right after for the same reason.
$2
;
return 0;
}
])
dnl #
dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
dnl #
AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])
rm -Rf build && mkdir -p build
echo "obj-m := conftest.o" >build/Makefile
AS_IF(
[AC_TRY_COMMAND(cp conftest.c build && make [$2] LINUXINCLUDE="-Iinclude -Iinclude2 -I$LINUX/include -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
[$4],
[_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
)
rm -Rf build
])
dnl #
dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
dnl #
AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
[ZFS_LINUX_COMPILE_IFELSE(
[AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
[modules],
[test -s build/conftest.o],
[$3], [$4])
])
dnl #
dnl # ZFS_LINUX_CONFIG
dnl #
AC_DEFUN([ZFS_LINUX_CONFIG],
[AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
ZFS_LINUX_TRY_COMPILE([
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
],[
#ifndef CONFIG_$1
#error CONFIG_$1 not #defined
#endif
],[
AC_MSG_RESULT([yes])
$2
],[
AC_MSG_RESULT([no])
$3
])
])
dnl #
dnl # ZFS_CHECK_SYMBOL_EXPORT
dnl # check symbol exported or not
dnl #
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
[AC_MSG_CHECKING([whether symbol $1 is exported])
grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
$LINUX_OBJ/Module*.symvers $SPL_OBJ/Module*.symvers 2>/dev/null
rc=$?
if test $rc -ne 0; then
export=0
for file in $2; do
grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
rc=$?
if test $rc -eq 0; then
export=1
break;
fi
done
if test $export -eq 0; then
AC_MSG_RESULT([no])
$4
else
AC_MSG_RESULT([yes])
$3
fi
else
AC_MSG_RESULT([yes])
$3
fi
]) ])

46
config/rpm.am Normal file
View File

@ -0,0 +1,46 @@
rpm-local:
mkdir -p $(rpmbuild)/TMP && \
mkdir -p $(rpmbuild)/BUILD && \
mkdir -p $(rpmbuild)/RPMS && \
mkdir -p $(rpmbuild)/SRPMS && \
mkdir -p $(rpmbuild)/SPECS && cp $(rpmspec) $(rpmbuild)/SPECS && \
mkdir -p $(rpmbuild)/SOURCES && cp $(distdir).tar.gz $(rpmbuild)/SOURCES
srpm-common: dist
rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \
rpmspec=$(pkg).spec; \
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
$(MAKE) $(AM_MAKEFLAGS) \
rpmbuild="$$rpmbuild" \
rpmspec="$$rpmspec" \
rpm-local || exit 1; \
/usr/bin/rpmbuild \
--define "_tmppath $$rpmbuild/TMP" \
--define "_topdir $$rpmbuild" \
--define "build_src_rpm 1" \
--define "dist %{nil}" \
--nodeps -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \
cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \
$(RM) -R $$rpmbuild
rpm-common:
rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \
rpmspec=$(pkg).spec; \
rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
$(MAKE) $(AM_MAKEFLAGS) \
rpmbuild="$$rpmbuild" \
rpmspec="$$rpmspec" \
rpm-local || exit 1; \
/usr/bin/rpmbuild \
--define "_tmppath $$rpmbuild/TMP" \
--define "_topdir $$rpmbuild" \
--define "dist %{nil}" \
--define "require_kdir $(LINUX)" \
--define "require_kobj $(LINUX_OBJ)" \
--define "require_kver $(LINUX_VERSION)" \
--define "require_spldir $(SPL)" \
--define "require_splobj $(SPL_OBJ)" \
--define "require_splver $(SPL_VERSION)" \
--nodeps --rebuild $$rpmpkg || exit 1; \
cp $$rpmbuild/RPMS/*/* . || exit 1; \
$(RM) -R $$rpmbuild

View File

@ -1,165 +1,3 @@
AC_DEFUN([ZFS_AC_KERNEL], [
AC_ARG_WITH([linux],
AS_HELP_STRING([--with-linux=PATH],
[Path to kernel source]),
[kernelsrc="$withval"; kernelbuild="$withval"])
AC_ARG_WITH(linux-obj,
AS_HELP_STRING([--with-linux-obj=PATH],
[Path to kernel build objects]),
[kernelbuild="$withval"])
AC_MSG_CHECKING([kernel source directory])
if test -z "$kernelsrc"; then
sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
2>/dev/null | grep -v obj | tail -1`
if test -e $sourcelink; then
kernelsrc=`readlink -f ${sourcelink}`
kernelbuild=
else
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Please specify the location of the kernel source
*** with the '--with-linux=PATH' option])
fi
else
if test "$kernelsrc" = "NONE"; then
kernsrcver=NONE
fi
fi
AC_MSG_RESULT([$kernelsrc])
AC_MSG_CHECKING([kernel build directory])
if test -z "$kernelbuild" && test -d ${kernelsrc}-obj; then
kernelbuild=${kernelsrc}-obj/`arch`/`arch`
else
kernelbuild=${kernelsrc}
fi
AC_MSG_RESULT([$kernelbuild])
AC_MSG_CHECKING([kernel source version])
if test -r $kernelbuild/include/linux/version.h &&
fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
kernsrcver=`(echo "#include <linux/version.h>";
echo "kernsrcver=UTS_RELEASE") |
cpp -I $kernelbuild/include |
grep "^kernsrcver=" | cut -d \" -f 2`
elif test -r $kernelbuild/include/linux/utsrelease.h &&
fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
kernsrcver=`(echo "#include <linux/utsrelease.h>";
echo "kernsrcver=UTS_RELEASE") |
cpp -I $kernelbuild/include |
grep "^kernsrcver=" | cut -d \" -f 2`
fi
if test -z "$kernsrcver"; then
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Cannot determine the version of the linux kernel source.
*** Please prepare the kernel before running this script])
fi
AC_MSG_RESULT([$kernsrcver])
LINUX=${kernelsrc}
LINUX_OBJ=${kernelbuild}
LINUX_VERSION=${kernsrcver}
AC_SUBST(LINUX)
AC_SUBST(LINUX_OBJ)
AC_SUBST(LINUX_VERSION)
])
AC_DEFUN([ZFS_AC_SPL], [
AC_ARG_WITH([spl],
AS_HELP_STRING([--with-spl=PATH],
[Path to spl source]),
[splsrc="$withval"; splbuild="$withval"])
AC_ARG_WITH([spl-obj],
AS_HELP_STRING([--with-spl-obj=PATH],
[Path to spl build objects]),
[splbuild="$withval"])
AC_MSG_CHECKING([spl source directory])
if test -z "$splsrc"; then
sourcelink=${LINUX}/include/spl
buildlink=${LINUX_OBJ}/include/spl
if test -e $sourcelink; then
splsrc=`readlink -f ${sourcelink}`
fi
if test -e $buildlink; then
splbuild=`readlink -f ${buildlink}`
fi
if test -z "$splsrc"; then
splsrc=$splbuild
fi
if test -z "$splsrc" -o -z "$splbuild"; then
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Please specify the location of the spl source
*** with the '--with-spl=PATH' option])
fi
else
if test "$splsrc" = "NONE"; then
splsymvers=NONE
splsrcver=NONE
fi
fi
AC_MSG_RESULT([$splsrc])
AC_MSG_CHECKING([spl build directory])
AC_MSG_RESULT([$splbuild])
AC_MSG_CHECKING([spl Module{s}.symvers])
if test -r $splbuild/module/Module.symvers; then
splsymvers=$splbuild/module/Module.symvers
elif test -r $splbuild/module/Modules.symvers; then
splsymvers=$splbuild/module/Modules.symvers
elif test -r $kernelbuild/include/spl/Module.symvers; then
splsymvers=$kernelbuild/include/spl/Module.symvers
elif test -r $kernelbuild/include/spl/Modules.symvers; then
splsymvers=$kernelbuild/include/spl/Modules.symvers
fi
if test -z "$splsymvers"; then
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Cannot find extra Module{s}.symvers in the spl source.
*** Please prepare the spl source before running this script])
fi
AC_MSG_RESULT([$splsymvers])
AC_MSG_CHECKING([spl source version])
if test -r $splbuild/spl_config.h &&
fgrep -q SPL_META_VERSION $splbuild/spl_config.h; then
splsrcver=`(echo "#include <spl_config.h>";
echo "splsrcver=SPL_META_VERSION") |
cpp -I $splbuild |
grep "^splsrcver=" | cut -d \" -f 2`
fi
if test -z "$splsrcver"; then
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([
*** Cannot determine the version of the spl source.
*** Please prepare the spl source before running this script])
fi
AC_MSG_RESULT([$splsrcver])
AC_SUBST(splsrc)
AC_SUBST(splsymvers)
])
AC_DEFUN([ZFS_AC_LICENSE], [ AC_DEFUN([ZFS_AC_LICENSE], [
AC_MSG_CHECKING([zfs license]) AC_MSG_CHECKING([zfs license])
LICENSE=`grep MODULE_LICENSE module/zfs/zfs_ioctl.c | cut -f2 -d'"'` LICENSE=`grep MODULE_LICENSE module/zfs/zfs_ioctl.c | cut -f2 -d'"'`
@ -200,48 +38,43 @@ AC_DEFUN([ZFS_AC_DEBUG], [
AC_DEFUN([ZFS_AC_CONFIG_SCRIPT], [ AC_DEFUN([ZFS_AC_CONFIG_SCRIPT], [
SCRIPT_CONFIG=.script-config SCRIPT_CONFIG=.script-config
rm -f ${SCRIPT_CONFIG} rm -f ${SCRIPT_CONFIG}
echo "KERNELSRC=${LINUX}" >>${SCRIPT_CONFIG} echo "KERNELSRC=${LINUX}" >>${SCRIPT_CONFIG}
echo "KERNELBUILD=${LINUX_OBJ}" >>${SCRIPT_CONFIG} echo "KERNELBUILD=${LINUX_OBJ}" >>${SCRIPT_CONFIG}
echo "KERNELSRCVER=$kernsrcver" >>${SCRIPT_CONFIG} echo "KERNELSRCVER=${LINUX_VERSION}" >>${SCRIPT_CONFIG}
echo >>${SCRIPT_CONFIG} echo >>${SCRIPT_CONFIG}
echo "SPLSRC=$splsrc" >>${SCRIPT_CONFIG} echo "SPLSRC=${SPL}" >>${SCRIPT_CONFIG}
echo "SPLBUILD=$splbuild" >>${SCRIPT_CONFIG} echo "SPLBUILD=${SPL_OBJ}" >>${SCRIPT_CONFIG}
echo "SPLSRCVER=$splsrcver" >>${SCRIPT_CONFIG} echo "SPLSRCVER=${SPL_VERSION}" >>${SCRIPT_CONFIG}
echo "SPLSYMVERS=$splsymvers" >>${SCRIPT_CONFIG} echo >>${SCRIPT_CONFIG}
echo >>${SCRIPT_CONFIG} echo "TOPDIR=${TOPDIR}" >>${SCRIPT_CONFIG}
echo "TOPDIR=${TOPDIR}" >>${SCRIPT_CONFIG} echo "BUILDDIR=${BUILDDIR}" >>${SCRIPT_CONFIG}
echo "LIBDIR=${LIBDIR}" >>${SCRIPT_CONFIG} echo "LIBDIR=${LIBDIR}" >>${SCRIPT_CONFIG}
echo "CMDDIR=${CMDDIR}" >>${SCRIPT_CONFIG} echo "CMDDIR=${CMDDIR}" >>${SCRIPT_CONFIG}
echo "MODDIR=${MODDIR}" >>${SCRIPT_CONFIG}
]) ])
AC_DEFUN([ZFS_AC_CONFIG], [ AC_DEFUN([ZFS_AC_CONFIG], [
TOPDIR=`readlink -f ${srcdir}`
TOPDIR=`/bin/pwd`
BUILDDIR=$TOPDIR BUILDDIR=$TOPDIR
LIBDIR=$TOPDIR/lib LIBDIR=$TOPDIR/lib
CMDDIR=$TOPDIR/cmd CMDDIR=$TOPDIR/cmd
MODDIR=$TOPDIR/module MODDIR=$TOPDIR/module
UNAME=`uname -r | cut -d- -f1`
if test -z "$ZFS_CONFIG"; then
ZFS_CONFIG=all
fi
AC_SUBST(UNAME)
AC_SUBST(TOPDIR) AC_SUBST(TOPDIR)
AC_SUBST(BUILDDIR) AC_SUBST(BUILDDIR)
AC_SUBST(LIBDIR) AC_SUBST(LIBDIR)
AC_SUBST(CMDDIR) AC_SUBST(CMDDIR)
AC_SUBST(MODDIR) AC_SUBST(MODDIR)
AC_SUBST(ZFS_CONFIG)
AC_ARG_WITH([zfs-config], ZFS_CONFIG=all
AC_ARG_WITH([config],
AS_HELP_STRING([--with-config=CONFIG], AS_HELP_STRING([--with-config=CONFIG],
[Config file 'kernel|user|all']), [Config file 'kernel|user|all']),
[ZFS_CONFIG="$withval"]) [ZFS_CONFIG="$withval"])
AC_MSG_CHECKING([zfs config]) AC_MSG_CHECKING([zfs config])
AC_MSG_RESULT([$ZFS_CONFIG]); AC_MSG_RESULT([$ZFS_CONFIG]);
AC_SUBST(ZFS_CONFIG)
case "$ZFS_CONFIG" in case "$ZFS_CONFIG" in
kernel) ZFS_AC_CONFIG_KERNEL ;; kernel) ZFS_AC_CONFIG_KERNEL ;;
@ -254,110 +87,12 @@ AC_DEFUN([ZFS_AC_CONFIG], [
user kernel|user|all]) ;; user kernel|user|all]) ;;
esac esac
AM_CONDITIONAL([CONFIG_USER],
[test "$ZFS_CONFIG" = user] ||
[test "$ZFS_CONFIG" = all])
AM_CONDITIONAL([CONFIG_KERNEL],
[test "$ZFS_CONFIG" = kernel] ||
[test "$ZFS_CONFIG" = all])
ZFS_AC_CONFIG_SCRIPT ZFS_AC_CONFIG_SCRIPT
]) ])
dnl #
dnl # ZFS_LINUX_CONFTEST
dnl #
AC_DEFUN([ZFS_LINUX_CONFTEST], [
cat >conftest.c <<_ACEOF
$1
_ACEOF
])
dnl #
dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
dnl #
m4_define([ZFS_LANG_PROGRAM], [
$1
int
main (void)
{
dnl Do *not* indent the following line: there may be CPP directives.
dnl Don't move the `;' right after for the same reason.
$2
;
return 0;
}
])
dnl #
dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
dnl #
AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])
rm -Rf build && mkdir -p build
echo "obj-m := conftest.o" >build/Makefile
AS_IF(
[AC_TRY_COMMAND(cp conftest.c build && make [$2] LINUXINCLUDE="-Iinclude -Iinclude2 -I$LINUX/include -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
[$4],
[_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
)
rm -Rf build
])
dnl #
dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
dnl #
AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
[ZFS_LINUX_COMPILE_IFELSE(
[AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
[modules],
[test -s build/conftest.o],
[$3], [$4])
])
dnl #
dnl # ZFS_LINUX_CONFIG
dnl #
AC_DEFUN([ZFS_LINUX_CONFIG],
[AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
ZFS_LINUX_TRY_COMPILE([
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
],[
#ifndef CONFIG_$1
#error CONFIG_$1 not #defined
#endif
],[
AC_MSG_RESULT([yes])
$2
],[
AC_MSG_RESULT([no])
$3
])
])
dnl #
dnl # ZFS_CHECK_SYMBOL_EXPORT
dnl # check symbol exported or not
dnl #
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
[AC_MSG_CHECKING([whether symbol $1 is exported])
grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
$LINUX/Module.symvers $splsymvers 2>/dev/null
rc=$?
if test $rc -ne 0; then
export=0
for file in $2; do
grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
rc=$?
if test $rc -eq 0; then
export=1
break;
fi
done
if test $export -eq 0; then
AC_MSG_RESULT([no])
$4
else
AC_MSG_RESULT([yes])
$3
fi
else
AC_MSG_RESULT([yes])
$3
fi
])

View File

@ -37,6 +37,7 @@ AC_CONFIG_AUX_DIR([config])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([$ZFS_META_NAME], [$ZFS_META_VERSION]) AM_INIT_AUTOMAKE([$ZFS_META_NAME], [$ZFS_META_VERSION])
AC_CONFIG_HEADERS([zfs_config.h]) AC_CONFIG_HEADERS([zfs_config.h])
AH_BOTTOM([#include <zfs_unconfig.h>])
AM_MAINTAINER_MODE AM_MAINTAINER_MODE
AC_PROG_INSTALL AC_PROG_INSTALL
@ -44,8 +45,6 @@ AC_PROG_CC
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AM_PROG_AS AM_PROG_AS
ZFS_AC_KERNEL
ZFS_AC_SPL
ZFS_AC_LICENSE ZFS_AC_LICENSE
ZFS_AC_CONFIG ZFS_AC_CONFIG
ZFS_AC_DEBUG ZFS_AC_DEBUG
@ -77,6 +76,7 @@ AC_CONFIG_FILES([
scripts/Makefile scripts/Makefile
scripts/zpool-config/Makefile scripts/zpool-config/Makefile
zfs.spec zfs.spec
zfs-modules.spec
]) ])
AC_OUTPUT AC_OUTPUT

View File

@ -1 +1 @@
pkginclude_HEADERS = sys/*.h nobase_pkginclude_HEADERS = sys/*.h

View File

@ -6,19 +6,23 @@ subdir-m += zfs
modules clean: modules clean:
# Make the exported SPL symbols available to these modules. # Make the exported SPL symbols available to these modules.
cp @splsymvers@ . cp @SPL_OBJ@/@SPL_SYMBOLS@ .
$(MAKE) -C @LINUX@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@
modules_install: modules_install:
$(MAKE) -C @LINUX@ SUBDIRS=`pwd` \ $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` \
INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=addon $@ INSTALL_MOD_PATH=$(DESTDIR) \
INSTALL_MOD_DIR=addon/zfs $@
find ${DESTDIR}/lib/modules/ -name 'modules.*' | xargs ${RM}
# Install the required headers in to the kernel source # Install the required headers in to the kernel source
(mkdir -p $(DESTDIR)/@LINUX@/include/zfs && \ destname=zfs-@ZFS_META_VERSION@/@LINUX_VERSION@; \
instdest=$(DESTDIR)/@prefix@/src/$$destname; \
(mkdir -p $$instdest && \
find . -mindepth 3 -maxdepth 3 -name '*.h' | \ find . -mindepth 3 -maxdepth 3 -name '*.h' | \
xargs cp -t $(DESTDIR)/@LINUX@/include/zfs) || exit 1; \ xargs cp -t $$instdest) || exit 1; \
(mkdir -p $(DESTDIR)/@LINUX@/include/zfs/sys && \ (mkdir -p $$instdest/sys && \
find . -mindepth 4 -maxdepth 4 -name '*.h' | \ find . -mindepth 4 -maxdepth 4 -name '*.h' | \
xargs cp -t $(DESTDIR)/@LINUX@/include/zfs/sys) || exit 1; xargs cp -t $$instdest/sys) || exit 1;
distdir: distdir:
distfiles=`find . -name '*.c' -o -name '*.h'`; \ distfiles=`find . -name '*.c' -o -name '*.h'`; \

205
zfs-modules.spec.in Normal file
View File

@ -0,0 +1,205 @@
# The following block is used to allow the source RPM to be rebuilt
# against specific kernels. It is preferable that rpmbuild define the
# require_kver, require_kdir, require_obj constants for us, but if it does not
# not we attempt to determine the correct values based on your distro.
%{?require_kver: %define kver %{require_kver}}
%{?require_kdir: %define kdir %{require_kdir}}
%{?require_kobj: %define kobj %{require_kobj}}
# kdir: Full path to the kernel source headers
# kobj: Full path to the kernel build objects
# kver: Kernel version
# kpkg: Kernel package name
# kdevpkg: Kernel devel package name
# kverpkg: Kernel package version
%{?require_splver: %define splver %{require_splver}}
%{?require_spldir: %define spldir %{require_spldir}}
%{?require_splobj: %define splobj %{require_splobj}}
# spldir: Full path to the spl source headers
# splobj: Full path to the spl build objects
# splver: Spl version
# splpkg: Spl package name
# spldevpkg: Spl devel package name
# splverpkg: Spl package version
# SLES*:
%if %{defined sles_version}
%if %{undefined kver}
%define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{_target_cpu}
%define kver %((echo X; %{__cat} %{klnk}/.kernelrelease
2>/dev/null) | tail -1)
%endif
%define kpkg kernel-%{_target_cpu}
%define kdevpkg kernel-source kernel-syms
%define kverpkg %(echo %{kver} | cut -d'-' -f1-2)
%if %{undefined kdir}
%define kdir %{_usrsrc}/linux-%{kverpkg}
%endif
%if %{undefined kobj}
%define kobj %{kdir}-obj/%{_target_cpu}/%{_target_cpu}
%endif
# CHAOS4:
%else
%if %{defined ch4}
%if %{undefined kver}
%define klnk %{_usrsrc}/kernels/*/include/config
%define kver %((echo X; %{__cat} %{klnk}/kernel.release
2>/dev/null) | tail -1)
%endif
%define kpkg chaos-kernel
%define kdevpkg chaos-kernel-devel
%define kverpkg %{kver}
%if %{undefined kdir}
%define kdir %{_usrsrc}/kernels/%{kver}
%endif
%if %{undefined kobj}
%define kobj %{kdir}
%endif
# RHEL*/Fedora:
%else
%if %{defined fedora} || %{defined rhel}
%if %{undefined kver}
%define klnk %{_usrsrc}/kernels/*/include/config
%define kver %((echo X; %{__cat} %{klnk}/kernel.release
2>/dev/null) | tail -1)
%endif
%define kpkg kernel
%define kdevpkg kernel-devel
%define kverpkg %(echo %{kver} | cut -d'.' -f1-7)
%if %{undefined kdir}
%define kdir %{_usrsrc}/kernels/%{kver}
%endif
%if %{undefined kobj}
%define kobj %{kdir}
%endif
%else
# Unsupported distro:
%if %{undefined kver}
%define kver X
%endif
%define kpkg kernel
%define kdevpkg kernel-devel
%define kverpkg %{kver}
%if %{undefined kdir}
%define kdir %{_usrsrc}/kernels/%{kver}
%endif
%if %{undefined kobj}
%define kobj %{kdir}
%endif
%endif
%endif
%endif
# SPL package dependencies
%if %{undefined splver}
%define spllnk %{_usrsrc}/spl-*/%{kver}
%define splver %((echo X; %{__cat} %{spllnk}/spl.release
2>/dev/null) | tail -1)
%endif
%define splpkg spl
%define spldevpkg spl-devel
%define splverpkg %{splver}
%if %{undefined spldir}
%define spldir %{_usrsrc}/spl-%{splver}/%{kver}
%endif
%if %{undefined splobj}
%define splobj %{spldir}/module
%endif
# Distro agnostic:
%define name @PACKAGE@-modules
%define version @VERSION@
%define debug_package %{nil}
# The kernel version should only be appended to a binary RPM. When
# building a source RPM it must be kernel version agnostic. This means
# the source RPM must never specify a required kernel version, but the
# final RPM should be keyed to the kernel version it was built against.
%if %{defined build_src_rpm}
%define release @ZFS_META_RELEASE@
%define krequires %{kpkg}
%define splrequires %{splpkg}
%else
%define relext %(echo %{kverpkg} | %{__sed} -e 's/-/_/g')
%define release @ZFS_META_RELEASE@_%{relext}
%define krequires %{kpkg} = %{kverpkg}
%define splrequires %{splpkg} = %{splverpkg}
%endif
Summary: ZFS File System
Group: Utilities/System
Name: %{name}
Version: %{version}
Release: %{release}
License: @LICENSE@
URL: git://eris.llnl.gov/zfs.git
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
Source: @PACKAGE@-%{version}.tar.gz
Requires: %{krequires}
Requires: %{splrequires}
BuildRequires: %{kdevpkg}
BuildRequires: %{spldevpkg}
%description
The %{name} package contains kernel modules and support utilities for
the %{name} file system.
%package devel
Summary: ZFS File System Headers and Symbols
Group: Development/Libraries
Requires: %{krequires}
Requires: %{splrequires}
BuildRequires: %{kdevpkg}
BuildRequires: %{spldevpkg}
%description devel
The %{name}-devel package contains the kernel header files and
Module.symvers symbols needed for building additional modules
which use %{name}.
%prep
%setup -n @PACKAGE@-%{version}
%build
%configure --with-linux=%{kdir} --with-linux-obj=%{kobj} \
--with-spl=%{spldir} --with-spl-obj=%{splobj} \
--with-config=kernel
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
/lib/modules/*
%files devel
%defattr(-,root,root)
%{_prefix}/src/*
%post
if [ -f /boot/System.map-%{kver} ]; then
depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
else
depmod -ae %{kver} || exit 0
fi
%postun
if [ -f /boot/System.map-%{kver} ]; then
depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
else
depmod -ae %{kver} || exit 0
fi

View File

@ -1,83 +1,40 @@
# The following block is used to allow the source RPM to be rebuilt %define name @PACKAGE@
# against arbitrary kernels. It ensure the release name is correct %define version @VERSION@
# and the proper build/install requires are set. %define release @ZFS_META_RELEASE@
%if 0%{?require_kver:1} %define debug_package %{nil}
%define kver %{require_kver}
%else
%define _kdir %((echo X; ls -1d /usr/src/kernels/* /usr/src/linux-* 2>/dev/null)|sed -e 's/linux-//' | tail -1)
%define kver %(basename %{_kdir})
%endif
# Each distro has its own kernel package naming convention. Summary: ZFS Library and Utils
%if 0%{?ch4}
%define kstr chaos-kernel
%define kdev chaos-kernel-devel
%define kdir /usr/src/kernels/%{kver}
%else
%define kstr kernel
%define kdev kernel-devel
%define kdir /usr/src/kernels/%{kver}
%endif
%define debug_package %{nil}
# The kernel version should only be appended to a binary RPM.
# When building a source RPM it must be kernel version agnostic.
%define name @PACKAGE@
%define version @VERSION@
%if %{?build_src_rpm:1}0
%define release @ZFS_META_RELEASE@
%else
%define release @ZFS_META_RELEASE@_%(echo %{kver} | sed -e 's/-/_/g')
%endif
%if 0%{?require_kver:1}
%define k_buildrequires %{kdev}=%{kver}
%define spl_buildrequires spl-devel>=@VERSION@
%else
%define k_buildrequires %{kdev}
%define spl_buildrequires spl-devel
%endif
Summary: ZFS File System
Group: Utilities/System Group: Utilities/System
Name: %{name} Name: %{name}
Version: %{version} Version: %{version}
Release: %{release} Release: %{release}
License: @LICENSE@ License: CDDL
URL: git://eris.llnl.gov/zfs.git URL: git://eris.llnl.gov/zfs.git
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
Source: %{name}-%{version}.tar.gz Source: %{name}-%{version}.tar.gz
Requires: %{kstr} = %{kver}
Requires: spl >= @VERSION@
Requires: zlib Requires: zlib
BuildRequires: %{k_buildrequires}
BuildRequires: %{spl_buildrequires}
BuildRequires: zlib-devel BuildRequires: zlib-devel
%description %description
The %{name} package contains kernel modules and support utilities for The %{name} package contains the libzfs library and support utilities
the %{name} file system. for the zfs file system.
%package devel %package devel
Summary: ZFS File System Headers and Symbols Summary: ZFS File System User Headers
Group: Development/Libraries Group: Development/Libraries
Requires: %{k_buildrequires} = %{kver} Requires: zlib
Requires: %{spl_buildrequires} >= @VERSION@
Requires: zlib-devel
BuildRequires: %{k_buildrequires}
BuildRequires: %{spl_buildrequires}
BuildRequires: zlib-devel BuildRequires: zlib-devel
%description devel %description devel
The %{name}-devel package contains the header files and Module.symvers The %{name}-devel package contains the header files needed for building
symbols needed for building additional modules which use %{name}. additional applications against the %{name} libraries.
%prep %prep
%setup %setup
%build %build
%configure --with-linux=%{kdir} --with-spl=%{kdir}/include/spl %configure --with-linux=%{kdir} --with-linux-obj=%{kobj} \
--with-spl=%{spldir} --with-spl-obj=%{splobj} \
--with-config=user
make make
%install %install
@ -93,23 +50,10 @@ rm -rf $RPM_BUILD_ROOT
%doc OPENSOLARIS.LICENSE README TODO ZFS.RELEASE %doc OPENSOLARIS.LICENSE README TODO ZFS.RELEASE
%{_sbindir}/* %{_sbindir}/*
%{_libdir}/* %{_libdir}/*
/lib/modules/*
%files devel %files devel
%defattr(-,root,root) %defattr(-,root,root)
%{kdir}/include/zfs/*
%{_includedir}/* %{_includedir}/*
%post %post
if [ -f /boot/System.map-%{kver} ]; then
depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
else
depmod -ae %{kver} || exit 0
fi
%postun %postun
if [ -f /boot/System.map-%{kver} ]; then
depmod -ae -F /boot/System.map-%{kver} %{kver} || exit 0
else
depmod -ae %{kver} || exit 0
fi

12
zfs_unconfig.h Normal file
View File

@ -0,0 +1,12 @@
/*
* Undefine these symbols to allow other autoheader enabled packages
* to leverage the ZFS configure checks without a header conflict.
*/
#undef PACKAGE
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#undef VERSION
#undef STDC_HEADERS