blob: 736344b9d72287c2b6f587d4afc53cca7535067a [file] [log] [blame]
Ryan Dahl7a251f32010-03-01 22:39:311#!/usr/bin/env python
Ryan8ddf9302009-09-02 18:19:522import re
Ryan1a126ed2009-04-04 12:50:153import Options
Ryan41d89f62009-07-28 10:29:184import sys, os, shutil
Ryan Dahld979ac92009-10-09 13:00:125from Utils import cmd_output
Ryan1a126ed2009-04-04 12:50:156from os.path import join, dirname, abspath
Ryana4593e32009-04-23 11:18:387from logging import fatal
8
Ryan Dahld979ac92009-10-09 13:00:129cwd = os.getcwd()
Ryan Dahl0c1aa362010-05-30 02:32:3310VERSION="0.1.97"
Ryan4d921992009-08-26 23:11:1611APPNAME="node.js"
12
Ryan63a9cd32009-04-15 08:08:2813import js2c
14
Ryan1a126ed2009-04-04 12:50:1515srcdir = '.'
16blddir = 'build'
17
Ryan Dahl311a62d2010-05-26 20:05:3118
Ryan Dahlef9f4042010-06-02 19:27:5319
Ryan Dahl311a62d2010-05-26 20:05:3120jobs=1
21if os.environ.has_key('JOBS'):
22 jobs = int(os.environ['JOBS'])
23
Ryan1a126ed2009-04-04 12:50:1524def set_options(opt):
25 # the gcc module provides a --debug-level option
26 opt.tool_options('compiler_cxx')
27 opt.tool_options('compiler_cc')
Ryan4d921992009-08-26 23:11:1628 opt.tool_options('misc')
Ryan29b528c2009-04-23 15:29:3129 opt.add_option( '--debug'
30 , action='store_true'
31 , default=False
32 , help='Build debug variant [Default: False]'
33 , dest='debug'
34 )
Ryan7bad9de2009-06-16 13:47:5735 opt.add_option( '--efence'
36 , action='store_true'
37 , default=False
38 , help='Build with -lefence for debugging [Default: False]'
39 , dest='efence'
40 )
Ryan Dahl9e8df0e2010-06-02 21:05:3741
Ryan Dahla9b962a2010-05-14 23:34:4742 opt.add_option( '--without-ssl'
43 , action='store_true'
44 , default=False
45 , help='Build without SSL'
46 , dest='without_ssl'
47 )
Ryan1a126ed2009-04-04 12:50:1548
Ryan Dahl9e8df0e2010-06-02 21:05:3749
50 opt.add_option('--shared-v8'
51 , action='store_true'
52 , default=False
53 , help='Link to a shared V8 DLL instead of static linking'
54 , dest='shared_v8'
55 )
56
57 opt.add_option( '--shared-v8-includes'
58 , action='store'
59 , default=False
60 , help='Directory containing V8 header files'
61 , dest='shared_v8_includes'
62 )
63
64 opt.add_option( '--shared-v8-libpath'
65 , action='store'
66 , default=False
67 , help='A directory to search for the shared V8 DLL'
68 , dest='shared_v8_libpath'
69 )
70
71 opt.add_option( '--shared-v8-libname'
72 , action='store'
73 , default=False
74 , help="Alternative lib name to link to (default: 'v8')"
75 , dest='shared_v8_libname'
76 )
77
78
79 opt.add_option('--shared-cares'
80 , action='store_true'
81 , default=False
82 , help='Link to a shared C-Ares DLL instead of static linking'
83 , dest='shared_cares'
84 )
85
86 opt.add_option( '--shared-cares-includes'
87 , action='store'
88 , default=False
89 , help='Directory containing C-Ares header files'
90 , dest='shared_cares_includes'
91 )
92
93 opt.add_option( '--shared-cares-libpath'
94 , action='store'
95 , default=False
96 , help='A directory to search for the shared C-Ares DLL'
97 , dest='shared_cares_libpath'
98 )
99
100
101 opt.add_option('--shared-libev'
102 , action='store_true'
103 , default=False
104 , help='Link to a shared libev DLL instead of static linking'
105 , dest='shared_libev'
106 )
107
108 opt.add_option( '--shared-libev-includes'
109 , action='store'
110 , default=False
111 , help='Directory containing libev header files'
112 , dest='shared_libev_includes'
113 )
114
115 opt.add_option( '--shared-libev-libpath'
116 , action='store'
117 , default=False
118 , help='A directory to search for the shared libev DLL'
119 , dest='shared_libev_libpath'
120 )
121
122
123
124
Ryan1a126ed2009-04-04 12:50:15125def configure(conf):
126 conf.check_tool('compiler_cxx')
Ryan Dahlf379b772010-01-12 00:43:10127 if not conf.env.CXX: conf.fatal('c++ compiler not found')
Ryan1a126ed2009-04-04 12:50:15128 conf.check_tool('compiler_cc')
Ryan Dahlf379b772010-01-12 00:43:10129 if not conf.env.CC: conf.fatal('c compiler not found')
Ryana4593e32009-04-23 11:18:38130
Ryan Dahl9e8df0e2010-06-02 21:05:37131 o = Options.options
132
133 conf.env["USE_DEBUG"] = o.debug
134
135 conf.env["USE_SHARED_V8"] = o.shared_v8 or o.shared_v8_includes or o.shared_v8_libpath or o.shared_v8_libname
136 conf.env["USE_SHARED_CARES"] = o.shared_cares or o.shared_cares_includes or o.shared_cares_libpath
137 conf.env["USE_SHARED_LIBEV"] = o.shared_libev or o.shared_libev_includes or o.shared_libev_libpath
Ryan1a126ed2009-04-04 12:50:15138
Ryan2b6d7242009-06-20 13:07:10139 conf.check(lib='dl', uselib_store='DL')
Raffaele Senab3b81d62010-06-09 04:08:05140 if not sys.platform.startswith("sunos") and not sys.platform.startswith("cygwin"):
Ryan Dahl0c125542010-01-19 23:38:20141 conf.env.append_value("CCFLAGS", "-rdynamic")
142 conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
Ryana97dce72009-08-31 09:14:34143
Vanilla Hsud22952b2010-01-07 07:37:27144 if sys.platform.startswith("freebsd"):
145 conf.check(lib='kvm', uselib_store='KVM')
146
Ryan8152f9c2009-09-01 12:15:29147 #if Options.options.debug:
148 # conf.check(lib='profiler', uselib_store='PROFILER')
Ryan7bad9de2009-06-16 13:47:57149
Ryan Dahlb8c3d712010-01-27 02:34:42150 if Options.options.efence:
151 conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE')
Ryana3627c02009-05-27 14:29:55152
Vanilla Hsud7a45012010-04-06 16:07:10153 if not conf.check(lib="execinfo", includes=['/usr/include', '/usr/local/include'], libpath=['/usr/lib', '/usr/local/lib'], uselib_store="EXECINFO"):
Rasmus Andersson6eb8bbc2009-12-15 22:37:49154 # Note on Darwin/OS X: This will fail, but will still be used as the
155 # execinfo stuff are part of the standard library.
Ryan Dahl8b62e862009-10-10 09:58:36156 if sys.platform.startswith("freebsd"):
Simon Cornelius P. Umacobe801f422009-12-09 12:36:12157 conf.fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.")
Ryana3627c02009-05-27 14:29:55158
Ryan Dahla9b962a2010-05-14 23:34:47159 if not Options.options.without_ssl:
160 if conf.check_cfg(package='openssl',
161 args='--cflags --libs',
162 uselib_store='OPENSSL'):
Standa Opichalfa514a92010-04-18 16:24:08163 conf.env["USE_OPENSSL"] = True
164 conf.env.append_value("CXXFLAGS", "-DHAVE_OPENSSL=1")
Ryan Dahla9b962a2010-05-14 23:34:47165 else:
166 libssl = conf.check_cc(lib='ssl',
167 header_name='openssl/ssl.h',
168 function_name='SSL_library_init',
169 libpath=['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/usr/sfw/lib'],
170 uselib_store='OPENSSL')
171 libcrypto = conf.check_cc(lib='crypto',
172 header_name='openssl/crypto.h',
173 uselib_store='OPENSSL')
174 if libcrypto and libssl:
175 conf.env["USE_OPENSSL"] = True
176 conf.env.append_value("CXXFLAGS", "-DHAVE_OPENSSL=1")
Rhys Jonesfb3a9cd2010-04-02 23:11:53177
Ryan Dahle9a116f2010-04-06 10:41:32178 conf.check(lib='rt', uselib_store='RT')
179
Ryan Dahl0c125542010-01-19 23:38:20180 if sys.platform.startswith("sunos"):
181 if not conf.check(lib='socket', uselib_store="SOCKET"):
182 conf.fatal("Cannot find socket library")
183 if not conf.check(lib='nsl', uselib_store="NSL"):
184 conf.fatal("Cannot find nsl library")
185
Ryan Dahl9e8df0e2010-06-02 21:05:37186
187
Ryan1a126ed2009-04-04 12:50:15188 conf.sub_config('deps/libeio')
Ryan Dahl9e8df0e2010-06-02 21:05:37189
190
191
192 if conf.env['USE_SHARED_V8']:
193 v8_includes = [];
194 if o.shared_v8_includes: v8_includes.append(o.shared_v8_includes);
195
196 v8_libpath = [];
197 if o.shared_v8_libpath: v8_libpath.append(o.shared_v8_libpath);
198
199 if not o.shared_v8_libname: o.shared_v8_libname = 'v8'
200
201 if not conf.check_cxx(lib=o.shared_v8_libname, header_name='v8.h',
202 uselib_store='V8',
203 includes=v8_includes,
204 libpath=v8_libpath):
205 conf.fatal("Cannot find v8")
206
207 if o.debug:
208 if not conf.check_cxx(lib=o.shared_v8_libname + '_g', header_name='v8.h',
209 uselib_store='V8_G',
210 includes=v8_includes,
211 libpath=v8_libpath):
212 conf.fatal("Cannot find v8_g")
213
214 if conf.env['USE_SHARED_CARES']:
215 cares_includes = [];
216 if o.shared_cares_includes: cares_includes.append(o.shared_cares_includes);
217 cares_libpath = [];
218 if o.shared_cares_libpath: cares_libpath.append(o.shared_cares_libpath);
219 if not conf.check_cxx(lib='cares',
220 header_name='ares.h',
221 uselib_store='CARES',
222 includes=cares_includes,
223 libpath=cares_libpath):
Ryan Dahl501136b2010-06-02 16:15:54224 conf.fatal("Cannot find c-ares")
Ryan Dahl9e8df0e2010-06-02 21:05:37225 else:
226 conf.sub_config('deps/c-ares')
227
228
229 if conf.env['USE_SHARED_LIBEV']:
230 libev_includes = [];
231 if o.shared_libev_includes: libev_includes.append(o.shared_libev_includes);
232 libev_libpath = [];
233 if o.shared_libev_libpath: libev_libpath.append(o.shared_libev_libpath);
234 if not conf.check_cxx(lib='ev', header_name='ev.h',
235 uselib_store='EV',
236 includes=libev_includes,
237 libpath=libev_libpath):
238 conf.fatal("Cannot find libev")
239 else:
240 conf.sub_config('deps/libev')
241
242
Ryan41d89f62009-07-28 10:29:18243
Ryan1a126ed2009-04-04 12:50:15244 conf.define("HAVE_CONFIG_H", 1)
Ryanc62b1242009-04-22 17:55:08245
Ryan Dahl42797252010-03-31 20:36:20246 if sys.platform.startswith("sunos"):
247 conf.env.append_value ('CCFLAGS', '-threads')
248 conf.env.append_value ('CXXFLAGS', '-threads')
249 #conf.env.append_value ('LINKFLAGS', ' -threads')
Raffaele Senab3b81d62010-06-09 04:08:05250 elif not sys.platform.startswith("cygwin"):
Ryan Dahl42797252010-03-31 20:36:20251 threadflags='-pthread'
252 conf.env.append_value ('CCFLAGS', threadflags)
253 conf.env.append_value ('CXXFLAGS', threadflags)
254 conf.env.append_value ('LINKFLAGS', threadflags)
255
Ryan Dahl1beb8402009-12-30 08:01:28256 conf.env.append_value("CCFLAGS", "-DX_STACKSIZE=%d" % (1024*64))
Ryan427e3f52009-05-14 11:16:45257
Ryan Dahl2b743aa2009-10-27 11:05:38258 # LFS
259 conf.env.append_value('CCFLAGS', '-D_LARGEFILE_SOURCE')
260 conf.env.append_value('CXXFLAGS', '-D_LARGEFILE_SOURCE')
261 conf.env.append_value('CCFLAGS', '-D_FILE_OFFSET_BITS=64')
262 conf.env.append_value('CXXFLAGS', '-D_FILE_OFFSET_BITS=64')
263
Andrew Johnston95996072010-03-22 07:25:24264 ## needed for node_file.cc fdatasync
265 ## Strangely on OSX 10.6 the g++ doesn't see fdatasync but gcc does?
266 code = """
267 #include <unistd.h>
268 int main(void)
269 {
270 int fd = 0;
271 fdatasync (fd);
272 return 0;
273 }
274 """
275 if conf.check_cxx(msg="Checking for fdatasync(2) with c++", fragment=code):
276 conf.env.append_value('CXXFLAGS', '-DHAVE_FDATASYNC=1')
277 else:
278 conf.env.append_value('CXXFLAGS', '-DHAVE_FDATASYNC=0')
279
Ryan Dahlf4811832009-11-02 23:21:00280 # platform
281 platform_def = '-DPLATFORM=' + sys.platform
282 conf.env.append_value('CCFLAGS', platform_def)
283 conf.env.append_value('CXXFLAGS', platform_def)
284
Ryan67af9582009-04-18 13:35:42285 # Split off debug variant before adding variant specific defines
Ryan7e1350f2009-04-16 09:37:44286 debug_env = conf.env.copy()
287 conf.set_env_name('debug', debug_env)
Ryan7e1350f2009-04-16 09:37:44288
Ryan67af9582009-04-18 13:35:42289 # Configure debug variant
290 conf.setenv('debug')
291 debug_env.set_variant('debug')
Ryan8ddf9302009-09-02 18:19:52292 debug_env.append_value('CCFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
293 debug_env.append_value('CXXFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
Ryan67af9582009-04-18 13:35:42294 conf.write_config_header("config.h")
295
296 # Configure default variant
297 conf.setenv('default')
Ryan Dahl48d58f92010-05-03 01:20:02298 conf.env.append_value('CCFLAGS', ['-DNDEBUG', '-g', '-O3'])
299 conf.env.append_value('CXXFLAGS', ['-DNDEBUG', '-g', '-O3'])
Ryan67af9582009-04-18 13:35:42300 conf.write_config_header("config.h")
Ryan63a9cd32009-04-15 08:08:28301
Ryan41d89f62009-07-28 10:29:18302
Ryan Dahl53ebe752009-10-08 21:20:14303def v8_cmd(bld, variant):
304 scons = join(cwd, 'tools/scons/scons.py')
Ryan1a126ed2009-04-04 12:50:15305 deps_src = join(bld.path.abspath(),"deps")
Ryan1a126ed2009-04-04 12:50:15306 v8dir_src = join(deps_src,"v8")
Ryan Dahl53ebe752009-10-08 21:20:14307
Ryan Dahlbc9b3432009-10-02 12:10:40308 # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
309 # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
310 # cannot see symbols in the executable which are hidden, even if the
311 # executable is statically linked together...
Ryan8ddf9302009-09-02 18:19:52312
Ryan Dahl7d9d8812009-10-26 21:27:52313 # XXX Remove this when v8 defaults x86_64 to native builds
Ryan Dahld85724d2009-10-08 22:34:39314 arch = ""
Ryan Dahl7d9d8812009-10-26 21:27:52315 if bld.env['DEST_CPU'] == 'x86_64':
Ryan Dahld85724d2009-10-08 22:34:39316 arch = "arch=x64"
317
318 if variant == "default":
319 mode = "release"
320 else:
321 mode = "debug"
Ryana4593e32009-04-23 11:18:38322
Ryan Dahl23d680b2010-05-13 23:24:05323 cmd_R = 'python "%s" -j %d -C "%s" -Y "%s" visibility=default mode=%s %s library=static snapshot=on'
Ryan Dahl53ebe752009-10-08 21:20:14324
325 cmd = cmd_R % ( scons
Ryan Dahl23d680b2010-05-13 23:24:05326 , Options.options.jobs
Ryan Dahl53ebe752009-10-08 21:20:14327 , bld.srcnode.abspath(bld.env_of_name(variant))
328 , v8dir_src
329 , mode
330 , arch
331 )
332 return cmd
333
334
335def build_v8(bld):
Ryan1a126ed2009-04-04 12:50:15336 v8 = bld.new_task_gen(
Ryan Dahl9e8df0e2010-06-02 21:05:37337 source = 'deps/v8/SConstruct '
338 + bld.path.ant_glob('v8/include/*')
339 + bld.path.ant_glob('v8/src/*'),
Ryan Dahl53ebe752009-10-08 21:20:14340 target = bld.env["staticlib_PATTERN"] % "v8",
341 rule = v8_cmd(bld, "default"),
342 before = "cxx",
Ryan Dahl9e8df0e2010-06-02 21:05:37343 install_path = None)
Ryan Dahl8b62e862009-10-10 09:58:36344 v8.uselib = "EXECINFO"
Ryan1a126ed2009-04-04 12:50:15345 bld.env["CPPPATH_V8"] = "deps/v8/include"
Ryan Dahlfc937aa2009-10-27 21:50:46346 t = join(bld.srcnode.abspath(bld.env_of_name("default")), v8.target)
Ryan Dahl42797252010-03-31 20:36:20347 bld.env_of_name('default').append_value("LINKFLAGS_V8", t)
348
Ryana4593e32009-04-23 11:18:38349
350 ### v8 debug
Ryan29b528c2009-04-23 15:29:31351 if bld.env["USE_DEBUG"]:
Ryan29b528c2009-04-23 15:29:31352 v8_debug = v8.clone("debug")
Ryan Dahl53ebe752009-10-08 21:20:14353 v8_debug.rule = v8_cmd(bld, "debug")
354 v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g"
Ryan Dahl8b62e862009-10-10 09:58:36355 v8_debug.uselib = "EXECINFO"
Ryan Dahl9e8df0e2010-06-02 21:05:37356 bld.env["CPPPATH_V8_G"] = "deps/v8/include"
Ryan Dahlfc937aa2009-10-27 21:50:46357 t = join(bld.srcnode.abspath(bld.env_of_name("debug")), v8_debug.target)
Ryan Dahl9e8df0e2010-06-02 21:05:37358 bld.env_of_name('debug').append_value("LINKFLAGS_V8_G", t)
Ryan1a126ed2009-04-04 12:50:15359
Ryan Dahl53ebe752009-10-08 21:20:14360 bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
Ryan2b6d7242009-06-20 13:07:10361
Ryan41d89f62009-07-28 10:29:18362def build(bld):
Ryan Dahlef9f4042010-06-02 19:27:53363 ## This snippet is to show full commands as WAF executes
364 import Build
365 old = Build.BuildContext.exec_command
366 def exec_command(self, cmd, **kw):
367 if isinstance(cmd, list): print(" ".join(cmd))
368 return old(self, cmd, **kw)
369 Build.BuildContext.exec_command = exec_command
370
Ryan Dahl501136b2010-06-02 16:15:54371 Options.options.jobs=jobs
Ryan Dahlef9f4042010-06-02 19:27:53372
Ryan Dahl9ea8c9f2010-04-07 20:34:40373 print "DEST_OS: " + bld.env['DEST_OS']
374 print "DEST_CPU: " + bld.env['DEST_CPU']
Ryan Dahl23d680b2010-05-13 23:24:05375 print "Parallel Jobs: " + str(Options.options.jobs)
Ryan Dahl9ea8c9f2010-04-07 20:34:40376
Ryan Dahl9e8df0e2010-06-02 21:05:37377 bld.add_subdirs('deps/libeio')
378
379 if not bld.env['USE_SHARED_V8']: build_v8(bld)
380 if not bld.env['USE_SHARED_LIBEV']: bld.add_subdirs('deps/libev')
381 if not bld.env['USE_SHARED_CARES']: bld.add_subdirs('deps/c-ares')
Ryan41d89f62009-07-28 10:29:18382
Jérémy Lalc93bab12010-03-11 21:15:32383
Ryan5a071ad2009-05-03 12:09:16384 ### http_parser
Ryan Dahl122e74b2009-10-27 21:26:53385 http_parser = bld.new_task_gen("cc")
Ryan5a071ad2009-05-03 12:09:16386 http_parser.source = "deps/http_parser/http_parser.c"
387 http_parser.includes = "deps/http_parser/"
388 http_parser.name = "http_parser"
389 http_parser.target = "http_parser"
390 http_parser.install_path = None
Ryan29b528c2009-04-23 15:29:31391 if bld.env["USE_DEBUG"]:
Ryan5a071ad2009-05-03 12:09:16392 http_parser.clone("debug")
Ryan1a126ed2009-04-04 12:50:15393
Ryan63a9cd32009-04-15 08:08:28394 ### src/native.cc
Zokab29f7872010-03-20 03:56:03395 def make_macros(loc, content):
396 f = open(loc, 'w')
397 f.write(content)
398 f.close
399
400 macros_loc_debug = join(
401 bld.srcnode.abspath(bld.env_of_name("debug")),
402 "macros.py"
403 )
404
405 macros_loc_default = join(
406 bld.srcnode.abspath(bld.env_of_name("default")),
407 "macros.py"
408 )
409
410 make_macros(macros_loc_debug, "") # leave debug(x) as is in debug build
411 # replace debug(x) with nothing in release build
412 make_macros(macros_loc_default, "macro debug(x) = ;\n")
413
Ryan63a9cd32009-04-15 08:08:28414 def javascript_in_c(task):
415 env = task.env
416 source = map(lambda x: x.srcpath(env), task.inputs)
417 targets = map(lambda x: x.srcpath(env), task.outputs)
Zokab29f7872010-03-20 03:56:03418 source.append(macros_loc_default)
419 js2c.JS2C(source, targets)
420
421 def javascript_in_c_debug(task):
422 env = task.env
423 source = map(lambda x: x.srcpath(env), task.inputs)
424 targets = map(lambda x: x.srcpath(env), task.outputs)
425 source.append(macros_loc_debug)
Ryan63a9cd32009-04-15 08:08:28426 js2c.JS2C(source, targets)
427
428 native_cc = bld.new_task_gen(
Ryan Dahl4ccdc502010-03-15 15:00:19429 source='src/node.js ' + bld.path.ant_glob('lib/*.js'),
Ryan Dahl53ebe752009-10-08 21:20:14430 target="src/node_natives.h",
Ryan Dahl4ccdc502010-03-15 15:00:19431 before="cxx",
432 install_path=None
Ryan63a9cd32009-04-15 08:08:28433 )
Ryan Dahl4bcb01c2009-10-16 20:53:44434
435 # Add the rule /after/ cloning the debug
436 # This is a work around for an error had in python 2.4.3 (I'll paste the
437 # error that was had into the git commit meessage. git-blame to find out
438 # where.)
Ryan29b528c2009-04-23 15:29:31439 if bld.env["USE_DEBUG"]:
Ryan Dahl4bcb01c2009-10-16 20:53:44440 native_cc_debug = native_cc.clone("debug")
Zokab29f7872010-03-20 03:56:03441 native_cc_debug.rule = javascript_in_c_debug
442
Ryan Dahl4bcb01c2009-10-16 20:53:44443 native_cc.rule = javascript_in_c
Ryan63a9cd32009-04-15 08:08:28444
Ryan2b6d7242009-06-20 13:07:10445 ### node lib
Ryan8152f9c2009-09-01 12:15:29446 node = bld.new_task_gen("cxx", "program")
447 node.name = "node"
448 node.target = "node"
Ryan Dahl9e8df0e2010-06-02 21:05:37449 node.uselib = 'RT EV OPENSSL CARES EXECINFO DL KVM SOCKET NSL'
450 node.add_objects = 'eio http_parser'
451 node.install_path = '${PREFIX}/lib'
452 node.install_path = '${PREFIX}/bin'
453 node.chmod = 0755
Ryan8152f9c2009-09-01 12:15:29454 node.source = """
Ryan1a126ed2009-04-04 12:50:15455 src/node.cc
Ryan Dahl630bb7a2009-12-13 07:42:45456 src/node_buffer.cc
Ryan Dahl42ee1692010-01-24 19:21:45457 src/node_http_parser.cc
Ryan Dahl78e49f12010-05-29 20:08:05458 src/node_net.cc
Ryan Dahlf2199382009-12-13 14:43:58459 src/node_io_watcher.cc
Ryan Dahla5df0f62009-10-27 10:46:58460 src/node_child_process.cc
461 src/node_constants.cc
Krishna Rajendrandc1f4eb2010-04-06 10:28:37462 src/node_cares.cc
Ryan Dahla5df0f62009-10-27 10:46:58463 src/node_events.cc
464 src/node_file.cc
Ryan Dahl8492c522010-03-15 21:05:18465 src/node_signal_watcher.cc
466 src/node_stat_watcher.cc
Ryan17c6a672009-08-24 18:25:24467 src/node_stdio.cc
Ryan Dahla5df0f62009-10-27 10:46:58468 src/node_timer.cc
Herbert Vojcikc2a06722010-04-17 15:18:15469 src/node_script.cc
Ryan1a126ed2009-04-04 12:50:15470 """
Ryan Dahl9e8df0e2010-06-02 21:05:37471 if bld.env["USE_OPENSSL"]: node.source += "src/node_crypto.cc"
Rhys Jonesfb3a9cd2010-04-02 23:11:53472
Ryan Dahl9e8df0e2010-06-02 21:05:37473 node.includes = """
474 src/
475 deps/libeio
476 deps/http_parser
477 """
Ryan Dahle9a116f2010-04-06 10:41:32478
Ryan Dahl9e8df0e2010-06-02 21:05:37479 if not bld.env["USE_SHARED_V8"]: node.includes += ' deps/v8/include '
Vanilla Hsu067f4082010-04-07 16:05:37480
Ryan Dahl9e8df0e2010-06-02 21:05:37481 if not bld.env["USE_SHARED_LIBEV"]:
482 node.add_objects += ' ev '
483 node.includes += ' deps/libev '
Ryan Dahle9a116f2010-04-06 10:41:32484
Ryan Dahl9e8df0e2010-06-02 21:05:37485 if not bld.env["USE_SHARED_CARES"]:
486 node.add_objects += ' cares '
487 node.includes += ' deps/c-ares deps/c-ares/' + bld.env['DEST_OS'] + '-' + bld.env['DEST_CPU']
Ryan8e7bbf22009-04-23 17:26:56488
Ryan4d921992009-08-26 23:11:16489 def subflags(program):
Ryan Dahld979ac92009-10-09 13:00:12490 if os.path.exists(join(cwd, ".git")):
Ryan Dahl962e9292009-10-09 14:16:27491 actual_version=cmd_output("git describe").strip()
Ryan Dahld979ac92009-10-09 13:00:12492 else:
493 actual_version=VERSION
494
Ryanb73264d2009-08-27 00:15:11495 x = { 'CCFLAGS' : " ".join(program.env["CCFLAGS"])
496 , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"])
497 , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"])
Ryan Dahld979ac92009-10-09 13:00:12498 , 'VERSION' : actual_version
Ryanb73264d2009-08-27 00:15:11499 , 'PREFIX' : program.env["PREFIX"]
Ryan4d921992009-08-26 23:11:16500 }
Ryan Dahlbf0d2782009-10-03 20:42:03501 return x
Ryan4d921992009-08-26 23:11:16502
Ryan4d921992009-08-26 23:11:16503 # process file.pc.in -> file.pc
Ryan Dahld979ac92009-10-09 13:00:12504
Ryanb73264d2009-08-27 00:15:11505 node_version = bld.new_task_gen('subst', before="cxx")
506 node_version.source = 'src/node_version.h.in'
507 node_version.target = 'src/node_version.h'
508 node_version.dict = subflags(node)
Ryana97dce72009-08-31 09:14:34509 node_version.install_path = '${PREFIX}/include/node'
Ryan4d921992009-08-26 23:11:16510
Ryan29b528c2009-04-23 15:29:31511 if bld.env["USE_DEBUG"]:
Ryan2b6d7242009-06-20 13:07:10512 node_g = node.clone("debug")
513 node_g.target = "node_g"
Ryan Dahl9e8df0e2010-06-02 21:05:37514 node_g.uselib += ' V8_G'
515
Ryanb73264d2009-08-27 00:15:11516 node_version_g = node_version.clone("debug")
517 node_version_g.dict = subflags(node_g)
Ryana97dce72009-08-31 09:14:34518 node_version_g.install_path = None
Ryan4d921992009-08-26 23:11:16519
Ryan Dahl9e8df0e2010-06-02 21:05:37520 # After creating the debug clone, append the V8 dep
521 node.uselib += ' V8'
Ryana97dce72009-08-31 09:14:34522
523 bld.install_files('${PREFIX}/include/node/', """
524 config.h
525 src/node.h
Ryan Dahl5f466c82009-10-27 19:17:03526 src/node_object_wrap.h
Ryan Dahld2415942010-05-06 21:14:52527 src/node_buffer.h
Ryan Dahl5f466c82009-10-27 19:17:03528 src/node_events.h
Ryan Dahlbf0d2782009-10-03 20:42:03529 """)
530
Ryan Dahlef9f4042010-06-02 19:27:53531 # Only install the man page if it exists.
Ryan Dahlbf0d2782009-10-03 20:42:03532 # Do 'make doc install' to build and install it.
533 if os.path.exists('doc/node.1'):
534 bld.install_files('${PREFIX}/share/man/man1/', 'doc/node.1')
535
536 bld.install_files('${PREFIX}/bin/', 'bin/*', chmod=0755)
Ryan Dahlbf0d2782009-10-03 20:42:03537 bld.install_files('${PREFIX}/lib/node/wafadmin', 'tools/wafadmin/*.py')
538 bld.install_files('${PREFIX}/lib/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py')
Ryan Dahl6f17ca52009-10-03 17:08:05539
Ryan Dahl132d6852009-10-27 17:11:07540def shutdown():
541 Options.options.debug
542 # HACK to get binding.node out of build directory.
543 # better way to do this?
544 if not Options.commands['clean']:
545 if os.path.exists('build/default/node') and not os.path.exists('node'):
546 os.symlink('build/default/node', 'node')
547 if os.path.exists('build/debug/node_g') and not os.path.exists('node_g'):
548 os.symlink('build/debug/node_g', 'node_g')
549 else:
550 if os.path.exists('node'): os.unlink('node')
551 if os.path.exists('node_g'): os.unlink('node_g')