Alien-FLTK

 view release on metacpan or  search on metacpan

inc/MBTFLTK.pm  view on Meta::CPAN

            = `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)
                for keys %scripts;
            manify($_,
                   catfile('blib', 'libdoc', man3_pagename($_)),
                   $opt{config}->get('man3ext'), \%opt)
                for keys %modules;
        }
    },
    test => sub {
        my %opt = @_;
        die "Must run `./Build build` first\n" if not -d 'blib';
        require TAP::Harness;
        my $tester = TAP::Harness->new(
            {verbosity => $opt{verbose},
             lib       => [
                 map {
                     rel2abs(catdir(qw/blib/, $_))
                 } qw/arch lib/
             ],
             color => -t STDOUT
            }
        );
        $tester->runtests(sort +find(qr/\.t$/, 't'))->has_errors and exit 1;
    },
    install => sub {
        my %opt = @_;
        die "Must run `./Build build` first\n" if not -d 'blib';
        install($opt{install_paths}->install_map,
                @opt{qw/verbose dry_run uninst/});
    },
);

sub Build {
    my $action = @ARGV && $ARGV[0] =~ /\A\w+\z/ ? shift @ARGV : 'build';
    die "No such action '$action'\n" if not $actions{$action};
    unshift @ARGV, @{decode_json(read_file('_build_params', 'utf8'))};
    GetOptions(\my %opt,
               qw/install_base=s install_path=s% installdirs=s destdir=s prefix=s config=s% uninst:1 verbose:1 dry_run:1 pureperl-only:1 create_packlist=i/
    );
    $_ = detildefy($_)
        for grep {defined} @opt{qw/install_base destdir prefix/},
        values %{$opt{install_path}};
    @opt{'config', 'meta'}
        = (ExtUtils::Config->new($opt{config}), get_meta());
    $actions{$action}->(
          %opt,
          install_paths =>
              ExtUtils::InstallPaths->new(%opt, dist_name => $opt{meta}->name)
    );
}

sub Build_PL {
    my $meta = get_meta();
    printf "Creating new 'Build' script for '%s' version '%s'\n",
        $meta->name, $meta->version;
    my $dir = $meta->name eq 'MBTFLTK' ? '' : "use lib 'inc';";
    write_file('Build', 'raw',
               "#!perl\n$dir\nuse MBTFLTK;\n\$|++;\nBuild();\n");
    make_executable('Build');
    my @env



( run in 1.491 second using v1.01-cache-2.11-cpan-2398b32b56e )