1*06b9b3e0SSimon J. Gerraty# $NetBSD: sh-flags.mk,v 1.4 2020/12/12 12:19:18 rillig Exp $ 2*06b9b3e0SSimon J. Gerraty# 3*06b9b3e0SSimon J. Gerraty# Tests for the effective RunFlags of a shell command (run/skip, echo/silent, 4*06b9b3e0SSimon J. Gerraty# error check, trace), which are controlled by 12 different switches. These 5*06b9b3e0SSimon J. Gerraty# switches interact in various non-obvious ways. To analyze the interactions, 6*06b9b3e0SSimon J. Gerraty# this test runs each possible combination of these switches, for now. 7*06b9b3e0SSimon J. Gerraty# 8*06b9b3e0SSimon J. Gerraty# As soon as an interaction of switches is identified as obvious and expected, 9*06b9b3e0SSimon J. Gerraty# this particular interaction may be removed from the test, to focus on the 10*06b9b3e0SSimon J. Gerraty# remaining ones. 11*06b9b3e0SSimon J. Gerraty# 12*06b9b3e0SSimon J. Gerraty# See also: 13*06b9b3e0SSimon J. Gerraty# Compat_RunCommand 14*06b9b3e0SSimon J. Gerraty# JobPrintSpecials 15*06b9b3e0SSimon J. Gerraty 16*06b9b3e0SSimon J. Gerratyall: .PHONY 17*06b9b3e0SSimon J. Gerraty 18*06b9b3e0SSimon J. Gerratyopt-ignerr.yes= -i 19*06b9b3e0SSimon J. Gerratyopt-jobs.yes= -j1 20*06b9b3e0SSimon J. Gerratyopt-loud.no= -d0 # side effect: make stdout unbuffered 21*06b9b3e0SSimon J. Gerratyopt-loud.yes= -dl # side effect: make stdout unbuffered 22*06b9b3e0SSimon J. Gerratyopt-no-action.yes= -n 23*06b9b3e0SSimon J. Gerratyopt-silent.yes= -s 24*06b9b3e0SSimon J. Gerratyopt-xtrace.yes= -dx 25*06b9b3e0SSimon J. Gerratytgt-always.yes= .MAKE 26*06b9b3e0SSimon J. Gerratytgt-ignerr.yes= .IGNORE 27*06b9b3e0SSimon J. Gerratytgt-silent.yes= .SILENT 28*06b9b3e0SSimon J. Gerratycmd-always.yes= + 29*06b9b3e0SSimon J. Gerratycmd-ignerr.yes= - 30*06b9b3e0SSimon J. Gerratycmd-silent.yes= @ 31*06b9b3e0SSimon J. Gerraty 32*06b9b3e0SSimon J. Gerratyletter.always.yes= a 33*06b9b3e0SSimon J. Gerratyletter.ignerr.yes= i 34*06b9b3e0SSimon J. Gerratyletter.jobs.yes= j 35*06b9b3e0SSimon J. Gerratyletter.loud.yes= l 36*06b9b3e0SSimon J. Gerratyletter.no-action.yes= n 37*06b9b3e0SSimon J. Gerratyletter.silent.yes= s 38*06b9b3e0SSimon J. Gerratyletter.xtrace.yes= x 39*06b9b3e0SSimon J. Gerraty 40*06b9b3e0SSimon J. Gerraty.if !defined(OPT_TARGET) 41*06b9b3e0SSimon J. Gerraty.for opt-ignerr in no yes 42*06b9b3e0SSimon J. Gerraty.for opt-jobs in no yes 43*06b9b3e0SSimon J. Gerraty.for opt-loud in no yes 44*06b9b3e0SSimon J. Gerraty.for opt-no-action in no yes 45*06b9b3e0SSimon J. Gerraty# Only 'no', not 'yes', since job->echo is based trivially on opts.silent. 46*06b9b3e0SSimon J. Gerraty.for opt-silent in no 47*06b9b3e0SSimon J. Gerraty# Only 'no', not 'yes', since that would add uncontrollable output from 48*06b9b3e0SSimon J. Gerraty# reading /etc/profile or similar files. 49*06b9b3e0SSimon J. Gerraty.for opt-xtrace in no 50*06b9b3e0SSimon J. Gerraty 51*06b9b3e0SSimon J. Gerratytarget= opt- 52*06b9b3e0SSimon J. Gerratytarget+= ${letter.ignerr.${opt-ignerr}:U_} 53*06b9b3e0SSimon J. Gerratytarget+= ${letter.jobs.${opt-jobs}:U_} 54*06b9b3e0SSimon J. Gerratytarget+= ${letter.loud.${opt-loud}:U_} 55*06b9b3e0SSimon J. Gerratytarget+= ${letter.no-action.${opt-no-action}:U_} 56*06b9b3e0SSimon J. Gerratytarget+= ${letter.silent.${opt-silent}:U_} 57*06b9b3e0SSimon J. Gerratytarget+= ${letter.xtrace.${opt-xtrace}:U_} 58*06b9b3e0SSimon J. Gerraty 59*06b9b3e0SSimon J. Gerraty.for target in ${target:ts} 60*06b9b3e0SSimon J. Gerraty 61*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}= ${MAKE} 62*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= ${opt-ignerr.${opt-ignerr}} 63*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= ${opt-jobs.${opt-jobs}} 64*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= ${opt-loud.${opt-loud}} 65*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= ${opt-no-action.${opt-no-action}} 66*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= ${opt-silent.${opt-silent}} 67*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= ${opt-xtrace.${opt-xtrace}} 68*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= -f ${MAKEFILE} 69*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= OPT_TARGET=${target} 70*06b9b3e0SSimon J. GerratyMAKE_CMD.${target}+= ${target} 71*06b9b3e0SSimon J. Gerraty 72*06b9b3e0SSimon J. Gerratyall: ${target} 73*06b9b3e0SSimon J. Gerraty${target}: .PHONY 74*06b9b3e0SSimon J. Gerraty @${MAKE_CMD.${target}:M*} 75*06b9b3e0SSimon J. Gerraty 76*06b9b3e0SSimon J. Gerraty.endfor 77*06b9b3e0SSimon J. Gerraty.endfor 78*06b9b3e0SSimon J. Gerraty.endfor 79*06b9b3e0SSimon J. Gerraty.endfor 80*06b9b3e0SSimon J. Gerraty.endfor 81*06b9b3e0SSimon J. Gerraty.endfor 82*06b9b3e0SSimon J. Gerraty.endfor 83*06b9b3e0SSimon J. Gerraty.endif 84*06b9b3e0SSimon J. Gerraty 85*06b9b3e0SSimon J. GerratySILENT.yes= @ 86*06b9b3e0SSimon J. GerratyALWAYS.yes= + 87*06b9b3e0SSimon J. GerratyIGNERR.yes= - 88*06b9b3e0SSimon J. Gerraty 89*06b9b3e0SSimon J. Gerraty.if defined(OPT_TARGET) 90*06b9b3e0SSimon J. Gerraty.for tgt-always in no yes 91*06b9b3e0SSimon J. Gerraty.for tgt-ignerr in no yes 92*06b9b3e0SSimon J. Gerraty.for tgt-silent in no yes 93*06b9b3e0SSimon J. Gerraty.for cmd-always in no yes 94*06b9b3e0SSimon J. Gerraty.for cmd-ignerr in no yes 95*06b9b3e0SSimon J. Gerraty.for cmd-silent in no yes 96*06b9b3e0SSimon J. Gerraty 97*06b9b3e0SSimon J. Gerratytarget= ${OPT_TARGET}-tgt- 98*06b9b3e0SSimon J. Gerratytarget+= ${letter.always.${tgt-always}:U_} 99*06b9b3e0SSimon J. Gerratytarget+= ${letter.ignerr.${tgt-ignerr}:U_} 100*06b9b3e0SSimon J. Gerratytarget+= ${letter.silent.${tgt-silent}:U_} 101*06b9b3e0SSimon J. Gerratytarget+= -cmd- 102*06b9b3e0SSimon J. Gerratytarget+= ${letter.always.${cmd-always}:U_} 103*06b9b3e0SSimon J. Gerratytarget+= ${letter.ignerr.${cmd-ignerr}:U_} 104*06b9b3e0SSimon J. Gerratytarget+= ${letter.silent.${cmd-silent}:U_} 105*06b9b3e0SSimon J. Gerraty 106*06b9b3e0SSimon J. Gerraty.for target in ${target:ts} 107*06b9b3e0SSimon J. Gerraty 108*06b9b3e0SSimon J. Gerraty${OPT_TARGET}: .WAIT ${target} .WAIT 109*06b9b3e0SSimon J. Gerraty.if ${tgt-always} == yes 110*06b9b3e0SSimon J. Gerraty${target}: .MAKE 111*06b9b3e0SSimon J. Gerraty.endif 112*06b9b3e0SSimon J. Gerraty.if ${tgt-ignerr} == yes 113*06b9b3e0SSimon J. Gerraty${target}: .IGNORE 114*06b9b3e0SSimon J. Gerraty.endif 115*06b9b3e0SSimon J. Gerraty.if ${tgt-silent} == yes 116*06b9b3e0SSimon J. Gerraty${target}: .SILENT 117*06b9b3e0SSimon J. Gerraty.endif 118*06b9b3e0SSimon J. Gerraty 119*06b9b3e0SSimon J. GerratyRUNFLAGS.${target}= ${SILENT.${cmd-silent}}${ALWAYS.${cmd-always}}${IGNERR.${cmd-ignerr}} 120*06b9b3e0SSimon J. Gerraty.if ${OPT_TARGET:M*i*} || ${tgt-ignerr} == yes || ${cmd-ignerr} == yes 121*06b9b3e0SSimon J. GerratyCMD.${target}= echo running; false 122*06b9b3e0SSimon J. Gerraty.else 123*06b9b3e0SSimon J. GerratyCMD.${target}= echo running 124*06b9b3e0SSimon J. Gerraty.endif 125*06b9b3e0SSimon J. Gerraty 126*06b9b3e0SSimon J. Gerraty${target}: .PHONY 127*06b9b3e0SSimon J. Gerraty @+echo hide-from-output 128*06b9b3e0SSimon J. Gerraty @+echo hide-from-output ${target} 129*06b9b3e0SSimon J. Gerraty ${RUNFLAGS.${target}} ${CMD.${target}} 130*06b9b3e0SSimon J. Gerraty.endfor 131*06b9b3e0SSimon J. Gerraty 132*06b9b3e0SSimon J. Gerraty.endfor 133*06b9b3e0SSimon J. Gerraty.endfor 134*06b9b3e0SSimon J. Gerraty.endfor 135*06b9b3e0SSimon J. Gerraty.endfor 136*06b9b3e0SSimon J. Gerraty.endfor 137*06b9b3e0SSimon J. Gerraty.endfor 138*06b9b3e0SSimon J. Gerraty.endif 139