4b0146
diff --git a/configure.py b/configure.py
4b0146
index 895a0869cb..791c3e4a62 100755
4b0146
--- a/configure.py
4b0146
+++ b/configure.py
4b0146
@@ -722,6 +722,12 @@ parser.add_argument('--shared',
4b0146
     help='compile shared library for embedding node in another project. ' +
4b0146
          '(This mode is not officially supported for regular applications)')
4b0146
 
4b0146
+parser.add_argument('--libdir',
4b0146
+    action='store',
4b0146
+    dest='libdir',
4b0146
+    default='lib',
4b0146
+    help='a directory to install the shared library into')
4b0146
+
4b0146
 parser.add_argument('--without-v8-platform',
4b0146
     action='store_true',
4b0146
     dest='without_v8_platform',
4b0146
@@ -1293,6 +1299,7 @@ def configure_node(o):
4b0146
   o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)
4b0146
 
4b0146
   o['variables']['node_shared'] = b(options.shared)
4b0146
+  o['variables']['libdir'] = options.libdir
4b0146
   node_module_version = getmoduleversion.get_version()
4b0146
 
4b0146
   if options.dest_os == 'android':
4b0146
diff --git a/tools/install.py b/tools/install.py
4b0146
index 045d406d84..b3ef454199 100755
4b0146
--- a/tools/install.py
4b0146
+++ b/tools/install.py
4b0146
@@ -121,22 +121,19 @@ def subdir_files(path, dest, action):
4b0146
 
4b0146
 def files(action):
4b0146
   is_windows = sys.platform == 'win32'
4b0146
-  output_file = 'node'
4b0146
   output_prefix = 'out/Release/'
4b0146
+  output_libprefix = output_prefix
4b0146
 
4b0146
-  if 'false' == variables.get('node_shared'):
4b0146
-    if is_windows:
4b0146
-      output_file += '.exe'
4b0146
+  if is_windows:
4b0146
+    output_bin = 'node.exe'
4b0146
+    output_lib = 'node.dll'
4b0146
   else:
4b0146
-    if is_windows:
4b0146
-      output_file += '.dll'
4b0146
-    else:
4b0146
-      output_file = 'lib' + output_file + '.' + variables.get('shlib_suffix')
4b0146
+    output_bin = 'node'
4b0146
+    output_lib = 'libnode.' + variables.get('shlib_suffix')
4b0146
 
4b0146
-  if 'false' == variables.get('node_shared'):
4b0146
-    action([output_prefix + output_file], 'bin/' + output_file)
4b0146
-  else:
4b0146
-    action([output_prefix + output_file], 'lib/' + output_file)
4b0146
+  action([output_prefix + output_bin], 'bin/' + output_bin)
4b0146
+  if 'true' == variables.get('node_shared'):
4b0146
+    action([output_libprefix + output_lib], variables.get('libdir') + '/' + output_lib)
4b0146
 
4b0146
   if 'true' == variables.get('node_use_dtrace'):
4b0146
     action(['out/Release/node.d'], 'lib/dtrace/node.d')