diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:06:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:06:04 +0000 |
commit | 2f0649f6fe411d7e07c8d56cf8ea56db53536da8 (patch) | |
tree | 778611fb52176dce1ad06c68e87b2cb348ca0f7b /usr/dash/gendeps.pl | |
parent | Initial commit. (diff) | |
download | klibc-upstream.tar.xz klibc-upstream.zip |
Adding upstream version 2.0.13.upstream/2.0.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'usr/dash/gendeps.pl')
-rwxr-xr-x | usr/dash/gendeps.pl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/usr/dash/gendeps.pl b/usr/dash/gendeps.pl new file mode 100755 index 0000000..e6797de --- /dev/null +++ b/usr/dash/gendeps.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl +# +# Generate dependencies for *generated* header files. Generated +# header files have to use #include "foo.h" syntax. +# + +($src, $obj, @build_headers) = @ARGV; +%build_headers = map { $_ => 1 } @build_headers; + +open(GENDEPS, "> $obj/.gendeps\0") + or die "$0: Cannot create $obj/.gendeps: $!\n"; + +opendir(DIR, $src) or die "$0: Cannot opendir $src: $!\n"; +while ( defined($file = readdir(DIR)) ) { + if ( $file =~ /^(.*)\.c$/ ) { + $basename = $1; + @hdrs = (); + open(FILE, "< $src/$file\0") + or die "$0: Cannot open $src/$file: $!\n"; + while ( defined($line = <FILE>) ) { + if ( $line =~ /^\s*\#\s*include\s+\"(.*)\"/ ) { + $header = $1; + + if ( $build_headers{$header} ) { + push(@hdrs, "\$(obj)/$header"); + } + } + } + close(FILE); + + if (scalar(@hdrs)) { + print GENDEPS "\$(obj)/$basename.o: ", join(' ', @hdrs), "\n"; + } + } +} + +closedir(DIR); +close(GENDEPS); |