The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / configure @ 0afdfae0

History | View | Annotate | Download (20.6 KB)

1
#!/usr/bin/env python
2
import optparse
3
import os
4
import pprint
5
import re
6
import shlex
7
import subprocess
8
import sys
9

    
10
CC = os.environ.get('CC', 'cc')
11

    
12
root_dir = os.path.dirname(__file__)
13
sys.path.insert(0, os.path.join(root_dir, 'tools', 'gyp', 'pylib'))
14
from gyp.common import GetFlavor
15

    
16
# parse our options
17
parser = optparse.OptionParser()
18

    
19
# Options should be in alphabetical order but keep --prefix at the top,
20
# that's arguably the one people will be looking for most.
21
parser.add_option('--prefix',
22
    action='store',
23
    dest='prefix',
24
    help='select the install prefix (defaults to /usr/local)')
25

    
26
parser.add_option('--debug',
27
    action='store_true',
28
    dest='debug',
29
    help='also build debug build')
30

    
31
parser.add_option('--dest-cpu',
32
    action='store',
33
    dest='dest_cpu',
34
    help='CPU architecture to build for. Valid values are: arm, ia32, x64')
35

    
36
parser.add_option('--dest-os',
37
    action='store',
38
    dest='dest_os',
39
    help='operating system to build for. Valid values are: '
40
         'win, mac, solaris, freebsd, openbsd, linux, android')
41

    
42
parser.add_option('--gdb',
43
    action='store_true',
44
    dest='gdb',
45
    help='add gdb support')
46

    
47
parser.add_option('--ninja',
48
    action='store_true',
49
    dest='use_ninja',
50
    help='generate files for the ninja build system')
51

    
52
parser.add_option('--no-ifaddrs',
53
    action='store_true',
54
    dest='no_ifaddrs',
55
    help='use on deprecated SunOS systems that do not support ifaddrs.h')
56

    
57
# deprecated
58
parser.add_option('--openssl-includes',
59
    action='store',
60
    dest='shared_openssl_includes',
61
    help=optparse.SUPPRESS_HELP)
62

    
63
# deprecated
64
parser.add_option('--openssl-libpath',
65
    action='store',
66
    dest='shared_openssl_libpath',
67
    help=optparse.SUPPRESS_HELP)
68

    
69
# deprecated
70
parser.add_option('--openssl-use-sys',
71
    action='store_true',
72
    dest='shared_openssl',
73
    help=optparse.SUPPRESS_HELP)
74

    
75
parser.add_option('--shared-cares',
76
    action='store_true',
77
    dest='shared_cares',
78
    help='link to a shared cares DLL instead of static linking')
79

    
80
parser.add_option('--shared-cares-includes',
81
    action='store',
82
    dest='shared_cares_includes',
83
    help='directory containing cares header files')
84

    
85
parser.add_option('--shared-cares-libname',
86
    action='store',
87
    dest='shared_cares_libname',
88
    help='alternative lib name to link to (default: \'cares\')')
89

    
90
parser.add_option('--shared-cares-libpath',
91
    action='store',
92
    dest='shared_cares_libpath',
93
    help='a directory to search for the shared cares DLL')
94

    
95
parser.add_option('--shared-http-parser',
96
    action='store_true',
97
    dest='shared_http_parser',
98
    help='link to a shared http_parser DLL instead of static linking')
99

    
100
parser.add_option('--shared-http-parser-includes',
101
    action='store',
102
    dest='shared_http_parser_includes',
103
    help='directory containing http_parser header files')
104

    
105
parser.add_option('--shared-http-parser-libname',
106
    action='store',
107
    dest='shared_http_parser_libname',
108
    help='alternative lib name to link to (default: \'http_parser\')')
109

    
110
parser.add_option('--shared-http-parser-libpath',
111
    action='store',
112
    dest='shared_http_parser_libpath',
113
    help='a directory to search for the shared http_parser DLL')
114

    
115
parser.add_option('--shared-libuv',
116
    action='store_true',
117
    dest='shared_libuv',
118
    help='link to a shared libuv DLL instead of static linking')
119

    
120
parser.add_option('--shared-libuv-includes',
121
    action='store',
122
    dest='shared_libuv_includes',
123
    help='directory containing libuv header files')
