You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/08/19 22:05:26 UTC

[2/2] git commit: Make recursive make more generic

Make recursive make more generic

Don't use GNU make or nmake features when calling make recursively. This
adds support for other make implementations like dmake.


Project: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/commit/c867a88e
Tree: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/tree/c867a88e
Diff: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/diff/c867a88e

Branch: refs/heads/solaris_fixes
Commit: c867a88eda1a73c55acfcdef33dedd2adb5a3fd4
Parents: 9798714
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Aug 19 21:58:23 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 19 21:58:23 2014 +0200

----------------------------------------------------------------------
 src/Charmonizer/Core/Make.c | 48 +++++++++++++++-------------------------
 1 file changed, 18 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/c867a88e/src/Charmonizer/Core/Make.c
----------------------------------------------------------------------
diff --git a/src/Charmonizer/Core/Make.c b/src/Charmonizer/Core/Make.c
index ef385c7..a5bd648 100644
--- a/src/Charmonizer/Core/Make.c
+++ b/src/Charmonizer/Core/Make.c
@@ -46,12 +46,10 @@ struct chaz_MakeFile {
 /* Static vars. */
 static struct {
     char *make_command;
-    int   is_gnu_make;
-    int   is_nmake;
     int   shell_type;
 } chaz_Make = {
     NULL,
-    0, 0, 0
+    0
 };
 
 /* Detect make command.
@@ -89,20 +87,13 @@ chaz_Make_init(void) {
     make = chaz_Make.make_command;
 
     if (make) {
-        if (strcmp(make, "make") == 0
-            || strcmp(make, "gmake") == 0
-            || strcmp(make, "mingw32-make") == 0
-            || strcmp(make, "mingw64-make") == 0
-           ) {
-            /* TODO: Add a feature test for GNU make. */
-            chaz_Make.is_gnu_make = 1;
-            /* TODO: Feature test which shell GNU make uses on Windows. */
-            chaz_Make.shell_type = CHAZ_OS_POSIX;
-        }
-        else if (strcmp(make, "nmake") == 0) {
-            chaz_Make.is_nmake = 1;
+        if (strcmp(make, "nmake") == 0) {
             chaz_Make.shell_type = CHAZ_OS_CMD_EXE;
         }
+        else {
+            /* TODO: Feature test which shell make uses on Windows. */
+            chaz_Make.shell_type = CHAZ_OS_POSIX;
+        }
     }
 }
 
@@ -645,34 +636,31 @@ chaz_MakeRule_add_make_command(chaz_MakeRule *rule, const char *dir,
                                const char *target) {
     char *command;
 
-    if (chaz_Make.is_gnu_make) {
+    if (chaz_Make.shell_type == CHAZ_OS_POSIX) {
         if (!target) {
-            command = chaz_Util_join(" ", "$(MAKE)", "-C", dir, NULL);
+            command = chaz_Util_join("", "(cd ", dir, " && $(MAKE))", NULL);
         }
         else {
-            command = chaz_Util_join(" ", "$(MAKE)", "-C", dir, target, NULL);
+            command = chaz_Util_join("", "(cd ", dir, " && $(MAKE) ", target,
+                                     ")", NULL);
         }
         chaz_MakeRule_add_command(rule, command);
         free(command);
     }
-    else if (chaz_Make.is_nmake) {
-        command = chaz_Util_join(" ", "cd", dir, NULL);
-        chaz_MakeRule_add_command(rule, command);
-        free(command);
-
+    else if (chaz_Make.shell_type == CHAZ_OS_CMD_EXE) {
         if (!target) {
-            chaz_MakeRule_add_command(rule, "$(MAKE) /nologo");
+            command = chaz_Util_join(" ", "pushd", dir, "&& $(MAKE) && popd",
+                                     NULL);
         }
         else {
-            command = chaz_Util_join(" ", "$(MAKE) /nologo", target, NULL);
-            chaz_MakeRule_add_command(rule, command);
-            free(command);
+            command = chaz_Util_join(" ", "pushd", dir, "&& $(MAKE)", target,
+                                     "&& popd", NULL);
         }
-
-        chaz_MakeRule_add_command(rule, "cd $(MAKEDIR)");
+        chaz_MakeRule_add_command(rule, command);
+        free(command);
     }
     else {
-        chaz_Util_die("Couldn't find a supported 'make' utility.");
+        chaz_Util_die("Unsupported shell type: %d", chaz_Make.shell_type);
     }
 }