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