bsd.obj.mk does not set CANONICALOBJDIR correctly when TARGET_ARCH and MAKEOBJDIRPREFIX are set

Doug Barton dougb at dougbarton.us
Fri Jan 2 08:08:56 UTC 2009


In working on cross-platform support for mergemaster I came across the
following problem. I set MAKEOBJDIRPREFIX to be that of the temproot
environment, which works fine when you do not specify a TARGET_ARCH.
When you do specify TARGET_ARCH there is a conflict between
src/Makefile.inc1 and share/mk/bsd.obj.mk. The former does this:

.if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
OBJTREE=        ${MAKEOBJDIRPREFIX}
.else
OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
.endif

however the latter does this:

.if defined(MAKEOBJDIRPREFIX)
CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
.else
CANONICALOBJDIR:=/usr/obj${.CURDIR}
.endif

When trying to install the stuff in src/etc/sendmail install(1) cannot
find the file because it is built in <foo>/obj but it's looking for it
in <foo>/obj/$target

The simplest fix I found was to do the following in bsd.obj.mk:

Index: bsd.obj.mk
===================================================================
--- bsd.obj.mk	(revision 186676)
+++ bsd.obj.mk	(working copy)
@@ -43,7 +43,7 @@
 .include <bsd.own.mk>

 .if defined(MAKEOBJDIRPREFIX)
-CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
+CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
 .else
 CANONICALOBJDIR:=/usr/obj${.CURDIR}
 .endif

However I would be happy with any solution that makes it work. It's
trivial to test with 'mergemaster -i -D</temp/dir/for/root> -A arm'


Doug


More information about the freebsd-hackers mailing list