]> git.proxmox.com Git - mirror_spl-debian.git/blame - debian/rules
Merge tag 'upstream/0.6.2'
[mirror_spl-debian.git] / debian / rules
CommitLineData
0fbe1fc0
DH
1#!/usr/bin/make -f
2
a9655987
DH
3NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
4VERSION := $(shell dpkg-parsechangelog \
5 | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
0fbe1fc0 6
d05a66da
CALP
7DKMSFILES := module include config spl.release.in autogen.sh \
8 META AUTHORS DISCLAIMER
16b165cc 9
2f30af71
TF
10ifndef DEB_HOST_ARCH
11DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
12endif
13
9436c4b5 14ifndef KVERS
01d50ac8 15KVERS=$(shell uname -r)
9436c4b5 16endif
01d50ac8 17
3d3fd67f
AX
18non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
19PACKAGE=spl
83359524 20pmodules = $(PACKAGE)-modules-$(non_epoch_version)
3d3fd67f 21
cc2a3926
CALP
22%:
23 dh $@ --with dkms
24
0fbe1fc0 25override_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.
0fbe1fc0 35 ./configure --prefix=/usr --with-config=user
d05a66da 36
0fbe1fc0
DH
37override_dh_auto_test:
38 # scripts/check.sh tries insmod and rmmod, so it cannot
39 # run in an unprivileged build environment.
40
41override_dh_auto_install:
a9655987 42 @# Install the utilities.
489c31a0 43 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
0fbe1fc0 44
a9655987
DH
45 @# Get a bare copy of the source code.
46 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree.
489c31a0 47 $(MAKE) distdir
0fbe1fc0 48
16b165cc
CALP
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)'
d05a66da 52 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
16b165cc
CALP
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:
d05a66da 56 @# (Makefile$|include/|module/|*.release$)
16b165cc 57 @# * Takes care of spaces and tabs
d05a66da 58 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$))/){next} } {print}' \
16b165cc 59 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
d05a66da
CALP
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
16b165cc
CALP
66 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
67 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
c30c9032 68
a9655987
DH
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.
16b165cc
CALP
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'
0fbe1fc0 74
cc2a3926 75override_dh_dkms:
0fbe1fc0 76 dh_dkms -V $(VERSION)
a9655987
DH
77
78override_dh_auto_clean:
79 dh_auto_clean
80 @if test -e META.orig; then mv META.orig META; fi
c168c73c 81 cp debian/control.in debian/control
3d3fd67f
AX
82
83# ------------
84
85override_dh_prep-deb-files:
86 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
2f30af71
TF
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$$//'` ; \
3d3fd67f 89 done
2f30af71 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' \
3d3fd67f
AX
91 < debian/control.modules.in > debian/control
92
93override_dh_configure_modules: override_dh_configure_modules_stamp
94override_dh_configure_modules_stamp:
95 ./configure --with-config=kernel --with-linux=$(KSRC) \
05d98138 96 --with-linux-obj=$(KOBJ)
3d3fd67f
AX
97 touch override_dh_configure_modules_stamp
98
99override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules
100 dh_testdir
101 dh_testroot
c3ea64f7 102 dh_prep
3d3fd67f
AX
103
104 $(MAKE) -C $(CURDIR)/module modules
105
2f30af71
TF
106 dh_installdirs -p${pmodules}-di
107 dh_install -p${pmodules}-di
108 dh_gencontrol -p${pmodules}-di
3d3fd67f 109
51caf985 110 dh_builddeb -p${pmodules}-di
3d3fd67f
AX
111
112override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
113 dh_testdir
114 dh_testroot
c3ea64f7 115 dh_prep
3d3fd67f
AX
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}
8779fc7a 126 dh_gencontrol -p${pmodules}
3d3fd67f
AX
127 dh_md5sums -p${pmodules}
128
51caf985 129 dh_builddeb -p${pmodules}