3 LSB_DISTRIBUTOR
:= $(shell lsb_release
-is
)
4 NAME
:= $(shell awk
'$$1 == "Name:" { print $$2; }' META
)
5 VERSION
:= $(shell dpkg-parsechangelog \
6 | awk
'$$1 == "Version:" { print $$2; }' | cut
-d-
-f1
)
8 DKMSFILES
:= module
include config zfs.release.in autogen.sh META AUTHORS \
9 DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown
11 export SHLIB_MAJOR
= 1
18 DEB_HOST_ARCH
= $(shell dpkg-architecture
-qDEB_HOST_ARCH
)
22 KVERS
=$(shell uname
-r
)
25 non_epoch_version
=$(shell echo
$(KVERS
) | perl
-pe
's/^\d+://')
27 pmodules
= $(PACKAGE
)-modules-
$(non_epoch_version
)
30 dh
$@
--with dkms
--parallel
32 override_dh_auto_configure
:
33 @cp debian
/control.in debian
/control
34 ifeq ($(BUILD_UDEB
), true
)
35 cat debian
/control.udeb.in
>> debian
/control
38 @
# Embed the downstream version in the module.
39 @sed
-e
's/^Version:.*/Version: $(VERSION)/' -i.orig META
41 @
# Create the makefiles and configure script.
44 @
# Build the userland, but don't build the kernel modules.
47 --libexecdir
=/usr
/libexec \
49 --includedir=/usr
/include \
50 --datarootdir
=/usr
/share \
53 override_dh_auto_test
:
54 # The dh_auto_test rule is disabled because
55 # `make check` cannot run in an unprivileged build environment.
57 override_dh_auto_install
:
58 @
# Install the utilities.
59 $(MAKE
) install DESTDIR
='$(CURDIR)/debian/tmp'
61 @
# Get a bare copy of the source code for DKMS.
62 @
# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not
63 @
# contain the userland sources. NB: Remove-userland-dist-rules.patch
66 @
# Install the DKMS source.
67 @
# We only want the files needed to build the modules
68 mkdir
-p
'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
69 $(foreach file
,$(DKMSFILES
),mv
'$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit
1;)
71 @
# * Deletes from configure.ac the parts not needed for building the kernel module
72 @
# * It deletes from inside AC_CONFIG_FILES([]) everything except:
73 @
# (Makefile$|include/|module/|*.release$)
74 @
# * Takes care of spaces and tabs
75 awk
'/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
76 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
77 @
# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
78 sed
'1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
79 '$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
81 grep
-q
'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
82 @
# Run autogen on the stripped source tree
83 cd
'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; .
/autogen.sh
84 rm -fr
'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
86 @
# This shunt allows DKMS to install the Module.symvers and zfs_config.h
87 @
# files to the ${dkms_tree} area through the POST_INSTALL directive.
88 echo
'#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
89 echo
'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
90 chmod
755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
92 mkdir
-p
$(CURDIR
)/debian
/tmp
/usr
/lib
93 for i in
`ls $(CURDIR)/debian/tmp/lib/*.so`; do \
94 ln
-s
/lib
/`readlink $${i}` $(CURDIR
)/debian
/tmp
/usr
/lib
/`basename $${i}`; \
98 override_dh_installinit
:
99 @
# Install the /etc/default/zfs options file.
100 dh_installinit
--name
=zfs
102 @
# Install the /etc/init.d/zfs-mount script.
103 ifeq ($(LSB_DISTRIBUTOR
),Debian
)
104 @
# Debian runs local mounts at sysv sequences [10..12] [08..09].
105 dh_installinit
--name
=zfs-mount \
106 --no-restart-on-upgrade
--no-start
-- defaults
13 07
108 dh_installinit
--name
=zfs-mount \
109 --no-restart-on-upgrade
--no-start
112 @
# Install the /etc/init.d/zfs-share script.
113 ifeq ($(LSB_DISTRIBUTOR
),Debian
)
114 @
# Debian runs nfs-kernel-server at sysv sequence 17 01.
115 dh_installinit
--name
=zfs-share \
116 --no-restart-on-upgrade
--no-start
-- defaults
18 00
117 else ifeq ($(LSB_DISTRIBUTOR
),Ubuntu
)
118 @
# Ubuntu runs nfs-kernel-server at sysv sequence 20 80.
119 dh_installinit
--name
=zfs-share \
120 --no-restart-on-upgrade
--no-start
-- defaults
21 79
122 dh_installinit
--name
=zfs-share \
123 --no-restart-on-upgrade
--no-start
127 dh_dkms
-V
$(VERSION
)
129 override_dh_makeshlibs
:
131 ifeq ($(BUILD_UDEB
), true
)
132 dh_makeshlibs
-plibnvpair
$(SHLIB_MAJOR
) --add-udeb
=libnvpair
$(SHLIB_MAJOR
)-udeb
133 dh_makeshlibs
-plibuutil
$(SHLIB_MAJOR
) --add-udeb
=libuutil
$(SHLIB_MAJOR
)-udeb
134 dh_makeshlibs
-plibzfs
$(SHLIB_MAJOR
) --add-udeb
=libzfs
$(SHLIB_MAJOR
)-udeb
135 dh_makeshlibs
-plibzpool
$(SHLIB_MAJOR
) --add-udeb
=libzpool
$(SHLIB_MAJOR
)-udeb
136 dh_makeshlibs
-pzfsutils
--add-udeb
=zfsutils-udeb
140 dh_strip
-plibnvpair1
--dbg-package
=libnvpair1-dbg
141 dh_strip
-plibuutil1
--dbg-package
=libuutil1-dbg
142 dh_strip
-plibzfs1
--dbg-package
=libzfs1-dbg
143 dh_strip
-plibzpool1
--dbg-package
=libzpool1-dbg
144 dh_strip
-pzfsutils
--dbg-package
=zfsutils-dbg
145 ifeq ($(BUILD_UDEB
), true
)
146 dh_strip
-plibnvpair
$(SHLIB_MAJOR
)-udeb
147 dh_strip
-plibuutil
$(SHLIB_MAJOR
)-udeb
148 dh_strip
-plibzfs
$(SHLIB_MAJOR
)-udeb
149 dh_strip
-plibzpool
$(SHLIB_MAJOR
)-udeb
150 dh_strip
-pzfsutils-udeb
153 override_dh_auto_clean
:
155 @if
test -e META.orig
; then mv META.orig META
; fi
156 cp debian
/control.in debian
/control
157 ifeq ($(BUILD_UDEB
), true
)
158 cat debian
/control.udeb.in
>> debian
/control
162 find .
-name lib
*.la
-delete
167 override_dh_prep-deb-files
:
168 for templ in
$(wildcard $(CURDIR
)/debian
/*_KVERS_
*.in
); do \
169 sed
-e
's/##KVERS##/$(KVERS)/g ; s/#KVERS#/$(KVERS)/g ; s/_KVERS_/$(KVERS)/g ; s/##KDREV##/$(KDREV)/g ; s/#KDREV#/$(KDREV)/g ; s/_KDREV_/$(KDREV)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/' \
170 < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
172 sed
-e
's/##KVERS##/$(KVERS)/g ; s/#KVERS#/$(KVERS)/g ; s/_KVERS_/$(KVERS)/g ; s/##KDREV##/$(KDREV)/g ; s/#KDREV#/$(KDREV)/g ; s/_KDREV_/$(KDREV)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g' \
173 < debian
/control.modules.in
> debian
/control
175 override_dh_configure_modules_udeb
: override_dh_configure_modules_udeb_stamp
176 override_dh_configure_modules_udeb_stamp
:
179 --with-config
=kernel \
180 --with-linux
=$(KSRC
) \
181 --with-linux-obj
=$(KOBJ
)
182 touch override_dh_configure_modules_udeb_stamp
184 override_dh_configure_modules
: override_dh_configure_modules_stamp
185 override_dh_configure_modules_stamp
:
187 --with-config
=kernel \
188 --with-linux
=$(KSRC
) \
189 --with-linux-obj
=$(KOBJ
)
190 touch override_dh_configure_modules_stamp
192 override_dh_binary-modules-udeb
: override_dh_prep-deb-files override_dh_configure_modules_udeb
197 $(MAKE
) -C
$(CURDIR
)/module modules
199 dh_installdirs
-p
${pmodules}-di
200 dh_install
-p
${pmodules}-di
201 dh_gencontrol
-p
${pmodules}-di
203 dh_builddeb
-p
${pmodules}-di
205 override_dh_binary-modules
: override_dh_prep-deb-files override_dh_configure_modules
210 $(MAKE
) -C
$(CURDIR
)/module modules
212 dh_install
-p
${pmodules}
213 dh_installdocs
-p
${pmodules}
214 dh_installchangelogs
-p
${pmodules}
215 dh_compress
-p
${pmodules}
216 dh_strip
-p
${pmodules}
217 dh_fixperms
-p
${pmodules}
218 dh_installdeb
-p
${pmodules}
219 dh_gencontrol
-p
${pmodules}
220 dh_md5sums
-p
${pmodules}
222 dh_builddeb
-p
${pmodules}