v8: upgrade to 3.22.24.5
[platform/upstream/nodejs.git] / Makefile
1 -include config.mk
2
3 BUILDTYPE ?= Release
4 PYTHON ?= python
5 NINJA ?= ninja
6 DESTDIR ?=
7 SIGN ?=
8 PREFIX ?= /usr/local
9
10 NODE ?= ./node
11
12 # Default to verbose builds.
13 # To do quiet/pretty builds, run `make V=` to set V to an empty string,
14 # or set the V environment variable to an empty string.
15 V ?= 1
16
17 ifeq ($(USE_NINJA),1)
18 ifneq ($(V),)
19 NINJA := $(NINJA) -v
20 endif
21 endif
22
23 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
24 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
25 ifeq ($(BUILDTYPE),Release)
26 all: out/Makefile node
27 else
28 all: out/Makefile node node_g
29 endif
30
31 # The .PHONY is needed to ensure that we recursively use the out/Makefile
32 # to check for changes.
33 .PHONY: node node_g
34
35 ifeq ($(USE_NINJA),1)
36 node: config.gypi
37         $(NINJA) -C out/Release/
38         ln -fs out/Release/node node
39
40 node_g: config.gypi
41         $(NINJA) -C out/Debug/
42         ln -fs out/Debug/node $@
43 else
44 node: config.gypi out/Makefile
45         $(MAKE) -C out BUILDTYPE=Release V=$(V)
46         ln -fs out/Release/node node
47
48 node_g: config.gypi out/Makefile
49         $(MAKE) -C out BUILDTYPE=Debug V=$(V)
50         ln -fs out/Debug/node $@
51 endif
52
53 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
54 ifeq ($(USE_NINJA),1)
55         touch out/Makefile
56         $(PYTHON) tools/gyp_node.py -f ninja
57 else
58         $(PYTHON) tools/gyp_node.py -f make
59 endif
60
61 config.gypi: configure
62         if [ -f $@ ]; then
63                 $(error Stale $@, please re-run ./configure)
64         else
65                 $(error No $@, please run ./configure first)
66         fi
67
68 install: all
69         $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
70
71 uninstall:
72         $(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
73
74 clean:
75         -rm -rf out/Makefile node node_g out/$(BUILDTYPE)/node blog.html email.md
76         -find out/ -name '*.o' -o -name '*.a' | xargs rm -rf
77         -rm -rf node_modules
78
79 distclean:
80         -rm -rf out
81         -rm -f config.gypi
82         -rm -f config.mk
83         -rm -rf node node_g blog.html email.md
84         -rm -rf node_modules
85
86 test: all
87         $(PYTHON) tools/test.py --mode=release simple message
88         $(MAKE) jslint
89         $(MAKE) cpplint
90
91 test-http1: all
92         $(PYTHON) tools/test.py --mode=release --use-http1 simple message
93
94 test-valgrind: all
95         $(PYTHON) tools/test.py --mode=release --valgrind simple message
96
97 test/gc/node_modules/weak/build/Release/weakref.node:
98         @if [ ! -f node ]; then make all; fi
99         ./node deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
100                 --directory="$(shell pwd)/test/gc/node_modules/weak" \
101                 --nodedir="$(shell pwd)"
102
103 test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
104         $(PYTHON) tools/test.py --mode=release gc
105
106 test-all: all test/gc/node_modules/weak/build/Release/weakref.node
107         $(PYTHON) tools/test.py --mode=debug,release
108         make test-npm
109
110 test-all-http1: all
111         $(PYTHON) tools/test.py --mode=debug,release --use-http1
112
113 test-all-valgrind: all
114         $(PYTHON) tools/test.py --mode=debug,release --valgrind
115
116 test-release: all
117         $(PYTHON) tools/test.py --mode=release
118
119 test-debug: all
120         $(PYTHON) tools/test.py --mode=debug
121
122 test-message: all
123         $(PYTHON) tools/test.py message
124
125 test-simple: all
126         $(PYTHON) tools/test.py simple
127
128 test-pummel: all
129         $(PYTHON) tools/test.py pummel
130
131 test-internet: all
132         $(PYTHON) tools/test.py internet
133
134 test-npm: node
135         ./node deps/npm/test/run.js
136
137 test-npm-publish: node
138         npm_package_config_publishtest=true ./node deps/npm/test/run.js
139
140 apidoc_sources = $(wildcard doc/api/*.markdown)
141 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
142           $(addprefix out/,$(apidoc_sources:.markdown=.json))
143
144 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets out/doc/about out/doc/community out/doc/download out/doc/logos out/doc/images
145
146 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
147
148 doc_images = $(addprefix out/,$(wildcard doc/images/* doc/*.jpg doc/*.png))
149
150 website_files = \
151         out/doc/index.html    \
152         out/doc/v0.4_announcement.html   \
153         out/doc/cla.html      \
154         out/doc/sh_main.js    \
155         out/doc/sh_javascript.min.js \
156         out/doc/sh_vim-dark.css \
157         out/doc/sh.css \
158         out/doc/favicon.ico   \
159         out/doc/pipe.css \
160         out/doc/about/index.html \
161         out/doc/community/index.html \
162         out/doc/download/index.html \
163         out/doc/logos/index.html \
164         out/doc/changelog.html \
165         $(doc_images)
166
167 doc: $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/ blog node
168
169 blogclean:
170         rm -rf out/blog
171
172 blog: doc/blog out/Release/node tools/blog
173         out/Release/node tools/blog/generate.js doc/blog/ out/blog/ doc/blog.html doc/rss.xml
174
175 $(apidoc_dirs):
176         mkdir -p $@
177
178 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
179         cp $< $@
180
181 out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh node
182         bash tools/build-changelog.sh
183
184 out/doc/%.html: doc/%.html node
185         cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
186
187 out/doc/%: doc/%
188         cp -r $< $@
189
190 out/doc/api/%.json: doc/api/%.markdown node
191         out/Release/node tools/doc/generate.js --format=json $< > $@
192
193 out/doc/api/%.html: doc/api/%.markdown node
194         out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@
195
196 email.md: ChangeLog tools/email-footer.md
197         bash tools/changelog-head.sh | sed 's|^\* #|* \\#|g' > $@
198         cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
199
200 blog.html: email.md
201         cat $< | ./node tools/doc/node_modules/.bin/marked > $@
202
203 blog-upload: blog
204         rsync -r out/blog/ node@nodejs.org:~/web/nodejs.org/blog/
205
206 website-upload: doc
207         rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
208         ssh node@nodejs.org '\
209     rm -f ~/web/nodejs.org/dist/latest &&\
210     ln -s $(VERSION) ~/web/nodejs.org/dist/latest &&\
211     rm -f ~/web/nodejs.org/docs/latest &&\
212     ln -s $(VERSION) ~/web/nodejs.org/docs/latest &&\
213     rm -f ~/web/nodejs.org/dist/node-latest.tar.gz &&\
214     ln -s $(VERSION)/node-$(VERSION).tar.gz ~/web/nodejs.org/dist/node-latest.tar.gz'
215
216 docopen: out/doc/api/all.html
217         -google-chrome out/doc/api/all.html
218
219 docclean:
220         -rm -rf out/doc
221
222 RAWVER=$(shell $(PYTHON) tools/getnodeversion.py)
223 VERSION=v$(RAWVER)
224 RELEASE=$(shell $(PYTHON) tools/getnodeisrelease.py)
225 PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
226 ifeq ($(findstring x86_64,$(shell uname -m)),x86_64)
227 DESTCPU ?= x64
228 else
229 DESTCPU ?= ia32
230 endif
231 ifeq ($(DESTCPU),x64)
232 ARCH=x64
233 else
234 ifeq ($(DESTCPU),arm)
235 ARCH=arm
236 else
237 ARCH=x86
238 endif
239 endif
240 TARNAME=node-$(VERSION)
241 ifdef NIGHTLY
242 TAG = nightly-$(NIGHTLY)
243 TARNAME=node-$(VERSION)-$(TAG)
244 endif
245 TARBALL=$(TARNAME).tar.gz
246 BINARYNAME=$(TARNAME)-$(PLATFORM)-$(ARCH)
247 BINARYTAR=$(BINARYNAME).tar.gz
248 PKG=out/$(TARNAME).pkg
249 packagemaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
250
251 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER).tgz
252 ifdef NIGHTLY
253 PKGSRC=nodejs-$(DESTCPU)-$(RAWVER)-$(TAG).tgz
254 endif
255
256 dist: doc $(TARBALL) $(PKG)
257
258 PKGDIR=out/dist-osx
259
260 release-only:
261         @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
262                 exit 0 ; \
263         else \
264           echo "" >&2 ; \
265                 echo "The git repository is not clean." >&2 ; \
266                 echo "Please commit changes before building release tarball." >&2 ; \
267                 echo "" >&2 ; \
268                 git status --porcelain | egrep -v '^\?\?' >&2 ; \
269                 echo "" >&2 ; \
270                 exit 1 ; \
271         fi
272         @if [ "$(NIGHTLY)" != "" -o "$(RELEASE)" = "1" ]; then \
273                 exit 0; \
274         else \
275           echo "" >&2 ; \
276                 echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
277           echo "Did you remember to update src/node_version.cc?" >&2 ; \
278           echo "" >&2 ; \
279                 exit 1 ; \
280         fi
281
282 pkg: $(PKG)
283
284 $(PKG): release-only
285         rm -rf $(PKGDIR)
286         rm -rf out/deps out/Release
287         $(PYTHON) ./configure --without-snapshot --dest-cpu=ia32 --tag=$(TAG)
288         $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)/32
289         rm -rf out/deps out/Release
290         $(PYTHON) ./configure --without-snapshot --dest-cpu=x64 --tag=$(TAG)
291         $(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
292         SIGN="$(APP_SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
293         lipo $(PKGDIR)/32/usr/local/bin/node \
294                 $(PKGDIR)/usr/local/bin/node \
295                 -output $(PKGDIR)/usr/local/bin/node-universal \
296                 -create
297         mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
298         rm -rf $(PKGDIR)/32
299         $(packagemaker) \
300                 --id "org.nodejs.Node" \
301                 --doc tools/osx-pkg.pmdoc \
302                 --out $(PKG)
303         SIGN="$(INT_SIGN)" PKG="$(PKG)" bash tools/osx-productsign.sh
304
305 $(TARBALL): release-only node doc
306         git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
307         mkdir -p $(TARNAME)/doc/api
308         cp doc/node.1 $(TARNAME)/doc/node.1
309         cp -r out/doc/api/* $(TARNAME)/doc/api/
310         rm -rf $(TARNAME)/deps/v8/test # too big
311         rm -rf $(TARNAME)/doc/images # too big
312         find $(TARNAME)/ -type l | xargs rm # annoying on windows
313         tar -cf $(TARNAME).tar $(TARNAME)
314         rm -rf $(TARNAME)
315         gzip -f -9 $(TARNAME).tar
316
317 tar: $(TARBALL)
318
319 $(BINARYTAR): release-only
320         rm -rf $(BINARYNAME)
321         rm -rf out/deps out/Release
322         $(PYTHON) ./configure --prefix=/ --without-snapshot --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
323         $(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
324         cp README.md $(BINARYNAME)
325         cp LICENSE $(BINARYNAME)
326         cp ChangeLog $(BINARYNAME)
327         tar -cf $(BINARYNAME).tar $(BINARYNAME)
328         rm -rf $(BINARYNAME)
329         gzip -f -9 $(BINARYNAME).tar
330
331 binary: $(BINARYTAR)
332
333 $(PKGSRC): release-only
334         rm -rf dist out
335         $(PYTHON) configure --prefix=/ --without-snapshot \
336                 --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
337         $(MAKE) install DESTDIR=dist
338         (cd dist; find * -type f | sort) > packlist
339         pkg_info -X pkg_install | \
340                 egrep '^(MACHINE_ARCH|OPSYS|OS_VERSION|PKGTOOLS_VERSION)' > build-info
341         pkg_create -B build-info -c tools/pkgsrc/comment -d tools/pkgsrc/description \
342                 -f packlist -I /opt/local -p dist -U $(PKGSRC)
343
344 pkgsrc: $(PKGSRC)
345
346 dist-upload: $(TARBALL) $(PKG)
347         ssh node@nodejs.org mkdir -p web/nodejs.org/dist/$(VERSION)
348         scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
349         scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
350
351 wrkclean:
352         $(MAKE) -C tools/wrk/ clean
353         rm tools/wrk/wrk
354
355 wrk: tools/wrk/wrk
356 tools/wrk/wrk:
357         $(MAKE) -C tools/wrk/
358
359 bench-net: all
360         @$(NODE) benchmark/common.js net
361
362 bench-crypto: all
363         @$(NODE) benchmark/common.js crypto
364
365 bench-tls: all
366         @$(NODE) benchmark/common.js tls
367
368 bench-http: wrk all
369         @$(NODE) benchmark/common.js http
370
371 bench-fs: all
372         @$(NODE) benchmark/common.js fs
373
374 bench-misc: all
375         @$(MAKE) -C benchmark/misc/function_call/
376         @$(NODE) benchmark/common.js misc
377
378 bench-array: all
379         @$(NODE) benchmark/common.js arrays
380
381 bench-buffer: all
382         @$(NODE) benchmark/common.js buffers
383
384 bench-all: bench bench-misc bench-array bench-buffer
385
386 bench: bench-net bench-http bench-fs bench-tls
387
388 bench-http-simple:
389          benchmark/http_simple_bench.sh
390
391 bench-idle:
392         ./node benchmark/idle_server.js &
393         sleep 1
394         ./node benchmark/idle_clients.js &
395
396 jslintfix:
397         PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
398
399 jslint:
400         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
402 CPPLINT_EXCLUDE ?=
403 CPPLINT_EXCLUDE += src/node_dtrace.cc
404 CPPLINT_EXCLUDE += src/node_dtrace.cc
405 CPPLINT_EXCLUDE += src/node_root_certs.h
406 CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
407 CPPLINT_EXCLUDE += src/queue.h
408 CPPLINT_EXCLUDE += src/tree.h
409 CPPLINT_EXCLUDE += src/v8abbr.h
410
411 CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard src/*.cc src/*.h src/*.c))
412
413 cpplint:
414         @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
415
416 lint: jslint cpplint
417
418 .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean check uninstall install install-includes install-bin all staticlib dynamiclib test test-all 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