shithub: riscv

ref: 46cf9d4eb02a3a7c2516be3053994d4fb69eb949
dir: /sys/src/cmd/mk/mkconv/

View raw version
#!/bin/rc

x=/tmp/mk$pid

fn sigexit { rm -f $x }
fn sigint { rm -f $x }

tee $x < $1 | sed -e 's/\$\(([^)]*)\)([        :\/])/$\1\2/g
	s/\$\(([^)]*)\)$/$\1/g
	s/\$\(([^)]*)\)/${\1}/g
	s/^     @/  /
	/^	-/,/[^\\]$/{
		/[^\\]\$/s/$/; set -e/
	}
	/^	-/s/	-/	set +e; /
	s/:\&/:/
	s/\$% /$stem /g
	s/\$%\./$stem\./g
	s/\$%/${stem}/g
	s/\$@([ 	]|$)/$target\1/g
	s/\$@/${target}/g
	s/\$\^/${prereq}/g
	s/\$\?/$newprereq/g'

if(grep -s 'cd[ 	]|make' < $x){
	{
		echo 'Warning: recipes containing cd or make need attention.'
		grep 'cd[ 	]|make' < $x
	} >[1=2]
}