Alien-FLTK
view release on metacpan or search on metacpan
inc/MBTFLTK.pm view on Meta::CPAN
),
module_name => join '::',
@dirnames,
$file_base
);
}
sub get_lib {
my ($meta) = @_;
my $location;
my $index = 'https://api.github.com/repos/fltk/fltk/tags';
{
print "Finding most recent version...";
my $response = HTTP::Tiny->new->get($index);
if ($response->{success}) {
# Snapshots don't contain fltk-config script
my $tags = decode_json $response->{content};
printf "\nGrabbing %s snapshot (%s)\n", $tags->[0]{name}, $tags->[0]{commit}{sha};
$location = $tags->[0]{tarball_url};
}
else {
print " Hrm. Grabbing latest known release\n";
$location
= 'https://github.com/fltk/fltk/archive/release-1.3.4-2.tar.gz';
}
}
my $file = basename($location) . '.tar.gz';
{
print "Downloading $location...";
my $response = HTTP::Tiny->new->mirror($location, $file);
if ($response->{success}) {
print " Done\n";
return $file;
}
}
exit !!print " Fail!";
}
sub build_lib {
my ($options) = @_;
my (%libinfo, $dir);
my $meta = $options->{meta};
my $cwd = rel2abs './'; # XXX - use Cwd;
# This is an ugly cludge. A working, ugly cludge though. :\
if (!-d 'share') {
mkpath('share', $options->{verbose}, oct '755') unless -d 'share';
$dir = tempd();
$libinfo{archive} = get_lib($meta->custom('x_alien'));
print "Extracting...";
my $ae = Archive::Extract->new(archive => $libinfo{archive});
exit print " Fail! " . $ae->error if !$ae->extract();
print " Done\nConfigure...\n";
chdir($ae->extract_path);
system q[NOCONFIGURE=1 ./autogen.sh];
system q[sh ./configure --enable-shared];
$libinfo{cflags} = `sh ./fltk-config --cflags --optim`;
$libinfo{cxxflags} = `sh ./fltk-config --cxxflags --optim`;
$libinfo{ldflags} = `sh ./fltk-config --ldflags`;
$libinfo{ldflags_gl} = `sh ./fltk-config --ldflags --use-gl`;
$libinfo{ldflags_gl_images}
= `sh ./fltk-config --ldflags --use-gl --use-images`;
$libinfo{ldflags_images} = `sh ./fltk-config --ldflags --use-images`;
# XXX - The following block is a mess!!!
chdir 'src';
my $gmake = can_run('gmake');
my $make = can_run('make');
printf "Checking for gmake... %s\n", ($gmake ? 'yes' : 'no');
printf "Checking for make... %s\n", ($make ? 'yes' : 'no');
#system(($gmake ? 'g' : '') . q[make -ns > build.sh]);
#system q[sh build.sh];
system(($gmake ? 'g' : '') . q[make -j 10]);
chdir '..';
my $archdir = catdir($cwd, qw[share]);
mkpath($archdir, $options->{verbose}, oct '755') unless -d $archdir;
# XXX - Copy FL => shared dir
dircopy rel2abs('FL'), catdir($archdir, 'include', 'FL')
or die $!;
copy
rel2abs(catdir('config.h')),
catdir($archdir, 'include', 'config.h')
or die $!;
dircopy rel2abs('lib'), catdir($archdir, 'lib')
or die $!;
#
write_file(catfile($archdir, qw[config.json]),
'utf8', encode_json(\%libinfo));
}
}
sub find {
my ($pattern, $dir) = @_;
my @ret;
File::Find::find(sub { push @ret, $File::Find::name if /$pattern/ && -f },
$dir)
if -d $dir;
return @ret;
}
my %actions = (
build => sub {
my %opt = @_;
system $^X, $_ and die "$_ returned $?\n" for find(qr/\.PL$/, 'lib');
my %modules
= map { $_ => catfile('blib', $_) } find(qr/\.p(?:m|od)$/, 'lib');
my %scripts = map { $_ => catfile('blib', $_) } find(qr//, 'script');
build_lib(\%opt);
my %shared = map {
$_ => catfile(qw/blib lib auto share dist/,
$opt{meta}->name, abs2rel($_, 'share'))
} find(qr//, 'share');
pm_to_blib({%modules, %scripts, %shared}, catdir(qw/blib lib auto/));
make_executable($_) for values %scripts;
mkpath(catdir(qw/blib arch/), $opt{verbose});
process_xs($_, \%opt) for find(qr/.xs$/, 'lib');
if ( $opt{install_paths}->install_destination('libdoc')
&& $opt{install_paths}->is_default_installable('libdoc'))
{ manify($_,
catfile('blib', 'bindoc', man1_pagename($_)),
$opt{config}->get('man1ext'), \%opt)
( run in 2.963 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )