Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 38 lines (25 sloc) 1.04 KB
#!/usr/bin/perl -w
use strict;
BEGIN:
my $input = shift or die("Please supply template filename as 1st argument");
my $prefix = shift or die("Please supply tinyaml install prefix as 2nd argument");
my $version = shift or die("Please supply tinyalk version number as 3rd argument");
sub check_dir() {
while ($_=shift) { return $_ if -d $_; }
return undef;
}
#my @env_pkgconfig=split(':',$ENV{'PKG_CONFIG_PATH'});
my @env_pkgconfig = $ENV{'PKG_CONFIG_PATH'} ? split( ':', $ENV{'PKG_CONFIG_PATH'} ) : ();
my $pkgconfigdir = &check_dir(@env_pkgconfig, "/usr/local/lib/pkgconfig", "/usr/share/pkgconfig", "/usr/lib/pkgconfig") or die("Can't locate pkg-config install directory");
open my $fd, "<$input";
my $basename = $input;
$basename =~ s/.*\///;
my $pcfile = "$pkgconfigdir/$basename";
$pcfile =~ s/\.in$//;
open my $out, ">$pcfile" or die("Couldn't open file $pcfile for writing.\n");
print "Installing pkg-config file as $pcfile.\n";
while(my $line=<$fd>) {
$line =~ s/#PREFIX#/$prefix/g;
$line =~ s/#VERSION#/$version/g;
print $out $line;
}