Skip to content

Instantly share code, notes, and snippets.

@somian
Created March 30, 2013 20:10
Show Gist options
  • Save somian/5278159 to your computer and use it in GitHub Desktop.
Save somian/5278159 to your computer and use it in GitHub Desktop.
This is not a complete script; but it illustrates some changes to a Makefile.PL to get around the noise from that uptight, unhappy little nun "ExtUtils::LibList".
use ExtUtils::MakeMaker;
use File::Spec;
use Cwd;
use strict;
# Adapted from a Makefile.PL for Glib.pm, Copyright (C) 2003-2009, 2012 by
# the gtk2-perl team [...]
our %PREREQ_PM = (
'ExtUtils::Depends' => '0.300',
'ExtUtils::PkgConfig' => '1.000',
);
# Writing a fake Makefile ensures that CPAN will pick up the correct
# dependencies and install them.
unless (eval "use ExtUtils::Depends '$PREREQ_PM{'ExtUtils::Depends'}';"
. "use ExtUtils::PkgConfig '$PREREQ_PM{'ExtUtils::PkgConfig'}';"
. "1") {
warn "$@\n";
WriteMakefile(
NAME => 'Glib',
PREREQ_FATAL => 1,
PREREQ_PM => \%PREREQ_PM,
);
exit 1; # not reached
}
my %mm_kv = $cobj->get_makefile_vars;
$::got_lib = $mm_kv{'LIBS'};
# shut EU-Liblist up the only way possible: do not invite her to our WriteMakefile()
# party at all:
delete $mm_kv{'LIBS'};
# ...but override `const_loadlibs´ below; otherwise we will be missing Makefile
# declarations that *must* be provided for package to build.
WriteMakefile(
NAME => 'Glib',
VERSION_FROM => 'lib/Glib.pm', # finds $VERSION
ABSTRACT_FROM => 'lib/Glib.pm', # retrieve abstract from module
PREREQ_PM => \%PREREQ_PM,
XSPROTOARG => '-noprototypes',
MAN3PODS => $cobj ? \%pod_files : {},
FUNCLIST => \@exports,
DL_FUNCS => { Glib => [] },
META_MERGE => \%meta_merge,
$cobj ? %mm_kv : (),
);
# [...]
sub MY::const_loadlibs
{
require 5.008; # "open" to a string buffer will not work before this?
my ($self) = @_;
my $crunch = my $inexpr = $::got_lib;
die unless $crunch;
my @is = split(q[ ]=> $crunch);
my $lgood;
my $rectfie = sub { my @ele; for my $lobster_shoes (@_) {
$lobster_shoes=~tr{\\}{/};
push @ele, $lobster_shoes;
} return @ele
};
# Because shoes for lobsters is just wrong, and so are backslashes for perl
# pathnames ...nearly never needed / right / non-ugly.
# But do not mess with args for configury on other OSes:
if ($^O !~ m{MSWin}i) {
$rectify = sub { return @_ };
}
my $prettier = sub {
my $aw = eval 'require Text::Wrap; 1';
if ($@ or !$aw) { return @_ }
my @input = map {$rectfie->($_)} @_;
my $evcode = <<' INANDOUT';
local $Text::Wrap::columns = 72;
local $Text::Wrap::separator = qq[ \\\n];
local $Text::Wrap::huge = 'overflow';
Text::Wrap::wrap( q[ ] x 1,
q[ ] x 22,
@input);
INANDOUT
# print STDERR qq[Generated string\n:] . eval $evcode;
return eval $evcode;
};
$crunch = $prettier->($crunch);
my $OSfam = $^O;
my $captbuf;
my($E,$B,$L,$R,$libpath);
{
no warnings 'once';
open SAVEERR, ">&STDERR";
close STDERR;
$captbuf = '';
open STDERR, '>', \$captbuf or die "Cannot capture STDERR: $!";
if ($^O =~ /mswin/i) { $inexpr = q[:NODEFAULT ].$inexpr; }
($E,$B,$L,$R,$libpath) = $self->ext($inexpr, "0", "1");
close STDERR;
open STDERR, ">&SAVEERR";
}
$lgood = $prettier->(@$libpath);
my $Es = ($E ne $L) ? $E : $lgood;
my $Ls = ($self->{CC} =~/gcc/i) ? $crunch : $lgood;
my $Bs = ($B =~/\A\s*\z/ ) ? "":$B;
if ($E ne $L) {
$E = $rectfie->($E);
$L = $rectfie->($L);
} else {
$E = q[];
$L = q[];
}
my $mftext = qq{
# Glib.pm on $OSfam depends on these external libraries:
#
EXTRALIBS =$Es
#--# [$E]
LDLOADLIBS =$Ls
#--# [$L]
BSLOADLIBS =$Bs
#
# The ExtUtils::Liblist program was used to generate these lists from
# the input
#
# $crunch
#
};
}
__END__
This is not a complete script. 2013-03-30 GMT-04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment