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