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