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.
This commit is contained in:
parent
1a444750d6
commit
485b334608
1 changed files with 42 additions and 105 deletions
|
@ -1,137 +1,74 @@
|
||||||
</$objtype/mkfile
|
</$objtype/mkfile
|
||||||
|
|
||||||
TARG=`{ls *.[cy] | sed '/\.tab\.c$/d;s/..$//'}
|
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
|
HFILES=/$objtype/include/u.h /sys/include/libc.h /sys/include/bio.h
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
PROGS=${TARG:%=$O.%}
|
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
YFLAGS=-d
|
YFLAGS=-d
|
||||||
|
|
||||||
NOTSYS=sml|dup|.+\..+
|
PCONLY=vmx
|
||||||
PCONLY=|vmx
|
POWERLESS=dtracy # until someone fixes the build for power
|
||||||
NOMK=$NOTSYS`{~ $objtype (386 amd64) || echo $PCONLY}
|
NOMK=`{~ $objtype (386 amd64) || echo $PCONLY} `{~ $objtype power && echo $POWERLESS}
|
||||||
|
DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' | grep -v '-e^'^('' $NOMK)^'$'}
|
||||||
|
|
||||||
cpuobjtype=`{sed -n 's/^O=//p' /$cputype/mkfile}
|
usage:VQ:
|
||||||
DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' | grep -v '^('$NOMK')$'}
|
echo 'usage: mk all, all.cpus, cmds, $O.$cmd'
|
||||||
APEDIRS=bzip2 compress cvs eqn grap gs links-ape lp pic postscript spin \
|
echo ' install, install.cpus, $cmd.install, $cmd.install.cpus'
|
||||||
tex troff
|
echo ' clean, nuke'
|
||||||
|
|
||||||
none:VQ:
|
%.c %.tab.h:D: %.y
|
||||||
echo usage: mk cmds, dirs, all, install, installall, '$O'.cmd, cmd.install, or cmd.installall
|
yacc $YFLAGS -o $stem.c -s $stem $stem.y
|
||||||
|
|
||||||
cmds:V: $PROGS
|
%.$O: $HFILES
|
||||||
|
|
||||||
ape:V: $APE
|
%.$O: %.c
|
||||||
for(i in $APEDIRS) @{
|
$CC $CFLAGS $stem.c
|
||||||
cd $i
|
|
||||||
echo mk $i
|
|
||||||
mk $MKFLAGS all
|
|
||||||
}
|
|
||||||
|
|
||||||
dirs:V:
|
$O.%: %.$O
|
||||||
for(i in cc $DIRS) @{
|
$LD $LDFLAGS -o $target $stem.$O
|
||||||
cd $i
|
|
||||||
echo mk $i
|
|
||||||
mk $MKFLAGS all
|
|
||||||
}
|
|
||||||
|
|
||||||
all:V: $PROGS dirs
|
$BIN/%: $O.%
|
||||||
|
cp $O.$stem $target
|
||||||
|
|
||||||
^([$OS])\.(.*):R: \2.\1
|
$BIN/cp: $O.cp
|
||||||
$stem1^l $LDFLAGS -o $target $stem2.$stem1
|
`{if(~ $objtype $cputype) echo ./$O.cp; if not echo cp} $prereq $target
|
||||||
|
|
||||||
.*\.[$OS]:R: $HFILES
|
$BIN/init: $O.init # hack, install location is not target
|
||||||
|
cp $O.init /$objtype/init
|
||||||
|
|
||||||
(.*)\.([$OS])'$':R: \1.c
|
%.acid: %.c $HFILES
|
||||||
$stem2^c $CFLAGS $stem1.c
|
$CC $CFLAGS -a $stem.c >$target
|
||||||
|
|
||||||
&:n: $O.&
|
%.cpus:V:
|
||||||
mv $O.$stem $stem
|
for(objtype in $CPUS) mk $MKFLAGS $stem
|
||||||
|
|
||||||
%.tab.h %.tab.c:D: %.y
|
%.dirs:V:
|
||||||
$YACC $YFLAGS -s $stem $prereq
|
|
||||||
|
|
||||||
%.install:V: $BIN/%
|
|
||||||
|
|
||||||
$cpuobjtype._cp: /bin/cp
|
|
||||||
cp $prereq $target
|
|
||||||
|
|
||||||
%.safeinstall: $O.% $cpuobjtype._cp
|
|
||||||
test -e $BIN/$stem && mv $BIN/$stem $BIN/_$stem
|
|
||||||
./$cpuobjtype._cp $O.$stem $BIN/$stem
|
|
||||||
|
|
||||||
%.safeinstallall:
|
|
||||||
for(objtype in $CPUS)
|
|
||||||
mk $stem.safeinstall
|
|
||||||
mk $stem.clean
|
|
||||||
|
|
||||||
$BIN/%: $O.% $cpuobjtype._cp
|
|
||||||
./$cpuobjtype._cp $O.$stem $BIN/$stem
|
|
||||||
|
|
||||||
%.directories:V:
|
|
||||||
for(i in $DIRS) @{
|
for(i in $DIRS) @{
|
||||||
cd $i
|
cd $i
|
||||||
echo mk $i
|
echo mk $i
|
||||||
mk $MKFLAGS $stem
|
mk $MKFLAGS $stem
|
||||||
}
|
}
|
||||||
|
|
||||||
clean:V: cleanfiles clean.directories
|
cmds:V: $O.cp $O.yacc ${TARG:%=$O.%}
|
||||||
|
|
||||||
nuke:V: cleanfiles nuke.directories
|
all:V: cmds
|
||||||
|
mk $MKFLAGS all.dirs
|
||||||
|
|
||||||
directories:V: install.directories
|
%.install:V: $BIN/%
|
||||||
|
|
||||||
cleanfiles:V:
|
install:V: cp.install
|
||||||
rm -f [$OS].out *.[$OS] y.tab.? y.debug y.output [$OS].$TARG [$OS].units.tab $TARG bc.c bc.tab.h units.tab.h units.c mpc.c mpc.tab.h [$OS]._cp
|
mk $MKFLAGS yacc.install
|
||||||
|
|
||||||
%.clean:V:
|
|
||||||
rm -f [$OS].$stem $stem.[$OS]
|
|
||||||
|
|
||||||
install:V:
|
|
||||||
test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
|
|
||||||
mk $MKFLAGS $TARG.install
|
mk $MKFLAGS $TARG.install
|
||||||
mk $MKFLAGS directories
|
mk $MKFLAGS install.dirs
|
||||||
|
|
||||||
installall:V:
|
installall:V: install.cpus
|
||||||
for(objtype in $CPUS)
|
|
||||||
mk $MKFLAGS install
|
|
||||||
|
|
||||||
%.installall: %.c
|
cleancmds:V:
|
||||||
test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
|
rm -f *.[$OS] [$OS].* y.tab.? y.debug y.output $YTARG.c *.tab.h
|
||||||
for (objtype in $CPUS) {
|
|
||||||
rfork e
|
|
||||||
mk $stem.install &
|
|
||||||
}
|
|
||||||
wait
|
|
||||||
rm -f $stem.[$OS] y.tab.? $stem.tab.? y.debug y.output [$OS].$stem bc.c bc.tab.h units.c mpc.c
|
|
||||||
|
|
||||||
%.acid: %.$O $HFILES
|
clean:V: cleancmds clean.dirs
|
||||||
$CC $CFLAGS -a $stem.c >$target
|
|
||||||
|
|
||||||
(bc|units|mpc|pc).c:R: \1.tab.c
|
nuke:V: cleancmds nuke.dirs
|
||||||
mv $stem1.tab.c $stem1.c
|
rm -f *.acid
|
||||||
|
|
||||||
$BIN/init: $O.init
|
|
||||||
cp $prereq /$objtype/init
|
|
||||||
|
|
||||||
$O.cj: cj.$O
|
|
||||||
$LD $LDFLAGS -o $O.cj cj.$O /$objtype/lib/libjpg.a
|
|
||||||
|
|
||||||
%.update:V:
|
|
||||||
update $stem.c /386/bin/$stem
|
|
||||||
|
|
||||||
compilers:V:
|
|
||||||
for(i in ?c)
|
|
||||||
if(! ~ $i cc rc) @{
|
|
||||||
cd $i
|
|
||||||
mk clean
|
|
||||||
objtype=$cputype mk install
|
|
||||||
mk clean
|
|
||||||
}
|
|
||||||
for(i in ?c)
|
|
||||||
if(! ~ $i cc rc) @{
|
|
||||||
cd $i
|
|
||||||
mk clean
|
|
||||||
mk installall
|
|
||||||
mk clean
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue