~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to wscript

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
# Copyright Joyent, Inc. and other Node contributors.
4
 
#
5
 
# Permission is hereby granted, free of charge, to any person obtaining a
6
 
# copy of this software and associated documentation files (the
7
 
# "Software"), to deal in the Software without restriction, including
8
 
# without limitation the rights to use, copy, modify, merge, publish,
9
 
# distribute, sublicense, and/or sell copies of the Software, and to permit
10
 
# persons to whom the Software is furnished to do so, subject to the
11
 
# following conditions:
12
 
#
13
 
# The above copyright notice and this permission notice shall be included
14
 
# in all copies or substantial portions of the Software.
15
 
#
16
 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
 
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
 
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19
 
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
 
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
 
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22
 
# USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 
 
24
 
import re
25
 
import Options
26
 
import sys, os, shutil, glob
27
 
import Utils
28
 
from Utils import cmd_output
29
 
from os.path import join, dirname, abspath, normpath
30
 
from logging import fatal
31
 
 
32
 
cwd = os.getcwd()
33
 
APPNAME="node.js"
34
 
 
35
 
# Use the directory that this file is found in to find the tools
36
 
# directory where the js2c.py file can be found.
37
 
sys.path.append(sys.argv[0] + '/tools');
38
 
import js2c
39
 
 
40
 
if sys.platform.startswith("cygwin"):
41
 
  print "cygwin not supported"
42
 
  sys.exit(1)
43
 
 
44
 
srcdir = '.'
45
 
blddir = 'out'
46
 
supported_archs = ('arm', 'ia32', 'x64', 'mips') # 'mips' supported by v8, but not node
47
 
 
48
 
jobs=1
49
 
if os.environ.has_key('JOBS'):
50
 
  jobs = int(os.environ['JOBS'])
51
 
 
52
 
def safe_path(path):
53
 
  return path.replace("\\", "/")
54
 
 
55
 
def canonical_cpu_type(arch):
56
 
  m = {'x86': 'ia32', 'i386':'ia32', 'x86_64':'x64', 'amd64':'x64', 'mipsel':'mips'}
57
 
  if arch in m: arch = m[arch]
58
 
  if not arch in supported_archs:
59
 
    raise Exception("supported architectures are "+', '.join(supported_archs)+\
60
 
                    " but NOT '" + arch + "'.")
61
 
  return arch
62
 
 
63
 
def set_options(opt):
64
 
  # the gcc module provides a --debug-level option
65
 
  opt.tool_options('compiler_cxx')
66
 
  opt.tool_options('compiler_cc')
67
 
  opt.tool_options('misc')
68
 
  opt.add_option( '--libdir'
69
 
                , action='store'
70
 
                , type='string'
71
 
                , default=False
72
 
                , help='Install into this libdir [Release: ${PREFIX}/lib]'
73
 
                )
74
 
  opt.add_option( '--debug'
75
 
                , action='store_true'
76
 
                , default=False
77
 
                , help='Build debug variant [Release: False]'
78
 
                , dest='debug'
79
 
                )
80
 
  opt.add_option( '--profile'
81
 
                , action='store_true'
82
 
                , default=False
83
 
                , help='Enable profiling [Release: False]'
84
 
                , dest='profile'
85
 
                )
86
 
  opt.add_option( '--efence'
87
 
                , action='store_true'
88
 
                , default=False
89
 
                , help='Build with -lefence for debugging [Release: False]'
90
 
                , dest='efence'
91
 
                )
92
 
 
93
 
  opt.add_option( '--without-npm'
94
 
                , action='store_true'
95
 
                , default=False
96
 
                , help='Don\'t install the bundled npm package manager [Release: False]'
97
 
                , dest='without_npm'
98
 
                )
99
 
 
100
 
  opt.add_option( '--without-snapshot'
101
 
                , action='store_true'
102
 
                , default=False
103
 
                , help='Build without snapshotting V8 libraries. You might want to set this for cross-compiling. [Release: False]'
104
 
                , dest='without_snapshot'
105
 
                )
106
 
 
107
 
  opt.add_option( '--without-ssl'
108
 
                , action='store_true'
109
 
                , default=False
110
 
                , help='Build without SSL'
111
 
                , dest='without_ssl'
112
 
                )
113
 
 
114
 
 
115
 
  opt.add_option('--shared-v8'
116
 
                , action='store_true'
117
 
                , default=False
118
 
                , help='Link to a shared V8 DLL instead of static linking'
119
 
                , dest='shared_v8'
120
 
                )
121
 
 
122
 
  opt.add_option( '--shared-v8-includes'
123
 
                , action='store'
124
 
                , default=False
125
 
                , help='Directory containing V8 header files'
126
 
                , dest='shared_v8_includes'
127
 
                )
128
 
 
129
 
  opt.add_option( '--shared-v8-libpath'
130
 
                , action='store'
131
 
                , default=False
132
 
                , help='A directory to search for the shared V8 DLL'
133
 
                , dest='shared_v8_libpath'
134
 
                )
135
 
 
136
 
  opt.add_option( '--shared-v8-libname'
137
 
                , action='store'
138
 
                , default=False
139
 
                , help="Alternative lib name to link to (default: 'v8')"
140
 
                , dest='shared_v8_libname'
141
 
                )
142
 
 
143
 
  opt.add_option( '--openssl-includes'
144
 
                , action='store'
145
 
                , default=False
146
 
                , help='A directory to search for the OpenSSL includes'
147
 
                , dest='openssl_includes'
148
 
                )
149
 
 
150
 
  opt.add_option( '--openssl-libpath'
151
 
                , action='store'
152
 
                , default=False
153
 
                , help="A directory to search for the OpenSSL libraries"
154
 
                , dest='openssl_libpath'
155
 
                )
156
 
 
157
 
  opt.add_option( '--no-ssl2'
158
 
                , action='store_true'
159
 
                , default=False
160
 
                , help="Disable OpenSSL v2"
161
 
                , dest='openssl_nov2'
162
 
                )
163
 
 
164
 
  opt.add_option( '--gdb'
165
 
                , action='store_true'
166
 
                , default=False
167
 
                , help="add gdb support"
168
 
                , dest='use_gdbjit'
169
 
                )
170
 
 
171
 
 
172
 
  opt.add_option( '--shared-zlib'
173
 
                , action='store_true'
174
 
                , default=False
175
 
                , help='Link to a shared zlib DLL instead of static linking'
176
 
                , dest='shared_zlib'
177
 
                )
