~amavect/mkfilechanges

0b88e4902c62131df8ab50c3e37b742740399ea6 — Amavect 1 year, 3 months ago 18d7660 mkfiles
many small changes, see DOC
8 files changed, 51 insertions(+), 59 deletions(-)

M DOC
M mkdiff
M src/cmd/mkfile
M src/cmd/mklib
M src/cmd/mkmany
M src/cmd/mkone
M src/cmd/mksyslib
M src/mkfile
M DOC => DOC +26 -25
@@ 19,7 19,7 @@ and contain many relics from Plan 9 from Bell Labs.
Additions in common:
Add the %.cpus metarule.
  This allows other targets to appended with .cpus to build for all arches.
  Chaining can be done, like install.dirs.cpus for the cmd/mkfile file.
  Chaining can be done, like install.dirs.cpus for /sys/src/cmd/mkfile.
  It is named due to the CPUS variable in the mkfile.proto file.
  It is not named %.all due to confusion with the all target.
  The install.cpus target should be preferred over the installall target.


@@ 29,7 29,8 @@ Changes in common:
Reorganization of targets to a more logical order.
Generally, target rules are reorganized so that targets that build first are first.
The %.acid rule is changed to depend on the %.c prerequisite.
The first rule is renamed to default.
Virtual rules that print out targets are named 'usage'.
The first rule is either 'all' or 'usage'.

Deletions in common:
The update rule.


@@ 37,6 38,7 @@ The update rule.
  This is removed. TODO: remove all $UPDATE variables from mkfiles.
The safeinstall rules.
  It's more of a placebo, in my opinion.
  I'm not aware of any specific uses for them.
  (Perhaps others have a different experience?)




@@ 49,19 51,13 @@ This will allow installall to work.
/sys/src/mkfile
The goal is to support the installall target.
The %.cpus metarule is added.
The install rule rebuilds the compiler first.
The install rule rebuilds the compiler first on $cputype.
The installall rule is redefined to install.cpus.
Recursive mk calls now pass $MKFLAGS.
The cleanlibs rule is removed. Just use mk clean.
The updatelibs rule is removed.

/sys/src/cmd/mkfile
Yacc rules are changed.
  Yacc targets are generated by the variable YTARG.
  This simplifies the clean target.
  Because there are no *.tab.c files generated, there are no errors.
  The meta rule is made to match only YTARG targets, stopping a $Ocpu.yacc cycle.
  A new copy of $Ocpu.yacc is built, in case installing causes a race.
TARG target generation is simplified.
  Duplicate targets from YTARG feeding into TARG do not duplicate builds.
BIN, LDFLAGS, YFLAGS, PCONLY, and DIRS are untouched.


@@ 70,46 66,51 @@ The only directories generated are from the */mkfile command.
PowerPC does not build dtracy, currently.
  Thus, POWERLESS feeds into NOMK.
  This should be fixed, so this exception can be deleted.
$cpuobjtype is renamed to $Ocpu because it is shorter.
The ape target doesn't build, and is rather useless.
  Thus, APEDIRS and the ape rule are deleted.
  The none rule is edited to prefer the .cpus targets.
The regexp rules are kept, despite being less readable.
  This allows $Ocpu.cp to be built instead of needing to be copied from /bin/cp.
  Thus, the $cpuobjtype._cp rule is deleted.
No more regexp rules!!!
The install rule must build cp and yacc to avoid a race.
  Other implementations using prereqs were criticized for being too complex and incomplete.
$cpuobjtype is unneeded because we can use $cpuobjtype.cp to install itself.
  The cp install rule gains a little complexity to detect when $objtype equals $cputype.
Yacc rules are changed.
  Yacc targets are generated by the variable YTARG.
  This simplifies the clean target.
  Because there are no *.tab.c files generated, there are no errors.
The &:n: rule is deleted.
  Just use a $cmd.install or $O.$cmd target.