124

    
125
parser.add_option('--shared-libuv-libname',
126
    action='store',
127
    dest='shared_libuv_libname',
128
    help='alternative lib name to link to (default: \'uv\')')
129

    
130
parser.add_option('--shared-libuv-libpath',
131
    action='store',
132
    dest='shared_libuv_libpath',
133
    help='a directory to search for the shared libuv DLL')
134

    
135
parser.add_option('--shared-openssl',
136
    action='store_true',
137
    dest='shared_openssl',
138
    help='link to a shared OpenSSl DLL instead of static linking')
139

    
140
parser.add_option('--shared-openssl-includes',
141
    action='store',
142
    dest='shared_openssl_includes',
143
    help='directory containing OpenSSL header files')
144

    
145
parser.add_option('--shared-openssl-libname',
146
    action='store',
147
    dest='shared_openssl_libname',
148
    help='alternative lib name to link to (default: \'crypto,ssl\')')
149

    
150
parser.add_option('--shared-openssl-libpath',
151
    action='store',
152
    dest='shared_openssl_libpath',
153
    help='a directory to search for the shared OpenSSL DLLs')
154

    
155
parser.add_option('--shared-v8',
156
    action='store_true',
157
    dest='shared_v8',
158
    help='link to a shared V8 DLL instead of static linking')
159

    
160
parser.add_option('--shared-v8-includes',
161
    action='store',
162
    dest='shared_v8_includes',
163
    help='directory containing V8 header files')
164

    
165
parser.add_option('--shared-v8-libname',
166
    action='store',
167
    dest='shared_v8_libname',
168
    help='alternative lib name to link to (default: \'v8\')')
169

    
170
parser.add_option('--shared-v8-libpath',
171
    action='store',
172
    dest='shared_v8_libpath',
173
    help='a directory to search for the shared V8 DLL')
174

    
175
parser.add_option('--shared-zlib',
176
    action='store_true',
177
    dest='shared_zlib',
178
    help='link to a shared zlib DLL instead of static linking')
179

    
180
parser.add_option('--shared-zlib-includes',
181
    action='store',
182
    dest='shared_zlib_includes',
183
    help='directory containing zlib header files')
184

    
185
parser.add_option('--shared-zlib-libname',
186
    action='store',
187
    dest='shared_zlib_libname',
188
    help='alternative lib name to link to (default: \'z\')')
189

    
190
parser.add_option('--shared-zlib-libpath',
191
    action='store',
192
    dest='shared_zlib_libpath',
193
    help='a directory to search for the shared zlib DLL')
194

    
195
# TODO document when we've decided on what the tracing API and its options will
196
# look like
197
parser.add_option('--systemtap-includes',
198
    action='store',
199
    dest='systemtap_includes',
200
    help=optparse.SUPPRESS_HELP)
201

    
202
parser.add_option('--tag',
203
    action='store',
204
    dest='tag',
205
    help='custom build tag')
206

    
207
parser.add_option('--with-arm-float-abi',
208
    action='store',
209
    dest='arm_float_abi',
210
    help='specifies which floating-point ABI to use. Valid values are: '
211
         'soft, softfp, hard')
212

    
213
parser.add_option('--with-dtrace',
214
    action='store_true',
215
    dest='with_dtrace',
216
    help='build with DTrace (default is true on sunos)')
217

    
218
parser.add_option('--with-etw',
219
    action='store_true',
220
    dest='with_etw',
221
    help='build with ETW (default is true on Windows)')
222

    
223
parser.add_option('--with-icu-path',
224
    action='store',
225
    dest='with_icu_path',
226
    help='Path to icu.gyp (ICU i18n, Chromium version only.)')
227

    
228
parser.add_option('--with-perfctr',
229
    action='store_true',
230
    dest='with_perfctr',
231
    help='build with performance counters (default is true on Windows)')
232

    
233
parser.add_option('--with-sslv2',
234
    action='store_true',
235
    dest='with_sslv2',
236
    help='enable SSL v2')
237

    
238
parser.add_option('--without-dtrace',
239
    action='store_true',
240
    dest='without_dtrace',
241
    help='build without DTrace')
242

    
243
parser.add_option('--without-etw',
244
    action='store_true',
245
    dest='without_etw',
246
    help='build without ETW')
247

    
248
parser.add_option('--without-npm',
249
    action='store_true',
250
    dest='without_npm',
251
    help='don\'t install the bundled npm package manager')