178
 
 
179
 
  opt.add_option( '--shared-zlib-includes'
180
 
                , action='store'
181
 
                , default=False
182
 
                , help='Directory containing zlib header files'
183
 
                , dest='shared_zlib_includes'
184
 
                )
185
 
 
186
 
  opt.add_option( '--shared-zlib-libpath'
187
 
                , action='store'
188
 
                , default=False
189
 
                , help='A directory to search for the shared zlib DLL'
190
 
                , dest='shared_zlib_libpath'
191
 
                )
192
 
 
193
 
 
194
 
  opt.add_option( '--shared-cares'
195
 
                , action='store_true'
196
 
                , default=False
197
 
                , help='Link to a shared C-Ares DLL instead of static linking'
198
 
                , dest='shared_cares'
199
 
                )
200
 
 
201
 
  opt.add_option( '--shared-cares-includes'
202
 
                , action='store'
203
 
                , default=False
204
 
                , help='Directory containing C-Ares header files'
205
 
                , dest='shared_cares_includes'
206
 
                )
207
 
 
208
 
  opt.add_option( '--shared-cares-libpath'
209
 
                , action='store'
210
 
                , default=False
211
 
                , help='A directory to search for the shared C-Ares DLL'
212
 
                , dest='shared_cares_libpath'
213
 
                )
214
 
 
215
 
  opt.add_option('--shared-libev'
216
 
                , action='store_true'
217
 
                , default=False
218
 
                , help='Link to a shared libev DLL instead of static linking'
219
 
                , dest='shared_libev'
220
 
                )
221
 
 
222
 
  opt.add_option( '--shared-libev-includes'
223
 
                , action='store'
224
 
                , default=False
225
 
                , help='Directory containing libev header files'
226
 
                , dest='shared_libev_includes'
227
 
                )
228
 
 
229
 
  opt.add_option( '--shared-libev-libpath'
230
 
                , action='store'
231
 
                , default=False
232
 
                , help='A directory to search for the shared libev DLL'
233
 
                , dest='shared_libev_libpath'
234
 
                )
235
 
 
236
 
  opt.add_option( '--with-dtrace'
237
 
                , action='store_true'
238
 
                , default=False
239
 
                , help='Build with DTrace (experimental)'
240
 
                , dest='dtrace'
241
 
                )
242
 
 
243
 
 
244
 
  opt.add_option( '--product-type'
245
 
                , action='store'
246
 
                , default='program'
247
 
                , help='What kind of product to produce (program, cstaticlib '\
248
 
                       'or cshlib) [default: %default]'
249
 
                , dest='product_type'
250
 
                )
251
 
 
252
 
  opt.add_option( '--dest-cpu'
253
 
                , action='store'
254
 
                , default=None
255
 
                , help='CPU architecture to build for. Valid values are: '+\
256
 
                       ', '.join(supported_archs)
257
 
                , dest='dest_cpu'
258
 
                )
259
 
 
260
 
def get_node_version():
261
 
  def get_define_value(lines, define):
262
 
    for line in lines:
263
 
      if define in line:
264
 
        return line.split()[-1] #define <NAME> <VALUE>
265
 
 
266
 
  lines = open("src/node_version.h").readlines()
267
 
  node_major_version = get_define_value(lines, 'NODE_MAJOR_VERSION')
268
 
  node_minor_version = get_define_value(lines, 'NODE_MINOR_VERSION')
269
 
  node_patch_version = get_define_value(lines, 'NODE_PATCH_VERSION')
270
 
  node_is_release    = get_define_value(lines, 'NODE_VERSION_IS_RELEASE')
271
 
 
272
 
  return "%s.%s.%s%s" % ( node_major_version,
273
 
                           node_minor_version,
274
 
                           node_patch_version,
275
 
                           node_is_release == "0" and "-pre" or ""
276
 
                         )
277
 
 
278
 
def arch_cflags(conf):
279
 
  flags = []
280
 
 
281
 
  if 'DEST_CPU' in conf.env:
282
 
    arch = conf.env['DEST_CPU']
283
 
    if arch == 'ia32':
284
 
      flags += ['-m32']
285
 
    elif arch == 'x64':
286
 
      flags += ['-m64']
287
 
    if sys.platform.startswith('darwin'):
288
 
      flags += ['-arch', {'ia32':'i386', 'x64':'x86_64'}.get(arch, arch)]
289
 
 
290
 
  return flags
291
 
 
292
 
def configure(conf):
293
 
  conf.check_tool('compiler_cxx')
294
 
  if not conf.env.CXX: conf.fatal('c++ compiler not found')
295
 
  conf.check_tool('compiler_cc')
296
 
  if not conf.env.CC: conf.fatal('c compiler not found')
297
 
 
298
 
  o = Options.options
299
 
 
300
 
  if o.libdir:
301
 
    conf.env['LIBDIR'] = o.libdir
302
 
  else:
303
 
    conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
304
 
 
305
 
  conf.env["USE_DEBUG"] = o.debug
306
 
  # Snapshot building does noet seem to work on mingw32
307
 
  conf.env["SNAPSHOT_V8"] = not o.without_snapshot and not sys.platform.startswith("win32")
308
 
  if sys.platform.startswith("sunos"):
309
 
    conf.env["SNAPSHOT_V8"] = False
310
 
  conf.env["USE_PROFILING"] = o.profile
311
 
 
312
 
  conf.env["USE_SHARED_V8"] = o.shared_v8 or o.shared_v8_includes or o.shared_v8_libpath or o.shared_v8_libname
313
 
  conf.env["USE_SHARED_CARES"] = o.shared_cares or o.shared_cares_includes or o.shared_cares_libpath
314
 
  conf.env["USE_SHARED_LIBEV"] = o.shared_libev or o.shared_libev_includes or o.shared_libev_libpath
315
 
  conf.env["USE_SHARED_ZLIB"] = o.shared_zlib or o.shared_zlib_includes or o.shared_zlib_libpath
316
 
 
317
 
  conf.env["USE_GDBJIT"] = o.use_gdbjit
318
 
  conf.env['USE_NPM'] = not o.without_npm
319
 
 
320
 
  conf.check(lib='dl', uselib_store='DL')
321
 
  if not sys.platform.startswith("sunos") and not sys.platform.startswith("win32"):
322
 
    conf.env.append_value("CCFLAGS", "-rdynamic")
323
 
    conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
324
 
 
325
 
  if 'bsd' in sys.platform:
326
 
    conf.check(lib='kvm', uselib_store='KVM')
