Subject: bmake shell
To: None <tech-pkg@netbsd.org>
From: Jonathan Perkin <jonathan@perkin.org.uk>
List: tech-pkg
Date: 07/30/2003 16:03:35
--4SFOXa2GPu3tIq4H
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
The attached patch fixes quite a few issues I've had along the
road of getting bulk builds to work on SunOS, due to the default
/bin/sh being insufficient for some constructs used in pkgsrc:
-% cat Makefile
nt:
@if [ file1 -nt file2 ]; then \
echo file1 ; \
else \
echo file2 ; \
fi
not:
@if [ ! `true` ]; then \
echo false ; \
fi
-% bmake nt
/bin/sh: test: unknown operator -nt
*** Error code 1
-% bmake not
/bin/sh: test: argument expected
*** Error code 1
Switching to /bin/ksh fixes this, but I don't know whether there
are other systems which have a somewhat limited /bin/sh and need
a different shell as well.
Also, there may be make behaviour which I've not accounted for
(basically replaced all references to "sh" in the source with
specified shell). I didn't regenerate configure neither because
my autoconf is a lot newer and the diff is huge.
Cheers,
--
Jonathan Perkin <jonathan@perkin.org.uk>
BBC Internet Services http://www.perkin.org.uk/jonathan/
--4SFOXa2GPu3tIq4H
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bmake.diff"
Index: bootstrap
===================================================================
RCS file: /cvsroot/othersrc/bootstrap-pkgsrc/bootstrap,v
retrieving revision 1.68
diff -u -r1.68 bootstrap
--- bootstrap 2003/07/28 04:48:32 1.68
+++ bootstrap 2003/07/30 14:29:36
@@ -220,6 +220,7 @@
need_bsd_install=no
set_opsys=no
whoamiprog=/usr/ucb/whoami
+ makeshell=/bin/ksh
;;
*)
echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
@@ -379,7 +380,10 @@
fi
echo_msg "Installing bmake"
-run_cmd "(cd bmake; $shprog ./configure --prefix=$prefix --with-default-sys-path=$prefix/share/mk $configargs && make -f makefile.boot bootstrap && env BINDIR=$prefix/bin MANDIR=$prefix/man $BSTRAP_ENV ./bmake -f Makefile install)"
+if [ -z "$makeshell" ]; then
+ makeshell="/bin/sh"
+fi
+run_cmd "(cd bmake; $shprog ./configure --prefix=$prefix --with-default-shell=$makeshell --with-default-sys-path=$prefix/share/mk $configargs && make -f makefile.boot bootstrap && env BINDIR=$prefix/bin MANDIR=$prefix/man $BSTRAP_ENV ./bmake -f Makefile install)"
# bootstrap lukemftp
case "$DEBIAN" in
Index: bmake/compat.c
===================================================================
RCS file: /cvsroot/othersrc/bootstrap-pkgsrc/bmake/compat.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 compat.c
--- bmake/compat.c 2002/09/19 10:40:06 1.1.1.1
+++ bmake/compat.c 2003/07/30 14:29:36
@@ -266,7 +266,7 @@
* -e flag as well as -c if it's supposed to exit when it hits an
* error.
*/
- static char *shargv[4] = { "/bin/sh" };
+ static char *shargv[4] = { DEFSHELLPROG };
if (DEBUG(SHELL))
shargv[1] = (errCheck ? "-exc" : "-xc");
Index: bmake/configure.in
===================================================================
RCS file: /cvsroot/othersrc/bootstrap-pkgsrc/bmake/configure.in,v
retrieving revision 1.2
diff -u -r1.2 configure.in
--- bmake/configure.in 2003/02/20 18:25:20 1.2
+++ bmake/configure.in 2003/07/30 14:29:37
@@ -135,6 +135,16 @@
dnl
echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
dnl
+dnl Specify a default shell (useful for avoiding SunOS /bin/sh)
+dnl
+AC_ARG_WITH(default-shell,
+[ --with-default-shell=SHELL override default shell],
+[case "${withval}" in
+yes) AC_MSG_ERROR(bad value ${withval} given for bmake SHELL) ;;
+no) ;;
+*) CPPFLAGS="$CPPFLAGS \"-DDEFSHELLPROG=\\\"$with_default_shell\\\"\"" ;;
+esac])
+dnl
dnl Allow folk to control _PATH_DEFSYSPATH
dnl
AC_ARG_WITH(default-sys-path,
Index: bmake/main.c
===================================================================
RCS file: /cvsroot/othersrc/bootstrap-pkgsrc/bmake/main.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 main.c
--- bmake/main.c 2002/09/19 10:40:09 1.1.1.1
+++ bmake/main.c 2003/07/30 14:29:37
@@ -1305,7 +1305,7 @@
/*
* Set up arguments for shell
*/
- args[0] = "sh";
+ args[0] = DEFSHELLPROG;
args[1] = "-c";
args[2] = cmd;
args[3] = NULL;
@@ -1336,7 +1336,7 @@
(void) dup2(fds[1], 1);
(void) close(fds[1]);
- (void) execv("/bin/sh", args);
+ (void) execv(DEFSHELLPROG, args);
_exit(1);
/*NOTREACHED*/
Index: bmake/make-conf.h
===================================================================
RCS file: /cvsroot/othersrc/bootstrap-pkgsrc/bmake/make-conf.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 make-conf.h
--- bmake/make-conf.h 2002/09/19 10:40:06 1.1.1.1
+++ bmake/make-conf.h 2003/07/30 14:29:37
@@ -42,6 +42,10 @@
#define DEFSHELL 1 /* Bourne shell */
+#ifndef DEFSHELLPROG
+#define DEFSHELLPROG "/bin/sh" /* Sane default */
+#endif
+
/*
* DEFMAXJOBS
* DEFMAXLOCAL
--4SFOXa2GPu3tIq4H--