The patch below allows the Windows port of Make to be less restrictive
in what it permits to put into SHELL.  Specifically, you can now use
Make variables and functions in the value of SHELL.  This allows to do
various useful tricks, such as the following (lifted from an article
in the latest Dr Dobb's Journal):

    OLD_SHELL := $(SHELL)
    SHELL = $(warning [$@ ($^) ($?)])$(OLD_SHELL)

which causes Make to print, for each target it builds, the
prerequisites that caused rebuild of that target.

Does anyone see any problem with this?  The only problem I see is that
the extra expansion could have side effects, such as the warning (with
empty values of the target and prerequisites) being printed when SHELL
is redefined, not only when the targets are rebuilt.  But I think this
is mostly harmless, and it can be worked around by using another
indirection:

    w = warning
    OLD_SHELL := $(SHELL)
    SHELL = $($w [$@ ($^) ($?)])$(OLD_SHELL)

Compared with this minor annoyance, the benefits are quite
significant, I think.

WDYT?


2007-03-03  Eli Zaretskii  <[EMAIL PROTECTED]>

        * variable.c (do_variable_definition) [WINDOWS32]: If
        find_and_set_default_shell fails to find the new value of SHELL
        verbatim, run it thru allocated_variable_expand and try again.

--- variable.c~1        2006-03-09 00:15:08.000000000 +0200
+++ variable.c  2007-03-03 16:20:12.718750000 +0200
@@ -1187,6 +1187,16 @@ do_variable_definition (const struct flo
                                       flocp);
           no_default_sh_exe = 0;
         }
+      else if (find_and_set_default_shell (alloc_value = 
allocated_variable_expand (p)))
+        {
+          v = define_variable_in_set (varname, strlen (varname), alloc_value,
+                                      origin, flavor == f_recursive,
+                                      (target_var
+                                       ? current_variable_set_list->set
+                                       : NULL),
+                                      flocp);
+          no_default_sh_exe = 0;
+        }
       else
         v = lookup_variable (varname, strlen (varname));
     }


_______________________________________________
Make-w32 mailing list
Make-w32@gnu.org
http://lists.gnu.org/mailman/listinfo/make-w32

Reply via email to