Skip to content

Commit a5ae8e6

Browse files
author
Junio C Hamano
committed
Fix documentation dependency generation.
Documentation/Makefile spent a lot of time to generate include dependencies, which was quite noticeable especially during "make clean". Rewrite it to generate just a single dependency file. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 79f6ac7 commit a5ae8e6

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

Documentation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.1
44
*.7
55
howto-index.txt
6+
doc.dep

Documentation/Makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,19 @@ install: man
5353
#
5454
# Determine "include::" file references in asciidoc files.
5555
#
56-
TEXTFILES = $(wildcard *.txt)
57-
DEPFILES = $(TEXTFILES:%.txt=%.dep)
58-
59-
%.dep : %.txt
60-
@rm -f $@
61-
@$(foreach dep, $(shell grep include:: $< | sed -e 's/include::/ /' -e 's/\[\]//'), \
62-
echo $(<:%.txt=%.html) $(<:%.txt=%.1) : $(dep) >> $@; )
56+
TEXTFILES = $(wildcard git-*.txt)
57+
doc.dep : $(TEXTFILES) build-docdep.perl
58+
rm -f $@+ $@
59+
perl ./build-docdep.perl >$@+
60+
mv $@+ $@
6361

64-
-include $(DEPFILES)
62+
-include doc.dep
6563

6664
git.7: ../README
6765

6866

6967
clean:
70-
rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html *.dep
68+
rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep
7169

7270
%.html : %.txt
7371
asciidoc -b xhtml11 -d manpage -f asciidoc.conf $<

Documentation/build-docdep.perl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/perl
2+
3+
my %include = ();
4+
5+
for my $text (<git-*.txt>) {
6+
open I, '<', $text || die "cannot read: $text";
7+
(my $base = $text) =~ s/\.txt$//;
8+
while (<I>) {
9+
if (/^include::/) {
10+
chomp;
11+
s/^include::\s*//;
12+
s/\[\]//;
13+
$include{$base}{$_} = 1;
14+
}
15+
}
16+
close I;
17+
}
18+
19+
# Do we care about chained includes???
20+
21+
while (my ($base, $included) = each %include) {
22+
my ($suffix) = '1';
23+
if ($base eq 'git') {
24+
$suffix = '7'; # yuck...
25+
}
26+
print "$base.html $base.$suffix : ", join(" ", keys %$included), "\n";
27+
}
28+

0 commit comments

Comments
 (0)