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
20 # Whether to build the DKMS packages
23 ifeq ($(BUILD_DKMS),true)
24 DKMS_TARGET = binary-$(DKMS_PKG)
30 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
36 # We need the kernels to be built with gcc-3.3; suspect that gcc-4.1 uses too
37 # much stack and crashes because of it.
41 # This is the debhelper compatibility version to use.
44 # Module-assistant stuff
45 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
46 PACKAGE=lustre-server-modules
48 PACKAGE=lustre-client-modules
50 MA_DIR ?= /usr/share/modass
51 -include $(MA_DIR)/include/generic.make
52 -include $(MA_DIR)/include/common-rules.make
54 ARCH=$(shell dpkg --print-architecture)
57 # This is the Lustre version
58 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
59 UPVERSION=$(shell echo $(VERSION) | sed -e 's/-[^-]*$$//')
61 # KVER is set to LINUXRELEASE being by autoconf which is either
62 # $(uname -r) or the version of the source specified by the user
65 # KVERS, KSRC are the kernel version and source to use when building lustre
66 # Will be the default when building lustre-{server,client}-utils, etc but whatever module-assistant
67 # supplied when building modules
71 EXTRA_OPTIONS?=$(IB_OPTIONS)
73 # Packages provided for both client and server builds
74 IOKIT_PKG=lustre-iokit
75 TESTS_PKG=lustre-tests
77 SOURCE_PKG=lustre-source
79 # Packages that are only built for server OR client builds
80 # The difference is that server build contain more modules & utils
81 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
82 UTILS_PKG=lustre-server-utils
83 MODS_PKG=lustre-server-modules
84 RESOURCE_PKG=lustre-resource-agents
85 RESOURCE_TARGET=binary-$(RESOURCE_PKG)
88 UTILS_PKG=lustre-client-utils
89 MODS_PKG=lustre-client-modules
92 DKMS_PKG=lustre-client-modules-dkms
96 #BUILDDIR=debian/build
98 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
103 AVAIL_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
104 ifneq ($(AVAIL_CPUS),1)
105 PMAKEARGS := -j $(AVAIL_CPUS)
108 autogen: autogen-stamp
109 autogen-stamp: patch-stamp
110 # see if any patches requires us to run autogen
111 # (for a distribution release tarball, it is expected that if
112 # downstream adds any patches that requires autogen.sh to be
113 # run, a patch will be added by downstream to install the
114 # needed autogen.sh scripts
115 # see https://bugzilla.lustre.org/attachment.cgi?id=27156
117 if grep -e "^--- .*\/autoconf\/" \
118 -e "^--- .*\/autoMakefile\.am" \
119 -e "^--- .*\/Makefile\.am" \
120 -e "^--- .*\/configure\.ac" \
121 -e "^--- .*\/configure\.in" \
122 debian/patches/*; then \
123 if [ ! -f build/autogen.sh ]; then \
124 echo "You have patches which require autogen.sh to be run, but it doesn't exist"; \
125 echo "Please see https://bugzilla.lustre.org/attachment.cgi?id=27156"; \
128 cp /usr/share/misc/config.sub config.sub; \
129 cp /usr/share/misc/config.sub ldiskfs/config.sub; \
130 cp /usr/share/misc/config.guess config.guess; \
131 cp /usr/share/misc/config.guess ldiskfs/config.guess; \
132 sh build/autogen.sh; \
136 # This section configures the lustre-utilities packages.
138 # Both client and server builds are quite similar, as the utilities build
139 # must create the modules too, to produce the "osd_<fstype>.so" libraries.
141 # The main difference is that the utilities build does not archive the
142 # modules, whereas the modules build omits the utilities, to create two
143 # neatly separated debian files.
145 # Note: KERNEL_SRC, KERNEL_OBJ, ZFS_SRC and SPL_SRC need to be set from the
146 # outside. This is done by "make debs". As such, invoking "debuild" or such
147 # direct debian build tools will lead to a client-only build.
148 configure: configure-stamp
149 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
151 # touch files to same date, to avoid auto*
152 find . -type f -print0 | xargs -0 touch -r COPYING; \
153 if [ "$(BUILDDIR)" != "." ]; then \
154 mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib; \
155 cp build/Makefile $(BUILDDIR)/build/; \
157 # Determine flags that are different between server/client module builds
158 echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
159 if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
160 export EXTRAFLAGS="--enable-server"; \
161 if echo "$${DEB_BUILD_PROFILES}" | grep -q "systemd"; then \
162 cp debian/lustre-server-utils.install.in \
163 debian/lustre-server-utils.install; \
165 sed /systemd/d debian/lustre-server-utils.install.in \
166 > debian/lustre-server-utils.install; \
169 export EXTRAFLAGS="--disable-server"; \
170 if echo "$${DEB_BUILD_PROFILES}" | grep -q "systemd"; then \
171 cp debian/lustre-client-utils.install.in \
172 debian/lustre-client-utils.install; \
174 sed /systemd/d debian/lustre-client-utils.install.in \
175 > debian/lustre-client-utils.install; \
178 if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
179 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
181 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
183 if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
184 export EXTRAFLAGS="$${EXTRAFLAGS} \
185 --enable-ldiskfs --enable-quilt"; \
187 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
189 if echo "$${DEB_BUILD_PROFILES}" | grep -q "o2ib"; then \
190 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=$${O2IB_SRC}"; \
192 if echo "$${DEB_BUILD_PROFILES}" | grep -qw "gss"; then \
193 export EXTRAFLAGS="$${EXTRAFLAGS} --enable-gss"; \
194 elif echo "$${DEB_BUILD_PROFILES}" | grep -qw "nogss"; then \
195 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-gss"; \
197 if echo "$${DEB_BUILD_PROFILES}" | grep -qw "crypto"; then \
198 export EXTRAFLAGS="$${EXTRAFLAGS} --enable-crypto"; \
199 elif echo "$${DEB_BUILD_PROFILES}" | grep -qw "nocrypto"; then \
200 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-crypto"; \
202 echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
203 ( cd $(BUILDDIR) && \
204 $(SRCDIR)/configure --disable-dependency-tracking \
205 --with-linux=$${KERNEL_SRC} \
206 --with-linux-obj=$${KERNEL_OBJ} \
214 build-arch build-indep: build
217 build-stamp: patch-stamp configure-stamp
219 $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
220 $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
221 # jump our lustre-[client|server]-modules into the control file if not using m-a
222 if ! $(USE_MA); then \
223 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
224 for file in debian/*_KVERS_*; do \
225 newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
226 cp $$file $$newfile; \
231 # let's try and operate as close as the user would and not build modules
233 # instead we will build the modules with m-a in the "make debs" target
234 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
235 # binary-$(MODS_PKG) binary-kern-mods
236 binary-arch: binary-$(UTILS_PKG) binary-$(DEV_PKG) \
237 binary-$(IOKIT_PKG) binary-$(TESTS_PKG) \
240 binary-indep: binary-$(SOURCE_PKG) $(DKMS_TARGET)
242 binary: binary-indep binary-arch
244 binary-$(UTILS_PKG): build-stamp
247 dh_installdirs -p $(UTILS_PKG)
248 dh_installdocs -p $(UTILS_PKG)
249 dh_installman -p $(UTILS_PKG)
250 dh_install -p $(UTILS_PKG)
251 rm -rf debian/$(UTILS_PKG)/usr/bin/iokit-* \
252 debian/$(UTILS_PKG)/usr/bin/*-survey \
253 debian/$(UTILS_PKG)/usr/bin/mcreate \
254 debian/$(UTILS_PKG)/usr/bin/munlink \
255 debian/$(UTILS_PKG)/usr/bin/statx \
256 debian/$(UTILS_PKG)/usr/sbin/wirecheck \
257 debian/$(UTILS_PKG)/usr/sbin/wiretest
258 dh_makeshlibs -p $(UTILS_PKG)
259 dh_installexamples -p $(UTILS_PKG)
260 dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
261 dh_compress -p $(UTILS_PKG)
262 dh_strip -p $(UTILS_PKG)
263 dh_installdeb -p $(UTILS_PKG)
264 dh_fixperms -p $(UTILS_PKG)
265 dh_gencontrol -p $(UTILS_PKG)
266 dh_md5sums -p $(UTILS_PKG)
267 dh_builddeb -p $(UTILS_PKG)
269 binary-$(RESOURCE_PKG): build-stamp
272 dh_installdirs -p $(RESOURCE_PKG)
273 dh_installdocs -p $(RESOURCE_PKG)
274 dh_installman -p $(RESOURCE_PKG)
275 dh_install -p $(RESOURCE_PKG)
276 dh_makeshlibs -p $(RESOURCE_PKG)
277 dh_installexamples -p $(RESOURCE_PKG)
278 dh_installchangelogs -p $(RESOURCE_PKG) lustre/ChangeLog
279 dh_compress -p $(RESOURCE_PKG)
280 dh_strip -p $(RESOURCE_PKG)
281 dh_installdeb -p $(RESOURCE_PKG)
282 dh_fixperms -p $(RESOURCE_PKG)
283 dh_gencontrol -p $(RESOURCE_PKG)
284 dh_md5sums -p $(RESOURCE_PKG)
285 dh_builddeb -p $(RESOURCE_PKG)
287 binary-$(IOKIT_PKG): build-stamp
290 dh_installdirs -p $(IOKIT_PKG)
291 dh_installdocs -p $(IOKIT_PKG)
292 dh_installman -p $(IOKIT_PKG)
293 dh_install -p $(IOKIT_PKG)
294 rm -rf debian/$(IOKIT_PKG)/usr/bin/lustre_req_history \
295 debian/$(IOKIT_PKG)/usr/bin/*ll*stat \
296 debian/$(IOKIT_PKG)/usr/bin/lfs-*
297 dh_makeshlibs -p $(IOKIT_PKG)
298 dh_installexamples -p $(IOKIT_PKG)
299 dh_installchangelogs -p $(IOKIT_PKG) lustre/ChangeLog
300 dh_compress -p $(IOKIT_PKG)
301 dh_strip -p $(IOKIT_PKG)
302 dh_installdeb -p $(IOKIT_PKG)
303 dh_fixperms -p $(IOKIT_PKG)
304 dh_gencontrol -p $(IOKIT_PKG)
305 dh_md5sums -p $(IOKIT_PKG)
306 dh_builddeb -p $(IOKIT_PKG)
308 binary-$(TESTS_PKG): build-stamp
311 dh_installdirs -p $(TESTS_PKG)
312 dh_installdocs -p $(TESTS_PKG)
313 dh_installman -p $(TESTS_PKG)
314 dh_install -p $(TESTS_PKG)
315 dh_makeshlibs -p $(TESTS_PKG)
316 dh_installexamples -p $(TESTS_PKG)
317 dh_installchangelogs -p $(TESTS_PKG) lustre/ChangeLog
318 dh_compress -p $(TESTS_PKG)
319 dh_strip -p $(TESTS_PKG)
320 dh_installdeb -p $(TESTS_PKG)
321 dh_fixperms -p $(TESTS_PKG)
322 dh_gencontrol -p $(TESTS_PKG)
323 dh_md5sums -p $(TESTS_PKG)
324 dh_builddeb -p $(TESTS_PKG)
326 binary-$(DEV_PKG): build-stamp
329 dh_installdirs -p $(DEV_PKG)
330 dh_install -p $(DEV_PKG)
331 dh_installdocs -p $(DEV_PKG)
332 dh_installchangelogs -p $(DEV_PKG) lustre/ChangeLog
333 dh_compress -p $(DEV_PKG)
334 dh_installdeb -p $(DEV_PKG)
335 dh_fixperms -p $(DEV_PKG)
336 dh_gencontrol -p $(DEV_PKG)
337 dh_md5sums -p $(DEV_PKG)
338 dh_builddeb -p $(DEV_PKG)
340 binary-$(SOURCE_PKG): build-stamp
344 dh_installdirs -p $(SOURCE_PKG) usr/src/modules/lustre/debian
345 rsync -av --exclude='debian/$(SOURCE_PKG)/*' \
347 . debian/$(SOURCE_PKG)/usr/src/modules/lustre
348 # Remove FULLCLEAN setting
349 rm debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
350 sed -e 's/FULLCLEAN=full-clean/FULLCLEAN=/' < debian/rules > debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
352 rm -rf debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patched \
353 debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patches/*
354 $(MAKE) -C debian/$(SOURCE_PKG)/usr/src/modules/lustre -f debian/rules clean
355 # Create the module-source tarball.
356 cd debian/$(SOURCE_PKG)/usr/src && tar jcf lustre.tar.bz2 modules
357 rm -rf debian/$(SOURCE_PKG)/usr/src/modules
358 dh_install -p$(SOURCE_PKG)
359 dh_installchangelogs -p $(SOURCE_PKG) lustre/ChangeLog
360 dh_installdocs -p $(SOURCE_PKG)
361 dh_link -p $(SOURCE_PKG) /usr/share/modass/packages/default.sh /usr/share/modass/overrides/lustre-source
362 dh_compress -p $(SOURCE_PKG)
363 dh_installdeb -p $(SOURCE_PKG)
364 dh_fixperms -p $(SOURCE_PKG)
365 dh_gencontrol -p $(SOURCE_PKG)
366 dh_md5sums -p $(SOURCE_PKG)
367 dh_builddeb -p $(SOURCE_PKG)
369 binary-$(DKMS_PKG): build-stamp
372 # Create /usr/src/lustre-client-modules-<version>
373 dh_installdirs -p $(DKMS_PKG) usr/src/lustre-client-modules-$(UPVERSION)
375 rsync -av --exclude='debian/$(DKMS_PKG)/*' --exclude='.git/' \
377 . debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)
379 $(MAKE) -C debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION) -f debian/rules clean
381 # Put the DKMS configuration file in place
382 sed -e 's/[@]UPVERSION[@]/$(UPVERSION)/' debian/dkms.conf.in > debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)/dkms.conf
383 dh_install -p $(DKMS_PKG)
384 dh_installchangelogs -p $(DKMS_PKG) lustre/ChangeLog
385 dh_installdocs -p $(DKMS_PKG)
386 dh_compress -p $(DKMS_PKG)
387 dh_installdeb -p $(DKMS_PKG)
388 dh_strip -p $(DKMS_PKG)
389 dh_fixperms -p $(DKMS_PKG)
390 dh_gencontrol -p $(DKMS_PKG)
391 dh_md5sums -p $(DKMS_PKG)
392 dh_builddeb -p $(DKMS_PKG)
394 # if only we could use m-a for this, but this stupid "compliant.list"
395 # thing fouls that up
397 # Build client or server modules
398 mkdir -p debian/m-a_root/usr_src/modules
399 ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
400 m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
401 mv -f debian/m-a_root/*.deb ..
403 # an alternative (to module-assistant) method of building the kernel modules
404 binary-$(MODS_PKG): build-stamp
405 if ! $(USE_MA); then \
406 cp debian/$(MODS_PKG).install debian/$(MODS_PKG)-$(KVER).install ; \
409 dh_installdirs -p $(MODS_PKG)-$(KVER); \
410 dh_installdocs -p $(MODS_PKG)-$(KVER); \
411 dh_install -p $(MODS_PKG)-$(KVER); \
412 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
413 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
414 dh_compress -p $(MODS_PKG)-$(KVER); \
415 dh_installdeb -p $(MODS_PKG)-$(KVER); \
416 dh_strip -p $(MODS_PKG)-$(KVER); \
417 dh_fixperms -p $(MODS_PKG)-$(KVER); \
418 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
419 dh_md5sums -p $(MODS_PKG)-$(KVER); \
420 dh_builddeb -p $(MODS_PKG)-$(KVER); \
425 ### For module-assistant
428 # the kdist_clean target is called by make-kpkg modules_clean and from
429 # kdist* rules. It is responsible for cleaning up any changes that have
430 # been made by the other kdist_commands (except for the .deb files created)
433 # can't dh_clean here or we remove the build artifacts for the other packages
436 #-$(MAKE) $(MFLAGS) -f debian/rules clean
437 # put the userspace tools' control file back
438 cp debian/control.main debian/control
441 # module assistant calculates all needed things for us and sets
442 # # following variables:
443 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
444 # # (revision of the Debian kernel-image package), CC (the correct
445 # # compiler), VERSION (the final package version string), PKGNAME (full
446 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
448 # # The kdist_configure target is called by make-kpkg modules_config and
449 # # by kdist* rules by dependency. It should configure the module so it is
450 # # ready for compilation (mostly useful for calling configure).
451 # # prep-deb-files from module-assistant creates the neccessary debian/
452 kdist_config: prep-deb-files patch-stamp
453 # Check build dependencies again, needs to be done since we just
454 # replaced the control file.
456 # Prepare the kernel to lustres' liking
457 # as non-root, we won't have permission for this
458 #-$(MAKE) -C $(KSRC) prepare scripts
459 # touch files to same date, to avoid auto*
460 find . -type f -print0 | xargs -0 touch -r COPYING \;
461 # Determine flags that are different between server/client module builds
462 # Note: It doesn't seem possible to *only* build modules.
463 echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
464 if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
465 export EXTRAFLAGS="--enable-server"; \
467 export EXTRAFLAGS="--disable-server"; \
469 if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
470 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
472 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
474 if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
475 export EXTRAFLAGS="$${EXTRAFLAGS} \
476 --enable-ldiskfs --enable-quilt"; \
478 export EXTRAFLAGS="$${EXTRAFLAGS} \
479 --disable-ldiskfs --disable-quilt"; \
481 if echo "$${DEB_BUILD_PROFILES}" | grep -q "o2ib"; then \
482 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=$${O2IB_SRC}"; \
484 if echo "$${DEB_BUILD_PROFILES}" | grep -qw "crypto"; then \
485 export EXTRAFLAGS="$${EXTRAFLAGS} --enable-crypto"; \
486 elif echo "$${DEB_BUILD_PROFILES}" | grep -qw "nocrypto"; then \
487 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-crypto"; \
489 echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
490 ./configure --with-linux=$(KSRC_TREE) \
491 --with-linux-obj=$(KSRC) \
492 --disable-dependency-tracking \
498 --with-kmp-moddir=updates/kernel \
503 kdist_configure: kdist_config
505 # the binary-modules rule is invoked by module-assistant while processing the
506 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
507 # during a normal build
508 binary-modules: prep-deb-files
512 $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
513 # Remove stuff that doesn't belong (no module-only target)
514 cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr/bin usr/sbin usr/lib usr/share usr/include/lustre lib/systemd sbin etc
515 dh_installdocs -p$(PKGNAME)
516 dh_installchangelogs -p$(PKGNAME)
517 dh_installmodules -p $(PKGNAME)
518 dh_compress -p $(PKGNAME)
519 dh_fixperms -p $(PKGNAME)
520 dh_installdeb -p $(PKGNAME)
521 dh_gencontrol -- -v$(VERSION)
522 dh_md5sums -p $(PKGNAME)
523 dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
524 dh_prep -p $(PKGNAME)
529 dpatch deapply-all -v
531 rm -rf debian/substvars debian/*.bak debian/*~ *~ *-stamp
532 ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | grep -v dkms | xargs rm -f || true
533 # only remove this if the clean was not called from kdist_clean
534 if [ "$$MA_SOURCE_PKG" = "" ]; then \
535 rm -rf debian/m-a_root; \
538 # make sure we have at least a basic control in place (see build-stamp)
540 cp debian/control.main debian/control
548 dpatch deapply-all -v
549 rm -rf debian/patched patch-stamp
551 .PHONY: binary-arch clean source diff binary binary-indep binary-arch install configure