1*954401e6SSimon J. Gerraty# $NetBSD: varname-dot-make-mode.mk,v 1.3 2022/05/07 17:49:47 rillig Exp $ 22c3632d1SSimon J. Gerraty# 32c3632d1SSimon J. Gerraty# Tests for the special .MAKE.MODE variable. 42c3632d1SSimon J. Gerraty 5*954401e6SSimon J. Gerraty# TODO: test .MAKE.MODE "meta", or see meta mode tests. 6*954401e6SSimon J. Gerraty# TODO: test .MAKE.MODE "compat" 72c3632d1SSimon J. Gerraty 8*954401e6SSimon J. Gerraty 9*954401e6SSimon J. Gerraty# See Makefile, POSTPROC for the postprocessing that takes place. 10*954401e6SSimon J. Gerraty# See the .rawout file for the raw output before stripping the digits. 11*954401e6SSimon J. Gerratyall: .PHONY make-mode-randomize-targets 12*954401e6SSimon J. Gerraty 13*954401e6SSimon J. Gerraty 14*954401e6SSimon J. Gerraty# By adding the word "randomize-targets" to the variable .MAKE.MODE, the 15*954401e6SSimon J. Gerraty# targets are not made in declaration order, but rather in random order. This 16*954401e6SSimon J. Gerraty# mode helps to find undeclared dependencies between files. 17*954401e6SSimon J. Gerraty# 18*954401e6SSimon J. Gerraty# History 19*954401e6SSimon J. Gerraty# Added on 2022-05-07. 20*954401e6SSimon J. Gerraty# 21*954401e6SSimon J. Gerraty# See also 22*954401e6SSimon J. Gerraty# https://gnats.netbsd.org/45226 23*954401e6SSimon J. Gerratymake-mode-randomize-targets: .PHONY 24*954401e6SSimon J. Gerraty @echo "randomize compat mode:" 25*954401e6SSimon J. Gerraty @${MAKE} -r -f ${MAKEFILE} randomize-targets 26*954401e6SSimon J. Gerraty 27*954401e6SSimon J. Gerraty @echo "randomize jobs mode (-j1):" 28*954401e6SSimon J. Gerraty @${MAKE} -r -f ${MAKEFILE} -j1 randomize-targets 29*954401e6SSimon J. Gerraty 30*954401e6SSimon J. Gerraty @echo "randomize jobs mode (-j5):" 31*954401e6SSimon J. Gerraty @${MAKE} -r -f ${MAKEFILE} -j5 randomize-targets | grep '^:' 32*954401e6SSimon J. Gerraty 33*954401e6SSimon J. Gerraty.if make(randomize-targets) 34*954401e6SSimon J. Gerratyrandomize-targets: .WAIT a1 a2 a3 .WAIT b1 b2 b3 .WAIT c1 c2 c3 .WAIT 35*954401e6SSimon J. Gerratya1 a2 a3 b1 b2 b3 c1 c2 c3: 36*954401e6SSimon J. Gerraty : Making ${.TARGET} 37*954401e6SSimon J. Gerraty 38*954401e6SSimon J. Gerraty# .MAKE.MODE is evaluated after parsing all files, so it suffices to switch 39*954401e6SSimon J. Gerraty# the mode after defining the targets. 40*954401e6SSimon J. Gerraty.MAKE.MODE+= randomize-targets 41*954401e6SSimon J. Gerraty.endif 42