]> git.proxmox.com Git - mirror_spl-debian.git/blob - debian/rules
Make use of dh-autoreconf
[mirror_spl-debian.git] / debian / rules
1 #!/usr/bin/make -f
2
3 NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
4 VERSION := $(shell dpkg-parsechangelog \
5 | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
6
7 DKMSFILES := module include config spl.release.in autogen.sh \
8 META AUTHORS DISCLAIMER
9
10 ifndef DEB_HOST_ARCH
11 DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
12 endif
13
14 ifndef KVERS
15 KVERS=$(shell uname -r)
16 endif
17
18 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
19 PACKAGE=spl
20 pmodules = $(PACKAGE)-modules-$(non_epoch_version)
21
22 %:
23 dh $@ --with dkms,autoreconf --parallel
24
25 override_dh_auto_configure:
26 @cp debian/control.in debian/control
27
28 @# Embed the downstream version in the module.
29 @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META
30
31 @# Build the userland, but don't build the kernel modules.
32 dh_auto_configure -- --with-config=user --disable-debug-kmem
33
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:
39 @# Install the utilities.
40 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
41
42 @# Get a bare copy of the source code.
43 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree.
44 $(MAKE) distdir
45
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)'
49 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
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:
53 @# (Makefile$|include/|module/|*.release$)
54 @# * Takes care of spaces and tabs
55 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$))/){next} } {print}' \
56 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
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
63 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
64 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
65
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.
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'
71
72 override_dh_dkms:
73 dh_dkms -V $(VERSION)
74
75 override_dh_auto_clean:
76 dh_auto_clean
77 @if test -e META.orig; then mv META.orig META; fi
78 cp debian/control.in debian/control
79
80 # ------------
81
82 override_dh_prep-deb-files:
83 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
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$$//'` ; \
86 done
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' \
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) \
93 --with-linux-obj=$(KOBJ) \
94 --disable-debug-kmem
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
100 dh_prep
101
102 $(MAKE) -C $(CURDIR)/module modules
103
104 dh_installdirs -p${pmodules}-di
105 dh_install -p${pmodules}-di
106 dh_gencontrol -p${pmodules}-di
107
108 dh_builddeb -p${pmodules}-di
109
110 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
111 dh_testdir
112 dh_testroot
113 dh_prep
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}
124 dh_gencontrol -p${pmodules}
125 dh_md5sums -p${pmodules}
126
127 dh_builddeb -p${pmodules}