plan9fox/sys/src/cmd/mkfile
Amavect 485b334608 cmd/mkfile: major cleanup
Target generation is revised, split into $YTARG and $TARG.
$PROGS is inlined to the cmd target.
%.cpus is added to allow chaining: mk all.cpus
$POWERLESS is added, since dtracy doesn't build yet on ppc.
$DIRS regexp is simplified, simplifing $NOMK.
$cpuobjtype is replaced with cp's recipe for copying itself on $cputype.
$APEDIRS is removed.
The none target is renamed to usage, since it prints out usage.
The ape target is removed.
The dirs target is replaced by all.dirs
%.directories is replaced by %.dirs
The all target serializes directories after cmds to match the install target recipe.
All regexp rules are replaced with nonregexp versions for clarity.
The &:n: rule is removed. Just build the $O.$cmd file.
.y files now build .c files, not .tab.c files, and remove (bc|units|mpc|pc).c:R:
All safeinstall rules are removed.
The cleanfiles rule is renamed to cleancmds and simplified.
%.clean is removed. Just use mk cleancmds.
The install rule serializes cp and yacc before building anything else, avoiding races.
The installall recipe is simplified with the install.cpus prereq.
%.installall is removed. Just use mk $cmd.install.cpus
The $O.cj, %.update, and compilers rules are removed.
2021-08-28 13:15:02 +00:00

75 lines
1.5 KiB
Makefile

</$objtype/mkfile
YTARG=`{ls | sed -n '/\.y$/s/\.y$//p'}
TARG=$YTARG `{ls | sed -n '/^cp\.c$/d; /^yacc\.c$/d; /\.c$/s/\.c$//p'}
HFILES=/$objtype/include/u.h /sys/include/libc.h /sys/include/bio.h
BIN=/$objtype/bin
LDFLAGS=
YFLAGS=-d
PCONLY=vmx
POWERLESS=dtracy # until someone fixes the build for power
NOMK=`{~ $objtype (386 amd64) || echo $PCONLY} `{~ $objtype power && echo $POWERLESS}
DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' | grep -v '-e^'^('' $NOMK)^'$'}
usage:VQ:
echo 'usage: mk all, all.cpus, cmds, $O.$cmd'
echo ' install, install.cpus, $cmd.install, $cmd.install.cpus'
echo ' clean, nuke'
%.c %.tab.h:D: %.y
yacc $YFLAGS -o $stem.c -s $stem $stem.y
%.$O: $HFILES
%.$O: %.c
$CC $CFLAGS $stem.c
$O.%: %.$O
$LD $LDFLAGS -o $target $stem.$O
$BIN/%: $O.%
cp $O.$stem $target
$BIN/cp: $O.cp
`{if(~ $objtype $cputype) echo ./$O.cp; if not echo cp} $prereq $target
$BIN/init: $O.init # hack, install location is not target
cp $O.init /$objtype/init
%.acid: %.c $HFILES
$CC $CFLAGS -a $stem.c >$target
%.cpus:V:
for(objtype in $CPUS) mk $MKFLAGS $stem
%.dirs:V:
for(i in $DIRS) @{
cd $i
echo mk $i
mk $MKFLAGS $stem
}
cmds:V: $O.cp $O.yacc ${TARG:%=$O.%}
all:V: cmds
mk $MKFLAGS all.dirs
%.install:V: $BIN/%
install:V: cp.install
mk $MKFLAGS yacc.install
mk $MKFLAGS $TARG.install
mk $MKFLAGS install.dirs
installall:V: install.cpus
cleancmds:V:
rm -f *.[$OS] [$OS].* y.tab.? y.debug y.output $YTARG.c *.tab.h
clean:V: cleancmds clean.dirs
nuke:V: cleancmds nuke.dirs
rm -f *.acid