Subject: Re: bmake and bootstrap and own.mk and MKCONF
To: Simon J. Gerraty <sjg@crufty.net>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 10/06/2005 15:04:44
>
> My preference is to only add functionality to make.
> Thus, the only difference b/w make and bmake should be those needed to
> support autoconf.  Send me the diffs and I'll take a look.

These are against bmake-20050901.tar.gz.

Please use http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/bootstrap/bmake/ to 
see the commit messages for information about most of these changes.

diff -pruN tmp/bmake/Makefile.in devel/bmake/files/Makefile.in
--- tmp/bmake/Makefile.in	2005-09-03 16:06:32.000000000 -0700
+++ devel/bmake/files/Makefile.in	2005-09-16 16:14:17.000000000 -0700
@@ -32,7 +32,9 @@ MACHINE_ARCH=@machine_arch@
  CFLAGS+= -I. -I${srcdir} @DEFS@ @CPPFLAGS@ ${XDEFS} -DMAKE_NATIVE
  CFLAGS+= ${CFLAGS_${.TARGET:T}}
  CFLAGS_main.o= "-DMAKE_VERSION=\"${MAKE_VERSION}\""
+LDFLAGS= @LDFLAGS@
  LIBOBJS= @LIBOBJS@
+LDADD= @LIBS@

  .PATH:	${srcdir}
  .PATH:	${srcdir}/lst.lib
@@ -51,7 +53,7 @@ SUBDIR=	PSD.doc
  .endif
  .endif

-.if (${OS} != "NetBSD" && ${OS} != "FreeBSD" && ${OS} != "OpenBSD")
+.if (${OS} != "NetBSD" && ${OS} != "FreeBSD" && ${OS} != "OpenBSD" && ${OS} != "DragonFly")
  # XXX not sure if we still want this given that configure
  # lets us force or not the definition of MACHINE.
  CFLAGS_main.o+= "-DFORCE_MACHINE=\"${MACHINE}\""
@@ -105,7 +107,7 @@ ${MAN}:	make.1
  BINDIR= ${prefix}/bin
  MANDIR= ${prefix}/man

-.if ${OS} == "FreeBSD" || ${OS} == "OpenBSD"
+.if ${OS} == "FreeBSD" || ${OS} == "OpenBSD" || ${OS} == "DragonFly"
  # freebsd's bsd.man.mk works differently
  MAN1=${MAN}
  MANDIR= ${prefix}/man/man
diff -pruN tmp/bmake/machine.sh devel/bmake/files/machine.sh
--- tmp/bmake/machine.sh	2003-07-10 23:16:35.000000000 -0700
+++ devel/bmake/files/machine.sh	2005-09-16 16:37:08.000000000 -0700
@@ -32,7 +32,8 @@ esac
  # Great! Solaris keeps moving arch(1)
  # we need this here, and it is not always available...
  Which() {
-	for d in `IFS=:; echo ${2:-$PATH}`
+	pathcomponents=`IFS=:; echo ${2:-$PATH}`
+	for d in ${pathcomponents}
  	do
  		test -x $d/$1 && { echo $d/$1; break; }
  	done
@@ -58,6 +59,17 @@ SunOS)
  HP-UX)
  	MACHINE_ARCH=`IFS="/-."; set $machine; echo $1`
  	;;
+IRIX)
+	MACHINE_ARCH=`uname -p 2>/dev/null`
+	;;
+Interix)
+	MACHINE=i386
+	MACHINE_ARCH=i386
+	;;
+UnixWare)
+	OSREL=`uname -v`
+	OSMAJOR=`IFS=.; set $OSREL; echo $1`
+	;;
  Linux)
          case "$machine" in
  	i?86) MACHINE_ARCH=i386;;# does anyone really care about 686 vs 586?
