Whamcloud - gitweb
LU-3462 ldiskfs: Subsume ldiskfs's build system into lustre
[fs/lustre-release.git] / autoMakefile.am
1 SUBDIRS := @LDISKFS_SUBDIR@ . @LIBSYSIO_SUBDIR@ @SNMP_SUBDIR@ @LUSTREIOKIT_SUBDIR@ @LIBCFS_SUBDIR@ lnet lustre
2 DIST_SUBDIRS := ldiskfs @SNMP_DIST_SUBDIR@ libsysio lustre-iokit @LIBCFS_SUBDIR@ lnet lustre config contrib
3
4 @TESTS_TRUE@BUILD_TESTS = true
5 @TESTS_FALSE@BUILD_TESTS = false
6 @SERVER_TRUE@BUILD_SERVER = true
7 @SERVER_FALSE@BUILD_SERVER = false
8 @CLIENT_TRUE@BUILD_CLIENT = true
9 @CLIENT_FALSE@BUILD_CLIENT = false
10 @LDISKFS_ENABLED_TRUE@BUILD_OSD_LDISKFS = true
11 @LDISKFS_ENABLED_FALSE@BUILD_OSD_LDISKFS = false
12 @ZFS_ENABLED_TRUE@BUILD_OSD_ZFS = true
13 @ZFS_ENABLED_FALSE@BUILD_OSD_ZFS = false
14
15 AUTOMAKE_OPTIONS = foreign
16
17 FIND_TAG_FILES_CMD = find $(top_srcdir) \
18                      -path $(top_srcdir)/ldiskfs/linux-stage \
19                      -prune -false -o -type f -name '*.[hc]'
20
21 # these empty rules are needed so that automake doesn't add its own
22 # recursive rules
23 etags-recursive:
24
25 ctags-recursive:
26
27 tags-recursive:
28
29 TAGS: etags
30
31 tags: ctags etags
32
33 etags:
34         $(RM) $(top_srcdir)/TAGS
35         ETAGSF=`etags --version | grep -iq exuberant && \
36                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
37         $(FIND_TAG_FILES_CMD) | xargs etags $$ETAGSF -a
38
39 ctags:
40         $(RM) $(top_srcdir)/tags
41         CTAGSF=`ctags --version | grep -iq exuberant && \
42                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
43         $(FIND_TAG_FILES_CMD) | xargs ctags $$CTAGSF -a
44
45 cscope-recursive:
46
47 cscope:
48         $(RM) $(top_srcdir)/cscope*.out $(top_srcdir)/cscope.files
49         $(FIND_TAG_FILES_CMD) > cscope.files
50         cscope -bRq
51
52 mkid:
53         $(FIND_TAG_FILES_CMD) | xargs mkid
54
55
56 doxygen:  doxygen-api doxygen-ref
57
58 doxygen-%: build/doxyfile.%
59         doxygen $<
60
61 if MODULES
62 sources: all-sources
63
64 all-sources: module-symvers
65         $(MAKE) sources -C lustre || exit $$?
66
67 if LINUX
68 all-am: modules
69
70 modules: $(DEP) all-sources
71         $(MAKE) CC="$(CC)" $(CROSS_VARS) -C $(LINUX_OBJ)             \
72         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
73         LINUXINCLUDE='$(EXTRA_LNET_INCLUDE) -I$$(srctree)/arch/$$(SRCARCH)/include -I$$(srctree)/arch/$$(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)' \
74         $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \
75         include/config/MARKER $@
76 endif # LINUX
77
78 endif # MODULES
79
80 dist-hook:
81         $(RM) $(distdir)/lustre-iokit/*.spec
82         find $(distdir) -name .deps -o \
83                         -name CVS -o \
84                         -name .svn -o \
85                         -name .git -o \
86                         -name .#* | xargs rm -rf
87         $(MAKE) $(AM_MAKEFLAGS) \
88           top_distdir="$(top_distdir)" distdir="$(distdir)" \
89           module-dist-hook
90
91 EXTRA_DIST = @PACKAGE_TARNAME@.spec                                     \
92         build/Makefile                                                  \
93         build/Rules.in
94
95 if ARCH_MIC
96 EXTRA_DIST += build/gen_filelist.sh
97 endif
98
99 rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
100         CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | \
101                 sed -re 's/--(en|dis)able-tests//'); \
102         if [ -n "@LINUX@" ]; then \
103                 CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
104                         sed -re 's/--with-linux=[^ ][^ ]*//'); \
105                 RPMARGS="--define \"kdir @LINUX@\""; \
106                 CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
107                         sed -re 's/--with-linux-obj=[^ ][^ ]*//'); \
108                 if [ -n "@LINUX_OBJ@" -a "@LINUX_OBJ@" != "@LINUX@" ]; then \
109                         RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
110                 fi; \
111         fi; \
112         if [ -n "@CROSS_PATH@" ]; then \
113                 if [[ "X$(BUILD_SERVER)" = Xtrue ]]; then \
114                         echo -e "\n" \
115                         "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"; \
116                         exit 1; \
117                 fi; \
118                 CROSS_SUFFIX="-mic"; \
119                 RPMARGS="$$RPMARGS --define \"post_script build/gen_filelist.sh\""; \
120                 RPMARGS="$$RPMARGS --define \"cross_path @CROSS_PATH@\""; \
121                 RPMARGS="$$RPMARGS --define \"rootdir %{cross_path}\""; \
122                 RPMARGS="$$RPMARGS --define \"_prefix %{cross_path}/usr\""; \
123                 RPMARGS="$$RPMARGS --define \"_mandir %{_prefix}/share/man\""; \
124                 RPMARGS="$$RPMARGS --define \"_sysconfdir %{cross_path}/etc\""; \
125                 RPMARGS="$$RPMARGS --define \"make_args @CROSS_VARS@\""; \
126                 if [ -s @LINUX@/../../.ver.build ]; then \
127                         MPSS_VERSION=$$(sed -ne 's/DRIVERS_\(.*\)-.*/\1/p' @LINUX@/../../.ver.build); \
128                         if [ -n "$$MPSS_VERSION" ]; then \
129                                 RPMARGS="$$RPMARGS --define \"cross_requires intel-mic-gpl = 2.1.$$MPSS_VERSION\""; \
130                         fi; \
131                 fi; \
132         fi; \
133         CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
134                 sed -re 's/--with-release=[^ ][^ ]*//'); \
135         RPMARGS="$$RPMARGS --define \"configure_args $$CONFIGURE_ARGS\""; \
136         if [[ "X$(BUILD_TESTS)" = Xfalse ]]; then \
137                 RPMARGS="$$RPMARGS --without lustre_tests"; \
138         fi; \
139         if [[ "X$(BUILD_SERVER)" = Xfalse ]]; then \
140                 RPMARGS="$$RPMARGS --without servers"; \
141                 if [ -n "@CROSS_PATH@" ]; then \
142                         RPMARGS="$$RPMARGS --define \"lustre_name lustre-client$$CROSS_SUFFIX\""; \
143                 fi; \
144         fi; \
145         if [[ "X$(BUILD_OSD_LDISKFS)" = Xtrue ]]; then \
146                 RPMARGS="$$RPMARGS --with ldiskfs"; \
147         fi; \
148         if [[ "X$(BUILD_OSD_ZFS)" = Xtrue ]]; then \
149                 RPMARGS="$$RPMARGS --with zfs"; \
150         fi; \
151         echo "Building Lustre RPM with $$RPMARGS"; \
152         eval rpmbuild $$RPMARGS -ta $(distdir).tar.gz
153
154 srpm-real: @PACKAGE_TARNAME@.spec dist Makefile
155         if [[ "X$(BUILD_TESTS)" = Xfalse ]]; then \
156                 RPMARGS="--without lustre_tests"; \
157         fi; \
158         eval rpmbuild $$RPMARGS -ts $(distdir).tar.gz
159
160 rpms:
161 if BUILD_LUSTREIOKIT
162         $(MAKE) -C @LUSTREIOKIT_SUBDIR@ $(AM_MAKEFLAGS) $@
163 endif
164         $(MAKE) $(AM_MAKEFLAGS) rpms-real
165
166 srpm:
167 if BUILD_LUSTREIOKIT
168         $(MAKE) -C @LUSTREIOKIT_SUBDIR@ $(AM_MAKEFLAGS) $@
169 endif
170         $(MAKE) $(AM_MAKEFLAGS) srpm-real
171
172 # In the debs target, first make sure what's in the changelog reflects
173 # the software version.  Here's how we could dig the version out of the
174 # autoconf version file directly:
175 # lversion=$$(sed -ne 's/m4_define(\[LUSTRE_[A-Z][A-Z]*\],\[\([0-9][0-9]*\)\])$$/\1/p'
176 #       lustre/autoconf/lustre-version.ac | tr '\n' '.' | sed -e 's/.$//');
177 #
178 # However, one cannot really run "make debs" without having done a
179 # configure first, so we could use the easier method of digging the
180 # version out of the config.h file.
181 debs:
182         lversion=$$(sed -ne 's/^#define VERSION "\(.*\)"$$/\1/p' config.h); \
183         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
184         if [ "$$lversion" != "$$cversion" ]; then \
185                 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; \
186         fi; \
187         rm -rf debs
188         dpkg-buildpackage -I.git -I\*.out[0-9]\* -I\*.swp || { \
189                 rc=$${PIPESTATUS[0]}; \
190                 [ $${rc} -gt 1 ] && exit $${rc}; \
191                 exit 0; \
192         }
193         export KPKG_DEST_DIR="$$(pwd)/.." && \
194         version=$$(sed -ne '1s/^lustre (\(.*\)).*$$/\1/p' debian/changelog) && \
195         rm -rf debian/tmp/modules-deb && \
196         mkdir debian/tmp/modules-deb && \
197         pushd debian/tmp/modules-deb && \
198         dpkg -x ../../../../lustre-source_$${version}_all.deb $$(pwd) && \
199         mkdir usr_src/ && \
200         tar -C usr_src/ -xjf usr/src/lustre.tar.bz2 && \
201         chmod 755 usr_src/modules/lustre/debian/rules && \
202         mkdir -p usr_share_modass && \
203         ln -s /usr/share/modass/include/ usr_share_modass/ && \
204         ln -s /usr/share/modass/packages/ usr_share_modass/ && \
205         echo "lustre" > usr_share_modass/compliant.list && \
206         export MA_DIR=$$(pwd)/usr_share_modass && \
207         KVERS=$${KVERS:-$(LINUXRELEASE)}; \
208         m-a build $${KVERS:+-l $$KVERS} -i -u $$(pwd) lustre && \
209         popd && \
210         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog); \
211         mkdir -p debs && \
212         mv ../liblustre_$${VER}_*.deb ../linux-patch-lustre_$${VER}_all.deb ../lustre-dev_$${VER}_*.deb ../lustre-source_$${VER}_all.deb ../lustre-tests_$${VER}_*.deb ../lustre-utils_$${VER}_*.deb ../lustre_$${VER}.dsc ../lustre_$${VER}_*.changes ../lustre_$${VER%-[0-9]*}.orig.tar.gz ../lustre_$${VER}.diff.gz ../lustre-client-modules-$${KVERS}_$${VER}_*.deb debs/
213
214 EXTRA_DIST += config.h.in
215
216 if USES_DPKG
217 EXTRA_DIST += debian/*
218 endif
219
220 module-symvers-zfs:
221 if ZFS_ENABLED
222         @if [ -f @SPL_OBJ@/@SPL_SYMBOLS@ ]; then \
223                 cat @SPL_OBJ@/@SPL_SYMBOLS@ >>@SYMVERFILE@; \
224         elif [ -f @SPL_OBJ@/module/@SPL_SYMBOLS@ ]; then \
225                 cat @SPL_OBJ@/module/@SPL_SYMBOLS@ >>@SYMVERFILE@; \
226         else \
227                 echo -e "\n" \
228                 "*** Missing spl symbols. Ensure you have built spl:\n" \
229                 "*** - @SPL_OBJ@/@SYMVERFILE@\n"; \
230                 exit 1; \
231         fi
232         @if [ -f @ZFS_OBJ@/@ZFS_SYMBOLS@ ]; then \
233                 cat @ZFS_OBJ@/@ZFS_SYMBOLS@ >>@SYMVERFILE@; \
234         elif [ -f @ZFS_OBJ@/module/@ZFS_SYMBOLS@ ]; then \
235                 cat @ZFS_OBJ@/module/@ZFS_SYMBOLS@ >>@SYMVERFILE@; \
236         else \
237                 echo -e "\n" \
238                 "*** Missing zfs symbols. Ensure you have built zfs:\n" \
239                 "*** - @ZFS_OBJ@/@SYMVERFILE@\n"; \
240                 exit 1; \
241         fi
242 endif # ZFS_ENABLED
243
244 module-symvers: module-symvers-zfs
245
246 CSTK=/tmp/checkstack
247 CSTKO=/tmp/checkstack.orig
248
249 checkstack:
250         [ -f ${CSTK} -a ! -s ${CSTKO} ] && mv -f ${CSTK} ${CSTKO} || true
251         { for MOD in $$(find . -name "*.ko"); do                             \
252                 objdump -d $$MOD | perl contrib/scripts/checkstack.pl;       \
253           done } | grep -v " bug " | sort -nr | uniq > ${CSTK}
254         [ -f ${CSTKO} ] && ! diff -u ${CSTKO} ${CSTK} || head -30 ${CSTK}
255
256 checkstack-update:
257         [ -f ${CSTK} ] && mv -f ${CSTK} ${CSTKO}
258
259 checkstack-clean:
260         rm -f ${CSTK} ${CSTKO}
261
262 module-dist-hook:
263         if [ -d CVS -o -d .git ]; then \
264                 perl lustre/scripts/make_META.pl > $(distdir)/META; \
265         elif [ -f META ]; then \
266                 cp META $(distdir)/META; \
267         else \
268                 echo -e "I have no idea how to create a META file in $(distdir).\nPlease file a bug at http://bugzilla.lustre.org/"; \
269                 exit 1; \
270         fi