Installing $BIN/init is a hack.
  It's just simpler than making init an exception to TARG.
The safeinstall rules are all deleted.
  It seems to be more of a placebo.
  I'm not aware of any specific uses for them.
  Maybe the compiler? I need another opinion.
The virtual target rules are reorganized.
The %.cpus metarule is added.
The %.directories metarule is renamed to %.dirs
The directories rule is deleted. Just use the install.dirs target.
The cmds rule is added as a convenience.
The install rule must force order so that $CC isn't installed while compiling.
The nuke rule is changed to match mkone's nuke, deleting .acid files.

/sys/src/cmd/mkone
The %.cpus rule is added.
The allall rule is deleted, with all.cpus replacing it.
The safeinstall rules are deleted.
The update rule is deleted.
With subdirectories, it's possible to install multiple pages to different sections.

/sys/src/cmd/mkmany
The default rule is changed to build the all target.
  All mkfiles should have the same default behavior.
The update rule is deleted.
The man page installation rules are changed.
  The old %.man rule was backwards and didn't work.
  A single man page might cover a suite of programs.
  Thus, MANFILES was removed and is up to the includer to specify.

/sys/src/cmd/mklib
The %.all rule is renamed to %.cpus
The update rule is deleted.
The aggregate metarule is deleted.
  `ar u` replaces the need for aggregate rules, which was designed for `ar r`.
  Since updates to files *almost always* happen after the last time the archive was updated
  (unless someone used touch to set a specific time),
  Only $newprereq files are needed.

/sys/src/cmd/mksyslib
The %.all rule is renamed to %.cpus
The %.installall rule is deleted.
The update rule is deleted.
The %.installall rule is deleted. Replaced by $target.install.cpus, or just installall.
The &:n: rule is deleted (it should be &:nV: anyways). Just use mk all.
%.clean is deleted. Just use mk clean.

M mkdiff => mkdiff +4 -2
@@ 5,5 5,7 @@ if(~ $#a 0){
	echo 'Bind the mkfiles first.'
	exit 'canhazbindplz'
}
bind -ac /dist/plan9front /
hg diff /sys/src/mkfile /sys/src/cmd/mkfile /sys/src/cmd/mkone /sys/src/cmd/mkmany /sys/src/cmd/mklib /sys/src/cmd/mksyslib
if(! test -d /.git)
	bind -ac /dist/plan9front /
cd /
git/diff /sys/src/mkfile /sys/src/cmd/mkfile /sys/src/cmd/mkone /sys/src/cmd/mkmany /sys/src/cmd/mklib /sys/src/cmd/mksyslib

M src/cmd/mkfile => src/cmd/mkfile +2 -2
@@ 14,7 14,7 @@ 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')$'}

default:VQ:
usage:VQ:
	echo 'usage: mk all, all.cpus, cmds, $O.$cmd'
	echo '	install, install.cpus, $cmd.install, $cmd.install.cpus'
	echo '	clean, nuke'


@@ 31,7 31,7 @@ $O.%: %.$O
	$LD $LDFLAGS -o $target $stem.$O

$BIN/%: $O.%
	cp $O.$stem $BIN/$stem
	cp $O.$stem $target

