]>
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 AX |
13 | ifndef BUILD_UDEB |
14 | BUILD_UDEB=false | |
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 | ||
a81c790e AX |
25 | non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://') |
26 | PACKAGE=zfs | |
7640dd28 | 27 | pmodules = $(PACKAGE)-modules-$(non_epoch_version) |
a81c790e | 28 | |
505714c7 CALP |
29 | %: |
30 | dh $@ --with dkms | |
31 | ||
7e4739a2 | 32 | override_dh_auto_configure: |
a81c790e | 33 | @cp debian/control.in debian/control |
042e58d4 AX |
34 | ifeq ($(BUILD_UDEB), true) |
35 | cat debian/control.udeb.in >> debian/control | |
36 | endif | |
a81c790e | 37 | |
5cc6dd58 DH |
38 | @# Embed the downstream version in the module. |
39 | @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META | |
40 | ||
01000cbc | 41 | @# Create the makefiles and configure script. |
2a9c6adc DH |
42 | ./autogen.sh |
43 | ||
37316e2f | 44 | @# Build the userland, but don't build the kernel modules. |
ab520f13 | 45 | ./configure \ |
4f023100 | 46 | --prefix='' \ |
ab520f13 | 47 | --libexecdir=/usr/libexec \ |
44bb78ce | 48 | --libdir=/lib \ |
ab520f13 DH |
49 | --includedir=/usr/include \ |
50 | --datarootdir=/usr/share \ | |
37316e2f DH |
51 | --with-config=user |
52 | ||
7e4739a2 | 53 | override_dh_auto_test: |
37316e2f | 54 | # The dh_auto_test rule is disabled because |
7e4739a2 DH |
55 | # `make check` cannot run in an unprivileged build environment. |
56 | ||
57 | override_dh_auto_install: | |
37316e2f | 58 | @# Install the utilities. |
661c4a4b | 59 | $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' |
7e4739a2 | 60 | |
37316e2f DH |
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 | |
661c4a4b | 64 | $(MAKE) distdir |
7e4739a2 | 65 | |
e6fd8d0f CALP |
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)' | |
66bbd7ad | 69 | $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;) |
e6fd8d0f CALP |
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: | |
66bbd7ad | 73 | @# (Makefile$|include/|module/|*.release$) |
e6fd8d0f | 74 | @# * Takes care of spaces and tabs |
66bbd7ad | 75 | awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \ |
e6fd8d0f | 76 | '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac' |
66bbd7ad CALP |
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 | |
e6fd8d0f CALP |
83 | cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh |
84 | rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache' | |
85 | ||
37316e2f DH |
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. | |
e6fd8d0f CALP |
88 | echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' |
89 | echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' | |
90 | chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' | |
7e4739a2 | 91 | |
f61f5bec | 92 | override_dh_installinit: |
fb579137 | 93 | @# Install the /etc/default/zfs options file. |
9e5db36f | 94 | dh_installinit --name=zfs |
9b360ccf | 95 | |
fb579137 DH |
96 | @# Install the /etc/init.d/zfs-mount script. |
97 | ifeq ($(LSB_DISTRIBUTOR),Debian) | |
98 | @# Debian runs local mounts at sysv sequences [10..12] [08..09]. | |
99 | dh_installinit --name=zfs-mount \ | |
100 | --no-restart-on-upgrade --no-start -- defaults 13 07 | |
101 | else | |
102 | dh_installinit --name=zfs-mount \ | |
103 | --no-restart-on-upgrade --no-start | |
104 | endif | |
105 | ||
106 | @# Install the /etc/init.d/zfs-share script. | |
107 | ifeq ($(LSB_DISTRIBUTOR),Debian) | |
108 | @# Debian runs nfs-kernel-server at sysv sequence 17 01. | |
109 | dh_installinit --name=zfs-share \ | |
110 | --no-restart-on-upgrade --no-start -- defaults 18 00 | |
111 | else ifeq ($(LSB_DISTRIBUTOR),Ubuntu) | |
112 | @# Ubuntu runs nfs-kernel-server at sysv sequence 20 80. | |
113 | dh_installinit --name=zfs-share \ | |
114 | --no-restart-on-upgrade --no-start -- defaults 21 79 | |
115 | else | |
042e58d4 AX |
116 | dh_installinit --name=zfs-share \ |
117 | --no-restart-on-upgrade --no-start | |
fb579137 DH |
118 | endif |
119 | ||
505714c7 CALP |
120 | override_dh_dkms: |
121 | dh_dkms -V $(VERSION) | |
122 | ||
a81c790e AX |
123 | override_dh_makeshlibs: |
124 | dh_makeshlibs -a | |
042e58d4 | 125 | ifeq ($(BUILD_UDEB), true) |
a81c790e AX |
126 | dh_makeshlibs -plibnvpair$(SHLIB_MAJOR) --add-udeb=libnvpair$(SHLIB_MAJOR)-udeb |
127 | dh_makeshlibs -plibuutil$(SHLIB_MAJOR) --add-udeb=libuutil$(SHLIB_MAJOR)-udeb | |
128 | dh_makeshlibs -plibzfs$(SHLIB_MAJOR) --add-udeb=libzfs$(SHLIB_MAJOR)-udeb | |
129 | dh_makeshlibs -plibzpool$(SHLIB_MAJOR) --add-udeb=libzpool$(SHLIB_MAJOR)-udeb | |
130 | dh_makeshlibs -pzfsutils --add-udeb=zfsutils-udeb | |
042e58d4 | 131 | endif |
a81c790e | 132 | |
47ba6fdb PF |
133 | override_dh_strip: |
134 | dh_strip -plibnvpair1 --dbg-package=libnvpair1-dbg | |
135 | dh_strip -plibuutil1 --dbg-package=libuutil1-dbg | |
136 | dh_strip -plibzfs1 --dbg-package=libzfs1-dbg | |
137 | dh_strip -plibzpool1 --dbg-package=libzpool1-dbg | |
138 | dh_strip -pzfsutils --dbg-package=zfsutils-dbg | |
042e58d4 | 139 | ifeq ($(BUILD_UDEB), true) |
a81c790e AX |
140 | dh_strip -plibnvpair$(SHLIB_MAJOR)-udeb |
141 | dh_strip -plibuutil$(SHLIB_MAJOR)-udeb | |
142 | dh_strip -plibzfs$(SHLIB_MAJOR)-udeb | |
143 | dh_strip -plibzpool$(SHLIB_MAJOR)-udeb | |
144 | dh_strip -pzfsutils-udeb | |
042e58d4 | 145 | endif |
a81c790e | 146 | |
5cc6dd58 DH |
147 | override_dh_auto_clean: |
148 | dh_auto_clean | |
149 | @if test -e META.orig; then mv META.orig META; fi | |
98675f09 | 150 | cp debian/control.in debian/control |
042e58d4 AX |
151 | ifeq ($(BUILD_UDEB), true) |
152 | cat debian/control.udeb.in >> debian/control | |
153 | endif | |
5cc6dd58 | 154 | |
9d521a01 AX |
155 | override_dh_install: |
156 | find . -name lib*.la -delete | |
157 | dh_install | |
a81c790e AX |
158 | |
159 | # ------------ | |
160 | ||
161 | override_dh_prep-deb-files: | |
162 | for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \ | |
a20a40e3 TF |
163 | 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)/' \ |
164 | < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \ | |
a81c790e | 165 | done |
a20a40e3 | 166 | 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 |
167 | < debian/control.modules.in > debian/control |
168 | ||
169 | override_dh_configure_modules: override_dh_configure_modules_stamp | |
170 | override_dh_configure_modules_stamp: | |
171 | ./configure --with-config=kernel --with-linux=$(KSRC) \ | |
172 | --with-linux-obj=$(KOBJ) | |
173 | touch override_dh_configure_modules_stamp | |
174 | ||
175 | override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules | |
176 | dh_testdir | |
177 | dh_testroot | |
1dd633c6 | 178 | dh_prep |
a81c790e AX |
179 | |
180 | $(MAKE) -C $(CURDIR)/module modules | |
181 | ||
a20a40e3 TF |
182 | dh_installdirs -p${pmodules}-di |
183 | dh_install -p${pmodules}-di | |
184 | dh_gencontrol -p${pmodules}-di | |
a81c790e | 185 | |
959e5456 | 186 | dh_builddeb -p${pmodules}-di |
a81c790e AX |
187 | |
188 | override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules | |
189 | dh_testdir | |
190 | dh_testroot | |
1dd633c6 | 191 | dh_prep |
a81c790e AX |
192 | |
193 | $(MAKE) -C $(CURDIR)/module modules | |
194 | ||
195 | dh_install -p${pmodules} | |
196 | dh_installdocs -p${pmodules} | |
197 | dh_installchangelogs -p${pmodules} | |
198 | dh_compress -p${pmodules} | |
199 | dh_strip -p${pmodules} | |
200 | dh_fixperms -p${pmodules} | |
201 | dh_installdeb -p${pmodules} | |
a878da18 | 202 | dh_gencontrol -p${pmodules} |
a81c790e AX |
203 | dh_md5sums -p${pmodules} |
204 | ||
959e5456 | 205 | dh_builddeb -p${pmodules} |