File: subst.in

package info (click to toggle)
netmrg 0.18.2-14
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,104 kB
  • ctags: 1,575
  • sloc: xml: 8,912; php: 7,389; sh: 4,019; cpp: 2,581; perl: 471; ansic: 338; makefile: 316; sql: 5
file content (46 lines) | stat: -rwxr-xr-x 1,027 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w

use strict;

my ${prefix} = "@prefix@";
my ${exec_prefix} = "@exec_prefix@";

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|\@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;
	}

}