327
 
 
328
 
  #if Options.options.debug:
329
 
  #  conf.check(lib='profiler', uselib_store='PROFILER')
330
 
 
331
 
  if Options.options.dtrace:
332
 
    if not sys.platform.startswith("sunos"):
333
 
      conf.fatal('DTrace support only currently available on Solaris')
334
 
 
335
 
    conf.find_program('dtrace', var='DTRACE', mandatory=True)
336
 
    conf.env["USE_DTRACE"] = True
337
 
    conf.env.append_value("CXXFLAGS", "-DHAVE_DTRACE=1")
338
 
 
339
 
  if Options.options.efence:
340
 
    conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE')
341
 
 
342
 
  if 'bsd' in sys.platform:
343
 
     if not conf.check(lib="execinfo",
344
 
                       includes=['/usr/include', '/usr/local/include'],
345
 
                       libpath=['/usr/lib', '/usr/local/lib'],
346
 
                       uselib_store="EXECINFO"):
347
 
       conf.fatal("Install the libexecinfo port from /usr/ports/devel/libexecinfo.")
348
 
 
349
 
  if not Options.options.without_ssl:
350
 
    # Don't override explicitly supplied openssl paths with pkg-config results.
351
 
    explicit_openssl = o.openssl_includes or o.openssl_libpath
352
 
 
353
 
    # Disable ssl v2 methods
354
 
    if o.openssl_nov2:
355
 
      conf.env.append_value("CPPFLAGS", "-DOPENSSL_NO_SSL2=1")
356
 
 
357
 
    if not explicit_openssl and conf.check_cfg(package='openssl',
358
 
                                               args='--cflags --libs',
359
 
                                               uselib_store='OPENSSL'):
360
 
      Options.options.use_openssl = conf.env["USE_OPENSSL"] = True
361
 
      conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
362
 
    else:
363
 
      if o.openssl_libpath: 
364
 
        openssl_libpath = [o.openssl_libpath]
365
 
      elif not sys.platform.startswith('win32'):
366
 
        openssl_libpath = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/usr/sfw/lib']
367
 
      else:
368
 
        openssl_libpath = [normpath(join(cwd, '../openssl'))]
369
 
 
370
 
      if o.openssl_includes: 
371
 
        openssl_includes = [o.openssl_includes]
372
 
      elif not sys.platform.startswith('win32'):
373
 
        openssl_includes = [];
374
 
      else:
375
 
        openssl_includes = [normpath(join(cwd, '../openssl/include'))];
376
 
 
377
 
      openssl_lib_names = ['ssl', 'crypto']
378
 
      if sys.platform.startswith('win32'):
379
 
        openssl_lib_names += ['ws2_32', 'gdi32']
380
 
 
381
 
      libssl = conf.check_cc(lib=openssl_lib_names,
382
 
                             header_name='openssl/ssl.h',
383
 
                             function_name='SSL_library_init',
384
 
                             includes=openssl_includes,
385
 
                             libpath=openssl_libpath,
386
 
                             uselib_store='OPENSSL')
387
 
 
388
 
      libcrypto = conf.check_cc(lib='crypto',
389
 
                                header_name='openssl/crypto.h',
390
 
                                includes=openssl_includes,
391
 
                                libpath=openssl_libpath,
392
 
                                uselib_store='OPENSSL')
393
 
 
394
 
      if libcrypto and libssl:
395
 
        conf.env["USE_OPENSSL"] = Options.options.use_openssl = True
396
 
        conf.env.append_value("CPPFLAGS", "-DHAVE_OPENSSL=1")
397
 
      elif sys.platform.startswith('win32'):
398
 
        conf.fatal("Could not autodetect OpenSSL support. " +
399
 
                   "Use the --openssl-libpath and --openssl-includes options to set the search path. " +
400
 
                   "Use configure --without-ssl to disable this message.")
401
 
      else:
402
 
        conf.fatal("Could not autodetect OpenSSL support. " +
403
 
                   "Make sure OpenSSL development packages are installed. " +
404
 
                   "Use configure --without-ssl to disable this message.")
405
 
  else:
406
 
    Options.options.use_openssl = conf.env["USE_OPENSSL"] = False
407
 
 
408
 
  conf.check(lib='util', libpath=['/usr/lib', '/usr/local/lib'],
409
 
             uselib_store='UTIL')
410
 
 
411
 
  # normalize DEST_CPU from --dest-cpu, DEST_CPU or built-in value
412
 
  if Options.options.dest_cpu and Options.options.dest_cpu:
413
 
    conf.env['DEST_CPU'] = canonical_cpu_type(Options.options.dest_cpu)
414
 
  elif 'DEST_CPU' in os.environ and os.environ['DEST_CPU']:
415
 
    conf.env['DEST_CPU'] = canonical_cpu_type(os.environ['DEST_CPU'])
416
 
  elif 'DEST_CPU' in conf.env and conf.env['DEST_CPU']:
417
 
    conf.env['DEST_CPU'] = canonical_cpu_type(conf.env['DEST_CPU'])
418
 
 
419
 
  have_librt = conf.check(lib='rt', uselib_store='RT')
420
 
 
421
 
  if sys.platform.startswith("sunos"):
422
 
    code =  """
423
 
      #include <ifaddrs.h>
424
 
      int main(void) {
425
 
        struct ifaddrs hello;
426
 
        return 0;
427
 
      }
428
 
    """
429
 
 
430
 
    if conf.check_cc(msg="Checking for ifaddrs on solaris", fragment=code):
431
 
      conf.env.append_value('CPPFLAGS',  '-DSUNOS_HAVE_IFADDRS')
432
 
 
433
 
    if not conf.check(lib='socket', uselib_store="SOCKET"):
434
 
      conf.fatal("Cannot find socket library")
435
 
    if not conf.check(lib='nsl', uselib_store="NSL"):
436
 
      conf.fatal("Cannot find nsl library")
437
 
    if not conf.check(lib='kstat', uselib_store="KSTAT"):
438
 
      conf.fatal("Cannot find kstat library")
439
 
 
440
 
  if conf.env['USE_SHARED_V8']:
441
 
    v8_includes = [];
442
 
    if o.shared_v8_includes: v8_includes.append(o.shared_v8_includes);
443
 
 
444
 
    v8_libpath = [];
445
 
    if o.shared_v8_libpath: v8_libpath.append(o.shared_v8_libpath);
446
 
 
447
 
    if not o.shared_v8_libname: o.shared_v8_libname = 'v8'
