Alt-ExtUtils-PkgConfig-PLICEASE

 view release on metacpan or  search on metacpan

lib/ExtUtils/PkgConfig.pm  view on Meta::CPAN

  %data;
}

sub modversion
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  defined $package ? $package->version : undef;
}

sub cflags
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  defined $package ? $package->cflags : undef;
}

sub libs
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  defined $package ? $package->libs : undef;
}

sub static_libs
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  defined $package ? $package->libs_static : undef;
}

sub _compare_version
{
  PkgConfig::LibPkgConf::Util::compare_version(@_);
}

sub atleast_version
{
  my(undef, $modulename, $version) = @_;
  my $package = _find($modulename);
  $package && (_compare_version($version, $package->version) <= 0 )
  ? 1 : undef;
}

sub exact_version
{
  my(undef, $modulename, $version) = @_;
  my $package = _find($modulename);
  $package && (_compare_version($version, $package->version) == 0 )
  ? 1 : undef;
}

sub max_version
{
  my(undef, $modulename, $version) = @_;
  my $package = _find($modulename);
  $package && (_compare_version($version, $package->version) >= 0 )
  ? 1 : undef;
}

sub _escape
{
  my($fragment) = "$_[0]";
  $fragment =~ s/(\s)/\\$1/g;
  $fragment;
}

sub cflags_only_I
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  $package ? join(' ', map { _escape $_ } grep { $_->type eq 'I' } $package->list_cflags) . ' ' : undef;
}

sub cflags_only_other
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  $package ? join(' ', map { _escape $_ } grep { $_->type ne 'I' } $package->list_cflags) . ' ' : undef;
}

sub libs_only_L
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  $package ? join(' ', map { _escape $_ } grep { $_->type eq 'L' } $package->list_libs) . ' ' : undef;
}

sub libs_only_l
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  $package ? join(' ', map { _escape $_ } grep { $_->type eq 'l' } $package->list_libs) . ' ' : undef;
}

sub libs_only_other
{
  my(undef, $modulename) = @_;
  my $package = _find($modulename);
  $package ? join(' ', map { _escape $_ } grep { $_->type ne 'L' && $_->type ne 'l' } $package->list_libs) . ' ' : undef;
}

sub variable
{
  my(undef, $modulename, $key) = @_;
  my $package = _find($modulename);
  my $value;
  $value = $package->variable($key) if $package;
  $value;
}

# the "create_version_macros" and "write_version_macros" and the documentation
# below are distributed under this license:
#
# Copyright (c) 2003-2004, 2012-2013 by the gtk2-perl team (see the file
# AUTHORS)
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

sub create_version_macros {
  my (undef, $pkg, $stem) = @_;

  if( $pkg && $stem ) {
    my %data = ExtUtils::PkgConfig->find ($pkg);

    if( %data ) {
      my @modversion = split /\./, $data{modversion};
      $modversion[1] = 0 unless defined $modversion[1];
      $modversion[2] = 0 unless defined $modversion[2];

      # If a version part contains non-numeric characters,
      # see if it at least starts with numbers and use those.
      # This is needed for versions like '2.0b2'.
      # foreach ( @modversion ) {
      #   if (/\D/ && /^(\d+)/) {
      #     $_ = $1;
      #   }
      # }
      @modversion =
        map { /\D/ && /^(\d+)/ ? $1 : $_ } @modversion;

      return <<__EOD__;
#define $stem\_MAJOR_VERSION ($modversion[0])
#define $stem\_MINOR_VERSION ($modversion[1])
#define $stem\_MICRO_VERSION ($modversion[2])
#define $stem\_CHECK_VERSION(major,minor,micro) \\
         ($stem\_MAJOR_VERSION > (major) || \\



( run in 2.573 seconds using v1.01-cache-2.11-cpan-9581c071862 )