@matheusbsbs / matheus-bagliano / commits / a5ae8e64cf
Fork 0

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>

Junio C Hamano committed Nov 7, 2005 at 18:21 UTC a5ae8e64cfa09cea57cce832c8371818711d94c2
3 files changed +36 -9
Documentation/.gitignore
+1
@@ -3,3 +3,4 @@
3 *.1
4 *.7
5 howto-index.txt
6 +doc.dep
Documentation/Makefile
+7 -9
@@ -53,21 +53,19 @@ install: man
53 #
54 # Determine "include::" file references in asciidoc files.
55 #
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 $@+ $@
61
64 --include $(DEPFILES)
62 +-include doc.dep
63
64 git.7: ../README
65
66
67 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
69
70 %.html : %.txt
71 asciidoc -b xhtml11 -d manpage -f asciidoc.conf $<
Documentation/build-docdep.perl new
+28
@@ -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 +