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