Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 1045 lines (865 sloc) 32.878 kB
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
1 #!/usr/bin/env python
2 import optparse
3 import os
45605c9 @jbergstroem gyp: switch json for pprint when generating config
jbergstroem authored
4 import pprint
30b29d8 @bnoordhuis build: disable -fstrict-aliasing if gcc < 4.6.0
bnoordhuis authored
5 import re
fb6c314 @Hello71 configure: always use shlex instead of split
Hello71 authored
6 import shlex
b9e1bb3 @bnoordhuis build: auto-run tools/gyp_node after ./configure
bnoordhuis authored
7 import subprocess
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
8 import sys
a308395 @srl295 build: i18n: add icu config options
srl295 authored
9 import shutil
10 import string
5cf4cef @ry add configure
ry authored
11
5062741 @bnoordhuis build: make CC command in -fstrict-aliasing check configurable
bnoordhuis authored
12 CC = os.environ.get('CC', 'cc')
13
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
14 root_dir = os.path.dirname(__file__)
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
15 sys.path.insert(0, os.path.join(root_dir, 'tools', 'gyp', 'pylib'))
16 from gyp.common import GetFlavor
97c9745 @ry Back to WAF
ry authored
17
a308395 @srl295 build: i18n: add icu config options
srl295 authored
18 # imports in tools/configure.d
19 sys.path.insert(0, os.path.join(root_dir, 'tools', 'configure.d'))
20 import nodedownload
21
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
22 # parse our options
23 parser = optparse.OptionParser()
97c9745 @ry Back to WAF
ry authored
24
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
25 # Options should be in alphabetical order but keep --prefix at the top,
26 # that's arguably the one people will be looking for most.
27 parser.add_option('--prefix',
28 action='store',
29 dest='prefix',
30 help='select the install prefix (defaults to /usr/local)')
31
32 parser.add_option('--debug',
33 action='store_true',
34 dest='debug',
35 help='also build debug build')
36
37 parser.add_option('--dest-cpu',
38 action='store',
39 dest='dest_cpu',
40 help='CPU architecture to build for. Valid values are: arm, ia32, x64')
41
42 parser.add_option('--dest-os',
43 action='store',
44 dest='dest_os',
45 help='operating system to build for. Valid values are: '
46 'win, mac, solaris, freebsd, openbsd, linux, android')
47
48 parser.add_option('--gdb',
49 action='store_true',
50 dest='gdb',
51 help='add gdb support')
52
53 parser.add_option('--ninja',
54 action='store_true',
55 dest='use_ninja',
56 help='generate files for the ninja build system')
57
58 parser.add_option('--no-ifaddrs',
59 action='store_true',
60 dest='no_ifaddrs',
61 help='use on deprecated SunOS systems that do not support ifaddrs.h')
62
cdc01fa @piranna configure: generate a fully statically linked exec
piranna authored
63 parser.add_option("--fully-static",
64 action="store_true",
65 dest="fully_static",
66 help="Generate an executable without external dynamic libraries. This "
67 "will not work on OSX when using default compilation environment")
68
627c1a9 @indutny configure: add --openssl-no-asm flag
indutny authored
69 parser.add_option("--openssl-no-asm",
70 action="store_true",
71 dest="openssl_no_asm",
72 help="Do not build optimized assembly for OpenSSL")
73
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
74 # deprecated
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
75 parser.add_option('--openssl-includes',
76 action='store',
77 dest='shared_openssl_includes',
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
78 help=optparse.SUPPRESS_HELP)
e61de70 @ry gyp: use built-in openssl by default
ry authored
79
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
80 # deprecated
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
81 parser.add_option('--openssl-libpath',
82 action='store',
83 dest='shared_openssl_libpath',
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
84 help=optparse.SUPPRESS_HELP)
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
85
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
86 # deprecated
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
87 parser.add_option('--openssl-use-sys',
88 action='store_true',
89 dest='shared_openssl',
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
90 help=optparse.SUPPRESS_HELP)
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
91
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
92 parser.add_option('--shared-cares',
93 action='store_true',
94 dest='shared_cares',
95 help='link to a shared cares DLL instead of static linking')
96
97 parser.add_option('--shared-cares-includes',
98 action='store',
99 dest='shared_cares_includes',
100 help='directory containing cares header files')
101
102 parser.add_option('--shared-cares-libname',
103 action='store',
104 dest='shared_cares_libname',
105 help='alternative lib name to link to (default: \'cares\')')
106
107 parser.add_option('--shared-cares-libpath',
108 action='store',
109 dest='shared_cares_libpath',
110 help='a directory to search for the shared cares DLL')
111
112 parser.add_option('--shared-http-parser',
113 action='store_true',
114 dest='shared_http_parser',
115 help='link to a shared http_parser DLL instead of static linking')
116
117 parser.add_option('--shared-http-parser-includes',
118 action='store',
119 dest='shared_http_parser_includes',
120 help='directory containing http_parser header files')
121
122 parser.add_option('--shared-http-parser-libname',
123 action='store',
124 dest='shared_http_parser_libname',
125 help='alternative lib name to link to (default: \'http_parser\')')
126
127 parser.add_option('--shared-http-parser-libpath',
128 action='store',
129 dest='shared_http_parser_libpath',
130 help='a directory to search for the shared http_parser DLL')
131
132 parser.add_option('--shared-libuv',
133 action='store_true',
134 dest='shared_libuv',
135 help='link to a shared libuv DLL instead of static linking')
136
137 parser.add_option('--shared-libuv-includes',
138 action='store',
139 dest='shared_libuv_includes',
140 help='directory containing libuv header files')
141
142 parser.add_option('--shared-libuv-libname',
143 action='store',
144 dest='shared_libuv_libname',
145 help='alternative lib name to link to (default: \'uv\')')
146
147 parser.add_option('--shared-libuv-libpath',
148 action='store',
149 dest='shared_libuv_libpath',
150 help='a directory to search for the shared libuv DLL')
151
152 parser.add_option('--shared-openssl',
153 action='store_true',
154 dest='shared_openssl',
155 help='link to a shared OpenSSl DLL instead of static linking')
156
157 parser.add_option('--shared-openssl-includes',
158 action='store',
159 dest='shared_openssl_includes',
160 help='directory containing OpenSSL header files')
161
162 parser.add_option('--shared-openssl-libname',
163 action='store',
164 dest='shared_openssl_libname',
165 help='alternative lib name to link to (default: \'crypto,ssl\')')
166
167 parser.add_option('--shared-openssl-libpath',
168 action='store',
169 dest='shared_openssl_libpath',
170 help='a directory to search for the shared OpenSSL DLLs')
171
172 parser.add_option('--shared-v8',
173 action='store_true',
174 dest='shared_v8',
175 help='link to a shared V8 DLL instead of static linking')
176
177 parser.add_option('--shared-v8-includes',
178 action='store',
179 dest='shared_v8_includes',
180 help='directory containing V8 header files')
181
182 parser.add_option('--shared-v8-libname',
183 action='store',
184 dest='shared_v8_libname',
185 help='alternative lib name to link to (default: \'v8\')')
186
187 parser.add_option('--shared-v8-libpath',
188 action='store',
189 dest='shared_v8_libpath',
190 help='a directory to search for the shared V8 DLL')
191
192 parser.add_option('--shared-zlib',
193 action='store_true',
194 dest='shared_zlib',
195 help='link to a shared zlib DLL instead of static linking')
196
197 parser.add_option('--shared-zlib-includes',
198 action='store',
199 dest='shared_zlib_includes',
200 help='directory containing zlib header files')
201
202 parser.add_option('--shared-zlib-libname',
203 action='store',
204 dest='shared_zlib_libname',
205 help='alternative lib name to link to (default: \'z\')')
206
207 parser.add_option('--shared-zlib-libpath',
208 action='store',
209 dest='shared_zlib_libpath',
210 help='a directory to search for the shared zlib DLL')
211
2f5fa08 @bnoordhuis build: add --systemtap-includes configure switch
bnoordhuis authored
212 # TODO document when we've decided on what the tracing API and its options will
213 # look like
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
214 parser.add_option('--systemtap-includes',
215 action='store',
216 dest='systemtap_includes',
2f5fa08 @bnoordhuis build: add --systemtap-includes configure switch
bnoordhuis authored
217 help=optparse.SUPPRESS_HELP)
218
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
219 parser.add_option('--tag',
220 action='store',
221 dest='tag',
222 help='custom build tag')
223
b55c9d6 @indutny configure: --v8-options option
indutny authored
224 parser.add_option('--v8-options',
225 action='store',
226 dest='v8_options',
490d5ab @bnoordhuis configure: make --v8-options switch more robust
bnoordhuis authored
227 help='v8 options to pass, see `node --v8-options` for examples.')
b55c9d6 @indutny configure: --v8-options option
indutny authored
228
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
229 parser.add_option('--with-arm-float-abi',
230 action='store',
231 dest='arm_float_abi',
232 help='specifies which floating-point ABI to use. Valid values are: '
233 'soft, softfp, hard')
234
235 parser.add_option('--with-dtrace',
236 action='store_true',
237 dest='with_dtrace',
238 help='build with DTrace (default is true on sunos)')
239
240 parser.add_option('--with-etw',
241 action='store_true',
242 dest='with_etw',
243 help='build with ETW (default is true on Windows)')
244
a308395 @srl295 build: i18n: add icu config options
srl295 authored
245 parser.add_option('--download',
246 action='store',
247 dest='download_list',
248 help=nodedownload.help())
249
9e32a7d @bnoordhuis build: add libicu i18n support
bnoordhuis authored
250 parser.add_option('--with-icu-path',
251 action='store',
252 dest='with_icu_path',
253 help='Path to icu.gyp (ICU i18n, Chromium version only.)')
254
a308395 @srl295 build: i18n: add icu config options
srl295 authored
255 parser.add_option('--with-icu-locales',
256 action='store',
257 dest='with_icu_locales',
258 help='Comma-separated list of locales for "small-icu". Default: "root,en". "root" is assumed.')
259
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
260 parser.add_option('--with-intl',
261 action='store',
262 dest='with_intl',
263 help='Intl mode: none, full-icu, small-icu (default is none)')
264
a308395 @srl295 build: i18n: add icu config options
srl295 authored
265 parser.add_option('--with-icu-source',
266 action='store',
267 dest='with_icu_source',
268 help='Intl mode: optional local path to icu/ dir, or path/URL of icu source archive.')
269
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
270 parser.add_option('--with-perfctr',
271 action='store_true',
272 dest='with_perfctr',
273 help='build with performance counters (default is true on Windows)')
274
275 parser.add_option('--without-dtrace',
276 action='store_true',
277 dest='without_dtrace',
278 help='build without DTrace')
279
280 parser.add_option('--without-etw',
281 action='store_true',
282 dest='without_etw',
283 help='build without ETW')
284
285 parser.add_option('--without-npm',
286 action='store_true',
287 dest='without_npm',
288 help='don\'t install the bundled npm package manager')
289
290 parser.add_option('--without-perfctr',
291 action='store_true',
292 dest='without_perfctr',
293 help='build without performance counters')
294
295 parser.add_option('--without-snapshot',
296 action='store_true',
297 dest='without_snapshot',
298 help='build without snapshotting V8 libraries. You might want to set'
299 ' this for cross-compiling. [Default: False]')
300
301 parser.add_option('--without-ssl',
302 action='store_true',
303 dest='without_ssl',
304 help='build without SSL')
305
0c7f6ca @misterdjules Merge remote-tracking branch 'upstream/v0.10' into merge-0-10-into-0-12
misterdjules authored
306 parser.add_option('--without-ssl2',
307 action='store_true',
308 dest='ssl2',
309 help='Disable SSL v2')
310
311 parser.add_option('--without-ssl3',
312 action='store_true',
313 dest='ssl3',
314 help='Disable SSL v3')
315
52e47b2 @bnoordhuis configure: order configure switches alphabetically
bnoordhuis authored
316 parser.add_option('--xcode',
317 action='store_true',
318 dest='use_xcode',
319 help='generate build files for use with xcode')
f84bf5b @mmalecki build: allow to specify custom tags
mmalecki authored
320
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
321 (options, args) = parser.parse_args()
322
a308395 @srl295 build: i18n: add icu config options
srl295 authored
323 # set up auto-download list
324 auto_downloads = nodedownload.parse(options.download_list)
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
325
a033261 @bnoordhuis build: DRY configure script
bnoordhuis authored
326 def b(value):
327 """Returns the string 'true' if value is truthy, 'false' otherwise."""
328 if value:
329 return 'true'
330 else:
331 return 'false'
332
333
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
334 def pkg_config(pkg):
335 cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
336 libs = cmd.readline().strip()
337 ret = cmd.close()
338 if (ret): return None
339
340 cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
341 cflags = cmd.readline().strip()
342 ret = cmd.close()
343 if (ret): return None
344
345 return (libs, cflags)
346
347
a0b6df0 @bnoordhuis Revert "configure: fix cross-compilation host_arch_cc()"
bnoordhuis authored
348 def cc_macros():
349 """Checks predefined macros using the CC command."""
19133ca @TooTallNate build: better host_arch() definition in configure
TooTallNate authored
350
792d9a9 @javihernandez build: print error message if no compiler found
javihernandez authored
351 try:
a0b6df0 @bnoordhuis Revert "configure: fix cross-compilation host_arch_cc()"
bnoordhuis authored
352 p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
792d9a9 @javihernandez build: print error message if no compiler found
javihernandez authored
353 stdin=subprocess.PIPE,
354 stdout=subprocess.PIPE,
355 stderr=subprocess.PIPE)
356 except OSError:
357 print '''Node.js configure error: No acceptable C compiler found!
358
359 Please make sure you have a C compiler installed on your system and/or
360 consider adjusting the CC environment variable if you installed
361 it in a non-standard prefix.
362 '''
363 sys.exit()
364
19133ca @TooTallNate build: better host_arch() definition in configure
TooTallNate authored
365 p.stdin.write('\n')
366 out = p.communicate()[0]
367
368 out = str(out).split('\n')
369
370 k = {}
371 for line in out:
372 lst = shlex.split(line)
373 if len(lst) > 2:
374 key = lst[1]
375 val = lst[2]
376 k[key] = val
90efdb3 @adammw build: improve armv7 / hard-float detection
adammw authored
377 return k
378
379
380 def is_arch_armv7():
381 """Check for ARMv7 instructions"""
382 cc_macros_cache = cc_macros()
383 return ('__ARM_ARCH_7__' in cc_macros_cache or
384 '__ARM_ARCH_7A__' in cc_macros_cache or
385 '__ARM_ARCH_7R__' in cc_macros_cache or
386 '__ARM_ARCH_7M__' in cc_macros_cache)
387
388
300dd34 @mmalecki gyp: fix ARM build
mmalecki authored
389 def is_arch_armv6():
390 """Check for ARMv6 instructions"""
391 cc_macros_cache = cc_macros()
392 return ('__ARM_ARCH_6__' in cc_macros_cache or
393 '__ARM_ARCH_6M__' in cc_macros_cache)
394
395
b916774 @TooTallNate configure: define "arm_fpu" and "arm_neon" for ARM
TooTallNate authored
396 def is_arm_neon():
397 """Check for ARM NEON support"""
398 return '__ARM_NEON__' in cc_macros()
399
400
223607c @bnoordhuis build: fix arm build after v8 upgrade
bnoordhuis authored
401 def is_arm_hard_float_abi():
90efdb3 @adammw build: improve armv7 / hard-float detection
adammw authored
402 """Check for hardfloat or softfloat eabi on ARM"""
403 # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
404 # the Floating Point ABI used (PCS stands for Procedure Call Standard).
405 # We use these as well as a couple of other defines to statically determine
406 # what FP ABI used.
407 # GCC versions 4.4 and below don't support hard-fp.
408 # GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
409 # __ARM_PCS_VFP.
410
411 if compiler_version() >= (4, 6, 0):
412 return '__ARM_PCS_VFP' in cc_macros()
413 elif compiler_version() < (4, 5, 0):
414 return False
415 elif '__ARM_PCS_VFP' in cc_macros():
416 return True
417 elif ('__ARM_PCS' in cc_macros() or
418 '__SOFTFP' in cc_macros() or
419 not '__VFP_FP__' in cc_macros()):
420 return False
421 else:
422 print '''Node.js configure error: Your version of GCC does not report
423 the Floating-Point ABI to compile for your hardware
424
425 Please manually specify which floating-point ABI to use with the
426 --with-arm-float-abi option.
427 '''
428 sys.exit()
429
430
431 def host_arch_cc():
432 """Host architecture check using the CC command."""
433
a0b6df0 @bnoordhuis Revert "configure: fix cross-compilation host_arch_cc()"
bnoordhuis authored
434 k = cc_macros()
19133ca @TooTallNate build: better host_arch() definition in configure
TooTallNate authored
435
436 matchup = {
437 '__x86_64__' : 'x64',
438 '__i386__' : 'ia32',
439 '__arm__' : 'arm',
884b253 @bsnote openssl: add missing configuration pieces for MIPS
bsnote authored
440 '__mips__' : 'mips',
09ccbef @Skomski build: detect host_arch better
Skomski authored
441 }
442
19133ca @TooTallNate build: better host_arch() definition in configure
TooTallNate authored
443 rtn = 'ia32' # default
444
445 for i in matchup:
446 if i in k and k[i] != '0':
447 rtn = matchup[i]
448 break
09ccbef @Skomski build: detect host_arch better
Skomski authored
449
19133ca @TooTallNate build: better host_arch() definition in configure
TooTallNate authored
450 return rtn
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
451
452
dc75232 @TooTallNate vcbuild: run the 'configure' script in vcbuild.bat
TooTallNate authored
453 def host_arch_win():
454 """Host architecture check using environ vars (better way to do this?)"""
455
423725b @refack configure: better detect windows 'bitness' (WOW64)
refack authored
456 observed_arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'x86')
457 arch = os.environ.get('PROCESSOR_ARCHITEW6432', observed_arch)
dc75232 @TooTallNate vcbuild: run the 'configure' script in vcbuild.bat
TooTallNate authored
458
459 matchup = {
460 'AMD64' : 'x64',
461 'x86' : 'ia32',
462 'arm' : 'arm',
884b253 @bsnote openssl: add missing configuration pieces for MIPS
bsnote authored
463 'mips' : 'mips',
dc75232 @TooTallNate vcbuild: run the 'configure' script in vcbuild.bat
TooTallNate authored
464 }
465
466 return matchup.get(arch, 'ia32')
467
468
07e5877 @bnoordhuis build: disable strict aliasing in v8 with gcc 4.5.x
bnoordhuis authored
469 def compiler_version():
3e5139f @piscisaureus Fix the Windows build
piscisaureus authored
470 try:
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
471 proc = subprocess.Popen(shlex.split(CC) + ['--version'],
472 stdout=subprocess.PIPE)
3e5139f @piscisaureus Fix the Windows build
piscisaureus authored
473 except WindowsError:
474 return (0, False)
475
a0add91 @bnoordhuis build: detect cc version with -dumpversion
bnoordhuis authored
476 is_clang = 'clang' in proc.communicate()[0].split('\n')[0]
f78ce08 @bnoordhuis build: handle output of localized gcc or clang
bnoordhuis authored
477
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
478 proc = subprocess.Popen(shlex.split(CC) + ['-dumpversion'],
479 stdout=subprocess.PIPE)
a0add91 @bnoordhuis build: detect cc version with -dumpversion
bnoordhuis authored
480 version = tuple(map(int, proc.communicate()[0].split('.')))
f78ce08 @bnoordhuis build: handle output of localized gcc or clang
bnoordhuis authored
481
482 return (version, is_clang)
483
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
484
bbf6b4e @bnoordhuis configure: turn on VFPv3 on ARMv7
bnoordhuis authored
485 def configure_arm(o):
486 if options.arm_float_abi:
223607c @bnoordhuis build: fix arm build after v8 upgrade
bnoordhuis authored
487 arm_float_abi = options.arm_float_abi
f9f9239 @tjfontaine build: older pythons don't support ternary if
tjfontaine authored
488 elif is_arm_hard_float_abi():
489 arm_float_abi = 'hard'
bbf6b4e @bnoordhuis configure: turn on VFPv3 on ARMv7
bnoordhuis authored
490 else:
0afdfae @indutny configure: always set `arm_float_abi`
indutny authored
491 arm_float_abi = 'default'
300dd34 @mmalecki gyp: fix ARM build
mmalecki authored
492
493 if is_arch_armv7():
494 o['variables']['arm_version'] = '7'
495 elif is_arch_armv6():
496 o['variables']['arm_version'] = '6'
497 else:
498 o['variables']['arm_version'] = 'default'
499
223607c @bnoordhuis build: fix arm build after v8 upgrade
bnoordhuis authored
500 o['variables']['arm_fpu'] = 'vfpv3' # V8 3.18 no longer supports VFP2.
b916774 @TooTallNate configure: define "arm_fpu" and "arm_neon" for ARM
TooTallNate authored
501 o['variables']['arm_neon'] = int(is_arm_neon())
223607c @bnoordhuis build: fix arm build after v8 upgrade
bnoordhuis authored
502 o['variables']['arm_thumb'] = 0 # -marm
503 o['variables']['arm_float_abi'] = arm_float_abi
bbf6b4e @bnoordhuis configure: turn on VFPv3 on ARMv7
bnoordhuis authored
504
505
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
506 def configure_node(o):
5e4e8ec build: add android support
Linus Mårtensson authored
507 if options.dest_os == 'android':
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
508 o['variables']['OS'] = 'android'
06c82c5 @bnoordhuis build: expand ~ in `./configure --prefix=~/a/b/c`
bnoordhuis authored
509 o['variables']['node_prefix'] = os.path.expanduser(options.prefix or '')
a9f2c4a @indutny --without-npm option
indutny authored
510 o['variables']['node_install_npm'] = b(not options.without_npm)
680d75a @shigeki build: make default_configuration consistent with BUILDTYPE
shigeki authored
511 o['default_configuration'] = 'Debug' if options.debug else 'Release'
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
512
c6bb361 @bnoordhuis build: partially fix configure on ARM
bnoordhuis authored
513 host_arch = host_arch_win() if os.name == 'nt' else host_arch_cc()
514 target_arch = options.dest_cpu or host_arch
515 o['variables']['host_arch'] = host_arch
516 o['variables']['target_arch'] = target_arch
517
1d90b5b @bsnote configure: allow V8 snapshot for cross-compilation
bsnote authored
518 if target_arch != host_arch and not options.without_snapshot:
519 o['variables']['want_separate_host_toolset'] = 1
449ffec @trevnorris configure: fix v8 overriding commands on build
trevnorris authored
520 else:
521 o['variables']['want_separate_host_toolset'] = 0
1d90b5b @bsnote configure: allow V8 snapshot for cross-compilation
bsnote authored
522
c6bb361 @bnoordhuis build: partially fix configure on ARM
bnoordhuis authored
523 if target_arch == 'arm':
bbf6b4e @bnoordhuis configure: turn on VFPv3 on ARMv7
bnoordhuis authored
524 configure_arm(o)
07e5877 @bnoordhuis build: disable strict aliasing in v8 with gcc 4.5.x
bnoordhuis authored
525
c6bb361 @bnoordhuis build: partially fix configure on ARM
bnoordhuis authored
526 cc_version, is_clang = compiler_version()
100e163 @bnoordhuis build: compile with -fno-tree-vrp when gcc >= 4.0
bnoordhuis authored
527 o['variables']['clang'] = 1 if is_clang else 0
528
8677860 @isaacs build: Don't set gcc_version for Windows
isaacs authored
529 if not is_clang and cc_version != 0:
100e163 @bnoordhuis build: compile with -fno-tree-vrp when gcc >= 4.0
bnoordhuis authored
530 o['variables']['gcc_version'] = 10 * cc_version[0] + cc_version[1]
531
532 # clang has always supported -fvisibility=hidden, right?
07e5877 @bnoordhuis build: disable strict aliasing in v8 with gcc 4.5.x
bnoordhuis authored
533 if not is_clang and cc_version < (4,0,0):
5ebc05f @bnoordhuis build: disable -fvisibility=hidden if gcc < 4.0.0
bnoordhuis authored
534 o['variables']['visibility'] = ''
30b29d8 @bnoordhuis build: disable -fstrict-aliasing if gcc < 4.6.0
bnoordhuis authored
535
78d245f @indutny Merge remote-tracking branch 'origin/v0.10'
indutny authored
536 if flavor in ('solaris', 'mac', 'linux', 'freebsd'):
c4def50 @bnoordhuis build: use zero overhead systemtap probes
bnoordhuis authored
537 use_dtrace = not options.without_dtrace
78d245f @indutny Merge remote-tracking branch 'origin/v0.10'
indutny authored
538 # Don't enable by default on linux and freebsd
539 if flavor in ('linux', 'freebsd'):
540 use_dtrace = options.with_dtrace
541
c4def50 @bnoordhuis build: use zero overhead systemtap probes
bnoordhuis authored
542 if flavor == 'linux':
543 if options.systemtap_includes:
544 o['include_dirs'] += [options.systemtap_includes]
545 o['variables']['node_use_dtrace'] = b(use_dtrace)
546 o['variables']['uv_use_dtrace'] = b(use_dtrace)
f0d80d7 @tjfontaine dtrace: enable uv's probes if enabled
tjfontaine authored
547 o['variables']['uv_parent_path'] = '/deps/uv/'
f657ce6 @sblom windows: add tracing with performance counters
sblom authored
548 elif options.with_dtrace:
06810b2 tracing: add systemtap support
Jan Wynholds authored
549 raise Exception(
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
550 'DTrace is currently only supported on SunOS, MacOS or Linux systems.')
cc15299 @davepacheco build: add support for DTrace and postmortem
davepacheco authored
551 else:
552 o['variables']['node_use_dtrace'] = 'false'
553
e851fef @tjfontaine build: embed the mdb_v8.so into the binary
tjfontaine authored
554 # if we're on illumos based systems wrap the helper library into the
555 # executable
556 if flavor == 'solaris':
557 o['variables']['node_use_mdb'] = 'true'
558 else:
559 o['variables']['node_use_mdb'] = 'false'
560
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
561 if options.no_ifaddrs:
562 o['defines'] += ['SUNOS_NO_IFADDRS']
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
563
35a1421 Windows: Enable ETW events.
Igor Zinkovsky authored
564 # By default, enable ETW on Windows.
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
565 if flavor == 'win':
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
566 o['variables']['node_use_etw'] = b(not options.without_etw)
f657ce6 @sblom windows: add tracing with performance counters
sblom authored
567 elif options.with_etw:
35a1421 Windows: Enable ETW events.
Igor Zinkovsky authored
568 raise Exception('ETW is only supported on Windows.')
569 else:
570 o['variables']['node_use_etw'] = 'false'
571
f657ce6 @sblom windows: add tracing with performance counters
sblom authored
572 # By default, enable Performance counters on Windows.
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
573 if flavor == 'win':
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
574 o['variables']['node_use_perfctr'] = b(not options.without_perfctr)
f657ce6 @sblom windows: add tracing with performance counters
sblom authored
575 elif options.with_perfctr:
576 raise Exception('Performance counter is only supported on Windows.')
577 else:
578 o['variables']['node_use_perfctr'] = 'false'
579
4be9c69 @isaacs build: Add hyphen to custom build tags
isaacs authored
580 if options.tag:
581 o['variables']['node_tag'] = '-' + options.tag
582 else:
583 o['variables']['node_tag'] = ''
f84bf5b @mmalecki build: allow to specify custom tags
mmalecki authored
584
b55c9d6 @indutny configure: --v8-options option
indutny authored
585 if options.v8_options:
490d5ab @bnoordhuis configure: make --v8-options switch more robust
bnoordhuis authored
586 o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
b55c9d6 @indutny configure: --v8-options option
indutny authored
587
35a1421 Windows: Enable ETW events.
Igor Zinkovsky authored
588
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
589 def configure_libz(o):
d03b848 @tchollingsworth build: support shared zlib
tchollingsworth authored
590 o['variables']['node_shared_zlib'] = b(options.shared_zlib)
591
592 # assume shared_zlib if one of these is set?
593 if options.shared_zlib_libpath:
594 o['libraries'] += ['-L%s' % options.shared_zlib_libpath]
595 if options.shared_zlib_libname:
596 o['libraries'] += ['-l%s' % options.shared_zlib_libname]
597 elif options.shared_zlib:
598 o['libraries'] += ['-lz']
599 if options.shared_zlib_includes:
600 o['include_dirs'] += [options.shared_zlib_includes]
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
601
602
bfd78b6 @sgallagher build: allow linking against system http_parser
sgallagher authored
603 def configure_http_parser(o):
604 o['variables']['node_shared_http_parser'] = b(options.shared_http_parser)
605
606 # assume shared http_parser if one of these is set?
607 if options.shared_http_parser_libpath:
608 o['libraries'] += ['-L%s' % options.shared_http_parser_libpath]
609 if options.shared_http_parser_libname:
610 o['libraries'] += ['-l%s' % options.shared_http_parser_libname]
611 elif options.shared_http_parser:
612 o['libraries'] += ['-lhttp_parser']
613 if options.shared_http_parser_includes:
614 o['include_dirs'] += [options.shared_http_parser_includes]
615
616
73ff653 @sgallagher build: allow linking against system c-ares
sgallagher authored
617 def configure_cares(o):
618 o['variables']['node_shared_cares'] = b(options.shared_cares)
619
620 # assume shared cares if one of these is set?
621 if options.shared_cares_libpath:
622 o['libraries'] += ['-L%s' % options.shared_cares_libpath]
623 if options.shared_cares_libname:
624 o['libraries'] += ['-l%s' % options.shared_cares_libname]
625 elif options.shared_cares:
626 o['libraries'] += ['-lcares']
627 if options.shared_cares_includes:
628 o['include_dirs'] += [options.shared_cares_includes]
629
630
38809e3 @sgallagher build: allow linking against system libuv
sgallagher authored
631 def configure_libuv(o):
632 o['variables']['node_shared_libuv'] = b(options.shared_libuv)
633
634 # assume shared libuv if one of these is set?
635 if options.shared_libuv_libpath:
636 o['libraries'] += ['-L%s' % options.shared_libuv_libpath]
afc29ed @tjfontaine src: update to latest libuv api
tjfontaine authored
637 else:
638 o['variables']['uv_library'] = 'static_library'
639
38809e3 @sgallagher build: allow linking against system libuv
sgallagher authored
640 if options.shared_libuv_libname:
641 o['libraries'] += ['-l%s' % options.shared_libuv_libname]
642 elif options.shared_libuv:
643 o['libraries'] += ['-luv']
644 if options.shared_libuv_includes:
645 o['include_dirs'] += [options.shared_libuv_includes]
646
647
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
648 def configure_v8(o):
a033261 @bnoordhuis build: DRY configure script
bnoordhuis authored
649 o['variables']['node_shared_v8'] = b(options.shared_v8)
f230a1c @bnoordhuis v8: upgrade to 3.22.24
bnoordhuis authored
650 o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0
651 o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs.
652 o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds.
653 o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
654 o['variables']['v8_use_snapshot'] = b(not options.without_snapshot)
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
655
656 # assume shared_v8 if one of these is set?
657 if options.shared_v8_libpath:
658 o['libraries'] += ['-L%s' % options.shared_v8_libpath]
659 if options.shared_v8_libname:
660 o['libraries'] += ['-l%s' % options.shared_v8_libname]
59ecf2c @isaacs Revert "Revert "build: support shared V8 properly""
isaacs authored
661 elif options.shared_v8:
662 o['libraries'] += ['-lv8']
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
663 if options.shared_v8_includes:
664 o['include_dirs'] += [options.shared_v8_includes]
665
666
667 def configure_openssl(o):
a033261 @bnoordhuis build: DRY configure script
bnoordhuis authored
668 o['variables']['node_use_openssl'] = b(not options.without_ssl)
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
669 o['variables']['node_shared_openssl'] = b(options.shared_openssl)
627c1a9 @indutny configure: add --openssl-no-asm flag
indutny authored
670 o['variables']['openssl_no_asm'] = (
671 1 if options.openssl_no_asm else 0)
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
672
673 if options.without_ssl:
674 return
675
c1f4aac @tjfontaine build: revert change to disable ssl2 and ssl3
tjfontaine authored
676 if options.ssl2:
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
677 o['defines'] += ['OPENSSL_NO_SSL2=1']
678
c1f4aac @tjfontaine build: revert change to disable ssl2 and ssl3
tjfontaine authored
679 if options.ssl3:
0ec78c9 @indutny configure: disable ssl2/ssl3 by default
indutny authored
680 o['defines'] += ['OPENSSL_NO_SSL3=1']
681
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
682 if options.shared_openssl:
683 (libs, cflags) = pkg_config('openssl') or ('-lssl -lcrypto', '')
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
684
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
685 if options.shared_openssl_libpath:
686 o['libraries'] += ['-L%s' % options.shared_openssl_libpath]
687
688 if options.shared_openssl_libname:
689 libnames = options.shared_openssl_libname.split(',')
690 o['libraries'] += ['-l%s' % s for s in libnames]
e61de70 @ry gyp: use built-in openssl by default
ry authored
691 else:
692 o['libraries'] += libs.split()
693
f315029 @bnoordhuis build: rename openssl configure switches
bnoordhuis authored
694 if options.shared_openssl_includes:
695 o['include_dirs'] += [options.shared_openssl_includes]
e61de70 @ry gyp: use built-in openssl by default
ry authored
696 else:
697 o['cflags'] += cflags.split()
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
698
699
cdc01fa @piranna configure: generate a fully statically linked exec
piranna authored
700 def configure_fullystatic(o):
701 if options.fully_static:
702 o['libraries'] += ['-static']
703 if flavor == 'mac':
704 print("Generation of static executable will not work on OSX "
705 "when using default compilation environment")
706
707
841b7f5 @sblom Ease building with VS Express by checking in generated files.
sblom authored
708 def configure_winsdk(o):
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
709 if flavor != 'win':
841b7f5 @sblom Ease building with VS Express by checking in generated files.
sblom authored
710 return
711
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
712 winsdk_dir = os.environ.get('WindowsSdkDir')
a616774 @sblom windows: improve Visual Studio Express build support
sblom authored
713
714 if winsdk_dir and os.path.isfile(winsdk_dir + '\\bin\\ctrpp.exe'):
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
715 print('Found ctrpp in WinSDK--will build generated files '
716 'into tools/msvs/genfiles.')
a616774 @sblom windows: improve Visual Studio Express build support
sblom authored
717 o['variables']['node_has_winsdk'] = 'true'
841b7f5 @sblom Ease building with VS Express by checking in generated files.
sblom authored
718 return
719
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
720 print('ctrpp not found in WinSDK path--using pre-gen files '
721 'from tools/msvs/genfiles.')
841b7f5 @sblom Ease building with VS Express by checking in generated files.
sblom authored
722
f769d13 @srl295 build: i18n: move noisy variables to separate gypi
srl295 authored
723 def write(filename, data):
724 filename = os.path.join(root_dir, filename)
725 print 'creating ', filename
726 f = open(filename, 'w+')
727 f.write(data)
728
729 do_not_edit = '# Do not edit. Generated by the configure script.\n'
730
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
731 def glob_to_var(dir_base, dir_sub):
732 list = []
733 dir_all = os.path.join(dir_base, dir_sub)
734 files = os.walk(dir_all)
735 for ent in files:
736 (path, dirs, files) = ent
737 for file in files:
738 if file.endswith('.cpp') or file.endswith('.c') or file.endswith('.h'):
739 list.append('%s/%s' % (dir_sub, file))
740 break
741 return list
742
743 def configure_intl(o):
a308395 @srl295 build: i18n: add icu config options
srl295 authored
744 icus = [
745 {
746 'url': 'http://download.icu-project.org/files/icu4c/54.1/icu4c-54_1-src.zip',
747 # from https://ssl.icu-project.org/files/icu4c/54.1/icu4c-src-54_1.md5:
748 'md5': '6b89d60e2f0e140898ae4d7f72323bca',
749 },
750 ]
751 def icu_download(path):
752 # download ICU, if needed
753 for icu in icus:
754 url = icu['url']
755 md5 = icu['md5']
756 local = url.split('/')[-1]
757 targetfile = os.path.join(root_dir, 'deps', local)
758 if not os.path.isfile(targetfile):
759 if nodedownload.candownload(auto_downloads, "icu"):
760 nodedownload.retrievefile(url, targetfile)
761 else:
762 print ' Re-using existing %s' % targetfile
763 if os.path.isfile(targetfile):
764 sys.stdout.write(' Checking file integrity with MD5:\r')
765 gotmd5 = nodedownload.md5sum(targetfile)
766 print ' MD5: %s %s' % (gotmd5, targetfile)
767 if (md5 == gotmd5):
768 return targetfile
769 else:
770 print ' Expected: %s *MISMATCH*' % md5
771 print '\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile
772 return None
f769d13 @srl295 build: i18n: move noisy variables to separate gypi
srl295 authored
773 icu_config = {
774 'variables': {}
775 }
776 icu_config_name = 'icu_config.gypi'
777 def write_config(data, name):
778 return
779
780 # write an empty file to start with
781 write(icu_config_name, do_not_edit +
782 pprint.pformat(icu_config, indent=2) + '\n')
783
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
784 # always set icu_small, node.gyp depends on it being defined.
785 o['variables']['icu_small'] = b(False)
786
787 with_intl = options.with_intl
a308395 @srl295 build: i18n: add icu config options
srl295 authored
788 with_icu_source = options.with_icu_source
9e32a7d @bnoordhuis build: add libicu i18n support
bnoordhuis authored
789 have_icu_path = bool(options.with_icu_path)
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
790 if have_icu_path and with_intl:
791 print 'Error: Cannot specify both --with-icu-path and --with-intl'
792 sys.exit(1)
793 elif have_icu_path:
794 # Chromium .gyp mode: --with-icu-path
795 o['variables']['v8_enable_i18n_support'] = 1
796 # use the .gyp given
9e32a7d @bnoordhuis build: add libicu i18n support
bnoordhuis authored
797 o['variables']['icu_gyp_path'] = options.with_icu_path
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
798 return
799 # --with-intl=<with_intl>
a308395 @srl295 build: i18n: add icu config options
srl295 authored
800 # set the default
801 if with_intl is None:
802 with_intl = 'none' # The default mode of Intl
803 # sanity check localelist
804 if options.with_icu_locales and (with_intl != 'small-icu'):
805 print 'Error: --with-icu-locales only makes sense with --with-intl=small-icu'
806 sys.exit(1)
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
807 if with_intl == 'none' or with_intl is None:
808 o['variables']['v8_enable_i18n_support'] = 0
809 return # no Intl
810 elif with_intl == 'small-icu':
811 # small ICU (English only)
812 o['variables']['v8_enable_i18n_support'] = 1
813 o['variables']['icu_small'] = b(True)
a308395 @srl295 build: i18n: add icu config options
srl295 authored
814 with_icu_locales = options.with_icu_locales
815 if not with_icu_locales:
816 with_icu_locales = 'root,en'
817 locs = set(with_icu_locales.split(','))
818 locs.add('root') # must have root
819 o['variables']['icu_locales'] = string.join(locs,',')
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
820 elif with_intl == 'full-icu':
821 # full ICU
822 o['variables']['v8_enable_i18n_support'] = 1
823 elif with_intl == 'system-icu':
824 # ICU from pkg-config.
825 o['variables']['v8_enable_i18n_support'] = 1
826 pkgicu = pkg_config('icu-i18n')
827 if not pkgicu:
828 print 'Error: could not load pkg-config data for "icu-i18n".'
829 print 'See above errors or the README.md.'
830 sys.exit(1)
831 (libs, cflags) = pkgicu
832 o['libraries'] += libs.split()
833 o['cflags'] += cflags.split()
834 # use the "system" .gyp
835 o['variables']['icu_gyp_path'] = 'tools/icu/icu-system.gyp'
836 return
837 else:
838 print 'Error: unknown value --with-intl=%s' % with_intl
839 sys.exit(1)
840 # Note: non-ICU implementations could use other 'with_intl'
841 # values.
842
a308395 @srl295 build: i18n: add icu config options
srl295 authored
843 # this is just the 'deps' dir. Used for unpacking.
844 icu_parent_path = os.path.join(root_dir, 'deps')
845
846 # The full path to the ICU source directory.
847 icu_full_path = os.path.join(icu_parent_path, 'icu')
848
849 # icu-tmp is used to download and unpack the ICU tarball.
850 icu_tmp_path = os.path.join(icu_parent_path, 'icu-tmp')
851
852 # --with-icu-source processing
853 # first, check that they didn't pass --with-icu-source=deps/icu
854 if with_icu_source and os.path.abspath(icu_full_path) == os.path.abspath(with_icu_source):
855 print 'Ignoring redundant --with-icu-source=%s' % (with_icu_source)
856 with_icu_source = None
857 # if with_icu_source is still set, try to use it.
858 if with_icu_source:
859 if os.path.isdir(icu_full_path):
860 print 'Deleting old ICU source: %s' % (icu_full_path)
861 shutil.rmtree(icu_full_path)
862 # now, what path was given?
863 if os.path.isdir(with_icu_source):
864 # it's a path. Copy it.
865 print '%s -> %s' % (with_icu_source, icu_full_path)
866 shutil.copytree(with_icu_source, icu_full_path)
867 else:
868 # could be file or URL.
869 # Set up temporary area
870 if os.path.isdir(icu_tmp_path):
871 shutil.rmtree(icu_tmp_path)
872 os.mkdir(icu_tmp_path)
873 icu_tarball = None
874 if os.path.isfile(with_icu_source):
875 # it's a file. Try to unpack it.
876 icu_tarball = with_icu_source
877 else:
878 # Can we download it?
879 local = os.path.join(icu_tmp_path, with_icu_source.split('/')[-1]) # local part
880 icu_tarball = nodedownload.retrievefile(with_icu_source, local)
881 # continue with "icu_tarball"
882 nodedownload.unpack(icu_tarball, icu_tmp_path)
883 # Did it unpack correctly? Should contain 'icu'
884 tmp_icu = os.path.join(icu_tmp_path, 'icu')
885 if os.path.isdir(tmp_icu):
886 os.rename(tmp_icu, icu_full_path)
887 shutil.rmtree(icu_tmp_path)
888 else:
889 print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
890 shutil.rmtree(icu_tmp_path)
891 sys.exit(1)
892
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
893 # ICU mode. (icu-generic.gyp)
894 byteorder = sys.byteorder
895 o['variables']['icu_gyp_path'] = 'tools/icu/icu-generic.gyp'
896 # ICU source dir relative to root
897 o['variables']['icu_path'] = icu_full_path
898 if not os.path.isdir(icu_full_path):
a308395 @srl295 build: i18n: add icu config options
srl295 authored
899 print '* ECMA-402 (Intl) support didn\'t find ICU in %s..' % (icu_full_path)
900 # can we download (or find) a zipfile?
901 localzip = icu_download(icu_full_path)
902 if localzip:
903 nodedownload.unpack(localzip, icu_parent_path)
904 if not os.path.isdir(icu_full_path):
905 print ' Cannot build Intl without ICU in %s.' % (icu_full_path)
906 print ' (Fix, or disable with "--with-intl=none" )'
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
907 sys.exit(1)
a308395 @srl295 build: i18n: add icu config options
srl295 authored
908 else:
909 print '* Using ICU in %s' % (icu_full_path)
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
910 # Now, what version of ICU is it? We just need the "major", such as 54.
911 # uvernum.h contains it as a #define.
912 uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
913 if not os.path.isfile(uvernum_h):
a308395 @srl295 build: i18n: add icu config options
srl295 authored
914 print ' Error: could not load %s - is ICU installed?' % uvernum_h
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
915 sys.exit(1)
916 icu_ver_major = None
917 matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
918 match_version = re.compile(matchVerExp)
919 for line in open(uvernum_h).readlines():
920 m = match_version.match(line)
921 if m:
922 icu_ver_major = m.group(1)
923 if not icu_ver_major:
a308395 @srl295 build: i18n: add icu config options
srl295 authored
924 print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
925 sys.exit(1)
926 icu_endianness = sys.byteorder[0]; # TODO(srl295): EBCDIC should be 'e'
927 o['variables']['icu_ver_major'] = icu_ver_major
928 o['variables']['icu_endianness'] = icu_endianness
929 icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l')
930 icu_data_file = 'icudt%s%s.dat' % (icu_ver_major, icu_endianness)
931 # relative to configure
932 icu_data_path = os.path.join(icu_full_path,
933 'source/data/in',
934 icu_data_file_l)
935 # relative to dep..
936 icu_data_in = os.path.join('../../deps/icu/source/data/in', icu_data_file_l)
937 if not os.path.isfile(icu_data_path) and icu_endianness != 'l':
938 # use host endianness
939 icu_data_path = os.path.join(icu_full_path,
940 'source/data/in',
941 icu_data_file)
942 # relative to dep..
943 icu_data_in = os.path.join('icu/source/data/in',
944 icu_data_file)
945 # this is the input '.dat' file to use .. icudt*.dat
946 # may be little-endian if from a icu-project.org tarball
947 o['variables']['icu_data_in'] = icu_data_in
948 # this is the icudt*.dat file which node will be using (platform endianness)
949 o['variables']['icu_data_file'] = icu_data_file
950 if not os.path.isfile(icu_data_path):
a308395 @srl295 build: i18n: add icu config options
srl295 authored
951 print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
952 print ' See the README.md.'
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
953 # .. and we're not about to build it from .gyp!
954 sys.exit(1)
955 # map from variable name to subdirs
956 icu_src = {
957 'stubdata': 'stubdata',
958 'common': 'common',
959 'i18n': 'i18n',
960 'io': 'io',
961 'tools': 'tools/toolutil',
962 'genccode': 'tools/genccode',
963 'genrb': 'tools/genrb',
964 'icupkg': 'tools/icupkg',
965 }
966 # this creates a variable icu_src_XXX for each of the subdirs
967 # with a list of the src files to use
968 for i in icu_src:
969 var = 'icu_src_%s' % i
970 path = '../../deps/icu/source/%s' % icu_src[i]
f769d13 @srl295 build: i18n: move noisy variables to separate gypi
srl295 authored
971 icu_config['variables'][var] = glob_to_var('tools/icu', path)
972 # write updated icu_config.gypi with a bunch of paths
973 write(icu_config_name, do_not_edit +
974 pprint.pformat(icu_config, indent=2) + '\n')
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
975 return # end of configure_intl
9e32a7d @bnoordhuis build: add libicu i18n support
bnoordhuis authored
976
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
977 # determine the "flavor" (operating system) we're building for,
978 # leveraging gyp's GetFlavor function
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
979 flavor_params = {}
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
980 if (options.dest_os):
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
981 flavor_params['flavor'] = options.dest_os
982 flavor = GetFlavor(flavor_params)
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
983
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
984 output = {
1e738c5 @bnoordhuis build: make python executable configurable
bnoordhuis authored
985 'variables': { 'python': sys.executable },
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
986 'include_dirs': [],
987 'libraries': [],
988 'defines': [],
989 'cflags': [],
990 }
991
992 configure_node(output)
993 configure_libz(output)
bfd78b6 @sgallagher build: allow linking against system http_parser
sgallagher authored
994 configure_http_parser(output)
73ff653 @sgallagher build: allow linking against system c-ares
sgallagher authored
995 configure_cares(output)
38809e3 @sgallagher build: allow linking against system libuv
sgallagher authored
996 configure_libuv(output)
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
997 configure_v8(output)
998 configure_openssl(output)
841b7f5 @sblom Ease building with VS Express by checking in generated files.
sblom authored
999 configure_winsdk(output)
ac2857b @srl295 build, i18n: improve Intl build, add "--with-intl"
srl295 authored
1000 configure_intl(output)
cdc01fa @piranna configure: generate a fully statically linked exec
piranna authored
1001 configure_fullystatic(output)
5e4e8ec build: add android support
Linus Mårtensson authored
1002
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
1003 # variables should be a root level element,
1004 # move everything else to target_defaults
1005 variables = output['variables']
1006 del output['variables']
1007 output = {
1008 'variables': variables,
1009 'target_defaults': output
1010 }
624f70e @ry GYP: rename options.gypi to config.gypi
ry authored
1011 pprint.pprint(output, indent=2)
14b04b0 @ry Remove SCONS deprecate WAF
ry authored
1012
f769d13 @srl295 build: i18n: move noisy variables to separate gypi
srl295 authored
1013 write('config.gypi', do_not_edit +
c937f5b @bnoordhuis build: fix up style issues in configure script
bnoordhuis authored
1014 pprint.pformat(output, indent=2) + '\n')
e493b29 @bnoordhuis build: respect --debug configure switch
bnoordhuis authored
1015
7b6d3ce @bnoordhuis build: add ninja support to Makefile
bnoordhuis authored
1016 config = {
1017 'BUILDTYPE': 'Debug' if options.debug else 'Release',
1018 'USE_NINJA': str(int(options.use_ninja or 0)),
ac04716 @tjfontaine build: add configure option to generate xcode build files
tjfontaine authored
1019 'USE_XCODE': str(int(options.use_xcode or 0)),
1e738c5 @bnoordhuis build: make python executable configurable
bnoordhuis authored
1020 'PYTHON': sys.executable,
7b6d3ce @bnoordhuis build: add ninja support to Makefile
bnoordhuis authored
1021 }
85e4fc4 @tjfontaine build: Makefile should respect configure --prefix
tjfontaine authored
1022
1023 if options.prefix:
1024 config['PREFIX'] = options.prefix
1025
7b6d3ce @bnoordhuis build: add ninja support to Makefile
bnoordhuis authored
1026 config = '\n'.join(map('='.join, config.iteritems())) + '\n'
1027
1028 write('config.mk',
1029 '# Do not edit. Generated by the configure script.\n' + config)
97c9745 @ry Back to WAF
ry authored
1030
2905884 @tjfontaine build: pass --no-parallel by default to gyp
tjfontaine authored
1031 gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
b5e1619 @tjfontaine build: ./configure pass positional args to gyp
tjfontaine authored
1032
7b6d3ce @bnoordhuis build: add ninja support to Makefile
bnoordhuis authored
1033 if options.use_ninja:
b5e1619 @tjfontaine build: ./configure pass positional args to gyp
tjfontaine authored
1034 gyp_args += ['-f', 'ninja-' + flavor]
ac04716 @tjfontaine build: add configure option to generate xcode build files
tjfontaine authored
1035 elif options.use_xcode:
b5e1619 @tjfontaine build: ./configure pass positional args to gyp
tjfontaine authored
1036 gyp_args += ['-f', 'xcode']
99b737b @TooTallNate configure: respect the --dest-os flag consistently
TooTallNate authored
1037 elif flavor == 'win':
b5e1619 @tjfontaine build: ./configure pass positional args to gyp
tjfontaine authored
1038 gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
dc75232 @TooTallNate vcbuild: run the 'configure' script in vcbuild.bat
TooTallNate authored
1039 else:
b5e1619 @tjfontaine build: ./configure pass positional args to gyp
tjfontaine authored
1040 gyp_args += ['-f', 'make-' + flavor]
1041
1042 gyp_args += args
d5f13f6 @bnoordhuis build: use proper python interpreter
bnoordhuis authored
1043
69b122a @srl295 build: configure return exit status from gyp
srl295 authored
1044 sys.exit(subprocess.call(gyp_args))
Something went wrong with that request. Please try again.