From a82e1d2bf3b5f2208ceddd1f5a51396a4997fb66 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 23 Oct 2012 10:27:19 -0400 Subject: [PATCH 2/3] build: allow linking against system c-ares --- configure | 35 +++++++++++++++++++++++++++++++++++ doc/api/process.markdown | 1 + node.gyp | 6 +++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 1fa522755de68a0eb182dde110b8c4a1a8f4aa7c..a23c04cb77fda65453e4cbe9c916d3d3f14f3d26 100755 --- a/configure +++ b/configure @@ -144,6 +144,26 @@ parser.add_option("--shared-http-parser-libname", dest="shared_http_parser_libname", help="Alternative lib name to link to (default: 'http_parser')") +parser.add_option("--shared-cares", + action="store_true", + dest="shared_cares", + help="Link to a shared cares DLL instead of static linking") + +parser.add_option("--shared-cares-includes", + action="store", + dest="shared_cares_includes", + help="Directory containing cares header files") + +parser.add_option("--shared-cares-libpath", + action="store", + dest="shared_cares_libpath", + help="A directory to search for the shared cares DLL") + +parser.add_option("--shared-cares-libname", + action="store", + dest="shared_cares_libname", + help="Alternative lib name to link to (default: 'cares')") + parser.add_option("--with-dtrace", action="store_true", dest="with_dtrace", @@ -434,6 +454,20 @@ def configure_http_parser(o): o['include_dirs'] += [options.shared_http_parser_includes] +def configure_cares(o): + o['variables']['node_shared_cares'] = b(options.shared_cares) + + # assume shared cares if one of these is set? + if options.shared_cares_libpath: + o['libraries'] += ['-L%s' % options.shared_cares_libpath] + if options.shared_cares_libname: + o['libraries'] += ['-l%s' % options.shared_cares_libname] + elif options.shared_cares: + o['libraries'] += ['-lcares'] + if options.shared_cares_includes: + o['include_dirs'] += [options.shared_cares_includes] + + def configure_v8(o): o['variables']['v8_use_snapshot'] = b(not options.without_snapshot) o['variables']['node_shared_v8'] = b(options.shared_v8) @@ -488,6 +522,7 @@ output = { configure_node(output) configure_libz(output) configure_http_parser(output) +configure_cares(output) configure_v8(output) configure_openssl(output) diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 41b163a15532f829a7d6c2b88ae9a9f31de0a9c8..1593eec879ff5141d13cee548df4675e9a18213c 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -299,6 +299,7 @@ An example of the possible output looks like: { host_arch: 'x64', node_install_npm: 'true', node_prefix: '', + node_shared_cares: 'false', node_shared_http_parser: 'false', node_shared_v8: 'false', node_shared_zlib: 'false', diff --git a/node.gyp b/node.gyp index a9903cd1c42cab4295d79d452ef1187c7fa7dbe3..ca1a9f30503c40099fe4d1770887750fb681d5b9 100644 --- a/node.gyp +++ b/node.gyp @@ -9,6 +9,7 @@ 'node_shared_v8%': 'false', 'node_shared_zlib%': 'false', 'node_shared_http_parser%': 'false', + 'node_shared_cares%': 'false', 'node_use_openssl%': 'true', 'node_shared_openssl%': 'false', 'library_files': [ @@ -58,7 +59,6 @@ 'type': 'executable', 'dependencies': [ - 'deps/cares/cares.gyp:cares', 'deps/uv/uv.gyp:libuv', 'node_js2c#host', ], @@ -196,6 +196,10 @@ 'dependencies': [ 'deps/http_parser/http_parser.gyp:http_parser' ], }], + [ 'node_shared_cares=="false"', { + 'dependencies': [ 'deps/cares/cares.gyp:cares' ], + }], + [ 'OS=="win"', { 'sources': [ 'src/res/node.rc', -- 1.8.0