Merge branch 'http-memleak' into v0.6
[platform/upstream/nodejs.git] / Makefile
1 PYTHON ?= python
2 WAF    = $(PYTHON) tools/waf-light
3
4 web_root = node@nodejs.org:~/web/nodejs.org/
5
6 #
7 # Because we recursively call make from waf we need to make sure that we are
8 # using the correct make. Not all makes are GNU Make, but this likely only
9 # works with gnu make. To deal with this we remember how the user invoked us
10 # via a make builtin variable and use that in all subsequent operations
11 #
12 export NODE_MAKE := $(MAKE)
13
14 all: program
15         @-[ -f out/Release/node ] && ls -lh out/Release/node
16
17 all-progress:
18         @$(WAF) -p build
19
20 program:
21         @$(WAF) --product-type=program build
22
23 staticlib:
24         @$(WAF) --product-type=cstaticlib build
25
26 dynamiclib:
27         @$(WAF) --product-type=cshlib build
28
29 install:
30         @$(WAF) install
31
32 uninstall:
33         @$(WAF) uninstall
34
35 test: all node_modules/weak
36         $(PYTHON) tools/test.py --mode=release simple message
37
38 test-http1: all
39         $(PYTHON) tools/test.py --mode=release --use-http1 simple message
40
41 test-valgrind: all
42         $(PYTHON) tools/test.py --mode=release --valgrind simple message
43
44 node_modules/weak:
45         @if [ ! -f node ]; then make all; fi
46         @if [ ! -d node_modules ]; then mkdir -p node_modules; fi
47         ./node deps/npm/bin/npm-cli.js install weak --prefix="$(shell pwd)"
48
49 test-gc: all node_modules/weak
50         $(PYTHON) tools/test.py --mode=release gc
51
52 test-all: all node_modules/weak
53         $(PYTHON) tools/test.py --mode=debug,release
54         make test-npm
55
56 test-all-http1: all
57         $(PYTHON) tools/test.py --mode=debug,release --use-http1
58
59 test-all-valgrind: all
60         $(PYTHON) tools/test.py --mode=debug,release --valgrind
61
62 test-release: all
63         $(PYTHON) tools/test.py --mode=release
64
65 test-debug: all
66         $(PYTHON) tools/test.py --mode=debug
67
68 test-message: all
69         $(PYTHON) tools/test.py message
70
71 test-simple: all
72         $(PYTHON) tools/test.py simple
73
74 test-pummel: all
75         $(PYTHON) tools/test.py pummel
76
77 test-internet: all
78         $(PYTHON) tools/test.py internet
79
80 test-npm: all
81         ./node deps/npm/test/run.js
82
83 test-npm-publish: all
84         npm_package_config_publishtest=true ./node deps/npm/test/run.js
85
86 out/Release/node: all
87
88 apidoc_sources = $(wildcard doc/api/*.markdown)
89 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
90           $(addprefix out/,$(apidoc_sources:.markdown=.json))
91
92 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets out/doc/about out/doc/community out/doc/logos out/doc/images
93
94 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
95
96 doc_images = $(addprefix out/,$(wildcard doc/images/* doc/*.jpg doc/*.png))
97
98 website_files = \
99         out/doc/index.html    \
100         out/doc/v0.4_announcement.html   \
101         out/doc/cla.html      \
102         out/doc/sh_main.js    \
103         out/doc/sh_javascript.min.js \
104         out/doc/sh_vim-dark.css \
105         out/doc/sh.css \
106         out/doc/favicon.ico   \
107         out/doc/pipe.css \
108         out/doc/about/index.html \
109         out/doc/community/index.html \
110         out/doc/logos/index.html \
111         out/doc/changelog.html \
112         $(doc_images)
113
114 doc: program $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/
115
116 $(apidoc_dirs):
117         mkdir -p $@
118
119 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
120         cp $< $@
121
122 out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh
123         bash tools/build-changelog.sh
124
125 out/doc/%.html: doc/%.html
126         cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
127
128 out/doc/%: doc/%
129         cp -r $< $@
130
131 out/doc/api/%.json: doc/api/%.markdown
132         out/Release/node tools/doc/generate.js --format=json $< > $@
133
134 out/doc/api/%.html: doc/api/%.markdown
135         out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@
136
137 email.md: ChangeLog tools/email-footer.md
138         bash tools/changelog-head.sh > $@
139         cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
140
141 blog.html: email.md
142         cat $< | ./node tools/doc/node_modules/.bin/marked > $@
143
144 website-upload: doc
145         rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
146         ssh node@nodejs.org '\
147     rm -f ~/web/nodejs.org/dist/latest &&\
148     ln -s $(VERSION) ~/web/nodejs.org/dist/latest &&\
149     rm -f ~/web/nodejs.org/docs/latest &&\
150     ln -s $(VERSION) ~/web/nodejs.org/docs/latest &&\
151     rm -f ~/web/nodejs.org/dist/node-latest.tar.gz &&\
152     ln -s $(VERSION)/node-$(VERSION).tar.gz ~/web/nodejs.org/dist/node-latest.tar.gz'
153
154 docopen: out/doc/api/all.html
155         -google-chrome out/doc/api/all.html
156
157 docclean:
158         -rm -rf out/doc
159
160 clean:
161         $(WAF) clean
162         -find tools -name "*.pyc" | xargs rm -f
163         -rm -rf blog.html email.md
164         -rm -rf node_modules
165
166 distclean: docclean
167         -find tools -name "*.pyc" | xargs rm -f
168         -rm -rf dist-osx
169         -rm -rf out/ node node_g
170         -rm -rf blog.html email.md
171
172 check:
173         @tools/waf-light check
174
175 VERSION=v$(shell $(PYTHON) tools/getnodeversion.py)
176 TARNAME=node-$(VERSION)
177 TARBALL=$(TARNAME).tar.gz
178 PKG=out/$(TARNAME).pkg
179
180 packagemaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
181
182 #dist: doc/node.1 doc/api
183 dist: $(TARBALL) $(PKG)
184
185 PKGDIR=out/dist-osx
186
187 pkg: $(PKG)
188
189 $(PKG):
190         -rm -rf $(PKGDIR)
191         # Need to remove deps between architecture changes.
192         rm -rf out/*/deps
193         $(WAF) configure --prefix=/usr/local --without-snapshot --dest-cpu=ia32
194         CFLAGS=-m32 DESTDIR=$(PKGDIR)/32 $(WAF) install
195         rm -rf out/*/deps
196         $(WAF) configure --prefix=/usr/local --without-snapshot --dest-cpu=x64
197         CFLAGS=-m64 DESTDIR=$(PKGDIR) $(WAF) install
198         lipo $(PKGDIR)/32/usr/local/bin/node \
199                 $(PKGDIR)/usr/local/bin/node \
200                 -output $(PKGDIR)/usr/local/bin/node-universal \
201                 -create
202         mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
203         rm -rf $(PKGDIR)/32
204         $(packagemaker) \
205                 --id "org.nodejs.NodeJS-$(VERSION)" \
206                 --doc tools/osx-pkg.pmdoc \
207                 --out $(PKG)
208
209 $(TARBALL): out/doc
210         git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
211         mkdir -p $(TARNAME)/doc
212         cp doc/node.1 $(TARNAME)/doc/node.1
213         cp -r out/doc/api $(TARNAME)/doc/api
214         rm -rf $(TARNAME)/deps/v8/test # too big
215         rm -rf $(TARNAME)/doc/images # too big
216         tar -cf $(TARNAME).tar $(TARNAME)
217         rm -rf $(TARNAME)
218         gzip -f -9 $(TARNAME).tar
219
220 dist-upload: $(TARBALL) $(PKG)
221         ssh node@nodejs.org mkdir -p web/nodejs.org/dist/$(VERSION)
222         scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
223         scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
224
225 bench:
226          benchmark/http_simple_bench.sh
227
228 bench-idle:
229         ./node benchmark/idle_server.js &
230         sleep 1
231         ./node benchmark/idle_clients.js &
232
233 jslint:
234         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
235
236 cpplint:
237         @$(PYTHON) tools/cpplint.py $(wildcard src/*.cc src/*.h src/*.c)
238
239 lint: jslint cpplint
240
241 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean dist-upload check uninstall install all program staticlib dynamiclib test test-all website-upload