diff -pruN tmp/bmake/main.c devel/bmake/files/main.c
--- tmp/bmake/main.c	2005-09-03 15:15:08.000000000 -0700
+++ devel/bmake/files/main.c	2005-09-16 16:40:19.000000000 -0700
@@ -1136,7 +1136,16 @@ ReadMakefile(ClientData p, ClientData q
  		Parse_File("(stdin)", stdin);
  		Var_Set("MAKEFILE", "", VAR_GLOBAL, 0);
  	} else {
+#ifdef __INTERIX
+		/* XXX tv: Hack pending a fix to bsd.pkg.mk to use some other
+		   variable name than this.  When using a NFS pkgsrc repository,
+		   bmake thinks "makefile" exists when running under "su" even
+		   though the filesystem is mounted case-sensitive on the
+		   non-su side.  This hoses all sorts of fun things. */
+		setMAKEFILE = FALSE;
+#else
  		setMAKEFILE = strcmp(fname, ".depend");
+#endif

  		/* if we've chdir'd, rebuild the path name */
  		if (strcmp(curdir, objdir) && *fname != '/') {
diff -pruN tmp/bmake/makefile.boot.in devel/bmake/files/makefile.boot.in
--- tmp/bmake/makefile.boot.in	2004-05-08 10:56:10.000000000 -0700
+++ devel/bmake/files/makefile.boot.in	2005-09-17 14:26:30.000000000 -0700
@@ -22,7 +22,7 @@ OBJ=arch.o buf.o compat.o cond.o dir.o f

  BMAKE_ENV= CC="$(CC)" MAKEFLAGS= MAKESYSPATH=`pwd`/mk:${MKSRC}:${MK}:${DEFAULT_MAKESYSPATH}

-bootstrap:	bmake.boot .mk.done
+bootstrap:	bmake.boot
  	${BMAKE_ENV} ./bmake.boot -f Makefile
  	${BMAKE_ENV} `pwd`/bmake -f Makefile test

@@ -33,7 +33,7 @@ bmake:	bmake.boot

  bmake.boot: ${OBJ}
  	(cd lst.lib; $(MAKE) -f makefile.boot CC="$(CC)" CFLAGS="-I.. -I../${srcdir} -I${srcdir} ${CFLAGS}" )
-	${CC} *.o lst.lib/*.o -o $@ @LIBS@
+	${CC} *.o lst.lib/*.o -o $@ @LDFLAGS@ @LIBS@
  	rm -f *.[ado] */*.[ado]


diff -pruN tmp/bmake/ranlib.h devel/bmake/files/ranlib.h
--- tmp/bmake/ranlib.h	2002-09-16 16:16:15.000000000 -0700
+++ devel/bmake/files/ranlib.h	2005-09-16 16:42:51.000000000 -0700
@@ -10,7 +10,7 @@
   * The ran_strx fields index the string table whose first byte is numbered 0.
   */

-#ifndef IRIX
+#if !defined(IRIX) && !defined(__digital__)
  #ifndef _ranlib_h
  #define _ranlib_h

diff -pruN tmp/bmake/sigcompat.c devel/bmake/files/sigcompat.c
--- tmp/bmake/sigcompat.c	2002-11-25 23:53:06.000000000 -0800
+++ devel/bmake/files/sigcompat.c	2005-09-16 16:44:06.000000000 -0700
@@ -103,6 +103,7 @@ static char *rcsid = "$Id: sigcompat.c,v

  #undef signal
  #include <stdio.h>
+#include <string.h>
  #include <sys/param.h>
  #include <sys/cdefs.h>
  #include "assert.h"
diff -pruN tmp/bmake/trace.h devel/bmake/files/trace.h
--- tmp/bmake/trace.h	2001-03-05 13:02:25.000000000 -0800
+++ devel/bmake/files/trace.h	2005-09-16 16:44:59.000000000 -0700
@@ -47,7 +47,7 @@ typedef enum {
  	MAKEERROR,
  	JOBSTART,
  	JOBEND,
-	MAKEINTR,
+	MAKEINTR
  } TrEvent;

  void Trace_Init(const char *);
diff -pruN tmp/bmake/var.c devel/bmake/files/var.c
--- tmp/bmake/var.c	2005-09-03 15:15:09.000000000 -0700
+++ devel/bmake/files/var.c	2005-09-16 16:48:52.000000000 -0700
@@ -125,7 +125,16 @@ __RCSID("$NetBSD: var.c,v 1.100 2005/08/

  #ifndef NO_REGEX
  #include    <sys/types.h>
+#include    <nbcompat/nbconfig.h>
+/* bmake supplies its own <sys/cdefs.h> so this header is always present. */
+#ifndef HAVE_SYS_CDEFS_H
+#define HAVE_SYS_CDEFS_H 1
+#endif
+#if HAVE_REGEX_H
  #include    <regex.h>
+#else
+#include    <nbcompat/regex.h>
+#endif
  #endif
  #include    <ctype.h>
  #include    <stdlib.h>


  Jeremy C. Reed

  	  	 	 Media Relations and Publishing Services
 	  	 	 http://www.reedmedia.net/