git: c2c7340fefe9 - stable/13 - release/Makefile.vm: Rework emulator-portinstall

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Tue, 05 Dec 2023 23:42:59 UTC
The branch stable/13 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=c2c7340fefe98db6917af02616c21b53db1d0d56

commit c2c7340fefe98db6917af02616c21b53db1d0d56
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2023-12-03 21:39:30 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2023-12-05 23:40:59 +0000

    release/Makefile.vm: Rework emulator-portinstall
    
    The emulator-portinstall target now unconditionally ensures that qemu
    is installed; but is only invoked if needed (aka. when cross building
    VM images).
    
    MFC After:      3 days
    MFC With:       97bd53ef4d20 ("Fix duplicate rc.conf files")
    
    (cherry picked from commit 7d0ee5ebd052d35e323f2d303e467c2cf305ca39)
---
 release/Makefile.vm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/release/Makefile.vm b/release/Makefile.vm
index 171ef227a7f0..27053208c689 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -53,8 +53,6 @@ ${_V}!=	eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo
 .endfor
 
 emulator-portinstall:
-.if ${TARGET_ARCH} != ${MACHINE_ARCH}
-.if ( ${TARGET_ARCH} != "i386" ) || ( ${MACHINE_ARCH} != "amd64" )
 .if !exists(/usr/local/bin/qemu-${TARGET_ARCH}-static)
 .if exists(${PORTSDIR}/emulators/qemu-user-static/Makefile)
 	env - UNAME_r=${UNAME_r} PATH=$$PATH make -C ${PORTSDIR}/emulators/qemu-user-static BATCH=1 all install clean
@@ -67,9 +65,13 @@ emulator-portinstall:
 .endif
 	touch ${.TARGET}
 
+.if ${TARGET_ARCH} != ${MACHINE_ARCH}
+.if ( ${TARGET_ARCH} != "i386" ) || ( ${MACHINE_ARCH} != "amd64" )
 QEMUSTATIC=/usr/local/bin/qemu-${TARGET_ARCH}-static
+QEMUTGT=emulator-portinstall
 .endif
 .endif
+QEMUTGT?=
 
 .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
 . for _CW in ${CLOUDWARE}
@@ -85,7 +87,7 @@ ${_CW:tu}IMAGE=	${_CW:tl}.${${_CW:tu}_FORMAT}
 ${_CW:tu}CONF?=	${.CURDIR}/tools/${_CW:tl}.conf
 .  endif
 
-cw-${_CW:tl}: emulator-portinstall
+cw-${_CW:tl}: ${QEMUTGT}
 	mkdir -p ${.OBJDIR}/${.TARGET}
 	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \
 		QEMUSTATIC=${QEMUSTATIC} \