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-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
86 UTILS_PKG=lustre-client-utils
87 MODS_PKG=lustre-client-modules
88 DKMS_PKG=lustre-client-modules-dkms
92 #BUILDDIR=debian/build
94 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
99 AVAIL_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
100 ifneq ($(AVAIL_CPUS),1)
101 PMAKEARGS := -j $(AVAIL_CPUS)
104 autogen: autogen-stamp
105 autogen-stamp: patch-stamp
106 # see if any patches requires us to run autogen
107 # (for a distribution release tarball, it is expected that if
108 # downstream adds any patches that requires autogen.sh to be
109 # run, a patch will be added by downstream to install the
110 # needed autogen.sh scripts
111 # see https://bugzilla.lustre.org/attachment.cgi?id=27156
113 if grep -e "^--- .*\/autoconf\/" \
114 -e "^--- .*\/autoMakefile\.am" \
115 -e "^--- .*\/Makefile\.am" \
116 -e "^--- .*\/configure\.ac" \
117 -e "^--- .*\/configure\.in" \
118 debian/patches/*; then \
119 if [ ! -f build/autogen.sh ]; then \
120 echo "You have patches which require autogen.sh to be run, but it doesn't exist"; \
121 echo "Please see https://bugzilla.lustre.org/attachment.cgi?id=27156"; \
124 cp /usr/share/misc/config.sub config.sub; \
125 cp /usr/share/misc/config.sub ldiskfs/config.sub; \
126 cp /usr/share/misc/config.guess config.guess; \
127 cp /usr/share/misc/config.guess ldiskfs/config.guess; \
128 sh build/autogen.sh; \
132 # This section configures the lustre-utilities packages.
134 # Both client and server builds are quite similar, as the utilities build
135 # must create the modules too, to produce the "osd_<fstype>.so" libraries.
137 # The main difference is that the utilities build does not archive the
138 # modules, whereas the modules build omits the utilities, to create two
139 # neatly separated debian files.
141 # Note: KERNEL_SRC, KERNEL_CFG, ZFS_SRC and SPL_SRC need to be set from the
142 # outside. This is done by "make debs". As such, invoking "debuild" or such
143 # direct debian build tools will lead to a client-only build.
144 configure: configure-stamp
145 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
147 # touch files to same date, to avoid auto*
148 find . -type f -print0 | xargs -0 touch -r COPYING; \
149 if [ "$(BUILDDIR)" != "." ]; then \
150 mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib; \
151 cp build/Makefile $(BUILDDIR)/build/; \
153 # Determine flags that are different between server/client module builds
154 echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
155 if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
156 export EXTRAFLAGS="--enable-server"; \
158 export EXTRAFLAGS="--disable-server --disable-modules"; \
160 if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
161 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
163 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
165 if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
166 export EXTRAFLAGS="$${EXTRAFLAGS} \
167 --enable-ldiskfs --enable-quilt"; \
169 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
171 echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
172 ( cd $(BUILDDIR) && \
173 $(SRCDIR)/configure --disable-dependency-tracking \
174 --with-linux=$${KERNEL_SRC} \
175 --with-linux-config=$${KERNEL_CFG} \
182 build-arch build-indep: build
185 build-stamp: patch-stamp configure-stamp
187 $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
188 $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
189 # jump our lustre-[client|server]-modules into the control file if not using m-a
190 if ! $(USE_MA); then \
191 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
192 for file in debian/*_KVERS_*; do \
193 newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
194 cp $$file $$newfile; \
199 # let's try and operate as close as the user would and not build modules
201 # instead we will build the modules with m-a in the "make debs" target
202 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
203 # binary-$(MODS_PKG) binary-kern-mods
204 binary-arch: binary-$(UTILS_PKG) binary-$(DEV_PKG) \
205 binary-$(IOKIT_PKG) binary-$(TESTS_PKG)
207 binary-indep: binary-$(SOURCE_PKG) $(DKMS_TARGET)
209 binary: binary-indep binary-arch
211 binary-$(UTILS_PKG): build-stamp
214 dh_installdirs -p $(UTILS_PKG)
215 dh_installdocs -p $(UTILS_PKG)
216 dh_installman -p $(UTILS_PKG)
217 dh_install -p $(UTILS_PKG)
218 rm -rf debian/$(UTILS_PKG)/usr/bin/iokit-* \
219 debian/$(UTILS_PKG)/usr/bin/*-survey \
220 debian/$(UTILS_PKG)/usr/bin/mcreate \
221 debian/$(UTILS_PKG)/usr/bin/munlink \
222 debian/$(UTILS_PKG)/usr/sbin/wirecheck \
223 debian/$(UTILS_PKG)/usr/sbin/wiretest
224 dh_makeshlibs -p $(UTILS_PKG)
225 dh_installexamples -p $(UTILS_PKG)
226 dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
227 dh_compress -p $(UTILS_PKG)
228 dh_strip -p $(UTILS_PKG)
229 dh_installdeb -p $(UTILS_PKG)
230 dh_fixperms -p $(UTILS_PKG)
231 dh_gencontrol -p $(UTILS_PKG)
232 dh_md5sums -p $(UTILS_PKG)
233 dh_builddeb -p $(UTILS_PKG)
235 binary-$(IOKIT_PKG): build-stamp
238 dh_installdirs -p $(IOKIT_PKG)
239 dh_installdocs -p $(IOKIT_PKG)
240 dh_installman -p $(IOKIT_PKG)
241 dh_install -p $(IOKIT_PKG)
242 rm -rf debian/$(IOKIT_PKG)/usr/bin/lustre_req_history \
243 debian/$(IOKIT_PKG)/usr/bin/*ll*stat \
244 debian/$(IOKIT_PKG)/usr/bin/lfs-*
245 dh_makeshlibs -p $(IOKIT_PKG)
246 dh_installexamples -p $(IOKIT_PKG)
247 dh_installchangelogs -p $(IOKIT_PKG) lustre/ChangeLog
248 dh_compress -p $(IOKIT_PKG)
249 dh_strip -p $(IOKIT_PKG)
250 dh_installdeb -p $(IOKIT_PKG)
251 dh_fixperms -p $(IOKIT_PKG)
252 dh_gencontrol -p $(IOKIT_PKG)
253 dh_md5sums -p $(IOKIT_PKG)
254 dh_builddeb -p $(IOKIT_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 binary-$(DKMS_PKG): build-stamp
320 # Create /usr/src/lustre-client-modules-<version>
321 dh_installdirs -p $(DKMS_PKG) usr/src/lustre-client-modules-$(UPVERSION)
323 rsync -av --exclude='debian/$(DKMS_PKG)/*' --exclude='.git/' \
325 . debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)
327 $(MAKE) -C debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION) -f debian/rules clean
329 # Put the DKMS configuration file in place
330 sed -e 's/[@]UPVERSION[@]/$(UPVERSION)/' debian/dkms.conf.in > debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)/dkms.conf
331 dh_install -p $(DKMS_PKG)
332 dh_installchangelogs -p $(DKMS_PKG) lustre/ChangeLog
333 dh_installdocs -p $(DKMS_PKG)
334 dh_compress -p $(DKMS_PKG)
335 dh_installdeb -p $(DKMS_PKG)
336 dh_strip -p $(DKMS_PKG)
337 dh_fixperms -p $(DKMS_PKG)
338 dh_gencontrol -p $(DKMS_PKG)
339 dh_md5sums -p $(DKMS_PKG)
340 dh_builddeb -p $(DKMS_PKG)
342 # if only we could use m-a for this, but this stupid "compliant.list"
343 # thing fouls that up
345 # Build client or server modules
346 mkdir -p debian/m-a_root/usr_src/modules
347 ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
348 m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
349 mv -f debian/m-a_root/*.deb ..
351 # an alternative (to module-assistant) method of building the kernel modules
352 binary-$(MODS_PKG): build-stamp
353 if ! $(USE_MA); then \
354 cp debian/$(MODS_PKG).install debian/$(MODS_PKG)-$(KVER).install ; \
357 dh_installdirs -p $(MODS_PKG)-$(KVER); \
358 dh_installdocs -p $(MODS_PKG)-$(KVER); \
359 dh_install -p $(MODS_PKG)-$(KVER); \
360 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
361 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
362 dh_compress -p $(MODS_PKG)-$(KVER); \
363 dh_installdeb -p $(MODS_PKG)-$(KVER); \
364 dh_strip -p $(MODS_PKG)-$(KVER); \
365 dh_fixperms -p $(MODS_PKG)-$(KVER); \
366 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
367 dh_md5sums -p $(MODS_PKG)-$(KVER); \
368 dh_builddeb -p $(MODS_PKG)-$(KVER); \
373 ### For module-assistant
376 # the kdist_clean target is called by make-kpkg modules_clean and from
377 # kdist* rules. It is responsible for cleaning up any changes that have
378 # been made by the other kdist_commands (except for the .deb files created)
381 # can't dh_clean here or we remove the build artifacts for the other packages
384 #-$(MAKE) $(MFLAGS) -f debian/rules clean
385 # put the userspace tools' control file back
386 cp debian/control.main debian/control
389 # module assistant calculates all needed things for us and sets
390 # # following variables:
391 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
392 # # (revision of the Debian kernel-image package), CC (the correct
393 # # compiler), VERSION (the final package version string), PKGNAME (full
394 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
396 # # The kdist_configure target is called by make-kpkg modules_config and
397 # # by kdist* rules by dependency. It should configure the module so it is
398 # # ready for compilation (mostly useful for calling configure).
399 # # prep-deb-files from module-assistant creates the neccessary debian/
400 kdist_config: prep-deb-files patch-stamp
401 # Check build dependencies again, needs to be done since we just
402 # replaced the control file.
404 # Prepare the kernel to lustres' liking
405 # as non-root, we won't have permission for this
406 #-$(MAKE) -C $(KSRC) prepare scripts
407 # touch files to same date, to avoid auto*
408 find . -type f -print0 | xargs -0 touch -r COPYING \;
409 # Determine flags that are different between server/client module builds
410 # Note: It doesn't seem possible to *only* build modules.
411 echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
412 if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
413 export EXTRAFLAGS="--enable-server"; \
415 export EXTRAFLAGS="--disable-server"; \
417 if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
418 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
420 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
422 if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
423 export EXTRAFLAGS="$${EXTRAFLAGS} \
424 --enable-ldiskfs --enable-quilt"; \
426 export EXTRAFLAGS="$${EXTRAFLAGS} \
427 --disable-ldiskfs --disable-quilt"; \
429 echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
430 ./configure --with-linux=$(KSRC_TREE) \
431 --with-linux-obj=$(KSRC) \
432 --disable-dependency-tracking \
438 --with-kmp-moddir=updates \
443 kdist_configure: kdist_config
445 # the binary-modules rule is invoked by module-assistant while processing the
446 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
447 # during a normal build
448 binary-modules: prep-deb-files
452 $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
453 # Remove stuff that doesn't belong (no module-only target)
454 cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr/bin usr/sbin usr/lib usr/share usr/include/lustre lib/systemd sbin etc
455 dh_installdocs -p$(PKGNAME)
456 dh_installchangelogs -p$(PKGNAME)
457 dh_installmodules -p $(PKGNAME)
458 dh_compress -p $(PKGNAME)
459 dh_fixperms -p $(PKGNAME)
460 dh_installdeb -p $(PKGNAME)
461 dh_gencontrol -- -v$(VERSION)
462 dh_md5sums -p $(PKGNAME)
463 dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
464 dh_prep -p $(PKGNAME)
469 dpatch deapply-all -v
471 rm -rf debian/substvars debian/*.bak debian/*~ *~ *-stamp
472 ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | grep -v dkms | xargs rm -f || true
473 # only remove this if the clean was not called from kdist_clean
474 if [ "$$MA_SOURCE_PKG" = "" ]; then \
475 rm -rf debian/m-a_root; \
478 # make sure we have at least a basic control in place (see build-stamp)
480 cp debian/control.main debian/control
488 dpatch deapply-all -v
489 rm -rf debian/patched patch-stamp
491 .PHONY: binary-arch clean source diff binary binary-indep binary-arch install configure