test: remove --use-http1 test runner flag
[platform/upstream/nodejs.git] / Makefile
1 -include config.mk
2
3 BUILDTYPE ?= Release
4 PYTHON ?= python
5 NINJA ?= ninja
6 DESTDIR ?=
7 SIGN ?=
8 PREFIX ?= /usr/local
9
10 # Determine EXEEXT
11 EXEEXT := $(shell $(PYTHON) -c \
12                 "import sys; print('.exe' if sys.platform == 'win32' else '')")
13
14 NODE ?= ./node$(EXEEXT)
15 NODE_EXE = node$(EXEEXT)
16 NODE_G_EXE = node_g$(EXEEXT)
17
18 # Default to verbose builds.
19 # To do quiet/pretty builds, run `make V=` to set V to an empty string,
20 # or set the V environment variable to an empty string.
21 V ?= 1
22
23 ifeq ($(USE_NINJA),1)
24 ifneq ($(V),)
25 NINJA := $(NINJA) -v
26 endif
27 endif
28
29 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
30 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
31 ifeq ($(BUILDTYPE),Release)
32 all: out/Makefile $(NODE_EXE)
33 else
34 all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
35 endif
36
37 # The .PHONY is needed to ensure that we recursively use the out/Makefile
38 # to check for changes.
39 .PHONY: $(NODE_EXE) $(NODE_G_EXE)
40
41 ifeq ($(USE_NINJA),1)
42 $(NODE_EXE): config.gypi
43         $(NINJA) -C out/Release/
44         ln -fs out/Release/$(NODE_EXE) $@
45
46 $(NODE_G_EXE): config.gypi
47         $(NINJA) -C out/Debug/
48         ln -fs out/Debug/$(NODE_EXE) $@
49 else
50 $(NODE_EXE): config.gypi out/Makefile
51         $(MAKE) -C out BUILDTYPE=Release V=$(V)
52         ln -fs out/Release/$(NODE_EXE) $@
53
54 $(NODE_G_EXE): config.gypi out/Makefile
55         $(MAKE) -C out BUILDTYPE=Debug V=$(V)
56         ln -fs out/Debug/$(NODE_EXE) $@
57 endif
58
59 out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp deps/v8/build/toolchain.gypi deps/v8/build/features.gypi deps/v8/tools/gyp/v8.gyp node.gyp config.gypi
60 ifeq ($(USE_NINJA),1)
61         touch out/Makefile
62         $(PYTHON) tools/gyp_node.py -f ninja
63 else
64         $(PYTHON) tools/gyp_node.py -f make
65 endif
66
67 config.gypi: configure
68         if [ -f $@ ]; then
69                 $(error Stale $@, please re-run ./configure)
70         else
71                 $(error No $@, please run ./configure first)
72         fi
73
74 install: all
75         $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
76
77 uninstall:
78         $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
79
80 clean:
81         -rm -rf out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) blog.html email.md
82         @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' | xargs rm -rf; fi
83         -rm -rf node_modules
84
85 distclean:
86         -rm -rf out
87         -rm -f config.gypi icu_config.gypi
88         -rm -f config.mk
89         -rm -rf $(NODE_EXE) $(NODE_G_EXE) blog.html email.md
90         -rm -rf node_modules
91         -rm -rf deps/icu
92         -rm -rf deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp
93
94 test: all
95         $(PYTHON) tools/test.py --mode=release message parallel sequential -J
96         $(MAKE) jslint
97         $(MAKE) cpplint
98
99 test-parallel: all
100         $(PYTHON) tools/test.py --mode=release parallel -J
101
102 test-valgrind: all
103         $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
104
105 test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE)
106         ./$(NODE_EXE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
107                 --directory="$(shell pwd)/test/gc/node_modules/weak" \
108                 --nodedir="$(shell pwd)"
109
110 build-addons: $(NODE_EXE)
111         rm -rf test/addons/doc-*/
112         ./$(NODE_EXE) tools/doc/addon-verify.js
113         $(foreach dir, \
114                         $(sort $(dir $(wildcard test/addons/*/*.gyp))), \
115                         ./$(NODE_EXE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
116                                         --directory="$(shell pwd)/$(dir)" \
117                                         --nodedir="$(shell pwd)" && ) echo "build done"
118
119 test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
120         $(PYTHON) tools/test.py --mode=release gc
121
122 test-build: all build-addons
123
124 test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
125         $(PYTHON) tools/test.py --mode=debug,release
126         make test-npm
127
128 test-all-valgrind: test-build
129         $(PYTHON) tools/test.py --mode=debug,release --valgrind
130
131 test-release: test-build
132         $(PYTHON) tools/test.py --mode=release
133
134 test-debug: test-build
135         $(PYTHON) tools/test.py --mode=debug
136
137 test-message: test-build
138         $(PYTHON) tools/test.py message
139
140 test-simple: all
141         $(PYTHON) tools/test.py parallel sequential
142
143 test-pummel: all wrk
144         $(PYTHON) tools/test.py pummel
145
146 test-internet: all
147         $(PYTHON) tools/test.py internet
148
149 test-debugger: all
150         $(PYTHON) tools/test.py debugger
151
152 test-npm: $(NODE_EXE)
153         rm -rf npm-cache npm-tmp npm-prefix
154         mkdir npm-cache npm-tmp npm-prefix
155         cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
156              npm_config_prefix="$(shell pwd)/npm-prefix" \
157              npm_config_tmp="$(shell pwd)/npm-tmp" \
158              ../../$(NODE_EXE) cli.js install
159         cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
160              npm_config_prefix="$(shell pwd)/npm-prefix" \
161              npm_config_tmp="$(shell pwd)/npm-tmp" \
162              ../../$(NODE_EXE) cli.js run-script test-all && \
163              ../../$(NODE_EXE) cli.js prune --prod && \
164              cd ../.. && \
165              rm -rf npm-cache npm-tmp npm-prefix
166
167 test-npm-publish: $(NODE_EXE)
168         npm_package_config_publishtest=true ./$(NODE_EXE) deps/npm/test/run.js
169
170 test-addons: test-build
171         $(PYTHON) tools/test.py --mode=release addons
172
173 test-timers:
174         $(MAKE) --directory=tools faketime
175         $(PYTHON) tools/test.py --mode=release timers
176
177 test-timers-clean:
178         $(MAKE) --directory=tools clean
179
180 apidoc_sources = $(wildcard doc/api/*.markdown)
181 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
182           $(addprefix out/,$(apidoc_sources:.markdown=.json))
183
184 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
185
186 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
187
188 website_files = \
189         out/doc/sh_main.js    \
190         out/doc/sh_javascript.min.js
191
192 doc: $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/ out/doc/changelog.html $(NODE_EXE)
193
194 $(apidoc_dirs):
195         mkdir -p $@
196
197 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
198         cp $< $@
199
200 out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh $(NODE_EXE)
201         bash tools/build-changelog.sh
202
203 out/doc/%: doc/%
204         cp -r $< $@
205
206 out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE)
207         out/Release/$(NODE_EXE) tools/doc/generate.js --format=json $< > $@
208
209 out/doc/api/%.html: doc/api/%.markdown $(NODE_EXE)
210         out/Release/$(NODE_EXE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@
211
212 email.md: ChangeLog tools/email-footer.md
213         bash tools/changelog-head.sh | sed 's|^\* #|* \\#|g' > $@
214         cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
215
216 blog.html: email.md
217         cat $< | ./$(NODE_EXE) tools/doc/node_modules/.bin/marked > $@
218
219 docopen: out/doc/api/all.html
220         -google-chrome out/doc/api/all.html
221
222 docclean:
223         -rm -rf out/doc
224
225 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
226 VERSION=v$(RAWVER)
227 RELEASE=$(shell $(PYTHON) tools/getnodeisrelease.py)
228 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
229 ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
230 DESTCPU ?= x64
231 else
232 DESTCPU ?= ia32
233 endif
234 ifeq ($(DESTCPU),x64)
235 ARCH=x64
236 else
237 ifeq ($(DESTCPU),arm)
238 ARCH=arm
239 else
240 ARCH=x86
241 endif
242 endif
243 TARNAME=node-$(VERSION)
244 ifdef NIGHTLY
245 TAG = nightly-$(NIGHTLY)
246 TARNAME=node-$(VERSION)-$(TAG)
247 endif
248 TARBALL=$(TARNAME).tar.gz
249 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
250 BINARYTAR=$(BINARYNAME).tar.gz
251 PKG=out/$(TARNAME).pkg
252 packagemaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
253
254 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER).tgz
255 ifdef NIGHTLY
256 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER)-$(TAG).tgz
257 endif
258
259 dist: doc $(TARBALL) $(PKG)
260
261 PKGDIR=out/dist-osx
262
263 release-only:
264         @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
265                 exit 0 ; \
266         else \
267           echo "" >&2 ; \
268                 echo "The git repository is not clean." >&2 ; \
269                 echo "Please commit changes before building release tarball." >&2 ; \
270                 echo "" >&2 ; \
271                 git status --porcelain | egrep -v '^\?\?' >&2 ; \
272                 echo "" >&2 ; \
273                 exit 1 ; \
274         fi
275         @if [ "$(NIGHTLY)" != "" -o "$(RELEASE)" = "1" ]; then \
276                 exit 0; \
277         else \
278           echo "" >&2 ; \
279                 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
280           echo "Did you remember to update src/node_version.cc?" >&2 ; \
281           echo "" >&2 ; \
282                 exit 1 ; \
283         fi
284
285 pkg: $(PKG)
286
287 $(PKG): release-only
288         rm -rf $(PKGDIR)
289         rm -rf out/deps out/Release
290         $(PYTHON) ./configure --without-snapshot --dest-cpu=ia32 --tag=$(TAG)
291         $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)/32
292         rm -rf out/deps out/Release
293         $(PYTHON) ./configure --without-snapshot --dest-cpu=x64 --tag=$(TAG)
294         $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
295         SIGN="$(APP_SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
296         lipo $(PKGDIR)/32/usr/local/bin/node \
297                 $(PKGDIR)/usr/local/bin/node \
298                 -output $(PKGDIR)/usr/local/bin/node-universal \
299                 -create
300         mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
301         rm -rf $(PKGDIR)/32
302         $(packagemaker) \
303                 --id "org.nodejs.Node" \
304                 --doc tools/osx-pkg.pmdoc \
305                 --out $(PKG)
306         SIGN="$(INT_SIGN)" PKG="$(PKG)" bash tools/osx-productsign.sh
307
308 $(TARBALL): release-only $(NODE_EXE) doc
309         git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
310         mkdir -p $(TARNAME)/doc/api
311         cp doc/iojs.1 $(TARNAME)/doc/iojs.1
312         cp -r out/doc/api/* $(TARNAME)/doc/api/
313         rm -rf $(TARNAME)/deps/v8/test # too big
314         rm -rf $(TARNAME)/doc/images # too big
315         find $(TARNAME)/ -type l | xargs rm # annoying on windows
316         tar -cf $(TARNAME).tar $(TARNAME)
317         rm -rf $(TARNAME)
318         gzip -f -9 $(TARNAME).tar
319
320 tar: $(TARBALL)
321
322 $(BINARYTAR): release-only
323         rm -rf $(BINARYNAME)
324         rm -rf out/deps out/Release
325         $(PYTHON) ./configure --prefix=/ --without-snapshot --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
326         $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
327         cp README.md $(BINARYNAME)
328         cp LICENSE $(BINARYNAME)
329         cp ChangeLog $(BINARYNAME)
330         tar -cf $(BINARYNAME).tar $(BINARYNAME)
331         rm -rf $(BINARYNAME)
332         gzip -f -9 $(BINARYNAME).tar
333
334 binary: $(BINARYTAR)
335
336 $(PKGSRC): release-only
337         rm -rf dist out
338         $(PYTHON) configure --prefix=/ --without-snapshot \
339                 --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
340         $(MAKE) install DESTDIR=dist
341         (cd dist; find * -type f | sort) > packlist
342         pkg_info -X pkg_install | \
343                 egrep '^(MACHINE_ARCH|OPSYS|OS_VERSION|PKGTOOLS_VERSION)' > build-info
344         pkg_create -B build-info -c tools/pkgsrc/comment -d tools/pkgsrc/description \
345                 -f packlist -I /opt/local -p dist -U $(PKGSRC)
346
347 pkgsrc: $(PKGSRC)
348
349 wrkclean:
350         $(MAKE) -C tools/wrk/ clean
351         rm tools/wrk/wrk
352
353 wrk: tools/wrk/wrk
354 tools/wrk/wrk:
355         $(MAKE) -C tools/wrk/
356
357 bench-net: all
358         @$(NODE) benchmark/common.js net
359
360 bench-crypto: all
361         @$(NODE) benchmark/common.js crypto
362
363 bench-tls: all
364         @$(NODE) benchmark/common.js tls
365
366 bench-http: wrk all
367         @$(NODE) benchmark/common.js http
368
369 bench-fs: all
370         @$(NODE) benchmark/common.js fs
371
372 bench-misc: all
373         @$(MAKE) -C benchmark/misc/function_call/
374         @$(NODE) benchmark/common.js misc
375
376 bench-array: all
377         @$(NODE) benchmark/common.js arrays
378
379 bench-buffer: all
380         @$(NODE) benchmark/common.js buffers
381
382 bench-all: bench bench-misc bench-array bench-buffer
383
384 bench: bench-net bench-http bench-fs bench-tls
385
386 bench-http-simple:
387          benchmark/http_simple_bench.sh
388
389 bench-idle:
390         ./$(NODE_EXE) benchmark/idle_server.js &
391         sleep 1
392         ./$(NODE_EXE) benchmark/idle_clients.js &
393
394 jslintfix:
395         PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
396
397 jslint:
398         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
399
400 CPPLINT_EXCLUDE ?=
401 CPPLINT_EXCLUDE += src/node_dtrace.cc
402 CPPLINT_EXCLUDE += src/node_dtrace.cc
403 CPPLINT_EXCLUDE += src/node_root_certs.h
404 CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
405 CPPLINT_EXCLUDE += src/queue.h
406 CPPLINT_EXCLUDE += src/tree.h
407 CPPLINT_EXCLUDE += src/v8abbr.h
408
409 CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard src/*.cc src/*.h src/*.c tools/icu/*.h tools/icu/*.cc deps/debugger-agent/include/* deps/debugger-agent/src/*))
410
411 cpplint:
412         @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
413
414 lint: jslint cpplint
415
416 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean check uninstall install install-includes install-bin all staticlib dynamiclib test test-all test-addons build-addons website-upload pkg blog blogclean tar binary release-only bench-http-simple bench-idle bench-all bench bench-misc bench-array bench-buffer bench-net bench-http bench-fs bench-tls