8 root_dir = os.path.dirname(__file__)
9 sys.path.insert(0, os.path.join(root_dir, 'deps', 'v8', 'tools'))
10 import utils # GuessArchitecture
13 parser = optparse.OptionParser()
15 parser.add_option("--debug",
18 help="Also build debug build")
20 parser.add_option("--prefix",
23 help="Select the install prefix (defaults to /usr/local)")
25 parser.add_option("--without-ssl",
28 help="Build without SSL")
30 parser.add_option("--without-snapshot",
32 dest="without_snapshot",
33 help="Build without snapshotting V8 libraries. You might want to set"
34 " this for cross-compiling. [Default: False]")
36 parser.add_option("--shared-v8",
39 help="Link to a shared V8 DLL instead of static linking")
41 parser.add_option("--shared-v8-includes",
43 dest="shared_v8_includes",
44 help="Directory containing V8 header files")
46 parser.add_option("--shared-v8-libpath",
48 dest="shared_v8_libpath",
49 help="A directory to search for the shared V8 DLL")
51 parser.add_option("--shared-v8-libname",
53 dest="shared_v8_libname",
54 help="Alternative lib name to link to (default: 'v8')")
56 parser.add_option("--openssl-includes",
58 dest="openssl_includes",
59 help="A directory to search for the OpenSSL includes")
61 parser.add_option("--openssl-libpath",
63 dest="openssl_libpath",
64 help="A directory to search for the OpenSSL libraries")
66 parser.add_option("--no-ssl2",
69 help="Disable OpenSSL v2")
71 parser.add_option("--shared-cares",
74 help="Link to a shared C-Ares DLL instead of static linking")
76 parser.add_option("--shared-cares-includes",
78 dest="shared_cares_includes",
79 help="Directory containing C-Ares header files")
81 parser.add_option("--shared-cares-libpath",
83 dest="shared_cares_libpath",
84 help="A directory to search for the shared C-Ares DLL")
86 parser.add_option("--with-dtrace",
89 help="Build with DTrace (experimental)")
91 # CHECKME does this still work with recent releases of V8?
92 parser.add_option("--gdb",
95 help="add gdb support")
97 parser.add_option("--dest-cpu",
100 help="CPU architecture to build for. Valid values are: arm, ia32, x64")
102 (options, args) = parser.parse_args()
106 cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
107 libs = cmd.readline().strip()
109 if (ret): return None
111 cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
112 cflags = cmd.readline().strip()
114 if (ret): return None
116 return (libs, cflags)
120 f = os.popen('uname %s' % switch)
127 """Host architecture. One of arm, ia32 or x64."""
130 if arch == 'unknown':
142 # TODO act on options.dest_cpu
146 def configure_node(o):
147 # TODO add gdb and dest_cpu
148 o['variables']['node_debug'] = 'true' if options.debug else 'false'
149 o['variables']['node_prefix'] = options.prefix if options.prefix else ''
150 o['variables']['node_use_dtrace'] = 'true' if options.with_dtrace else 'false'
151 o['variables']['host_arch'] = host_arch()
152 o['variables']['target_arch'] = target_arch()
154 # TODO move to node.gyp
155 if sys.platform == 'sunos5':
156 o['variables']['visibility'] = '' # FIXME -fvisibility=hidden, should be a gcc check
159 def configure_libz(o):
160 o['libraries'] += ['-lz']
164 o['variables']['v8_use_snapshot'] = 'true' if not options.without_snapshot else 'false'
165 o['variables']['node_shared_v8'] = 'true' if options.shared_v8 else 'false'
167 # assume shared_v8 if one of these is set?
168 if options.shared_v8_libpath:
169 o['libraries'] += ['-L%s' % options.shared_v8_libpath]
170 if options.shared_v8_libname:
171 o['libraries'] += ['-l%s' % options.shared_v8_libname]
172 if options.shared_v8_includes:
173 o['include_dirs'] += [options.shared_v8_includes]
176 def configure_cares(o):
177 o['variables']['node_shared_cares'] = 'true' if options.shared_cares else 'false'
179 # assume shared_cares if one of these is set?
180 if options.shared_cares_libpath:
181 o['libraries'] += ['-L%s' % options.shared_cares_libpath]
182 if options.shared_cares_includes:
183 o['include_dirs'] += [options.shared_cares_includes]
186 def configure_openssl(o):
187 o['variables']['node_use_openssl'] = 'false' if options.without_ssl else 'true'
189 if options.without_ssl:
193 o['defines'] += ['OPENSSL_NO_SSL2=1']
195 out = pkg_config('openssl')
196 (libs, cflags) = out if out else ('', '')
198 if options.openssl_libpath:
199 o['libraries'] += ['-L%s' % options.openssl_libpath, '-lssl', '-lcrypto']
201 o['libraries'] += libs.split()
203 if options.openssl_includes:
204 o['include_dirs'] += [options.openssl_includes]
206 o['cflags'] += cflags.split()
208 if libs or cflags or options.openssl_libpath or options.openssl_includes:
209 o['variables']['node_use_system_openssl'] = 'true'
211 o['variables']['node_use_system_openssl'] = 'false'
214 print "configure options:", options
224 configure_node(output)
225 configure_libz(output)
227 configure_cares(output)
228 configure_openssl(output)
230 # variables should be a root level element,
231 # move everything else to target_defaults
232 variables = output['variables']
233 del output['variables']
235 'variables': variables,
236 'target_defaults': output
239 fn = os.path.join(root_dir, 'options.gypi')
240 print "creating ", fn
243 f.write("# Do not edit. Generated by the configure script.\n")
244 json.dump(output, f, indent=2, skipkeys=True)