]>
Commit | Line | Data |
---|---|---|
0fbe1fc0 DH |
1 | #!/usr/bin/make -f |
2 | ||
a9655987 DH |
3 | NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META) |
4 | VERSION := $(shell dpkg-parsechangelog \ | |
5 | | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1) | |
0fbe1fc0 | 6 | |
16b165cc CALP |
7 | DKMSFILES := module include config Makefile.in autogen.sh dkms.conf.in \ |
8 | spl.release.in META spl_config.h AUTHORS DISCLAIMER | |
9 | ||
cc2a3926 CALP |
10 | %: |
11 | dh $@ --with dkms | |
12 | ||
0fbe1fc0 | 13 | override_dh_auto_configure: |
a9655987 DH |
14 | @# Embed the downstream version in the module. |
15 | @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META | |
16 | ||
17 | @# Create the makefiles and configure script. | |
287506cd DH |
18 | ./autogen.sh |
19 | ||
a9655987 | 20 | @# Build the userland, but don't build the kernel modules. |
0fbe1fc0 DH |
21 | ./configure --prefix=/usr --with-config=user |
22 | ||
23 | override_dh_auto_test: | |
24 | # scripts/check.sh tries insmod and rmmod, so it cannot | |
25 | # run in an unprivileged build environment. | |
26 | ||
27 | override_dh_auto_install: | |
a9655987 | 28 | @# Install the utilities. |
489c31a0 | 29 | $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' |
0fbe1fc0 | 30 | |
a9655987 DH |
31 | @# Create a dummy hostid file for the zfs-initramfs package. |
32 | @# NB: Commentary in the spl.postinst script. | |
5702dc92 DH |
33 | mkdir -p '$(CURDIR)/debian/tmp/etc/' |
34 | /usr/bin/printf '\xFF\xFF\xFF\xFF' >'$(CURDIR)/debian/tmp/etc/hostid' | |
35 | ||
a9655987 DH |
36 | @# Get a bare copy of the source code. |
37 | @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree. | |
489c31a0 | 38 | $(MAKE) distdir |
0fbe1fc0 | 39 | |
16b165cc CALP |
40 | # Install the DKMS source. |
41 | @# We only want the files needed to build the modules | |
42 | mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' | |
43 | $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)';) | |
44 | @# Hellish awk line: | |
45 | @# * Deletes from configure.ac the parts not needed for building the kernel module | |
46 | @# * It deletes from inside AC_CONFIG_FILES([]) everything except: | |
47 | @# (Makefile$|include/|module/|*.release$|dkms.conf$) | |
48 | @# * Takes care of spaces and tabs | |
49 | awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$|dkms\.conf([ \t]+)?$$))/){next} } {print}' \ | |
50 | '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac' | |
51 | cp '$(CURDIR)/autogen.sh' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' | |
52 | cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh | |
53 | rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache' | |
c30c9032 | 54 | |
a9655987 DH |
55 | @# This shunt allows DKMS to install the Module.symvers and spl_config.h |
56 | @# files to the ${dkms_tree} area through the POST_INSTALL directive. | |
16b165cc CALP |
57 | echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' |
58 | echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' | |
59 | chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' | |
0fbe1fc0 | 60 | |
cc2a3926 | 61 | override_dh_dkms: |
0fbe1fc0 | 62 | dh_dkms -V $(VERSION) |
a9655987 DH |
63 | |
64 | override_dh_auto_clean: | |
65 | dh_auto_clean | |
66 | @if test -e META.orig; then mv META.orig META; fi |