448
 
 
449
 
    if not conf.check_cxx(lib=o.shared_v8_libname, header_name='v8.h',
450
 
                          uselib_store='V8',
451
 
                          includes=v8_includes,
452
 
                          libpath=v8_libpath):
453
 
      conf.fatal("Cannot find v8")
454
 
 
455
 
    if o.debug:
456
 
      if not conf.check_cxx(lib=o.shared_v8_libname, header_name='v8.h',
457
 
                            uselib_store='V8_G',
458
 
                            includes=v8_includes,
459
 
                            libpath=v8_libpath):
460
 
        conf.fatal("Cannot find v8_g")
461
 
 
462
 
  if conf.env["USE_SHARED_ZLIB"] and not sys.platform.startswith("win32"):
463
 
    conf.env.append_value("LINKFLAGS", "-lz")
464
 
 
465
 
  if conf.env['USE_SHARED_CARES']:
466
 
    cares_includes = [];
467
 
    if o.shared_cares_includes: cares_includes.append(o.shared_cares_includes);
468
 
    cares_libpath = [];
469
 
    if o.shared_cares_libpath: cares_libpath.append(o.shared_cares_libpath);
470
 
    if not conf.check_cxx(lib='cares',
471
 
                          header_name='ares.h',
472
 
                          uselib_store='CARES',
473
 
                          includes=cares_includes,
474
 
                          libpath=cares_libpath):
475
 
      conf.fatal("Cannot find c-ares")
476
 
 
477
 
 
478
 
  if conf.env['USE_SHARED_LIBEV']:
479
 
    libev_includes = [];
480
 
    if o.shared_libev_includes: libev_includes.append(o.shared_libev_includes);
481
 
    libev_libpath = [];
482
 
    if o.shared_libev_libpath: libev_libpath.append(o.shared_libev_libpath);
483
 
    if not conf.check_cxx(lib='ev', header_name='ev.h',
484
 
                          uselib_store='EV',
485
 
                          includes=libev_includes,
486
 
                          libpath=libev_libpath):
487
 
      conf.fatal("Cannot find libev")
488
 
  else:
489
 
    conf.sub_config('deps/libev')
490
 
 
491
 
  conf.define("HAVE_CONFIG_H", 1)
492
 
 
493
 
  if sys.platform.startswith("sunos"):
494
 
    conf.env.append_value ('CCFLAGS', '-threads')
495
 
    conf.env.append_value ('CXXFLAGS', '-threads')
496
 
    #conf.env.append_value ('LINKFLAGS', ' -threads')
497
 
  elif not sys.platform.startswith("win32"):
498
 
    threadflags='-pthread'
499
 
    conf.env.append_value ('CCFLAGS', threadflags)
500
 
    conf.env.append_value ('CXXFLAGS', threadflags)
501
 
    conf.env.append_value ('LINKFLAGS', threadflags)
502
 
 
503
 
  if sys.platform.startswith('darwin'):
504
 
    # used by platform_darwin_*.cc
505
 
    conf.env.append_value('LINKFLAGS', ['-framework','Carbon'])
506
 
 
507
 
  flags = arch_cflags(conf)
508
 
  conf.env.append_value('CCFLAGS', flags)
509
 
  conf.env.append_value('CXXFLAGS', flags)
510
 
  conf.env.append_value('LINKFLAGS', flags)
511
 
 
512
 
  # LFS
513
 
  conf.env.append_value('CPPFLAGS',  '-D_LARGEFILE_SOURCE')
514
 
  conf.env.append_value('CPPFLAGS',  '-D_FILE_OFFSET_BITS=64')
515
 
 
516
 
  if sys.platform.startswith('darwin'):
517
 
    conf.env.append_value('CPPFLAGS', '-D_DARWIN_USE_64_BIT_INODE=1')
518
 
 
519
 
  # Makes select on windows support more than 64 FDs
520
 
  if sys.platform.startswith("win32"):
521
 
    conf.env.append_value('CPPFLAGS', '-DFD_SETSIZE=1024');
522
 
 
523
 
  ## needed for node_file.cc fdatasync
524
 
  ## Strangely on OSX 10.6 the g++ doesn't see fdatasync but gcc does?
525
 
  code =  """
526
 
    #include <unistd.h>
527
 
    int main(void)
528
 
    {
529
 
       int fd = 0;
530
 
       fdatasync (fd);
531
 
       return 0;
532
 
    }
533
 
  """
534
 
  if conf.check_cxx(msg="Checking for fdatasync(2) with c++", fragment=code):
535
 
    conf.env.append_value('CPPFLAGS', '-DHAVE_FDATASYNC=1')
536
 
  else:
537
 
    conf.env.append_value('CPPFLAGS', '-DHAVE_FDATASYNC=0')
538
 
 
539
 
  # arch
540
 
  conf.env.append_value('CPPFLAGS', '-DARCH="' + conf.env['DEST_CPU'] + '"')
541
 
 
542
 
  # platform
543
 
  conf.env.append_value('CPPFLAGS', '-DPLATFORM="' + conf.env['DEST_OS'] + '"')
544
 
 
545
 
  # posix?
546
 
  if not sys.platform.startswith('win'):
547
 
    conf.env.append_value('CPPFLAGS', '-D__POSIX__=1')
548
 
 
549
 
  platform_file = "src/platform_%s.cc" % conf.env['DEST_OS']
550
 
  if os.path.exists(join(cwd, platform_file)):
551
 
    Options.options.platform_file = True
552
 
    conf.env["PLATFORM_FILE"] = platform_file
553
 
  else:
554
 
    Options.options.platform_file = False
555
 
    conf.env["PLATFORM_FILE"] = "src/platform_none.cc"
556
 
 
557
 
  if conf.env['USE_PROFILING'] == True:
558
 
    conf.env.append_value('CPPFLAGS', '-pg')
559
 
    conf.env.append_value('LINKFLAGS', '-pg')
560
 
 
561
 
  if sys.platform.startswith("win32"):
562
 
    conf.env.append_value('LIB', 'psapi')
563
 
    conf.env.append_value('LIB', 'winmm')
564
 
    # This enforces ws2_32 to be linked after crypto, otherwise the linker
565
 
    # will run into undefined references from libcrypto.a
566
 
    if not Options.options.use_openssl:
567
 
      conf.env.append_value('LIB', 'ws2_32')
568
 
 
569
 
  conf.env.append_value('CPPFLAGS', '-Wno-unused-parameter');
570
 
  conf.env.append_value('CPPFLAGS', '-D_FORTIFY_SOURCE=2');