$BIN/cp: $O.cp
	`{if(~ $objtype $cputype) echo ./$O.cp; if not echo cp} $prereq $target

M src/cmd/mklib => src/cmd/mklib +7 -10
@@ 1,10 1,9 @@
AFLAGS=
YFLAGS=-d

LIBOBJ=${OFILES:%=$LIB(%)}
LIBDIR=.
LIBDIR=

default:V: all
all:V: $LIB

y.tab.h y.tab.c: $YFILES
	yacc $YFLAGS $prereq


@@ 17,10 16,11 @@ y.tab.h y.tab.c: $YFILES
%.$O: %.s
	$AS $AFLAGS $stem.s

$LIB(%.$O):N: %.$O
$LIB: $OFILES
	ar vu $LIB $newprereq

$LIB: $LIBOBJ
	ar vu $LIB $newmember
$LIBDIR$LIB: $LIB
	cp $LIB $LIBDIR$LIB

%.acid: %.c $HFILES
	$CC $CFLAGS -a $stem.c >$target


@@ 28,10 28,7 @@ $LIB: $LIBOBJ
%.cpus:V:
	for(objtype in $CPUS) mk $MKFLAGS $stem

all:V: $LIB

install:VQ: $LIB
	~ $LIBDIR '.' || cp $LIB $LIBDIR/$LIB
install:V: $LIBDIR$LIB

installall:V: install.cpus


M src/cmd/mkmany => src/cmd/mkmany +1 -3
@@ 2,7 2,7 @@ PROGS=${TARG:%=$O.%}
LDFLAGS=
YFLAGS=-d

default:V: all
all:V: $PROGS

lex.yy.c: $LFILES
	$LEX $LFLAGS $prereq


@@ 30,8 30,6 @@ $BIN/%: $O.%
%.cpus:V:
	for(objtype in $CPUS) mk $MKFLAGS $stem

all:V: $PROGS

%.install:V: $BIN/%

install:V: ${TARG:%=$BIN/%}

M src/cmd/mkone => src/cmd/mkone +1 -3
@@ 2,7 2,7 @@ LDFLAGS=
YFLAGS=-d
AFLAGS=

default:V: all
all:V: $O.out

lex.yy.c: $LFILES
	$LEX $LFLAGS $prereq


@@ 30,8 30,6 @@ $BIN/$TARG: $O.out
%.cpus:V:
	for(objtype in $CPUS) mk $MKFLAGS $stem

all:V: $O.out

install:V: $BIN/$TARG

installall:V: install.cpus

M src/cmd/mksyslib => src/cmd/mksyslib +7 -9
@@ 1,9 1,12 @@
AFLAGS=
YFLAGS=-d

default:V: all

&:n: &.$O
	ar vu $LIB $stem.$O

all:V: $LIB

y.tab.h y.tab.c: $YFILES
	yacc $YFLAGS $prereq

%.$O: $HFILES



@@ 13,7 16,7 @@ default:V: all
%.$O: %.s
	$AS $AFLAGS $stem.s

$LIB:V: $OFILES  # force archive even when not needed
$LIB: $OFILES
	ar vu $LIB $newprereq

%.acid: %.c $HFILES


@@ 22,15 25,10 @@ $LIB:V: $OFILES  # force archive even when not needed
%.cpus:V:
	for(objtype in $CPUS) mk $MKFLAGS $stem

all:V: $LIB

install:V: $LIB

installall:V: install.cpus

%.clean:V:
	rm -f $stem.[$OS] [$OS].$stem $stem.acid $stem

clean:V:
	rm -f *.[$OS] [$OS].out $CLEANFILES


M src/mkfile => src/mkfile +3 -5
@@ 46,12 46,11 @@ CMDS=cmd\
SUBSYS=ape\
	/acme\

default:VQ:
usage:VQ:
	echo mk all, install, install.cpus, clean, nuke, release, kernels, or libs

%.cpus:VQ:
	# deletion is correct as long as arm is before arm64 in $CPUS
	CPUS=`{echo $CPUS | sed 's/'$cputype'//'}
	CPUS=`{echo $CPUS | sed 's/'$cputype'( |$)//'}
	for(objtype in $cputype $CPUS) mk $MKFLAGS $stem

all clean nuke:VQ:


@@ 64,9 63,8 @@ all clean nuke:VQ:

install:VQ:
	date
	@{
	if(~ $objtype $cputype) @{
		rfork e
		objtype=$cputype
		if(~ $O 0) O=v  # translate rc frontends
		for(i in libc libbio cmd/cc cmd/$O^(c a l)) @{
			cd $i