Make rules for release blog post and email message
[platform/upstream/nodejs.git] / Makefile
1 -include config.mk
2
3 BUILDTYPE ?= Release
4 PYTHON ?= python
5
6 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
7 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
8 ifeq ($(BUILDTYPE),Release)
9 all: out/Makefile node
10 else
11 all: out/Makefile node node_g
12 endif
13
14 # The .PHONY is needed to ensure that we recursively use the out/Makefile
15 # to check for changes.
16 .PHONY: node node_g
17
18 node: config.gypi
19         $(MAKE) -C out BUILDTYPE=Release
20         ln -fs out/Release/node node
21
22 node_g: config.gypi
23         $(MAKE) -C out BUILDTYPE=Debug
24         ln -fs out/Debug/node node_g
25
26 config.gypi: configure
27         ./configure
28
29 out/Debug/node:
30         $(MAKE) -C out BUILDTYPE=Debug
31
32 out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp deps/v8/build/common.gypi deps/v8/tools/gyp/v8.gyp node.gyp config.gypi
33         tools/gyp_node -f make
34
35 install: all
36         out/Release/node tools/installer.js install
37
38 uninstall:
39         out/Release/node tools/installer.js uninstall
40
41 clean:
42         -rm -rf out/Makefile node node_g out/$(BUILDTYPE)/node blog.html email.md
43         -find out/ -name '*.o' -o -name '*.a' | xargs rm -rf
44
45 distclean:
46         -rm -rf out
47         -rm -f config.gypi
48         -rm -f config.mk
49         -rm -rf node node_g blog.html email.md
50
51 test: all
52         $(PYTHON) tools/test.py --mode=release simple message
53         PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
54
55 test-http1: all
56         $(PYTHON) tools/test.py --mode=release --use-http1 simple message
57
58 test-valgrind: all
59         $(PYTHON) tools/test.py --mode=release --valgrind simple message
60
61 test-all: all
62         python tools/test.py --mode=debug,release
63         $(MAKE) test-npm
64
65 test-all-http1: all
66         $(PYTHON) tools/test.py --mode=debug,release --use-http1
67
68 test-all-valgrind: all
69         $(PYTHON) tools/test.py --mode=debug,release --valgrind
70
71 test-release: all
72         $(PYTHON) tools/test.py --mode=release
73
74 test-debug: all
75         $(PYTHON) tools/test.py --mode=debug
76
77 test-message: all
78         $(PYTHON) tools/test.py message
79
80 test-simple: all
81         $(PYTHON) tools/test.py simple
82
83 test-pummel: all
84         $(PYTHON) tools/test.py pummel
85
86 test-internet: all
87         $(PYTHON) tools/test.py internet
88
89 test-npm: node
90         ./node deps/npm/test/run.js
91
92 test-npm-publish: node
93         npm_package_config_publishtest=true ./node deps/npm/test/run.js
94
95 apidoc_sources = $(wildcard doc/api/*.markdown)
96 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
97           $(addprefix out/,$(apidoc_sources:.markdown=.json))
98
99 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets out/doc/about out/doc/community out/doc/logos out/doc/images
100
101 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
102
103 doc_images = $(addprefix out/,$(wildcard doc/images/* doc/*.jpg doc/*.png))
104
105 website_files = \
106         out/doc/index.html    \
107         out/doc/v0.4_announcement.html   \
108         out/doc/cla.html      \
109         out/doc/sh_main.js    \
110         out/doc/sh_javascript.min.js \
111         out/doc/sh_vim-dark.css \
112         out/doc/sh.css \
113         out/doc/favicon.ico   \
114         out/doc/pipe.css \
115         out/doc/about/index.html \
116         out/doc/community/index.html \
117         out/doc/logos/index.html \
118         $(doc_images)
119
120 doc: program $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/
121
122 $(apidoc_dirs):
123         mkdir -p $@
124
125 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
126         cp $< $@
127
128 out/doc/%.html: doc/%.html
129         cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
130
131 out/doc/%: doc/%
132         cp -r $< $@
133
134 out/doc/api/%.json: doc/api/%.markdown
135         out/Release/node tools/doc/generate.js --format=json $< > $@
136
137 out/doc/api/%.html: doc/api/%.markdown
138         out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@
139
140 email.md: ChangeLog tools/email-footer.md
141         bash tools/changelog-head.sh > $@
142         cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
143
144 blog.html: email.md
145         cat $< | node tools/doc/node_modules/.bin/marked > $@
146
147 website-upload: doc
148         rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
149
150 docopen: out/doc/api/all.html
151         -google-chrome out/doc/api/all.html
152
153 docclean:
154         -rm -rf out/doc
155
156 VERSION=v$(shell $(PYTHON) tools/getnodeversion.py)
157 TARNAME=node-$(VERSION)
158 TARBALL=$(TARNAME).tar.gz
159 PKG=out/$(TARNAME).pkg
160 packagemaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
161
162 dist: doc $(TARBALL) $(PKG)
163
164 PKGDIR=out/dist-osx
165
166 pkg: $(PKG)
167
168 $(PKG):
169         rm -rf $(PKGDIR)
170         rm -rf out/deps out/Release
171         ./configure --prefix=$(PKGDIR)/32/usr/local --without-snapshot --dest-cpu=ia32
172         $(MAKE) install
173         rm -rf out/deps out/Release
174         ./configure --prefix=$(PKGDIR)/usr/local --without-snapshot --dest-cpu=x64
175         $(MAKE) install
176         lipo $(PKGDIR)/32/usr/local/bin/node \
177                 $(PKGDIR)/usr/local/bin/node \
178                 -output $(PKGDIR)/usr/local/bin/node-universal \
179                 -create
180         mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
181         rm -rf $(PKGDIR)/32
182         $(packagemaker) \
183                 --id "org.nodejs.NodeJS-$(VERSION)" \
184                 --doc tools/osx-pkg.pmdoc \
185                 --out $(PKG)
186
187 $(TARBALL): node out/doc
188         @if [ $(shell ./node --version) = "$(VERSION)" ]; then \
189                 exit 0; \
190         else \
191           echo "" >&2 ; \
192                 echo "$(shell ./node --version) doesn't match $(VERSION)." >&2 ; \
193           echo "Did you remember to update src/node_version.cc?" >&2 ; \
194           echo "" >&2 ; \
195                 exit 1 ; \
196         fi
197         git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
198         mkdir -p $(TARNAME)/doc
199         cp doc/node.1 $(TARNAME)/doc/node.1
200         cp -r out/doc/api $(TARNAME)/doc/api
201         rm -rf $(TARNAME)/deps/v8/test # too big
202         rm -rf $(TARNAME)/doc/images # too big
203         tar -cf $(TARNAME).tar $(TARNAME)
204         rm -rf $(TARNAME)
205         gzip -f -9 $(TARNAME).tar
206
207 dist-upload: $(TARBALL) $(PKG)
208         ssh node@nodejs.org mkdir -p web/nodejs.org/dist/$(VERSION)
209         scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
210         scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
211
212 bench:
213          benchmark/http_simple_bench.sh
214
215 bench-idle:
216         ./node benchmark/idle_server.js &
217         sleep 1
218         ./node benchmark/idle_clients.js &
219
220 jslint:
221         PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js
222
223 cpplint:
224         @$(PYTHON) tools/cpplint.py $(wildcard src/*.cc src/*.h src/*.c)
225
226 lint: jslint cpplint
227
228 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean check uninstall install install-includes install-bin all program staticlib dynamiclib test test-all website-upload pkg