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