Whamcloud - gitweb
LU-6142 mgc: SPDX for management client
[fs/lustre-release.git] / autoMakefile.am
1 # SPDX-License-Identifier: GPL-2.0
2
3 #
4 # This file is part of Lustre, http://www.lustre.org/
5 #
6 # autoMakefile.am
7 #
8 # Used by automake to create the top-level autoMakefile.in,
9 # which is used by config.status to create the top-level
10 # autoMakefile
11 #
12
13 SUBDIRS := @LDISKFS_SUBDIR@ \
14         . \
15         @LUSTREIOKIT_SUBDIR@ \
16         libcfs \
17         lnet \
18         lustre
19
20 DIST_SUBDIRS := ldiskfs \
21         lustre-iokit \
22         libcfs \
23         lnet \
24         lustre \
25         cc-plugins \
26         config
27
28 AUTOMAKE_OPTIONS = foreign
29
30 if DEQUOTE_CC_VERSION_TEXT
31 DEQUOTE = yes
32 endif
33
34 if MPITESTS
35 ENABLE_MPITESTS = yes
36 else
37 ENABLE_MPITESTS = no
38 endif
39
40 if TESTS
41 ENABLE_TESTS = yes
42 else
43 ENABLE_TESTS = no
44 endif
45
46 if UTILS
47 ENABLE_UTILS = yes
48 else
49 ENABLE_UTILS = no
50 endif
51
52 if BUILD_LUSTREIOKIT
53 ENABLE_IOKIT = yes
54 else
55 ENABLE_IOKIT = no
56 endif
57
58 FIND_TAG_FILES_CMD = find $(top_srcdir) \
59                      -path $(top_srcdir)/ldiskfs/linux-stage \
60                      -prune -false -o -type f -name '*.[hc]'
61
62 help:
63         @echo  'Cleaning targets:'
64         @echo  '  clean             - Remove generated object files but keep the files'
65         @echo  '                      generated by autotools; use `git clean -xdf` to'
66         @echo  '                      purge all files not tracked by git'
67         @echo  ''
68         @echo  'Generic targets:'
69         @echo  '  all               - Build all modules and utilities enabled by'
70         @echo  '                      autotools'
71         @echo  '  utils             - Build only userspace utilities'
72         @echo  '  checkpatch        - Run checkpatch.pl on latest commit'
73         @echo  '  checkstack        - Run checkstack.pl'
74         @echo  '  checkstack-update - Update checkstack.pl'
75         @echo  '  checkstack-clean  - Remove checkstack.pl artifacts'
76         @echo  ''
77         @echo  'Packaging targets:'
78         @echo  '  rpms              - Create RPM packages'
79         @echo  '  srpm              - Create source RPM packages'
80         @echo  '  dkms-rpm          - Create DKMS RPM packages'
81         @echo  '  dkms-srpm         - Create source DKMS RPM packages'
82         @echo  '  debs              - Create Debian packages'
83         @echo  '  dkms-debs         - Create DKMS Debian packages'
84
85 checkpatch:
86         @git diff HEAD~1 | ./contrib/scripts/checkpatch.pl
87
88 utils:
89         $(MAKE) -C libcfs/libcfs/util
90         $(MAKE) -C lnet/utils
91         $(MAKE) -C lustre/utils
92
93 # these empty rules are needed so that automake doesn't add its own
94 # recursive rules
95 etags-recursive:
96
97 ctags-recursive:
98
99 tags-recursive:
100
101 TAGS: etags
102
103 tags: ctags etags
104
105 etags:
106         $(RM) $(top_srcdir)/TAGS
107         ETAGSF=`etags --version | grep -iq exuberant && \
108                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
109         $(FIND_TAG_FILES_CMD) | xargs etags $$ETAGSF -a
110
111 ctags:
112         $(RM) $(top_srcdir)/tags
113         CTAGSF=`ctags --version | grep -iq exuberant && \
114                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
115         $(FIND_TAG_FILES_CMD) | xargs ctags $$CTAGSF -a
116
117 cscope-recursive:
118
119 cscope:
120         $(RM) $(top_srcdir)/cscope*.out $(top_srcdir)/cscope.files
121         $(FIND_TAG_FILES_CMD) > cscope.files
122         cscope -bRq
123
124 mkid:
125         $(FIND_TAG_FILES_CMD) | xargs mkid
126
127
128 if MODULES
129 .PHONY: ldiskfs-sources
130
131 ldiskfs-sources:
132 if LDISKFS_ENABLED
133         $(MAKE) sources -C @LDISKFS_SUBDIR@ || exit $$?
134 endif
135 if BUILT_IN_KO2IBLND
136         $(MAKE) sources -C lnet/klnds/in-kernel-o2iblnd || exit $$?
137 endif
138
139 if LINUX
140 all-am: modules
141
142 modules: undef.h ldiskfs-sources
143         $(MAKE) DEQUOTE_CC_VERSION_TEXT=$(DEQUOTE) \
144         KBUILD_EXTRA_SYMBOLS="@INT_O2IB_SYMBOLS@ @EXTRA_SYMBOLS@" \
145         LDFLAGS= CC="$(CC)" -C $(LINUX_OBJ) \
146         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
147         LINUXINCLUDE='-I$$(srctree)/arch/$$(SRCARCH)/include -Iarch/$$(SRCARCH)/include/generated -Iinclude $$(if $$(KBUILD_SRC)$$(building_out_of_srctree),-Iinclude2 -I$$(srctree)/include) -I$$(srctree)/arch/$$(SRCARCH)/include/uapi -Iarch/$$(SRCARCH)/include/generated/uapi -I$$(srctree)/include/uapi -Iinclude/generated/uapi -include $(CONFIG_INCLUDE)' \
148         $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \
149         include/config/MARKER $@
150 if EXTERNAL_KO2IBLND
151         $(MAKE) DEQUOTE_CC_VERSION_TEXT=$(DEQUOTE) BUILD_EXT_O2IB=yes \
152         KBUILD_EXTRA_SYMBOLS="$(PWD)/Module.symvers @EXT_O2IB_SYMBOLS@ @EXTRA_SYMBOLS@" \
153         LDFLAGS= CC="$(CC)" -C $(LINUX_OBJ) \
154         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
155         LINUXINCLUDE='-I$$(srctree)/arch/$$(SRCARCH)/include -Iarch/$$(SRCARCH)/include/generated -Iinclude $$(if $$(KBUILD_SRC)$$(building_out_of_srctree),-Iinclude2 -I$$(srctree)/include) -I$$(srctree)/arch/$$(SRCARCH)/include/uapi -Iarch/$$(SRCARCH)/include/generated/uapi -I$$(srctree)/include/uapi -Iinclude/generated/uapi -include $(CONFIG_INCLUDE)' \
156         $(MODULE_TARGET)=$(PWD)/lnet/klnds/o2iblnd -o tmp_include_depends -o scripts -o \
157         include/config/MARKER $@
158 endif # EXTERNAL_KO2IBLND
159 endif # LINUX
160
161 endif # MODULES
162
163 all: plugins
164
165 # compiler plugins should be built as soon as possible,
166 # so they can be available to the rest of the build
167 # system
168 plugins: undef.h
169 if CC_PLUGINS
170         $(MAKE) all -C cc-plugins
171 endif # CC_PLUGINS
172
173 undef.h: config.h.in
174         grep -v config.h.in config.h.in > $@
175
176 dist-hook: undef.h
177         find $(distdir) -name .deps -o \
178                         -name CVS -o \
179                         -name .svn -o \
180                         -name .git -o \
181                         -name .#* -exec rm -rf {} \;
182
183 EXTRA_DIST = @PACKAGE_TARNAME@.spec     \
184         build/Makefile                  \
185         build/Rules.in                  \
186         config.h.in                     \
187         lustre-dkms_pre-build.sh        \
188         lustre-dkms_post-build.sh       \
189         LUSTRE-VERSION-GEN              \
190         LUSTRE-VERSION-FILE             \
191         undef.h                         \
192         autogen.sh                      \
193         modules.order                   \
194         config/lustre-version.m4
195
196 # contrib is a directory.  Putting a directory in EXTRA_DIST
197 # recursively includes the entire directory contents in the
198 # distribution tarball (the tarball created with "make dist").
199 EXTRA_DIST += contrib
200 EXTRA_DIST += rpm
201
202 rpm-local:
203         @(if test -z "$(RPMBUILD)"; then \
204                 echo -e "\n" \
205         "*** Required util 'rpmbuild' missing. Please install the\n" \
206         "*** package for your distribution which provides 'rpmbuild',\n" \
207         "*** re-run configure, and try again.\n"; \
208                 exit 1; \
209         fi; \
210         $(MKDIR_P) $(rpmbuilddir)/TMP   && \
211         $(MKDIR_P) $(rpmbuilddir)/BUILD && \
212         $(MKDIR_P) $(rpmbuilddir)/RPMS  && \
213         $(MKDIR_P) $(rpmbuilddir)/SRPMS && \
214         $(MKDIR_P) $(rpmbuilddir)/SPECS && \
215         $(MKDIR_P) $(rpmbuilddir)/SOURCES)
216
217 if SERVER
218 dkms-srpm: $(PACKAGE)-dkms.spec dist Makefile
219         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
220         $(MAKE) $(AM_MAKEFLAGS) \
221                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
222         $(RPMBUILD) \
223                 --define "_tmppath $$rpmbuilddir/TMP" \
224                 --define "_topdir $$rpmbuilddir" \
225                 --define "_sourcedir $(top_srcdir)" \
226                 --with servers --with zfs -without ldiskfs \
227                 --bs $(PACKAGE)-dkms.spec || exit 1; \
228         $(RPMBUILD) \
229                 --define "_tmppath $$rpmbuilddir/TMP" \
230                 --define "_topdir $$rpmbuilddir" \
231                 --define "_sourcedir $(top_srcdir)" \
232                 --with servers --without zfs --with ldiskfs \
233                 --bs $(PACKAGE)-dkms.spec || exit 1; \
234         $(RPMBUILD) \
235                 --define "_tmppath $$rpmbuilddir/TMP" \
236                 --define "_topdir $$rpmbuilddir" \
237                 --define "_sourcedir $(top_srcdir)" \
238                 --with servers --with zfs --with ldiskfs \
239                 --bs $(PACKAGE)-dkms.spec || exit 1; \
240         cp $$rpmbuilddir/SRPMS/*.src.rpm $(top_srcdir) || exit 1; \
241         rm -rf $$rpmbuilddir
242
243 dkms-rpm: dkms-srpm
244         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
245         $(RPMBUILD) \
246                 --define "_tmppath $$rpmbuilddir/TMP" \
247                 --define "_topdir $$rpmbuilddir" \
248                 @RPMBUILD_BINARY_ARGS@ \
249                 --with servers --with zfs --without ldiskfs \
250                 --rebuild $(PACKAGE)-zfs-dkms-*.src.rpm || exit 1; \
251         $(RPMBUILD) \
252                 --define "_tmppath $$rpmbuilddir/TMP" \
253                 --define "_topdir $$rpmbuilddir" \
254                 @RPMBUILD_BINARY_ARGS@ \
255                 --with servers --without zfs --with ldiskfs \
256                 --rebuild $(PACKAGE)-ldiskfs-dkms-*.src.rpm || exit 1; \
257         $(RPMBUILD) \
258                 --define "_tmppath $$rpmbuilddir/TMP" \
259                 --define "_topdir $$rpmbuilddir" \
260                 @RPMBUILD_BINARY_ARGS@ \
261                 --with servers --with zfs --with ldiskfs \
262                 --rebuild $(PACKAGE)-all-dkms-*.src.rpm || exit 1; \
263         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
264         rm -rf $$rpmbuilddir
265 else
266
267 dkms-srpm: $(PACKAGE)-dkms.spec dist Makefile
268         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
269         $(MAKE) $(AM_MAKEFLAGS) \
270                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
271         $(RPMBUILD) \
272                 --define "_tmppath $$rpmbuilddir/TMP" \
273                 --define "_topdir $$rpmbuilddir" \
274                 --define "_sourcedir $(top_srcdir)" \
275                 --without servers \
276                 --bs $(PACKAGE)-dkms.spec || exit 1; \
277         cp $$rpmbuilddir/SRPMS/*.src.rpm $(top_srcdir) || exit 1; \
278         rm -rf $$rpmbuilddir
279
280 dkms-rpm: dkms-srpm
281         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
282         $(RPMBUILD) \
283                 --define "_tmppath $$rpmbuilddir/TMP" \
284                 --define "_topdir $$rpmbuilddir" \
285                 @RPMBUILD_BINARY_ARGS@ \
286                 --without servers \
287                 --rebuild $(PACKAGE)-client-dkms-*.src.rpm || exit 1; \
288         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
289         rm -rf $$rpmbuilddir
290
291 endif
292
293 dkms-srpms: dkms-srpm
294
295 dkms-rpms: dkms-rpm
296
297 rpms: srpm
298         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
299         if test "x@CONFIG_CACHE_FILE@" != "x"; then \
300                 export CONFIG_CACHE_FILE="@CONFIG_CACHE_FILE@"; \
301         fi; \
302         $(MAKE) $(AM_MAKEFLAGS) \
303                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
304         $(RPMBUILD) \
305                 --define "_tmppath $$rpmbuilddir/TMP" \
306                 --define "_topdir $$rpmbuilddir" \
307                 @RPMBUILD_BINARY_ARGS@ \
308                 --rebuild $(distdir)-*.src.rpm || exit 1; \
309         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
310         rm -rf $$rpmbuilddir
311
312 srpm: @PACKAGE_TARNAME@.spec dist Makefile
313         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
314         $(MAKE) $(AM_MAKEFLAGS) \
315                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
316         cp $(top_srcdir)/rpm/* $(top_srcdir); \
317         $(RPMBUILD) \
318                 --define "_tmppath $$rpmbuilddir/TMP" \
319                 --define "_topdir $$rpmbuilddir" \
320                 --define "dist %{nil}" \
321                 -ts $(distdir).tar.gz || exit 1; \
322         cp $$rpmbuilddir/SRPMS/$(distdir)-*.src.rpm $(top_srcdir) || exit 1; \
323         rm -rf $$rpmbuilddir
324
325 debs_common:
326         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
327         rm -f /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2; \
328         if test -f /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2; then \
329                 echo "************************************************************" ; \
330                 echo "WARNING: move or remove /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2" ; \
331                 echo "************************************************************" ; \
332                 exit 1 ; \
333         fi
334 # In the debs target, first make sure what's in the changelog reflects
335 # the software version.
336 debs: undef.h debs_common
337         cp -v debian/changelog.in debian/changelog ; \
338         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
339         lversion=$$(echo @VERSION@ | tr '_' '-'); \
340         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
341         if [ "$$lversion" != "$$cversion" ]; then \
342                 echo -e "1i\nlustre ($$lversion-1) unstable; urgency=low\n\n  * Automated changelog entry update\n\n -- Andreas Dilger <adilger@whamcloud.com>  $$(date -R)\n\n.\nwq" | ed debian/changelog; \
343         fi; \
344         rm -rf debs; \
345         if test "x@ENABLE_SERVER@" = "xyes"; then \
346                 DEB_BUILD_PROFILES="server"; \
347         else \
348                 DEB_BUILD_PROFILES="client"; \
349         fi; \
350         if test "x@ENABLE_LDISKFS@" = "xyes"; then \
351                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} ldiskfs"; \
352         fi; \
353         if test "x@ENABLE_ZFS@" = "xyes"; then \
354                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} zfs"; \
355                 export SPL_SRC="@SPL@"; \
356                 export ZFS_SRC="@ZFS@"; \
357                 echo "ZFS support is enabled. Will expect pre-compiled SPL and ZFS sources in:"; \
358                 echo "SPL: $${SPL_SRC}"; \
359                 echo "ZFS: $${ZFS_SRC}"; \
360         fi; \
361         if test "x@ENABLE_MULTIPLE_LNDS@" != "xno"; then \
362                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} multiple-lnds"; \
363         fi; \
364         if test "x@ENABLE_GNI@" = "xyes"; then \
365                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} gnilnd"; \
366         fi; \
367         if test "x@KFILND@" = "xkfilnd"; then \
368                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} kfilnd"; \
369         fi; \
370         if test "x@DPKG_EXT_O2IB@" != "x"; then \
371                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} ext_o2ib"; \
372                 export O2IB_SRC="@EXT_O2IBPATH@"; \
373         fi ; \
374         if test "x@DPKG_INT_O2IB@" != "x"; then \
375                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} int_o2ib"; \
376         fi; \
377         if test "x@CONFIG_CACHE_FILE@" != "x"; then \
378                 export CONFIG_CACHE_FILE="@CONFIG_CACHE_FILE@"; \
379         fi; \
380         debiantmp=$$(mktemp -t -d debbuild-$$USER-XXXXXXXX) ; \
381         cp debian/control.main $$debiantmp/control.main.bkp ; \
382         cp debian/control.modules.in $$debiantmp/control.modules.in.bkp ; \
383         if test "x@ENABLE_GSS@" = "xyes"; then \
384                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} gss"; \
385                 sed -i "s+^\(Build-Depends: .*\)$$+\1, libkrb5-dev, libssl-dev+" debian/control.main ; \
386                 awk 'BEGIN{change=0} $$1 == "Package:" {if (($$2 == "lustre-client-utils") || ($$2 == "lustre-server-utils")) change=1; else change=0; fi } {if (($$1 == "Depends:") && change) print $$0 ", libgssapi-krb5-2, libkrb5-3, libssl1.1|libssl3"; else print; fi}' debian/control.main > $$debiantmp/control.main && mv $$debiantmp/control.main debian/control.main ; \
387                 sed -i "s+^\(Build-Depends: .*\)$$+\1, libkrb5-dev, libssl-dev+" debian/control.modules.in ; \
388         elif test "x@ENABLE_GSS@" = "xno"; then \
389                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nogss"; \
390         fi; \
391         if test "x$(ENABLE_MPITESTS)" = "xyes"; then \
392                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} mpitests"; \
393         elif test "x$(ENABLE_MPITESTS)" = "xno"; then \
394                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nompitests"; \
395                 sed -i -e 's/mpi-default-dev,//' -e 's/mpi-default-bin,//' debian/control.main ; \
396         fi; \
397         if test "x$(ENABLE_TESTS)" = "xyes"; then \
398                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} tests"; \
399         elif test "x$(ENABLE_TESTS)" = "xno"; then \
400                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} notests"; \
401                 sed -i -e 's/mpi-default-dev,//' -e 's/mpi-default-bin,//' debian/control.main ; \
402         fi; \
403         if test "x$(ENABLE_IOKIT)" = "xyes"; then \
404                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} iokit"; \
405         elif test "x$(ENABLE_IOKIT)" = "xno"; then \
406                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} noiokit"; \
407         fi; \
408         if test "x$(ENABLE_UTILS)" = "xyes"; then \
409                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} utils"; \
410         elif test "x$(ENABLE_UTILS)" = "xno"; then \
411                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} noutils"; \
412         fi; \
413         if test "x@ENABLE_CRYPTO@" = "xyes"; then \
414                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} crypto"; \
415         elif test "x@ENABLE_CRYPTO@" = "xno"; then \
416                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nocrypto"; \
417         fi; \
418         if test "x@systemdsystemunitdir@" != "x"; then \
419                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} systemd"; \
420                 export SYSTEMD_OPTIONS="--with-systemdsystemunitdir=@systemdsystemunitdir@"; \
421         fi; \
422         if test "x@ENABLE_PINGER@" = "xyes"; then \
423                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} pinger"; \
424         elif test "x@ENABLE_PINGER@" = "xno"; then \
425                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nopinger"; \
426         fi; \
427         if test "x@ENABLE_CHECKSUM@" = "xyes"; then \
428                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} checksum"; \
429         elif test "x@ENABLE_CHECKSUM@" = "xno"; then \
430                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nochecksum"; \
431         fi; \
432         if test "x@ENABLE_FLOCK@" = "xyes"; then \
433                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} flock"; \
434         elif test "x@ENABLE_FLOCK@" = "xno"; then \
435                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} noflock"; \
436         fi; \
437         if test "x@ENABLE_LRU_RESIZE@" = "xyes"; then \
438                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} lru-resize"; \
439         elif test "x@ENABLE_LRU_RESIZE@" = "xno"; then \
440                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nolru-resize"; \
441         fi; \
442         if test "x@ENABLE_MINDF@" = "xyes"; then \
443                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} mindf"; \
444         elif test "x@ENABLE_MINDF@" = "xno"; then \
445                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nomindf"; \
446         fi; \
447         if test "x@ENABLE_FAIL_ALLOC@" = "xyes"; then \
448                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} fail-alloc"; \
449         elif test "x@ENABLE_FAIL_ALLOC@" = "xno"; then \
450                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nofail-alloc"; \
451         fi; \
452         if test "x@ENABLE_INVARIANTS@" = "xyes"; then \
453                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} invariants"; \
454         elif test "x@ENABLE_INVARIANTS@" = "xno"; then \
455                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} noinvariants"; \
456         fi; \
457         if test "x@ENABLE_LU_REF@" = "xyes"; then \
458                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} lu_ref"; \
459         elif test "x@ENABLE_LU_REF@" = "xno"; then \
460                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nolu_ref"; \
461         fi; \
462         if test "x@ENABLE_PGSTAT_TRACK@" = "xyes"; then \
463                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} pgstate-track"; \
464         elif test "x@ENABLE_PGSTAT_TRACK@" = "xno"; then \
465                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nopgstate-track"; \
466         fi; \
467         if test "x@ENABLE_LIBCFS_CDEBUG@" = "xyes"; then \
468                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} libcfs-cdebug"; \
469         elif test "x@ENABLE_LIBCFS_CDEBUG@" = "xno"; then \
470                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nolibcfs-cdebug"; \
471         fi; \
472         if test "x@ENABLE_LIBCFS_TRACE@" = "xyes"; then \
473                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} libcfs-trace"; \
474         elif test "x@ENABLE_LIBCFS_TRACE@" = "xno"; then \
475                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nolibcfs-trace"; \
476         fi; \
477         if test "x@ENABLE_LIBCFS_ASSERT@" = "xyes"; then \
478                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} libcfs-assert"; \
479         elif test "x@ENABLE_LIBCFS_ASSERT@" = "xno"; then \
480                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nolibcfs-assert"; \
481         fi; \
482         if test "x@ENABLE_PANIC_DUMPLOG@" = "xyes"; then \
483                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} panic_dumplog"; \
484         elif test "x@ENABLE_PANIC_DUMPLOG@" = "xno"; then \
485                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nopanic_dumplog"; \
486         fi; \
487         if test "x@ENABLE_READLINE@" = "xyes"; then \
488                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} readline"; \
489         elif test "x@ENABLE_READLINE@" = "xno"; then \
490                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} noreadline"; \
491         fi; \
492         if test "x@ENABLE_LIBPTHREAD@" = "xyes"; then \
493                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} libpthread"; \
494         elif test "x@ENABLE_LIBPTHREAD@" = "xno"; then \
495                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nolibpthread"; \
496         fi; \
497         if test "x@ENABLE_BACKOFF@" = "xyes"; then \
498                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} backoff"; \
499         elif test "x@ENABLE_BACKOFF@" = "xno"; then \
500                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nobackoff"; \
501         fi; \
502         if test "x@ENABLE_EFENCE@" = "xyes"; then \
503                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} efence"; \
504         elif test "x@ENABLE_EFENCE@" = "xno"; then \
505                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} noefence"; \
506         fi; \
507         if test "x@TESTS_FALSE@" = "x"; then \
508                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} notests"; \
509         fi; \
510         export KERNEL_OBJ="$(LINUX_OBJ)"; \
511         export KERNEL_SRC="$(LINUX)"; \
512         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"; \
513         echo "Kernel Source: $${KERNEL_SRC}"; \
514         echo "Kernel Object: $${KERNEL_OBJ}"; \
515         if test "x@ENABLEO2IB@" = "xno"; then \
516                 export IB_OPTIONS="--with-o2ib=no"; \
517         else \
518                 if test "x@ENABLEO2IB@" != "xyes" && \
519                    test -n "@EXT_O2IBPATH@"; then \
520                         export IB_OPTIONS="--with-o2ib=@EXT_O2IBPATH@"; \
521                 else \
522                         export IB_OPTIONS="--with-o2ib=yes"; \
523                 fi; \
524         fi; \
525         cp -v debian/control.main debian/control ; \
526         sed "s/_KVERS_/$(LINUXRELEASE)/g" debian/lustre-tests.install.in \
527                 > debian/lustre-tests.install; \
528         tmpprofiles=`tr ' ' ',' <<< $$DEB_BUILD_PROFILES`; \
529         dpkg-buildpackage -us -uc -I.git -I\*.out[0-9]\* -I\*.swp -P$$tmpprofiles || { \
530                 rc=$${PIPESTATUS[0]}; \
531                 cp $$debiantmp/control.main.bkp debian/control.main || true && \
532                 cp $$debiantmp/control.modules.in.bkp debian/control.modules.in || true && \
533                 [ $${rc} -gt 1 ] && exit $${rc}; \
534                 exit 0; \
535         }; \
536         cp $$debiantmp/control.main.bkp debian/control.main || true && \
537         cp $$debiantmp/control.modules.in.bkp debian/control.modules.in || true && \
538         export KPKG_DEST_DIR="$$(pwd)/.." && \
539         version=$$(sed -ne '1s/^lustre (\(.*\)).*$$/\1/p' debian/changelog) && \
540         rm -rf debian/tmp/modules-deb && \
541         mkdir debian/tmp/modules-deb && \
542         pushd debian/tmp/modules-deb && \
543         dpkg -x ../../../../lustre-source_$${version}_all.deb $$(pwd) && \
544         mkdir usr_src/ && \
545         tar -C usr_src/ -xjf usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2 && \
546         chmod 755 usr_src/modules/lustre/debian/rules && \
547         mkdir -p usr_share_modass && \
548         ln -s /usr/share/modass/include/ usr_share_modass/ && \
549         ln -s /usr/share/modass/packages/ usr_share_modass/ && \
550         echo "lustre" > usr_share_modass/compliant.list && \
551         export MA_DIR=$$(pwd)/usr_share_modass && \
552         KVERS=$${KVERS:-$(LINUXRELEASE)} && \
553         export KSRC_TREE=$(LINUX) && \
554         KSRC=$${KSRC:-$(LINUX_OBJ)} && \
555         TARBALL=$$(realpath usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2) \
556         m-a build $${KSRC:+-k $$KSRC} $${KVERS:+-l $$KVERS} -i -u $$(pwd) lustre && \
557         popd && \
558         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog) && \
559         if test "x@ENABLE_SERVER@" = "xyes"; then \
560                 DEB_SERVER_PKG="../lustre-resource-agents_$${VER}_*.deb"; \
561         fi; \
562         MULTILNDPKGS= ; \
563         if test "x@ENABLE_MULTIPLE_LNDS@" != "xno"; then \
564                 debian/repackage-multiple-lnds.sh $${KVERS} $${VER} ../lustre-*-modules-$${KVERS}_$${VER}_*.deb ; \
565                 MULTILNDPKGS="../lustre-lnet-module-*-$${KVERS}_$${VER}_*.deb"; \
566         fi; \
567         mkdir -p debs && \
568         mv ../lustre-dev_$${VER}_*.deb ../lustre-source_$${VER}_all.deb \
569            ../lustre-iokit_$${VER}_*.deb ../lustre-tests_$${VER}_*.deb \
570            ../lustre-*-utils_$${VER}_*.deb $${DEB_SERVER_PKG} $${MULTILNDPKGS} \
571            ../lustre_$${VER}.dsc ../lustre_$${VER}_*.changes \
572            ../lustre_$${VER}.tar.gz ../lustre-*-modules-$${KVERS}_$${VER}_*.deb \
573            ../lustre-*-dbgsym_$${VER}_*.ddeb ../lustre_$${VER}_*.buildinfo \
574            debs/ 2> /dev/null || true
575
576 dkms-debs: undef.h debs_common
577         cp -v debian/changelog.in debian/changelog ; \
578         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
579         lversion=$$(echo @VERSION@ | tr '_' '-'); \
580         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
581         if [ "$$lversion" != "$$cversion" ]; then \
582                 echo -e "1i\nlustre ($$lversion-1) unstable; urgency=low\n\n  * Automated changelog entry update\n\n -- Brian J. Murrell <brian@interlinx.bc.ca>  $$(date -R)\n\n.\nwq" | ed debian/changelog; \
583         fi; \
584         rm -rf debs; \
585         export DEB_BUILD_PROFILES="client"; \
586         export KERNEL_OBJ="$(LINUX_OBJ)"; \
587         export KERNEL_SRC="$(LINUX)"; \
588         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"; \
589         tmpprofiles=`tr ' ' ',' <<< $$DEB_BUILD_PROFILES`; \
590         echo "Kernel Source: $${KERNEL_SRC}"; \
591         echo "Kernel Object: $${KERNEL_OBJ}"; \
592         export BUILD_DKMS="true" && \
593         cp -v debian/control.main debian/control ; \
594         dpkg-buildpackage -us -uc -I.git -I\*.out[0-9]\* -I\*.swp -P$$tmpprofiles || { \
595                 rc=$${PIPESTATUS[0]}; \
596                 [ $${rc} -gt 1 ] && exit $${rc}; \
597                 exit 0; \
598         }; \
599         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog) && \
600         mkdir -p debs && \
601         mv ../lustre-dev_$${VER}_*.deb ../lustre-source_$${VER}_all.deb \
602            ../lustre-iokit_$${VER}_*.deb ../lustre-tests_$${VER}_*.deb \
603            ../lustre-*-utils_$${VER}_*.deb \
604            ../lustre_$${VER}.dsc ../lustre_$${VER}_*.changes \
605            ../lustre_$${VER}.tar.gz ../lustre-*-modules-dkms_$${VER}_*.deb \
606            ../lustre-*-dbgsym_$${VER}_*.ddeb ../lustre_$${VER}_*.buildinfo \
607            debs/
608
609 EXTRA_DIST += debian/*
610
611 CSTK=/tmp/checkstack
612 CSTKO=/tmp/checkstack.orig
613
614 checkstack:
615         [ -f ${CSTK} -a ! -s ${CSTKO} ] && mv -f ${CSTK} ${CSTKO} || true
616         { for MOD in $$(find . -name "*.ko"); do                             \
617                 objdump -d $$MOD | perl contrib/scripts/checkstack.pl;       \
618           done } | grep -v " bug " | sort -nr | uniq > ${CSTK}
619         [ -f ${CSTKO} ] && ! diff -u ${CSTKO} ${CSTK} || head -n 30 ${CSTK}
620
621 checkstack-update:
622         [ -f ${CSTK} ] && mv -f ${CSTK} ${CSTKO}
623
624 checkstack-clean:
625         rm -f ${CSTK} ${CSTKO}