252

    
253
parser.add_option('--without-perfctr',
254
    action='store_true',
255
    dest='without_perfctr',
256
    help='build without performance counters')
257

    
258
parser.add_option('--without-snapshot',
259
    action='store_true',
260
    dest='without_snapshot',
261
    help='build without snapshotting V8 libraries. You might want to set'
262
         ' this for cross-compiling. [Default: False]')
263

    
264
parser.add_option('--without-ssl',
265
    action='store_true',
266
    dest='without_ssl',
267
    help='build without SSL')
268

    
269
parser.add_option('--xcode',
270
    action='store_true',
271
    dest='use_xcode',
272
    help='generate build files for use with xcode')
273

    
274
(options, args) = parser.parse_args()
275

    
276

    
277
def b(value):
278
  """Returns the string 'true' if value is truthy, 'false' otherwise."""
279
  if value:
280
    return 'true'
281
  else:
282
    return 'false'
283

    
284

    
285
def pkg_config(pkg):
286
  cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
287
  libs = cmd.readline().strip()
288
  ret = cmd.close()
289
  if (ret): return None
290

    
291
  cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
292
  cflags = cmd.readline().strip()
293
  ret = cmd.close()
294
  if (ret): return None
295

    
296
  return (libs, cflags)
297

    
298

    
299
def cc_macros():
300
  """Checks predefined macros using the CC command."""
301

    
302
  try:
303
    p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
304
                         stdin=subprocess.PIPE,
305
                         stdout=subprocess.PIPE,
306
                         stderr=subprocess.PIPE)
307
  except OSError:
308
    print '''Node.js configure error: No acceptable C compiler found!
309

    
310
        Please make sure you have a C compiler installed on your system and/or
311
        consider adjusting the CC environment variable if you installed
312
        it in a non-standard prefix.
313
        '''
314
    sys.exit()
315

    
316
  p.stdin.write('\n')
317
  out = p.communicate()[0]
318

    
319
  out = str(out).split('\n')
320

    
321
  k = {}
322
  for line in out:
323
    lst = shlex.split(line)
324
    if len(lst) > 2:
325
      key = lst[1]
326
      val = lst[2]
327
      k[key] = val
328
  return k
329

    
330

    
331
def is_arch_armv7():
332
  """Check for ARMv7 instructions"""
333
  cc_macros_cache = cc_macros()
334
  return ('__ARM_ARCH_7__' in cc_macros_cache or
335
          '__ARM_ARCH_7A__' in cc_macros_cache or
336
          '__ARM_ARCH_7R__' in cc_macros_cache or
337
          '__ARM_ARCH_7M__' in cc_macros_cache)
338

    
339

    
340
def is_arm_neon():
341
  """Check for ARM NEON support"""
342
  return '__ARM_NEON__' in cc_macros()
343

    
344

    
345
def is_arm_hard_float_abi():
346
  """Check for hardfloat or softfloat eabi on ARM"""
347
  # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
348
  # the Floating Point ABI used (PCS stands for Procedure Call Standard).
349
  # We use these as well as a couple of other defines to statically determine
350
  # what FP ABI used.
351
  # GCC versions 4.4 and below don't support hard-fp.
352
  # GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
353
  # __ARM_PCS_VFP.
354

    
355
  if compiler_version() >= (4, 6, 0):
356
    return '__ARM_PCS_VFP' in cc_macros()
357
  elif compiler_version() < (4, 5, 0):
358
    return False
359
  elif '__ARM_PCS_VFP' in cc_macros():
360
    return True
361
  elif ('__ARM_PCS' in cc_macros() or
362
        '__SOFTFP' in cc_macros() or
363
        not '__VFP_FP__' in cc_macros()):
364
    return False
365
  else:
366
    print '''Node.js configure error: Your version of GCC does not report
367
      the Floating-Point ABI to compile for your hardware
368

    
369
      Please manually specify which floating-point ABI to use with the
370
      --with-arm-float-abi option.
371
      '''
372
    sys.exit()
373

    
374

    
375
def host_arch_cc():
376
  """Host architecture check using the CC command."""
377

    
378
  k = cc_macros()
379

    
380
  matchup = {
381
    '__x86_64__'  : 'x64',
382
    '__i386__'    : 'ia32',
383
    '__arm__'     : 'arm',
384
    '__mips__'    : 'mips',
385
  }
