summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorMichael Brown2005-04-17 17:56:32 +0200
committerMichael Brown2005-04-17 17:56:32 +0200
commita107996c9a866e6d2322eabf5533aae7bb8ad790 (patch)
tree5d6aa71f11407815ec7e5427ca4a51406c3a533b /src/util
parentAll .h files in this directory are generated from the top-level config.h (diff)
downloadipxe-a107996c9a866e6d2322eabf5533aae7bb8ad790.tar.gz
ipxe-a107996c9a866e6d2322eabf5533aae7bb8ad790.tar.xz
ipxe-a107996c9a866e6d2322eabf5533aae7bb8ad790.zip
If we end up with fragments that are older than config.h, set the
timestamp on config.h to match the oldest fragment, to prevent make from always attempting to rebuild the fragments.
Diffstat (limited to 'src/util')
-rwxr-xr-xsrc/util/mkconfig.pl33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/util/mkconfig.pl b/src/util/mkconfig.pl
index 2f2d6a4c..7850661a 100755
--- a/src/util/mkconfig.pl
+++ b/src/util/mkconfig.pl
@@ -1,11 +1,12 @@
#!/usr/bin/perl -w
use File::Spec::Functions qw ( :ALL );
+use File::stat;
use strict;
use warnings;
my $cfgdir = "config";
-my $config_h = "config.h";
+my $config_h = shift || "config.h";
# Read in a whole file
#
@@ -38,6 +39,15 @@ sub delete_file {
unlink $file or die "Could not delete $file: $!\n";
}
+# Get a file modification time
+#
+sub file_mtime {
+ my $file = shift;
+
+ my $stat = stat ( $file ) or die "Could not stat $file: $!\n";
+ return $stat->mtime;
+}
+
# Read a directory listing (excluding the . and .. entries)
#
sub read_dir {
@@ -155,9 +165,24 @@ foreach my $file ( keys %$current ) {
unlink catfile ( $cfgdir, $file ) unless exists $new->{$file};
}
-# Write out any modified fragments
+# Write out any modified fragments, and find the oldest timestamp of
+# any unmodified fragments.
#
+my $oldest = time ();
foreach my $file ( keys %$new ) {
- write_file ( catfile ( $cfgdir, $file ), $new->{$file} )
- unless $current->{$file} && $new->{$file} eq $current->{$file};
+ if ( $current->{$file} && $new->{$file} eq $current->{$file} ) {
+ # Unmodified
+ my $time = file_mtime ( catfile ( $cfgdir, $file ) );
+ $oldest = $time if $time < $oldest;
+ } else {
+ write_file ( catfile ( $cfgdir, $file ), $new->{$file} );
+ }
+}
+
+# If we now have fragments that are older than config.h, set the
+# timestamp on config.h to match the oldest fragment, to prevent make
+# from always attempting to rebuild the fragments.
+#
+if ( $oldest < file_mtime ( $config_h ) ) {
+ utime time(), $oldest, $config_h or die "Could not touch $config_h: $!\n";
}