1#!/usr/bin/perl -w
2#
3# Copyright by The HDF Group.
4# Copyright by the Board of Trustees of the University of Illinois.
5# All rights reserved.
6#
7# This file is part of HDF5.  The full HDF5 copyright notice, including
8# terms governing use, modification, and redistribution, is contained in
9# the COPYING file, which can be found at the root of the source code
10# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
11# If you do not have access to either file, you may request a copy from
12# help@hdfgroup.org.
13#
14my $depend_file;
15my $new_depend_file;
16my $srcdir;
17my $top_srcdir;
18my $top_builddir;
19
20while ($_ = shift @ARGV) {
21    if (/^--top_srcdir=([^ \t\n]*)/) {
22        $top_srcdir = $1;
23        $top_srcdir =~ s/\+/\\\+/g;
24        $top_srcdir =~ s/\./\\\./g;
25    } elsif (/^--top_builddir=([^ \t\n]*)/) {
26        $top_builddir = $1;
27        $top_builddir =~ s/\+/\\\+/g;
28        $top_builddir =~ s/\./\\\./g;
29    } else {
30        $depend_file = $_;
31        $new_depend_file = "$_.new";
32        last;
33    }
34}
35
36open(DEPEND, "<$depend_file") || die "cannot open file $depend_file: $!\n";
37open(NEW, ">$new_depend_file") || die "cannot open file $new_depend_file: $!\n";
38
39while (<DEPEND>) {
40    s/\.o(\b)/\.lo$1/g;
41    s/ $top_srcdir/ \$\(top_srcdir\)/g;
42    s/ $top_builddir/ \$\(top_builddir\)/g;
43    print NEW $_;
44}
45
46close(DEPEND);
47close(NEW);
48
49`mv $new_depend_file $depend_file`;
50