]> git.pond.sub.org Git - empserver/blobdiff - info/findsubj.pl
Update copyright notice
[empserver] / info / findsubj.pl
index ffe7eb95c20a62e54e59f41df86eb30ad9215981..06c732767d693c787e166ebf8298701021f8c17b 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 #  Empire - A multi-player, client/server Internet based war game.
-#  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+#  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
 #                           Ken Stevens, Steve McClure
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -20,9 +20,9 @@
 #
 #  ---
 #
-#  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
-#  related information and legal notices. It is expected that any future
-#  projects/authors will amend these files as needed.
+#  See files README, COPYING and CREDITS in the root of the source
+#  tree for related information and legal notices.  It is expected
+#  that future projects/authors will amend these files as needed.
 #
 #  ---
 #
 # 
 #  Known contributors to this file:
 #     Ken Stevens (when it was still info.pl)
-#     Markus Armbruster, 2006
+#     Markus Armbruster, 2006-2008
 #
 
+# Usage: findsubj.pl INFO-FILE...
 # Run it at the root of the build tree.  This updates the make include
 # file subjects.mk, which guides the remaking of info index files.
 #
 #       --- Global variables ---
 # @Subjects       Existing subjects
 # $filename       The name of the current info file
+# $filename{TOPIC}
+#                 TOPIC's info file name
 # $chapter{TOPIC} TOPIC's chapter (first arg to .TH)
 # $see_also{TOPIC}
 #                 TOPIC's SEE ALSO items (.SA argument)
@@ -61,19 +64,15 @@ use warnings;
 
 use Errno qw(ENOENT);
 
-our (%chapter, %see_also, %sanr);
+our (%filename, %chapter, %see_also, %sanr);
 our ($filename, %subjfil);
 
 # Get known subjects
 our @Subjects = split(' ', read_make_var("subjects", "subjects.mk", ""));
-# Get source directory
-my $srcdir = read_make_var("srcdir", "GNUmakefile");
-# Get info sources
-my @tsrc = grep(/\.t$/, split(' ' , read_make_var("src", "sources.mk")));
 
 # Parse the .t files
-for my $t (@tsrc) {
-    parse_file("$srcdir/$t");
+for my $f (@ARGV) {
+    parse_file("$f");
 }
 
 # Create %subjfil from %see_also
@@ -101,6 +100,7 @@ for my $t (keys %subjfil) {
 # Update subjects.mk
 open(F, ">subjects.mk")
     or die "Can't open subjects.mk for writing: $!";
+print F "# DO NOT EDIT THIS FILE.  It was automatically generated by findsubj.pl\n";
 print F "subjects := " . join(' ', @Subjects) . "\n";
 for my $t (@Subjects) {
     print F "info/$t.t:$subjfil{$t}\n";
@@ -137,7 +137,8 @@ sub parse_file {
 
     $topic = $filename;
     $topic =~ s,.*/([^/]*)\.t$,$1,;
-    
+    $filename{$topic} = $filename;
+
     open(F, "<$filename")
        or die "Can't open $filename: $!";
   
@@ -178,7 +179,7 @@ sub parse_see_also {
     my $found;                # found a subject?
 
     $wanted = undef if $wanted eq 'Concept' or $wanted eq 'Command';
-    $filename = "$srcdir/$topic";
+    $filename = $filename{$topic};
 
     for (@see_also) {
        if (!exists $see_also{$_}) { # is this entry a subject?
@@ -199,6 +200,6 @@ sub parse_see_also {
 sub error {
     my ($error) = @_;
 
-    print STDERR "info.pl:$filename:$.: $error\n";
+    print STDERR "findsubj.pl:$filename:$.: $error\n";
     exit 1;
 }