info/toc: New; generated machine-readable table of contents
Next commit will put it to use. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
8a94f2a8ae
commit
0a702949db
2 changed files with 17 additions and 4 deletions
8
Make.mk
8
Make.mk
|
@ -321,15 +321,15 @@ $(libs) $(empth_lib):
|
||||||
|
|
||||||
# Info formatting
|
# Info formatting
|
||||||
|
|
||||||
# mksubj.pl reads $(tsrc) and writes $(tsubj). The naive rule
|
# mksubj.pl reads $(tsrc) and writes $(tsubj). A naive rule
|
||||||
# $(ttop) $(tsubj): $(tsrc)
|
# $(tsubj): $(tsrc)
|
||||||
# COMMAND
|
# COMMAND
|
||||||
# runs COMMAND once for each target. That's because multiple targets
|
# runs COMMAND once for each target. That's because multiple targets
|
||||||
# in an explicit rule is just a shorthand for one rule per target,
|
# in an explicit rule is just a shorthand for one rule per target,
|
||||||
# each with the same prerequisites and commands. Use a stamp file.
|
# each with the same prerequisites and commands. Use a stamp file.
|
||||||
$(tsubj): info/stamp-subj ;
|
$(tsubj) info/toc: info/stamp-subj ;
|
||||||
info/stamp-subj: info/mksubj.pl $(tsrc)
|
info/stamp-subj: info/mksubj.pl $(tsrc)
|
||||||
$(call quiet-command,perl $(srcdir)/info/mksubj.pl $(subjects) $(filter %.t, $^),GEN '$(tsubj)')
|
$(call quiet-command,perl $(srcdir)/info/mksubj.pl $(subjects) $(filter %.t, $^),GEN '$(tsubj) info/toc')
|
||||||
>$@
|
>$@
|
||||||
|
|
||||||
$(ttop): info/mktop.pl info/subjects.mk
|
$(ttop): info/mktop.pl info/subjects.mk
|
||||||
|
|
|
@ -77,6 +77,8 @@ for (keys %Subjects) {
|
||||||
update_subj($_);
|
update_subj($_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_toc();
|
||||||
|
|
||||||
sub fn2topic {
|
sub fn2topic {
|
||||||
my ($fn) = @_;
|
my ($fn) = @_;
|
||||||
$fn =~ s,.*/([^/]*)\.t$,$1,;
|
$fn =~ s,.*/([^/]*)\.t$,$1,;
|
||||||
|
@ -249,6 +251,17 @@ sub same_contents {
|
||||||
return $contents eq $old;
|
return $contents eq $old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub write_toc {
|
||||||
|
my @toc;
|
||||||
|
for (keys %chapter) {
|
||||||
|
push @toc, "$chapter{$_} $_";
|
||||||
|
}
|
||||||
|
open(TOC, ">info/toc")
|
||||||
|
or die "Can't open info/toc for writing: $!";
|
||||||
|
print TOC join("\n", sort @toc);
|
||||||
|
close TOC;
|
||||||
|
}
|
||||||
|
|
||||||
# Print an integrity error message and exit with code 1
|
# Print an integrity error message and exit with code 1
|
||||||
sub error {
|
sub error {
|
||||||
my ($error) = @_;
|
my ($error) = @_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue