Whamcloud - gitweb
LU-7896: do not call lu_site_purge() for single object exceed
[fs/lustre-release.git] / debian / rules
1 #!/usr/bin/make -f
2 #
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
6 #
7 # Copying and modification is unlimited, provided that the modified
8 # version is marked as being modified.
9
10 # Uncomment this to turn on verbose mode.
11 # export DH_VERBOSE=1
12
13 DEB_BUILD_GNU_SYSTEM = $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
14 DEB_BUILD_GNU_CPU = $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
15
16 # whether to use module-assistant to build the kernel modules or not
17 USE_MA = true
18
19 CFLAGS = -Wall -g
20 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
21         CFLAGS += -O0
22 else
23         CFLAGS += -O2
24 endif
25
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.
28 #CC?=gcc-3.3
29 #export CC
30
31 # This is the debhelper compatibility version to use.
32 export DH_COMPAT=7
33
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
39
40 ARCH=$(shell dpkg --print-architecture)
41 TOP_DIR:=$(shell pwd)
42
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/-[^-]*$$//')
46
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
49 KVER?=$(LINUXRELEASE)
50
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
54 KVERS?=$(KVER)
55 KSRC?=$(LINUX_OBJ)
56 KSRC_TREE?=$(LINUX)
57 IB_OPTIONS?=""
58
59 # Packages
60 PATCH_PKG=linux-patch-lustre
61 UTILS_PKG=lustre-utils
62 TESTS_PKG=lustre-tests
63 DEV_PKG=lustre-dev
64 SOURCE_PKG=lustre-source
65 MODS_PKG=lustre-client-modules
66
67 #Build dir
68 #BUILDDIR=debian/build
69 #SRCDIR=../..
70 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
71 # autoconf macros
72 BUILDDIR=.
73 SRCDIR=.
74
75 AVAIL_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
76 ifneq ($(AVAIL_CPUS),1)
77       PMAKEARGS := -j $(AVAIL_CPUS)
78 endif
79
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
88         #  for an example)
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"; \
98                         exit 1; \
99                 fi; \
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; \
105         fi; \
106         touch $@
107
108 configure: configure-stamp
109 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
110         dh_testdir
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/; \
116                 cp lustre/contrib/mpich-*.patch $(BUILDDIR)/lustre/contrib/; \
117         fi
118         ( cd $(BUILDDIR) && \
119          $(SRCDIR)/configure --disable-dependency-tracking \
120                    --disable-modules \
121                    --disable-snmp \
122                    --disable-client \
123                    --enable-quota \
124                    --disable-server )
125         touch $@
126
127 build-arch build-indep: build
128
129 build: build-stamp
130 build-stamp: patch-stamp configure-stamp
131         dh_testdir
132         $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
133         $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
134         # jump our lustre-client-modules into the control file if not using m-a
135         if ! $(USE_MA); then \
136                 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
137                 for file in debian/*_KVERS_*; do \
138                         newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
139                         cp $$file $$newfile; \
140                 done; \
141         fi
142         touch $@
143
144 # let's try and operate as close as the user would and not build modules
145 # here (for now)
146 # instead we will build the modules with m-a in the "make debs" target
147 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
148 # binary-$(MODS_PKG) binary-kern-mods
149 binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG)
150
151 binary-indep: binary-$(PATCH_PKG) binary-$(SOURCE_PKG)
152
153 binary: binary-indep binary-arch
154
155 binary-$(PATCH_PKG): patch-stamp
156         dh_testdir
157         dh_testroot
158         dh_installdirs -p $(PATCH_PKG)
159         dh_installdocs -p $(PATCH_PKG)
160 #       dh_installkpatches -p $(PATCH_PKG)
161         dh_install -p $(PATCH_PKG)
162
163         # Install apply script
164         cp $(TOP_DIR)/debian/linux-patch-lustre.apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
165         chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/apply
166         set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
167           mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/; \
168           ln -s ../../../lustre/scripts/apply $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/apply/lustre; \
169         done
170
171         # Install unpatch script
172         cp $(TOP_DIR)/debian/linux-patch-lustre.unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
173         chmod a+x $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/scripts/unpatch
174         set -e; for KERNEL in $(SUPPORTED_KERNELS); do \
175           mkdir -p $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/; \
176           ln -s ../../../lustre/scripts/unpatch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/all/$$KERNEL/unpatch/lustre; \
177         done
178
179         # Install series
180         cp lustre/kernel_patches/series/*.series $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/series/
181
182         # Install patches
183         cp lustre/kernel_patches/patches/*.patch $(TOP_DIR)/debian/$(PATCH_PKG)/usr/src/kernel-patches/lustre/patches/
184
185         dh_installchangelogs -p $(PATCH_PKG) lustre/ChangeLog
186         dh_compress -p $(PATCH_PKG)
187         dh_installdeb -p $(PATCH_PKG)
188         dh_fixperms -p $(PATCH_PKG)
189         dh_gencontrol -p $(PATCH_PKG)
190         dh_md5sums -p $(PATCH_PKG)
191         dh_builddeb -p $(PATCH_PKG)
192
193 binary-$(UTILS_PKG): build-stamp
194         dh_testdir
195         dh_testroot
196         dh_installdirs -p $(UTILS_PKG)
197         dh_installdocs -p  $(UTILS_PKG)
198         dh_installman -p $(UTILS_PKG)
199         dh_install -p $(UTILS_PKG)
200         dh_makeshlibs -p $(UTILS_PKG)
201         dh_installexamples -p $(UTILS_PKG)
202         dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
203         dh_compress -p $(UTILS_PKG)
204         dh_strip -p $(UTILS_PKG)
205         dh_installdeb -p $(UTILS_PKG)
206         dh_fixperms -p $(UTILS_PKG)
207         dh_gencontrol -p $(UTILS_PKG)
208         dh_md5sums -p $(UTILS_PKG)
209         dh_builddeb -p $(UTILS_PKG)
210
211 binary-$(TESTS_PKG): build-stamp
212         dh_testdir
213         dh_testroot
214         dh_installdirs -p $(TESTS_PKG)
215         dh_installdocs -p  $(TESTS_PKG)
216         dh_installman -p $(TESTS_PKG)
217         dh_install -p $(TESTS_PKG)
218         dh_makeshlibs -p $(TESTS_PKG)
219         dh_installexamples -p $(TESTS_PKG)
220         dh_installchangelogs -p $(TESTS_PKG) lustre/ChangeLog
221         dh_compress -p $(TESTS_PKG)
222         dh_strip -p $(TESTS_PKG)
223         dh_installdeb -p $(TESTS_PKG)
224         dh_fixperms -p $(TESTS_PKG)
225         dh_gencontrol -p $(TESTS_PKG)
226         dh_md5sums -p $(TESTS_PKG)
227         dh_builddeb -p $(TESTS_PKG)
228
229 binary-$(DEV_PKG): build-stamp
230         dh_testdir
231         dh_testroot
232         dh_installdirs -p $(DEV_PKG)
233         dh_install -p $(DEV_PKG)
234         dh_installdocs -p $(DEV_PKG)
235         dh_installchangelogs -p $(DEV_PKG) lustre/ChangeLog
236         dh_compress -p $(DEV_PKG)
237         dh_installdeb -p $(DEV_PKG)
238         dh_fixperms -p $(DEV_PKG)
239         dh_gencontrol -p $(DEV_PKG)
240         dh_md5sums -p $(DEV_PKG)
241         dh_builddeb -p $(DEV_PKG)
242
243 binary-$(SOURCE_PKG): build-stamp
244         dh_testdir 
245         dh_testroot
246         # Copy everything 
247         dh_installdirs -p $(SOURCE_PKG) usr/src/modules/lustre/debian
248         rsync -av --exclude='debian/$(SOURCE_PKG)/*' \
249               --link-dest=$(PWD) \
250               . debian/$(SOURCE_PKG)/usr/src/modules/lustre
251         # Remove FULLCLEAN setting
252         rm debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
253         sed -e 's/FULLCLEAN=full-clean/FULLCLEAN=/' < debian/rules > debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
254         # clean up dest
255         rm -rf debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patched \
256                debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patches/* 
257         $(MAKE) -C debian/$(SOURCE_PKG)/usr/src/modules/lustre -f debian/rules clean
258         # Create the module-source tarball.
259         cd debian/$(SOURCE_PKG)/usr/src && tar jcf lustre.tar.bz2 modules 
260         rm -rf debian/$(SOURCE_PKG)/usr/src/modules
261         dh_install -p$(SOURCE_PKG)
262         dh_installchangelogs -p $(SOURCE_PKG) lustre/ChangeLog
263         dh_installdocs -p $(SOURCE_PKG) 
264         dh_link -p $(SOURCE_PKG) /usr/share/modass/packages/default.sh /usr/share/modass/overrides/lustre-source
265         dh_compress -p $(SOURCE_PKG)
266         dh_installdeb -p $(SOURCE_PKG)
267         dh_fixperms -p $(SOURCE_PKG)
268         dh_gencontrol -p $(SOURCE_PKG)
269         dh_md5sums -p $(SOURCE_PKG)
270         dh_builddeb -p $(SOURCE_PKG)
271
272 # if only we could use m-a for this, but this stupid "compliant.list"
273 # thing fouls that up
274 binary-kern-mods:
275         mkdir -p debian/m-a_root/usr_src/modules
276         ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
277         m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
278         mv -f debian/m-a_root/*.deb ..
279
280 # an alternative (to module-assistant) method of building the kernel modules
281 binary-$(MODS_PKG): build-stamp
282         if ! $(USE_MA); then \
283                 cp debian/lustre-client-modules.install debian/lustre-client-modules-$(KVER).install ; \
284                 dh_testdir; \
285                 dh_testroot; \
286                 dh_installdirs -p $(MODS_PKG)-$(KVER); \
287                 dh_installdocs -p $(MODS_PKG)-$(KVER); \
288                 dh_install -p $(MODS_PKG)-$(KVER); \
289                 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
290                 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
291                 dh_compress -p $(MODS_PKG)-$(KVER); \
292                 dh_installdeb -p $(MODS_PKG)-$(KVER); \
293                 dh_strip -p $(MODS_PKG)-$(KVER); \
294                 dh_fixperms -p $(MODS_PKG)-$(KVER); \
295                 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
296                 dh_md5sums -p $(MODS_PKG)-$(KVER); \
297                 dh_builddeb -p $(MODS_PKG)-$(KVER); \
298         fi
299
300 ###
301 ### For module-assistant
302 ###
303
304 # the kdist_clean target is called by make-kpkg modules_clean and from
305 # kdist* rules. It is responsible for cleaning up any changes that have
306 # been made by the other kdist_commands (except for the .deb files created)
307
308 kdist_clean: 
309         # can't dh_clean here or we remove the build artifacts for the other packages
310         # still in progress
311         #dh_clean
312         #-$(MAKE) $(MFLAGS) -f debian/rules clean
313         # put the userspace tools' control file back
314         cp debian/control.main debian/control
315
316
317 # module assistant calculates all needed things for us and sets
318 # # following variables:
319 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
320 # # (revision of the Debian kernel-image package), CC (the correct
321 # # compiler), VERSION (the final package version string), PKGNAME (full
322 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
323 #
324 # # The kdist_configure target is called by make-kpkg modules_config and
325 # # by kdist* rules by dependency. It should configure the module so it is
326 # # ready for compilation (mostly useful for calling configure).
327 # # prep-deb-files from module-assistant creates the neccessary debian/ 
328 kdist_config: prep-deb-files patch-stamp
329         #  Check build dependencies again, needs to be done since we just
330         # replaced the control file.
331         dpkg-checkbuilddeps
332         # Prepare the kernel to lustres' liking
333         # as non-root, we won't have permission for this
334         #-$(MAKE) -C $(KSRC) prepare scripts
335         # touch files to same date, to avoid auto*
336         find . -type f -print0 | xargs -0 touch -r COPYING \;
337         # Doesn't seem possible to only build modules...
338         ./configure --with-linux=$(KSRC_TREE) \
339                     --with-linux-obj=$(KSRC) \
340                     --disable-server \
341                     --disable-quilt  \
342                     --disable-dependency-tracking \
343                     --disable-doc  \
344                     --disable-utils \
345                     --disable-iokit \
346                     --disable-snmp \
347                     --disable-tests \
348                     --enable-quota \
349                     $(IB_OPTIONS)
350
351 kdist_configure: kdist_config
352
353 # the binary-modules rule is invoked by module-assistant while processing the
354 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
355 # during a normal build
356 binary-modules: prep-deb-files
357         dh_testroot
358         dh_prep
359         $(MAKE) $(PMAKEARGS)
360         $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
361         # Remove stuff that doesn't belong (no module-only target)
362         cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr sbin etc
363         dh_installdocs -p$(PKGNAME)
364         dh_installchangelogs -p$(PKGNAME)
365         dh_installmodules -p $(PKGNAME)
366         dh_compress -p $(PKGNAME)
367         dh_fixperms -p $(PKGNAME)
368         dh_installdeb -p $(PKGNAME)
369         dh_gencontrol -- -v$(VERSION)
370         dh_md5sums -p $(PKGNAME)
371         dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
372         dh_prep -p $(PKGNAME)
373
374 clean:
375         dh_testdir
376         dh_testroot
377         dpatch deapply-all -v
378         -$(MAKE) distclean
379         rm -rf  debian/substvars debian/*.bak debian/*~ *~  *-stamp debian/$(PATCH_PKG)
380         ls -d debian/lustre-client-modules-* | grep -v _KVERS_ | xargs rm -f || true
381         # only remove this if the clean was not called from kdist_clean
382         if [ "$$MA_SOURCE_PKG" = "" ]; then \
383                 rm -rf  debian/m-a_root; \
384         fi
385         dh_clean
386         # make sure we have at least a basic control in place (see build-stamp)
387         rm -f debian/control
388         cp debian/control.main debian/control
389
390 patch: patch-stamp
391 patch-stamp:
392         dpatch apply-all -v
393         touch $@
394
395 unpatch:
396         dpatch deapply-all -v
397         rm -rf debian/patched patch-stamp
398
399 .PHONY: binary-arch clean source diff  binary binary-indep binary-arch install configure