10 EXEEXT := $(shell $(PYTHON) -c \
11 "import sys; print('.exe' if sys.platform == 'win32' else '')")
13 NODE ?= ./iojs$(EXEEXT)
14 NODE_EXE = iojs$(EXEEXT)
15 NODE_G_EXE = iojs_g$(EXEEXT)
17 # Default to verbose builds.
18 # To do quiet/pretty builds, run `make V=` to set V to an empty string,
19 # or set the V environment variable to an empty string.
22 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
23 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
24 ifeq ($(BUILDTYPE),Release)
25 all: out/Makefile $(NODE_EXE)
27 all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
30 # The .PHONY is needed to ensure that we recursively use the out/Makefile
31 # to check for changes.
32 .PHONY: $(NODE_EXE) $(NODE_G_EXE)
34 $(NODE_EXE): config.gypi out/Makefile
35 $(MAKE) -C out BUILDTYPE=Release V=$(V)
36 ln -fs out/Release/$(NODE_EXE) $@
38 $(NODE_G_EXE): config.gypi out/Makefile
39 $(MAKE) -C out BUILDTYPE=Debug V=$(V)
40 ln -fs out/Debug/$(NODE_EXE) $@
42 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
43 $(PYTHON) tools/gyp_node.py -f make
45 config.gypi: configure
47 $(error Stale $@, please re-run ./configure)
49 $(error No $@, please run ./configure first)
53 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
56 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
59 -rm -rf out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE) blog.html email.md
60 @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' | xargs rm -rf; fi
65 -rm -f config.gypi icu_config.gypi
67 -rm -rf $(NODE_EXE) $(NODE_G_EXE) blog.html email.md
70 -rm -rf deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp
71 -rm -f $(BINARYTAR).* $(TARBALL).*
78 test: | cctest # Depends on 'all'.
79 $(PYTHON) tools/test.py --mode=release message parallel sequential -J
84 $(PYTHON) tools/test.py --mode=release parallel -J
87 $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
89 test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE)
90 $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
91 --directory="$(shell pwd)/test/gc/node_modules/weak" \
92 --nodedir="$(shell pwd)"
94 build-addons: $(NODE_EXE)
95 rm -rf test/addons/doc-*/
96 $(NODE) tools/doc/addon-verify.js
98 $(sort $(dir $(wildcard test/addons/*/*.gyp))), \
99 $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
100 --directory="$(shell pwd)/$(dir)" \
101 --nodedir="$(shell pwd)" && ) echo "build done"
103 test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
104 $(PYTHON) tools/test.py --mode=release gc
106 test-build: all build-addons
108 test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
109 $(PYTHON) tools/test.py --mode=debug,release
111 test-all-valgrind: test-build
112 $(PYTHON) tools/test.py --mode=debug,release --valgrind
115 $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release message parallel sequential
117 test-release: test-build
118 $(PYTHON) tools/test.py --mode=release
120 test-debug: test-build
121 $(PYTHON) tools/test.py --mode=debug
123 test-message: test-build
124 $(PYTHON) tools/test.py message
126 test-simple: | cctest # Depends on 'all'.
127 $(PYTHON) tools/test.py parallel sequential
130 $(PYTHON) tools/test.py pummel
133 $(PYTHON) tools/test.py internet
136 $(PYTHON) tools/test.py debugger
138 test-npm: $(NODE_EXE)
139 NODE_EXE=$(NODE_EXE) tools/test-npm.sh
141 test-npm-publish: $(NODE_EXE)
142 npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js
144 test-addons: test-build
145 $(PYTHON) tools/test.py --mode=release addons
148 $(MAKE) --directory=tools faketime
149 $(PYTHON) tools/test.py --mode=release timers
152 $(MAKE) --directory=tools clean
154 apidoc_sources = $(wildcard doc/api/*.markdown)
155 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
156 $(addprefix out/,$(apidoc_sources:.markdown=.json))
158 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
160 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
162 doc: $(apidoc_dirs) $(apiassets) $(apidocs) tools/doc/ $(NODE_EXE)
167 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
173 out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE)
174 $(NODE) tools/doc/generate.js --format=json $< > $@
176 out/doc/api/%.html: doc/api/%.markdown $(NODE_EXE)
177 $(NODE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@
179 docopen: out/doc/api/all.html
180 -google-chrome out/doc/api/all.html
185 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
187 FULLVERSION=$(VERSION)
188 RELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
189 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
190 NPMVERSION=v$(shell cat deps/npm/package.json | grep '"version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')
191 ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
196 ifeq ($(DESTCPU),x64)
199 ifeq ($(DESTCPU),arm)
206 TAG = nightly-$(NIGHTLY)
207 FULLVERSION=$(VERSION)-$(TAG)
209 TARNAME=iojs-$(FULLVERSION)
210 TARBALL=$(TARNAME).tar
211 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
212 BINARYTAR=$(BINARYNAME).tar
213 XZ=$(shell which xz > /dev/null 2>&1; echo $$?)
215 PKG=out/$(TARNAME).pkg
216 PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
218 PKGSRC=iojs-$(DESTCPU)-$(RAWVER).tgz
220 PKGSRC=iojs-$(DESTCPU)-$(RAWVER)-$(TAG).tgz
223 dist: doc $(TARBALL) $(PKG)
228 @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
232 echo "The git repository is not clean." >&2 ; \
233 echo "Please commit changes before building release tarball." >&2 ; \
235 git status --porcelain | egrep -v '^\?\?' >&2 ; \
239 @if [ "$(NIGHTLY)" != "" -o "$(RELEASE)" = "1" ]; then \
243 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
244 echo "Did you remember to update src/node_version.h?" >&2 ; \
253 rm -rf out/deps out/Release
254 $(PYTHON) ./configure --dest-cpu=ia32 --tag=$(TAG)
255 $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)/32
256 rm -rf out/deps out/Release
257 $(PYTHON) ./configure --dest-cpu=x64 --tag=$(TAG)
258 $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
259 SIGN="$(APP_SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
260 lipo $(PKGDIR)/32/usr/local/bin/iojs \
261 $(PKGDIR)/usr/local/bin/iojs \
262 -output $(PKGDIR)/usr/local/bin/iojs-universal \
264 mv $(PKGDIR)/usr/local/bin/iojs-universal $(PKGDIR)/usr/local/bin/iojs
266 cat tools/osx-pkg.pmdoc/index.xml.tmpl | sed -e 's|__iojsversion__|'$(FULLVERSION)'|g' | sed -e 's|__npmversion__|'$(NPMVERSION)'|g' > tools/osx-pkg.pmdoc/index.xml
268 --id "org.nodejs.Node" \
269 --doc tools/osx-pkg.pmdoc \
271 SIGN="$(INT_SIGN)" PKG="$(PKG)" bash tools/osx-productsign.sh
273 $(TARBALL): release-only $(NODE_EXE) doc
274 git checkout-index -a -f --prefix=$(TARNAME)/
275 mkdir -p $(TARNAME)/doc/api
276 cp doc/iojs.1 $(TARNAME)/doc/iojs.1
277 cp -r out/doc/api/* $(TARNAME)/doc/api/
278 rm -rf $(TARNAME)/deps/v8/{test,samples,tools/profviz} # too big
279 rm -rf $(TARNAME)/doc/images # too big
280 rm -rf $(TARNAME)/deps/uv/{docs,samples,test}
281 rm -rf $(TARNAME)/deps/openssl/{doc,demos,test}
282 rm -rf $(TARNAME)/deps/zlib/contrib # too big, unused
283 find $(TARNAME)/ -type l | xargs rm # annoying on windows
284 tar -cf $(TARNAME).tar $(TARNAME)
286 gzip -c -f -9 $(TARNAME).tar > $(TARNAME).tar.gz
288 xz -c -f -$(XZ_COMPRESSION) $(TARNAME).tar > $(TARNAME).tar.xz
294 $(BINARYTAR): release-only
296 rm -rf out/deps out/Release
297 $(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
298 $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
299 cp README.md $(BINARYNAME)
300 cp LICENSE $(BINARYNAME)
301 cp CHANGELOG.md $(BINARYNAME)
302 tar -cf $(BINARYNAME).tar $(BINARYNAME)
304 gzip -c -f -9 $(BINARYNAME).tar > $(BINARYNAME).tar.gz
306 xz -c -f -$(XZ_COMPRESSION) $(BINARYNAME).tar > $(BINARYNAME).tar.xz
312 $(PKGSRC): release-only
314 $(PYTHON) configure --prefix=/ \
315 --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
316 $(MAKE) install DESTDIR=dist
317 (cd dist; find * -type f | sort) > packlist
318 pkg_info -X pkg_install | \
319 egrep '^(MACHINE_ARCH|OPSYS|OS_VERSION|PKGTOOLS_VERSION)' > build-info
320 pkg_create -B build-info -c tools/pkgsrc/comment -d tools/pkgsrc/description \
321 -f packlist -I /opt/local -p dist -U $(PKGSRC)
325 haswrk=$(shell which wrk > /dev/null 2>&1; echo $$?)
328 @echo "please install wrk before proceeding. More information can be found in benchmark/README.md." >&2
333 @$(NODE) benchmark/common.js net
336 @$(NODE) benchmark/common.js crypto
339 @$(NODE) benchmark/common.js tls
342 @$(NODE) benchmark/common.js http
345 @$(NODE) benchmark/common.js fs
348 @$(MAKE) -C benchmark/misc/function_call/
349 @$(NODE) benchmark/common.js misc
352 @$(NODE) benchmark/common.js arrays
355 @$(NODE) benchmark/common.js buffers
358 @$(NODE) benchmark/common.js url
361 @$(NODE) benchmark/common.js events
363 bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events
365 bench: bench-net bench-http bench-fs bench-tls
368 benchmark/http_simple_bench.sh
371 $(NODE) benchmark/idle_server.js &
373 $(NODE) benchmark/idle_clients.js &
376 $(NODE) tools/eslint/bin/eslint.js src lib test --rulesdir tools/eslint-rules --reset --quiet
379 CPPLINT_EXCLUDE += src/node_lttng.cc
380 CPPLINT_EXCLUDE += src/node_root_certs.h
381 CPPLINT_EXCLUDE += src/node_lttng_tp.h
382 CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
383 CPPLINT_EXCLUDE += src/queue.h
384 CPPLINT_EXCLUDE += src/tree.h
385 CPPLINT_EXCLUDE += src/v8abbr.h
387 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/*))
390 @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
394 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \
395 check uninstall install install-includes install-bin all staticlib \
396 dynamiclib test test-all test-addons build-addons website-upload pkg \
397 blog blogclean tar binary release-only bench-http-simple bench-idle \
398 bench-all bench bench-misc bench-array bench-buffer bench-net \
399 bench-http bench-fs bench-tls cctest