8 STAGINGSERVER ?= iojs-www
10 OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]')
13 EXEEXT := $(shell $(PYTHON) -c \
14 "import sys; print('.exe' if sys.platform == 'win32' else '')")
16 NODE ?= ./iojs$(EXEEXT)
17 NODE_EXE = iojs$(EXEEXT)
18 NODE_G_EXE = iojs_g$(EXEEXT)
20 # Default to verbose builds.
21 # To do quiet/pretty builds, run `make V=` to set V to an empty string,
22 # or set the V environment variable to an empty string.
25 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
26 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
27 ifeq ($(BUILDTYPE),Release)
28 all: out/Makefile $(NODE_EXE)
30 all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
33 # The .PHONY is needed to ensure that we recursively use the out/Makefile
34 # to check for changes.
35 .PHONY: $(NODE_EXE) $(NODE_G_EXE)
37 $(NODE_EXE): config.gypi out/Makefile
38 $(MAKE) -C out BUILDTYPE=Release V=$(V)
39 ln -fs out/Release/$(NODE_EXE) $@
41 $(NODE_G_EXE): config.gypi out/Makefile
42 $(MAKE) -C out BUILDTYPE=Debug V=$(V)
43 ln -fs out/Debug/$(NODE_EXE) $@
45 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
46 $(PYTHON) tools/gyp_node.py -f make
48 config.gypi: configure
50 $(error Stale $@, please re-run ./configure)
52 $(error No $@, please run ./configure first)
56 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
59 $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
62 -rm -rf out/Makefile $(NODE_EXE) $(NODE_G_EXE) out/$(BUILDTYPE)/$(NODE_EXE)
63 @if [ -d out ]; then find out/ -name '*.o' -o -name '*.a' | xargs rm -rf; fi
68 -rm -f config.gypi icu_config.gypi
70 -rm -rf $(NODE_EXE) $(NODE_G_EXE)
73 -rm -rf deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp
74 -rm -f $(BINARYTAR).* $(TARBALL).*
81 test: | cctest # Depends on 'all'.
82 $(PYTHON) tools/test.py --mode=release message parallel sequential -J
87 $(PYTHON) tools/test.py --mode=release parallel -J
90 $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
92 test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE)
93 $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
94 --directory="$(shell pwd)/test/gc/node_modules/weak" \
95 --nodedir="$(shell pwd)"
97 build-addons: $(NODE_EXE)
98 rm -rf test/addons/doc-*/
99 $(NODE) tools/doc/addon-verify.js
101 $(sort $(dir $(wildcard test/addons/*/*.gyp))), \
102 $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
103 --directory="$(shell pwd)/$(dir)" \
104 --nodedir="$(shell pwd)" && ) echo "build done"
106 test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
107 $(PYTHON) tools/test.py --mode=release gc
109 test-build: all build-addons
111 test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
112 $(PYTHON) tools/test.py --mode=debug,release
114 test-all-valgrind: test-build
115 $(PYTHON) tools/test.py --mode=debug,release --valgrind
118 $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release message parallel sequential
120 test-release: test-build
121 $(PYTHON) tools/test.py --mode=release
123 test-debug: test-build
124 $(PYTHON) tools/test.py --mode=debug
126 test-message: test-build
127 $(PYTHON) tools/test.py message
129 test-simple: | cctest # Depends on 'all'.
130 $(PYTHON) tools/test.py parallel sequential
133 $(PYTHON) tools/test.py pummel
136 $(PYTHON) tools/test.py internet
139 $(PYTHON) tools/test.py debugger
141 test-npm: $(NODE_EXE)
142 NODE=$(NODE) tools/test-npm.sh
144 test-npm-publish: $(NODE_EXE)
145 npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js
147 test-addons: test-build
148 $(PYTHON) tools/test.py --mode=release addons
151 $(MAKE) --directory=tools faketime
152 $(PYTHON) tools/test.py --mode=release timers
155 $(MAKE) --directory=tools clean
157 apidoc_sources = $(wildcard doc/api/*.markdown)
158 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
159 $(addprefix out/,$(apidoc_sources:.markdown=.json))
161 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
163 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
165 doc: $(apidoc_dirs) $(apiassets) $(apidocs) tools/doc/ $(NODE_EXE)
170 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
176 out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE)
177 $(NODE) tools/doc/generate.js --format=json $< > $@
179 out/doc/api/%.html: doc/api/%.markdown $(NODE_EXE)
180 $(NODE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@
182 docopen: out/doc/api/all.html
183 -google-chrome out/doc/api/all.html
189 $(PYTHON) ./configure $(CONFIG_FLAGS)
193 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
196 # For nightly builds, you must set DISTTYPE to "nightly", "next-nightly" or
197 # "custom". For the nightly and next-nightly case, you need to set DATESTRING
198 # and COMMIT in order to properly name the build.
199 # For the rc case you need to set CUSTOMTAG to an appropriate CUSTOMTAG number
204 ifeq ($(DISTTYPE),release)
205 FULLVERSION=$(VERSION)
206 else # ifeq ($(DISTTYPE),release)
207 ifeq ($(DISTTYPE),custom)
209 $(error CUSTOMTAG is not set for DISTTYPE=custom)
210 endif # ifndef CUSTOMTAG
212 else # ifeq ($(DISTTYPE),custom)
214 $(error DATESTRING is not set for nightly)
215 endif # ifndef DATESTRING
217 $(error COMMIT is not set for nightly)
218 endif # ifndef COMMIT
219 ifneq ($(DISTTYPE),nightly)
220 ifneq ($(DISTTYPE),next-nightly)
221 $(error DISTTYPE is not release, custom, nightly or next-nightly)
222 endif # ifneq ($(DISTTYPE),next-nightly)
223 endif # ifneq ($(DISTTYPE),nightly)
224 TAG=$(DISTTYPE)$(DATESTRING)$(COMMIT)
225 endif # ifeq ($(DISTTYPE),custom)
226 FULLVERSION=$(VERSION)-$(TAG)
227 endif # ifeq ($(DISTTYPE),release)
229 DISTTYPEDIR ?= $(DISTTYPE)
230 RELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
231 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
232 NPMVERSION=v$(shell cat deps/npm/package.json | grep '"version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')
234 ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
239 ifeq ($(DESTCPU),x64)
242 ifeq ($(DESTCPU),arm)
245 ifeq ($(DESTCPU),ppc64)
248 ifeq ($(DESTCPU),ppc)
257 # enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel
261 ifeq ($(DESTCPU),ia32)
265 TARNAME=iojs-$(FULLVERSION)
266 TARBALL=$(TARNAME).tar
267 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
268 BINARYTAR=$(BINARYNAME).tar
269 # OSX doesn't have xz installed by default, http://macpkg.sourceforge.net/
270 XZ=$(shell which xz > /dev/null 2>&1; echo $$?)
273 PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
277 @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
281 echo "The git repository is not clean." >&2 ; \
282 echo "Please commit changes before building release tarball." >&2 ; \
284 git status --porcelain | egrep -v '^\?\?' >&2 ; \
288 @if [ "$(DISTTYPE)" != "release" -o "$(RELEASE)" = "1" ]; then \
292 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
293 echo "Did you remember to update src/node_version.h?" >&2 ; \
300 rm -rf out/deps out/Release
301 $(PYTHON) ./configure \
304 --release-urlbase=$(RELEASE_URLBASE) \
306 $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
307 SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
308 cat tools/osx-pkg.pmdoc/index.xml.tmpl \
309 | sed -E "s/\\{iojsversion\\}/$(FULLVERSION)/g" \
310 | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
311 > tools/osx-pkg.pmdoc/index.xml
313 --id "org.iojs.pkg" \
314 --doc tools/osx-pkg.pmdoc \
316 SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
321 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
322 scp -p iojs-$(FULLVERSION).pkg $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).pkg
323 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).pkg.done"
325 $(TARBALL): release-only $(NODE_EXE) doc
326 git checkout-index -a -f --prefix=$(TARNAME)/
327 mkdir -p $(TARNAME)/doc/api
328 cp doc/iojs.1 $(TARNAME)/doc/iojs.1
329 cp -r out/doc/api/* $(TARNAME)/doc/api/
330 rm -rf $(TARNAME)/deps/v8/{test,samples,tools/profviz} # too big
331 rm -rf $(TARNAME)/doc/images # too big
332 rm -rf $(TARNAME)/deps/uv/{docs,samples,test}
333 rm -rf $(TARNAME)/deps/openssl/{doc,demos,test}
334 rm -rf $(TARNAME)/deps/zlib/contrib # too big, unused
335 find $(TARNAME)/ -type l | xargs rm # annoying on windows
336 tar -cf $(TARNAME).tar $(TARNAME)
338 gzip -c -f -9 $(TARNAME).tar > $(TARNAME).tar.gz
340 xz -c -f -$(XZ_COMPRESSION) $(TARNAME).tar > $(TARNAME).tar.xz
347 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
348 scp -p iojs-$(FULLVERSION).tar.gz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.gz
349 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.gz.done"
351 scp -p iojs-$(FULLVERSION).tar.xz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.xz
352 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.xz.done"
356 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
357 scp -r out/doc/ $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/
358 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/doc.done"
360 $(TARBALL)-headers: config.gypi release-only
361 $(PYTHON) ./configure \
363 --dest-cpu=$(DESTCPU) \
365 --release-urlbase=$(RELEASE_URLBASE) \
367 HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
368 find $(TARNAME)/ -type l | xargs rm # annoying on windows
369 tar -cf $(TARNAME)-headers.tar $(TARNAME)
371 gzip -c -f -9 $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.gz
373 xz -c -f -$(XZ_COMPRESSION) $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.xz
375 rm $(TARNAME)-headers.tar
377 tar-headers: $(TARBALL)-headers
379 tar-headers-upload: tar-headers
380 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
381 scp -p $(TARNAME)-headers.tar.gz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz
382 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz.done"
384 scp -p $(TARNAME)-headers.tar.xz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz
385 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz.done"
388 $(BINARYTAR): release-only
390 rm -rf out/deps out/Release
391 $(PYTHON) ./configure \
393 --dest-cpu=$(DESTCPU) \
395 --release-urlbase=$(RELEASE_URLBASE) \
397 $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
398 cp README.md $(BINARYNAME)
399 cp LICENSE $(BINARYNAME)
400 cp CHANGELOG.md $(BINARYNAME)
401 tar -cf $(BINARYNAME).tar $(BINARYNAME)
403 gzip -c -f -9 $(BINARYNAME).tar > $(BINARYNAME).tar.gz
405 xz -c -f -$(XZ_COMPRESSION) $(BINARYNAME).tar > $(BINARYNAME).tar.xz
411 binary-upload: binary
412 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
413 scp -p iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz
414 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz.done"
416 scp -p iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz
417 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz.done"
420 haswrk=$(shell which wrk > /dev/null 2>&1; echo $$?)
423 @echo "please install wrk before proceeding. More information can be found in benchmark/README.md." >&2
428 @$(NODE) benchmark/common.js net
431 @$(NODE) benchmark/common.js crypto
434 @$(NODE) benchmark/common.js tls
437 @$(NODE) benchmark/common.js http
440 @$(NODE) benchmark/common.js fs
443 @$(MAKE) -C benchmark/misc/function_call/
444 @$(NODE) benchmark/common.js misc
447 @$(NODE) benchmark/common.js arrays
450 @$(NODE) benchmark/common.js buffers
453 @$(NODE) benchmark/common.js url
456 @$(NODE) benchmark/common.js events
458 bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events
460 bench: bench-net bench-http bench-fs bench-tls
463 benchmark/http_simple_bench.sh
466 $(NODE) benchmark/idle_server.js &
468 $(NODE) benchmark/idle_clients.js &
471 $(NODE) tools/eslint/bin/eslint.js src lib test --rulesdir tools/eslint-rules --reset --quiet
474 CPPLINT_EXCLUDE += src/node_lttng.cc
475 CPPLINT_EXCLUDE += src/node_root_certs.h
476 CPPLINT_EXCLUDE += src/node_lttng_tp.h
477 CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
478 CPPLINT_EXCLUDE += src/queue.h
479 CPPLINT_EXCLUDE += src/tree.h
480 CPPLINT_EXCLUDE += src/v8abbr.h
482 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/*))
485 @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
489 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \
490 check uninstall install install-includes install-bin all staticlib \
491 dynamiclib test test-all test-addons build-addons website-upload pkg \
492 blog blogclean tar binary release-only bench-http-simple bench-idle \
493 bench-all bench bench-misc bench-array bench-buffer bench-net \
494 bench-http bench-fs bench-tls cctest run-ci