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)
16 # whether to use module-assistant to build the kernel modules or not
20 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
26 # We need the kernels to be built with gcc-3.3; suspect that gcc-4.1 uses too
27 # much stack and crashes because of it.
31 # This is the debhelper compatability version to use.
34 # Module-assistant stuff
35 PACKAGE=lustre-client-modules
36 MA_DIR ?= /usr/share/modass
37 -include $(MA_DIR)/include/generic.make
38 -include $(MA_DIR)/include/common-rules.make
40 ARCH=$(shell dpkg --print-architecture)
43 # the lustre build process. This is $(KERNEL_VERSION)
44 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
45 #SUPPORTED_KERNELS=2.6.27
46 SUPPORTED_KERNELS=2.6.18 2.6.20 2.6.22
47 UPVERSION=$(shell echo $VERSION | sed -e 's/-[^-]*$$//')
48 #KERNEL_VERSION=2.6.27
49 # the kernel version to build all of this with
50 #KVER=2.6.27-11-generic
51 # if the above is not set, default to whatever kernel is booted
53 KERNEL_TREE=/lib/modules/$(KVER)/build
54 # KVERS, KSRC are the kernel version and source to use when building lustre
55 # Will be the default when building lustre-utils, etc but whatever module-assistant
56 # supplied when building modules
57 KVERS?=$(KERNEL_VERSION)
62 PATCH_PKG=linux-patch-lustre
63 UTILS_PKG=lustre-utils
64 TESTS_PKG=lustre-tests
67 SOURCE_PKG=lustre-source
68 MODS_PKG=lustre-client-modules
71 #BUILDDIR=debian/build
73 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
78 autogen: autogen-stamp
79 autogen-stamp: patch-stamp
80 # There is really no reason to run this unless somebody adds a
81 # patch that patches the autoconf system, in which case they can
82 # include a patch for autogen.sh and uncomment this stuff.
83 #cp /usr/share/misc/config.sub config.sub
84 #cp /usr/share/misc/config.sub libsysio/config.sub
85 #cp /usr/share/misc/config.sub ldiskfs/config.sub
86 #cp /usr/share/misc/config.guess config.guess
87 #cp /usr/share/misc/config.guess libsysio/config.guess
88 #cp /usr/share/misc/config.guess ldiskfs/config.guess
92 configure: configure-stamp
93 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
95 # touch files to same date, to avoid auto*
96 find . -type f -print0 | xargs -0 touch -r COPYING; \
97 if [ "$(BUILDDIR)" != "." ]; then \
98 mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib $(BUILDDIR)/libsysio; \
99 cp build/Makefile $(BUILDDIR)/build/; \
100 cp lustre/contrib/mpich-*.patch $(BUILDDIR)/lustre/contrib/; \
101 ln -s ../../../libsysio/include $(BUILDDIR)/libsysio/; \
103 ( cd $(BUILDDIR) && \
104 $(SRCDIR)/configure --disable-dependency-tracking \
112 build-arch build-indep: build
115 build-stamp: patch-stamp configure-stamp
117 $(MAKE) -C $(BUILDDIR)
118 $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
119 # jump our lustre-client-modules into the control file if not using m-a
120 if ! $(USE_MA); then \
121 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
122 for file in debian/*_KVERS_*; do \
123 newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
124 cp $$file $$newfile; \
129 # let's try and operate as close as the user would and not build modules
131 # instead we will build the modules with m-a in the "make debs" target
132 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) binary-$(LIB_PKG) binary-$(MODS_PKG) binary-kern-mods
133 binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) binary-$(LIB_PKG)
135 binary-indep: binary-$(PATCH_PKG) binary-$(SOURCE_PKG)
137 binary: binary-indep binary-arch
139 binary-$(PATCH_PKG): patch-stamp
142 dh_installdirs -p $(PATCH_PKG)
143 dh_installdocs -p $(PATCH_PKG)
144 # dh_installkpatches -p $(PATCH_PKG)
145 dh_install -p $(PATCH_PKG)
147 # Install apply script
148 cp $(TOP_DIR)/debian/linux-patch-lustre.apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
149 chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
150 set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
151 mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/; \
152 ln -s ../../../lustre/scripts/apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/lustre; \
155 # Install unpatch script
156 cp $(TOP_DIR)/debian/linux-patch-lustre.unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
157 chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
158 set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
159 mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/; \
160 ln -s ../../../lustre/scripts/unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/lustre; \
164 cp lustre/kernel_patches/series/*.series $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/series/
167 cp lustre/kernel_patches/patches/*.patch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/patches/
169 dh_installchangelogs -p $(PATCH_PKG) lustre/ChangeLog
170 dh_compress -p $(PATCH_PKG)
171 dh_installdeb -p $(PATCH_PKG)
172 dh_fixperms -p $(PATCH_PKG)
173 dh_gencontrol -p $(PATCH_PKG)
174 dh_md5sums -p $(PATCH_PKG)
175 dh_builddeb -p $(PATCH_PKG)
177 binary-$(UTILS_PKG): build-stamp
180 dh_installdirs -p $(UTILS_PKG)
181 dh_installdocs -p $(UTILS_PKG)
182 dh_installman -p $(UTILS_PKG)
183 dh_install -p $(UTILS_PKG)
184 dh_makeshlibs -p $(UTILS_PKG)
185 dh_shlibdeps -L $(LIB_PKG) -l debian/$(LIB_PKG)/usr/lib
186 dh_installexamples -p $(UTILS_PKG)
187 dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
188 dh_compress -p $(UTILS_PKG)
189 dh_strip -p $(UTILS_PKG)
190 dh_installdeb -p $(UTILS_PKG)
191 dh_fixperms -p $(UTILS_PKG)
192 dh_gencontrol -p $(UTILS_PKG)
193 dh_md5sums -p $(UTILS_PKG)
194 dh_builddeb -p $(UTILS_PKG)
196 binary-$(TESTS_PKG): build-stamp
199 dh_installdirs -p $(TESTS_PKG)
200 dh_installdocs -p $(TESTS_PKG)
201 dh_installman -p $(TESTS_PKG)
202 dh_install -p $(TESTS_PKG)
203 dh_makeshlibs -p $(TESTS_PKG)
204 dh_shlibdeps -L $(LIB_PKG) -l debian/$(LIB_PKG)/usr/lib
205 dh_installexamples -p $(TESTS_PKG)
206 dh_installchangelogs -p $(TESTS_PKG) lustre/ChangeLog
207 dh_compress -p $(TESTS_PKG)
208 dh_strip -p $(TESTS_PKG)
209 dh_installdeb -p $(TESTS_PKG)
210 dh_fixperms -p $(TESTS_PKG)
211 dh_gencontrol -p $(TESTS_PKG)
212 dh_md5sums -p $(TESTS_PKG)
213 dh_builddeb -p $(TESTS_PKG)
215 binary-$(DEV_PKG): build-stamp
218 dh_installdirs -p $(DEV_PKG)
219 dh_install -p $(DEV_PKG)
220 dh_installdocs -p $(DEV_PKG)
221 dh_installchangelogs -p $(DEV_PKG) lustre/ChangeLog
222 dh_compress -p $(DEV_PKG)
223 dh_installdeb -p $(DEV_PKG)
224 dh_fixperms -p $(DEV_PKG)
225 dh_gencontrol -p $(DEV_PKG)
226 dh_md5sums -p $(DEV_PKG)
227 dh_builddeb -p $(DEV_PKG)
229 binary-$(LIB_PKG): build-stamp
232 dh_installdirs -p $(LIB_PKG)
233 dh_installdocs -p $(LIB_PKG)
234 dh_install -p $(LIB_PKG)
235 dh_makeshlibs -p $(LIB_PKG)
236 dh_shlibdeps -L $(LIB_PKG) -l debian/$(LIB_PKG)/usr/lib
237 dh_installchangelogs -p $(LIB_PKG) lustre/ChangeLog
238 dh_compress -p $(LIB_PKG)
239 dh_installdeb -p $(LIB_PKG)
240 dh_strip -p $(LIB_PKG)
241 dh_fixperms -p $(LIB_PKG)
242 dh_gencontrol -p $(LIB_PKG)
243 dh_md5sums -p $(LIB_PKG)
244 dh_builddeb -p $(LIB_PKG)
246 binary-$(SOURCE_PKG): build-stamp
250 dh_installdirs -p $(SOURCE_PKG) usr/src/modules/lustre/debian
251 rsync -av --exclude='debian/$(SOURCE_PKG)/*' \
253 . debian/$(SOURCE_PKG)/usr/src/modules/lustre
254 # Remove FULLCLEAN setting
255 rm debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
256 sed -e 's/FULLCLEAN=full-clean/FULLCLEAN=/' < debian/rules > debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
258 rm -rf debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patched \
259 debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patches/*
260 $(MAKE) -C debian/$(SOURCE_PKG)/usr/src/modules/lustre -f debian/rules clean
261 # Create the module-source tarball.
262 cd debian/$(SOURCE_PKG)/usr/src && tar jcf lustre.tar.bz2 modules
263 rm -rf debian/$(SOURCE_PKG)/usr/src/modules
264 dh_install -p$(SOURCE_PKG)
265 dh_installchangelogs -p $(SOURCE_PKG) lustre/ChangeLog
266 dh_installdocs -p $(SOURCE_PKG)
267 dh_link -p $(SOURCE_PKG) /usr/share/modass/packages/default.sh /usr/share/modass/overrides/lustre-source
268 dh_compress -p $(SOURCE_PKG)
269 dh_installdeb -p $(SOURCE_PKG)
270 dh_fixperms -p $(SOURCE_PKG)
271 dh_gencontrol -p $(SOURCE_PKG)
272 dh_md5sums -p $(SOURCE_PKG)
273 dh_builddeb -p $(SOURCE_PKG)
275 # if only we could use m-a for this, but this stupid "compliant.list"
276 # thing fouls that up
278 mkdir -p debian/m-a_root/usr_src/modules
279 ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
280 m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
281 mv -f debian/m-a_root/*.deb ..
283 # an alternative (to module-assistant) method of building the kernel modules
284 binary-$(MODS_PKG): build-stamp
285 if ! $(USE_MA); then \
286 cp debian/lustre-client-modules.install debian/lustre-client-modules-$(KVER).install ; \
289 dh_installdirs -p $(MODS_PKG)-$(KVER); \
290 dh_installdocs -p $(MODS_PKG)-$(KVER); \
291 dh_install -p $(MODS_PKG)-$(KVER); \
292 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
293 dh_shlibdeps -L $(LIB_PKG) -l debian/$(LIB_PKG)/usr/lib; \
294 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
295 dh_compress -p $(MODS_PKG)-$(KVER); \
296 dh_installdeb -p $(MODS_PKG)-$(KVER); \
297 dh_strip -p $(MODS_PKG)-$(KVER); \
298 dh_fixperms -p $(MODS_PKG)-$(KVER); \
299 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
300 dh_md5sums -p $(MODS_PKG)-$(KVER); \
301 dh_builddeb -p $(MODS_PKG)-$(KVER); \
305 ### For module-assistant
308 # the kdist_clean target is called by make-kpkg modules_clean and from
309 # kdist* rules. It is responsible for cleaning up any changes that have
310 # been made by the other kdist_commands (except for the .deb files created)
313 # can't dh_clean here or we remove the build artifacts for the other packages
316 #-$(MAKE) $(MFLAGS) -f debian/rules clean
317 # put the userspace tools' control file back
318 cp debian/control.main debian/control
321 # module assistant calculates all needed things for us and sets
322 # # following variables:
323 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
324 # # (revision of the Debian kernel-image package), CC (the correct
325 # # compiler), VERSION (the final package version string), PKGNAME (full
326 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
328 # # The kdist_configure target is called by make-kpkg modules_config and
329 # # by kdist* rules by dependency. It should configure the module so it is
330 # # ready for compilation (mostly useful for calling configure).
331 # # prep-deb-files from module-assistant creates the neccessary debian/
332 kdist_config: prep-deb-files patch-stamp
333 # Check build dependencies again, needs to be done since we just
334 # replaced the control file.
336 # Prepare the kernel to lustres' liking
337 # as non-root, we won't have permission for this
338 #-$(MAKE) -C $(KSRC) prepare scripts
339 # touch files to same date, to avoid auto*
340 find . -type f -print0 | xargs -0 touch -r COPYING \;
341 # Doesn't seem possible to only build modules...
342 ./configure --with-linux=$(KSRC) \
344 --disable-dependency-tracking \
347 --disable-liblustre \
354 kdist_configure: kdist_config
356 # the binary-modules rule is invoked by module-assistant while processing the
357 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
358 # during a normal build
359 binary-modules: prep-deb-files
363 $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
364 # Remove stuff that doesn't belong (no module-only target)
365 cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr sbin etc
366 dh_installdocs -p$(PKGNAME)
367 dh_installchangelogs -p$(PKGNAME)
368 dh_installmodules -p $(PKGNAME)
369 dh_compress -p $(PKGNAME)
370 dh_fixperms -p $(PKGNAME)
371 dh_installdeb -p $(PKGNAME)
372 dh_gencontrol -- -v$(VERSION)
373 dh_md5sums -p $(PKGNAME)
374 dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
375 dh_clean -k -p $(PKGNAME)
382 rm -rf debian/substvars debian/*.bak debian/*~ *~ *-stamp debian/$(PATCH_PKG)
383 ls -d debian/lustre-client-modules-* | grep -v _KVERS_ | xargs rm -f || true
384 # only remove this if the clean was not called from kdist_clean
385 if [ "$$MA_SOURCE_PKG" = "" ]; then \
386 rm -rf debian/m-a_root; \
389 # make sure we have at least a basic control in place (see build-stamp)
391 cp debian/control.main debian/control
400 rm -rf debian/patched patch-stamp
402 .PHONY: binary-arch clean source diff binary binary-indep binary-arch install configure