Tests for memory leaks
[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 node_modules/weak
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 node_modules/weak:
65         @if [ ! -f node ]; then make all; fi
66         @if [ ! -d node_modules ]; then mkdir -p node_modules; fi
67         ./node deps/npm/bin/npm-cli.js install weak --prefix="$(shell pwd)"
68
69 test-gc: all node_modules/weak
70         $(PYTHON) tools/test.py --mode=release gc
71
72 test-all: all node_modules/weak
73         $(PYTHON) tools/test.py --mode=debug,release
74         make test-npm
75
76 test-all-http1: all
77         $(PYTHON) tools/test.py --mode=debug,release --use-http1
78
79 test-all-valgrind: all
80         $(PYTHON) tools/test.py --mode=debug,release --valgrind
81
82 test-release: all
83         $(PYTHON) tools/test.py --mode=release
84
85 test-debug: all
86         $(PYTHON) tools/test.py --mode=debug
87
88 test-message: all
89         $(PYTHON) tools/test.py message
90
91 test-simple: all
92         $(PYTHON) tools/test.py simple
93
94 test-pummel: all
95         $(PYTHON) tools/test.py pummel
96
97 test-internet: all
98         $(PYTHON) tools/test.py internet
99
100 test-npm: node
101         ./node deps/npm/test/run.js
102
103 test-npm-publish: node
104         npm_package_config_publishtest=true ./node deps/npm/test/run.js
105
106 apidoc_sources = $(wildcard doc/api/*.markdown)
107 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
108           $(addprefix out/,$(apidoc_sources:.markdown=.json))
109
110 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets out/doc/about out/doc/community out/doc/logos out/doc/images
111
112 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
113
114 doc_images = $(addprefix out/,$(wildcard doc/images/* doc/*.jpg doc/*.png))
115
116 website_files = \
117         out/doc/index.html    \
118         out/doc/v0.4_announcement.html   \
119         out/doc/cla.html      \
120         out/doc/sh_main.js    \
121         out/doc/sh_javascript.min.js \
122         out/doc/sh_vim-dark.css \
123         out/doc/sh.css \
124         out/doc/favicon.ico   \
125         out/doc/pipe.css \
126         out/doc/about/index.html \
127         out/doc/community/index.html \
128         out/doc/logos/index.html \
129         out/doc/changelog.html \
130         $(doc_images)
131
132 doc: program $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/
133
134 $(apidoc_dirs):
135         mkdir -p $@
136
137 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
138         cp $< $@
139
140 out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh
141         bash tools/build-changelog.sh
142
143 out/doc/%.html: doc/%.html
144         cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
145
146 out/doc/%: doc/%
147         cp -r $< $@
148
149 out/doc/api/%.json: doc/api/%.markdown
150         out/Release/node tools/doc/generate.js --format=json $< > $@
151
152 out/doc/api/%.html: doc/api/%.markdown
153         out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@
154
155 email.md: ChangeLog tools/email-footer.md
156         bash tools/changelog-head.sh > $@
157         cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
158
159 blog.html: email.md
160         cat $< | ./node tools/doc/node_modules/.bin/marked > $@
161
162 website-upload: doc
163         rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
164         ssh node@nodejs.org '\
165     rm -f ~/web/nodejs.org/dist/latest &&\
166     ln -s $(VERSION) ~/web/nodejs.org/dist/latest &&\
167     rm -f ~/web/nodejs.org/docs/latest &&\
168     ln -s $(VERSION) ~/web/nodejs.org/docs/latest &&\
169     rm -f ~/web/nodejs.org/dist/node-latest.tar.gz &&\
170     ln -s $(VERSION)/node-$(VERSION).tar.gz ~/web/nodejs.org/dist/node-latest.tar.gz'
171
172 docopen: out/doc/api/all.html
173         -google-chrome out/doc/api/all.html
174
175 docclean:
176         -rm -rf out/doc
177
178 VERSION=v$(shell $(PYTHON) tools/getnodeversion.py)
179 TARNAME=node-$(VERSION)
180 TARBALL=$(TARNAME).tar.gz
181 PKG=out/$(TARNAME).pkg
182 packagemaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
183
184 dist: doc $(TARBALL) $(PKG)
185
186 PKGDIR=out/dist-osx
187
188 pkg: $(PKG)
189
190 $(PKG):
191         rm -rf $(PKGDIR)
192         rm -rf out/deps out/Release
193         ./configure --prefix=$(PKGDIR)/32/usr/local --without-snapshot --dest-cpu=ia32
194         $(MAKE) install
195         rm -rf out/deps out/Release
196         ./configure --prefix=$(PKGDIR)/usr/local --without-snapshot --dest-cpu=x64
197         $(MAKE) 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): node out/doc
210         @if [ $(shell ./node --version) = "$(VERSION)" ]; then \
211                 exit 0; \
212         else \
213           echo "" >&2 ; \
214                 echo "$(shell ./node --version) doesn't match $(VERSION)." >&2 ; \
215           echo "Did you remember to update src/node_version.cc?" >&2 ; \
216           echo "" >&2 ; \
217                 exit 1 ; \
218         fi
219         git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
220         mkdir -p $(TARNAME)/doc
221         cp doc/node.1 $(TARNAME)/doc/node.1
222         cp -r out/doc/api $(TARNAME)/doc/api
223         rm -rf $(TARNAME)/deps/v8/test # too big
224         rm -rf $(TARNAME)/doc/images # too big
225         tar -cf $(TARNAME).tar $(TARNAME)
226         rm -rf $(TARNAME)
227         gzip -f -9 $(TARNAME).tar
228
229 dist-upload: $(TARBALL) $(PKG)
230         ssh node@nodejs.org mkdir -p web/nodejs.org/dist/$(VERSION)
231         scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
232         scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
233
234 bench:
235          benchmark/http_simple_bench.sh
236
237 bench-idle:
238         ./node benchmark/idle_server.js &
239         sleep 1
240         ./node benchmark/idle_clients.js &
241
242 jslint:
243         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
244
245 cpplint:
246         @$(PYTHON) tools/cpplint.py $(wildcard src/*.cc src/*.h src/*.c)
247
248 lint: jslint cpplint
249
250 .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