571
 
 
572
 
  # Split off debug variant before adding variant specific defines
573
 
  debug_env = conf.env.copy()
574
 
  conf.set_env_name('Debug', debug_env)
575
 
 
576
 
  # Configure debug variant
577
 
  conf.setenv('Debug')
578
 
  debug_env.set_variant('Debug')
579
 
  debug_env.append_value('CPPFLAGS', '-DDEBUG')
580
 
  debug_compile_flags = ['-g', '-O0', '-Wall', '-Wextra']
581
 
  debug_env.append_value('CCFLAGS', debug_compile_flags)
582
 
  debug_env.append_value('CXXFLAGS', debug_compile_flags)
583
 
  conf.write_config_header("config.h")
584
 
 
585
 
  # Configure default variant
586
 
  conf.setenv('Release')
587
 
  default_compile_flags = ['-g', '-O3']
588
 
  conf.env.append_value('CCFLAGS', default_compile_flags)
589
 
  conf.env.append_value('CXXFLAGS', default_compile_flags)
590
 
  conf.write_config_header("config.h")
591
 
 
592
 
 
593
 
def v8_cmd(bld, variant):
594
 
  scons = join(cwd, 'tools/scons/scons.py')
595
 
  deps_src = join(bld.path.abspath(),"deps")
596
 
  v8dir_src = join(deps_src,"v8")
597
 
 
598
 
  # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
599
 
  # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
600
 
  # cannot see symbols in the executable which are hidden, even if the
601
 
  # executable is statically linked together...
602
 
 
603
 
  # XXX Change this when v8 defaults x86_64 to native builds
604
 
  # Possible values are (arm, ia32, x64, mips).
605
 
  arch = ""
606
 
  if bld.env['DEST_CPU']:
607
 
    arch = "arch="+bld.env['DEST_CPU']
608
 
 
609
 
  toolchain = "gcc"
610
 
 
611
 
  if variant == "Release":
612
 
    mode = "release"
613
 
  else:
614
 
    mode = "debug"
615
 
 
616
 
  if bld.env["SNAPSHOT_V8"]:
617
 
    snapshot = "snapshot=on"
618
 
  else:
619
 
    snapshot = ""
620
 
 
621
 
  cmd_R = sys.executable + ' "%s" -j %d -C "%s" -Y "%s" visibility=default mode=%s %s toolchain=%s library=static %s'
622
 
 
623
 
  cmd = cmd_R % ( scons
624
 
                , Options.options.jobs
625
 
                , safe_path(bld.srcnode.abspath(bld.env_of_name(variant)))
626
 
                , safe_path(v8dir_src)
627
 
                , mode
628
 
                , arch
629
 
                , toolchain
630
 
                , snapshot
631
 
                )
632
 
 
633
 
  if bld.env["USE_GDBJIT"]:
634
 
    cmd += ' gdbjit=on '
635
 
 
636
 
  if sys.platform.startswith("sunos"):
637
 
    cmd += ' toolchain=gcc strictaliasing=off'
638
 
 
639
 
 
640
 
 
641
 
  return ("echo '%s' && " % cmd) + cmd
642
 
 
643
 
 
644
 
def build_v8(bld):
645
 
  v8 = bld.new_task_gen(
646
 
    source        = 'deps/v8/SConstruct '
647
 
                    + bld.path.ant_glob('v8/include/*')
648
 
                    + bld.path.ant_glob('v8/src/*'),
649
 
    target        = bld.env["staticlib_PATTERN"] % "v8",
650
 
    rule          = v8_cmd(bld, "Release"),
651
 
    before        = "cxx",
652
 
    install_path  = None)
653
 
 
654
 
  v8.env.env = dict(os.environ)
655
 
  v8.env.env['CC'] = sh_escape(bld.env['CC'][0])
656
 
  v8.env.env['CXX'] = sh_escape(bld.env['CXX'][0])
657
 
 
658
 
  v8.uselib = "EXECINFO"
659
 
  bld.env["CPPPATH_V8"] = "deps/v8/include"
660
 
  t = join(bld.srcnode.abspath(bld.env_of_name("Release")), v8.target)
661
 
  bld.env_of_name('Release').append_value("LINKFLAGS_V8", t)
662
 
 
663
 
  ### v8 debug
664
 
  if bld.env["USE_DEBUG"]:
665
 
    v8_debug = v8.clone("Debug")
666
 
    v8_debug.rule   = v8_cmd(bld, "Debug")
667
 
    v8_debug.target = bld.env["staticlib_PATTERN"] % "v8_g"
668
 
    v8_debug.uselib = "EXECINFO"
669
 
    bld.env["CPPPATH_V8_G"] = "deps/v8/include"
670
 
    t = join(bld.srcnode.abspath(bld.env_of_name("Debug")), v8_debug.target)
671
 
    bld.env_of_name('Debug').append_value("LINKFLAGS_V8_G", t)
672
 
 
673
 
  bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
674
 
 
675
 
def sh_escape(s):
676
 
  if sys.platform.startswith('win32'):
677
 
    return '"' + s + '"'
678
 
  else:
679
 
    return s.replace("\\", "\\\\").replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
680
 
 
681
 
def uv_cmd(bld, variant):
682
 
  srcdeps = join(bld.path.abspath(), "deps")
683
 
  srcdir = join(srcdeps, "uv")
684
 
  blddir = bld.srcnode.abspath(bld.env_of_name(variant)) + '/deps/uv'
685
 
  #
686
 
  # FIXME This is awful! We're copying the entire source directory into the
687
 
  # build directory before each compile. This could be much improved by
688
 
  # modifying libuv's build to send object files to a separate directory.
689
 
  #
690
 
  cmd = 'cp -r ' + sh_escape(srcdir)  + '/* ' + sh_escape(blddir)
691
 
  if not sys.platform.startswith('win32'):
692
 
    make = ('if [ -z "$NODE_MAKE" ]; then NODE_MAKE=make; fi; '
693
 
            '$NODE_MAKE -C ' + sh_escape(blddir))
694
 
    flags = arch_cflags(bld)
695
 
    if flags: make += ' CFLAGS=\'%s\'' % ' '.join(flags) # don't escape
696
 
  else:
697
 
    make = 'make -C ' + sh_escape(blddir)
698
 
  return '%s && (%s clean) && (%s all)' % (cmd, make, make)
699
 
 
700
 
 
701
 
