File: subst.in

package info (click to toggle)
netmrg 0.20-2.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,820 kB
  • ctags: 2,009
  • sloc: php: 9,401; sh: 4,597; cpp: 2,898; perl: 621; ansic: 381; makefile: 331; xml: 92; sql: 71; sed: 16
file content (48 lines) | stat: -rwxr-xr-x 1,101 bytes parent folder | download | duplicates (4)
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;
	}

}