Subject: obj.${MACHINE_ARCH}-${OBJECT_FMT}
To: None <tech-userlevel@netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: tech-userlevel
Date: 04/28/2001 16:19:47
As far as I can tell, the two problems people spotted with my last
suggestion about MACHINE_ARCH-specific objdirs[1] were that the default
should be to share objdirs within a MACHINE_ARCH, and that there would be
problems on sparc64, because of the particularly flexible way MACHINE_ARCH
is used there.  Another problem that occurred to me is that within a
MACHINE_ARCH, we might sometimes have different MACHINEs using different
object formats (e.g. the various m68k ports at the moment), so objdirs
should be named based on the (MACHINE_ARCH, OBJECT_FMT) tuple.

[1] <URL:http://mail-index.netbsd.org/tech-userlevel/2001/04/18/0002.html>

With that in mind, here's my current patch to bsd.obj.mk.  In the default
case, it creates obj.${MACHINE_ARCH}-${OBJECT_FMT}, and symlinks it from
obj.${MACHINE}.  sparc64 systems can flip between using obj.sparc-ELF and
obj.sparc64-ELF by changing MACHINE_ARCH and re-running "make obj", which
I suspect is a simple as it's going to get.  The only problem I can see
with this is that in the USR_OBJMACHINE case, you end up with
/usr/obj.i386 and /usr/obj.i386-ELF, which seems a bit odd, but I think is
a necessary consequence of coping with sparc64.

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/28 15:04:25
@@ -5,6 +5,8 @@
 .include <bsd.own.mk>
 .endif

+OBJDIRSUFFIX ?= ${MACHINE_ARCH}-${OBJECT_FMT}
+
 .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/>