forked from gugod/App-perlbrew
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.PL
59 lines (47 loc) · 1.33 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
my $author = ((grep{ $_ eq '--author' } @ARGV) or -d '.git' && `git remote -v` =~ /git\@github/);
print STDERR "Running as an author mode!\n" if $author;
sub slurp {
my $file = shift;
open CODE, '<', $file;
local $/ = undef;
my $code = <CODE>;
return $code;
}
sub embed {
my $package = shift;
my $code = slurp(
-f $package ? $package : do {
$package =~ s{::}{/}g;
$package .= ".pm";
$INC{$package};
}
);
$code =~ s/(\n__END__\n.*\Z)/\n/ms;
$code =~ s/(\n__DATA__\n.*\Z)/\n/ms;
$code .= "\n\$INC{'$package'} = __FILE__;\n";
return $code;
}
# Author: perl Makefile.PL packs App/perlbrew.pm to perlbrew
if ($author) {
unshift @INC, "lib";
require App::perlbrew;
require HTTP::Lite;
my $script = slurp 'bin/perlbrew';
open OUT, "> perlbrew";
local $, = "\n";
print OUT "#!/usr/bin/env perl",
'# DO NOT EDIT -- this is an auto generated file',
embed('HTTP::Lite'),
embed('App::perlbrew'),
'package main;',
slurp('bin/perlbrew');
}
use inc::Module::Install;
license 'perl';
all_from 'lib/App/perlbrew.pm';
repository 'git://github.com/gugod/App-perlbrew.git';
requires 'HTTP::Lite' => 2.2;
# requires 'local::lib' => 1.004009;
install_script 'bin/perlbrew';
tests 't/*.t';
WriteAll;