Whamcloud - gitweb
LU-17662 osd-zfs: Support for ZFS 2.2.3
[fs/lustre-release.git] / debian / rules
1 #!/usr/bin/make -f
2 # SPDX-License-Identifier: NOASSERTION
3
4 #
5 # This file is part of Lustre, http://www.lustre.org/
6 #
7 # debian/rules
8 #
9 # Debian rules file
10 #
11 # Copying and modification is unlimited, provided that the modified
12 # version is marked as being modified.
13 # (This version has been modified from the original)
14 #
15 # Created 2009 by Brian J. Murrell based on work by
16 # Alastair McKinstry, <alastair.mckinstry@ichec.ie>, <mckinstry@debian.org>
17 # Patrick Winnertz, and the pkg-lustre Debian maintainers
18 #
19
20 # Uncomment this to turn on verbose mode.
21 # export DH_VERBOSE=1
22
23 DEB_BUILD_GNU_SYSTEM = $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
24 DEB_BUILD_GNU_CPU = $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
25
26
27 # whether to use module-assistant to build the kernel modules or not
28 USE_MA = true
29
30 # Whether to build the DKMS packages
31 BUILD_DKMS ?= false
32
33 ifeq ($(BUILD_DKMS),true)
34         DKMS_TARGET = binary-$(DKMS_PKG)
35 else
36         DKMS_TARGET =
37 endif
38
39 CFLAGS = -Wall -g
40 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
41         CFLAGS += -O0
42 else
43         CFLAGS += -O2
44 endif
45
46 # This is the debhelper compatibility version to use.
47 export DH_COMPAT=11
48
49 # Module-assistant stuff
50 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
51         PACKAGE=lustre-server-modules
52 else
53         PACKAGE=lustre-client-modules
54 endif
55 MA_DIR ?= /usr/share/modass
56 -include $(MA_DIR)/include/generic.make
57 -include $(MA_DIR)/include/common-rules.make
58
59 ARCH=$(shell dpkg --print-architecture)
60 TOP_DIR:=$(shell pwd)
61
62 # This is the Lustre version
63 VERSION=$(shell sed -n -e '1s/.*(\(.*\)) .*/\1/p' debian/changelog)
64 UPVERSION=$(shell echo $(VERSION) | sed -e 's/-[^-]*$$//')
65
66 # KVER is set to LINUXRELEASE being by autoconf which is either
67 # $(uname -r) or the version of the source specified by the user
68 KVER?=$(LINUXRELEASE)
69
70 # KVERS, KSRC are the kernel version and source to use when building lustre
71 # Will be the default when building lustre-{server,client}-utils, etc but whatever module-assistant
72 # supplied when building modules
73 KVERS?=$(KVER)
74 KSRC?=$(LINUX_OBJ)
75 KSRC_TREE?=$(LINUX)
76 EXTRA_OPTIONS?=$(IB_OPTIONS)
77
78 ifneq ($(SYSTEMD_OPTIONS),)
79         EXTRA_OPTIONS += $(SYSTEMD_OPTIONS)
80 endif
81
82 # Packages provided for both client and server builds
83 IOKIT_PKG=lustre-iokit
84 TESTS_PKG=lustre-tests
85 DEV_PKG=lustre-dev
86 SOURCE_PKG=lustre-source
87
88 # Packages that are only built for server OR client builds
89 # The difference is that server build contain more modules & utils
90 ifneq (,$(findstring server,$(DEB_BUILD_PROFILES)))
91         UTILS_PKG=lustre-server-utils
92         MODS_PKG=lustre-server-modules
93         RESOURCE_PKG=lustre-resource-agents
94         RESOURCE_TARGET=binary-$(RESOURCE_PKG)
95         DKMS_PKG=
96 else
97         UTILS_PKG=lustre-client-utils
98         MODS_PKG=lustre-client-modules
99         RESOURCE_TARGET=
100         RESOURCE_PKG=
101         DKMS_PKG=lustre-client-modules-dkms
102 endif
103
104 #Build dir
105 #BUILDDIR=debian/build
106 #SRCDIR=../..
107 # I'm afraid we seem to have broken the BUILDDIR concept in Lustre's
108 # autoconf macros
109 BUILDDIR=.
110 SRCDIR=.
111
112 AVAIL_CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
113 ifneq ($(AVAIL_CPUS),1)
114       PMAKEARGS := -j $(AVAIL_CPUS)
115 endif
116
117 autogen: autogen-stamp
118 autogen-stamp: patch-stamp
119         # see if any patches requires us to run autogen
120         # (for a distribution release tarball, it is expected that if
121         #  downstream adds any patches that requires autogen.sh to be
122         #  run, a patch will be added by downstream to install the
123         #  needed autogen.sh scripts
124         #  see https://bugzilla.lustre.org/attachment.cgi?id=27156
125         #  for an example)
126         if grep -e "^--- .*\/autoconf\/" \
127                 -e "^--- .*\/autoMakefile\.am" \
128                 -e "^--- .*\/Makefile\.am" \
129                 -e "^--- .*\/configure\.ac" \
130                 -e "^--- .*\/configure\.in" \
131             debian/patches/*; then \
132                 if [ ! -f build/autogen.sh ]; then \
133                         echo "You have patches which require autogen.sh to be run, but it doesn't exist"; \
134                         echo "Please see https://bugzilla.lustre.org/attachment.cgi?id=27156"; \
135                         exit 1; \
136                 fi; \
137                 cp /usr/share/misc/config.sub config.sub; \
138                 cp /usr/share/misc/config.sub ldiskfs/config.sub; \
139                 cp /usr/share/misc/config.guess config.guess; \
140                 cp /usr/share/misc/config.guess ldiskfs/config.guess; \
141                 bash build/autogen.sh; \
142         fi; \
143         touch $@
144
145 # This section configures the lustre-utilities packages.
146 #
147 # Both client and server builds are quite similar, as the utilities build
148 # must create the modules too, to produce the "osd_<fstype>.so" libraries.
149 #
150 # The main difference is that the utilities build does not archive the
151 # modules, whereas the modules build omits the utilities, to create two
152 # neatly separated debian files.
153 #
154 # Note: KERNEL_SRC, KERNEL_OBJ, ZFS_SRC and SPL_SRC need to be set from the
155 # outside. This is done by "make debs". As such, invoking "debuild" or such
156 # direct debian build tools will lead to a client-only build.
157 configure: configure-stamp
158 configure-stamp: autogen-stamp debian/control.main debian/control.modules.in
159         dh_testdir
160         # touch files to same date, to avoid auto*
161         find . -type f -print0 | xargs -0 touch -r COPYING; \
162         if [ "$(BUILDDIR)" != "." ]; then \
163                 mkdir -p $(BUILDDIR)/build $(BUILDDIR)/lustre/contrib; \
164                 cp build/Makefile $(BUILDDIR)/build/; \
165         fi
166         # Determine flags that are different between server/client module builds
167         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
168         if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
169                 export EXTRAFLAGS="--enable-server"; \
170                 if echo "$${DEB_BUILD_PROFILES}" | grep -q "systemd"; then \
171                         systemd_dir=$$(echo $${SYSTEMD_OPTIONS} | \
172                                        sed -e "s/--with-systemdsystemunitdir=\///g" \
173                                            -e "s/\//\\\\\//g"); \
174                         sed "s/lib\/systemd\/system/$${systemd_dir}/g" \
175                                 debian/lustre-server-utils.install.in \
176                                 > debian/lustre-server-utils.install; \
177                 else \
178                         sed /systemd/d debian/lustre-server-utils.install.in \
179                                 > debian/lustre-server-utils.install; \
180                 fi; \
181         else \
182                 export EXTRAFLAGS="--disable-server"; \
183                 if echo "$${DEB_BUILD_PROFILES}" | grep -q "systemd"; then \
184                         systemd_dir=$$(echo $${SYSTEMD_OPTIONS} | \
185                                        sed -e "s/--with-systemdsystemunitdir=\///g" \
186                                            -e "s/\//\\\\\//g"); \
187                         sed "s/lib\/systemd\/system/$${systemd_dir}/g" \
188                                 debian/lustre-client-utils.install.in \
189                                 > debian/lustre-client-utils.install; \
190                 else \
191                         sed /systemd/d debian/lustre-client-utils.install.in \
192                                 > debian/lustre-client-utils.install; \
193                 fi; \
194         fi; \
195         if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
196                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
197         else \
198                 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
199         fi; \
200         if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
201                 export EXTRAFLAGS="$${EXTRAFLAGS} \
202                         --enable-ldiskfs --enable-quilt"; \
203         else \
204                 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-ldiskfs"; \
205         fi; \
206         if echo "$${DEB_BUILD_PROFILES}" | grep -q "multiple-lnds"; then \
207                 export EXTRAFLAGS="$${EXTRAFLAGS} --enable-multiple-lnds"; \
208         fi; \
209         if echo "$${DEB_BUILD_PROFILES}" | grep -q "ext_o2ib"; then \
210                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=$${O2IB_SRC}"; \
211         elif echo "$${DEB_BUILD_PROFILES}" | grep -q "int_o2ib"; then \
212                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=yes"; \
213         else \
214                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=no"; \
215         fi; \
216         if echo "$${DEB_BUILD_PROFILES}" | grep -q "gnilnd"; then \
217                 export EXTRAFLAGS="$${EXTRAFLAGS} --enable-gni"; \
218         fi; \
219         if echo "$${DEB_BUILD_PROFILES}" | grep -q "kfilnd"; then \
220                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-kfi=/usr/src/kfabric"; \
221         fi; \
222         options="gss crypto pinger checksum flock lru-resize"; \
223         options="$${options} mindf fail-alloc invariants lu_ref pgstate-track"; \
224         options="$${options} libcfs-cdebug libcfs-trace libcfs-assert"; \
225         options="$${options} panic_dumplog readline libpthread"; \
226         options="$${options} backoff gni efence"; \
227         for option in $${options}; do \
228                 if echo "$${DEB_BUILD_PROFILES}" | grep -qw "$${option}"; then \
229                         export EXTRAFLAGS="$${EXTRAFLAGS} --enable-$${option}"; \
230                 elif echo "$${DEB_BUILD_PROFILES}" | grep -qw "no$${option}"; then \
231                         export EXTRAFLAGS="$${EXTRAFLAGS} --disable-$${option}"; \
232                 fi; \
233         done; \
234         if [ -f "$${CONFIG_CACHE_FILE}" ]; then \
235                 export TMP_CACHE_FILE=$$(mktemp); \
236                 sed -e "/ac_cv_env/d" \
237                     -e "/am_cv_CC_dependencies_compiler_type/d" \
238                     -e "/lb_cv_mpi_tests/d" \
239                        "$${CONFIG_CACHE_FILE}" > $${TMP_CACHE_FILE}; \
240                 export EXTRAFLAGS="$${EXTRAFLAGS} --cache-file=$${TMP_CACHE_FILE}"; \
241         fi; \
242         echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
243         ( cd $(BUILDDIR) && \
244                 $(SRCDIR)/configure --disable-dependency-tracking \
245                         --with-linux=$${KERNEL_SRC} \
246                         --with-linux-obj=$${KERNEL_OBJ} \
247                         --enable-quota \
248                         $${EXTRAFLAGS} \
249                         $(EXTRA_OPTIONS) \
250         ); \
251         touch $@
252
253 build-arch build-indep: build
254
255 build: build-stamp
256 build-stamp: patch-stamp configure-stamp
257         dh_testdir
258         $(MAKE) -C $(BUILDDIR) $(PMAKEARGS)
259         $(MAKE) -C $(BUILDDIR) DESTDIR=$(TOP_DIR)/debian/tmp install
260         # jump our lustre-[client|server]-modules into the control file if not using m-a
261         if ! $(USE_MA); then \
262                 (cat debian/control.main; sed -e '1,/^$$/d' -e "s/_KVERS_/$(KVER)/g" < debian/control.modules.in) > debian/control; \
263                 for file in debian/*_KVERS_*; do \
264                         newfile=$$(echo $$file | sed -e "s/_KVERS_/$(KVER)/g"); \
265                         cp $$file $$newfile; \
266                 done; \
267         fi
268         touch $@
269
270 # let's try and operate as close as the user would and not build modules
271 # here (for now)
272 # instead we will build the modules with m-a in the "make debs" target
273 # binary-arch: binary-$(UTILS_PKG) binary-$(TESTS_PKG) binary-$(DEV_PKG) \
274 # binary-$(MODS_PKG) binary-kern-mods
275 binary-arch: binary-$(UTILS_PKG) binary-$(DEV_PKG) \
276              binary-$(IOKIT_PKG) binary-$(TESTS_PKG) \
277              $(RESOURCE_TARGET)
278
279 binary-indep: binary-$(SOURCE_PKG) $(DKMS_TARGET)
280
281 binary: binary-indep binary-arch
282
283 binary-$(UTILS_PKG): build-stamp
284         dh_testdir
285         dh_testroot
286         dh_installdirs -p $(UTILS_PKG)
287         dh_installdocs -p  $(UTILS_PKG)
288         dh_installman -p $(UTILS_PKG)
289         dh_install -p $(UTILS_PKG)
290         rm -rf debian/$(UTILS_PKG)/usr/bin/iokit-* \
291                debian/$(UTILS_PKG)/usr/bin/*-survey \
292                debian/$(UTILS_PKG)/usr/bin/mcreate \
293                debian/$(UTILS_PKG)/usr/bin/statx \
294                debian/$(UTILS_PKG)/usr/sbin/wirecheck \
295                debian/$(UTILS_PKG)/usr/sbin/wiretest
296         dh_makeshlibs -p $(UTILS_PKG)
297         dh_installexamples -p $(UTILS_PKG)
298         dh_installchangelogs -p $(UTILS_PKG) lustre/ChangeLog
299         dh_compress -p $(UTILS_PKG)
300         dh_strip -p $(UTILS_PKG)
301         dh_installdeb -p $(UTILS_PKG)
302         dh_fixperms -p $(UTILS_PKG)
303         dh_gencontrol -p $(UTILS_PKG)
304         dh_md5sums -p $(UTILS_PKG)
305         dh_builddeb -p $(UTILS_PKG)
306
307 binary-$(RESOURCE_PKG): build-stamp
308         dh_testdir
309         dh_testroot
310         dh_installdirs -p $(RESOURCE_PKG)
311         dh_installdocs -p  $(RESOURCE_PKG)
312         dh_installman -p $(RESOURCE_PKG)
313         dh_install -p $(RESOURCE_PKG)
314         dh_makeshlibs -p $(RESOURCE_PKG)
315         dh_installexamples -p $(RESOURCE_PKG)
316         dh_installchangelogs -p $(RESOURCE_PKG) lustre/ChangeLog
317         dh_compress -p $(RESOURCE_PKG)
318         dh_strip -p $(RESOURCE_PKG)
319         dh_installdeb -p $(RESOURCE_PKG)
320         dh_fixperms -p $(RESOURCE_PKG)
321         dh_gencontrol -p $(RESOURCE_PKG)
322         dh_md5sums -p $(RESOURCE_PKG)
323         dh_builddeb -p $(RESOURCE_PKG)
324
325 binary-$(IOKIT_PKG): build-stamp
326         dh_testdir
327         dh_testroot
328         dh_installdirs -p $(IOKIT_PKG)
329         dh_installdocs -p  $(IOKIT_PKG)
330         dh_installman -p $(IOKIT_PKG)
331         dh_install -p $(IOKIT_PKG)
332         rm -rf debian/$(IOKIT_PKG)/usr/bin/lustre_req_history \
333                debian/$(IOKIT_PKG)/usr/bin/*ll*stat \
334                debian/$(IOKIT_PKG)/usr/bin/lfs-*
335         dh_makeshlibs -p $(IOKIT_PKG)
336         dh_installexamples -p $(IOKIT_PKG)
337         dh_installchangelogs -p $(IOKIT_PKG) lustre/ChangeLog
338         dh_compress -p $(IOKIT_PKG)
339         dh_strip -p $(IOKIT_PKG)
340         dh_installdeb -p $(IOKIT_PKG)
341         dh_fixperms -p $(IOKIT_PKG)
342         dh_gencontrol -p $(IOKIT_PKG)
343         dh_md5sums -p $(IOKIT_PKG)
344         dh_builddeb -p $(IOKIT_PKG)
345
346 binary-$(TESTS_PKG): build-stamp
347         dh_testdir
348         dh_testroot
349         dh_installdirs -p $(TESTS_PKG)
350         dh_installdocs -p  $(TESTS_PKG)
351         dh_installman -p $(TESTS_PKG)
352         dh_install -p $(TESTS_PKG)
353         dh_makeshlibs -p $(TESTS_PKG)
354         dh_installexamples -p $(TESTS_PKG)
355         dh_installchangelogs -p $(TESTS_PKG) lustre/ChangeLog
356         dh_compress -p $(TESTS_PKG)
357         dh_strip -p $(TESTS_PKG)
358         dh_installdeb -p $(TESTS_PKG)
359         dh_fixperms -p $(TESTS_PKG)
360         dh_gencontrol -p $(TESTS_PKG)
361         dh_md5sums -p $(TESTS_PKG)
362         dh_builddeb -p $(TESTS_PKG)
363
364 binary-$(DEV_PKG): build-stamp
365         dh_testdir
366         dh_testroot
367         dh_installdirs -p $(DEV_PKG)
368         dh_install -p $(DEV_PKG)
369         dh_installdocs -p $(DEV_PKG)
370         dh_installchangelogs -p $(DEV_PKG) lustre/ChangeLog
371         dh_compress -p $(DEV_PKG)
372         dh_installdeb -p $(DEV_PKG)
373         dh_fixperms -p $(DEV_PKG)
374         dh_gencontrol -p $(DEV_PKG)
375         dh_md5sums -p $(DEV_PKG)
376         dh_builddeb -p $(DEV_PKG)
377
378 binary-$(SOURCE_PKG): build-stamp
379         dh_testdir 
380         dh_testroot
381         # Copy everything 
382         dh_installdirs -p $(SOURCE_PKG) usr/src/modules/lustre/debian
383         rsync -av --exclude='debian/$(SOURCE_PKG)/*' \
384               --link-dest=$(PWD) \
385               . debian/$(SOURCE_PKG)/usr/src/modules/lustre
386         # Remove FULLCLEAN setting
387         rm debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
388         cp -v debian/rules debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
389         sed -i -e 's/FULLCLEAN=full-clean/FULLCLEAN=/' debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/rules
390         # clean up dest
391         rm -rf debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patched \
392                debian/$(SOURCE_PKG)/usr/src/modules/lustre/debian/patches/* 
393         $(MAKE) -C debian/$(SOURCE_PKG)/usr/src/modules/lustre -f debian/rules clean
394         # Create the module-source tarball.
395         cd debian/$(SOURCE_PKG)/usr/src && tar --exclude-vcs -jcf lustre-$${SRC_GIT_HASH}.tar.bz2 modules
396         rm -rf debian/$(SOURCE_PKG)/usr/src/modules
397         dh_install -p$(SOURCE_PKG)
398         dh_installchangelogs -p $(SOURCE_PKG) lustre/ChangeLog
399         dh_installdocs -p $(SOURCE_PKG) 
400         dh_link -p $(SOURCE_PKG) /usr/share/modass/packages/default.sh /usr/share/modass/overrides/lustre-source
401         dh_compress -p $(SOURCE_PKG)
402         dh_installdeb -p $(SOURCE_PKG)
403         dh_fixperms -p $(SOURCE_PKG)
404         dh_gencontrol -p $(SOURCE_PKG)
405         dh_md5sums -p $(SOURCE_PKG)
406         dh_builddeb -p $(SOURCE_PKG)
407
408 binary-$(DKMS_PKG): build-stamp
409         dh_testdir
410         dh_testroot
411         # Create /usr/src/lustre-client-modules-<version>
412         dh_installdirs -p $(DKMS_PKG) usr/src/lustre-client-modules-$(UPVERSION)
413         # Copy the source
414         rsync -av --exclude='debian/$(DKMS_PKG)/*' --exclude='.git/' \
415                 --link-dest=$(PWD) \
416                 . debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)
417         # Clean it up
418         $(MAKE) -C debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION) -f debian/rules clean
419
420         # Put the DKMS configuration file in place
421         sed -e 's/[@]UPVERSION[@]/$(UPVERSION)/' debian/dkms.conf.in > debian/$(DKMS_PKG)/usr/src/lustre-client-modules-$(UPVERSION)/dkms.conf
422         dh_install -p $(DKMS_PKG)
423         dh_installchangelogs -p $(DKMS_PKG) lustre/ChangeLog
424         dh_installdocs -p $(DKMS_PKG)
425         dh_compress -p $(DKMS_PKG)
426         dh_installdeb -p $(DKMS_PKG)
427         dh_strip -p $(DKMS_PKG)
428         dh_fixperms -p $(DKMS_PKG)
429         dh_gencontrol -p $(DKMS_PKG)
430         dh_md5sums -p $(DKMS_PKG)
431         dh_builddeb -p $(DKMS_PKG)
432
433 # if only we could use m-a for this, but this stupid "compliant.list"
434 # thing fouls that up
435 binary-kern-mods:
436         # Build client or server modules
437         mkdir -p debian/m-a_root/usr_src/modules
438         ln -s ../../../../ debian/m-a_root/usr_src/modules/lustre
439         m-a -t -u debian/m-a_root/ -d -v -k $(KSRC) build lustre
440         mv -f debian/m-a_root/*.deb ..
441
442 # an alternative (to module-assistant) method of building the kernel modules
443 binary-$(MODS_PKG): build-stamp
444         if ! $(USE_MA); then \
445                 cp debian/$(MODS_PKG).install debian/$(MODS_PKG)-$(KVER).install ; \
446                 dh_testdir; \
447                 dh_testroot; \
448                 dh_installdirs -p $(MODS_PKG)-$(KVER); \
449                 dh_installdocs -p $(MODS_PKG)-$(KVER); \
450                 dh_install -p $(MODS_PKG)-$(KVER); \
451                 dh_makeshlibs -p $(MODS_PKG)-$(KVER); \
452                 dh_installchangelogs -p $(MODS_PKG)-$(KVER) lustre/ChangeLog; \
453                 dh_compress -p $(MODS_PKG)-$(KVER); \
454                 dh_installdeb -p $(MODS_PKG)-$(KVER); \
455                 dh_strip -p $(MODS_PKG)-$(KVER); \
456                 dh_fixperms -p $(MODS_PKG)-$(KVER); \
457                 dh_gencontrol -p $(MODS_PKG)-$(KVER); \
458                 dh_md5sums -p $(MODS_PKG)-$(KVER); \
459                 dh_builddeb -p $(MODS_PKG)-$(KVER); \
460         fi
461
462
463 ###
464 ### For module-assistant
465 ###
466
467 # the kdist_clean target is called by make-kpkg modules_clean and from
468 # kdist* rules. It is responsible for cleaning up any changes that have
469 # been made by the other kdist_commands (except for the .deb files created)
470
471 kdist_clean: 
472         # can't dh_clean here or we remove the build artifacts for the other packages
473         # still in progress
474         #dh_clean
475         #-$(MAKE) $(MFLAGS) -f debian/rules clean
476         # put the userspace tools' control file back
477         cp debian/control.main debian/control
478
479
480 # module assistant calculates all needed things for us and sets
481 # # following variables:
482 # # KSRC (kernel source directory), KVERS (kernel version string), KDREV
483 # # (revision of the Debian kernel-image package), CC (the correct
484 # # compiler), VERSION (the final package version string), PKGNAME (full
485 # # package name with KVERS included), DEB_DESTDIR (path to store DEBs)
486 #
487 # # The kdist_configure target is called by make-kpkg modules_config and
488 # # by kdist* rules by dependency. It should configure the module so it is
489 # # ready for compilation (mostly useful for calling configure).
490 # # prep-deb-files from module-assistant creates the neccessary debian/ 
491 kdist_config: prep-deb-files patch-stamp
492         #  Check build dependencies again, needs to be done since we just
493         # replaced the control file.
494         dpkg-checkbuilddeps
495         # Prepare the kernel to lustres' liking
496         # as non-root, we won't have permission for this
497         #-$(MAKE) -C $(KSRC) prepare scripts
498         # touch files to same date, to avoid auto*
499         find . -type f -print0 | xargs -0 touch -r COPYING \;
500         # Determine flags that are different between server/client module builds
501         # Note: It doesn't seem possible to *only* build modules.
502         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"
503         if echo "$${DEB_BUILD_PROFILES}" | grep -q "server"; then \
504                 export EXTRAFLAGS="--enable-server"; \
505         else \
506                 export EXTRAFLAGS="--disable-server"; \
507         fi; \
508         if echo "$${DEB_BUILD_PROFILES}" | grep -q "zfs"; then \
509                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-zfs=$${ZFS_SRC} --with-spl=$${SPL_SRC}"; \
510         else \
511                 export EXTRAFLAGS="$${EXTRAFLAGS} --without-zfs" ; \
512         fi; \
513         if echo "$${DEB_BUILD_PROFILES}" | grep -q "ldiskfs"; then \
514                 export EXTRAFLAGS="$${EXTRAFLAGS} \
515                         --enable-ldiskfs --enable-quilt"; \
516         else \
517                 export EXTRAFLAGS="$${EXTRAFLAGS} \
518                         --disable-ldiskfs --disable-quilt"; \
519         fi; \
520         if echo "$${DEB_BUILD_PROFILES}" | grep -q "multiple-lnds"; then \
521                 export EXTRAFLAGS="$${EXTRAFLAGS} --enable-multiple-lnds"; \
522         fi; \
523         if echo "$${DEB_BUILD_PROFILES}" | grep -q "ext_o2ib"; then \
524                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=$${O2IB_SRC}"; \
525         elif echo "$${DEB_BUILD_PROFILES}" | grep -q "int_o2ib"; then \
526                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=yes"; \
527         else \
528                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-o2ib=no"; \
529         fi; \
530         if echo "$${DEB_BUILD_PROFILES}" | grep -q "gnilnd"; then \
531                 export EXTRAFLAGS="$${EXTRAFLAGS} --enable-gni"; \
532         fi; \
533         if echo "$${DEB_BUILD_PROFILES}" | grep -q "kfilnd"; then \
534                 export EXTRAFLAGS="$${EXTRAFLAGS} --with-kfi=/usr/src/kfabric"; \
535         fi; \
536         options="gss crypto pinger checksum flock lru-resize"; \
537         options="$${options} mindf fail-alloc invariants lu_ref pgstate-track"; \
538         options="$${options} libcfs-cdebug libcfs-trace libcfs-assert"; \
539         options="$${options} panic_dumplog readline libpthread"; \
540         options="$${options} backoff gni efence"; \
541         for option in $${options}; do \
542                 if echo "$${DEB_BUILD_PROFILES}" | grep -qw "$${option}"; then \
543                         export EXTRAFLAGS="$${EXTRAFLAGS} --enable-$${option}"; \
544                 elif echo "$${DEB_BUILD_PROFILES}" | grep -qw "no$${option}"; then \
545                         export EXTRAFLAGS="$${EXTRAFLAGS} --disable-$${option}"; \
546                 fi; \
547         done; \
548         if echo "$${DEB_BUILD_PROFILES}" | grep -q "notests"; then \
549                 export EXTRAFLAGS="$${EXTRAFLAGS} --disable-tests"; \
550         fi; \
551         if [ -f "$${CONFIG_CACHE_FILE}" ]; then \
552                 export TMP_CACHE_FILE=$$(mktemp --tmpdir newconfig-XXXXXXXX.cache); \
553                 sed -e "/ac_cv_env/d" \
554                     -e "/am_cv_CC_dependencies_compiler_type/d" \
555                     -e "/lb_cv_mpi_tests/d" \
556                        "$${CONFIG_CACHE_FILE}" > $${TMP_CACHE_FILE}; \
557                 export EXTRAFLAGS="$${EXTRAFLAGS} --cache-file=$${TMP_CACHE_FILE}"; \
558         fi; \
559         echo "Final value of EXTRAFLAGS: $${EXTRAFLAGS}"; \
560         ./configure --with-linux=$(KSRC_TREE) \
561                 --with-linux-obj=$(KSRC) \
562                 --disable-dependency-tracking \
563                 --disable-doc  \
564                 --disable-iokit \
565                 --enable-quota \
566                 --with-kmp-moddir=updates/kernel \
567                 $${EXTRAFLAGS} \
568                 $(EXTRA_OPTIONS)
569
570
571 kdist_configure: kdist_config
572
573 # the binary-modules rule is invoked by module-assistant while processing the
574 # kdist* targets. It is called by module-assistant or make-kpkg and *not*
575 # during a normal build
576 binary-modules: prep-deb-files
577         dh_testroot
578         dh_prep
579         $(MAKE) $(PMAKEARGS)
580         $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKGNAME)
581         # Remove stuff that doesn't belong (no module-only target)
582         cd $(CURDIR)/debian/$(PKGNAME) && rm -rf usr/bin usr/sbin usr/lib usr/share usr/include/lustre lib/systemd sbin etc
583         dh_installdocs -p$(PKGNAME)
584         dh_installchangelogs -p$(PKGNAME)
585         dh_installmodules -p $(PKGNAME)
586         dh_compress -p $(PKGNAME)
587         dh_fixperms -p $(PKGNAME)
588         sed "s/depmod -a/depmod -a $(KVERS)/" $(CURDIR)/debian/postinst > $(CURDIR)/debian/$(PKGNAME).postinst
589         sed "s/depmod -a/depmod -a $(KVERS)/" $(CURDIR)/debian/postrm > $(CURDIR)/debian/$(PKGNAME).postrm
590         chmod +x $(CURDIR)/debian/$(PKGNAME).postinst $(CURDIR)/debian/$(PKGNAME).postrm
591         dh_installdeb -p $(PKGNAME)
592         dh_gencontrol -- -v$(VERSION)
593         dh_md5sums -p $(PKGNAME)
594         dh_builddeb --destdir=$(DEB_DESTDIR) -p $(PKGNAME)
595         dh_prep -p $(PKGNAME)
596
597 clean:
598         dh_testdir
599         dh_testroot
600         dpatch deapply-all -v
601         -$(MAKE) distclean
602         rm -rf  debian/substvars debian/*.bak debian/*~ *~  *-stamp
603         ls -d debian/lustre-*-modules-* | grep -v _KVERS_ | grep -v dkms | xargs rm -f || true
604         # only remove this if the clean was not called from kdist_clean
605         if [ "$$MA_SOURCE_PKG" = "" ]; then \
606                 rm -rf  debian/m-a_root; \
607         fi
608         dh_clean
609         # make sure we have at least a basic control in place (see build-stamp)
610         rm -f debian/control
611         cp debian/control.main debian/control
612
613 patch: patch-stamp
614 patch-stamp:
615         dpatch apply-all -v
616         touch $@
617
618 unpatch:
619         dpatch deapply-all -v
620         rm -rf debian/patched patch-stamp
621
622 .PHONY: binary-arch clean source diff  binary binary-indep binary-arch install configure