]>
Commit | Line | Data |
---|---|---|
7e4739a2 DH |
1 | #!/usr/bin/make -f |
2 | ||
fb579137 | 3 | LSB_DISTRIBUTOR := $(shell lsb_release -is) |
5cc6dd58 DH |
4 | NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META) |
5 | VERSION := $(shell dpkg-parsechangelog \ | |
6 | | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1) | |
7e4739a2 | 7 | |
66bbd7ad CALP |
8 | DKMSFILES := module include config zfs.release.in autogen.sh META AUTHORS \ |
9 | DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown | |
e6fd8d0f | 10 | |
a81c790e AX |
11 | export SHLIB_MAJOR = 1 |
12 | ||
042e58d4 | 13 | ifndef BUILD_UDEB |
6d1b4acf | 14 | BUILD_UDEB=false |
042e58d4 AX |
15 | endif |
16 | ||
a20a40e3 TF |
17 | ifndef DEB_HOST_ARCH |
18 | DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH) | |
19 | endif | |
20 | ||
9c581c9d AX |
21 | ifndef KVERS |
22 | KVERS=$(shell uname -r) | |
23 | endif | |
24 | ||
c2b155ae TF |
25 | ifndef SPL |
26 | SPL=/usr/src/spl-$(VERSION) | |
27 | endif | |
28 | ||
a81c790e AX |
29 | non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://') |
30 | PACKAGE=zfs | |
7640dd28 | 31 | pmodules = $(PACKAGE)-modules-$(non_epoch_version) |
a81c790e | 32 | |
30f59abc RL |
33 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
34 | ||
505714c7 | 35 | %: |
e8f06def | 36 | dh $@ --with autoreconf,dkms --parallel |
505714c7 | 37 | |
7e4739a2 | 38 | override_dh_auto_configure: |
a81c790e | 39 | @cp debian/control.in debian/control |
042e58d4 AX |
40 | ifeq ($(BUILD_UDEB), true) |
41 | cat debian/control.udeb.in >> debian/control | |
42 | endif | |
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 | 55 | override_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 | ||
59 | override_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. | |
3dce9963 | 90 | printf '#!/bin/sh\ncp "$$@"\n' >'$(META_DISTDIR)/cp' |
e6fd8d0f | 91 | chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' |
7e4739a2 | 92 | |
a0d08c54 | 93 | mkdir -p $(CURDIR)/debian/tmp/usr/lib |
3f2148a9 AX |
94 | for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \ |
95 | ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \ | |
96 | rm $${i}; \ | |
97 | done | |
98 | ||
505714c7 CALP |
99 | override_dh_dkms: |
100 | dh_dkms -V $(VERSION) | |
101 | ||
a81c790e AX |
102 | override_dh_makeshlibs: |
103 | dh_makeshlibs -a | |
042e58d4 | 104 | ifeq ($(BUILD_UDEB), true) |
3dce9963 AX |
105 | dh_makeshlibs -plibnvpair$(SHLIB_MAJOR)linux --add-udeb=libnvpair$(SHLIB_MAJOR)-udeb |
106 | dh_makeshlibs -plibuutil$(SHLIB_MAJOR)linux --add-udeb=libuutil$(SHLIB_MAJOR)-udeb | |
107 | dh_makeshlibs -plibzfs$(SHLIB_MAJOR)linux --add-udeb=libzfs$(SHLIB_MAJOR)-udeb | |
108 | dh_makeshlibs -plibzpool$(SHLIB_MAJOR)linux --add-udeb=libzpool$(SHLIB_MAJOR)-udeb | |
109 | dh_makeshlibs -pzfsutils-linux --add-udeb=zfsutils-udeb | |
042e58d4 | 110 | endif |
a81c790e | 111 | |
47ba6fdb | 112 | override_dh_strip: |
4365121d | 113 | dh_strip --dbg-package=zfs-dbg |
042e58d4 | 114 | ifeq ($(BUILD_UDEB), true) |
a81c790e AX |
115 | dh_strip -plibnvpair$(SHLIB_MAJOR)-udeb |
116 | dh_strip -plibuutil$(SHLIB_MAJOR)-udeb | |
117 | dh_strip -plibzfs$(SHLIB_MAJOR)-udeb | |
118 | dh_strip -plibzpool$(SHLIB_MAJOR)-udeb | |
119 | dh_strip -pzfsutils-udeb | |
042e58d4 | 120 | endif |
a81c790e | 121 | |
5cc6dd58 DH |
122 | override_dh_auto_clean: |
123 | dh_auto_clean | |
4c8f5221 | 124 | debconf-updatepo |
5cc6dd58 | 125 | @if test -e META.orig; then mv META.orig META; fi |
98675f09 | 126 | cp debian/control.in debian/control |
042e58d4 AX |
127 | ifeq ($(BUILD_UDEB), true) |
128 | cat debian/control.udeb.in >> debian/control | |
129 | endif | |
5cc6dd58 | 130 | |
9d521a01 AX |
131 | override_dh_install: |
132 | find . -name lib*.la -delete | |
2097931f | 133 | dh_install --list-missing |
a81c790e AX |
134 | |
135 | # ------------ | |
136 | ||
137 | override_dh_prep-deb-files: | |
138 | for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \ | |
a20a40e3 TF |
139 | 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)/' \ |
140 | < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \ | |
a81c790e | 141 | done |
a20a40e3 | 142 | 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 |
143 | < debian/control.modules.in > debian/control |
144 | ||
6766f188 AX |
145 | override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp |
146 | override_dh_configure_modules_udeb_stamp: | |
147 | ./configure \ | |
148 | --without-selinux \ | |
149 | --with-config=kernel \ | |
150 | --with-linux=$(KSRC) \ | |
c2b155ae TF |
151 | --with-linux-obj=$(KOBJ) \ |
152 | --with-spl=$(SPL) | |
6766f188 AX |
153 | touch override_dh_configure_modules_udeb_stamp |
154 | ||
a81c790e AX |
155 | override_dh_configure_modules: override_dh_configure_modules_stamp |
156 | override_dh_configure_modules_stamp: | |
6766f188 AX |
157 | ./configure \ |
158 | --with-config=kernel \ | |
159 | --with-linux=$(KSRC) \ | |
c2b155ae TF |
160 | --with-linux-obj=$(KOBJ) \ |
161 | --with-spl=$(SPL) | |
a81c790e AX |
162 | touch override_dh_configure_modules_stamp |
163 | ||
6766f188 | 164 | override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb |
a81c790e AX |
165 | dh_testdir |
166 | dh_testroot | |
1dd633c6 | 167 | dh_prep |
a81c790e AX |
168 | |
169 | $(MAKE) -C $(CURDIR)/module modules | |
170 | ||
a20a40e3 TF |
171 | dh_installdirs -p${pmodules}-di |
172 | dh_install -p${pmodules}-di | |
173 | dh_gencontrol -p${pmodules}-di | |
a81c790e | 174 | |
959e5456 | 175 | dh_builddeb -p${pmodules}-di |
a81c790e AX |
176 | |
177 | override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules | |
178 | dh_testdir | |
179 | dh_testroot | |
1dd633c6 | 180 | dh_prep |
a81c790e AX |
181 | |
182 | $(MAKE) -C $(CURDIR)/module modules | |
183 | ||
184 | dh_install -p${pmodules} | |
185 | dh_installdocs -p${pmodules} | |
186 | dh_installchangelogs -p${pmodules} | |
187 | dh_compress -p${pmodules} | |
188 | dh_strip -p${pmodules} | |
189 | dh_fixperms -p${pmodules} | |
190 | dh_installdeb -p${pmodules} | |
a878da18 | 191 | dh_gencontrol -p${pmodules} |
a81c790e | 192 | dh_md5sums -p${pmodules} |
959e5456 | 193 | dh_builddeb -p${pmodules} |