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)
249 # enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel
253 ifeq ($(DESTCPU),ia32)
257 TARNAME=iojs-$(FULLVERSION)
258 TARBALL=$(TARNAME).tar
259 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
260 BINARYTAR=$(BINARYNAME).tar
261 # OSX doesn't have xz installed by default, http://macpkg.sourceforge.net/
262 XZ=$(shell which xz > /dev/null 2>&1; echo $$?)
265 PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
269 @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
273 echo "The git repository is not clean." >&2 ; \
274 echo "Please commit changes before building release tarball." >&2 ; \
276 git status --porcelain | egrep -v '^\?\?' >&2 ; \
280 @if [ "$(DISTTYPE)" != "release" -o "$(RELEASE)" = "1" ]; then \
284 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
285 echo "Did you remember to update src/node_version.h?" >&2 ; \
292 rm -rf out/deps out/Release
293 $(PYTHON) ./configure --dest-cpu=x64 --tag=$(TAG)
294 $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
295 SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
296 cat tools/osx-pkg.pmdoc/index.xml.tmpl \
297 | sed -E "s/\\{iojsversion\\}/$(FULLVERSION)/g" \
298 | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
299 > tools/osx-pkg.pmdoc/index.xml
301 --id "org.iojs.pkg" \
302 --doc tools/osx-pkg.pmdoc \
304 SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
309 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
310 scp -p iojs-$(FULLVERSION).pkg $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).pkg
311 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).pkg.done"
313 $(TARBALL): release-only $(NODE_EXE) doc
314 git checkout-index -a -f --prefix=$(TARNAME)/
315 mkdir -p $(TARNAME)/doc/api
316 cp doc/iojs.1 $(TARNAME)/doc/iojs.1
317 cp -r out/doc/api/* $(TARNAME)/doc/api/
318 rm -rf $(TARNAME)/deps/v8/{test,samples,tools/profviz} # too big
319 rm -rf $(TARNAME)/doc/images # too big
320 rm -rf $(TARNAME)/deps/uv/{docs,samples,test}
321 rm -rf $(TARNAME)/deps/openssl/{doc,demos,test}
322 rm -rf $(TARNAME)/deps/zlib/contrib # too big, unused
323 find $(TARNAME)/ -type l | xargs rm # annoying on windows
324 tar -cf $(TARNAME).tar $(TARNAME)
326 gzip -c -f -9 $(TARNAME).tar > $(TARNAME).tar.gz
328 xz -c -f -$(XZ_COMPRESSION) $(TARNAME).tar > $(TARNAME).tar.xz
335 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
336 scp -p iojs-$(FULLVERSION).tar.gz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.gz
337 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.gz.done"
339 scp -p iojs-$(FULLVERSION).tar.xz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.xz
340 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION).tar.xz.done"
344 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
345 scp -r out/doc/ $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/
346 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/doc.done"
348 $(TARBALL)-headers: config.gypi release-only
349 $(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
350 HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
351 find $(TARNAME)/ -type l | xargs rm # annoying on windows
352 tar -cf $(TARNAME)-headers.tar $(TARNAME)
354 gzip -c -f -9 $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.gz
356 xz -c -f -$(XZ_COMPRESSION) $(TARNAME)-headers.tar > $(TARNAME)-headers.tar.xz
358 rm $(TARNAME)-headers.tar
360 tar-headers: $(TARBALL)-headers
362 tar-headers-upload: tar-headers
363 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
364 scp -p $(TARNAME)-headers.tar.gz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz
365 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.gz.done"
367 scp -p $(TARNAME)-headers.tar.xz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz
368 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME)-headers.tar.xz.done"
371 $(BINARYTAR): release-only
373 rm -rf out/deps out/Release
374 $(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
375 $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
376 cp README.md $(BINARYNAME)
377 cp LICENSE $(BINARYNAME)
378 cp CHANGELOG.md $(BINARYNAME)
379 tar -cf $(BINARYNAME).tar $(BINARYNAME)
381 gzip -c -f -9 $(BINARYNAME).tar > $(BINARYNAME).tar.gz
383 xz -c -f -$(XZ_COMPRESSION) $(BINARYNAME).tar > $(BINARYNAME).tar.xz
389 binary-upload: binary
390 ssh $(STAGINGSERVER) "mkdir -p staging/$(DISTTYPEDIR)/$(FULLVERSION)"
391 scp -p iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz
392 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.gz.done"
394 scp -p iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz $(STAGINGSERVER):staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz
395 ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/iojs-$(FULLVERSION)-$(OSTYPE)-$(ARCH).tar.xz.done"
398 haswrk=$(shell which wrk > /dev/null 2>&1; echo $$?)
401 @echo "please install wrk before proceeding. More information can be found in benchmark/README.md." >&2
406 @$(NODE) benchmark/common.js net
409 @$(NODE) benchmark/common.js crypto
412 @$(NODE) benchmark/common.js tls
415 @$(NODE) benchmark/common.js http
418 @$(NODE) benchmark/common.js fs
421 @$(MAKE) -C benchmark/misc/function_call/
422 @$(NODE) benchmark/common.js misc
425 @$(NODE) benchmark/common.js arrays
428 @$(NODE) benchmark/common.js buffers
431 @$(NODE) benchmark/common.js url
434 @$(NODE) benchmark/common.js events
436 bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events
438 bench: bench-net bench-http bench-fs bench-tls
441 benchmark/http_simple_bench.sh
444 $(NODE) benchmark/idle_server.js &
446 $(NODE) benchmark/idle_clients.js &
449 $(NODE) tools/eslint/bin/eslint.js src lib test --rulesdir tools/eslint-rules --reset --quiet
452 CPPLINT_EXCLUDE += src/node_lttng.cc
453 CPPLINT_EXCLUDE += src/node_root_certs.h
454 CPPLINT_EXCLUDE += src/node_lttng_tp.h
455 CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
456 CPPLINT_EXCLUDE += src/queue.h
457 CPPLINT_EXCLUDE += src/tree.h
458 CPPLINT_EXCLUDE += src/v8abbr.h
460 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/*))
463 @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
467 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \
468 check uninstall install install-includes install-bin all staticlib \
469 dynamiclib test test-all test-addons build-addons website-upload pkg \
470 blog blogclean tar binary release-only bench-http-simple bench-idle \
471 bench-all bench bench-misc bench-array bench-buffer bench-net \
472 bench-http bench-fs bench-tls cctest run-ci