Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/usr.bin/make



On Sat, 13 Oct 2007, Simon Gerraty wrote:
> >What about DEFSHELL or DEFSHELL_NAME for the basename or full path
> >of the default shell, and rename the existing DEFSHELL variable to
> >DEFSHELL_INDEX (an index into the shells[] array defined in job.c).
> 
> It would be nice to remove the need to know the index at all.

Does this look OK?  The configure script would need to change to fit in.

Index: config.h
===================================================================
--- config.h    9 Oct 2006 20:44:35 -0000       1.19
+++ config.h    14 Oct 2007 16:44:34 -0000
@@ -72,10 +72,6 @@
  *     from: @(#)config.h      8.1 (Berkeley) 6/6/93
  */
 
-#ifndef DEFSHELL
-#define        DEFSHELL        0       /* Bourne shell; see shells[] in job.c 
*/
-#endif
-
 /*
  * DEFMAXJOBS
  * DEFMAXLOCAL
Index: job.c
===================================================================
--- job.c       13 Oct 2007 20:01:33 -0000      1.132
+++ job.c       14 Oct 2007 16:44:35 -0000
@@ -201,14 +201,35 @@
 /*
  * Descriptions for various shells.
  *
- * DEFSHELL in config.h is usually 0, so shells[0] describes the
- * default shell.  If _BASENAME_DEFSHELL is not defined, then shells[0]
- * describes "sh".  If _BASENAME_DEFSHELL is defined, then shells[0]
- * decsribes whatever shell is named by _BASENAME_DEFSHELL, but this
- * shell is assumed to be sh-compatible.
+ * The build environment may set DEFSHELL_INDEX to one of
+ * DEFSHELL_INDEX_SH, DEFSHELL_INDEX_KSH, or DEFSHELL_INDEX_CSH, to
+ * select one of the prefedined shells as the default shell.
+ *
+ * Alternatively, the build environment may set DEFSHELL_NAME to the
+ * name or the full path of a sh-compatible shell, which will be used as
+ * the default shell.
+ *
+ * ".SHELL" lines in Makefiles can choose the default shell from the
+ # set defined here, or add additional shells.
  */
+
+#ifdef DEFSHELL_NAME
+#define DEFSHELL_INDEX_CUSTOM 0
+#define DEFSHELL_INDEX_SH     1
+#define DEFSHELL_INDEX_KSH    2
+#define DEFSHELL_INDEX_CSH    3
+#else /* !DEFSHELL_NAME */
+#define DEFSHELL_INDEX_SH     0
+#define DEFSHELL_INDEX_KSH    1
+#define DEFSHELL_INDEX_CSH    2
+#endif /* !DEFSHELL_NAME */
+
+#ifndef DEFSHELL_INDEX
+#define DEFSHELL_INDEX 0       /* DEFSHELL_INDEX_CUSTOM or DEFSHELL_INDEX_SH */
+#endif /* !DEFSHELL_INDEX */
+
 static Shell    shells[] = {
-#ifdef _BASENAME_DEFSHELL
+#ifdef DEFSHELL_NAME
     /*
      * An sh-compatible shell with a non-standard name.
      *
@@ -217,18 +238,16 @@
      * sh-compatible shells.
      */
 {
-    _BASENAME_DEFSHELL,
+    DEFSHELL_NAME,
     FALSE, "", "", "", 0,
     FALSE, "echo \"%s\"\n", "%s\n", "{ %s \n} || exit $?\n", "'\n'", '#',
     "",
     "",
 },
-#endif /* _BASENAME_DEFSHELL */
+#endif /* DEFSHELL_NAME */
     /*
      * SH description. Echo control is also possible and, under
      * sun UNIX anyway, one can even control error checking.
-     *
-     * This entry will be shells[0] if _BASENAME_DEFSHELL is not defined.
      */
 {
     "sh",
@@ -272,7 +291,7 @@
     NULL, NULL,
 }
 };
-static Shell   *commandShell = &shells[DEFSHELL];/* this is the shell to
+static Shell *commandShell = &shells[DEFSHELL_INDEX]; /* this is the shell to
                                                   * which we pass all
                                                   * commands in the Makefile.
                                                   * It is set by the
@@ -2029,10 +2048,10 @@
     if (shellPath == NULL) {
        /*
         * We are using the default shell, which may be an absolute
-        * path if _BASENAME_DEFSHELL is defined.
+        * path if DEFSHELL_NAME is defined.
         */
        shellName = commandShell->name;
-#ifdef _BASENAME_DEFSHELL
+#ifdef DEFSHELL_NAME
        if (*shellName == '/') {
            shellPath = shellName;
            shellName = strrchr(shellPath, '/');



Home | Main Index | Thread Index | Old Index