* [9front] [PATCH] cmd/mkfile: major cleanup
@ 2021-08-24 22:47 Amavect
2021-08-24 23:01 ` ori
0 siblings, 1 reply; 6+ messages in thread
From: Amavect @ 2021-08-24 22:47 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 5608 bytes --]
I'm pinging this patch again, wondering if there is interest.
Thanks
Amavect
From: Amavect <amavect@gmail.com>
Date: Sat, 21 Aug 2021 18:41:01 +0000
Subject: [PATCH] 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.
$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.
---
diff 8c796bf8b9c10a0845717c47af908e47dfe14482
0e7549936b6b628ff6d1600628726f316d5301d2 ---
a/sys/src/cmd/mkfile Thu Aug 19 23:07:37 2021 +++
b/sys/src/cmd/mkfile Sat Aug 21 13:41:01 2021 @@ -1,137 +1,75 @@
</$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
+
BIN=/$objtype/bin
-PROGS=${TARG:%=$O.%}
LDFLAGS=
YFLAGS=-d
-NOTSYS=sml|dup|.+\..+
+NOMK=glenda
PCONLY=|vmx
-NOMK=$NOTSYS`{~ $objtype (386 amd64) || echo $PCONLY}
-
-cpuobjtype=`{sed -n 's/^O=//p' /$cputype/mkfile}
+POWERLESS=|dtracy # until someone fixes the build for power
+NOMK=$NOMK`{~ $objtype (386 amd64) || echo $PCONLY}`{~ $objtype power
&& echo $POWERLESS} DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' |
grep -v '^('$NOMK')$'} -APEDIRS=bzip2 compress cvs eqn grap gs
links-ape lp pic postscript spin \
- tex troff
-none:VQ:
- echo usage: mk cmds, dirs, all, install, installall, '$O'.cmd,
cmd.install, or cmd.installall +usage:VQ:
+ echo 'usage: mk all, all.cpus, cmds, $O.$cmd'
+ echo ' install, install.cpus, $cmd.install,
$cmd.install.cpus'
+ echo ' clean, nuke'
-cmds:V: $PROGS
+%.c %.tab.h:D: %.y
+ yacc $YFLAGS -o $stem.c -s $stem $stem.y
-ape:V: $APE
- for(i in $APEDIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
+%.$O: $HFILES
-dirs:V:
- for(i in cc $DIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
-
-all:V: $PROGS dirs
+%.$O: %.c
+ $CC $CFLAGS $stem.c
-^([$OS])\.(.*):R: \2.\1
- $stem1^l $LDFLAGS -o $target $stem2.$stem1
+$O.%: %.$O
+ $LD $LDFLAGS -o $target $stem.$O
-.*\.[$OS]:R: $HFILES
+$BIN/%: $O.%
+ cp $O.$stem $target
-(.*)\.([$OS])'$':R: \1.c
- $stem2^c $CFLAGS $stem1.c
+$BIN/cp: $O.cp
+ `{if(~ $objtype $cputype) echo ./$O.cp; if not echo cp}
$prereq $target
-&:n: $O.&
- mv $O.$stem $stem
+$BIN/init: $O.init # hack, install location is not target
+ cp $O.init /$objtype/init
-%.tab.h %.tab.c:D: %.y
- $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
+%.acid: %.c $HFILES
+ $CC $CFLAGS -a $stem.c >$target
-$BIN/%: $O.% $cpuobjtype._cp
- ./$cpuobjtype._cp $O.$stem $BIN/$stem
+%.cpus:V:
+ for(objtype in $CPUS) mk $MKFLAGS $stem
-%.directories:V:
+%.dirs:V:
for(i in $DIRS) @{
cd $i
echo mk $i
mk $MKFLAGS $stem
}
-clean:V: cleanfiles clean.directories
-
-nuke:V: cleanfiles nuke.directories
-
-directories:V: install.directories
+cmds:V: $O.cp $O.yacc ${TARG:%=$O.%}
-cleanfiles:V:
- 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 +all:V: cmds
+ mk $MKFLAGS all.dirs
-%.clean:V:
- rm -f [$OS].$stem $stem.[$OS]
+%.install:V: $BIN/%
-install:V:
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
+install:V: cp.install
+ mk $MKFLAGS yacc.install
mk $MKFLAGS $TARG.install
- mk $MKFLAGS directories
-
-installall:V:
- for(objtype in $CPUS)
- mk $MKFLAGS install
-
-%.installall: %.c
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
- 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
- $CC $CFLAGS -a $stem.c >$target
+ mk $MKFLAGS install.dirs
-(bc|units|mpc|pc).c:R: \1.tab.c
- mv $stem1.tab.c $stem1.c
+installall:V: install.cpus
-$BIN/init: $O.init
- cp $prereq /$objtype/init
+cleancmds:V:
+ rm -f *.[$OS] [$OS].* y.tab.? y.debug y.output $YTARG.c *.tab.h
-$O.cj: cj.$O
- $LD $LDFLAGS -o $O.cj cj.$O /$objtype/lib/libjpg.a
+clean:V: cleancmds clean.dirs
-%.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
- }
+nuke:V: cleancmds nuke.dirs
+ rm -f *.acid
[-- Attachment #2.1: Type: text/plain, Size: 311 bytes --]
from postmaster@1ess:
The following attachment had content that we can't
prove to be harmless. To avoid possible automatic
execution, we changed the content headers.
The original header was:
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=cmdmkfile.diff
[-- Attachment #2.2: cmdmkfile.diff.suspect --]
[-- Type: application/octet-stream, Size: 5531 bytes --]
From: Amavect <amavect@gmail.com>
Date: Sat, 21 Aug 2021 18:41:01 +0000
Subject: [PATCH] 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.
$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.
---
diff 8c796bf8b9c10a0845717c47af908e47dfe14482 0e7549936b6b628ff6d1600628726f316d5301d2
--- a/sys/src/cmd/mkfile Thu Aug 19 23:07:37 2021
+++ b/sys/src/cmd/mkfile Sat Aug 21 13:41:01 2021
@@ -1,137 +1,75 @@
</$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
+
BIN=/$objtype/bin
-PROGS=${TARG:%=$O.%}
LDFLAGS=
YFLAGS=-d
-NOTSYS=sml|dup|.+\..+
+NOMK=glenda
PCONLY=|vmx
-NOMK=$NOTSYS`{~ $objtype (386 amd64) || echo $PCONLY}
-
-cpuobjtype=`{sed -n 's/^O=//p' /$cputype/mkfile}
+POWERLESS=|dtracy # until someone fixes the build for power
+NOMK=$NOMK`{~ $objtype (386 amd64) || echo $PCONLY}`{~ $objtype power && echo $POWERLESS}
DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' | grep -v '^('$NOMK')$'}
-APEDIRS=bzip2 compress cvs eqn grap gs links-ape lp pic postscript spin \
- tex troff
-none:VQ:
- echo usage: mk cmds, dirs, all, install, installall, '$O'.cmd, cmd.install, or cmd.installall
+usage:VQ:
+ echo 'usage: mk all, all.cpus, cmds, $O.$cmd'
+ echo ' install, install.cpus, $cmd.install, $cmd.install.cpus'
+ echo ' clean, nuke'
-cmds:V: $PROGS
+%.c %.tab.h:D: %.y
+ yacc $YFLAGS -o $stem.c -s $stem $stem.y
-ape:V: $APE
- for(i in $APEDIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
+%.$O: $HFILES
-dirs:V:
- for(i in cc $DIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
-
-all:V: $PROGS dirs
+%.$O: %.c
+ $CC $CFLAGS $stem.c
-^([$OS])\.(.*):R: \2.\1
- $stem1^l $LDFLAGS -o $target $stem2.$stem1
+$O.%: %.$O
+ $LD $LDFLAGS -o $target $stem.$O
-.*\.[$OS]:R: $HFILES
+$BIN/%: $O.%
+ cp $O.$stem $target
-(.*)\.([$OS])'$':R: \1.c
- $stem2^c $CFLAGS $stem1.c
+$BIN/cp: $O.cp
+ `{if(~ $objtype $cputype) echo ./$O.cp; if not echo cp} $prereq $target
-&:n: $O.&
- mv $O.$stem $stem
+$BIN/init: $O.init # hack, install location is not target
+ cp $O.init /$objtype/init
-%.tab.h %.tab.c:D: %.y
- $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
+%.acid: %.c $HFILES
+ $CC $CFLAGS -a $stem.c >$target
-$BIN/%: $O.% $cpuobjtype._cp
- ./$cpuobjtype._cp $O.$stem $BIN/$stem
+%.cpus:V:
+ for(objtype in $CPUS) mk $MKFLAGS $stem
-%.directories:V:
+%.dirs:V:
for(i in $DIRS) @{
cd $i
echo mk $i
mk $MKFLAGS $stem
}
-clean:V: cleanfiles clean.directories
-
-nuke:V: cleanfiles nuke.directories
-
-directories:V: install.directories
+cmds:V: $O.cp $O.yacc ${TARG:%=$O.%}
-cleanfiles:V:
- 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
+all:V: cmds
+ mk $MKFLAGS all.dirs
-%.clean:V:
- rm -f [$OS].$stem $stem.[$OS]
+%.install:V: $BIN/%
-install:V:
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
+install:V: cp.install
+ mk $MKFLAGS yacc.install
mk $MKFLAGS $TARG.install
- mk $MKFLAGS directories
-
-installall:V:
- for(objtype in $CPUS)
- mk $MKFLAGS install
-
-%.installall: %.c
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
- 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
- $CC $CFLAGS -a $stem.c >$target
+ mk $MKFLAGS install.dirs
-(bc|units|mpc|pc).c:R: \1.tab.c
- mv $stem1.tab.c $stem1.c
+installall:V: install.cpus
-$BIN/init: $O.init
- cp $prereq /$objtype/init
+cleancmds:V:
+ rm -f *.[$OS] [$OS].* y.tab.? y.debug y.output $YTARG.c *.tab.h
-$O.cj: cj.$O
- $LD $LDFLAGS -o $O.cj cj.$O /$objtype/lib/libjpg.a
+clean:V: cleancmds clean.dirs
-%.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
- }
+nuke:V: cleancmds nuke.dirs
+ rm -f *.acid
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] [PATCH] cmd/mkfile: major cleanup
2021-08-24 22:47 [9front] [PATCH] cmd/mkfile: major cleanup Amavect
@ 2021-08-24 23:01 ` ori
2021-08-28 13:28 ` Amavect
0 siblings, 1 reply; 6+ messages in thread
From: ori @ 2021-08-24 23:01 UTC (permalink / raw)
To: 9front
Quoth Amavect <amavect@gmail.com>:
> I'm pinging this patch again, wondering if there is interest.
>
> Thanks
> Amavect
Thanks for the ping -- it looks fine with a quick skim,
and I'll try to look closer in the next few days.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] [PATCH] cmd/mkfile: major cleanup
2021-08-24 23:01 ` ori
@ 2021-08-28 13:28 ` Amavect
2021-08-29 12:57 ` cinap_lenrek
0 siblings, 1 reply; 6+ messages in thread
From: Amavect @ 2021-08-28 13:28 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 6090 bytes --]
On Tue, 24 Aug 2021 19:01:33 -0400
ori@eigenstate.org wrote:
> Thanks for the ping -- it looks fine with a quick skim,
> and I'll try to look closer in the next few days.
Chatted with ori yesterday.
He had some good ideas with simplifying $NOMK and $DIRS generation.
TODO: init.c doesn't really belong in cmd/ and should probably be
moved to /sys/src/boot/ since it complicates cmd/mkfile.
That will be a separate patch.
Thanks,
Amavect
From: Amavect <amavect@gmail.com>
Date: Sat, 28 Aug 2021 13:15:02 +0000
Subject: [PATCH] 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.
---
diff 61f37abf576a02c7f1e3561cfaba3c0457f55c9d
5fb0b83b0ca45b5830227f0c82af3a7696ad1acc ---
a/sys/src/cmd/mkfile Fri Aug 27 09:13:11 2021 +++
b/sys/src/cmd/mkfile Sat Aug 28 08:15:02 2021 @@ -1,137 +1,74 @@
</$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
+
BIN=/$objtype/bin
-PROGS=${TARG:%=$O.%}
LDFLAGS=
YFLAGS=-d
-NOTSYS=sml|dup|.+\..+
-PCONLY=|vmx
-NOMK=$NOTSYS`{~ $objtype (386 amd64) || echo $PCONLY}
-
-cpuobjtype=`{sed -n 's/^O=//p' /$cputype/mkfile}
-DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' | grep -v '^('$NOMK')$'}
-APEDIRS=bzip2 compress cvs eqn grap gs links-ape lp pic postscript
spin \
- tex troff
-
-none:VQ:
- echo usage: mk cmds, dirs, all, install, installall, '$O'.cmd,
cmd.install, or cmd.installall -
-cmds:V: $PROGS
-
-ape:V: $APE
- for(i in $APEDIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
-
-dirs:V:
- for(i in cc $DIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
+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)^'$'}
-all:V: $PROGS dirs
+usage:VQ:
+ echo 'usage: mk all, all.cpus, cmds, $O.$cmd'
+ echo ' install, install.cpus, $cmd.install,
$cmd.install.cpus'
+ echo ' clean, nuke'
-^([$OS])\.(.*):R: \2.\1
- $stem1^l $LDFLAGS -o $target $stem2.$stem1
+%.c %.tab.h:D: %.y
+ yacc $YFLAGS -o $stem.c -s $stem $stem.y
-.*\.[$OS]:R: $HFILES
+%.$O: $HFILES
-(.*)\.([$OS])'$':R: \1.c
- $stem2^c $CFLAGS $stem1.c
+%.$O: %.c
+ $CC $CFLAGS $stem.c
-&:n: $O.&
- mv $O.$stem $stem
+$O.%: %.$O
+ $LD $LDFLAGS -o $target $stem.$O
-%.tab.h %.tab.c:D: %.y
- $YACC $YFLAGS -s $stem $prereq
+$BIN/%: $O.%
+ cp $O.$stem $target
-%.install:V: $BIN/%
+$BIN/cp: $O.cp
+ `{if(~ $objtype $cputype) echo ./$O.cp; if not echo cp}
$prereq $target
-$cpuobjtype._cp: /bin/cp
- cp $prereq $target
+$BIN/init: $O.init # hack, install location is not target
+ cp $O.init /$objtype/init
-%.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
+%.acid: %.c $HFILES
+ $CC $CFLAGS -a $stem.c >$target
-$BIN/%: $O.% $cpuobjtype._cp
- ./$cpuobjtype._cp $O.$stem $BIN/$stem
+%.cpus:V:
+ for(objtype in $CPUS) mk $MKFLAGS $stem
-%.directories:V:
+%.dirs:V:
for(i in $DIRS) @{
cd $i
echo mk $i
mk $MKFLAGS $stem
}
-clean:V: cleanfiles clean.directories
-
-nuke:V: cleanfiles nuke.directories
-
-directories:V: install.directories
+cmds:V: $O.cp $O.yacc ${TARG:%=$O.%}
-cleanfiles:V:
- 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 +all:V: cmds
+ mk $MKFLAGS all.dirs
-%.clean:V:
- rm -f [$OS].$stem $stem.[$OS]
+%.install:V: $BIN/%
-install:V:
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
+install:V: cp.install
+ mk $MKFLAGS yacc.install
mk $MKFLAGS $TARG.install
- mk $MKFLAGS directories
-
-installall:V:
- for(objtype in $CPUS)
- mk $MKFLAGS install
-
-%.installall: %.c
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
- 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
- $CC $CFLAGS -a $stem.c >$target
+ mk $MKFLAGS install.dirs
-(bc|units|mpc|pc).c:R: \1.tab.c
- mv $stem1.tab.c $stem1.c
+installall:V: install.cpus
-$BIN/init: $O.init
- cp $prereq /$objtype/init
+cleancmds:V:
+ rm -f *.[$OS] [$OS].* y.tab.? y.debug y.output $YTARG.c *.tab.h
-$O.cj: cj.$O
- $LD $LDFLAGS -o $O.cj cj.$O /$objtype/lib/libjpg.a
+clean:V: cleancmds clean.dirs
-%.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
- }
+nuke:V: cleancmds nuke.dirs
+ rm -f *.acid
[-- Attachment #2.1: Type: text/plain, Size: 312 bytes --]
from postmaster@4ess:
The following attachment had content that we can't
prove to be harmless. To avoid possible automatic
execution, we changed the content headers.
The original header was:
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=cmdmkfile2.diff
[-- Attachment #2.2: cmdmkfile2.diff.suspect --]
[-- Type: application/octet-stream, Size: 5650 bytes --]
From: Amavect <amavect@gmail.com>
Date: Sat, 28 Aug 2021 13:15:02 +0000
Subject: [PATCH] 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.
---
diff 61f37abf576a02c7f1e3561cfaba3c0457f55c9d 5fb0b83b0ca45b5830227f0c82af3a7696ad1acc
--- a/sys/src/cmd/mkfile Fri Aug 27 09:13:11 2021
+++ b/sys/src/cmd/mkfile Sat Aug 28 08:15:02 2021
@@ -1,137 +1,74 @@
</$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
+
BIN=/$objtype/bin
-PROGS=${TARG:%=$O.%}
LDFLAGS=
YFLAGS=-d
-NOTSYS=sml|dup|.+\..+
-PCONLY=|vmx
-NOMK=$NOTSYS`{~ $objtype (386 amd64) || echo $PCONLY}
-
-cpuobjtype=`{sed -n 's/^O=//p' /$cputype/mkfile}
-DIRS=`{echo */mkfile | sed 's,/mkfile *,\n,g' | grep -v '^('$NOMK')$'}
-APEDIRS=bzip2 compress cvs eqn grap gs links-ape lp pic postscript spin \
- tex troff
-
-none:VQ:
- echo usage: mk cmds, dirs, all, install, installall, '$O'.cmd, cmd.install, or cmd.installall
-
-cmds:V: $PROGS
-
-ape:V: $APE
- for(i in $APEDIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
-
-dirs:V:
- for(i in cc $DIRS) @{
- cd $i
- echo mk $i
- mk $MKFLAGS all
- }
+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)^'$'}
-all:V: $PROGS dirs
+usage:VQ:
+ echo 'usage: mk all, all.cpus, cmds, $O.$cmd'
+ echo ' install, install.cpus, $cmd.install, $cmd.install.cpus'
+ echo ' clean, nuke'
-^([$OS])\.(.*):R: \2.\1
- $stem1^l $LDFLAGS -o $target $stem2.$stem1
+%.c %.tab.h:D: %.y
+ yacc $YFLAGS -o $stem.c -s $stem $stem.y
-.*\.[$OS]:R: $HFILES
+%.$O: $HFILES
-(.*)\.([$OS])'$':R: \1.c
- $stem2^c $CFLAGS $stem1.c
+%.$O: %.c
+ $CC $CFLAGS $stem.c
-&:n: $O.&
- mv $O.$stem $stem
+$O.%: %.$O
+ $LD $LDFLAGS -o $target $stem.$O
-%.tab.h %.tab.c:D: %.y
- $YACC $YFLAGS -s $stem $prereq
+$BIN/%: $O.%
+ cp $O.$stem $target
-%.install:V: $BIN/%
+$BIN/cp: $O.cp
+ `{if(~ $objtype $cputype) echo ./$O.cp; if not echo cp} $prereq $target
-$cpuobjtype._cp: /bin/cp
- cp $prereq $target
+$BIN/init: $O.init # hack, install location is not target
+ cp $O.init /$objtype/init
-%.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
+%.acid: %.c $HFILES
+ $CC $CFLAGS -a $stem.c >$target
-$BIN/%: $O.% $cpuobjtype._cp
- ./$cpuobjtype._cp $O.$stem $BIN/$stem
+%.cpus:V:
+ for(objtype in $CPUS) mk $MKFLAGS $stem
-%.directories:V:
+%.dirs:V:
for(i in $DIRS) @{
cd $i
echo mk $i
mk $MKFLAGS $stem
}
-clean:V: cleanfiles clean.directories
-
-nuke:V: cleanfiles nuke.directories
-
-directories:V: install.directories
+cmds:V: $O.cp $O.yacc ${TARG:%=$O.%}
-cleanfiles:V:
- 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
+all:V: cmds
+ mk $MKFLAGS all.dirs
-%.clean:V:
- rm -f [$OS].$stem $stem.[$OS]
+%.install:V: $BIN/%
-install:V:
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
+install:V: cp.install
+ mk $MKFLAGS yacc.install
mk $MKFLAGS $TARG.install
- mk $MKFLAGS directories
-
-installall:V:
- for(objtype in $CPUS)
- mk $MKFLAGS install
-
-%.installall: %.c
- test -e $cpuobjtype._cp || cp /bin/cp $cpuobjtype._cp
- 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
- $CC $CFLAGS -a $stem.c >$target
+ mk $MKFLAGS install.dirs
-(bc|units|mpc|pc).c:R: \1.tab.c
- mv $stem1.tab.c $stem1.c
+installall:V: install.cpus
-$BIN/init: $O.init
- cp $prereq /$objtype/init
+cleancmds:V:
+ rm -f *.[$OS] [$OS].* y.tab.? y.debug y.output $YTARG.c *.tab.h
-$O.cj: cj.$O
- $LD $LDFLAGS -o $O.cj cj.$O /$objtype/lib/libjpg.a
+clean:V: cleancmds clean.dirs
-%.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
- }
+nuke:V: cleancmds nuke.dirs
+ rm -f *.acid
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-30 11:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 22:47 [9front] [PATCH] cmd/mkfile: major cleanup Amavect
2021-08-24 23:01 ` ori
2021-08-28 13:28 ` Amavect
2021-08-29 12:57 ` cinap_lenrek
2021-08-29 21:26 ` Stuart Morrow
2021-08-30 11:42 ` Rodrigo G. López
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).