11 EXEEXT := $(shell $(PYTHON) -c \
12 "import sys; print('.exe' if sys.platform == 'win32' else '')")
14 NODE ?= ./node$(EXEEXT)
15 NODE_EXE = node$(EXEEXT)
16 NODE_G_EXE = node_g$(EXEEXT)
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.
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)
34 all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
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)
42 $(NODE_EXE): config.gypi
43 $(NINJA) -C out/Release/
44 ln -fs out/Release/$(NODE_EXE) $@
46 $(NODE_G_EXE): config.gypi
47 $(NINJA) -C out/Debug/
48 ln -fs out/Debug/$(NODE_EXE) $@
50 $(NODE_EXE): config.gypi out/Makefile
51 $(MAKE) -C out BUILDTYPE=Release V=$(V)
52 ln -fs out/Release/$(NODE_EXE) $@
54 $(NODE_G_EXE): config.gypi out/Makefile
55 $(MAKE) -C out BUILDTYPE=Debug V=$(V)
56 ln -fs out/Debug/$(NODE_EXE) $@
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
62 $(PYTHON) tools/gyp_node.py -f ninja
64 $(PYTHON) tools/gyp_node.py -f make
67 config.gypi: configure
69 $(error Stale $@, please re-run ./configure)
71 $(error No $@, please run ./configure first)
75 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
78 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
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
87 -rm -f config.gypi icu_config.gypi
89 -rm -rf $(NODE_EXE) $(NODE_G_EXE) blog.html email.md
92 -rm -rf deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp
95 $(PYTHON) tools/test.py --mode=release message parallel sequential -J
100 $(PYTHON) tools/test.py --mode=release parallel -J
103 $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
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)"
110 build-addons: $(NODE_EXE)
111 rm -rf test/addons/doc-*/
112 ./$(NODE_EXE) tools/doc/addon-verify.js
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"
119 test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
120 $(PYTHON) tools/test.py --mode=release gc
122 test-build: all build-addons
124 test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
125 $(PYTHON) tools/test.py --mode=debug,release
128 test-all-valgrind: test-build
129 $(PYTHON) tools/test.py --mode=debug,release --valgrind
131 test-release: test-build
132 $(PYTHON) tools/test.py --mode=release
134 test-debug: test-build
135 $(PYTHON) tools/test.py --mode=debug
137 test-message: test-build
138 $(PYTHON) tools/test.py message
141 $(PYTHON) tools/test.py parallel sequential
144 $(PYTHON) tools/test.py pummel
147 $(PYTHON) tools/test.py internet
150 $(PYTHON) tools/test.py debugger
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 && \
165 rm -rf npm-cache npm-tmp npm-prefix
167 test-npm-publish: $(NODE_EXE)
168 npm_package_config_publishtest=true ./$(NODE_EXE) deps/npm/test/run.js
170 test-addons: test-build
171 $(PYTHON) tools/test.py --mode=release addons
174 $(MAKE) --directory=tools faketime
175 $(PYTHON) tools/test.py --mode=release timers
178 $(MAKE) --directory=tools clean
180 apidoc_sources = $(wildcard doc/api/*.markdown)
181 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
182 $(addprefix out/,$(apidoc_sources:.markdown=.json))
184 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
186 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
190 out/doc/sh_javascript.min.js
192 doc: $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/ out/doc/changelog.html $(NODE_EXE)
197 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
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
206 out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE)
207 out/Release/$(NODE_EXE) tools/doc/generate.js --format=json $< > $@
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 $< > $@
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' >> $@
217 cat $< | ./$(NODE_EXE) tools/doc/node_modules/.bin/marked > $@
219 docopen: out/doc/api/all.html
220 -google-chrome out/doc/api/all.html
225 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
227 RELEASE=$(shell $(PYTHON) tools/getnodeisrelease.py)
228 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
229 ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
234 ifeq ($(DESTCPU),x64)
237 ifeq ($(DESTCPU),arm)
243 TARNAME=node-$(VERSION)
245 TAG = nightly-$(NIGHTLY)
246 TARNAME=node-$(VERSION)-$(TAG)
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
254 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER).tgz
256 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER)-$(TAG).tgz
259 dist: doc $(TARBALL) $(PKG)
264 @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
268 echo "The git repository is not clean." >&2 ; \
269 echo "Please commit changes before building release tarball." >&2 ; \
271 git status --porcelain | egrep -v '^\?\?' >&2 ; \
275 @if [ "$(NIGHTLY)" != "" -o "$(RELEASE)" = "1" ]; then \
279 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
280 echo "Did you remember to update src/node_version.cc?" >&2 ; \
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 \
300 mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
303 --id "org.nodejs.Node" \
304 --doc tools/osx-pkg.pmdoc \
306 SIGN="$(INT_SIGN)" PKG="$(PKG)" bash tools/osx-productsign.sh
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)
318 gzip -f -9 $(TARNAME).tar
322 $(BINARYTAR): release-only
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)
332 gzip -f -9 $(BINARYNAME).tar
336 $(PKGSRC): release-only
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)
350 $(MAKE) -C tools/wrk/ clean
355 $(MAKE) -C tools/wrk/
358 @$(NODE) benchmark/common.js net
361 @$(NODE) benchmark/common.js crypto
364 @$(NODE) benchmark/common.js tls
367 @$(NODE) benchmark/common.js http
370 @$(NODE) benchmark/common.js fs
373 @$(MAKE) -C benchmark/misc/function_call/
374 @$(NODE) benchmark/common.js misc
377 @$(NODE) benchmark/common.js arrays
380 @$(NODE) benchmark/common.js buffers
382 bench-all: bench bench-misc bench-array bench-buffer
384 bench: bench-net bench-http bench-fs bench-tls
387 benchmark/http_simple_bench.sh
390 ./$(NODE_EXE) benchmark/idle_server.js &
392 ./$(NODE_EXE) benchmark/idle_clients.js &
395 PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
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
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
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/*))
412 @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
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