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