]> git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/rules
Pedantic format change
[mirror_zfs-debian.git] / debian / rules
1 #!/usr/bin/make -f
2
3 LSB_DISTRIBUTOR := $(shell lsb_release -is)
4 NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
5 VERSION := $(shell dpkg-parsechangelog \
6 | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
7
8 DKMSFILES := module include config zfs.release.in autogen.sh META AUTHORS \
9 DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown
10
11 ifndef BUILD_UDEB
12 BUILD_UDEB=false
13 endif
14
15 ifndef DEB_HOST_ARCH
16 DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
17 endif
18
19 ifndef KVERS
20 KVERS=$(shell uname -r)
21 endif
22
23 ifndef SPL
24 SPL=/usr/src/spl-$(VERSION)
25 endif
26
27 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
28 PACKAGE=zfs
29 pmodules = $(PACKAGE)-modules-$(non_epoch_version)
30
31 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
32
33 %:
34 dh $@ --with autoreconf,dkms --parallel
35
36 override_dh_auto_configure:
37 @cp debian/control.in debian/control
38 ifeq ($(BUILD_UDEB), true)
39 cat debian/control.udeb.in >> debian/control
40 endif
41
42 @# Embed the downstream version in the module.
43 @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META
44
45 @# Build the userland, but don't build the kernel modules.
46 dh_auto_configure -- \
47 --bindir=/bin \
48 --sbindir=/sbin \
49 --libdir=/lib \
50 --with-udevdir=/lib/udev \
51 --with-config=user
52
53 override_dh_auto_test:
54 # The dh_auto_test rule is disabled because
55 # `make check` cannot run in an unprivileged build environment.
56
57 override_dh_auto_install:
58 @# Install the utilities.
59 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
60
61 @# Get a bare copy of the source code for DKMS.
62 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not
63 @# contain the userland sources. NB: Remove-userland-dist-rules.patch
64 $(MAKE) distdir
65
66 @# Install the DKMS source.
67 @# We only want the files needed to build the modules
68 mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
69 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
70 @# Hellish awk line:
71 @# * Deletes from configure.ac the parts not needed for building the kernel module
72 @# * It deletes from inside AC_CONFIG_FILES([]) everything except:
73 @# (Makefile$|include/|module/|*.release$)
74 @# * Takes care of spaces and tabs
75 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
76 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
77 @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
78 sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
79 '$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
80 @# Sanity test
81 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
82 @# Run autogen on the stripped source tree
83 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
84 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
85
86 @# This shunt allows DKMS to install the Module.symvers and zfs_config.h
87 @# files to the ${dkms_tree} area through the POST_INSTALL directive.
88 printf '#!/bin/sh\ncp "$$@"\n' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
89 chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
90
91 mkdir -p $(CURDIR)/debian/tmp/usr/lib
92 for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \
93 ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \
94 rm $${i}; \
95 done
96
97 override_dh_dkms:
98 dh_dkms -V $(VERSION)
99
100 override_dh_makeshlibs:
101 dh_makeshlibs -a
102 ifeq ($(BUILD_UDEB), true)
103 dh_makeshlibs -plibnvpair1linux --add-udeb=libnvpair1-udeb
104 dh_makeshlibs -plibuutil1linux --add-udeb=libuutil1-udeb
105 dh_makeshlibs -plibzfs2linux --add-udeb=libzfs2-udeb
106 dh_makeshlibs -plibzpool2linux --add-udeb=libzpool2-udeb
107 dh_makeshlibs -pzfsutils-linux --add-udeb=zfsutils-udeb
108 endif
109
110 override_dh_strip:
111 dh_strip --dbg-package=zfs-dbg
112 ifeq ($(BUILD_UDEB), true)
113 dh_strip -plibnvpair1-udeb
114 dh_strip -plibuutil1-udeb
115 dh_strip -plibzfs2-udeb
116 dh_strip -plibzpool2-udeb
117 dh_strip -pzfsutils-udeb
118 endif
119
120 override_dh_auto_clean:
121 dh_auto_clean
122 debconf-updatepo
123 @if test -e META.orig; then mv META.orig META; fi
124 cp debian/control.in debian/control
125 ifeq ($(BUILD_UDEB), true)
126 cat debian/control.udeb.in >> debian/control
127 endif
128
129 override_dh_install:
130 find . -name lib*.la -delete
131 dh_install --list-missing
132
133 # ------------
134
135 override_dh_prep-deb-files:
136 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
137 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)/' \
138 < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
139 done
140 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' \
141 < debian/control.modules.in > debian/control
142
143 override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp
144 override_dh_configure_modules_udeb_stamp:
145 ./configure \
146 --without-selinux \
147 --with-config=kernel \
148 --with-linux=$(KSRC) \
149 --with-linux-obj=$(KOBJ) \
150 --with-spl=$(SPL)
151 touch override_dh_configure_modules_udeb_stamp
152
153 override_dh_configure_modules: override_dh_configure_modules_stamp
154 override_dh_configure_modules_stamp:
155 ./configure \
156 --with-config=kernel \
157 --with-linux=$(KSRC) \
158 --with-linux-obj=$(KOBJ) \
159 --with-spl=$(SPL)
160 touch override_dh_configure_modules_stamp
161
162 override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb
163 dh_testdir
164 dh_testroot
165 dh_prep
166
167 $(MAKE) -C $(CURDIR)/module modules
168
169 dh_installdirs -p${pmodules}-di
170 dh_install -p${pmodules}-di
171 dh_gencontrol -p${pmodules}-di
172
173 dh_builddeb -p${pmodules}-di
174
175 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
176 dh_testdir
177 dh_testroot
178 dh_prep
179
180 $(MAKE) -C $(CURDIR)/module modules
181
182 dh_install -p${pmodules}
183 dh_installdocs -p${pmodules}
184 dh_installchangelogs -p${pmodules}
185 dh_compress -p${pmodules}
186 dh_strip -p${pmodules}
187 dh_fixperms -p${pmodules}
188 dh_installdeb -p${pmodules}
189 dh_gencontrol -p${pmodules}
190 dh_md5sums -p${pmodules}
191 dh_builddeb -p${pmodules}