I tried cross-building sparc64 from amd64 and failed when it looked for libsa.a in the wrong directory (obj.sparc64 instead of obj.amd64.sparc64). The diff below is inspired by src/sys/arch/amd64/stand/Makefile.inc, and applied to other arches that had similarly styled code.
I'd appreciate test reports to make sure this doesn't break native builds on any of the affected architectures (hp300, loongson, sgi, sparc, sparc64). Just a quick "make obj && make clean && make" in src/sys/arch/$MACHINE/stand should suffice. Thanks. Index: hp300/stand/Makefile.inc =================================================================== RCS file: /cvs/src/sys/arch/hp300/stand/Makefile.inc,v retrieving revision 1.9 diff -u -p hp300/stand/Makefile.inc --- hp300/stand/Makefile.inc 26 Nov 2007 10:01:42 -0000 1.9 +++ hp300/stand/Makefile.inc 14 Mar 2011 22:19:05 -0000 @@ -21,10 +21,8 @@ CPPFLAGS+= -DHEAP_LIMIT="0xffffdfff" ### Figure out what to use for libcommon COMMONDIR= ${.CURDIR}/../common -.if exists(${COMMONDIR}/obj.${MACHINE}) -COMMONOBJDIR= ${COMMONDIR}/obj.${MACHINE} -.elif exists(${COMMONDIR}/obj) -COMMONOBJDIR= ${COMMONDIR}/obj +.if exists(${COMMONDIR}/${__objdir}) +COMMONOBJDIR= ${COMMONDIR}/${__objdir} .else COMMONOBJDIR= ${COMMONDIR} .endif @@ -34,10 +32,8 @@ LIBCOMMON= ${COMMONOBJDIR}/libcommon.a ### Figure out what to use for libsa LIBSADIR= ${.CURDIR}/../libsa -.if exists(${LIBSADIR}/obj.${MACHINE}) -LIBSAOBJDIR= ${LIBSADIR}/obj.${MACHINE} -.elif exists(${LIBSADIR}/obj) -LIBSAOBJDIR= ${LIBSADIR}/obj +.if exists(${LIBSADIR}/${__objdir}) +LIBSAOBJDIR= ${LIBSADIR}/${__objdir} .else LIBSAOBJDIR= ${LIBSADIR} .endif @@ -47,10 +43,8 @@ LIBSA= ${LIBSAOBJDIR}/libsa.a ### Figure out what to use for libsaz LIBSAZDIR= ${.CURDIR}/../libsaz -.if exists(${LIBSAZDIR}/obj.${MACHINE}) -LIBSAZOBJDIR= ${LIBSAZDIR}/obj.${MACHINE} -.elif exists(${LIBSAZDIR}/obj) -LIBSAZOBJDIR= ${LIBSAZDIR}/obj +.if exists(${LIBSAZDIR}/${__objdir}) +LIBSAZOBJDIR= ${LIBSAZDIR}/${__objdir} .else LIBSAZOBJDIR= ${LIBSAZDIR} .endif @@ -60,10 +54,8 @@ LIBSAZ= ${LIBSAZOBJDIR}/libsaz.a ### Figure out what to use for libz LIBZDIR= ${.CURDIR}/../libz -.if exists(${LIBZDIR}/obj.${MACHINE}) -LIBZOBJDIR= ${LIBZDIR}/obj.${MACHINE} -.elif exists(${LIBZDIR}/obj) -LIBZOBJDIR= ${LIBZDIR}/obj +.if exists(${LIBZDIR}/${__objdir}) +LIBZOBJDIR= ${LIBZDIR}/${__objdir} .else LIBZOBJDIR= ${LIBZDIR} .endif @@ -73,10 +65,8 @@ LIBZ= ${LIBZOBJDIR}/libz.a ### Figure out what to use for mkboot MKBOOTDIR= ${.CURDIR}/../mkboot -.if exists(${MKBOOTDIR}/obj.${MACHINE}) -MKBOOTOBJDIR= ${MKBOOTDIR}/obj.${MACHINE} -.elif exists(${MKBOOTDIR}/obj) -MKBOOTOBJDIR= ${MKBOOTDIR}/obj +.if exists(${MKBOOTDIR}/${__objdir}) +MKBOOTOBJDIR= ${MKBOOTDIR}/${__objdir} .else MKBOOTOBJDIR= ${MKBOOTDIR} .endif @@ -86,10 +76,8 @@ MKBOOT_PROG= ${MKBOOTOBJDIR}/mkboot ### Figure out what to use for stripboot STRIPBOOTDIR= ${.CURDIR}/../stripboot -.if exists(${STRIPBOOTDIR}/obj.${MACHINE}) -STRIPBOOTOBJDIR= ${STRIPBOOTDIR}/obj.${MACHINE} -.elif exists(${STRIPBOOTDIR}/obj) -STRIPBOOTOBJDIR= ${STRIPBOOTDIR}/obj +.if exists(${STRIPBOOTDIR}/${__objdir}) +STRIPBOOTOBJDIR= ${STRIPBOOTDIR}/${__objdir} .else STRIPBOOTOBJDIR= ${STRIPBOOTDIR} .endif Index: loongson/stand/Makefile.inc =================================================================== RCS file: /cvs/src/sys/arch/loongson/stand/Makefile.inc,v retrieving revision 1.1 diff -u -p loongson/stand/Makefile.inc --- loongson/stand/Makefile.inc 14 Feb 2010 22:39:33 -0000 1.1 +++ loongson/stand/Makefile.inc 14 Mar 2011 22:19:05 -0000 @@ -25,10 +25,8 @@ LD?= ld ### Figure out what to use for libsa LIBSADIR?= ${.CURDIR}/../libsa -.if exists(${LIBSADIR}/obj.${MACHINE}) -LIBSAOBJDIR= ${LIBSADIR}/obj.${MACHINE} -.elif exists(${LIBSADIR}/obj) -LIBSAOBJDIR= ${LIBSADIR}/obj +.if exists(${LIBSADIR}/${__objdir}) +LIBSAOBJDIR= ${LIBSADIR}/${__objdir} .else LIBSAOBJDIR= ${LIBSADIR} .endif @@ -38,10 +36,8 @@ LIBSA= ${LIBSAOBJDIR}/libsa.a ### Figure out what to use for libz LIBZDIR?= ${.CURDIR}/../libz -.if exists(${LIBZDIR}/obj.${MACHINE}) -LIBZOBJDIR= ${LIBZDIR}/obj.${MACHINE} -.elif exists(${LIBZDIR}/obj) -LIBZOBJDIR= ${LIBZDIR}/obj +.if exists(${LIBZDIR}/${__objdir}) +LIBZOBJDIR= ${LIBZDIR}/${__objdir} .else LIBZOBJDIR= ${LIBZDIR} .endif Index: sgi/stand/Makefile.inc =================================================================== RCS file: /cvs/src/sys/arch/sgi/stand/Makefile.inc,v retrieving revision 1.6 diff -u -p sgi/stand/Makefile.inc --- sgi/stand/Makefile.inc 14 Sep 2010 14:28:05 -0000 1.6 +++ sgi/stand/Makefile.inc 14 Mar 2011 22:19:05 -0000 @@ -24,10 +24,8 @@ LIBSA_CPPFLAGS?= -DNEEDS_HEAP_H ### Figure out what to use for libsa LIBSADIR?= ${.CURDIR}/../libsa -.if exists(${LIBSADIR}/obj.${MACHINE}) -LIBSAOBJDIR= ${LIBSADIR}/obj.${MACHINE} -.elif exists(${LIBSADIR}/obj) -LIBSAOBJDIR= ${LIBSADIR}/obj +.if exists(${LIBSADIR}/${__objdir}) +LIBSAOBJDIR= ${LIBSADIR}/${__objdir} .else LIBSAOBJDIR= ${LIBSADIR} .endif @@ -37,10 +35,8 @@ LIBSA= ${LIBSAOBJDIR}/libsa.a ### Figure out what to use for libz LIBZDIR?= ${.CURDIR}/../libz -.if exists(${LIBZDIR}/obj.${MACHINE}) -LIBZOBJDIR= ${LIBZDIR}/obj.${MACHINE} -.elif exists(${LIBZDIR}/obj) -LIBZOBJDIR= ${LIBZDIR}/obj +.if exists(${LIBZDIR}/${__objdir}) +LIBZOBJDIR= ${LIBZDIR}/${__objdir} .else LIBZOBJDIR= ${LIBZDIR} .endif Index: sparc/stand/Makefile.inc =================================================================== RCS file: /cvs/src/sys/arch/sparc/stand/Makefile.inc,v retrieving revision 1.16 diff -u -p sparc/stand/Makefile.inc --- sparc/stand/Makefile.inc 29 Jun 2010 21:33:54 -0000 1.16 +++ sparc/stand/Makefile.inc 14 Mar 2011 22:19:05 -0000 @@ -48,10 +48,8 @@ DEFS= -DSTANDALONE -D_STANDALONE -DRELOC=${RELOC} -DS ### Figure out what to use for libsa LIBSADIR= ${.CURDIR}/../libsa -.if exists(${LIBSADIR}/obj.${MACHINE}) -LIBSAOBJDIR= ${LIBSADIR}/obj.${MACHINE} -.elif exists(${LIBSADIR}/obj) -LIBSAOBJDIR= ${LIBSADIR}/obj +.if exists(${LIBSADIR}/${__objdir}) +LIBSAOBJDIR= ${LIBSADIR}/${__objdir} .else LIBSAOBJDIR= ${LIBSADIR} .endif @@ -61,10 +59,8 @@ LIBSA= ${LIBSAOBJDIR}/libsa.a ### Figure out what to use for libz LIBZDIR= ${.CURDIR}/../libz -.if exists(${LIBZDIR}/obj.${MACHINE}) -LIBZOBJDIR= ${LIBZDIR}/obj.${MACHINE} -.elif exists(${LIBZDIR}/obj) -LIBZOBJDIR= ${LIBZDIR}/obj +.if exists(${LIBZDIR}/${__objdir}) +LIBZOBJDIR= ${LIBZDIR}/${__objdir} .else LIBZOBJDIR= ${LIBZDIR} .endif Index: sparc64/stand/Makefile.inc =================================================================== RCS file: /cvs/src/sys/arch/sparc64/stand/Makefile.inc,v retrieving revision 1.8 diff -u -p sparc64/stand/Makefile.inc --- sparc64/stand/Makefile.inc 26 Nov 2007 10:26:02 -0000 1.8 +++ sparc64/stand/Makefile.inc 14 Mar 2011 22:19:05 -0000 @@ -23,10 +23,8 @@ CFLAGS+= -fno-builtin-vprintf -fno-builtin-printf -fno ### Figure out what to use for libsa LIBSADIR= ${.CURDIR}/../libsa -.if exists(${LIBSADIR}/obj.${MACHINE}) -LIBSAOBJDIR= ${LIBSADIR}/obj.${MACHINE} -.elif exists(${LIBSADIR}/obj) -LIBSAOBJDIR= ${LIBSADIR}/obj +.if exists(${LIBSADIR}/${__objdir}) +LIBSAOBJDIR= ${LIBSADIR}/${__objdir} .else LIBSAOBJDIR= ${LIBSADIR} .endif @@ -36,10 +34,8 @@ LIBSA= ${LIBSAOBJDIR}/libsa.a ### Figure out what to use for libz LIBZDIR= ${.CURDIR}/../libz -.if exists(${LIBZDIR}/obj.${MACHINE}) -LIBZOBJDIR= ${LIBZDIR}/obj.${MACHINE} -.elif exists(${LIBZDIR}/obj) -LIBZOBJDIR= ${LIBZDIR}/obj +.if exists(${LIBZDIR}/${__objdir}) +LIBZOBJDIR= ${LIBZDIR}/${__objdir} .else LIBZOBJDIR= ${LIBZDIR} .endif