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 compatibility 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 # This is the Lustre version
44 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
45 UPVERSION=$(shell echo $VERSION | sed -e 's/-[^-]*$$//')
47 # KVER is set to LINUXRELEASE being by autoconf which is either
48 # $(uname -r) or the version of the source specified by the user
51 # KVERS, KSRC are the kernel version and source to use when building lustre
52 # Will be the default when building lustre-utils, etc but whatever module-assistant
53 # supplied when building modules
60 UTILS_PKG=lustre-utils
61 TESTS_PKG=lustre-tests
63 SOURCE_PKG=lustre-source
64 MODS_PKG=lustre-client-modules
65 IOKIT_PKG=lustre-iokit
68 #BUILDDIR=debian/build
70 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
75 AVAIL_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
76 ifneq ($(AVAIL_CPUS),1)
77 PMAKEARGS := -j $(AVAIL_CPUS)
80 autogen: autogen-stamp
81 autogen-stamp: patch-stamp
82 # see if any patches requires us to run autogen
83 # (for a distribution release tarball, it is expected that if
84 # downstream adds any patches that requires autogen.sh to be
85 # run, a patch will be added by downstream to install the
86 # needed autogen.sh scripts
87 # see https://bugzilla.lustre.org/attachment.cgi?id=27156
89 if grep -e "^--- .*\/autoconf\/" \
90 -e "^--- .*\/autoMakefile\.am" \
91 -e "^--- .*\/Makefile\.am" \
92 -e "^--- .*\/configure\.ac" \
93 -e "^--- .*\/configure\.in" \
94 debian/patches/*; then \
95 if [ ! -f build/autogen.sh ]; then \
96 echo "You have patches which require autogen.sh to be run, but it doesn't exist"; \
97 echo "Please see https://bugzilla.lustre.org/attachment.cgi?id=27156"; \
100 cp /usr/share/misc/config.sub config.sub; \
101 cp /usr/share/misc/config.sub ldiskfs/config.sub; \
102 cp /usr/share/misc/config.guess config.guess; \
103 cp /usr/share/misc/config.guess ldiskfs/config.guess; \
104 sh build/autogen.sh; \
108 configure: configure-stamp
109 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
111 # touch files to same date, to avoid auto*
112 find . -type f -print0 | xargs -0 touch -r COPYING; \
113 if [ "$(BUILDDIR)" != "." ]; then \
114 mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib; \
115 cp build/Makefile $(BUILDDIR)/build/; \
117 ( cd $(BUILDDIR) && \
118 $(SRCDIR)/configure --disable-dependency-tracking \
126 build-arch build-indep: build
129 build-stamp: patch-stamp configure-stamp
131 $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
132 $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
133 # jump our lustre-client-modules into the control file if not using m-a
134 if ! $(USE_MA); then \
135 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
136 for file in debian/*_KVERS_*; do \
137 newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
138 cp $$file $$newfile; \
143 # let's try and operate as close as the user would and not build modules
145 # instead we will build the modules with m-a in the "make debs" target
146 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
147 # binary-$(MODS_PKG) binary-kern-mods
148 binary-arch: binary-$(UTILS_PKG) binary-$(DEV_PKG) \
149 binary-$(IOKIT_PKG) binary-$(TESTS_PKG)
151 binary-indep: binary-$(SOURCE_PKG)
153 binary: binary-indep binary-arch
155 binary-$(UTILS_PKG): build-stamp
158 dh_installdirs -p $(UTILS_PKG)
159 dh_installdocs -p $(UTILS_PKG)
160 dh_installman -p $(UTILS_PKG)
161 dh_install -p $(UTILS_PKG)
162 rm -rf debian/$(UTILS_PKG)/usr/bin/iokit-* \
163 debian/$(UTILS_PKG)/usr/bin/*-survey \
164 debian/$(UTILS_PKG)/usr/bin/mcreate \
165 debian/$(UTILS_PKG)/usr/bin/munlink \
166 debian/$(UTILS_PKG)/usr/sbin/wirecheck \
167 debian/$(UTILS_PKG)/usr/sbin/wiretest
168 dh_makeshlibs -p $(UTILS_PKG)
169 dh_installexamples -p $(UTILS_PKG)
170 dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
171 dh_compress -p $(UTILS_PKG)
172 dh_strip -p $(UTILS_PKG)
173 dh_installdeb -p $(UTILS_PKG)
174 dh_fixperms -p $(UTILS_PKG)
175 dh_gencontrol -p $(UTILS_PKG)
176 dh_md5sums -p $(UTILS_PKG)
177 dh_builddeb -p $(UTILS_PKG)
179 binary-$(IOKIT_PKG): build-stamp
182 dh_installdirs -p $(IOKIT_PKG)
183 dh_installdocs -p $(IOKIT_PKG)
184 dh_installman -p $(IOKIT_PKG)
185 dh_install -p $(IOKIT_PKG)
186 rm -rf debian/$(IOKIT_PKG)/usr/bin/lustre_req_history \
187 debian/$(IOKIT_PKG)/usr/bin/*ll*stat \
188 debian/$(IOKIT_PKG)/usr/bin/lfs-*
189 dh_makeshlibs -p $(IOKIT_PKG)
190 dh_installexamples -p $(IOKIT_PKG)
191 dh_installchangelogs -p $(IOKIT_PKG) lustre/ChangeLog
192 dh_compress -p $(IOKIT_PKG)
193 dh_strip -p $(IOKIT_PKG)
194 dh_installdeb -p $(IOKIT_PKG)
195 dh_fixperms -p $(IOKIT_PKG)
196 dh_gencontrol -p $(IOKIT_PKG)
197 dh_md5sums -p $(IOKIT_PKG)
198 dh_builddeb -p $(IOKIT_PKG)
200 binary-$(TESTS_PKG): build-stamp
203 dh_installdirs -p $(TESTS_PKG)
204 dh_installdocs -p $(TESTS_PKG)
205 dh_installman -p $(TESTS_PKG)
206 dh_install -p $(TESTS_PKG)
207 dh_makeshlibs -p $(TESTS_PKG)
208 dh_installexamples -p $(TESTS_PKG)
209 dh_installchangelogs -p $(TESTS_PKG) lustre/ChangeLog
210 dh_compress -p $(TESTS_PKG)
211 dh_strip -p $(TESTS_PKG)
212 dh_installdeb -p $(TESTS_PKG)
213 dh_fixperms -p $(TESTS_PKG)
214 dh_gencontrol -p $(TESTS_PKG)
215 dh_md5sums -p $(TESTS_PKG)
216 dh_builddeb -p $(TESTS_PKG)
218 binary-$(DEV_PKG): build-stamp
221 dh_installdirs -p $(DEV_PKG)
222 dh_install -p $(DEV_PKG)
223 dh_installdocs -p $(DEV_PKG)
224 dh_installchangelogs -p $(DEV_PKG) lustre/ChangeLog
225 dh_compress -p $(DEV_PKG)
226 dh_installdeb -p $(DEV_PKG)
227 dh_fixperms -p $(DEV_PKG)
228 dh_gencontrol -p $(DEV_PKG)
229 dh_md5sums -p $(DEV_PKG)
230 dh_builddeb -p $(DEV_PKG)
232 binary-$(SOURCE_PKG): build-stamp
236 dh_installdirs -p $(SOURCE_PKG) usr/src/modules/lustre/debian
237 rsync -av --exclude='debian/$(SOURCE_PKG)/*' \
239 . debian/$(SOURCE_PKG)/usr/src/modules/lustre
240 # Remove FULLCLEAN setting
241 rm debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
242 sed -e 's/FULLCLEAN=full-clean/FULLCLEAN=/' < debian/rules > debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
244 rm -rf debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patched \
245 debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patches/*
246 $(MAKE) -C debian/$(SOURCE_PKG)/usr/src/modules/lustre -f debian/rules clean
247 # Create the module-source tarball.
248 cd debian/$(SOURCE_PKG)/usr/src && tar jcf lustre.tar.bz2 modules
249 rm -rf debian/$(SOURCE_PKG)/usr/src/modules
250 dh_install -p$(SOURCE_PKG)
251 dh_installchangelogs -p $(SOURCE_PKG) lustre/ChangeLog
252 dh_installdocs -p $(SOURCE_PKG)
253 dh_link -p $(SOURCE_PKG) /usr/share/modass/packages/default.sh /usr/share/modass/overrides/lustre-source
254 dh_compress -p $(SOURCE_PKG)
255 dh_installdeb -p $(SOURCE_PKG)
256 dh_fixperms -p $(SOURCE_PKG)
257 dh_gencontrol -p $(SOURCE_PKG)
258 dh_md5sums -p $(SOURCE_PKG)
259 dh_builddeb -p $(SOURCE_PKG)
261 # if only we could use m-a for this, but this stupid "compliant.list"
262 # thing fouls that up
264 mkdir -p debian/m-a_root/usr_src/modules
265 ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
266 m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
267 mv -f debian/m-a_root/*.deb ..
269 # an alternative (to module-assistant) method of building the kernel modules
270 binary-$(MODS_PKG): build-stamp
271 if ! $(USE_MA); then \
272 cp debian/lustre-client-modules.install debian/lustre-client-modules-$(KVER).install ; \
275 dh_installdirs -p $(MODS_PKG)-$(KVER); \
276 dh_installdocs -p $(MODS_PKG)-$(KVER); \
277 dh_install -p $(MODS_PKG)-$(KVER); \
278 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
279 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
280 dh_compress -p $(MODS_PKG)-$(KVER); \
281 dh_installdeb -p $(MODS_PKG)-$(KVER); \
282 dh_strip -p $(MODS_PKG)-$(KVER); \
283 dh_fixperms -p $(MODS_PKG)-$(KVER); \
284 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
285 dh_md5sums -p $(MODS_PKG)-$(KVER); \
286 dh_builddeb -p $(MODS_PKG)-$(KVER); \
290 ### For module-assistant
293 # the kdist_clean target is called by make-kpkg modules_clean and from
294 # kdist* rules. It is responsible for cleaning up any changes that have
295 # been made by the other kdist_commands (except for the .deb files created)
298 # can't dh_clean here or we remove the build artifacts for the other packages
301 #-$(MAKE) $(MFLAGS) -f debian/rules clean
302 # put the userspace tools' control file back
303 cp debian/control.main debian/control
306 # module assistant calculates all needed things for us and sets
307 # # following variables:
308 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
309 # # (revision of the Debian kernel-image package), CC (the correct
310 # # compiler), VERSION (the final package version string), PKGNAME (full
311 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
313 # # The kdist_configure target is called by make-kpkg modules_config and
314 # # by kdist* rules by dependency. It should configure the module so it is
315 # # ready for compilation (mostly useful for calling configure).
316 # # prep-deb-files from module-assistant creates the neccessary debian/
317 kdist_config: prep-deb-files patch-stamp
318 # Check build dependencies again, needs to be done since we just
319 # replaced the control file.
321 # Prepare the kernel to lustres' liking
322 # as non-root, we won't have permission for this
323 #-$(MAKE) -C $(KSRC) prepare scripts
324 # touch files to same date, to avoid auto*
325 find . -type f -print0 | xargs -0 touch -r COPYING \;
326 # Doesn't seem possible to only build modules...
327 ./configure --with-linux=$(KSRC_TREE) \
328 --with-linux-obj=$(KSRC) \
331 --disable-dependency-tracking \
338 --with-kmp-moddir=updates \
341 kdist_configure: kdist_config
343 # the binary-modules rule is invoked by module-assistant while processing the
344 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
345 # during a normal build
346 binary-modules: prep-deb-files
350 $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
351 # Remove stuff that doesn't belong (no module-only target)
352 cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr/bin usr/sbin usr/lib usr/share usr/include/lustre sbin etc
353 dh_installdocs -p$(PKGNAME)
354 dh_installchangelogs -p$(PKGNAME)
355 dh_installmodules -p $(PKGNAME)
356 dh_compress -p $(PKGNAME)
357 dh_fixperms -p $(PKGNAME)
358 dh_installdeb -p $(PKGNAME)
359 dh_gencontrol -- -v$(VERSION)
360 dh_md5sums -p $(PKGNAME)
361 dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
362 dh_prep -p $(PKGNAME)
367 dpatch deapply-all -v
369 rm -rf debian/substvars debian/*.bak debian/*~ *~ *-stamp
370 ls -d debian/lustre-client-modules-* | grep -v _KVERS_ | xargs rm -f || true
371 # only remove this if the clean was not called from kdist_clean
372 if [ "$$MA_SOURCE_PKG" = "" ]; then \
373 rm -rf debian/m-a_root; \
376 # make sure we have at least a basic control in place (see build-stamp)
378 cp debian/control.main debian/control
386 dpatch deapply-all -v
387 rm -rf debian/patched patch-stamp
389 .PHONY: binary-arch clean source diff binary binary-indep binary-arch install configure