Whamcloud - gitweb
LU-1199 build: fix for configure args with space inside
[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=""; \
101         for arg in $(ac_configure_args); do \
102                 case $$arg in \
103                         --with-release=* ) ;; \
104                         --enable-tests | --disable-tests ) ;; \
105                         --with-linux=* | --with-linux-obj=* ) ;; \
106                         * ) CONFIGURE_ARGS="$$CONFIGURE_ARGS '$$arg'" ;; \
107                 esac; \
108         done; \
109         RPMARGS="--define \"configure_args $$CONFIGURE_ARGS\""; \
110         if [ -n "@LINUX@" ]; then  \
111                 RPMARGS="$$RPMARGS --define \"kdir @LINUX@\""; \
112                 if [ -n "@LINUX_OBJ@" -a "@LINUX_OBJ@" != "@LINUX@" ]; then \
113                         RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
114                 fi; \
115         fi; \
116         if [ -n "@CROSS_PATH@" ]; then \
117                 if [[ "X$(BUILD_SERVER)" = Xtrue ]]; then \
118                         echo -e "\n" \
119                         "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"; \
120                         exit 1; \
121                 fi; \
122                 CROSS_SUFFIX="-mic"; \
123                 RPMARGS="$$RPMARGS --define \"post_script build/gen_filelist.sh\""; \
124                 RPMARGS="$$RPMARGS --define \"cross_path @CROSS_PATH@\""; \
125                 RPMARGS="$$RPMARGS --define \"rootdir %{cross_path}\""; \
126                 RPMARGS="$$RPMARGS --define \"_prefix %{cross_path}/usr\""; \
127                 RPMARGS="$$RPMARGS --define \"_mandir %{_prefix}/share/man\""; \
128                 RPMARGS="$$RPMARGS --define \"_sysconfdir %{cross_path}/etc\""; \
129                 RPMARGS="$$RPMARGS --define \"make_args @CROSS_VARS@\""; \
130                 if [ -s @LINUX@/../../.ver.build ]; then \
131                         MPSS_VERSION=$$(sed -ne 's/DRIVERS_\(.*\)-.*/\1/p' @LINUX@/../../.ver.build); \
132                         if [ -n "$$MPSS_VERSION" ]; then \
133                                 RPMARGS="$$RPMARGS --define \"cross_requires intel-mic-gpl = 2.1.$$MPSS_VERSION\""; \
134                         fi; \
135                 fi; \
136         fi; \
137         if [[ "X$(BUILD_TESTS)" = Xfalse ]]; then \
138                 RPMARGS="$$RPMARGS --without lustre_tests"; \
139         fi; \
140         if [[ "X$(BUILD_SERVER)" = Xfalse ]]; then \
141                 RPMARGS="$$RPMARGS --without servers"; \
142                 if [ -n "$$CROSS_SUFFIX" ]; then \
143                         RPMARGS="$$RPMARGS --define \"lustre_name lustre-client$$CROSS_SUFFIX\""; \
144                 fi; \
145         fi; \
146         if [[ "X$(BUILD_OSD_LDISKFS)" = Xtrue ]]; then \
147                 RPMARGS="$$RPMARGS --with ldiskfs"; \
148         fi; \
149         if [[ "X$(BUILD_OSD_ZFS)" = Xtrue ]]; then \
150                 RPMARGS="$$RPMARGS --with zfs"; \
151         fi; \
152         echo "Building Lustre RPM with $$RPMARGS"; \
153         eval rpmbuild $$RPMARGS -ta $(distdir).tar.gz
154
155 srpm-real: @PACKAGE_TARNAME@.spec dist Makefile
156         if [[ "X$(BUILD_TESTS)" = Xfalse ]]; then \
157                 RPMARGS="--without lustre_tests"; \
158         fi; \
159         eval rpmbuild $$RPMARGS -ts $(distdir).tar.gz
160
161 rpms:
162 if BUILD_LUSTREIOKIT
163         $(MAKE) -C @LUSTREIOKIT_SUBDIR@ $(AM_MAKEFLAGS) $@
164 endif
165         $(MAKE) $(AM_MAKEFLAGS) rpms-real
166
167 srpm:
168 if BUILD_LUSTREIOKIT
169         $(MAKE) -C @LUSTREIOKIT_SUBDIR@ $(AM_MAKEFLAGS) $@
170 endif
171         $(MAKE) $(AM_MAKEFLAGS) srpm-real
172
173 # In the debs target, first make sure what's in the changelog reflects
174 # the software version.  Here's how we could dig the version out of the
175 # autoconf version file directly:
176 # lversion=$$(sed -ne 's/m4_define(\[LUSTRE_[A-Z][A-Z]*\],\[\([0-9][0-9]*\)\])$$/\1/p'
177 #       lustre/autoconf/lustre-version.ac | tr '\n' '.' | sed -e 's/.$//');
178 #
179 # However, one cannot really run "make debs" without having done a
180 # configure first, so we could use the easier method of digging the
181 # version out of the config.h file.
182 debs:
183         lversion=$$(sed -ne 's/^#define VERSION "\(.*\)"$$/\1/p' config.h); \
184         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
185         if [ "$$lversion" != "$$cversion" ]; then \
186                 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; \
187         fi; \
188         rm -rf debs
189         dpkg-buildpackage -I.git -I\*.out[0-9]\* -I\*.swp || { \
190                 rc=$${PIPESTATUS[0]}; \
191                 [ $${rc} -gt 1 ] && exit $${rc}; \
192                 exit 0; \
193         }
194         export KPKG_DEST_DIR="$$(pwd)/.." && \
195         version=$$(sed -ne '1s/^lustre (\(.*\)).*$$/\1/p' debian/changelog) && \
196         rm -rf debian/tmp/modules-deb && \
197         mkdir debian/tmp/modules-deb && \
198         pushd debian/tmp/modules-deb && \
199         dpkg -x ../../../../lustre-source_$${version}_all.deb $$(pwd) && \
200         mkdir usr_src/ && \
201         tar -C usr_src/ -xjf usr/src/lustre.tar.bz2 && \
202         chmod 755 usr_src/modules/lustre/debian/rules && \
203         mkdir -p usr_share_modass && \
204         ln -s /usr/share/modass/include/ usr_share_modass/ && \
205         ln -s /usr/share/modass/packages/ usr_share_modass/ && \
206         echo "lustre" > usr_share_modass/compliant.list && \
207         export MA_DIR=$$(pwd)/usr_share_modass && \
208         KVERS=$${KVERS:-$(LINUXRELEASE)}; \
209         m-a build $${KVERS:+-l $$KVERS} -i -u $$(pwd) lustre && \
210         popd && \
211         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog); \
212         mkdir -p debs && \
213         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/
214
215 EXTRA_DIST += config.h.in
216
217 if USES_DPKG
218 EXTRA_DIST += debian/*
219 endif
220
221 module-symvers-zfs:
222 if ZFS_ENABLED
223         @if [ -f @SPL_OBJ@/@SPL_SYMBOLS@ ]; then \
224                 cat @SPL_OBJ@/@SPL_SYMBOLS@ >>@SYMVERFILE@; \
225         elif [ -f @SPL_OBJ@/module/@SPL_SYMBOLS@ ]; then \
226                 cat @SPL_OBJ@/module/@SPL_SYMBOLS@ >>@SYMVERFILE@; \
227         else \
228                 echo -e "\n" \
229                 "*** Missing spl symbols. Ensure you have built spl:\n" \
230                 "*** - @SPL_OBJ@/@SYMVERFILE@\n"; \
231                 exit 1; \
232         fi
233         @if [ -f @ZFS_OBJ@/@ZFS_SYMBOLS@ ]; then \
234                 cat @ZFS_OBJ@/@ZFS_SYMBOLS@ >>@SYMVERFILE@; \
235         elif [ -f @ZFS_OBJ@/module/@ZFS_SYMBOLS@ ]; then \
236                 cat @ZFS_OBJ@/module/@ZFS_SYMBOLS@ >>@SYMVERFILE@; \
237         else \
238                 echo -e "\n" \
239                 "*** Missing zfs symbols. Ensure you have built zfs:\n" \
240                 "*** - @ZFS_OBJ@/@SYMVERFILE@\n"; \
241                 exit 1; \
242         fi
243 endif # ZFS_ENABLED
244
245 module-symvers: module-symvers-zfs
246
247 CSTK=/tmp/checkstack
248 CSTKO=/tmp/checkstack.orig
249
250 checkstack:
251         [ -f ${CSTK} -a ! -s ${CSTKO} ] && mv -f ${CSTK} ${CSTKO} || true
252         { for MOD in $$(find . -name "*.ko"); do                             \
253                 objdump -d $$MOD | perl contrib/scripts/checkstack.pl;       \
254           done } | grep -v " bug " | sort -nr | uniq > ${CSTK}
255         [ -f ${CSTKO} ] && ! diff -u ${CSTKO} ${CSTK} || head -30 ${CSTK}
256
257 checkstack-update:
258         [ -f ${CSTK} ] && mv -f ${CSTK} ${CSTKO}
259
260 checkstack-clean:
261         rm -f ${CSTK} ${CSTKO}
262
263 module-dist-hook:
264         if [ -d CVS -o -d .git ]; then \
265                 perl lustre/scripts/make_META.pl > $(distdir)/META; \
266         elif [ -f META ]; then \
267                 cp META $(distdir)/META; \
268         else \
269                 echo -e "I have no idea how to create a META file in $(distdir).\nPlease file a bug at http://bugzilla.lustre.org/"; \
270                 exit 1; \
271         fi