def build_uv(bld):
702
 
  uv = bld.new_task_gen(
703
 
    name = 'uv',
704
 
    source = 'deps/uv/include/uv.h',
705
 
    target = 'deps/uv/uv.a',
706
 
    before = "cxx",
707
 
    rule = uv_cmd(bld, 'Release')
708
 
  )
709
 
 
710
 
  uv.env.env = dict(os.environ)
711
 
  uv.env.env['CC'] = sh_escape(bld.env['CC'][0])
712
 
  uv.env.env['CXX'] = sh_escape(bld.env['CXX'][0])
713
 
 
714
 
  t = join(bld.srcnode.abspath(bld.env_of_name("Release")), uv.target)
715
 
  bld.env_of_name('Release').append_value("LINKFLAGS_UV", t)
716
 
 
717
 
  if bld.env["USE_DEBUG"]:
718
 
    uv_debug = uv.clone("Debug")
719
 
    uv_debug.rule = uv_cmd(bld, 'Debug')
720
 
    uv_debug.env.env = dict(os.environ)
721
 
 
722
 
    t = join(bld.srcnode.abspath(bld.env_of_name("Debug")), uv_debug.target)
723
 
    bld.env_of_name('Debug').append_value("LINKFLAGS_UV", t)
724
 
 
725
 
  bld.install_files('${PREFIX}/include/node/', 'deps/uv/include/*.h')
726
 
  bld.install_files('${PREFIX}/include/node/uv-private', 'deps/uv/include/uv-private/*.h')
727
 
  bld.install_files('${PREFIX}/include/node/ev', 'deps/uv/src/ev/*.h')
728
 
 
729
 
 
730
 
def build(bld):
731
 
  ## This snippet is to show full commands as WAF executes
732
 
  import Build
733
 
  old = Build.BuildContext.exec_command
734
 
  def exec_command(self, cmd, **kw):
735
 
    if isinstance(cmd, list): print(" ".join(cmd))
736
 
    return old(self, cmd, **kw)
737
 
  Build.BuildContext.exec_command = exec_command
738
 
 
739
 
  Options.options.jobs=jobs
740
 
  product_type = Options.options.product_type
741
 
  product_type_is_lib = product_type != 'program'
742
 
 
743
 
  print "DEST_OS: " + bld.env['DEST_OS']
744
 
  print "DEST_CPU: " + bld.env['DEST_CPU']
745
 
  print "Parallel Jobs: " + str(Options.options.jobs)
746
 
  print "Product type: " + product_type
747
 
 
748
 
  build_uv(bld)
749
 
 
750
 
  if not bld.env['USE_SHARED_V8']: build_v8(bld)
751
 
 
752
 
 
753
 
  ### http_parser
754
 
  http_parser = bld.new_task_gen("cc")
755
 
  http_parser.source = "deps/http_parser/http_parser.c"
756
 
  http_parser.includes = "deps/http_parser/"
757
 
  http_parser.name = "http_parser"
758
 
  http_parser.target = "http_parser"
759
 
  http_parser.install_path = None
760
 
  if bld.env["USE_DEBUG"]:
761
 
    http_parser.clone("Debug")
762
 
  if product_type_is_lib:
763
 
    http_parser.ccflags = '-fPIC'
764
 
 
765
 
  ### src/native.cc
766
 
  def make_macros(loc, content):
767
 
    f = open(loc, 'a')
768
 
    f.write(content)
769
 
    f.close
770
 
 
771
 
  macros_loc_debug   = join(
772
 
     bld.srcnode.abspath(bld.env_of_name("Debug")),
773
 
     "macros.py"
774
 
  )
775
 
 
776
 
  macros_loc_default = join(
777
 
    bld.srcnode.abspath(bld.env_of_name("Release")),
778
 
    "macros.py"
779
 
  )
780
 
 
781
 
  ### We need to truncate the macros.py file
782
 
  f = open(macros_loc_debug, 'w')
783
 
  f.close
784
 
  f = open(macros_loc_default, 'w')
785
 
  f.close
786
 
 
787
 
  make_macros(macros_loc_debug, "")  # leave debug(x) as is in debug build
788
 
  # replace debug(x) with nothing in release build
789
 
  make_macros(macros_loc_default, "macro debug(x) = ;\n")
790
 
  make_macros(macros_loc_default, "macro assert(x) = ;\n")
791
 
 
792
 
  if not bld.env["USE_DTRACE"]:
793
 
    probes = [
794
 
      'DTRACE_HTTP_CLIENT_REQUEST',
795
 
      'DTRACE_HTTP_CLIENT_RESPONSE',
796
 
      'DTRACE_HTTP_SERVER_REQUEST',
797
 
      'DTRACE_HTTP_SERVER_RESPONSE',
798
 
      'DTRACE_NET_SERVER_CONNECTION',
799
 
      'DTRACE_NET_STREAM_END',
800
 
      'DTRACE_NET_SOCKET_READ',
801
 
      'DTRACE_NET_SOCKET_WRITE'
802
 
    ]
803
 
 
804
 
    for probe in probes:
805
 
      make_macros(macros_loc_default, "macro %s(x) = ;\n" % probe)
806
 
      make_macros(macros_loc_debug, "macro %s(x) = ;\n" % probe)
807
 
 
808
 
  def javascript_in_c(task):
809
 
    env = task.env
810
 
    source = map(lambda x: x.srcpath(env), task.inputs)
811
 
    targets = map(lambda x: x.srcpath(env), task.outputs)
812
 
    source.append(macros_loc_default)
813
 
    js2c.JS2C(source, targets)
814
 
 
815
 
  def javascript_in_c_debug(task):
816
 
    env = task.env
817
 
    source = map(lambda x: x.srcpath(env), task.inputs)
818
 
    targets = map(lambda x: x.srcpath(env), task.outputs)
819
 
    source.append(macros_loc_debug)
820
 
    js2c.JS2C(source, targets)
821
 
 
822
 
  native_cc = bld.new_task_gen(
823
 
    source='src/node.js ' + bld.path.ant_glob('lib/*.js'),
824
 
    target="src/node_natives.h",
825
 
    before="cxx",
826
 
    install_path=None
827
 
  )
828
 
 
829
 
  # Add the rule /after/ cloning the debug
830
 
  # This is a work around for an error had in python 2.4.3 (I'll paste the
831
 
  # error that was had into the git commit meessage. git-blame to find out
832
 
  # where.)
833
 
  if bld.env["USE_DEBUG"]:
834
 
    native_cc_debug = native_cc.clone("Debug")
