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