]>
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 | |
d05a66da CALP |
7 | DKMSFILES := module include config spl.release.in autogen.sh \ |
8 | META AUTHORS DISCLAIMER | |
16b165cc | 9 | |
2f30af71 TF |
10 | ifndef DEB_HOST_ARCH |
11 | DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH) | |
12 | endif | |
13 | ||
9436c4b5 | 14 | ifndef KVERS |
01d50ac8 | 15 | KVERS=$(shell uname -r) |
9436c4b5 | 16 | endif |
01d50ac8 | 17 | |
3d3fd67f AX |
18 | non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://') |
19 | PACKAGE=spl | |
83359524 | 20 | pmodules = $(PACKAGE)-modules-$(non_epoch_version) |
3d3fd67f | 21 | |
cc2a3926 | 22 | %: |
b5d05826 | 23 | dh $@ --with dkms --parallel |
cc2a3926 | 24 | |
0fbe1fc0 | 25 | override_dh_auto_configure: |
3d3fd67f AX |
26 | @cp debian/control.in debian/control |
27 | ||
a9655987 DH |
28 | @# Embed the downstream version in the module. |
29 | @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META | |
30 | ||
31 | @# Create the makefiles and configure script. | |
287506cd DH |
32 | ./autogen.sh |
33 | ||
a9655987 | 34 | @# Build the userland, but don't build the kernel modules. |
72e64659 AX |
35 | ./configure --prefix=/usr --with-config=user \ |
36 | --disable-debug-kmem | |
d05a66da | 37 | |
0fbe1fc0 DH |
38 | override_dh_auto_test: |
39 | # scripts/check.sh tries insmod and rmmod, so it cannot | |
40 | # run in an unprivileged build environment. | |
41 | ||
42 | override_dh_auto_install: | |
a9655987 | 43 | @# Install the utilities. |
489c31a0 | 44 | $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' |
0fbe1fc0 | 45 | |
a9655987 DH |
46 | @# Get a bare copy of the source code. |
47 | @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree. | |
489c31a0 | 48 | $(MAKE) distdir |
0fbe1fc0 | 49 | |
16b165cc CALP |
50 | # Install the DKMS source. |
51 | @# We only want the files needed to build the modules | |
52 | mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' | |
d05a66da | 53 | $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;) |
16b165cc CALP |
54 | @# Hellish awk line: |
55 | @# * Deletes from configure.ac the parts not needed for building the kernel module | |
56 | @# * It deletes from inside AC_CONFIG_FILES([]) everything except: | |
d05a66da | 57 | @# (Makefile$|include/|module/|*.release$) |
16b165cc | 58 | @# * Takes care of spaces and tabs |
d05a66da | 59 | awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$))/){next} } {print}' \ |
16b165cc | 60 | '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac' |
d05a66da CALP |
61 | @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs. |
62 | sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \ | |
63 | '$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am' | |
64 | @# Sanity test | |
65 | grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am' | |
66 | @# Run autogen on the stripped source tree | |
16b165cc CALP |
67 | cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh |
68 | rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache' | |
c30c9032 | 69 | |
a9655987 DH |
70 | @# This shunt allows DKMS to install the Module.symvers and spl_config.h |
71 | @# files to the ${dkms_tree} area through the POST_INSTALL directive. | |
16b165cc CALP |
72 | echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' |
73 | echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' | |
74 | chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' | |
0fbe1fc0 | 75 | |
cc2a3926 | 76 | override_dh_dkms: |
0fbe1fc0 | 77 | dh_dkms -V $(VERSION) |
a9655987 DH |
78 | |
79 | override_dh_auto_clean: | |
80 | dh_auto_clean | |
81 | @if test -e META.orig; then mv META.orig META; fi | |
c168c73c | 82 | cp debian/control.in debian/control |
3d3fd67f AX |
83 | |
84 | # ------------ | |
85 | ||
86 | override_dh_prep-deb-files: | |
87 | for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \ | |
2f30af71 TF |
88 | 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' \ |
89 | < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \ | |
3d3fd67f | 90 | done |
2f30af71 | 91 | 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' \ |
3d3fd67f AX |
92 | < debian/control.modules.in > debian/control |
93 | ||
94 | override_dh_configure_modules: override_dh_configure_modules_stamp | |
95 | override_dh_configure_modules_stamp: | |
96 | ./configure --with-config=kernel --with-linux=$(KSRC) \ | |
72e64659 AX |
97 | --with-linux-obj=$(KOBJ) \ |
98 | --disable-debug-kmem | |
3d3fd67f AX |
99 | touch override_dh_configure_modules_stamp |
100 | ||
101 | override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules | |
102 | dh_testdir | |
103 | dh_testroot | |
c3ea64f7 | 104 | dh_prep |
3d3fd67f AX |
105 | |
106 | $(MAKE) -C $(CURDIR)/module modules | |
107 | ||
2f30af71 TF |
108 | dh_installdirs -p${pmodules}-di |
109 | dh_install -p${pmodules}-di | |
110 | dh_gencontrol -p${pmodules}-di | |
3d3fd67f | 111 | |
51caf985 | 112 | dh_builddeb -p${pmodules}-di |
3d3fd67f AX |
113 | |
114 | override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules | |
115 | dh_testdir | |
116 | dh_testroot | |
c3ea64f7 | 117 | dh_prep |
3d3fd67f AX |
118 | |
119 | $(MAKE) -C $(CURDIR)/module modules | |
120 | ||
121 | dh_installdocs -p${pmodules} | |
122 | dh_install -p${pmodules} | |
123 | dh_installchangelogs -p${pmodules} | |
124 | dh_compress -p${pmodules} | |
125 | dh_strip -p${pmodules} | |
126 | dh_fixperms -p${pmodules} | |
127 | dh_installdeb -p${pmodules} | |
8779fc7a | 128 | dh_gencontrol -p${pmodules} |
3d3fd67f AX |
129 | dh_md5sums -p${pmodules} |
130 | ||
51caf985 | 131 | dh_builddeb -p${pmodules} |