Whamcloud - gitweb
LU-7931 tests: Allow per-subtest setup/cleanup
[fs/lustre-release.git] / autoMakefile.am
1 SUBDIRS := @LDISKFS_SUBDIR@ \
2         . \
3         @LUSTREIOKIT_SUBDIR@ \
4         @LIBCFS_SUBDIR@ \
5         @SNMP_SUBDIR@ \
6         lnet \
7         lustre
8
9 DIST_SUBDIRS := ldiskfs \
10         lustre-iokit \
11         @LIBCFS_SUBDIR@ \
12         @SNMP_DIST_SUBDIR@ \
13         lnet \
14         lustre \
15         config
16
17 AUTOMAKE_OPTIONS = foreign
18
19 FIND_TAG_FILES_CMD = find $(top_srcdir) \
20                      -path $(top_srcdir)/ldiskfs/linux-stage \
21                      -prune -false -o -type f -name '*.[hc]'
22
23 # these empty rules are needed so that automake doesn't add its own
24 # recursive rules
25 etags-recursive:
26
27 ctags-recursive:
28
29 tags-recursive:
30
31 TAGS: etags
32
33 tags: ctags etags
34
35 etags:
36         $(RM) $(top_srcdir)/TAGS
37         ETAGSF=`etags --version | grep -iq exuberant && \
38                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
39         $(FIND_TAG_FILES_CMD) | xargs etags $$ETAGSF -a
40
41 ctags:
42         $(RM) $(top_srcdir)/tags
43         CTAGSF=`ctags --version | grep -iq exuberant && \
44                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
45         $(FIND_TAG_FILES_CMD) | xargs ctags $$CTAGSF -a
46
47 cscope-recursive:
48
49 cscope:
50         $(RM) $(top_srcdir)/cscope*.out $(top_srcdir)/cscope.files
51         $(FIND_TAG_FILES_CMD) > cscope.files
52         cscope -bRq
53
54 mkid:
55         $(FIND_TAG_FILES_CMD) | xargs mkid
56
57
58 doxygen:  doxygen-api doxygen-ref
59
60 doxygen-%: build/doxyfile.%
61         doxygen $<
62
63 if MODULES
64 .PHONY: ldiskfs-sources lustre-sources
65
66 ldiskfs-sources:
67 if LDISKFS_ENABLED
68         $(MAKE) sources -C @LDISKFS_SUBDIR@ || exit $$?
69 endif
70
71 lustre-sources:
72         $(MAKE) sources -C lustre || exit $$?
73
74 if LINUX
75 all-am: modules
76
77 modules: undef.h ldiskfs-sources lustre-sources
78         $(MAKE) CC="$(CC)" -C $(LINUX_OBJ) \
79         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
80         LINUXINCLUDE='-I$$(srctree)/arch/$$(SRCARCH)/include -Iarch/$$(SRCARCH)/include/generated -Iinclude $$(if $$(KBUILD_SRC),-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)' \
81         $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \
82         include/config/MARKER $@
83 endif # LINUX
84
85 endif # MODULES
86
87 undef.h: config.h.in
88         grep -v config.h.in config.h.in > $@
89
90 dist-hook: undef.h
91         find $(distdir) -name .deps -o \
92                         -name CVS -o \
93                         -name .svn -o \
94                         -name .git -o \
95                         -name .#* -exec rm -rf {} \;
96
97 EXTRA_DIST = @PACKAGE_TARNAME@.spec     \
98         build/Makefile                  \
99         build/Rules.in                  \
100         config.h.in                     \
101         undef.h                         \
102         lustre-dkms_pre-build.sh        \
103         lustre-dkms_post-build.sh       \
104         LUSTRE-VERSION-GEN              \
105         LUSTRE-VERSION-FILE
106
107 # contrib is a directory.  Putting a directory in EXTRA_DIST
108 # recursively includes the entire directory contents in the
109 # distribution tarball (the tarball created with "make dist").
110 EXTRA_DIST += contrib
111
112 rpm-local:
113         @(if test -z "$(RPMBUILD)"; then \
114                 echo -e "\n" \
115         "*** Required util 'rpmbuild' missing. Please install the\n" \
116         "*** package for your distribution which provides 'rpmbuild',\n" \
117         "*** re-run configure, and try again.\n"; \
118                 exit 1; \
119         fi; \
120         $(MKDIR_P) $(rpmbuilddir)/TMP   && \
121         $(MKDIR_P) $(rpmbuilddir)/BUILD && \
122         $(MKDIR_P) $(rpmbuilddir)/RPMS  && \
123         $(MKDIR_P) $(rpmbuilddir)/SRPMS && \
124         $(MKDIR_P) $(rpmbuilddir)/SPECS && \
125         $(MKDIR_P) $(rpmbuilddir)/SOURCES)
126
127 if SERVER
128 DKMS_PACKAGE=$(PACKAGE)
129 DKMS_SERVER=--with servers
130 else
131 DKMS_PACKAGE=$(PACKAGE)-client
132 DKMS_SERVER=--without servers
133 endif
134
135 # Only zfs Lustre DKMS Server is supported, so previous configure command
136 # must use related parameters for success.
137 dkms-srpm: $(PACKAGE)-dkms.spec dist Makefile
138         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
139         $(MAKE) $(AM_MAKEFLAGS) \
140                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
141         $(RPMBUILD) \
142                 --define "_tmppath $$rpmbuilddir/TMP" \
143                 --define "_topdir $$rpmbuilddir" \
144                 --define "_sourcedir $(top_srcdir)" \
145                 $(DKMS_SERVER) \
146                 --bs $(PACKAGE)-dkms.spec || exit 1; \
147         cp $$rpmbuilddir/SRPMS/*.src.rpm $(top_srcdir) || exit 1; \
148         rm -rf $$rpmbuilddir
149
150 dkms-rpm: dkms-srpm
151         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
152         $(RPMBUILD) \
153                 --define "_tmppath $$rpmbuilddir/TMP" \
154                 --define "_topdir $$rpmbuilddir" \
155                 @RPMBUILD_BINARY_ARGS@ \
156                 --rebuild $(DKMS_PACKAGE)-dkms-*.src.rpm || exit 1; \
157         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
158         rm -rf $$rpmbuilddir
159
160 rpms: srpm
161         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
162         $(MAKE) $(AM_MAKEFLAGS) \
163                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
164         $(RPMBUILD) \
165                 --define "_tmppath $$rpmbuilddir/TMP" \
166                 --define "_topdir $$rpmbuilddir" \
167                 @RPMBUILD_BINARY_ARGS@ \
168                 --rebuild $(distdir)-*.src.rpm || exit 1; \
169         cp $$rpmbuilddir/RPMS/*/*.rpm $(top_srcdir) || exit 1; \
170         rm -rf $$rpmbuilddir
171
172 srpm: @PACKAGE_TARNAME@.spec dist Makefile
173         rpmbuilddir=`mktemp -t -d rpmbuild-@PACKAGE@-$$USER-XXXXXXXX`; \
174         $(MAKE) $(AM_MAKEFLAGS) \
175                 rpmbuilddir="$$rpmbuilddir" rpm-local || exit 1; \
176         $(RPMBUILD) \
177                 --define "_tmppath $$rpmbuilddir/TMP" \
178                 --define "_topdir $$rpmbuilddir" \
179                 --define "build_src_rpm 1" \
180                 --define "dist %{nil}" \
181                 -ts $(distdir).tar.gz || exit 1; \
182         cp $$rpmbuilddir/SRPMS/$(distdir)-*.src.rpm $(top_srcdir) || exit 1; \
183         rm -rf $$rpmbuilddir
184
185 # In the debs target, first make sure what's in the changelog reflects
186 # the software version.  Here's how we could dig the version out of the
187 # autoconf version file directly:
188 # lversion=$$(sed -ne 's/m4_define(\[LUSTRE_[A-Z][A-Z]*\],\[\([0-9][0-9]*\)\])$$/\1/p'
189 #       lustre/autoconf/lustre-version.ac | tr '\n' '.' | sed -e 's/.$//');
190 #
191 # However, one cannot really run "make debs" without having done a
192 # configure first, so we could use the easier method of digging the
193 # version out of the config.h file.
194 debs: undef.h
195         lversion=$$(sed -ne 's/^#define VERSION "\(.*\)"$$/\1/p' config.h); \
196         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
197         if [ "$$lversion" != "$$cversion" ]; then \
198                 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; \
199         fi; \
200         rm -rf debs
201         dpkg-buildpackage -I.git -I\*.out[0-9]\* -I\*.swp || { \
202                 rc=$${PIPESTATUS[0]}; \
203                 [ $${rc} -gt 1 ] && exit $${rc}; \
204                 exit 0; \
205         }
206         export KPKG_DEST_DIR="$$(pwd)/.." && \
207         version=$$(sed -ne '1s/^lustre (\(.*\)).*$$/\1/p' debian/changelog) && \
208         rm -rf debian/tmp/modules-deb && \
209         mkdir debian/tmp/modules-deb && \
210         pushd debian/tmp/modules-deb && \
211         dpkg -x ../../../../lustre-source_$${version}_all.deb $$(pwd) && \
212         mkdir usr_src/ && \
213         tar -C usr_src/ -xjf usr/src/lustre.tar.bz2 && \
214         chmod 755 usr_src/modules/lustre/debian/rules && \
215         mkdir -p usr_share_modass && \
216         ln -s /usr/share/modass/include/ usr_share_modass/ && \
217         ln -s /usr/share/modass/packages/ usr_share_modass/ && \
218         echo "lustre" > usr_share_modass/compliant.list && \
219         export MA_DIR=$$(pwd)/usr_share_modass && \
220         KVERS=$${KVERS:-$(LINUXRELEASE)} && \
221         if test "x@ENABLEO2IB@" = "xno"; then \
222                 export IB_OPTIONS="--with-o2ib=no"; \
223         else \
224                 if test -n "@O2IBPATH@"; then \
225                         export IB_OPTIONS="--with-o2ib=@O2IBPATH@"; \
226                 fi; \
227         fi; \
228         export KSRC_TREE=$(LINUX) && \
229         KSRC=$${KSRC:-$(LINUX_OBJ)} && \
230         m-a build $${KSRC:+-k $$KSRC} $${KVERS:+-l $$KVERS} -i -u $$(pwd) lustre && \
231         popd && \
232         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog) && \
233         mkdir -p debs && \
234         mv ../linux-patch-lustre_$${VER}_all.deb ../lustre-dev_$${VER}_*.deb \
235            ../lustre-source_$${VER}_all.deb ../lustre-tests_$${VER}_*.deb \
236            ../lustre-utils_$${VER}_*.deb ../lustre_$${VER}.dsc \
237            ../lustre_$${VER}_*.changes ../lustre_$${VER}.tar.gz \
238            ../lustre-client-modules-$${KVERS}_$${VER}_*.deb debs/
239
240 if USES_DPKG
241 EXTRA_DIST += debian/*
242 endif
243
244 CSTK=/tmp/checkstack
245 CSTKO=/tmp/checkstack.orig
246
247 checkstack:
248         [ -f ${CSTK} -a ! -s ${CSTKO} ] && mv -f ${CSTK} ${CSTKO} || true
249         { for MOD in $$(find . -name "*.ko"); do                             \
250                 objdump -d $$MOD | perl contrib/scripts/checkstack.pl;       \
251           done } | grep -v " bug " | sort -nr | uniq > ${CSTK}
252         [ -f ${CSTKO} ] && ! diff -u ${CSTKO} ${CSTK} || head -n 30 ${CSTK}
253
254 checkstack-update:
255         [ -f ${CSTK} ] && mv -f ${CSTK} ${CSTKO}
256
257 checkstack-clean:
258         rm -f ${CSTK} ${CSTKO}