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