3 # Create a file which describes dependencies. The file gets included by the
4 # Makefile which creates TOC.lyx files
6 # Essentially, this file creates a TOCs target, which makes the
7 # TOC.lyx for every possible language. Then it creates a target for
8 # each language's xx_TOC.lyx, which depends on various files.
9 # E.g., de_TOC.lyx depends on files like de_UserGuide.lyx. If non-English
10 # files don't exist, TOC.lyx just uses the corresponding English file.
15 # This is a Makefile for the TOC.lyx files.
16 # It was automatically generated by $0
18 # First come the rules for each xx_TOC.lyx file. Then comes the
19 # TOCs target, which prints all the TOC files.
22 # Add (whitespace separated) "Foo" to this list to create a TOC for Foo.lyx
23 # Don't bother including Reference.lyx
24 my @Default_Files = map {"$_.lyx"} qw(
25 Intro FAQ Tutorial UserGuide Extended Customization
28 my $Toc_Top_Dir = "TOC_top";
29 my $Toc_Top_Base = "TOC_top.lyx";
30 my $Toc_Base = "TOC.lyx";
32 # Any language which has any translated docs needs to have a TOC.lyx
34 opendir (DIR, ".") or die $!;
35 foreach (readdir DIR) {
36 $a{$1}++ if /^([a-z]{2}_)/;
39 my @langs = sort keys %a;
40 unshift @langs, ""; # English file doesn't have en_ prefix
42 # Foreach language, create Makefile dependencies
43 # and create make action
44 my @Tocs; # List of all TOC files
46 foreach $lang (@langs) {
47 # "TOCs" target will depend on this language's TOC
48 my $tfile = "$lang$Toc_Base";
51 # Make list of files, English or not.
53 # TODO print warning if language-specific file doesn't exist?
54 my $ttfile = (-e "$Toc_Top_Dir/$lang$Toc_Top_Base" ?
55 "$Toc_Top_Dir/$lang$Toc_Top_Base" :
56 "$Toc_Top_Dir/$Toc_Top_Base");
57 my @Files = ($ttfile);
59 # Now actual Doc files
60 foreach (@Default_Files) {
61 my $i18n = $lang . $_;
62 # Use xx_foo if it exists, else foo
63 push (@Files, (-e $i18n ? $i18n : $_));
66 # Create Makefile dependencies for this language's TOC file
67 my $depend = "$tfile: ";
68 $depend .= join (" ", @Files);
72 my $make = "\tperl Doc_toc.pl ";
73 # TODO is there a simple way to tell it to pass all the dependencies in?
74 # Then this could be a default rule for creating *TOC.lyx!
75 $make .= join (" ", @Files);
80 my $depend = "TOCs: ";
81 $depend .= join (" ", @Tocs);
84 print "\t\@echo Made TOCs succesfully.\n";