File: replace_autoconf_vars

package info (click to toggle)
atool 0.39.0-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 672 kB
  • sloc: perl: 1,797; sh: 625; makefile: 47
file content (43 lines) | stat: -rw-r--r-- 885 bytes parent folder | download | duplicates (10)
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
#!/usr/bin/perl -w
# This script reads configure.ac, and replaces all occurences of
# @.+@ in script and manpage with values.
# It returns 0 on success, 1 if it missed something.
#
# Stphane (kwisatz) Jourdois <kwisatz@rubis.org>
# Mon, 16 Aug 2004 15:22:24 +0200

use strict;

my %vars = (
	'PERL' => '/usr/bin/perl',
);

my ($from, $to) = @ARGV;

open AC, '<configure.ac' or die "Cannot read configure.ac: $!\n";

while (<AC>) {
	if (/^AC_INIT\((\w+), ([0-9.]+), .+\)/) {
		$vars{'PACKAGE_NAME'} = $1;
		$vars{'PACKAGE_VERSION'} = $2;

		# Remove this line if there is are
		# other interesting lines in configure.ac
		# For now there isn't.
		last;
	}
}
close AC;

open FROM, "<$from" or die "Cannot read $from: $!\n";
open TO, ">$to" or die "Cannot write $to: $!\n";

while (<FROM>) {
	for my $var (keys %vars) {
		s/\@$var\@/$vars{$var}/g;
	}
	print TO;
}

close FROM;
close TO;