|
@@ -7,6 +7,7 @@ use warnings;
|
7
|
7
|
|
8
|
8
|
my $cfgdir = "config";
|
9
|
9
|
my $config_h = shift || "config.h";
|
|
10
|
+my @input_files;
|
10
|
11
|
|
11
|
12
|
# Read in a whole file
|
12
|
13
|
#
|
|
@@ -110,15 +111,15 @@ sub postamble {
|
110
|
111
|
return "\n#endif /* $guard */\n";
|
111
|
112
|
}
|
112
|
113
|
|
113
|
|
-# Get the new configuration by splitting config.h file using the
|
114
|
|
-# @BEGIN/@END tags
|
|
114
|
+# Parse one config.h file into an existing configuration
|
115
|
115
|
#
|
116
|
|
-sub new_config {
|
|
116
|
+sub parse_config {
|
117
|
117
|
my $file = shift;
|
118
|
|
-
|
119
|
|
- my $cfg = {};
|
|
118
|
+ my $cfg = shift;
|
120
|
119
|
my $cursor = "";
|
121
|
120
|
|
|
121
|
+ push ( @input_files, $file );
|
|
122
|
+
|
122
|
123
|
open my $fh, "<$file" or die "Could not open $file: $!\n";
|
123
|
124
|
while ( <$fh> ) {
|
124
|
125
|
if ( ( my $newcursor, my $suffix ) = /\@BEGIN\s+(\w+\.h)(.*)$/ ) {
|
|
@@ -133,14 +134,28 @@ sub new_config {
|
133
|
134
|
." at $file line $.\n" unless $cursor eq $oldcursor;
|
134
|
135
|
$cfg->{$cursor} .= $prefix."*/\n";
|
135
|
136
|
$cursor = "";
|
|
137
|
+ } elsif ( ( my $newfile ) = /\@TRYSOURCE\s+([\w\-]+\.h)/ ) {
|
|
138
|
+ die "Missing \"\@END $cursor\" before \"\@TRYSOURCE $newfile\""
|
|
139
|
+ ." at $file line $.\n" if $cursor;
|
|
140
|
+ parse_config ( $newfile, $cfg ) if -e $newfile;
|
136
|
141
|
} else {
|
137
|
142
|
$cfg->{$cursor} .= $_ if $cursor;
|
138
|
143
|
}
|
139
|
144
|
}
|
140
|
145
|
close $fh;
|
141
|
146
|
die "Missing \"\@END $cursor\" in $file\n" if $cursor;
|
|
147
|
+}
|
142
|
148
|
|
143
|
|
- foreach $cursor ( keys %$cfg ) {
|
|
149
|
+# Get the new configuration by splitting config.h file using the
|
|
150
|
+# @BEGIN/@END tags
|
|
151
|
+#
|
|
152
|
+sub new_config {
|
|
153
|
+ my $file = shift;
|
|
154
|
+ my $cfg = {};
|
|
155
|
+
|
|
156
|
+ parse_config ( $file, $cfg );
|
|
157
|
+
|
|
158
|
+ foreach my $cursor ( keys %$cfg ) {
|
144
|
159
|
$cfg->{$cursor} .= postamble ( $cursor );
|
145
|
160
|
}
|
146
|
161
|
|
|
@@ -180,9 +195,11 @@ foreach my $file ( keys %$new ) {
|
180
|
195
|
}
|
181
|
196
|
|
182
|
197
|
# If we now have fragments that are older than config.h, set the
|
183
|
|
-# timestamp on config.h to match the oldest fragment, to prevent make
|
184
|
|
-# from always attempting to rebuild the fragments.
|
|
198
|
+# timestamp on each input file to match the oldest fragment, to
|
|
199
|
+# prevent make from always attempting to rebuild the fragments.
|
185
|
200
|
#
|
186
|
|
-if ( $oldest < file_mtime ( $config_h ) ) {
|
187
|
|
- utime time(), $oldest, $config_h or die "Could not touch $config_h: $!\n";
|
|
201
|
+foreach my $file ( @input_files ) {
|
|
202
|
+ if ( $oldest < file_mtime ( $file ) ) {
|
|
203
|
+ utime time(), $oldest, $file or die "Could not touch $file: $!\n";
|
|
204
|
+ }
|
188
|
205
|
}
|