From 7e6a56505a8d51eebefb324720d05d4545636770 Mon Sep 17 00:00:00 2001
From: Boris Gordon <boris@boztek.net>
Date: Sun, 15 Jan 2012 11:55:41 +1100
Subject: [PATCH] Issue #911722: Set default project subdir either in make
 file or as command line option.

---
 commands/make/make.drush.inc |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/commands/make/make.drush.inc b/commands/make/make.drush.inc
index 430dce0..27f20e9 100644
--- a/commands/make/make.drush.inc
+++ b/commands/make/make.drush.inc
@@ -44,6 +44,7 @@ function make_drush_command() {
       'translations' => 'Retrieve translations for the specified comma-separated list of language(s) if available for all projects.',
       'working-copy' => 'Preserves VCS directories, like .git, for projects downloaded using such methods.',
       'download-mechanism' => 'How to download files. Should be autodetected, but this is an override if it doesn\'t work. Options are "curl" and "make" (a native download method).',
+      'default-subdir' => 'Set a default sub directory under modules, themes and libraries to download projects to.',
     ),
     'topics' => array('docs-make', 'docs-make-example'),
   );
@@ -175,6 +176,7 @@ function drush_make_post_make($makefile = NULL, $build_path = NULL) {
 
 function make_projects($recursion, $contrib_destination, $info, $build_path) {
   $release_info = drush_get_option('release-info', 'updatexml');
+  $subdir_option = drush_get_option('default-subdir', '');
   drush_include_engine('release_info', $release_info);
 
   $projects = array();
@@ -201,9 +203,17 @@ function make_projects($recursion, $contrib_destination, $info, $build_path) {
       'contrib_destination' => $contrib_destination,
       'version'             => '',
       'location'            => drush_get_option('make-update-default-url', RELEASE_INFO_DEFAULT_URL),
-      'subdir'              => '',
       'directory_name'      => '',
     );
+
+    // If the project is not an install profile use a default subdir path when set.
+    // Prefer the make file setting over the command line option
+    $default_subdir = (!empty($info['defaults']['subdir'])) ? $info['defaults']['subdir'] : $subdir_option;
+    $subdir = array(
+      'subdir' => (($project['type'] != 'profile') ? $default_subdir : ''),
+    );
+    $project += $subdir;
+
     // If download components are specified, but not the download
     // type, default to git. Additionally, if the 'revision' parameter is
     // passed at the top level, this is short-hand for download revision.
-- 
1.7.7

