Subject: machine symlinks in stand dirs (Re: CVS commit: src/sys/arch/i386/stand)
To: None <christos@netbsd.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: tech-toolchain
Date: 05/07/2005 13:02:27
[moved from source-changes]

In article <20050505180304.B2D802DA27@cvs.netbsd.org> on source-changes
christos@netbsd.org wrote:

> Modified Files:
> 	src/sys/arch/i386/stand: Makefile.booters
> 	src/sys/arch/i386/stand/boot: Makefile.boot
> 	src/sys/arch/i386/stand/bootxx: Makefile.bootxx
> 
> Log Message:
> add dependall and realdepend to the targets that we need to call in the
> beginning. XXX: The real fix (handle dependencies in .BEGIN) is forthcoming.

Maybe beforedepend is enough here, but I think we should have
some common rules to create ${MACHINE_CPU} and ${MACHINE} symlinks
in these stand dirs.

Currently we have mostly two method (with several variants):

(1) create symlinks in .BEGIN rule (not dependency)
    if target is not obj, clean, or cleandir

sys/arch/pmax/stand/Makefile:
---
.if !make(obj) && !make(clean) && !make(cleandir)
.BEGIN:
	@[ -h machine ] || ln -s $S/arch/${MACHINE}/include machine
	@[ -h pmax ] || ln -s $S/arch/${MACHINE}/include pmax
	@[ -h mips ] || ln -s $S/arch/mips/include mips
.NOPATH: machine pmax mips
.endif
CLEANFILES+= machine pmax mips
---

sys/arch/acorn32/stand/Makefile.buildboot:
---
.if !make(obj) && !make(clean) && !make(cleandir)
.BEGIN:
	-rm -f machine ${MACHINE_ARCH}
	ln -s $S/arch/${MACHINE}/include machine
	ln -s $S/arch/${MACHINE_ARCH}/include ${MACHINE_ARCH}
.endif

CLEANFILES+= machine ${MACHINE_ARCH}
---


(2) create symlinks on target beforedepend and realall
    (or some specific targets)

sys/arch/cobalt/boot/Makefile:
---
.PHONY:		machine-links
beforedepend:	machine-links

machine-links:	machine cobalt mips
machine cobalt:
	-rm -f ${.TARGET}
	ln -s ${COBALT}/include ${.TARGET}

mips:
	-rm -f ${.TARGET}
	ln -s ${MIPS}/include ${.TARGET}

CLEANFILES+=	machine cobalt mips

realall: machine-links ${PROG}
---

sys/arch/mvme68k/stand/Makefile.booters:
---
CLEANFILES+= machine m68k

machine :
	-rm -f ${.TARGET}
	ln -s $S/arch/mvme68k/include machine

m68k :
	-rm -f ${.TARGET}
	ln -s $S/arch/m68k/include m68k

.if defined(LIB)

lib${LIB}.a:: machine m68k ${OBJS}
beforedepend:	machine m68k

.else

PROGDEPENDS?=	${SRTOBJ} ${BUGCRT} ${OBJS} ${LIBS}
PROGLINKOBJS?=	${PROGDEPENDS}

${PROG}: machine m68k ${PROGDEPENDS}
	${LD} -N -Ttext ${RELOC} -o $@ ${PROGLINKOBJS}
 :
---
(I'm not sure if .PHONY and .PATH are needed in the rule
 and why i386 has different rules, BTW)

The method (1) seems a bit ugly for me, but method (2)
doesn't create symlinks on specific targets.
("make exec.o" in sys/arch/i386/stand/boot/biosboot still fails)

Which is better? Or we should have another way?
---
Izumi Tsutsui