permit multiline comments and strings in macros
[bpt/coccinelle.git] / Makefile.release
1
2 ##############################################################################
3 # Release rules to generate website archives
4 ##############################################################################
5
6 PACKAGE=$(PRJNAME)-$(VERSION)
7 CCPACKAGE=coccicheck-$(CCVERSION)
8
9 EXCLUDE=$(PACKAGE)/debian .depend
10
11 DOC=docs/manual/manual.pdf \
12 docs/manual/options.pdf \
13 docs/manual/main_grammar.pdf \
14 docs/html \
15 docs/man \
16 docs/spatch.1 \
17 docs/manual/cocci-python.txt
18 BINSRC=spatch* env.sh env.csh standard.h standard.iso \
19 *.txt $(DOC) demos/* scripts/spatch*
20 BINSRC-PY=$(BINSRC) $(PYLIB) python/coccilib/
21
22 EXCL=$(EXCLUDE:%=--exclude=%)
23 BINSRC2=$(BINSRC:%=$(PACKAGE)/%)
24 BINSRC2-PY=$(BINSRC-PY:%=$(PACKAGE)/%)
25
26 # TMP should point to a folder that is private to the release
27 # process. In addition, it should not be the direct parent of
28 # the directory in which the release is performed, because it
29 # creates temporary directories that in this case could have
30 # a name clash with the current directory.
31 ifndef TMP
32 TMP=/var/tmp
33 endif
34
35 # should be defined by Makefile.config
36 ifndef OCAMLVERSION
37 OCAMLVERSION=$(shell ocaml -version |perl -p -e 's/.*version (.*)/$$1/;')
38 endif
39
40 # can be overriden in the environment
41 ifndef GIT
42 GIT=git
43 endif
44
45 # the release process rewrites the Makefile.config, so we need
46 # to save important configure flags.
47 remember_ocamlbuild:=$(FEATURE_OCAMLBUILD)
48
49 ifeq ($(remember_ocamlbuild),yes)
50 extra_configure_flags := --enable-ocamlbuild
51 else
52 extra_configure_flags :=
53 endif
54
55
56
57 # Procedure to do first time:
58 # cd ~/release
59 # git clone ... coccinelle
60 # cd coccinelle
61 #
62 # Procedure to do each time:
63 #
64 # 1) make prerelease # WARN: These will clean your local rep. of pending modifications
65 #
66 # UPDATE VERSION number in ./version
67 # and commit it with
68 #
69 # 2) make release
70 #
71 # The project is then automatically licensified.
72 #
73 # 3) make package
74 #
75 # if WEBSITE is set properly, you can also run 'make website'
76 # Check that run an ocaml in /usr/bin
77
78 # The 'git rebase' is in there just in case you started with
79 # unpushed changes. However, that is probably something you should
80 # not do in the first place.
81
82 release-help:
83 @echo "To make a release, perform the following steps:"
84 @echo ""
85 @echo "1. Make sure that all changes are committed and pushed."
86 @echo " (making a release will destroy any uncommitted changes)"
87 @echo " Preferably, start from a fresh clone of the coccinelle repo."
88 @echo "2. Run 'make prerelease'. It will generate some files that are not"
89 @echo " in the repository but part of the release tarballs."
90 @echo "3. Edit ./version. It must be a new version."
91 @echo "4. Run 'make release'. It makes changes to the git repository that"
92 @echo " are not idempotent. Running this step again is likely to result"
93 @echo " in some git errors. These are not dramatic and are therefore"
94 @echo " ignored."
95 @echo "5. Run 'make package'. It will build many tarballs."
96 @echo "6. Run 'make website'. Make sure that $(WEBBASE) exists beforehand."
97 @echo " Hint: run step 5 and 6 directly after each other. The tarballs"
98 @echo " are stored temporarily in $(TMP)."
99 @echo "7. Updated some webpages and commit them to svn."
100
101 prerelease:
102 @echo "pulling changes from the repository"
103 $(GIT) pull --rebase
104 $(MAKE) fix-expected
105 $(MAKE) distclean KEEP_CONFIG=1
106 @echo "\n\tEdit ./version"
107 @echo "\tCommit with 'make release'\n"
108 @echo "\t* set the GIT env variable to 'echo' to skip performing any git commands"
109 @echo "\t* changes to files other than ./version will not be committed automatically."
110
111 fix-expected:
112 @echo "going to generate: tests/SCORE_expected_orig.sexp"
113 $(MAKE) distclean
114 ./configure --enable-release --disable-python $(extra_configure_flags)
115 $(MAKE) opt-only
116 yes | ./spatch.opt -testall --iso-file ./standard.iso --macro-file-builtins ./standard.h
117 cp tests/SCORE_actual.sexp tests/SCORE_expected_orig.sexp
118 @echo "generated: test/SCORE_expected_orig.sexp"
119
120 release:
121 @echo "Marking version: $(VERSION)"
122 echo -n "$(VERSION)" > ./version
123 $(GIT) add ./version
124 -$(GIT) commit -m "Release $(VERSION)"
125 -$(GIT) tag -a -m "Release $(VERSION)" $(VERSION)
126 $(GIT) push --mirror
127 $(MAKE) licensify
128 @echo "\n\tLicensify has run: do not commit any files from now on!"
129 @echo "\n\tRun 'make package'\n"
130
131 package:
132 $(MAKE) package-src
133 $(MAKE) package-nopython
134 $(MAKE) package-python
135 @echo "\tPut online with 'make website'"
136 @echo "\tThe coccinelle SVN repository must be in $(WEBBASE)\n"
137
138 package-src:
139 ./configure --enable-release --disable-python --disable-pcre-syntax $(extra_configure_flags)
140 $(MAKE) srctar
141 $(MAKE) coccicheck
142
143 # Reconfigures the project without Python support
144 # Note: we disable pcre syntax as well to eliminate the dependency
145 # on those libraries.
146 package-nopython:
147 $(MAKE) distclean
148 ./configure --enable-release --disable-python --disable-pcre-syntax --disable-menhirLib --disable-pycaml $(extra_configure_flags)
149 $(MAKE) bintar
150 $(MAKE) bytecodetar
151
152 # Reconfigure project with Python support
153 # Note: we disable pcre syntax as well to eliminate the dependency
154 # on those libraries.
155 package-python:
156 $(MAKE) distclean
157 ./configure --enable-release --enable-python --disable-pcre-syntax --disable-menhirLib --disable-pycaml $(extra_configure_flags)
158 $(MAKE) bintar-python
159 $(MAKE) bytecodetar-python
160
161
162 # I currently pre-generate the parser so the user does not have to
163 # install menhir on his machine. We could also do a few cleanups.
164 # You may have first to do a 'make licensify'.
165 #
166 # update: make docs generates pdf but also some ugly .log files, so
167 # make clean is there to remove them while not removing the pdf
168 # (only distclean remove the pdfs).
169 srctar: Makefile.config
170 $(MAKE) docs
171 $(MAKE) -C parsing_cocci parser_cocci_menhir.ml
172 $(MAKE) -C parsing_cocci parser_cocci_menhir.mli
173 $(MAKE) distclean KEEP_GENERATED=1 KEEP_CONFIG=1
174 if test -f "$(TMP)/$(PACKAGE)/"; then rm -f "$(TMP)/$(PACKAGE)/"; fi # remove it if it is a symlink
175 $(MKDIR_P) "$(TMP)/$(PACKAGE)/"
176 cp -rfa ./* "$(TMP)/$(PACKAGE)/"
177 rm -f $(TMP)/$(PACKAGE)/Makefile.config
178 cd $(TMP); tar cvfz $(PACKAGE).tgz --exclude-vcs $(EXCL) $(PACKAGE)
179 rm -rf $(TMP)/$(PACKAGE)
180
181 bintar: all-dev
182 $(MAKE) docs
183 rm -f $(TMP)/$(PACKAGE)
184 ln -s `pwd` $(TMP)/$(PACKAGE)
185 @if test -n "${PATCHELF}" -a -f spatch; then \
186 $(PATCHELF) --set-interpreter "/lib/ld-linux.so.2" --set-rpath "" spatch; fi
187 @if test -n "${PATCHELF}" -a -f spatch.opt; then \
188 $(PATCHELF) --set-interpreter "/lib/ld-linux.so.2" --set-rpath "" spatch.opt; fi
189 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86.tgz --exclude-vcs $(BINSRC2)
190 rm -f $(TMP)/$(PACKAGE)
191
192 staticbintar: all-release
193 $(MAKE) docs
194 rm -f $(TMP)/$(PACKAGE)
195 ln -s `pwd` $(TMP)/$(PACKAGE)
196 $(MAKE) static
197 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86-static.tgz --exclude-vcs $(BINSRC2)
198 rm -f $(TMP)/$(PACKAGE)
199
200 bytecodetar: all-dev
201 $(MAKE) docs
202 rm -f $(TMP)/$(PACKAGE)
203 ln -s `pwd` $(TMP)/$(PACKAGE)
204 $(MAKE) purebytecode
205 $(MAKE) copy-stubs
206 @if test -n "${PATCHELF}" -a -f dllpycaml_stubs.so; then \
207 $(PATCHELF) --set-rpath "" dllpycaml_stubs.so; fi
208 @if test -n "${PATHCELF}" -a -f dllpcre_stubs.so; then \
209 $(PATCHELF) --set-rpath "" dllpcre_stubs.so; fi
210 cd $(TMP); tar cvfz $(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz --exclude-vcs $(BINSRC2) $$(find -L $(PACKAGE) -maxdepth 1 -name 'dll*.so')
211 rm -f $(TMP)/$(PACKAGE)
212 rm -f dllpycaml_stubs.so dllpcre_stubs.so
213
214 bintar-python: all
215 $(MAKE) docs
216 @if test -n "${PATCHELF}" -a -f spatch; then \
217 $(PATCHELF) --set-interpreter "/lib/ld-linux.so.2" --set-rpath "" spatch; fi
218 @if test -n "${PATCHELF}" -a -f spatch.opt; then \
219 $(PATCHELF) --set-interpreter "/lib/ld-linux.so.2" --set-rpath "" spatch.opt; fi
220 rm -f $(TMP)/$(PACKAGE)
221 ln -s `pwd` $(TMP)/$(PACKAGE)
222 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86-python.tgz --exclude-vcs $(BINSRC2-PY)
223 rm -f $(TMP)/$(PACKAGE)
224
225 bytecodetar-python: all-dev
226 $(MAKE) docs
227 rm -f $(TMP)/$(PACKAGE)
228 ln -s `pwd` $(TMP)/$(PACKAGE)
229 $(MAKE) purebytecode
230 $(MAKE) copy-stubs
231 @if test -n "${PATCHELF}" -a -f dllpycaml_stubs.so; then \
232 $(PATCHELF) --set-rpath "" dllpycaml_stubs.so; fi
233 @if test -n "${PATHCELF}" -a -f dllpcre_stubs.so; then \
234 $(PATCHELF) --set-rpath "" dllpcre_stubs.so; fi
235 cd $(TMP); tar cvfz $(PACKAGE)-bin-bytecode-$(OCAMLVERSION)-python.tgz --exclude-vcs $(BINSRC2-PY) $$(find -L $(PACKAGE) -maxdepth 1 -name 'dll*.so')
236 rm -f $(TMP)/$(PACKAGE)
237 rm -f dllpycaml_stubs.so dllpcre_stubs.so
238
239 coccicheck:
240 cp -a ./scripts/coccicheck $(TMP)/$(CCPACKAGE)
241 tar cvfz $(TMP)/$(CCPACKAGE).tgz -C $(TMP) --exclude-vcs $(CCPACKAGE)
242 rm -rf $(TMP)/$(CCPACKAGE)
243
244 clean-packages::
245 rm -f $(TMP)/$(PACKAGE).tgz
246 rm -f $(TMP)/$(PACKAGE)-bin-x86.tgz
247 rm -f $(TMP)/$(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz
248 rm -f $(TMP)/$(PACKAGE)-bin-x86-python.tgz
249 rm -f $(TMP)/$(PACKAGE)-bin-bytecode-$(OCAMLVERSION)-python.tgz
250 rm -f $(TMP)/$(CCPACKAGE).tgz
251
252 #
253 # No need to licensify 'demos'. Because these are basic building blocks
254 # to use SmPL.
255 #
256 TOLICENSIFY=ctl engine globals parsing_cocci popl popl09 python scripts tools
257 licensify:
258 ocaml str.cma tools/licensify.ml
259 set -e; for i in $(TOLICENSIFY); do cd $$i; ocaml str.cma ../tools/licensify.ml; cd ..; done
260
261 # When checking out the source from diku sometimes I have some "X in the future"
262 # error messages.
263 fixdates:
264 echo do 'touch **/*.*'
265
266 ocamlversion:
267 @echo $(OCAMLVERSION)
268
269
270 ##############################################################################
271 # Packaging rules -- To build deb packages
272 ##############################################################################
273 #
274 # Run 'make packsrc' to build a Deb source package
275 #
276 # The package is prepared in $(TMP), usually /tmp
277 # Once the package has been build, it is uploaded
278 # to a PPA on launchpad.
279 #
280 # You should have a "coccinelle" project configured
281 # for dput in your ~/.dput.cf file.
282 #
283 # The 'packbin' target is to build a deb package
284 # locally. It is only for testing purpose.
285 #
286
287 EXCL_SYNC=--exclude ".git" \
288 --exclude ".gitignore" \
289 --exclude ".cvsignore" \
290 --exclude ".svn" \
291 --exclude "tests" \
292 --exclude "TODO" \
293 --cvs-exclude
294
295 packsrc: prepack
296 $(MAKE) -C $(TMP)/$(PACKAGE)/debian lucid
297 $(MAKE) -C $(TMP)/$(PACKAGE)/debian karmic
298 $(MAKE) -C $(TMP)/$(PACKAGE)/debian maverick
299 $(MAKE) -C $(TMP)/$(PACKAGE)/debian natty
300 $(MAKE) -C $(TMP)/$(PACKAGE)/debian oneiric
301 $(MAKE) push
302 rm -rf $(TMP)/$(PACKAGE)/
303
304 packbin: prepack
305 $(MAKE) -C $(TMP)/$(PACKAGE)/debian binary
306 rm -rf $(TMP)/$(PACKAGE)/
307 rm -rf $(TMP)/$(PACKAGE)_$(VERSION)*_source.build
308
309 prepack:
310 rsync -a $(EXCL_SYNC) . $(TMP)/$(PACKAGE)
311 $(MAKE) -C $(TMP)/$(PACKAGE) licensify
312 sed -i "s|^OCAMLCFLAGS=.*$$|OCAMLCFLAGS=|" $(TMP)/$(PACKAGE)/Makefile
313 rm -rf $(TMP)/$(PACKAGE)/tools
314
315 push:
316 cd $(TMP)/ && for p in `ls $(PRJNAME)_$(VERSION)*_source.changes`; do dput $(PRJNAME) $$p ; done
317 rm -rf $(TMP)/$(PRJNAME)_$(VERSION)*_source.changes
318 rm -rf $(TMP)/$(PRJNAME)_$(VERSION)*_source.$(PRJNAME).upload
319 rm -rf $(TMP)/$(PRJNAME)_$(VERSION)*.dsc
320 rm -rf $(TMP)/$(PRJNAME)_$(VERSION)*.tar.gz
321
322 # Produces a source tarball
323 # Note: start from a fresh working directory
324 # Note: configure first
325 dist:
326 $(MAKE) licensify
327 $(MAKE) docs
328 $(MAKE) -C parsing_cocci parser_cocci_menhir.ml
329 $(MAKE) distclean KEEP_CONFIG=1 KEEP_GENERATED=1
330 tar cvfz $(PACKAGE).tar.gz --transform="s,^,$(PACKAGE)/,S" --exclude=$(PACKAGE).tar.gz --exclude-backups --exclude-vcs *