summaryrefslogtreecommitdiff
path: root/ACE/bin/ace_install_pkgconfig.pl
blob: 587b7c3b277b7f7becb61c8804c814c07301cee5 (plain)
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
eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}'
    & eval 'exec perl -w -S $0 $argv:q'
    if 0;
# ********************************************************************
# $Id$
# ace_install_pkgconfig.pl - Creates *.pc files for pkg-config in the
#                            installed location, based on the *.pc.in
#                            files from the source tree, with @foo@
#                            variables replaced with their values.
#                            Called from the MPC-generated makefiles.
# ********************************************************************

use strict;
use Getopt::Long;

my ($prefix, $libdir, $libs, $destdir, $version, %custom);
GetOptions('prefix=s' => \$prefix, 'libdir=s' => \$libdir, 'libs=s' => \$libs,
           'destdir=s' => \$destdir,
           'version=s' => \$version, 'custom=s' => \%custom);

my %subs = ('LIBS' => $libs, 'VERSION' => $version, 'exec_prefix' => $prefix,
            'prefix' => $prefix, 'includedir' => "$prefix/include",
            'libdir' => "$prefix/$libdir");

for my $k (keys %custom) {
  $subs{$k} = $custom{$k};
}

my $pcdir = "${destdir}$prefix/$libdir/pkgconfig";
if (scalar @ARGV && ! -d $pcdir) {
  mkdir($pcdir, 0755);
}

for my $file (@ARGV) {
  open IN, $file;
  my $pcfile = $file;
  $pcfile =~ s/\.in$//;
  open OUT, ">$pcdir/$pcfile";
  while (<IN>) {
    s/@(\w+)@/exists $subs{$1} ? $subs{$1} : $&/ge;
    print OUT $_;
  }
  close OUT;
  close IN;
}