Subject: obj.${MACHINE_ARCH} etc
To: None <tech-userlevel@netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: tech-userlevel
Date: 04/18/2001 13:38:44
One of the arguments against splitting up the arm32 port into lots of
little ports has been that it will make building binary snapshots slower,
since the current build system treats each MACHINE separately, putting
binaries in obj.${MACHINE}.  This means that it's not possible to take
advantage of all the work done in building (say) a dnard snapshot when
building an hpcarm snapshot in the same tree.  This is clearly silly.

Clearly (to me), what's needed is for builds of the same MACHINE_ARCH to
be able to share objdirs.  Clearly, also, this won't always be
appropriate.  Here's a way to achieve that:

We arrange that bsd.obj.mk create obj.${OBJDIRSUFFIX} rather than
obj.${MACHINE} if OBJDIRSUFFIX is defined.  It also symlinks
obj.${MACHINE} to obj.{$OBJDIRSUFFIX} so as to avoid the need to modify
make.  Any Makefile that knows that it's not doing anything
MACHINE-specific can define OBJDIRSUFFIX=${MACHINE_ARCH} and get to share
objdirs with builds for other systems.

A rough diff to bsd.obj.mk which seems to accomplish this is below.  Is
this the right way to be going about this?

Index: bsd.obj.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.obj.mk,v
retrieving revision 1.26
diff -u -u -r1.26 bsd.obj.mk
--- bsd.obj.mk	2001/03/11 07:32:31	1.26
+++ bsd.obj.mk	2001/04/18 12:26:11
@@ -5,6 +5,8 @@
 .include <bsd.own.mk>
 .endif

+OBJDIRSUFFIX ?= ${MACHINE}
+
 .if ${MKOBJ} == "no"
 obj:
 .else
@@ -28,18 +30,18 @@
 	fi
 .else
 .if defined(OBJMACHINE)
-__objdir=	obj.${MACHINE}
+__objdir=	obj.${OBJDIRSUFFIX}
 .else
 __objdir=	obj
 .endif

 .if defined(USR_OBJMACHINE)
-__usrobjdir=	${BSDOBJDIR}.${MACHINE}
+__usrobjdir=	${BSDOBJDIR}.${OBJDIRSUFFIX}
 __usrobjdirpf=
 .else
 __usrobjdir=	${BSDOBJDIR}
 .if defined(OBJMACHINE)
-__usrobjdirpf=	.${MACHINE}
+__usrobjdirpf=	.${OBJDIRSUFFIX}
 .else
 __usrobjdirpf=
 .endif
@@ -80,6 +82,11 @@
 			mkdir $$dest; \
 		fi ; \
 	fi;
+.if defined(OBJMACHINE) && ${OBJDIRSUFFIX} != ${MACHINE}
+	@echo "obj.${MACHINE} -> ${__objdir}"
+	@rm -f obj.${MACHINE}
+	@ln -s ${__objdir} obj.${MACHINE}
+.endif
 .endif
 .endif


-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>