bmake

Introduction

In the past when building large software projects, I've had to ensure that GNU make (if not my own patched version of it), was installed and had developed a set of macros to greatly simplify delveloping complex build trees.

My main development machine for the last several years, runs 4.4BSD (NetBSD to be precise), and the BSD source tree is an excellent example of managing a large software project. In following NetBSD's -current delevlopment, I learned to use the new BSD Makefiles and make(1), I'll refer to it as bmake from here on. Since then all my new projects and many of my old ones use bmake. Since bmake.tar.gz uses GNU's autoconf and is quite portable, I've skipped the effort of making the rest of my distribution support GNU make.

It may be insteresting to note that much of my tree uses the same simple Makefile, it is:

# RCSid:
#	$Id: bmake.html,v 1.7 1998/10/30 11:28:49 sjg Exp $
#
#	@(#) Copyright (c) 1995 Simon J. Gerraty
#
#	This file is provided in the hope that it will
#	be of use.  There is absolutely NO WARRANTY.
#	Permission to copy, redistribute or otherwise
#	use this file is hereby granted provided that 
#	the above copyright notice and this notice are
#	left intact. 
#      
#	Please send copies of changes and bug-fixes to:
#	sjg@quick.com.au
#

# a totally generic makefile suits 90% of projects

PROG=	${.CURDIR:T}

SRCS=	$(PROG).c

.include "prog.mk"

macros

The example Makefile above, perhaps suggests why I like bmake(1). The important magic is in the line:
.include "prog.mk";
Makefiles for libraries inlcude lib.mk btw. Anyway, apart from reading a bunch of rules from the system macros (/usr/share/mk/* by default) it reads "../Makefile.inc" thus provinding a hook for much magic. My Makefile.inc files typically look for Makefile.${MACHINE}.inc as well. Note that I used to use the bsd.*.mk macros (intended for building /usr/src), but attempts to get simple portability improvments committed into these, usually failed, so the only viable solution is to maintain a parallel set.

obj

Another cool feature of bmake(1) is that if the directory obj exists in the same directory as the Makefile, then bmake will chdir into it before doing anything else. This helps keep the build tree clean, and if the obj directories are symlinks off to a separate file system, eg.
/usr/src/bin/cat/obj -> /usr/obj/bin/cat
then suddenly building for multiple architectures is very easy. Since I typically export my tree via NFS and want to gather the binaries into my configs tree, I use the following:

/usr/local/obj -> src/obj.${MACHINE}
and then I set:

BSDSRCDIR=`cd /usr/local/src; /bin/pwd`
BSDOBJDIR=/usr/local/obj
Note: You must set BSDSRCDIR with the same value that /bin/pwd produces as otherwise obj.mk will do the wrong thing.

MACHINE and MACHINE_ARCH

The variables MACHINE and MACHINE_ARCH are built into bmake. The script bmake/machine.sh is used to set it it from the output of uname(1).

bootstraping bmake

This is about all I ever need to do on a new machine:
$ mkdir /tmp/bmake
$ cd /tmp/bmake
$ /usr/local/src/sjg/bmake/configure
$ make -f makefile.boot
# /usr/local/src/sjg/bmake/install-sh -m755 /tmp/bmake /usr/local/bin
# mkdir /usr/local/share/mk
# cd /usr/local/src/sjg/bmake/mk
# ../install-sh [d-s]*.mk /usr/local/share/mk
# ../install-sh `uname`.sys.mk /usr/local/share/mk/sys.mk
Note that bmake/mk contains copies of bsd.*.mk too which should only be installed on non-4.4BSD systems.


$Id: bmake.html,v 1.7 1998/10/30 11:28:49 sjg Exp $
Copyright © 1997 QUICK.COM.AU