3 # Created 2009 by Brian J. Murrell based on work by
4 # Alastair McKinstry, <alastair.mckinstry@ichec.ie>, <mckinstry@debian.org>
5 # Patrick Winnertz, and the pkg-lustre Debian maintainers
7 # Copying and modification is unlimited, provided that the modified
8 # version is marked as being modified.
10 # Uncomment this to turn on verbose mode.
13 DEB_BUILD_GNU_SYSTEM = $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
14 DEB_BUILD_GNU_CPU = $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
17 # whether to use module-assistant to build the kernel modules or not
21 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
27 # We need the kernels to be built with gcc-3.3; suspect that gcc-4.1 uses too
28 # much stack and crashes because of it.
32 # This is the debhelper compatibility version to use.
35 # Module-assistant stuff
36 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
37 PACKAGE=lustre-server-modules
39 PACKAGE=lustre-client-modules
41 MA_DIR ?= /usr/share/modass
42 -include $(MA_DIR)/include/generic.make
43 -include $(MA_DIR)/include/common-rules.make
45 ARCH=$(shell dpkg --print-architecture)
48 # This is the Lustre version
49 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
50 UPVERSION=$(shell echo $VERSION | sed -e 's/-[^-]*$$//')
52 # KVER is set to LINUXRELEASE being by autoconf which is either
53 # $(uname -r) or the version of the source specified by the user
56 # KVERS, KSRC are the kernel version and source to use when building lustre
57 # Will be the default when building lustre-utils, etc but whatever module-assistant
58 # supplied when building modules
64 # Packages provided for both client and server builds
65 PATCH_PKG=linux-patch-lustre
66 TESTS_PKG=lustre-tests
68 SOURCE_PKG=lustre-source
69 SOURCE_PKG=lustre-source
71 # Packages that are only built for server OR client builds
72 # The difference is that server build contain more modules & utils
73 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
74 UTILS_PKG=lustre-server-utils
75 MODS_PKG=lustre-server-modules
77 UTILS_PKG=lustre-client-utils
78 MODS_PKG=lustre-client-modules
82 #BUILDDIR=debian/build
84 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
89 AVAIL_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
90 ifneq ($(AVAIL_CPUS),1)
91 PMAKEARGS := -j $(AVAIL_CPUS)
94 autogen: autogen-stamp
95 autogen-stamp: patch-stamp
96 # see if any patches requires us to run autogen
97 # (for a distribution release tarball, it is expected that if
98 # downstream adds any patches that requires autogen.sh to be
99 # run, a patch will be added by downstream to install the
100 # needed autogen.sh scripts
101 # see https://bugzilla.lustre.org/attachment.cgi?id=27156
103 if grep -e "^--- .*\/autoconf\/" \
104 -e "^--- .*\/autoMakefile\.am" \
105 -e "^--- .*\/Makefile\.am" \
106 -e "^--- .*\/configure\.ac" \
107 -e "^--- .*\/configure\.in" \
108 debian/patches/*; then \
109 if [ ! -f build/autogen.sh ]; then \
110 echo "You have patches which require autogen.sh to be run, but it doesn't exist"; \
111 echo "Please see https://bugzilla.lustre.org/attachment.cgi?id=27156"; \
114 cp /usr/share/misc/config.sub config.sub; \
115 cp /usr/share/misc/config.sub ldiskfs/config.sub; \
116 cp /usr/share/misc/config.guess config.guess; \
117 cp /usr/share/misc/config.guess ldiskfs/config.guess; \
118 sh build/autogen.sh; \
122 # This section configures the lustre-utilities packages.
124 # Both client and server builds are quite similar, as the utilities build
125 # must create the modules too, to produce the "osd_<fstype>.so" libraries.
127 # The main difference is that the utilities build does not archive the
128 # modules, whereas the modules build omits the utilities, to create two
129 # neatly separated debian files.
131 # Note: KERNEL_SRC, KERNEL_CFG, ZFS_SRC and SPL_SRC need to be set from the
132 # outside. This is done by "make debs". As such, invoking "debuild" or such
133 # direct debian build tools will lead to a client-only build.
134 configure: configure-stamp
135 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
137 # touch files to same date, to avoid auto*
138 find . -type f -print0 | xargs -0 touch -r COPYING; \
139 if [ "$(BUILDDIR)" != "." ]; then \
140 mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib; \
141 cp build/Makefile $(BUILDDIR)/build/; \
143 # Determine flags that are different between server/client module builds
144 echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
145 if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
146 export EXTRAFLAGS="--enable-server"; \
148 export EXTRAFLAGS="--disable-server"; \
150 if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
151 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
153 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
155 if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
156 export EXTRAFLAGS="$${EXTRAFLAGS} \
157 --enable-ldiskfs --enable-quilt"; \
159 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
161 echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
162 ( cd $(BUILDDIR) && \
163 $(SRCDIR)/configure --disable-dependency-tracking \
164 --with-linux=$${KERNEL_SRC} \
165 --with-linux-config=$${KERNEL_CFG} \
172 build-arch build-indep: build
175 build-stamp: patch-stamp configure-stamp
177 $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
178 $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
179 # jump our lustre-[client|server]-modules into the control file if not using m-a
180 if ! $(USE_MA); then \
181 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
182 for file in debian/*_KVERS_*; do \
183 newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
184 cp $$file $$newfile; \
189 # let's try and operate as close as the user would and not build modules
191 # instead we will build the modules with m-a in the "make debs" target
192 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
193 # binary-$(MODS_PKG) binary-kern-mods
194 binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG)
196 binary-indep: binary-$(PATCH_PKG) binary-$(SOURCE_PKG)
198 binary: binary-indep binary-arch
200 binary-$(PATCH_PKG): patch-stamp
203 dh_installdirs -p $(PATCH_PKG)
204 dh_installdocs -p $(PATCH_PKG)
205 # dh_installkpatches -p $(PATCH_PKG)
206 dh_install -p $(PATCH_PKG)
208 # Install apply script
209 cp $(TOP_DIR)/debian/linux-patch-lustre.apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
210 chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
211 set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
212 mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/; \
213 ln -s ../../../lustre/scripts/apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/lustre; \
216 # Install unpatch script
217 cp $(TOP_DIR)/debian/linux-patch-lustre.unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
218 chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
219 set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
220 mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/; \
221 ln -s ../../../lustre/scripts/unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/lustre; \
225 cp lustre/kernel_patches/series/*.series $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/series/
228 cp lustre/kernel_patches/patches/*.patch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/patches/
230 dh_installchangelogs -p $(PATCH_PKG) lustre/ChangeLog
231 dh_compress -p $(PATCH_PKG)
232 dh_installdeb -p $(PATCH_PKG)
233 dh_fixperms -p $(PATCH_PKG)
234 dh_gencontrol -p $(PATCH_PKG)
235 dh_md5sums -p $(PATCH_PKG)
236 dh_builddeb -p $(PATCH_PKG)
238 binary-$(UTILS_PKG): build-stamp
241 dh_installdirs -p $(UTILS_PKG)
242 dh_installdocs -p $(UTILS_PKG)
243 dh_installman -p $(UTILS_PKG)
244 dh_install -p $(UTILS_PKG)
245 dh_makeshlibs -p $(UTILS_PKG)
246 dh_installexamples -p $(UTILS_PKG)
247 dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
248 dh_compress -p $(UTILS_PKG)
249 dh_strip -p $(UTILS_PKG)
250 dh_installdeb -p $(UTILS_PKG)
251 dh_fixperms -p $(UTILS_PKG)
252 dh_gencontrol -p $(UTILS_PKG)
253 dh_md5sums -p $(UTILS_PKG)
254 dh_builddeb -p $(UTILS_PKG)
256 binary-$(TESTS_PKG): build-stamp
259 dh_installdirs -p $(TESTS_PKG)
260 dh_installdocs -p $(TESTS_PKG)
261 dh_installman -p $(TESTS_PKG)
262 dh_install -p $(TESTS_PKG)
263 dh_makeshlibs -p $(TESTS_PKG)
264 dh_installexamples -p $(TESTS_PKG)
265 dh_installchangelogs -p $(TESTS_PKG) lustre/ChangeLog
266 dh_compress -p $(TESTS_PKG)
267 dh_strip -p $(TESTS_PKG)
268 dh_installdeb -p $(TESTS_PKG)
269 dh_fixperms -p $(TESTS_PKG)
270 dh_gencontrol -p $(TESTS_PKG)
271 dh_md5sums -p $(TESTS_PKG)
272 dh_builddeb -p $(TESTS_PKG)
274 binary-$(DEV_PKG): build-stamp
277 dh_installdirs -p $(DEV_PKG)
278 dh_install -p $(DEV_PKG)
279 dh_installdocs -p $(DEV_PKG)
280 dh_installchangelogs -p $(DEV_PKG) lustre/ChangeLog
281 dh_compress -p $(DEV_PKG)
282 dh_installdeb -p $(DEV_PKG)
283 dh_fixperms -p $(DEV_PKG)
284 dh_gencontrol -p $(DEV_PKG)
285 dh_md5sums -p $(DEV_PKG)
286 dh_builddeb -p $(DEV_PKG)
288 binary-$(SOURCE_PKG): build-stamp
292 dh_installdirs -p $(SOURCE_PKG) usr/src/modules/lustre/debian
293 rsync -av --exclude='debian/$(SOURCE_PKG)/*' \
295 . debian/$(SOURCE_PKG)/usr/src/modules/lustre
296 # Remove FULLCLEAN setting
297 rm debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
298 sed -e 's/FULLCLEAN=full-clean/FULLCLEAN=/' < debian/rules > debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
300 rm -rf debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patched \
301 debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patches/*
302 $(MAKE) -C debian/$(SOURCE_PKG)/usr/src/modules/lustre -f debian/rules clean
303 # Create the module-source tarball.
304 cd debian/$(SOURCE_PKG)/usr/src && tar jcf lustre.tar.bz2 modules
305 rm -rf debian/$(SOURCE_PKG)/usr/src/modules
306 dh_install -p$(SOURCE_PKG)
307 dh_installchangelogs -p $(SOURCE_PKG) lustre/ChangeLog
308 dh_installdocs -p $(SOURCE_PKG)
309 dh_link -p $(SOURCE_PKG) /usr/share/modass/packages/default.sh /usr/share/modass/overrides/lustre-source
310 dh_compress -p $(SOURCE_PKG)
311 dh_installdeb -p $(SOURCE_PKG)
312 dh_fixperms -p $(SOURCE_PKG)
313 dh_gencontrol -p $(SOURCE_PKG)
314 dh_md5sums -p $(SOURCE_PKG)
315 dh_builddeb -p $(SOURCE_PKG)
317 # if only we could use m-a for this, but this stupid "compliant.list"
318 # thing fouls that up
320 # Build client or server modules
321 mkdir -p debian/m-a_root/usr_src/modules
322 ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
323 m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
324 mv -f debian/m-a_root/*.deb ..
326 # an alternative (to module-assistant) method of building the kernel modules
327 binary-$(MODS_PKG): build-stamp
328 if ! $(USE_MA); then \
329 cp debian/$(MODS_PKG).install debian/$(MODS_PKG)-$(KVER).install ; \
332 dh_installdirs -p $(MODS_PKG)-$(KVER); \
333 dh_installdocs -p $(MODS_PKG)-$(KVER); \
334 dh_install -p $(MODS_PKG)-$(KVER); \
335 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
336 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
337 dh_compress -p $(MODS_PKG)-$(KVER); \
338 dh_installdeb -p $(MODS_PKG)-$(KVER); \
339 dh_strip -p $(MODS_PKG)-$(KVER); \
340 dh_fixperms -p $(MODS_PKG)-$(KVER); \
341 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
342 dh_md5sums -p $(MODS_PKG)-$(KVER); \
343 dh_builddeb -p $(MODS_PKG)-$(KVER); \
348 ### For module-assistant
351 # the kdist_clean target is called by make-kpkg modules_clean and from
352 # kdist* rules. It is responsible for cleaning up any changes that have
353 # been made by the other kdist_commands (except for the .deb files created)
356 # can't dh_clean here or we remove the build artifacts for the other packages
359 #-$(MAKE) $(MFLAGS) -f debian/rules clean
360 # put the userspace tools' control file back
361 cp debian/control.main debian/control
364 # module assistant calculates all needed things for us and sets
365 # # following variables:
366 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
367 # # (revision of the Debian kernel-image package), CC (the correct
368 # # compiler), VERSION (the final package version string), PKGNAME (full
369 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
371 # # The kdist_configure target is called by make-kpkg modules_config and
372 # # by kdist* rules by dependency. It should configure the module so it is
373 # # ready for compilation (mostly useful for calling configure).
374 # # prep-deb-files from module-assistant creates the neccessary debian/
375 kdist_config: prep-deb-files patch-stamp
376 # Check build dependencies again, needs to be done since we just
377 # replaced the control file.
379 # Prepare the kernel to lustres' liking
380 # as non-root, we won't have permission for this
381 #-$(MAKE) -C $(KSRC) prepare scripts
382 # touch files to same date, to avoid auto*
383 find . -type f -print0 | xargs -0 touch -r COPYING \;
384 # Determine flags that are different between server/client module builds
385 # Note: It doesn't seem possible to *only* build modules.
386 echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
387 if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
388 export EXTRAFLAGS="--enable-server"; \
390 export EXTRAFLAGS="--disable-server"; \
392 if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
393 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
395 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
397 if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
398 export EXTRAFLAGS="$${EXTRAFLAGS} \
399 --enable-ldiskfs --enable-quilt"; \
401 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
403 echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
404 ./configure --with-linux=$(KSRC_TREE) \
405 --with-linux-obj=$(KSRC) \
406 --disable-dependency-tracking \
413 --with-kmp-moddir=updates \
418 kdist_configure: kdist_config
420 # the binary-modules rule is invoked by module-assistant while processing the
421 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
422 # during a normal build
423 binary-modules: prep-deb-files
427 $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
428 # Remove stuff that doesn't belong (no module-only target)
429 cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr sbin etc
430 dh_installdocs -p$(PKGNAME)
431 dh_installchangelogs -p$(PKGNAME)
432 dh_installmodules -p $(PKGNAME)
433 dh_compress -p $(PKGNAME)
434 dh_fixperms -p $(PKGNAME)
435 dh_installdeb -p $(PKGNAME)
436 dh_gencontrol -- -v$(VERSION)
437 dh_md5sums -p $(PKGNAME)
438 dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
439 dh_prep -p $(PKGNAME)
444 dpatch deapply-all -v
446 rm -rf debian/substvars debian/*.bak debian/*~ *~ *-stamp debian/$(PATCH_PKG)
447 ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | xargs rm -f || true
448 # only remove this if the clean was not called from kdist_clean
449 if [ "$$MA_SOURCE_PKG" = "" ]; then \
450 rm -rf debian/m-a_root; \
453 # make sure we have at least a basic control in place (see build-stamp)
455 cp debian/control.main debian/control
463 dpatch deapply-all -v
464 rm -rf debian/patched patch-stamp
466 .PHONY: binary-arch clean source diff binary binary-indep binary-arch install configure