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