Fix #3761 build: Default to V=1
[platform/upstream/nodejs.git] / Makefile
1 -include config.mk
2
3 BUILDTYPE ?= Release
4 PYTHON ?= python
5 DESTDIR ?=
6
7 # Default to verbose builds.
8 # To do quiet/pretty builds, run `make V=` to set V to an empty string,
9 # or set the V environment variable to an empty string.
10 V ?= 1
11
12 # BUILDTYPE=Debug builds both release and debug builds. If you want to compile
13 # just the debug build, run `make -C out BUILDTYPE=Debug` instead.
14 ifeq ($(BUILDTYPE),Release)
15 all: out/Makefile node
16 else
17 all: out/Makefile node node_g
18 endif
19
20 # The .PHONY is needed to ensure that we recursively use the out/Makefile
21 # to check for changes.
22 .PHONY: node node_g
23
24 node: config.gypi
25         $(MAKE) -C out BUILDTYPE=Release V=$(V)
26         ln -fs out/Release/node node
27
28 node_g: config.gypi
29         $(MAKE) -C out BUILDTYPE=Debug V=$(V)
30         ln -fs out/Debug/node node_g
31
32 config.gypi: configure
33         ./configure
34
35 out/Debug/node:
36         $(MAKE) -C out BUILDTYPE=Debug V=$(V)
37
38 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
39         $(PYTHON) tools/gyp_node -f make
40
41 install: all
42         out/Release/node tools/installer.js install $(DESTDIR)
43
44 uninstall:
45         out/Release/node tools/installer.js uninstall
46
47 clean:
48         -rm -rf out/Makefile node node_g out/$(BUILDTYPE)/node blog.html email.md
49         -find out/ -name '*.o' -o -name '*.a' | xargs rm -rf
50         -rm -rf node_modules
51
52 distclean:
53         -rm -rf out
54         -rm -f config.gypi
55         -rm -f config.mk
56         -rm -rf node node_g blog.html email.md
57         -rm -rf node_modules
58
59 test: all
60         $(PYTHON) tools/test.py --mode=release simple message
61         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
62
63 test-http1: all
64         $(PYTHON) tools/test.py --mode=release --use-http1 simple message
65
66 test-valgrind: all
67         $(PYTHON) tools/test.py --mode=release --valgrind simple message
68
69 test/gc/node_modules/weak/build:
70         @if [ ! -f node ]; then make all; fi
71         ./node deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
72                 --directory="$(shell pwd)/test/gc/node_modules/weak" \
73                 --nodedir="$(shell pwd)"
74
75 test-gc: all test/gc/node_modules/weak/build
76         $(PYTHON) tools/test.py --mode=release gc
77
78 test-all: all test/gc/node_modules/weak/build
79         $(PYTHON) tools/test.py --mode=debug,release
80         make test-npm
81
82 test-all-http1: all
83         $(PYTHON) tools/test.py --mode=debug,release --use-http1
84
85 test-all-valgrind: all
86         $(PYTHON) tools/test.py --mode=debug,release --valgrind
87
88 test-release: all
89         $(PYTHON) tools/test.py --mode=release
90
91 test-debug: all
92         $(PYTHON) tools/test.py --mode=debug
93
94 test-message: all
95         $(PYTHON) tools/test.py message
96
97 test-simple: all
98         $(PYTHON) tools/test.py simple
99
100 test-pummel: all
101         $(PYTHON) tools/test.py pummel
102
103 test-internet: all
104         $(PYTHON) tools/test.py internet
105
106 test-npm: node
107         ./node deps/npm/test/run.js
108
109 test-npm-publish: node
110         npm_package_config_publishtest=true ./node deps/npm/test/run.js
111
112 apidoc_sources = $(wildcard doc/api/*.markdown)
113 apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
114           $(addprefix out/,$(apidoc_sources:.markdown=.json))
115
116 apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets out/doc/about out/doc/community out/doc/logos out/doc/images
117
118 apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
119
120 doc_images = $(addprefix out/,$(wildcard doc/images/* doc/*.jpg doc/*.png))
121
122 website_files = \
123         out/doc/index.html    \
124         out/doc/v0.4_announcement.html   \
125         out/doc/cla.html      \
126         out/doc/sh_main.js    \
127         out/doc/sh_javascript.min.js \
128         out/doc/sh_vim-dark.css \
129         out/doc/sh.css \
130         out/doc/favicon.ico   \
131         out/doc/pipe.css \
132         out/doc/about/index.html \
133         out/doc/community/index.html \
134         out/doc/logos/index.html \
135         out/doc/changelog.html \
136         $(doc_images)
137
138 doc: $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/ blog node
139
140 blogclean:
141         rm -rf out/blog
142
143 blog: doc/blog out/Release/node tools/blog
144         out/Release/node tools/blog/generate.js doc/blog/ out/blog/ doc/blog.html doc/rss.xml
145
146 $(apidoc_dirs):
147         mkdir -p $@
148
149 out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
150         cp $< $@
151
152 out/doc/changelog.html: ChangeLog doc/changelog-head.html doc/changelog-foot.html tools/build-changelog.sh node
153         bash tools/build-changelog.sh
154
155 out/doc/%.html: doc/%.html node
156         cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
157
158 out/doc/%: doc/%
159         cp -r $< $@
160
161 out/doc/api/%.json: doc/api/%.markdown node
162         out/Release/node tools/doc/generate.js --format=json $< > $@
163
164 out/doc/api/%.html: doc/api/%.markdown node
165         out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@
166
167 email.md: ChangeLog tools/email-footer.md
168         bash tools/changelog-head.sh | sed 's|^\* #|* \\#|g' > $@
169         cat tools/email-footer.md | sed -e 's|__VERSION__|'$(VERSION)'|g' >> $@
170
171 blog.html: email.md
172         cat $< | ./node tools/doc/node_modules/.bin/marked > $@
173
174 blog-upload: blog
175         rsync -r out/blog/ node@nodejs.org:~/web/nodejs.org/blog/
176
177 website-upload: doc
178         rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
179         ssh node@nodejs.org '\
180     rm -f ~/web/nodejs.org/dist/latest &&\
181     ln -s $(VERSION) ~/web/nodejs.org/dist/latest &&\
182     rm -f ~/web/nodejs.org/docs/latest &&\
183     ln -s $(VERSION) ~/web/nodejs.org/docs/latest &&\
184     rm -f ~/web/nodejs.org/dist/node-latest.tar.gz &&\
185     ln -s $(VERSION)/node-$(VERSION).tar.gz ~/web/nodejs.org/dist/node-latest.tar.gz'
186
187 docopen: out/doc/api/all.html
188         -google-chrome out/doc/api/all.html
189
190 docclean:
191         -rm -rf out/doc
192
193 VERSION=v$(shell $(PYTHON) tools/getnodeversion.py)
194 TARNAME=node-$(VERSION)
195 TARBALL=$(TARNAME).tar.gz
196 PKG=out/$(TARNAME).pkg
197 packagemaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
198
199 dist: doc $(TARBALL) $(PKG)
200
201 PKGDIR=out/dist-osx
202
203 pkg: $(PKG)
204
205 $(PKG):
206         rm -rf $(PKGDIR)
207         rm -rf out/deps out/Release
208         ./configure --prefix=$(PKGDIR)/32/usr/local --without-snapshot --dest-cpu=ia32
209         $(MAKE) install V=$(V)
210         rm -rf out/deps out/Release
211         ./configure --prefix=$(PKGDIR)/usr/local --without-snapshot --dest-cpu=x64
212         $(MAKE) install V=$(V)
213         lipo $(PKGDIR)/32/usr/local/bin/node \
214                 $(PKGDIR)/usr/local/bin/node \
215                 -output $(PKGDIR)/usr/local/bin/node-universal \
216                 -create
217         mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
218         rm -rf $(PKGDIR)/32
219         $(packagemaker) \
220                 --id "org.nodejs.NodeJS-$(VERSION)" \
221                 --doc tools/osx-pkg.pmdoc \
222                 --out $(PKG)
223
224 $(TARBALL): node doc
225         @if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
226                 exit 0 ; \
227         else \
228           echo "" >&2 ; \
229                 echo "The git repository is not clean." >&2 ; \
230                 echo "Please commit changes before building release tarball." >&2 ; \
231                 echo "" >&2 ; \
232                 git status --porcelain | egrep -v '^\?\?' >&2 ; \
233                 echo "" >&2 ; \
234                 exit 1 ; \
235         fi
236         @if [ $(shell ./node --version) = "$(VERSION)" ]; then \
237                 exit 0; \
238         else \
239           echo "" >&2 ; \
240                 echo "$(shell ./node --version) doesn't match $(VERSION)." >&2 ; \
241           echo "Did you remember to update src/node_version.cc?" >&2 ; \
242           echo "" >&2 ; \
243                 exit 1 ; \
244         fi
245         git archive --format=tar --prefix=$(TARNAME)/ HEAD | tar xf -
246         mkdir -p $(TARNAME)/doc/api
247         cp doc/node.1 $(TARNAME)/doc/node.1
248         cp -r out/doc/api/* $(TARNAME)/doc/api/
249         rm -rf $(TARNAME)/deps/v8/test # too big
250         rm -rf $(TARNAME)/doc/images # too big
251         find $(TARNAME)/ -type l | xargs rm # annoying on windows
252         tar -cf $(TARNAME).tar $(TARNAME)
253         rm -rf $(TARNAME)
254         gzip -f -9 $(TARNAME).tar
255
256 dist-upload: $(TARBALL) $(PKG)
257         ssh node@nodejs.org mkdir -p web/nodejs.org/dist/$(VERSION)
258         scp $(TARBALL) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARBALL)
259         scp $(PKG) node@nodejs.org:~/web/nodejs.org/dist/$(VERSION)/$(TARNAME).pkg
260
261 bench:
262          benchmark/http_simple_bench.sh
263
264 bench-idle:
265         ./node benchmark/idle_server.js &
266         sleep 1
267         ./node benchmark/idle_clients.js &
268
269 jslint:
270         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
271
272 cpplint:
273         @$(PYTHON) tools/cpplint.py $(wildcard src/*.cc src/*.h src/*.c)
274
275 lint: jslint cpplint
276
277 .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