10 STAGINGSERVER ?= node-www
12 OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]')
15 EXEEXT := $(shell $(PYTHON) -c \
16 "import sys; print('.exe' if sys.platform == 'win32' else '')")
18 NODE ?= ./node$(EXEEXT)
19 NODE_EXE = node$(EXEEXT)
20 NODE_G_EXE = node_g$(EXEEXT)
22 # Flags for packaging.
23 BUILD_DOWNLOAD_FLAGS ?= --download=all
24 BUILD_INTL_FLAGS ?= --with-intl=small-icu
25 BUILD_RELEASE_FLAGS ?= $(BUILD_DOWNLOAD_FLAGS) $(BUILD_INTL_FLAGS)
27 # Default to verbose builds.
28 # To do quiet/pretty builds, run `make V=` to set V to an empty string,
29 # or set the V environment variable to an empty string.
32 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
33 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
34 ifeq ($(BUILDTYPE),Release)
35 all: out/Makefile $(NODE_EXE)
37 all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
40 # The .PHONY is needed to ensure that we recursively use the out/Makefile
41 # to check for changes.
42 .PHONY: $(NODE_EXE) $(NODE_G_EXE)
44 $(NODE_EXE): config.gypi out/Makefile
45 $(MAKE) -C out BUILDTYPE=Release V=$(V)
46 ln -fs out/Release/$(NODE_EXE) $@
48 $(NODE_G_EXE): config.gypi out/Makefile
49 $(MAKE) -C out BUILDTYPE=Debug V=$(V)
50 ln -fs out/Debug/$(NODE_EXE) $@
52 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
53 $(PYTHON) tools/gyp_node.py -f make
55 config.gypi: configure
57 $(error Stale $@, please re-run ./configure)
59 $(error No $@, please run ./configure first)
63 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
66 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
69 -rm -rf out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE)
70 @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' -o -name '*.d' | xargs rm -rf; fi
72 @if [ -d deps/icu ]; then echo deleting deps/icu; rm -rf deps/icu; fi
77 -rm -f config.gypi icu_config.gypi config_fips.gypi
79 -rm -rf $(NODE_EXE) $(NODE_G_EXE)
82 -rm -rf deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp
83 -rm -f $(BINARYTAR).* $(TARBALL).*
90 test: | cctest # Depends on 'all'.
91 $(PYTHON) tools/test.py --mode=release message parallel sequential -J
96 $(PYTHON) tools/test.py --mode=release parallel -J
99 $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
101 test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE)
102 $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
103 --directory="$(shell pwd)/test/gc/node_modules/weak" \
104 --nodedir="$(shell pwd)"
106 # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
107 test/addons/.docbuildstamp: doc/api/addons.markdown
108 $(RM) -r test/addons/doc-*/
109 $(NODE) tools/doc/addon-verify.js
112 ADDONS_BINDING_GYPS := \
113 $(filter-out test/addons/doc-*/binding.gyp, \
114 $(wildcard test/addons/*/binding.gyp))
116 # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
117 test/addons/.buildstamp: $(ADDONS_BINDING_GYPS) | test/addons/.docbuildstamp
118 # Cannot use $(wildcard test/addons/*/) here, it's evaluated before
119 # embedded addons have been generated from the documentation.
120 for dirname in test/addons/*/; do \
121 $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
122 --directory="$$PWD/$$dirname" \
127 # .buildstamp and .docbuildstamp need $(NODE_EXE) but cannot depend on it
128 # directly because it calls make recursively. The parent make cannot know
129 # if the subprocess touched anything so it pessimistically assumes that
130 # .buildstamp and .docbuildstamp are out of date and need a rebuild.
131 # Just goes to show that recursive make really is harmful...
132 # TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
133 build-addons: $(NODE_EXE) test/addons/.buildstamp
135 test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
136 $(PYTHON) tools/test.py --mode=release gc
138 test-build: | all build-addons
140 test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
141 $(PYTHON) tools/test.py --mode=debug,release
143 test-all-valgrind: test-build
144 $(PYTHON) tools/test.py --mode=debug,release --valgrind
146 test-ci: | build-addons
147 $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release --flaky-tests=$(FLAKY_TESTS) \
148 $(TEST_CI_ARGS) addons message parallel sequential
150 test-release: test-build
151 $(PYTHON) tools/test.py --mode=release
153 test-debug: test-build
154 $(PYTHON) tools/test.py --mode=debug
156 test-message: test-build
157 $(PYTHON) tools/test.py message
159 test-simple: | cctest # Depends on 'all'.
160 $(PYTHON) tools/test.py parallel sequential
163 $(PYTHON) tools/test.py pummel
166 $(PYTHON) tools/test.py internet
169 $(PYTHON) tools/test.py debugger
171 test-npm: $(NODE_EXE)
172 NODE=$(NODE) tools/test-npm.sh
174 test-npm-publish: $(NODE_EXE)
175 npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js
177 test-addons: test-build
178 $(PYTHON) tools/test.py --mode=release addons
181 $(MAKE) --directory=tools faketime
182 $(PYTHON) tools/test.py --mode=release timers
185 $(MAKE) --directory=tools clean
187 apidoc_sources = $(wildcard doc/api/*.markdown)
188 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
189 $(addprefix out/,$(apidoc_sources:.markdown=.json))
191 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
193 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
195 doc: $(apidoc_dirs) $(apiassets) $(apidocs) tools/doc/ $(NODE_EXE)
200 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
206 out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE)
207 $(NODE) tools/doc/generate.js --format=json $< > $@
209 out/doc/api/%.html: doc/api/%.markdown $(NODE_EXE)
210 $(NODE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@
212 docopen: out/doc/api/all.html
213 -google-chrome out/doc/api/all.html
219 $(PYTHON) ./configure $(CONFIG_FLAGS)
223 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
226 # For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
227 # "custom". For the nightly and next-nightly case, you need to set DATESTRING
228 # and COMMIT in order to properly name the build.
229 # For the rc case you need to set CUSTOMTAG to an appropriate CUSTOMTAG number
234 ifeq ($(DISTTYPE),release)
235 FULLVERSION=$(VERSION)
236 else # ifeq ($(DISTTYPE),release)
237 ifeq ($(DISTTYPE),custom)
239 $(error CUSTOMTAG is not set for DISTTYPE=custom)
240 endif # ifndef CUSTOMTAG
242 else # ifeq ($(DISTTYPE),custom)
244 $(error DATESTRING is not set for nightly)
245 endif # ifndef DATESTRING
247 $(error COMMIT is not set for nightly)
248 endif # ifndef COMMIT
249 ifneq ($(DISTTYPE),nightly)
250 ifneq ($(DISTTYPE),next-nightly)
251 $(error DISTTYPE is not release, custom, nightly or next-nightly)
252 endif # ifneq ($(DISTTYPE),next-nightly)
253 endif # ifneq ($(DISTTYPE),nightly)
254 TAG=$(DISTTYPE)$(DATESTRING)$(COMMIT)
255 endif # ifeq ($(DISTTYPE),custom)
256 FULLVERSION=$(VERSION)-$(TAG)
257 endif # ifeq ($(DISTTYPE),release)
259 DISTTYPEDIR ?= $(DISTTYPE)
260 RELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
261 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
262 NPMVERSION=v$(shell cat deps/npm/package.json | grep '"version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')
264 ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
269 ifeq ($(DESTCPU),x64)
272 ifeq ($(DESTCPU),arm)
275 ifeq ($(DESTCPU),ppc64)
278 ifeq ($(DESTCPU),ppc)
287 # enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel
291 ifeq ($(DESTCPU),ia32)
295 TARNAME=node-$(FULLVERSION)
296 TARBALL=$(TARNAME).tar
297 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
298 BINARYTAR=$(BINARYNAME).tar
299 # OSX doesn't have xz installed by default, http://macpkg.sourceforge.net/
300 XZ=$(shell which xz > /dev/null 2>&1; echo $$?)
303 PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
307 @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
311 echo "The git repository is not clean." >&2 ; \
312 echo "Please commit changes before building release tarball." >&2 ; \
314 git status --porcelain | egrep -v '^\?\?' >&2 ; \
318 @if [ "$(DISTTYPE)" != "release" -o "$(RELEASE)" = "1" ]; then \
322 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
323 echo "Did you remember to update src/node_version.h?" >&2 ; \
330 rm -rf out/deps out/Release
331 $(PYTHON) ./configure \
334 --release-urlbase=$(RELEASE_URLBASE) \
335 $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
336 $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
337 SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
338 cat tools/osx-pkg.pmdoc/index.xml.tmpl \
339 | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
340 | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
341 > tools/osx-pkg.pmdoc/index.xml
343 --id "org.nodejs.pkg" \
344 --doc tools/osx-pkg.pmdoc \
346 SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
351 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
352 chmod 664 node-$(FULLVERSION).pkg
353 scp -p node-$(FULLVERSION).pkg $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).pkg
354 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).pkg.done"
356 $(TARBALL): release-only $(NODE_EXE) doc
357 git checkout-index -a -f --prefix=$(TARNAME)/
358 mkdir -p $(TARNAME)/doc/api
359 cp doc/node.1 $(TARNAME)/doc/node.1
360 cp -r out/doc/api/* $(TARNAME)/doc/api/
361 rm -rf $(TARNAME)/deps/v8/{test,samples,tools/profviz} # too big
362 rm -rf $(TARNAME)/doc/images # too big
363 rm -rf $(TARNAME)/deps/uv/{docs,samples,test}
364 rm -rf $(TARNAME)/deps/openssl/{doc,demos,test}
365 rm -rf $(TARNAME)/deps/zlib/contrib # too big, unused
366 find $(TARNAME)/ -type l | xargs rm # annoying on windows
367 tar -cf $(TARNAME).tar $(TARNAME)
369 gzip -c -f -9 $(TARNAME).tar > $(TARNAME).tar.gz
371 xz -c -f -$(XZ_COMPRESSION) $(TARNAME).tar > $(TARNAME).tar.xz
378 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
379 chmod 664 node-$(FULLVERSION).tar.gz
380 scp -p node-$(FULLVERSION).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.gz
381 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.gz.done"
383 chmod 664 node-$(FULLVERSION).tar.xz
384 scp -p node-$(FULLVERSION).tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.xz
385 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.xz.done"
389 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
390 chmod -R ug=rw-x+X,o=r+X out/doc/
391 scp -pr out/doc/ $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/
392 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs.done"
394 $(TARBALL)-headers: config.gypi release-only
395 $(PYTHON) ./configure \
397 --dest-cpu=$(DESTCPU) \
399 --release-urlbase=$(RELEASE_URLBASE) \
400 $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
401 HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
402 find $(TARNAME)/ -type l | xargs rm # annoying on windows
403 tar -cf $(TARNAME)-headers.tar $(TARNAME)
405 gzip -c -f -9 $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.gz
407 xz -c -f -$(XZ_COMPRESSION) $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.xz
409 rm $(TARNAME)-headers.tar
411 tar-headers: $(TARBALL)-headers
413 tar-headers-upload: tar-headers
414 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
415 chmod 664 $(TARNAME)-headers.tar.gz
416 scp -p $(TARNAME)-headers.tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz
417 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz.done"
419 chmod 664 $(TARNAME)-headers.tar.xz
420 scp -p $(TARNAME)-headers.tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz
421 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz.done"
424 $(BINARYTAR): release-only
426 rm -rf out/deps out/Release
427 $(PYTHON) ./configure \
429 --dest-cpu=$(DESTCPU) \
431 --release-urlbase=$(RELEASE_URLBASE) \
432 $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
433 $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
434 cp README.md $(BINARYNAME)
435 cp LICENSE $(BINARYNAME)
436 cp CHANGELOG.md $(BINARYNAME)
437 tar -cf $(BINARYNAME).tar $(BINARYNAME)
439 gzip -c -f -9 $(BINARYNAME).tar > $(BINARYNAME).tar.gz
441 xz -c -f -$(XZ_COMPRESSION) $(BINARYNAME).tar > $(BINARYNAME).tar.xz
447 binary-upload: binary
448 ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"
449 chmod 664 node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz
450 scp -p node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz
451 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz.done"
453 chmod 664 node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz
454 scp -p node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz
455 ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz.done"
458 haswrk=$(shell which wrk > /dev/null 2>&1; echo $$?)
461 @echo "please install wrk before proceeding. More information can be found in benchmark/README.md." >&2
466 @$(NODE) benchmark/common.js net
469 @$(NODE) benchmark/common.js crypto
472 @$(NODE) benchmark/common.js tls
475 @$(NODE) benchmark/common.js http
478 @$(NODE) benchmark/common.js fs
481 @$(MAKE) -C benchmark/misc/function_call/
482 @$(NODE) benchmark/common.js misc
485 @$(NODE) benchmark/common.js arrays
488 @$(NODE) benchmark/common.js buffers
491 @$(NODE) benchmark/common.js url
494 @$(NODE) benchmark/common.js events
496 bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events
498 bench: bench-net bench-http bench-fs bench-tls
501 benchmark/http_simple_bench.sh
504 $(NODE) benchmark/idle_server.js &
506 $(NODE) benchmark/idle_clients.js &
509 $(NODE) tools/eslint/bin/eslint.js src lib test tools/eslint-rules \
510 --rulesdir tools/eslint-rules --reset --quiet
513 CPPLINT_EXCLUDE += src/node_lttng.cc
514 CPPLINT_EXCLUDE += src/node_root_certs.h
515 CPPLINT_EXCLUDE += src/node_lttng_tp.h
516 CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
517 CPPLINT_EXCLUDE += src/queue.h
518 CPPLINT_EXCLUDE += src/tree.h
519 CPPLINT_EXCLUDE += src/v8abbr.h
520 CPPLINT_EXCLUDE += $(wildcard test/addons/doc-*/*.cc test/addons/doc-*/*.h)
522 CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
523 deps/debugger-agent/include/* \
524 deps/debugger-agent/src/* \
535 @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
539 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \
540 check uninstall install install-includes install-bin all staticlib \
541 dynamiclib test test-all test-addons build-addons website-upload pkg \
542 blog blogclean tar binary release-only bench-http-simple bench-idle \
543 bench-all bench bench-misc bench-array bench-buffer bench-net \
544 bench-http bench-fs bench-tls cctest run-ci