-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsubst.in
executable file
·48 lines (38 loc) · 1.08 KB
/
subst.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl -w
use strict;
my ${prefix} = "@prefix@";
my ${exec_prefix} = "@exec_prefix@";
my ${datarootdir} = "@datarootdir@";
while (my $f = shift @ARGV) {
my $TEMP = '';
if (-x "/bin/mktemp") {
$TEMP = `/bin/mktemp $f.$$.XXXXXX`;
die "Cannot make temporary file $TEMP" if($?);
chomp $TEMP;
} else {
my $XXXXXX = rand;
$TEMP = "$f.$$.$XXXXXX";
}
open IN, "<$f" || die "Cannot open $f for reading";
open OUT, ">$TEMP" || die "Cannot make temporary file $TEMP";
while (<IN>) {
s|\@libexecdir\@|@libexecdir@|g; # put all --with-vars before directories
s|\@localstatedir\@|@localstatedir@|g;
s|\@sysconfdir\@|@sysconfdir@|g;
s|\@datarootdir\@|@datarootdir@|g;
s|\@datadir\@|@datadir@|g;
s|\@sbindir\@|@sbindir@|g;
s|\@bindir\@|@bindir@|g;
s|define PACKAGE|define NETMRG_PACKAGE|; # work around autoconf stupidity
s|\$\{exec_prefix\}|@exec_prefix@|g; # must be next to last
s|\$\{prefix\}|@prefix@|g; # must be last
print OUT $_;
}
close OUT;
close IN;
if ((! -e $f) || (`diff $f $TEMP`)) {
rename $TEMP, $f;
} else {
unlink $TEMP;
}
}