1- WAF =python tools/waf-light
1+ # config
22
3- all :
4- @$(WAF ) build
3+ # define DEBUG=1 to build node_g
54
6- all-progress :
7- @$(WAF ) -p build
5+ WANT_OPENSSL =1
6+ PREFIX =/usr
7+ SHELL =/bin/sh
8+ INSTALL = install
89
9- install :
10- @$(WAF ) install
1110
12- uninstall :
13- @ $( WAF ) uninstall
11+ -include config.mak.autogen
12+ -include config.mak
1413
15- test : all
14+
15+ platform := $(shell python -c 'import sys; print sys.platform')
16+
17+
18+ ifeq ($(platform ) ,linux2)
19+ platform := linux
20+ endif
21+
22+ # fix me
23+ arch = x86_64
24+
25+
26+ ifeq ($(platform ) ,darwin)
27+ LINKFLAGS += -framework Carbon
28+ endif
29+
30+ ifeq ($(platform ) ,linux)
31+ LINKFLAGS += -pthread -lrt
32+ endif
33+
34+ ifdef WANT_OPENSSL
35+ HAVE_OPENSSL = 1
36+ HAVE_CRYPTO = 1
37+ ifdef OPENSSL_DIR
38+ OPENSSL_LINKFLAGS += -L$(OPENSSL_DIR)/lib
39+ OPENSSL_CPPFLAGS += -I$(OPENSSL_DIR)/include
40+ endif
41+ OPENSSL_LINKFLAGS += -lssl -lcrypto
42+ endif
43+
44+ cflags += -pedantic
45+
46+
47+
48+
49+ debug_CPPDEFINES = -DDEBUG $(CFLAGS )
50+ debug_CFLAGS = -Wall -O0 -ggdb $(CFLAGS )
51+ debug_CXXFLAGS = $(debug_CFLAGS )
52+ debug_LINKFLAGS = $(LINKFLAGS )
53+
54+ release_CPPDEFINES = -DNODEBUG
55+ release_CFLAGS = -Wall -O2
56+ release_CXXFLAGS = $(release_CFLAGS )
57+ release_LINKFLAGS = $(LINKFLAGS )
58+
59+ builddir = build
60+
61+
62+ libev_sources = deps/libev/ev.c
63+ # Note: -I$(builddir)/deps/libev contains config.h which is generated from
64+ # deps/libev/config.h.in during the configure script
65+ libev_CPPFLAGS = -Ideps/libev -I$(builddir ) /deps/libev
66+ libev_release_objects = $(builddir ) /release/deps/libev/ev.o
67+ libev_debug_objects = $(builddir ) /debug/deps/libev/ev.o
68+
69+ libeio_sources = deps/libeio/eio.c
70+ libeio_release_objects = $(builddir ) /release/deps/libeio/eio.o
71+ libeio_debug_objects = $(builddir ) /debug/deps/libeio/eio.o
72+ # Note: -I$(builddir)/deps/libeio contains config.h which is generated from
73+ # deps/libeio/config.h.in during the configure script
74+ libeio_CPPFLAGS = -D_GNU_SOURCE -Ideps/libeio -I$(builddir ) /deps/libeio
75+
76+ http_parser_sources = deps/http_parser/http_parser.c
77+ http_parser_release_objects = $(builddir ) /release/deps/http_parser/http_parser.o
78+ http_parser_debug_objects = $(builddir ) /debug/deps/http_parser/http_parser.o
79+ http_parser_CPPFLAGS = -Ideps/http_parser
80+
81+ cares_sources = $(wildcard deps/c-ares/* .c)
82+ cares_release_objects = $(addprefix $(builddir ) /release/,$(cares_sources:.c=.o ) )
83+ cares_debug_objects = $(addprefix $(builddir ) /debug/,$(cares_sources:.c=.o ) )
84+ cares_CPPFLAGS = -DHAVE_CONFIG_H=1 -Ideps/c-ares -Ideps/c-ares/$(platform ) -$(arch )
85+
86+ node_sources = src/node.cc \
87+ src/platform_$(platform ) .cc \
88+ src/node_buffer.cc \
89+ src/node_cares.cc \
90+ src/node_child_process.cc \
91+ src/node_constants.cc \
92+ src/node_crypto.cc \
93+ src/node_events.cc \
94+ src/node_extensions.cc \
95+ src/node_file.cc \
96+ src/node_http_parser.cc \
97+ src/node_idle_watcher.cc \
98+ src/node_io_watcher.cc \
99+ src/node_main.cc \
100+ src/node_net.cc \
101+ src/node_script.cc \
102+ src/node_signal_watcher.cc \
103+ src/node_stat_watcher.cc \
104+ src/node_stdio.cc \
105+ src/node_timer.cc \
106+ src/node_javascript.cc \
107+
108+ node_debug_objects = $(addprefix $(builddir ) /debug/,$(node_sources:.cc=.o ) )
109+ node_release_objects = $(addprefix $(builddir ) /release/,$(node_sources:.cc=.o ) )
110+
111+ # TODO HAVE_FDATASYNC should be set in configure.
112+
113+ node_CPPFLAGS = -Isrc/ -Ideps/libeio/ -Ideps/libev/ -Ideps/http_parser/ \
114+ -Ideps/libev/include/ -Ideps/v8/include -DPLATFORM=\"$(platform ) \" \
115+ -DX_STACKSIZE=65536 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
116+ -DHAVE_FDATASYNC=0 -I$(builddir ) /release/src $(cares_CPPFLAGS )
117+ node_debug_CPPFLAGS = $(subst release,debug,$(NODE_CPPFLAGS ) )
118+
119+ libv8 = $(builddir ) /libv8.a
120+ libv8_g = $(builddir ) /libv8_g.a
121+
122+ dirs = $(builddir ) /release/src \
123+ $(builddir ) /release/deps/libev \
124+ $(builddir ) /release/deps/libeio \
125+ $(builddir ) /release/deps/c-ares \
126+ $(builddir ) /release/deps/http_parser \
127+ $(builddir ) /release/deps/v8 \
128+ $(builddir ) /release/lib/pkgconfig
129+ debug_dirs = $(subst release,debug,$(dirs ) )
130+
131+
132+
133+
134+ # Rules
135+
136+ all : $(dirs ) node
137+
138+ ifdef DEBUG
139+ all : $(debug_dirs ) node_g
140+ endif
141+
142+
143+ node : $(builddir ) /node
144+ ln -fs $< $@
145+
146+ node_g : $(builddir ) /node_g
147+ ln -fs $< $@
148+
149+
150+
151+ $(dirs ) $(debug_dirs ) :
152+ mkdir -p $@
153+
154+
155+ # libev
156+
157+ $(builddir ) /release/deps/libev/% .o : deps/libev/% .c
158+ $(CC ) -c $(release_CFLAGS ) $(release_CPPFLAGS ) $(libev_CFLAGS ) \
159+ $(libev_CPPFLAGS ) $< -o $@
160+
161+ $(builddir ) /debug/deps/libev/% .o : deps/libev/% .c
162+ $(CC ) -c $(debug_CFLAGS ) $(debug_CPPFLAGS ) $(libev_CFLAGS ) \
163+ $(libev_CPPFLAGS ) $< -o $@
164+
165+
166+ # libeio
167+
168+ $(builddir ) /release/deps/libeio/% .o : deps/libeio/% .c
169+ $(CC ) -c $(release_CFLAGS ) $(release_CPPFLAGS ) $(libeio_CFLAGS ) \
170+ $(libeio_CPPFLAGS ) $< -o $@
171+
172+ $(builddir ) /debug/deps/libeio/% .o : deps/libeio/% .c
173+ $(CC ) -c $(debug_CFLAGS ) $(debug_CPPFLAGS ) $(libeio_CFLAGS ) \
174+ $(libeio_CPPFLAGS ) $< -o $@
175+
176+
177+ # http-parser
178+
179+ $(builddir ) /release/deps/http_parser/% .o : deps/http_parser/% .c
180+ $(CC ) -c $(release_CFLAGS ) $(release_CPPFLAGS ) $(http_parser_CFLAGS ) \
181+ $(http_parser_CPPFLAGS ) $< -o $@
182+
183+ $(builddir ) /debug/deps/http_parser/% .o : deps/http_parser/% .c
184+ $(CC ) -c $(debug_CFLAGS ) $(debug_CPPFLAGS ) $(http_parser_CFLAGS ) \
185+ $(http_parser_CPPFLAGS ) $< -o $@
186+
187+
188+ # c-ares
189+
190+ $(builddir ) /release/deps/c-ares/% .o : deps/c-ares/% .c
191+ $(CC ) -c $(release_CFLAGS ) $(release_CPPFLAGS ) $(cares_CFLAGS ) \
192+ $(cares_CPPFLAGS ) $< -o $@
193+
194+ $(builddir ) /debug/deps/c-ares/% .o : deps/c-ares/% .c
195+ $(CC ) -c $(debug_CFLAGS ) $(debug_CPPFLAGS ) $(cares_CFLAGS ) \
196+ $(cares_CPPFLAGS ) $< -o $@
197+
198+
199+ # node
200+
201+ $(builddir ) /release/src/% .o : src/% .cc
202+ $(CXX ) -c $(release_CXXFLAGS ) $(release_CPPFLAGS ) $(node_CXXFLAGS ) \
203+ $(node_CPPFLAGS ) $(OPENSSL_CPPFLAGS ) $< -o $@
204+
205+ $(builddir ) /debug/src/% .o : src/% .cc
206+ $(CXX ) -c $(debug_CXXFLAGS ) $(debug_CPPFLAGS ) $(node_CXXFLAGS ) \
207+ $(node_CPPFLAGS ) $(OPENSSL_CPPFLAGS ) $< -o $@
208+
209+
210+ # node.o
211+
212+ $(builddir ) /release/src/node.o : src/node.cc $(builddir ) /release/src/node_natives.h
213+ $(CXX ) -c $(release_CXXFLAGS ) $(release_CPPFLAGS ) $(node_CFLAGS ) \
214+ $(node_CPPFLAGS ) $(OPENSSL_CPPFLAGS ) $< -o $@
215+
216+ $(builddir ) /debug/src/node.o : src/node.cc $(builddir ) /debug/src/node_natives.h
217+ $(CXX ) -c $(debug_CXXFLAGS ) $(debug_CPPFLAGS ) $(node_CFLAGS ) \
218+ $(node_CPPFLAGS ) $(OPENSSL_CPPFLAGS ) $< -o $@
219+
220+
221+ # node executable
222+
223+ $(builddir ) /node : $(node_release_objects ) $(libev_release_objects ) \
224+ $(libeio_release_objects ) $(http_parser_release_objects ) \
225+ $(cares_release_objects ) $(libv8 )
226+ $(CXX ) -o $@ $^ $(release_LINKFLAGS ) $(node_LINKFLAGS ) $(OPENSSL_LINKFLAGS )
227+
228+ $(builddir ) /node_g : $(node_debug_objects ) $(libev_debug_objects ) \
229+ $(libeio_debug_objects ) $(http_parser_debug_objects ) \
230+ $(cares_debug_objects ) $(libv8_g )
231+ $(CXX ) -o $@ $^ $(debug_LINKFLAGS ) $(node_LINKFLAGS ) $(OPENSSL_LINKFLAGS )
232+
233+
234+
235+ $(builddir ) /release/src/node_natives.h : src/node.js lib/* .js
236+ python tools/js2c.py $^ > $@
237+
238+ $(builddir ) /debug/src/node_natives.h : src/node.js lib/* .js
239+ python tools/js2c.py $^ > $@
240+ # TODO a debug flag for the macros ?
241+
242+
243+
244+ $(builddir ) /release/src/node_config.h : src/node_config.h.in
245+ sed -e " s#@PREFIX@#$( PREFIX) #" \
246+ -e " s#@CCFLAGS@#$( release_CFLAGS) #" \
247+ -e " s#@CPPFLAGS@#$( release_CPPFLAGS) #" $< > $@ || rm $@
248+
249+ $(builddir ) /debug/src/node_config.h : src/node_config.h.in
250+ sed -e " s#@PREFIX@#$( PREFIX) #" \
251+ -e " s#@CCFLAGS@#$( debug_CFLAGS) #" \
252+ -e " s#@CPPFLAGS@#$( debug_CPPFLAGS) #" $< > $@ || rm $@
253+
254+
255+ # FIXME convert to a generalized *.in preprocessor
256+ $(builddir ) /release/lib/pkgconfig/nodejs.pc : tools/nodejs.pc.in
257+ sed \
258+ -e " s#@PREFIX@#$( PREFIX) #" \
259+ -e " s#@VERSION@#$( VERSION) #" \
260+ -e " s#@CCFLAGS@#$( CFLAGS) #" \
261+ -e " s#@CPPFLAGS@#$( CPPFLAGS) #" $< > $@ || rm $@
262+
263+ # v8 does its own debug and release version, so we don't put it in the
264+ # profile_builddir but rather just the builddir.
265+ $(libv8 ) :
266+ python tools/scons/scons.py -C $(builddir ) -Y ` pwd` /deps/v8 \
267+ visibility=default mode=release arch=x64 library=static snapshot=on
268+
269+ $(libv8_g ) :
270+ python tools/scons/scons.py -C $(builddir ) -Y ` pwd` /deps/v8 \
271+ visibility=default mode=debug arch=x64 library=static snapshot=on
272+
273+
274+ # header deps
275+ $(builddir ) /release/src/node.o : $(builddir ) /release/src/node_config.h
276+ $(builddir ) /debug/src/node.o : $(builddir ) /debug/src/node_config.h
277+
278+
279+ # TODO install
280+
281+ test : $(builddir ) /node
16282 python tools/test.py --mode=release simple message
17283
18- test-all : all
284+ test-all : $( builddir ) /node $( builddir ) /node_g
19285 python tools/test.py --mode=debug,release
20286
21- test-release : all
287+ test-release : $( builddir ) /node
22288 python tools/test.py --mode=release
23289
24- test-debug : all
290+ test-debug : $( builddir ) /node_g
25291 python tools/test.py --mode=debug
26292
27- test-message : all
293+ test-message : $( builddir ) /node
28294 python tools/test.py message
29295
30- test-simple : all
296+ test-simple : $( builddir ) /node
31297 python tools/test.py simple
32298
33- test-pummel : all
299+ test-pummel : $( builddir ) /node
34300 python tools/test.py pummel
35301
36- test-internet : all
302+ test-internet : $( builddir ) /node
37303 python tools/test.py internet
38304
39305# http://rtomayko.github.com/ronn
@@ -59,15 +325,15 @@ docclean:
59325 @-rm -f doc/node.1 doc/api.html doc/changelog.html
60326
61327clean :
62- @$(WAF ) clean
63- @-find tools -name " *.pyc" | xargs rm -f
328+ -rm -f node node_g $(builddir ) /node $(builddir ) /node_g
329+ -find $(builddir ) -name " *.o" | xargs rm -f
330+ -find . -name " *.pyc" | xargs rm -f
64331
65332distclean : docclean
66- @-find tools -name " *.pyc" | xargs rm -f
67- @-rm -rf build/ node node_g
333+ -find tools -name " *.pyc" | xargs rm -f
334+ -rm -rf build/ node node_g
335+ -rm -rf configure config.mak.autogen config.log autom4te.cache config.status
68336
69- check :
70- @tools/waf-light check
71337
72338VERSION =$(shell git describe)
73339TARNAME =node-$(VERSION )
0 commit comments