]> git.proxmox.com Git - mirror_spl-debian.git/blob - debian/rules
Allow parallel building
[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 --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 @# Create the makefiles and configure script.
32 ./autogen.sh
33
34 @# Build the userland, but don't build the kernel modules.
35 ./configure --prefix=/usr --with-config=user \
36 --disable-debug-kmem
37
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:
43 @# Install the utilities.
44 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
45
46 @# Get a bare copy of the source code.
47 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree.
48 $(MAKE) distdir
49
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)'
53 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
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:
57 @# (Makefile$|include/|module/|*.release$)
58 @# * Takes care of spaces and tabs
59 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$))/){next} } {print}' \
60 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
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
67 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
68 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
69
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.
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'
75
76 override_dh_dkms:
77 dh_dkms -V $(VERSION)
78
79 override_dh_auto_clean:
80 dh_auto_clean
81 @if test -e META.orig; then mv META.orig META; fi
82 cp debian/control.in debian/control
83
84 # ------------
85
86 override_dh_prep-deb-files:
87 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
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$$//'` ; \
90 done
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' \
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) \
97 --with-linux-obj=$(KOBJ) \
98 --disable-debug-kmem
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
104 dh_prep
105
106 $(MAKE) -C $(CURDIR)/module modules
107
108 dh_installdirs -p${pmodules}-di
109 dh_install -p${pmodules}-di
110 dh_gencontrol -p${pmodules}-di
111
112 dh_builddeb -p${pmodules}-di
113
114 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
115 dh_testdir
116 dh_testroot
117 dh_prep
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}
128 dh_gencontrol -p${pmodules}
129 dh_md5sums -p${pmodules}
130
131 dh_builddeb -p${pmodules}