blob: 6310451ec9b5732f4956379f37d1ba786bf10097 [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 Dahl61c80142010-03-13 02:50:4610VERSION="0.1.32"
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
18def set_options(opt):
19 # the gcc module provides a --debug-level option
20 opt.tool_options('compiler_cxx')
21 opt.tool_options('compiler_cc')
Ryan4d921992009-08-26 23:11:1622 opt.tool_options('misc')
Ryan29b528c2009-04-23 15:29:3123 opt.add_option( '--debug'
24 , action='store_true'
25 , default=False
26 , help='Build debug variant [Default: False]'
27 , dest='debug'
28 )
Ryan7bad9de2009-06-16 13:47:5729 opt.add_option( '--efence'
30 , action='store_true'
31 , default=False
32 , help='Build with -lefence for debugging [Default: False]'
33 , dest='efence'
34 )
Jérémy Lalc93bab12010-03-11 21:15:3235 opt.add_option( '--system'
36 , action='store_true'
37 , default=False
38 , help='Build using system libraries and headers (like a debian build) [Default: False]'
39 , dest='system'
40 )
Ryan1a126ed2009-04-04 12:50:1541
Ryan41d89f62009-07-28 10:29:1842def mkdir_p(dir):
43 if not os.path.exists (dir):
44 os.makedirs (dir)
45
Ryan Dahl18da8ff2009-09-28 20:39:0046# Copied from Python 2.6 because 2.4.4 at least is broken by not using
47# mkdirs
48# http://mail.python.org/pipermail/python-bugs-list/2005-January/027118.html
49def copytree(src, dst, symlinks=False, ignore=None):
50 names = os.listdir(src)
51 if ignore is not None:
52 ignored_names = ignore(src, names)
53 else:
54 ignored_names = set()
55
56 os.makedirs(dst)
57 errors = []
58 for name in names:
59 if name in ignored_names:
60 continue
Ryan Dahl53ebe752009-10-08 21:20:1461 srcname = join(src, name)
62 dstname = join(dst, name)
Ryan Dahl18da8ff2009-09-28 20:39:0063 try:
64 if symlinks and os.path.islink(srcname):
65 linkto = os.readlink(srcname)
66 os.symlink(linkto, dstname)
67 elif os.path.isdir(srcname):
68 copytree(srcname, dstname, symlinks, ignore)
69 else:
70 shutil.copy2(srcname, dstname)
71 # XXX What about devices, sockets etc.?
72 except (IOError, os.error), why:
73 errors.append((srcname, dstname, str(why)))
74 # catch the Error from the recursive copytree so that we can
75 # continue with other files
76 except Error, err:
77 errors.extend(err.args[0])
78 try:
79 shutil.copystat(src, dst)
80 except OSError, why:
81 if WindowsError is not None and isinstance(why, WindowsError):
82 # Copying file access times may fail on Windows
83 pass
84 else:
85 errors.extend((src, dst, str(why)))
86 if errors:
87 raise Error, errors
88
Ryan41d89f62009-07-28 10:29:1889def conf_subproject (conf, subdir, command=None):
90 print("---- %s ----" % subdir)
91 src = join(conf.srcdir, subdir)
Simon Cornelius P. Umacobe801f422009-12-09 12:36:1292 if not os.path.exists (src): conf.fatal("no such subproject " + subdir)
Ryan41d89f62009-07-28 10:29:1893
94 default_tgt = join(conf.blddir, "default", subdir)
95
96 if not os.path.exists(default_tgt):
Ryan Dahl18da8ff2009-09-28 20:39:0097 copytree(src, default_tgt, True)
Ryan41d89f62009-07-28 10:29:1898
99 if command:
masuidrive3337e9d2010-02-10 10:21:54100 if os.system("cd \"%s\" && %s" % (default_tgt, command)) != 0:
Simon Cornelius P. Umacobe801f422009-12-09 12:36:12101 conf.fatal("Configuring %s failed." % (subdir))
Ryan41d89f62009-07-28 10:29:18102
103 debug_tgt = join(conf.blddir, "debug", subdir)
104
105 if not os.path.exists(debug_tgt):
Ryan Dahl18da8ff2009-09-28 20:39:00106 copytree(default_tgt, debug_tgt, True)
Ryan41d89f62009-07-28 10:29:18107
Ryan1a126ed2009-04-04 12:50:15108def configure(conf):
109 conf.check_tool('compiler_cxx')
Ryan Dahlf379b772010-01-12 00:43:10110 if not conf.env.CXX: conf.fatal('c++ compiler not found')
Ryan1a126ed2009-04-04 12:50:15111 conf.check_tool('compiler_cc')
Ryan Dahlf379b772010-01-12 00:43:10112 if not conf.env.CC: conf.fatal('c compiler not found')
Ryana4593e32009-04-23 11:18:38113
Ryan8e7bbf22009-04-23 17:26:56114 conf.env["USE_DEBUG"] = Options.options.debug
Jérémy Lalc93bab12010-03-11 21:15:32115 conf.env["USE_SYSTEM"] = Options.options.system
Ryan1a126ed2009-04-04 12:50:15116
Ryan2b6d7242009-06-20 13:07:10117 conf.check(lib='dl', uselib_store='DL')
Ryan Dahl0c125542010-01-19 23:38:20118 if not sys.platform.startswith("sunos"):
119 conf.env.append_value("CCFLAGS", "-rdynamic")
120 conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
Ryana97dce72009-08-31 09:14:34121
Vanilla Hsud22952b2010-01-07 07:37:27122 if sys.platform.startswith("freebsd"):
123 conf.check(lib='kvm', uselib_store='KVM')
124
Ryan8152f9c2009-09-01 12:15:29125 #if Options.options.debug:
126 # conf.check(lib='profiler', uselib_store='PROFILER')
Ryan7bad9de2009-06-16 13:47:57127
Ryan8152f9c2009-09-01 12:15:29128 #if Options.options.efence:
129 # conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE')
Ryana3627c02009-05-27 14:29:55130
Ryan Dahl8b62e862009-10-10 09:58:36131 if not conf.check(lib="execinfo", libpath=['/usr/lib', '/usr/local/lib'], uselib_store="EXECINFO"):
Rasmus Andersson6eb8bbc2009-12-15 22:37:49132 # Note on Darwin/OS X: This will fail, but will still be used as the
133 # execinfo stuff are part of the standard library.
Ryan Dahl8b62e862009-10-10 09:58:36134 if sys.platform.startswith("freebsd"):
Simon Cornelius P. Umacobe801f422009-12-09 12:36:12135 conf.fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.")
Ryana3627c02009-05-27 14:29:55136
Rhys Jonesb6dda612009-11-22 02:58:08137 if conf.check_cfg(package='gnutls',
138 args='--cflags --libs',
Ryan Dahl8a58e832009-11-28 14:25:10139 atleast_version='2.5.0',
Rhys Jonesb6dda612009-11-22 02:58:08140 #libpath=['/usr/lib', '/usr/local/lib'],
141 uselib_store='GNUTLS'):
142 if conf.check(lib='gpg-error',
Ryan Dahl0b823dc2010-02-17 21:56:44143 libpath=['/usr/lib', '/usr/local/lib', '/opt/local/lib'],
Rhys Jonesb6dda612009-11-22 02:58:08144 uselib_store='GPGERROR'):
145 conf.env.append_value("CCFLAGS", "-DEVCOM_HAVE_GNUTLS=1")
146 conf.env.append_value("CXXFLAGS", "-DEVCOM_HAVE_GNUTLS=1")
147
Ryan Dahl0c125542010-01-19 23:38:20148 if sys.platform.startswith("sunos"):
149 if not conf.check(lib='socket', uselib_store="SOCKET"):
150 conf.fatal("Cannot find socket library")
151 if not conf.check(lib='nsl', uselib_store="NSL"):
152 conf.fatal("Cannot find nsl library")
153
Ryan1a126ed2009-04-04 12:50:15154 conf.sub_config('deps/libeio')
Jérémy Lalc93bab12010-03-11 21:15:32155 if not Options.options.system:
156 conf.sub_config('deps/libev')
157 if sys.platform.startswith("sunos"):
158 conf_subproject(conf, 'deps/udns', 'LIBS="-lsocket -lnsl" ./configure')
159 else:
160 conf_subproject(conf, 'deps/udns', './configure')
Ryan Dahl0c125542010-01-19 23:38:20161 else:
Jérémy Lalc93bab12010-03-11 21:15:32162 if not conf.check(lib='v8', uselib_store='V8'):
163 conf.fatal("Cannot find V8")
164 if not conf.check(lib='ev', uselib_store='EV'):
165 conf.fatal("Cannot find libev")
Ryan Dahlffeb4722010-03-13 20:20:09166 if not conf.check(lib='udns', uselib_store='UDNS'):
Jérémy Lalc93bab12010-03-11 21:15:32167 conf.fatal("Cannot find udns")
Ryan41d89f62009-07-28 10:29:18168
Ryan1a126ed2009-04-04 12:50:15169 conf.define("HAVE_CONFIG_H", 1)
Ryanc62b1242009-04-22 17:55:08170
Ryan1df6d612009-09-03 13:59:48171 conf.env.append_value("CCFLAGS", "-DX_STACKSIZE=%d" % (1024*64))
Ryan427e3f52009-05-14 11:16:45172
Ryan Dahl2b743aa2009-10-27 11:05:38173 # LFS
174 conf.env.append_value('CCFLAGS', '-D_LARGEFILE_SOURCE')
175 conf.env.append_value('CXXFLAGS', '-D_LARGEFILE_SOURCE')
176 conf.env.append_value('CCFLAGS', '-D_FILE_OFFSET_BITS=64')
177 conf.env.append_value('CXXFLAGS', '-D_FILE_OFFSET_BITS=64')
178
Ryan Dahlf4811832009-11-02 23:21:00179 # platform
180 platform_def = '-DPLATFORM=' + sys.platform
181 conf.env.append_value('CCFLAGS', platform_def)
182 conf.env.append_value('CXXFLAGS', platform_def)
183
Ryan67af9582009-04-18 13:35:42184 # Split off debug variant before adding variant specific defines
Ryan7e1350f2009-04-16 09:37:44185 debug_env = conf.env.copy()
186 conf.set_env_name('debug', debug_env)
Ryan7e1350f2009-04-16 09:37:44187
Ryan67af9582009-04-18 13:35:42188 # Configure debug variant
189 conf.setenv('debug')
190 debug_env.set_variant('debug')
Ryan8ddf9302009-09-02 18:19:52191 debug_env.append_value('CCFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
192 debug_env.append_value('CXXFLAGS', ['-DDEBUG', '-g', '-O0', '-Wall', '-Wextra'])
Ryan67af9582009-04-18 13:35:42193 conf.write_config_header("config.h")
194
195 # Configure default variant
196 conf.setenv('default')
Ryan8ddf9302009-09-02 18:19:52197 conf.env.append_value('CCFLAGS', ['-DNDEBUG', '-O3'])
198 conf.env.append_value('CXXFLAGS', ['-DNDEBUG', '-O3'])
Ryan67af9582009-04-18 13:35:42199 conf.write_config_header("config.h")
Ryan63a9cd32009-04-15 08:08:28200
Ryan41d89f62009-07-28 10:29:18201def build_udns(bld):
202 default_build_dir = bld.srcnode.abspath(bld.env_of_name("default"))
Ryan1a126ed2009-04-04 12:50:15203
Ryan41d89f62009-07-28 10:29:18204 default_dir = join(default_build_dir, "deps/udns")
205
206 static_lib = bld.env["staticlib_PATTERN"] % "udns"
207
masuidrive3337e9d2010-02-10 10:21:54208 rule = 'cd "%s" && make'
Ryan41d89f62009-07-28 10:29:18209
210 default = bld.new_task_gen(
211 target= join("deps/udns", static_lib),
212 rule= rule % default_dir,
213 before= "cxx",
214 install_path= None
215 )
216
217 bld.env["CPPPATH_UDNS"] = "deps/udns"
Ryan Dahlfc937aa2009-10-27 21:50:46218 t = join(bld.srcnode.abspath(bld.env_of_name("default")), default.target)
219 bld.env_of_name('default')["LINKFLAGS_UDNS"] = [t]
Ryan41d89f62009-07-28 10:29:18220
221 if bld.env["USE_DEBUG"]:
222 debug_build_dir = bld.srcnode.abspath(bld.env_of_name("debug"))
223 debug_dir = join(debug_build_dir, "deps/udns")
224 debug = default.clone("debug")
225 debug.rule = rule % debug_dir
Ryan Dahlfc937aa2009-10-27 21:50:46226 t = join(bld.srcnode.abspath(bld.env_of_name("debug")), debug.target)
227 bld.env_of_name('debug')["LINKFLAGS_UDNS"] = [t]
Ryan Dahl0c125542010-01-19 23:38:20228
Ryan Dahlbf0d2782009-10-03 20:42:03229 bld.install_files('${PREFIX}/include/node/', 'deps/udns/udns.h')
Ryan41d89f62009-07-28 10:29:18230
Ryan Dahl53ebe752009-10-08 21:20:14231def v8_cmd(bld, variant):
232 scons = join(cwd, 'tools/scons/scons.py')
Ryan1a126ed2009-04-04 12:50:15233 deps_src = join(bld.path.abspath(),"deps")
Ryan1a126ed2009-04-04 12:50:15234 v8dir_src = join(deps_src,"v8")
Ryan Dahl53ebe752009-10-08 21:20:14235
Ryan Dahlbc9b3432009-10-02 12:10:40236 # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
237 # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
238 # cannot see symbols in the executable which are hidden, even if the
239 # executable is statically linked together...
Ryan8ddf9302009-09-02 18:19:52240
Ryan Dahl7d9d8812009-10-26 21:27:52241 # XXX Remove this when v8 defaults x86_64 to native builds
Ryan Dahld85724d2009-10-08 22:34:39242 arch = ""
Ryan Dahl7d9d8812009-10-26 21:27:52243 if bld.env['DEST_CPU'] == 'x86_64':
Ryan Dahld85724d2009-10-08 22:34:39244 arch = "arch=x64"
245
246 if variant == "default":
247 mode = "release"
248 else:
249 mode = "debug"
Ryana4593e32009-04-23 11:18:38250
masuidrive3337e9d2010-02-10 10:21:54251 cmd_R = 'python "%s" -C "%s" -Y "%s" visibility=default mode=%s %s library=static snapshot=on'
Ryan Dahl53ebe752009-10-08 21:20:14252
253 cmd = cmd_R % ( scons
254 , bld.srcnode.abspath(bld.env_of_name(variant))
255 , v8dir_src
256 , mode
257 , arch
258 )
259 return cmd
260
261
262def build_v8(bld):
Ryan1a126ed2009-04-04 12:50:15263 v8 = bld.new_task_gen(
Ryan Dahl59b7a1b2009-10-09 10:49:48264 source = 'deps/v8/SConstruct '
265 + bld.path.ant_glob('v8/include/*')
266 + bld.path.ant_glob('v8/src/*'),
Ryan Dahl53ebe752009-10-08 21:20:14267 target = bld.env["staticlib_PATTERN"] % "v8",
268 rule = v8_cmd(bld, "default"),
269 before = "cxx",
270 install_path = None
Ryan1a126ed2009-04-04 12:50:15271 )
Ryan Dahl8b62e862009-10-10 09:58:36272 v8.uselib = "EXECINFO"
Ryan1a126ed2009-04-04 12:50:15273 bld.env["CPPPATH_V8"] = "deps/v8/include"
Ryan Dahlfc937aa2009-10-27 21:50:46274 t = join(bld.srcnode.abspath(bld.env_of_name("default")), v8.target)
Ryan Dahl0c125542010-01-19 23:38:20275 if sys.platform.startswith("sunos"):
276 bld.env_of_name('default')["LINKFLAGS_V8"] = ["-mt", t]
277 else:
278 bld.env_of_name('default')["LINKFLAGS_V8"] = ["-pthread", t]
Ryana4593e32009-04-23 11:18:38279
280 ### v8 debug
Ryan29b528c2009-04-23 15:29:31281 if bld.env["USE_DEBUG"]:
Ryan29b528c2009-04-23 15:29:31282 v8_debug = v8.clone("debug")
Ryan Dahl53ebe752009-10-08 21:20:14283 v8_debug.rule = v8_cmd(bld, "debug")
284 v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g"
Ryan Dahl8b62e862009-10-10 09:58:36285 v8_debug.uselib = "EXECINFO"
Ryan Dahlfc937aa2009-10-27 21:50:46286 t = join(bld.srcnode.abspath(bld.env_of_name("debug")), v8_debug.target)
Ryan Dahl0c125542010-01-19 23:38:20287 if sys.platform.startswith("sunos"):
288 bld.env_of_name('debug')["LINKFLAGS_V8"] = ["-mt", t]
289 else:
290 bld.env_of_name('debug')["LINKFLAGS_V8"] = ["-pthread", t]
Ryan1a126ed2009-04-04 12:50:15291
Ryan Dahl53ebe752009-10-08 21:20:14292 bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
Ryan2b6d7242009-06-20 13:07:10293
Ryan41d89f62009-07-28 10:29:18294def build(bld):
Jérémy Lalc93bab12010-03-11 21:15:32295 if not bld.env["USE_SYSTEM"]:
296 bld.add_subdirs('deps/libeio deps/libev')
297 build_udns(bld)
298 build_v8(bld)
299 else:
300 bld.add_subdirs('deps/libeio')
Ryan41d89f62009-07-28 10:29:18301
Jérémy Lalc93bab12010-03-11 21:15:32302
Ryan41d89f62009-07-28 10:29:18303
Ryan0fb0af32009-07-25 15:52:21304 ### evcom
Ryan Dahl122e74b2009-10-27 21:26:53305 evcom = bld.new_task_gen("cc")
Ryan0fb0af32009-07-25 15:52:21306 evcom.source = "deps/evcom/evcom.c"
Jérémy Lalc93bab12010-03-11 21:15:32307 if not bld.env["USE_SYSTEM"]:
308 evcom.includes = "deps/evcom/ deps/libev/"
309 else:
310 evcom.includes = "deps/evcom/"
Ryan0fb0af32009-07-25 15:52:21311 evcom.name = "evcom"
312 evcom.target = "evcom"
Rhys Jonesb6dda612009-11-22 02:58:08313 evcom.uselib = "GPGERROR GNUTLS"
Ryan0fb0af32009-07-25 15:52:21314 evcom.install_path = None
Ryan29b528c2009-04-23 15:29:31315 if bld.env["USE_DEBUG"]:
Ryan0fb0af32009-07-25 15:52:21316 evcom.clone("debug")
Ryan Dahlbf0d2782009-10-03 20:42:03317 bld.install_files('${PREFIX}/include/node/', 'deps/evcom/evcom.h')
Ryan1a126ed2009-04-04 12:50:15318
Ryan5a071ad2009-05-03 12:09:16319 ### http_parser
Ryan Dahl122e74b2009-10-27 21:26:53320 http_parser = bld.new_task_gen("cc")
Ryan5a071ad2009-05-03 12:09:16321 http_parser.source = "deps/http_parser/http_parser.c"
322 http_parser.includes = "deps/http_parser/"
323 http_parser.name = "http_parser"
324 http_parser.target = "http_parser"
325 http_parser.install_path = None
Ryan29b528c2009-04-23 15:29:31326 if bld.env["USE_DEBUG"]:
Ryan5a071ad2009-05-03 12:09:16327 http_parser.clone("debug")
Ryan1a126ed2009-04-04 12:50:15328
Ryan17c6a672009-08-24 18:25:24329 ### coupling
Ryan Dahl122e74b2009-10-27 21:26:53330 coupling = bld.new_task_gen("cc")
Ryan17c6a672009-08-24 18:25:24331 coupling.source = "deps/coupling/coupling.c"
332 coupling.includes = "deps/coupling/"
333 coupling.name = "coupling"
334 coupling.target = "coupling"
335 coupling.install_path = None
336 if bld.env["USE_DEBUG"]:
337 coupling.clone("debug")
338
Ryan63a9cd32009-04-15 08:08:28339 ### src/native.cc
340 def javascript_in_c(task):
341 env = task.env
342 source = map(lambda x: x.srcpath(env), task.inputs)
343 targets = map(lambda x: x.srcpath(env), task.outputs)
344 js2c.JS2C(source, targets)
345
346 native_cc = bld.new_task_gen(
Ryan Dahld737a062009-11-07 13:37:22347 source='src/node.js',
Ryan Dahl53ebe752009-10-08 21:20:14348 target="src/node_natives.h",
Ryan63a9cd32009-04-15 08:08:28349 before="cxx"
350 )
Ryan8e7bbf22009-04-23 17:26:56351 native_cc.install_path = None
Ryan Dahl4bcb01c2009-10-16 20:53:44352
353 # Add the rule /after/ cloning the debug
354 # This is a work around for an error had in python 2.4.3 (I'll paste the
355 # error that was had into the git commit meessage. git-blame to find out
356 # where.)
Ryan29b528c2009-04-23 15:29:31357 if bld.env["USE_DEBUG"]:
Ryan Dahl4bcb01c2009-10-16 20:53:44358 native_cc_debug = native_cc.clone("debug")
359 native_cc_debug.rule = javascript_in_c
360 native_cc.rule = javascript_in_c
Ryan63a9cd32009-04-15 08:08:28361
Ryan2b6d7242009-06-20 13:07:10362 ### node lib
Ryan8152f9c2009-09-01 12:15:29363 node = bld.new_task_gen("cxx", "program")
364 node.name = "node"
365 node.target = "node"
366 node.source = """
Ryan1a126ed2009-04-04 12:50:15367 src/node.cc
Ryan Dahla5df0f62009-10-27 10:46:58368 src/node_child_process.cc
369 src/node_constants.cc
370 src/node_dns.cc
371 src/node_events.cc
372 src/node_file.cc
373 src/node_http.cc
374 src/node_net.cc
375 src/node_signal_handler.cc
Ryan Dahl8d2f9e82009-11-17 13:07:48376 src/node_stat.cc
Ryan17c6a672009-08-24 18:25:24377 src/node_stdio.cc
Ryan Dahla5df0f62009-10-27 10:46:58378 src/node_timer.cc
Ryan Dahlaeb7d6d2010-01-18 18:12:04379 src/node_idle_watcher.cc
Ryan1a126ed2009-04-04 12:50:15380 """
Jérémy Lalc93bab12010-03-11 21:15:32381 if not bld.env["USE_SYSTEM"]:
382 node.includes = """
383 src/
384 deps/v8/include
385 deps/libev
386 deps/udns
387 deps/libeio
388 deps/evcom
389 deps/http_parser
390 deps/coupling
391 """
392 node.add_objects = 'ev eio evcom http_parser coupling'
393 node.uselib_local = ''
394 node.uselib = 'GNUTLS GPGERROR UDNS V8 EXECINFO DL KVM SOCKET NSL'
395 else:
396 node.includes = """
397 src/
398 deps/libeio
399 deps/evcom
400 deps/http_parser
401 deps/coupling
402 """
403 node.add_objects = 'eio evcom http_parser coupling'
404 node.uselib_local = 'eio'
405 node.uselib = 'EV GNUTLS GPGERROR UDNS V8 EXECINFO DL KVM SOCKET NSL'
Rhys Jonesb6dda612009-11-22 02:58:08406
Ryan8152f9c2009-09-01 12:15:29407 node.install_path = '${PREFIX}/lib'
Ryan8e7bbf22009-04-23 17:26:56408 node.install_path = '${PREFIX}/bin'
409 node.chmod = 0755
410
Ryan4d921992009-08-26 23:11:16411 def subflags(program):
Ryan Dahld979ac92009-10-09 13:00:12412 if os.path.exists(join(cwd, ".git")):
Ryan Dahl962e9292009-10-09 14:16:27413 actual_version=cmd_output("git describe").strip()
Ryan Dahld979ac92009-10-09 13:00:12414 else:
415 actual_version=VERSION
416
Ryanb73264d2009-08-27 00:15:11417 x = { 'CCFLAGS' : " ".join(program.env["CCFLAGS"])
418 , 'CPPFLAGS' : " ".join(program.env["CPPFLAGS"])
419 , 'LIBFLAGS' : " ".join(program.env["LIBFLAGS"])
Ryan Dahld979ac92009-10-09 13:00:12420 , 'VERSION' : actual_version
Ryanb73264d2009-08-27 00:15:11421 , 'PREFIX' : program.env["PREFIX"]
Ryan4d921992009-08-26 23:11:16422 }
Ryan Dahlbf0d2782009-10-03 20:42:03423 return x
Ryan4d921992009-08-26 23:11:16424
Ryan4d921992009-08-26 23:11:16425 # process file.pc.in -> file.pc
Ryan Dahld979ac92009-10-09 13:00:12426
Ryanb73264d2009-08-27 00:15:11427 node_version = bld.new_task_gen('subst', before="cxx")
428 node_version.source = 'src/node_version.h.in'
429 node_version.target = 'src/node_version.h'
430 node_version.dict = subflags(node)
Ryana97dce72009-08-31 09:14:34431 node_version.install_path = '${PREFIX}/include/node'
Ryan4d921992009-08-26 23:11:16432
Ryan29b528c2009-04-23 15:29:31433 if bld.env["USE_DEBUG"]:
Ryan2b6d7242009-06-20 13:07:10434 node_g = node.clone("debug")
435 node_g.target = "node_g"
Ryan4d921992009-08-26 23:11:16436
Ryanb73264d2009-08-27 00:15:11437 node_version_g = node_version.clone("debug")
438 node_version_g.dict = subflags(node_g)
Ryana97dce72009-08-31 09:14:34439 node_version_g.install_path = None
Ryan4d921992009-08-26 23:11:16440
Ryana97dce72009-08-31 09:14:34441
442 bld.install_files('${PREFIX}/include/node/', """
443 config.h
444 src/node.h
Ryan Dahl5f466c82009-10-27 19:17:03445 src/node_object_wrap.h
446 src/node_events.h
447 src/node_net.h
Ryan Dahlbf0d2782009-10-03 20:42:03448 """)
449
450 # Only install the man page if it exists.
451 # Do 'make doc install' to build and install it.
452 if os.path.exists('doc/node.1'):
453 bld.install_files('${PREFIX}/share/man/man1/', 'doc/node.1')
454
455 bld.install_files('${PREFIX}/bin/', 'bin/*', chmod=0755)
Ryan Dahl6f17ca52009-10-03 17:08:05456
457 # Why am I using two lines? Because WAF SUCKS.
Ryan Dahlbf0d2782009-10-03 20:42:03458 bld.install_files('${PREFIX}/lib/node/wafadmin', 'tools/wafadmin/*.py')
459 bld.install_files('${PREFIX}/lib/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py')
Ryan Dahl6f17ca52009-10-03 17:08:05460
Ryan Dahlbf0d2782009-10-03 20:42:03461 bld.install_files('${PREFIX}/lib/node/libraries/', 'lib/*.js')
Ryan Dahl132d6852009-10-27 17:11:07462
463def shutdown():
464 Options.options.debug
465 # HACK to get binding.node out of build directory.
466 # better way to do this?
467 if not Options.commands['clean']:
468 if os.path.exists('build/default/node') and not os.path.exists('node'):
469 os.symlink('build/default/node', 'node')
470 if os.path.exists('build/debug/node_g') and not os.path.exists('node_g'):
471 os.symlink('build/debug/node_g', 'node_g')
472 else:
473 if os.path.exists('node'): os.unlink('node')
474 if os.path.exists('node_g'): os.unlink('node_g')