Whamcloud - gitweb
b=22281 refactor packaging and versioning
[fs/lustre-release.git] / build / autoMakefile.am.toplevel
1 # This file is included by each package's toplevel autoMakefile[.am],
2 # which must define SUBDIRS as a minimum.
3
4 AUTOMAKE_OPTIONS = foreign
5
6 FIND_TAG_FILES_CMD = find $(top_srcdir) \
7                      -path $(top_srcdir)/ldiskfs/ldiskfs/linux-stage -prune -false -o\
8                      -type f -name '*.[hc]'
9
10 # these empty rules are needed so that automake doesn't add its own
11 # recursive rules
12 etags-recursive:
13
14 ctags-recursive:
15
16 tags-recursive:
17
18 TAGS: etags
19
20 tags: ctags etags
21
22 etags:
23         $(RM) $(top_srcdir)/TAGS
24         ETAGSF=`etags --version | grep -iq exuberant && \
25                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
26         $(FIND_TAG_FILES_CMD) | xargs etags $$ETAGSF -a
27
28 ctags:
29         $(RM) $(top_srcdir)/tags
30         CTAGSF=`ctags --version | grep -iq exuberant && \
31                 echo "-I __initdata,__exitdata,EXPORT_SYMBOL"`; \
32         $(FIND_TAG_FILES_CMD) | xargs ctags $$CTAGSF -a
33
34 cscope-recursive:
35
36 cscope:
37         $(RM) $(top_srcdir)/cscope*.out $(top_srcdir)/cscope.files
38         $(FIND_TAG_FILES_CMD) > cscope.files
39         cscope -bRq
40
41 mkid:
42         $(FIND_TAG_FILES_CMD) | xargs mkid
43
44
45 doxygen:  doxygen-api doxygen-ref
46
47 doxygen-%: build/doxyfile.%
48            doxygen $<
49
50 if MODULES
51 sources: all-sources
52
53 all-sources: $(EXTRA_SOURCES)
54         for dir in $(SOURCES_SUBDIRS) ; do \
55                 $(MAKE) sources -C $$dir || exit $$? ; \
56         done
57
58 if LINUX
59 all-am: modules
60
61 if !LINUX25
62 DEP = dep
63 dep: .depend
64
65 .depend: all-sources
66         $(MAKE) $(ARCH_UM) CC="$(CC)" -C $(LINUX_OBJ)                \
67         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
68         -o scripts -o include/config/MARKER _sfdep_$(PWD)            \
69         _FASTDEP_ALL_SUB_DIRS="$(PWD)"
70
71 CLEANFILES = .depend
72 endif # !LINUX25
73
74 modules: $(DEP) all-sources
75         $(MAKE) $(ARCH_UM) CC="$(CC)" -C $(LINUX_OBJ)                \
76         -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \
77         LINUXINCLUDE='$(EXTRA_LNET_INCLUDE) -I$$(srctree)/arch/$$(SRCARCH)/include -Iinclude $$(if $$(KBUILD_SRC),-Iinclude2 -I$$(srctree)/include) -include include/linux/autoconf.h' \
78         $(MODULE_TARGET)=$(PWD) -o tmp_include_depends -o scripts -o \
79         include/config/MARKER $@
80 endif # LINUX
81
82 endif # MODULES
83
84 dist-hook:
85         $(RM) $(distdir)/ldiskfs/*.spec
86         $(RM) $(distdir)/lustre-iokit/*.spec
87         find $(distdir) -name .deps -o \
88                         -name CVS -o \
89                         -name .svn -o \
90                         -name .git -o \
91                         -name .#* | xargs rm -rf
92         $(MAKE) $(AM_MAKEFLAGS) \
93           top_distdir="$(top_distdir)" distdir="$(distdir)" \
94           module-dist-hook
95
96 EXTRA_DIST = @PACKAGE_TARNAME@.spec                                     \
97         build/Makefile build/autoMakefile.am.toplevel build/lbuild      \
98         build/Rules.in                                                  \
99         build/update_oldconfig                                          \
100         build/autoconf/lustre-build-linux.m4                            \
101         build/autoconf/lustre-build-darwin.m4                           \
102         build/autoconf/lustre-build.m4 build/rdac_spec                  \
103         build/mptlinux.spec.patch build/patches
104
105 rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
106         CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | sed -re 's/--(en|dis)able-tests//'); \
107         if [ -n "@LINUX@" ]; then \
108                 CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-linux=[^ ][^ ]*//'); \
109                 RPMARGS="--define \"kdir @LINUX@\""; \
110                 CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-linux-obj=[^ ][^ ]*//'); \
111                 if [ -n "@LINUX_OBJ@" -a "@LINUX_OBJ@" != "@LINUX@" ]; then \
112                         RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
113                 fi; \
114         fi; \
115         CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-release=[^ ][^ ]*//'); \
116         RPMARGS="$$RPMARGS --define \"configure_args $$CONFIGURE_ARGS\""; \
117         if ! $(BUILD_TESTS); then \
118                 RPMARGS="$$RPMARGS --define \"build_lustre_tests 0\""; \
119         fi; \
120         echo "Building Lustre RPM with $$RPMARGS"; \
121         eval rpmbuild $$RPMARGS -ta $(distdir).tar.gz
122
123 srpm-real: @PACKAGE_TARNAME@.spec dist Makefile
124         if ! $(BUILD_TESTS); then \
125                 RPMARGS="--define \"build_lustre_tests 0\""; \
126         fi; \
127         eval rpmbuild $$RPMARGS -ta $(distdir).tar.gz
128
129 rpms:
130         for subdir in $(RPM_SUBDIRS) ; do                               \
131                 echo "Making rpms in $$subdir";                         \
132                 (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) rpms);          \
133                 echo "Finished rpms in $$subdir";                       \
134         done;                                                           \
135         $(MAKE) $(AM_MAKEFLAGS) rpms-real
136
137 srpm:
138         for subdir in $(RPM_SUBDIRS) ; do                               \
139                 echo "Making srpm in $$subdir";                         \
140                 (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) srpm);          \
141                 echo "Finished srpms in $$subdir";                      \
142         done;                                                           \
143         $(MAKE) $(AM_MAKEFLAGS) srpm-real
144
145 # In the debs target, first make sure what's in the changelog reflects
146 # the software version.  Here's how we could dig the version out of the
147 # autoconf version file directly:
148 # lversion=$$(sed -ne 's/m4_define(\[LUSTRE_[A-Z][A-Z]*\],\[\([0-9][0-9]*\)\])$$/\1/p'
149 #       lustre/autoconf/lustre-version.ac | tr '\n' '.' | sed -e 's/.$//');
150 #
151 # However, one cannot really run "make debs" without having done a
152 # configure first, so we could use the easier method of digging the
153 # version out of the config.h file.
154 debs:
155         lversion=$$(sed -ne 's/^#define VERSION "\(.*\)"$$/\1/p' config.h); \
156         cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \
157         if [ "$$lversion" != "$$cversion" ]; then \
158                 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; \
159         fi; \
160         if [ -d .git ]; then \
161                 ver=$$(git describe --match [0-9v]\* --tags); \
162                 if [[ $$ver = *-*-* ]]; then \
163                         hash=$${ver##*-}; \
164                         ffw=$${ver#*-}; \
165                         ffw=$${ffw%-*}; \
166                         ver=$${ver%%-*}; \
167                 fi; \
168                 if [ $$ffw -gt 0 ]; then \
169                         tag=$$ver; \
170                         if [[ $$ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$$ ]]; then \
171                                 ver=$$(echo $$ver | \
172                                   sed -e 's/^v\(.*\)/\1/' \
173                                       -e 's/_RC[[0-9]].*$$//' \
174                                       -e 's/_/./g'); \
175                         fi; \
176                         pdir="debian/patches"; \
177                         if [ -d $$pdir ]; then \
178                                 rm -rf $$pdir; \
179                         fi; \
180                         mkdir $$pdir; \
181                         git format-patch -o $$pdir $$tag..HEAD; \
182                         pushd $$pdir; \
183                         if [ -d ../patched ]; then \
184                                 rm -rf ../patched; \
185                         fi; \
186                         mkdir ../patched; \
187                         rm -f 00list *.dpatch; \
188                         for file in [0-9][0-9][0-9][0-9]-*.patch; do \
189                                 if ! grep -q "^ debian/changelog" $$file; then \
190                                         desc=$$(cat $$file | sed -e '1,/^$$/d' \
191                                                                  -e '/^---$$/,$$d'); \
192                                         dpatch_file=$${file/.patch/.dpatch}; \
193                                         sed -e '1,/^---$$/d' $$file | \
194                                           dpatch patch-template -p "$${file%.patch}" \
195                                           "$$desc" > $$dpatch_file; \
196                                         echo "faked by make debs run from git" > \
197                                           ../patched/$$dpatch_file; \
198                                         echo $$dpatch_file >> 00list; \
199                                 fi; \
200                                 rm -f $$file; \
201                         done; \
202                 fi; \
203         fi
204         rm -rf debs
205         dpkg-buildpackage || { \
206                 rc=$${PIPESTATUS[0]}; \
207                 [ $${rc} -gt 1 ] && exit $${rc}; \
208                 exit 0; \
209         }
210         export KPKG_DEST_DIR="$$(pwd)/.." && \
211         version=$$(sed -ne '1s/^lustre (\(.*\)).*$$/\1/p' debian/changelog) && \
212         rm -rf debian/tmp/modules-deb && \
213         mkdir debian/tmp/modules-deb && \
214         pushd debian/tmp/modules-deb && \
215         dpkg -x ../../../../lustre-source_$${version}_all.deb $$(pwd) && \
216         mkdir usr_src/ && \
217         tar -C usr_src/ -xjf usr/src/lustre.tar.bz2 && \
218         chmod 755 usr_src/modules/lustre/debian/rules && \
219         mkdir -p usr_share_modass && \
220         ln -s /usr/share/modass/include/ usr_share_modass/ && \
221         ln -s /usr/share/modass/packages/ usr_share_modass/ && \
222         echo "lustre" > usr_share_modass/compliant.list && \
223         export MA_DIR=$$(pwd)/usr_share_modass && \
224         KVERS=$${KVERS:-$(LINUXRELEASE)}; \
225         m-a build $${KVERS:+-l $$KVERS} -i -u $$(pwd) lustre && \
226         popd && \
227         VER=$$(sed -ne '1s/^lustre (\(.*-[0-9][0-9]*\)).*$$/\1/p' debian/changelog); \
228         mkdir -p debs && \
229         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}.tar.gz ../lustre-client-modules-$${KVERS}_$${VER}_*.deb debs/