835
 
    native_cc_debug.rule = javascript_in_c_debug
836
 
 
837
 
  native_cc.rule = javascript_in_c_debug
838
 
 
839
 
  if bld.env["USE_DTRACE"]:
840
 
    dtrace_usdt = bld.new_task_gen(
841
 
      name   = "dtrace_usdt",
842
 
      source = "src/node_provider.d",
843
 
      target = "src/node_provider.h",
844
 
      rule   = "%s -x nolibs -h -o ${TGT} -s ${SRC}" % (bld.env.DTRACE),
845
 
      before = "cxx",
846
 
    )
847
 
 
848
 
    if bld.env["USE_DEBUG"]:
849
 
      dtrace_usdt_g = dtrace_usdt.clone("Debug")
850
 
 
851
 
    bld.install_files('${LIBDIR}/dtrace', 'src/node.d')
852
 
 
853
 
    if sys.platform.startswith("sunos"):
854
 
      #
855
 
      # The USDT DTrace provider works slightly differently on Solaris than on
856
 
      # the Mac; on Solaris, any objects that have USDT DTrace probes must be
857
 
      # post-processed with the DTrace command.  (This is not true on the
858
 
      # Mac, which has first-class linker support for USDT probes.)  On
859
 
      # Solaris, we must therefore post-process our object files.  Waf doesn't
860
 
      # seem to really have a notion for this, so we inject a task after
861
 
      # compiling and before linking, and then find all of the node object
862
 
      # files and shuck them off to dtrace (which will modify them in place
863
 
      # as appropriate).
864
 
      #
865
 
      def dtrace_postprocess(task):
866
 
        abspath = bld.srcnode.abspath(bld.env_of_name(task.env.variant()))
867
 
        objs = glob.glob(abspath + 'src/*.o')
868
 
        source = task.inputs[0].srcpath(task.env)
869
 
        target = task.outputs[0].srcpath(task.env)
870
 
        cmd = '%s -G -x nolibs -s %s -o %s %s' % (task.env.DTRACE,
871
 
                                                  source,
872
 
                                                  target,
873
 
                                                  ' '.join(objs))
874
 
        Utils.exec_command(cmd)
875
 
 
876
 
      #
877
 
      # ustack helpers do not currently work on MacOS.  We currently only
878
 
      # support 32-bit x86.
879
 
      #
880
 
      def dtrace_do_ustack(task):
881
 
        abspath = bld.srcnode.abspath(bld.env_of_name(task.env.variant()))
882
 
        source = task.inputs[0].srcpath(task.env)
883
 
        target = task.outputs[0].srcpath(task.env)
884
 
        cmd = '%s -32 -I../src -C -G -s %s -o %s' % (task.env.DTRACE, source, target)
885
 
        Utils.exec_command(cmd)
886
 
 
887
 
      dtrace_ustack = bld.new_task_gen(
888
 
        name = "dtrace_ustack-postprocess",
889
 
        source = "src/v8ustack.d",
890
 
        target = "v8ustack.o",
891
 
        always = True,
892
 
        before = "cxx_link",
893
 
        after = "cxx",
894
 
        rule = dtrace_do_ustack
895
 
      )
896
 
 
897
 
      dtracepost = bld.new_task_gen(
898
 
        name   = "dtrace_usdt-postprocess",
899
 
        source = "src/node_provider.d",
900
 
        target = "node_provider.o",
901
 
        always = True,
902
 
        before = "cxx_link",
903
 
        after  = "cxx",
904
 
        rule = dtrace_postprocess
905
 
      )
906
 
 
907
 
      t = join(bld.srcnode.abspath(bld.env_of_name("Release")), dtracepost.target)
908
 
      bld.env_of_name('Release').append_value('LINKFLAGS', t)
909
 
 
910
 
      t = join(bld.srcnode.abspath(bld.env_of_name("Release")), dtrace_ustack.target)
911
 
      bld.env_of_name('Release').append_value('LINKFLAGS', t)
912
 
 
913
 
      #
914
 
      # Note that for the same (mysterious) issue outlined above with respect
915
 
      # to assigning the rule to native_cc/native_cc_debug, we must apply the
916
 
      # rule to dtracepost/dtracepost_g only after they have been cloned.  We
917
 
      # also must put node_provider.o on the link line, but because we
918
 
      # (apparently?) lack LINKFLAGS in debug, we (shamelessly) stowaway on
919
 
      # LINKFLAGS_V8_G.
920
 
      #
921
 
      if bld.env["USE_DEBUG"]:
922
 
        dtracepost_g = dtracepost.clone("Debug")
923
 
        dtracepost_g.rule = dtrace_postprocess
924
 
        t = join(bld.srcnode.abspath(bld.env_of_name("Debug")), dtracepost.target)
925
 
        bld.env_of_name("Debug").append_value('LINKFLAGS_V8_G', t)
926
 
 
927
 
 
928
 
  ### node lib
929
 
  node = bld.new_task_gen("cxx", product_type)
930
 
  node.name         = "node"
931
 
  node.target       = "node"
932
 
  node.uselib = 'RT OPENSSL ZLIB CARES EV EXECINFO DL KVM SOCKET NSL KSTAT UTIL OPROFILE'
933
 
  node.add_objects = 'http_parser'
934
 
  if product_type_is_lib:
935
 
    node.install_path = '${LIBDIR}'
936
 
  else:
937
 
    node.install_path = '${PREFIX}/bin'
938
 
  node.chmod = 0755
939
 
  node.source = """
940
 
    src/node.cc
941
 
    src/node_buffer.cc
942
 
    src/node_javascript.cc
943
 
    src/node_extensions.cc
944
 
    src/node_http_parser.cc
945
 
    src/node_constants.cc
946
 
    src/node_file.cc
947
 
    src/node_script.cc
948
 
    src/node_os.cc
949
 
    src/node_dtrace.cc
950
 
    src/node_string.cc
951
 
    src/node_zlib.cc
952
 
    src/timer_wrap.cc
953
 
    src/handle_wrap.cc
954
 
    src/stream_wrap.cc
955
 
    src/tcp_wrap.cc
956
 
    src/udp_wrap.cc
957
 
    src/pipe_wrap.cc
958
 
    src/cares_wrap.cc
959
 
    src/tty_wrap.cc
960
 
    src/fs_event_wrap.cc
961
 
    src/process_wrap.cc
962
 
    src/v8_typed_array.cc
963
 
  """
964
 
 
965
 
  if bld.env["USE_DTRACE"]:
966
 
    node.source += " src/node_dtrace.cc "
