Some weeks ago, I made a small modification to make(1) so that it could
be built to use a different shell for its work. It already seemed to
have the idea at least partially thought out and in the code, so it was
a naturally easy thing to finish implementing. The code will remain
exactly the same unless you set the following (e.g. in make.conf):
MAKE_SHELL=ksh
Well, it's been sitting in my tree for a while now, and there have been
0 problems with it. I use the ports and build worlds extensively, not
to mention having built everything which uses make(1) with this. The
pdksh is more than sufficiently Bourne (or shall I say compatible? It's
just a superset...) to support every single thing I've thrown at it.
Of course, it would be possible to use the real ksh with this patch, or
whatever ksh you want named "/bin/ksh".
I certainly don't mind adding more shells to the ${MAKE_SHELL} logic, but
so far have only done ksh because using pdksh as the ${MAKE_SHELL} does,
for me, result in about 10% faster make world time, and speeds port
building enormously (though port building speed has gotten faster with
some reason optimizations made to the Mk/bsd.port*.mk files).
I'd like to get public opinion on this change to see if many others will
find it useful. Note that the change also allows you to use "/bin/csh"
with MAKE_SHELL=csh, but you might not want to shoot yourself in the foot
like that :) Let me know if you find it useful to you; if people do find
it useful enough to have these make(1) speed increases, I'll commit it
to 5.0 and 4.0. It should also apply to 3.4, but I haven't tried it yet,
as my machines run -CURRENT.
Let me know what kind of results you have :) I'm interested in results
with the real Korn shell, zsh, or bash, as well; I'll specifically add
those to the logic if people have good results there.
Thanks for any feedback!
--
Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! /
[EMAIL PROTECTED] `------------------------------'
Index: Makefile
===================================================================
RCS file: /usr2/ncvs/src/usr.bin/make/Makefile,v
retrieving revision 1.13
diff -u -r1.13 Makefile
--- Makefile 1999/11/15 17:07:45 1.13
+++ Makefile 2000/02/04 05:34:37
@@ -12,4 +12,20 @@
lstMember.c lstNext.c lstOpen.c lstRemove.c lstReplace.c lstSucc.c
.PATH: ${.CURDIR}/lst.lib
+# Set the shell which make(1) uses. Bourne is the default, but a decent
+# Korn shell works fine, and much faster. Using the C shell for this
+# will almost certainly break everything, but it's Unix tradition to
+# allow you to shoot yourself in the foot if you want to :-)
+
+MAKE_SHELL?= sh
+.if ${MAKE_SHELL} == "csh"
+CFLAGS+= -DDEFSHELL=0
+.elif ${MAKE_SHELL} == "sh"
+CFLAGS+= -DDEFSHELL=1
+.elif ${MAKE_SHELL} == "ksh"
+CFLAGS+= -DDEFSHELL=2
+.else
+.error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"."
+.endif
+
.include <bsd.prog.mk>
Index: config.h
===================================================================
RCS file: /usr2/ncvs/src/usr.bin/make/config.h,v
retrieving revision 1.9
diff -u -r1.9 config.h
--- config.h 1999/09/10 20:51:59 1.9
+++ config.h 2000/02/04 05:23:52
@@ -39,8 +39,6 @@
* $FreeBSD: src/usr.bin/make/config.h,v 1.9 1999/09/10 20:51:59 julian Exp $
*/
-#define DEFSHELL 1 /* Bourne shell */
-
/*
* DEFMAXJOBS
* DEFMAXLOCAL
Index: job.c
===================================================================
RCS file: /usr2/ncvs/src/usr.bin/make/job.c,v
retrieving revision 1.17
diff -u -r1.17 job.c
--- job.c 2000/01/17 06:43:40 1.17
+++ job.c 2000/02/03 23:24:35
@@ -191,6 +191,16 @@
"v", "e",
},
/*
+ * KSH description. The Korn shell has a superset of
+ * the Bourne shell's functionality.
+ */
+{
+ "ksh",
+ TRUE, "set -", "set -v", "set -", 5,
+ TRUE, "set -e", "set +e",
+ "v", "e",
+},
+ /*
* UNKNOWN.
*/
{
Index: main.c
===================================================================
RCS file: /usr2/ncvs/src/usr.bin/make/main.c,v
retrieving revision 1.35
diff -u -r1.35 main.c
--- main.c 1999/11/23 10:35:24 1.35
+++ main.c 2000/03/25 20:02:54
@@ -483,6 +483,13 @@
/* avoid faults on read-only strings */
static char syspath[] = _PATH_DEFSYSPATH;
+#if DEFSHELL == 2
+ /*
+ * Turn off ENV to make ksh happier.
+ */
+ unsetenv("ENV");
+#endif
+
#ifdef RLIMIT_NOFILE
/*
* get rid of resource limit on file descriptors
@@ -1005,7 +1012,13 @@
(void) dup2(fds[1], 1);
(void) close(fds[1]);
+#if DEFSHELL == 1
(void) execv("/bin/sh", args);
+#elif DEFSHELL == 2
+ (void) execv("/bin/ksh", args);
+#else
+#error "DEFSHELL must be 1 or 2."
+#endif
_exit(1);
/*NOTREACHED*/