386

    
387
  rtn = 'ia32' # default
388

    
389
  for i in matchup:
390
    if i in k and k[i] != '0':
391
      rtn = matchup[i]
392
      break
393

    
394
  return rtn
395

    
396

    
397
def host_arch_win():
398
  """Host architecture check using environ vars (better way to do this?)"""
399

    
400
  arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')
401

    
402
  matchup = {
403
    'AMD64'  : 'x64',
404
    'x86'    : 'ia32',
405
    'arm'    : 'arm',
406
    'mips'   : 'mips',
407
  }
408

    
409
  return matchup.get(arch, 'ia32')
410

    
411

    
412
def compiler_version():
413
  try:
414
    proc = subprocess.Popen(shlex.split(CC) + ['--version'],
415
                            stdout=subprocess.PIPE)
416
  except WindowsError:
417
    return (0, False)
418

    
419
  is_clang = 'clang' in proc.communicate()[0].split('\n')[0]
420

    
421
  proc = subprocess.Popen(shlex.split(CC) + ['-dumpversion'],
422
                          stdout=subprocess.PIPE)
423
  version = tuple(map(int, proc.communicate()[0].split('.')))
424

    
425
  return (version, is_clang)
426

    
427

    
428
def configure_arm(o):
429
  if options.arm_float_abi:
430
    arm_float_abi = options.arm_float_abi
431
  elif is_arm_hard_float_abi():
432
    arm_float_abi = 'hard'
433
  else:
434
    arm_float_abi = 'default'
435
  o['variables']['armv7'] = int(is_arch_armv7())
436
  o['variables']['arm_fpu'] = 'vfpv3'  # V8 3.18 no longer supports VFP2.
437
  o['variables']['arm_neon'] = int(is_arm_neon())
438
  o['variables']['arm_thumb'] = 0      # -marm
439
  o['variables']['arm_float_abi'] = arm_float_abi
440

    
441

    
442
def configure_node(o):
443
  if options.dest_os == 'android':
444
    o['variables']['OS'] = 'android'
445
  o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
446
  o['variables']['node_install_npm'] = b(not options.without_npm)
447
  o['default_configuration'] = 'Debug' if options.debug else 'Release'
448

    
449
  host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
450
  target_arch = options.dest_cpu or host_arch
451
  o['variables']['host_arch'] = host_arch
452
  o['variables']['target_arch'] = target_arch
453

    
454
  if target_arch == 'arm':
455
    configure_arm(o)
456

    
457
  cc_version, is_clang = compiler_version()
458
  o['variables']['clang'] = 1 if is_clang else 0
459

    
460
  if not is_clang and cc_version != 0:
461
    o['variables']['gcc_version'] = 10 * cc_version[0] + cc_version[1]
462

    
463
  # clang has always supported -fvisibility=hidden, right?
464
  if not is_clang and cc_version < (4,0,0):
465
    o['variables']['visibility'] = ''
466

    
467
  if flavor in ('solaris', 'mac', 'linux'):
468
    use_dtrace = not options.without_dtrace
469
    # Don't enable by default on linux, it needs the sdt-devel package.
470
    if flavor == 'linux':
471
      if options.systemtap_includes:
472
        o['include_dirs'] += [options.systemtap_includes]
473
      use_dtrace = options.with_dtrace
474
    o['variables']['node_use_dtrace'] = b(use_dtrace)
475
    o['variables']['uv_use_dtrace'] = b(use_dtrace)
476
    o['variables']['uv_parent_path'] = '/deps/uv/'
477
  elif options.with_dtrace:
478
    raise Exception(
479
       'DTrace is currently only supported on SunOS, MacOS or Linux systems.')
480
  else:
481
    o['variables']['node_use_dtrace'] = 'false'
482

    
483
  # if we're on illumos based systems wrap the helper library into the
484
  # executable
485
  if flavor == 'solaris':
486
    o['variables']['node_use_mdb'] = 'true'
487
  else:
488
    o['variables']['node_use_mdb'] = 'false'
489

    
490
  if options.no_ifaddrs:
491
    o['defines'] += ['SUNOS_NO_IFADDRS']
492

    
493
  # By default, enable ETW on Windows.
494
  if flavor == 'win':
495
    o['variables']['node_use_etw'] = b(not options.without_etw)
496
  elif options.with_etw:
