Merge pull request #2240 from DOCGroup/revert-2239-jwi-pi23
[ACE_TAO.git] / ACE / bin / ace_install_pkgconfig.pl
blob6564fe9f2303f6bd4fe314f7235df0a4fddec580
1 eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}'
2 & eval 'exec perl -w -S $0 $argv:q'
3 if 0;
4 # ********************************************************************
5 # ace_install_pkgconfig.pl - Creates *.pc files for pkg-config in the
6 # installed location, based on the *.pc.in
7 # files from the source tree, with @foo@
8 # variables replaced with their values.
9 # Called from the MPC-generated makefiles.
10 # ********************************************************************
12 use strict;
13 use Getopt::Long;
15 my ($prefix, $libdir, $libs, $destdir, $version, %custom);
16 GetOptions('prefix=s' => \$prefix, 'libdir=s' => \$libdir, 'libs=s' => \$libs,
17 'destdir=s' => \$destdir,
18 'version=s' => \$version, 'custom=s' => \%custom);
20 my %subs = ('LIBS' => $libs, 'VERSION' => $version, 'exec_prefix' => $prefix,
21 'prefix' => $prefix, 'includedir' => "$prefix/include",
22 'libdir' => "$prefix/$libdir");
24 for my $k (keys %custom) {
25 $subs{$k} = $custom{$k};
28 my $pcdir = "${destdir}$prefix/$libdir/pkgconfig";
29 if (scalar @ARGV && ! -d $pcdir) {
30 mkdir($pcdir, 0755);
33 for my $file (@ARGV) {
34 open IN, $file or die $file . ": $!";
35 my $pcfile = $file;
36 $pcfile =~ s/\.in$//;
37 open OUT, ">$pcdir/$pcfile";
38 while (<IN>) {
39 s/@(\w+)@/exists $subs{$1} ? $subs{$1} : $&/ge;
40 print OUT $_;
42 close OUT;
43 close IN;