967
 
 
968
 
  if not sys.platform.startswith("win32"):
969
 
    node.source += " src/node_signal_watcher.cc "
970
 
    node.source += " src/node_stat_watcher.cc "
971
 
    node.source += " src/node_io_watcher.cc "
972
 
 
973
 
  node.source += bld.env["PLATFORM_FILE"]
974
 
  if not product_type_is_lib:
975
 
    node.source = 'src/node_main.cc '+node.source
976
 
 
977
 
  if bld.env["USE_OPENSSL"]: node.source += " src/node_crypto.cc "
978
 
 
979
 
  node.includes = """
980
 
    src/
981
 
    deps/http_parser
982
 
    deps/uv/include
983
 
    deps/uv/src/ev
984
 
  """
985
 
 
986
 
  if not bld.env["USE_SHARED_V8"]: node.includes += ' deps/v8/include '
987
 
 
988
 
  if os.environ.has_key('RPATH'):
989
 
    node.rpath = os.environ['RPATH']
990
 
 
991
 
  if (sys.platform.startswith("win32")):
992
 
    # Static libgcc
993
 
    bld.env.append_value('LINKFLAGS', '-static-libgcc')
994
 
    bld.env.append_value('LINKFLAGS', '-static-libstdc++')
995
 
 
996
 
  def subflags(program):
997
 
    x = { 'CCFLAGS'   : " ".join(program.env["CCFLAGS"]).replace('"', '\\"')
998
 
        , 'CPPFLAGS'  : " ".join(program.env["CPPFLAGS"]).replace('"', '\\"')
999
 
        , 'LIBFLAGS'  : " ".join(program.env["LIBFLAGS"]).replace('"', '\\"')
1000
 
        , 'PREFIX'    : safe_path(program.env["PREFIX"])
1001
 
        , 'VERSION'   : get_node_version()
1002
 
        }
1003
 
    return x
1004
 
 
1005
 
  # process file.pc.in -> file.pc
1006
 
 
1007
 
  node_conf = bld.new_task_gen('subst', before="cxx")
1008
 
  node_conf.source = 'src/node_config.h.in'
1009
 
  node_conf.target = 'src/node_config.h'
1010
 
  node_conf.dict = subflags(node)
1011
 
  node_conf.install_path = '${PREFIX}/include/node'
1012
 
 
1013
 
  if bld.env["USE_DEBUG"]:
1014
 
    node_g = node.clone("Debug")
1015
 
    node_g.target = "node"
1016
 
    node_g.uselib += ' V8_G UV '
1017
 
    node_g.install_path = None
1018
 
 
1019
 
    node_conf_g = node_conf.clone("Debug")
1020
 
    node_conf_g.dict = subflags(node_g)
1021
 
    node_conf_g.install_path = None
1022
 
 
1023
 
  # After creating the debug clone, append the V8 dep
1024
 
  node.uselib += ' V8 UV '
1025
 
 
1026
 
  bld.install_files('${PREFIX}/include/node/', """
1027
 
    config.h
1028
 
    src/node.h
1029
 
    src/node_object_wrap.h
1030
 
    src/node_buffer.h
1031
 
    src/node_version.h
1032
 
  """)
1033
 
 
1034
 
  # Only install the man page if it exists.
1035
 
  # Do 'make doc install' to build and install it.
1036
 
  if os.path.exists('doc/node.1'):
1037
 
    prefix = 'bsd' in sys.platform and '${PREFIX}' or '${PREFIX}/share'
1038
 
    bld.install_files(prefix + '/man/man1/', 'doc/node.1')
1039
 
 
1040
 
  bld.install_files('${PREFIX}/bin/', 'tools/node-waf', chmod=0755)
1041
 
  bld.install_files('${LIBDIR}/node/wafadmin', 'tools/wafadmin/*.py')
1042
 
  bld.install_files('${LIBDIR}/node/wafadmin/Tools', 'tools/wafadmin/Tools/*.py')
1043
 
 
1044
 
  if bld.env['USE_NPM']:
1045
 
    install_npm(bld)
1046
 
 
1047
 
def install_npm(bld):
1048
 
  start_dir = bld.path.find_dir('deps/npm')
1049
 
  # The chmod=-1 is a Node hack. We changed WAF so that when chmod was set to
1050
 
  # -1 that the same permission in this tree are used. Necessary to get
1051
 
  # npm-cli.js to be executable without having to list every file in npm.
1052
 
  bld.install_files('${LIBDIR}/node_modules/npm',
1053
 
                    start_dir.ant_glob('**/*'),
1054
 
                    cwd=start_dir,
1055
 
                    relative_trick=True,
1056
 
                    chmod=-1)
1057
 
  bld.symlink_as('${PREFIX}/bin/npm',
1058
 
                 '../lib/node_modules/npm/bin/npm-cli.js')
1059
 
 
1060
 
def shutdown():
1061
 
  Options.options.debug
1062
 
  # HACK to get binding.node out of build directory.
1063
 
  # better way to do this?
1064
 
  if Options.commands['configure']:
1065
 
    if not Options.options.use_openssl:
1066
 
      print "WARNING WARNING WARNING"
1067
 
      print "OpenSSL not found. Will compile Node without crypto support!"
1068
 
 
1069
 
    if not Options.options.platform_file:
1070
 
      print "WARNING: Platform not fully supported. Using src/platform_none.cc"
1071
 
 
1072
 
  elif not Options.commands['clean']:
1073
 
    if sys.platform.startswith("win32"):
1074
 
      if os.path.exists('out/Release/node.exe'):
1075
 
        os.system('cp out/Release/node.exe .')
1076
 
      if os.path.exists('out/Debug/node.exe'):
1077
 
        os.system('cp out/Debug/node.exe node_g.exe')
1078
 
    else:
1079
 
      if os.path.exists('out/Release/node') and not os.path.islink('node'):
1080
 
        os.symlink('out/Release/node', 'node')
1081
 
      if os.path.exists('out/Debug/node') and not os.path.islink('node_g'):
1082
 
        os.symlink('out/Debug/node', 'node_g')
1083
 
  else:
1084
 
    if sys.platform.startswith("win32"):
1085
 
      if os.path.exists('node.exe'): os.unlink('node.exe')
1086
 
      if os.path.exists('node_g.exe'): os.unlink('node_g.exe')
1087
 
    else:
1088
 
      if os.path.exists('node'): os.unlink('node')
1089
 
      if os.path.exists('node_g'): os.unlink('node_g')