/[ascend]/trunk/models/update-Makefile.pl
ViewVC logotype

Contents of /trunk/models/update-Makefile.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (19 years, 10 months ago) by aw0a
File MIME type: text/x-perl
File size: 3131 byte(s)
Setting up web subdirectory in repository
1 #!/usr/local/bin/perl5 -w
2 #
3
4 # This script updates the variable INSTALL_FILE_LIST in the
5 # `Makefile.in' file in this directory. The script sets
6 # INSTALL_FILE_LIST to the list of non-Makefile-files listed in the
7 # CVS/Entries file. The former value of INSTALL_FILE_LIST is lost,
8 # but a backup copy of Makefile.in is available in `Makefile.in.$$~'
9 # where $$ is the process-id.
10
11 # Load modules. man <module-name> for more info.
12 use strict;
13 use IO::File;
14
15 # The Makefile variable to update
16 my $update_macro = 'INSTALL_FILE_LIST';
17
18 # @files will contain the list of files to add to the Makefile.in
19 my @files = ();
20
21 # @exclude contains the list of files NOT to add to Makefile.in
22 my @exclude = qw(configure configure.in
23 Makefile.in Makefile.Rules.in Makefile.Template
24 update-Makefile.pl);
25
26 # Convert the exclude array into a hash for quick lookup
27 my %exclude = ();
28 foreach (@exclude) {
29 $exclude{$_} = 1;
30 }
31
32 # Populate @files by reading the CVS/Entries file in this directory
33 &readEntries('.');
34
35 # Sort files
36 @files = sort @files;
37
38 # Rename `Makefile.in' to `Makefile.in.$$~'
39 my $new = 'Makefile.in';
40 my $old = "$new.$$~";
41 rename( $new, $old ) ||
42 die "Cannot rename $new: $!";
43
44 # Open the files
45 my $NEW = new IO::File $new, 'w';
46 my $OLD = new IO::File $old;
47 die "Cannot open $new: $!" unless defined $NEW;
48 die "Cannot open $old: $!" unless defined $OLD;
49
50 # Read in the old version. We do a straight copy until we find
51 # $update_macro, at which point we ignore everthing in the old
52 # version until the end of $update_macro definition, and we insert
53 # the list of files we found (in @files).
54 while( <$OLD> ) {
55 $NEW->print( $_);
56 next unless /^$update_macro\s*=/o;
57 # Ignore everything in $OLD until the end of $update_macro
58 while( <$OLD> ) {
59 next if m,\\,;
60 last;
61 }
62 # The last line in the $update_macro definition does not end in a
63 # backslash, so we have to treat it specially
64 my $last = pop @files;
65 # Print each file in @files
66 foreach my $f ( @files ) {
67 $NEW->print( "\t", $f, " \\\n" );
68 }
69 # Now print the last one
70 $NEW->print( "\t", $last, "\n" );
71 }
72
73 # Close the files
74 $OLD->close() || die "Cannot close $old: $!";
75 $NEW->close() || die "Cannot close $new: $!";
76
77 # All done!
78 exit;
79
80 # Add most of the files in the CVS/Entries file to the global @files
81 # variable (ignore those in %exclude). The argument to readEntries
82 # is the directory which the CVS/Entries file applies to
83 sub readEntries {
84 my($dir) = @_;
85 # localize globals
86 local($_,$!,$1);
87 # open the CVS/Entries file
88 my $entry = new IO::File "CVS/Entries";
89 die "Cannot open $_/Entries: $!" unless defined $entry;
90 # For each line in $entry, split the line on slash and check to
91 # see if the file name is in %exclude; if not, add it to the
92 # global variable @files
93 while( <$entry> ) {
94 my($empty,$file,$version,$data,$misc) = split( '/', $_ );
95 next if defined $exclude{$file};
96 push @files, $file;
97 }
98 $entry->close() || die "Cannot close $dir/CVS/Entries: $!";
99 }

Properties

Name Value
svn:executable *

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22