497
    raise Exception('ETW is only supported on Windows.')
498
  else:
499
    o['variables']['node_use_etw'] = 'false'
500

    
501
  # By default, enable Performance counters on Windows.
502
  if flavor == 'win':
503
    o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
504
  elif options.with_perfctr:
505
    raise Exception('Performance counter is only supported on Windows.')
506
  else:
507
    o['variables']['node_use_perfctr'] = 'false'
508

    
509
  if options.tag:
510
    o['variables']['node_tag'] = '-' + options.tag
511
  else:
512
    o['variables']['node_tag'] = ''
513

    
514

    
515
def configure_libz(o):
516
  o['variables']['node_shared_zlib'] = b(options.shared_zlib)
517

    
518
  # assume shared_zlib if one of these is set?
519
  if options.shared_zlib_libpath:
520
    o['libraries'] += ['-L%s' % options.shared_zlib_libpath]
521
  if options.shared_zlib_libname:
522
    o['libraries'] += ['-l%s' % options.shared_zlib_libname]
523
  elif options.shared_zlib:
524
    o['libraries'] += ['-lz']
525
  if options.shared_zlib_includes:
526
    o['include_dirs'] += [options.shared_zlib_includes]
527

    
528

    
529
def configure_http_parser(o):
530
    o['variables']['node_shared_http_parser'] = b(options.shared_http_parser)
531

    
532
    # assume shared http_parser if one of these is set?
533
    if options.shared_http_parser_libpath:
534
        o['libraries'] += ['-L%s' % options.shared_http_parser_libpath]
535
    if options.shared_http_parser_libname:
536
        o['libraries'] += ['-l%s' % options.shared_http_parser_libname]
537
    elif options.shared_http_parser:
538
        o['libraries'] += ['-lhttp_parser']
539
    if options.shared_http_parser_includes:
540
        o['include_dirs'] += [options.shared_http_parser_includes]
541

    
542

    
543
def configure_cares(o):
544
    o['variables']['node_shared_cares'] = b(options.shared_cares)
545

    
546
    # assume shared cares if one of these is set?
547
    if options.shared_cares_libpath:
548
        o['libraries'] += ['-L%s' % options.shared_cares_libpath]
549
    if options.shared_cares_libname:
550
        o['libraries'] += ['-l%s' % options.shared_cares_libname]
551
    elif options.shared_cares:
552
        o['libraries'] += ['-lcares']
553
    if options.shared_cares_includes:
554
        o['include_dirs'] += [options.shared_cares_includes]
555

    
556

    
557
def configure_libuv(o):
558
  o['variables']['node_shared_libuv'] = b(options.shared_libuv)
559

    
560
  # assume shared libuv if one of these is set?
561
  if options.shared_libuv_libpath:
562
    o['libraries'] += ['-L%s' % options.shared_libuv_libpath]
563
  if options.shared_libuv_libname:
564
    o['libraries'] += ['-l%s' % options.shared_libuv_libname]
565
  elif options.shared_libuv:
566
    o['libraries'] += ['-luv']
567
  if options.shared_libuv_includes:
568
    o['include_dirs'] += [options.shared_libuv_includes]
569

    
570

    
571
def configure_v8(o):
572
  o['variables']['node_shared_v8'] = b(options.shared_v8)
573
  o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0
574
  o['variables']['v8_no_strict_aliasing'] = 1  # Work around compiler bugs.
575
  o['variables']['v8_optimized_debug'] = 0  # Compile with -O0 in debug builds.
576
  o['variables']['v8_random_seed'] = 0  # Use a random seed for hash tables.
577
  o['variables']['v8_use_snapshot'] = b(not options.without_snapshot)
578

    
579
  # assume shared_v8 if one of these is set?
580
  if options.shared_v8_libpath:
581
    o['libraries'] += ['-L%s' % options.shared_v8_libpath]
582
  if options.shared_v8_libname:
583
    o['libraries'] += ['-l%s' % options.shared_v8_libname]
584
  elif options.shared_v8:
585
    o['libraries'] += ['-lv8']
586
  if options.shared_v8_includes:
587
    o['include_dirs'] += [options.shared_v8_includes]
588

    
589

    
590
def configure_openssl(o):
591
  o['variables']['node_use_openssl'] = b(not options.without_ssl)
592
  o['variables']['node_shared_openssl'] = b(options.shared_openssl)
