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