Whamcloud - gitweb
LU-16412 llite: check read page past requested
[fs/lustre-release.git] / autoMakefile.am
1 SUBDIRS := @LDISKFS_SUBDIR@ \
2         . \
3         @LUSTREIOKIT_SUBDIR@ \
4         libcfs \
5         @SNMP_SUBDIR@ \
6         lnet \
7         lustre
8
9 DIST_SUBDIRS := ldiskfs \
10         lustre-iokit \
11         libcfs \
12         @SNMP_DIST_SUBDIR@ \
13         lnet \
14         lustre \
15         config
16
17 AUTOMAKE_OPTIONS = foreign
18
19 if DEQUOTE_CC_VERSION_TEXT
20 DEQUOTE = yes
21 endif
22
23 FIND_TAG_FILES_CMD = find $(top_srcdir) \
24                      -path $(top_srcdir)/ldiskfs/linux-stage \
25                      -prune -false -o -type f -name '*.[hc]'
26
27 # these empty rules are needed so that automake doesn't add its own
28 # recursive rules
29 etags-recursive:
30
31 ctags-recursive:
32
33 tags-recursive:
34
35 TAGS: etags
36
37 tags: ctags etags
38
39 etags:
40         $(RM) $(top_srcdir)/TAGS
41         ETAGSF=`etags --version | grep -iq exuberant && \
42                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
43         $(FIND_TAG_FILES_CMD) | xargs etags $$ETAGSF -a
44
45 ctags:
46         $(RM) $(top_srcdir)/tags
47         CTAGSF=`ctags --version | grep -iq exuberant && \
48                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
49         $(FIND_TAG_FILES_CMD) | xargs ctags $$CTAGSF -a
50
51 cscope-recursive:
52
53 cscope:
54         $(RM) $(top_srcdir)/cscope*.out $(top_srcdir)/cscope.files
55         $(FIND_TAG_FILES_CMD) > cscope.files
56         cscope -bRq
57
58 mkid:
59         $(FIND_TAG_FILES_CMD) | xargs mkid
60
61
62 doxygen:  doxygen-api doxygen-ref
63
64 doxygen-%: build/doxyfile.%
65         doxygen $<
66
67 if MODULES
68 .PHONY: ldiskfs-sources
69
70 ldiskfs-sources:
71 if LDISKFS_ENABLED
72         $(MAKE) sources -C @LDISKFS_SUBDIR@ || exit $$?
73 endif
74
75 if LINUX
76 all-am: modules
77
78 modules: undef.h ldiskfs-sources
79         $(MAKE) DEQUOTE_CC_VERSION_TEXT=$(DEQUOTE) \
80         LDFLAGS= CC="$(CC)" -C $(LINUX_OBJ) \
81         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
82         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)' \
83         $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \
84         include/config/MARKER $@
85 endif # LINUX
86
87 endif # MODULES
88
89 all: undef.h
90
91 undef.h: config.h.in
92         grep -v config.h.in config.h.in > $@
93
94 dist-hook: undef.h
95         find $(distdir) -name .deps -o \
96                         -name CVS -o \
97                         -name .svn -o \
98                         -name .git -o \
99                         -name .#* -exec rm -rf {} \;
100
101 EXTRA_DIST = @PACKAGE_TARNAME@.spec     \
102         build/Makefile                  \
103         build/Rules.in                  \
104         config.h.in                     \
105         lustre-dkms_pre-build.sh        \
106         lustre-dkms_post-build.sh       \
107         LUSTRE-VERSION-GEN              \
108         LUSTRE-VERSION-FILE             \
109         undef.h                         \
110         autogen.sh                      \
111         config/lustre-version.m4
112
113 # contrib is a directory.  Putting a directory in EXTRA_DIST
114 # recursively includes the entire directory contents in the
115 # distribution tarball (the tarball created with "make dist").
116 EXTRA_DIST += contrib
117 EXTRA_DIST += rpm
118
119 rpm-local:
120         @(if test -z "$(RPMBUILD)"; then \
121                 echo -e "\n" \
122         "*** Required util 'rpmbuild' missing. Please install the\n" \
123         "*** package for your distribution which provides 'rpmbuild',\n" \
124         "*** re-run configure, and try again.\n"; \
125                 exit 1; \
126         fi; \
127         $(MKDIR_P) $(rpmbuilddir)/TMP   && \
128         $(MKDIR_P) $(rpmbuilddir)/BUILD && \
129         $(MKDIR_P) $(rpmbuilddir)/RPMS  && \
130         $(MKDIR_P) $(rpmbuilddir)/SRPMS && \
131         $(MKDIR_P) $(rpmbuilddir)/SPECS && \
132         $(MKDIR_P) $(rpmbuilddir)/SOURCES)
133
134 if SERVER
135 dkms-srpm: $(PACKAGE)-dkms.spec dist Makefile
136         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
137         $(MAKE) $(AM_MAKEFLAGS) \
138                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
139         $(RPMBUILD) \
140                 --define "_tmppath $$rpmbuilddir/TMP" \
141                 --define "_topdir $$rpmbuilddir" \
142                 --define "_sourcedir $(top_srcdir)" \
143                 --with servers --with zfs -without ldiskfs \
144                 --bs $(PACKAGE)-dkms.spec || exit 1; \
145         $(RPMBUILD) \
146                 --define "_tmppath $$rpmbuilddir/TMP" \
147                 --define "_topdir $$rpmbuilddir" \
148                 --define "_sourcedir $(top_srcdir)" \
149                 --with servers --without zfs --with ldiskfs \
150                 --bs $(PACKAGE)-dkms.spec || exit 1; \
151         $(RPMBUILD) \
152                 --define "_tmppath $$rpmbuilddir/TMP" \
153                 --define "_topdir $$rpmbuilddir" \
154                 --define "_sourcedir $(top_srcdir)" \
155                 --with servers --with zfs --with ldiskfs \
156                 --bs $(PACKAGE)-dkms.spec || exit 1; \
157         cp $$rpmbuilddir/SRPMS/*.src.rpm $(top_srcdir) || exit 1; \
158         rm -rf $$rpmbuilddir
159
160 dkms-rpm: dkms-srpm
161         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
162         $(RPMBUILD) \
163                 --define "_tmppath $$rpmbuilddir/TMP" \
164                 --define "_topdir $$rpmbuilddir" \
165                 @RPMBUILD_BINARY_ARGS@ \
166                 --with servers --with zfs --without ldiskfs \
167                 --rebuild $(PACKAGE)-zfs-dkms-*.src.rpm || exit 1; \
168         $(RPMBUILD) \
169                 --define "_tmppath $$rpmbuilddir/TMP" \
170                 --define "_topdir $$rpmbuilddir" \
171                 @RPMBUILD_BINARY_ARGS@ \
172                 --with servers --without zfs --with ldiskfs \
173                 --rebuild $(PACKAGE)-ldiskfs-dkms-*.src.rpm || exit 1; \
174         $(RPMBUILD) \
175                 --define "_tmppath $$rpmbuilddir/TMP" \
176                 --define "_topdir $$rpmbuilddir" \
177                 @RPMBUILD_BINARY_ARGS@ \
178                 --with servers --with zfs --with ldiskfs \
179                 --rebuild $(PACKAGE)-all-dkms-*.src.rpm || exit 1; \
180         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
181         rm -rf $$rpmbuilddir
182 else
183
184 dkms-srpm: $(PACKAGE)-dkms.spec dist Makefile
185         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
186         $(MAKE) $(AM_MAKEFLAGS) \
187                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
188         $(RPMBUILD) \
189                 --define "_tmppath $$rpmbuilddir/TMP" \
190                 --define "_topdir $$rpmbuilddir" \
191                 --define "_sourcedir $(top_srcdir)" \
192                 --without servers \
193                 --bs $(PACKAGE)-dkms.spec || exit 1; \
194         cp $$rpmbuilddir/SRPMS/*.src.rpm $(top_srcdir) || exit 1; \
195         rm -rf $$rpmbuilddir
196
197 dkms-rpm: dkms-srpm
198         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
199         $(RPMBUILD) \
200                 --define "_tmppath $$rpmbuilddir/TMP" \
201                 --define "_topdir $$rpmbuilddir" \
202                 @RPMBUILD_BINARY_ARGS@ \
203                 --without servers \
204                 --rebuild $(PACKAGE)-client-dkms-*.src.rpm || exit 1; \
205         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
206         rm -rf $$rpmbuilddir
207
208 endif
209
210 dkms-srpms: dkms-srpm
211
212 dkms-rpms: dkms-rpm
213
214 rpms: srpm
215         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
216         if test "x@CONFIG_CACHE_FILE@" != "x"; then \
217                 export CONFIG_CACHE_FILE="@CONFIG_CACHE_FILE@"; \
218         fi; \
219         $(MAKE) $(AM_MAKEFLAGS) \
220                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
221         $(RPMBUILD) \
222                 --define "_tmppath $$rpmbuilddir/TMP" \
223                 --define "_topdir $$rpmbuilddir" \
224                 @RPMBUILD_BINARY_ARGS@ \
225                 --rebuild $(distdir)-*.src.rpm || exit 1; \
226         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
227         rm -rf $$rpmbuilddir
228
229 srpm: @PACKAGE_TARNAME@.spec dist Makefile
230         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
231         $(MAKE) $(AM_MAKEFLAGS) \
232                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
233         cp $(top_srcdir)/rpm/* $(top_srcdir); \
234         $(RPMBUILD) \
235                 --define "_tmppath $$rpmbuilddir/TMP" \
236                 --define "_topdir $$rpmbuilddir" \
237                 --define "dist %{nil}" \
238                 -ts $(distdir).tar.gz || exit 1; \
239         cp $$rpmbuilddir/SRPMS/$(distdir)-*.src.rpm $(top_srcdir) || exit 1; \
240         rm -rf $$rpmbuilddir
241
242 debs_common:
243         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
244         rm -f /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2; \
245         if test -f /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2; then \
246                 echo "************************************************************" ; \
247                 echo "WARNING: move or remove /usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2" ; \
248                 echo "************************************************************" ; \
249                 exit 1 ; \
250         fi
251 # In the debs target, first make sure what's in the changelog reflects
252 # the software version.
253 debs: undef.h debs_common
254         cp -v debian/changelog.in debian/changelog ; \
255         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
256         lversion=$$(echo @VERSION@ | tr '_' '-'); \
257         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
258         if [ "$$lversion" != "$$cversion" ]; then \
259                 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; \
260         fi; \
261         rm -rf debs; \
262         if test "x@ENABLE_SERVER@" = "xyes"; then \
263                 DEB_BUILD_PROFILES="server"; \
264         else \
265                 DEB_BUILD_PROFILES="client"; \
266         fi; \
267         if test "x@ENABLE_LDISKFS@" = "xyes"; then \
268                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} ldiskfs"; \
269         fi; \
270         if test "x@ENABLE_ZFS@" = "xyes"; then \
271                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} zfs"; \
272                 export SPL_SRC="@SPL@"; \
273                 export ZFS_SRC="@ZFS@"; \
274                 echo "ZFS support is enabled. Will expect pre-compiled SPL and ZFS sources in:"; \
275                 echo "SPL: $${SPL_SRC}"; \
276                 echo "ZFS: $${ZFS_SRC}"; \
277         fi; \
278         if test "x@ENABLEO2IB@" != "xno"; then \
279                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} o2ib"; \
280                 export O2IB_SRC="@O2IBPATH@"; \
281         fi; \
282         if test "x@CONFIG_CACHE_FILE@" != "x"; then \
283                 export CONFIG_CACHE_FILE="@CONFIG_CACHE_FILE@"; \
284         fi; \
285         if test "x@ENABLE_GSS@" = "xyes"; then \
286                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} gss"; \
287                 debiantmp=$$(mktemp -t -d debbuild-$$USER-XXXXXXXX) ; \
288                 cp debian/control $$debiantmp/control.bkp ; \
289                 cp debian/control.main $$debiantmp/control.main.bkp ; \
290                 cp debian/control.modules.in $$debiantmp/control.modules.in.bkp ; \
291                 sed -i "s+^\(Build-Depends: .*\)$$+\1, libkrb5-dev, libssl-dev+" debian/control.main ; \
292                 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 ; \
293                 sed -i "s+^\(Build-Depends: .*\)$$+\1, libkrb5-dev, libssl-dev+" debian/control.modules.in ; \
294         elif test "x@ENABLE_GSS@" = "xno"; then \
295                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nogss"; \
296         fi; \
297         if test "x@ENABLE_CRYPTO@" = "xyes"; then \
298                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} crypto"; \
299         elif test "x@ENABLE_CRYPTO@" = "xno"; then \
300                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} nocrypto"; \
301         fi; \
302         if test "x@systemdsystemunitdir@" != "x"; then \
303                 export DEB_BUILD_PROFILES="$${DEB_BUILD_PROFILES} systemd"; \
304         fi; \
305         export KERNEL_OBJ="$(LINUX_OBJ)"; \
306         export KERNEL_SRC="$(LINUX)"; \
307         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"; \
308         echo "Kernel Source: $${KERNEL_SRC}"; \
309         echo "Kernel Object: $${KERNEL_OBJ}"; \
310         if test "x@ENABLEO2IB@" = "xno"; then \
311                 export IB_OPTIONS="--with-o2ib=no"; \
312         else \
313                 if test "x@ENABLEO2IB@" != "xyes" && \
314                    test -n "@O2IBPATH@"; then \
315                         export IB_OPTIONS="--with-o2ib=@O2IBPATH@"; \
316                 else \
317                         export IB_OPTIONS="--with-o2ib=yes"; \
318                 fi; \
319         fi; \
320         dpkg-buildpackage -us -uc -I.git -I\*.out[0-9]\* -I\*.swp || { \
321                 rc=$${PIPESTATUS[0]}; \
322                 cp $$debiantmp/control.bkp debian/control || true && \
323                 cp $$debiantmp/control.main.bkp debian/control.main || true && \
324                 cp $$debiantmp/control.modules.in.bkp debian/control.modules.in || true && \
325                 [ $${rc} -gt 1 ] && exit $${rc}; \
326                 exit 0; \
327         }; \
328         cp $$debiantmp/control.bkp debian/control || true && \
329         cp $$debiantmp/control.main.bkp debian/control.main || true && \
330         cp $$debiantmp/control.modules.in.bkp debian/control.modules.in || true && \
331         export KPKG_DEST_DIR="$$(pwd)/.." && \
332         version=$$(sed -ne '1s/^lustre (\(.*\)).*$$/\1/p' debian/changelog) && \
333         rm -rf debian/tmp/modules-deb && \
334         mkdir debian/tmp/modules-deb && \
335         pushd debian/tmp/modules-deb && \
336         dpkg -x ../../../../lustre-source_$${version}_all.deb $$(pwd) && \
337         mkdir usr_src/ && \
338         tar -C usr_src/ -xjf usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2 && \
339         chmod 755 usr_src/modules/lustre/debian/rules && \
340         mkdir -p usr_share_modass && \
341         ln -s /usr/share/modass/include/ usr_share_modass/ && \
342         ln -s /usr/share/modass/packages/ usr_share_modass/ && \
343         echo "lustre" > usr_share_modass/compliant.list && \
344         export MA_DIR=$$(pwd)/usr_share_modass && \
345         KVERS=$${KVERS:-$(LINUXRELEASE)} && \
346         export KSRC_TREE=$(LINUX) && \
347         KSRC=$${KSRC:-$(LINUX_OBJ)} && \
348         TARBALL=$$(realpath usr/src/lustre-$${SRC_GIT_HASH}.tar.bz2) \
349         m-a build $${KSRC:+-k $$KSRC} $${KVERS:+-l $$KVERS} -i -u $$(pwd) lustre && \
350         popd && \
351         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog) && \
352         if test "x@ENABLE_SERVER@" = "xyes"; then \
353                 DEB_SERVER_PKG="../lustre-resource-agents_$${VER}_*.deb"; \
354         fi; \
355         mkdir -p debs && \
356         mv ../lustre-dev_$${VER}_*.deb ../lustre-source_$${VER}_all.deb \
357            ../lustre-iokit_$${VER}_*.deb ../lustre-tests_$${VER}_*.deb \
358            ../lustre-*-utils_$${VER}_*.deb $${DEB_SERVER_PKG} \
359            ../lustre_$${VER}.dsc ../lustre_$${VER}_*.changes \
360            ../lustre_$${VER}.tar.gz ../lustre-*-modules-$${KVERS}_$${VER}_*.deb \
361            debs/
362
363 dkms-debs: undef.h debs_common
364         cp -v debian/changelog.in debian/changelog ; \
365         export SRC_GIT_HASH=$$(git log --oneline | head -1 | cut -d' ' -f1); \
366         lversion=$$(echo @VERSION@ | tr '_' '-'); \
367         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
368         if [ "$$lversion" != "$$cversion" ]; then \
369                 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; \
370         fi; \
371         rm -rf debs; \
372         export DEB_BUILD_PROFILES="client"; \
373         export KERNEL_OBJ="$(LINUX_OBJ)"; \
374         export KERNEL_SRC="$(LINUX)"; \
375         echo "Enabled Build Profiles: $${DEB_BUILD_PROFILES}"; \
376         echo "Kernel Source: $${KERNEL_SRC}"; \
377         echo "Kernel Object: $${KERNEL_OBJ}"; \
378         export BUILD_DKMS="true" && \
379         dpkg-buildpackage -us -uc -I.git -I\*.out[0-9]\* -I\*.swp || { \
380                 rc=$${PIPESTATUS[0]}; \
381                 [ $${rc} -gt 1 ] && exit $${rc}; \
382                 exit 0; \
383         }; \
384         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog) && \
385         mkdir -p debs && \
386         mv ../lustre-dev_$${VER}_*.deb ../lustre-source_$${VER}_all.deb \
387            ../lustre-iokit_$${VER}_*.deb ../lustre-tests_$${VER}_*.deb \
388            ../lustre-*-utils_$${VER}_*.deb \
389            ../lustre_$${VER}.dsc ../lustre_$${VER}_*.changes \
390            ../lustre_$${VER}.tar.gz ../lustre-*-modules-dkms_$${VER}_*.deb \
391            debs/
392
393 EXTRA_DIST += debian/*
394
395 CSTK=/tmp/checkstack
396 CSTKO=/tmp/checkstack.orig
397
398 checkstack:
399         [ -f ${CSTK} -a ! -s ${CSTKO} ] && mv -f ${CSTK} ${CSTKO} || true
400         { for MOD in $$(find . -name "*.ko"); do                             \
401                 objdump -d $$MOD | perl contrib/scripts/checkstack.pl;       \
402           done } | grep -v " bug " | sort -nr | uniq > ${CSTK}
403         [ -f ${CSTKO} ] && ! diff -u ${CSTKO} ${CSTK} || head -n 30 ${CSTK}
404
405 checkstack-update:
406         [ -f ${CSTK} ] && mv -f ${CSTK} ${CSTKO}
407
408 checkstack-clean:
409         rm -f ${CSTK} ${CSTKO}