593

    
594
  if options.without_ssl:
595
    return
596

    
597
  # OpenSSL uses `#ifndef OPENSSL_NO_SSL2` checks so only define the
598
  # macro when we want to _disable_ SSL2.
599
  if not options.with_sslv2:
600
    o['defines'] += ['OPENSSL_NO_SSL2=1']
601

    
602
  if options.shared_openssl:
603
    (libs, cflags) = pkg_config('openssl') or ('-lssl -lcrypto', '')
604

    
605
    if options.shared_openssl_libpath:
606
      o['libraries'] += ['-L%s' % options.shared_openssl_libpath]
607

    
608
    if options.shared_openssl_libname:
609
      libnames = options.shared_openssl_libname.split(',')
610
      o['libraries'] += ['-l%s' % s for s in libnames]
611
    else:
612
      o['libraries'] += libs.split()
613

    
614
    if options.shared_openssl_includes:
615
      o['include_dirs'] += [options.shared_openssl_includes]
616
    else:
617
      o['cflags'] += cflags.split()
618

    
619

    
620
def configure_winsdk(o):
621
  if flavor != 'win':
622
    return
623

    
624
  winsdk_dir = os.environ.get('WindowsSdkDir')
625

    
626
  if winsdk_dir and os.path.isfile(winsdk_dir + '\\bin\\ctrpp.exe'):
627
    print('Found ctrpp in WinSDK--will build generated files '
628
          'into tools/msvs/genfiles.')
629
    o['variables']['node_has_winsdk'] = 'true'
630
    return
631

    
632
  print('ctrpp not found in WinSDK path--using pre-gen files '
633
        'from tools/msvs/genfiles.')
634

    
635

    
636
def configure_icu(o):
637
  have_icu_path = bool(options.with_icu_path)
638
  o['variables']['v8_enable_i18n_support'] = int(have_icu_path)
639
  if have_icu_path:
640
    o['variables']['icu_gyp_path'] = options.with_icu_path
641

    
642

    
643
# determine the "flavor" (operating system) we're building for,
644
# leveraging gyp's GetFlavor function
645
flavor_params = {}
646
if (options.dest_os):
647
  flavor_params['flavor'] = options.dest_os
648
flavor = GetFlavor(flavor_params)
649

    
650
output = {
651
  'variables': { 'python': sys.executable },
652
  'include_dirs': [],
653
  'libraries': [],
654
  'defines': [],
655
  'cflags': [],
656
}
657

    
658
configure_node(output)
659
configure_libz(output)
660
configure_http_parser(output)
661
configure_cares(output)
662
configure_libuv(output)
663
configure_v8(output)
664
configure_openssl(output)
665
configure_winsdk(output)
666
configure_icu(output)
667

    
668
# variables should be a root level element,
669
# move everything else to target_defaults
670
variables = output['variables']
671
del output['variables']
672
output = {
673
  'variables': variables,
674
  'target_defaults': output
675
}
676
pprint.pprint(output, indent=2)
677

    
678
def write(filename, data):
679
  filename = os.path.join(root_dir, filename)
680
  print 'creating ', filename
681
  f = open(filename, 'w+')
682
  f.write(data)
683

    
684
write('config.gypi', '# Do not edit. Generated by the configure script.\n' +
685
      pprint.pformat(output, indent=2) + '\n')
686

    
687
config = {
688
  'BUILDTYPE': 'Debug' if options.debug else 'Release',
689
  'USE_NINJA': str(int(options.use_ninja or 0)),
690
  'USE_XCODE': str(int(options.use_xcode or 0)),
691
  'PYTHON': sys.executable,
692
}
693

    
694
if options.prefix:
695
  config['PREFIX'] = options.prefix
696

    
697
config = '\n'.join(map('='.join, config.iteritems())) + '\n'
698

    
699
write('config.mk',
700
      '# Do not edit. Generated by the configure script.\n' + config)
701

    
702
gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
703

    
704
if options.use_ninja:
705
  gyp_args += ['-f', 'ninja-' + flavor]
706
elif options.use_xcode:
707
  gyp_args += ['-f', 'xcode']
708
elif flavor == 'win':
709
  gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
710
else:
711
  gyp_args += ['-f', 'make-' + flavor]
712

    
713
gyp_args += args
714

    
715
subprocess.call(gyp_args)