-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBuild.PL
137 lines (127 loc) · 3.77 KB
/
Build.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
use strict;
use warnings;
use lib 'inc';
use MyBuilder;
use Config;
use File::Spec::Functions qw.catdir catfile.;
use File::Copy;
my $version = get_version();
my $builder = MyBuilder->new(
module_name => 'Text::BibTeX',
license => 'perl',
dist_author =>
[ 'Alberto Simões <[email protected]>', 'Greg Ward <[email protected]>' ],
needs_compiler => 1,
meta_merge => {
resources => { repository => 'http://github.com/ambs/Text-BibTeX', },
},
configure_requires => {
'Module::Build' => '0.36',
'Config::AutoConf' => '0.16',
'ExtUtils::LibBuilder' => '0.09',
},
requires => {
'Scalar::Util' => '1.42',
'Unicode::Normalize' => '0',
'Encode' => '0',
},
build_requires => {
'File::Copy' => '0',
'Config::AutoConf' => '0.320',
'ExtUtils::LibBuilder' => '0.02',
'Capture::Tiny' => '0.06',
'ExtUtils::CBuilder' => '0.27',
'Module::Build' => '0.3603',
'Cwd' => '0',
},
add_to_cleanup => [
'Text-BibTeX-*',
# NOT SURE YET 'btparse/src/bt_config.h',
'btparse/src/*.so',
'btparse/src/*.dylib',
'btparse/src/*.dll',
'btparse/src/*.o',
'xscode/*.o',
'btparse/tests/*.o',
'btparse/progs/*.o',
'btparse/progs/dumpnames',
'btparse/progs/bibparse',
'btparse/progs/biblex',
'btparse/tests/postprocess_test',
'btparse/tests/read_test',
'btparse/tests/simple_test',
'btparse/tests/macro_test',
'btparse/tests/case_test',
'btparse/tests/name_test',
'btparse/tests/purify_test',
'btparse/tests/namebug'
],
);
## HACK HACK HACK HACK
my $libdir = $builder->install_destination("bin");
my $hdrdir = undef;
if ( $^O =~ /mswin32/i ) {
$libdir = undef;
# Find a place where we can write.
my @folders = split /;/, $ENV{PATH};
my $installed = 0;
my $target = "text-bibtex.$$";
while ( @folders && !$installed ) {
$libdir = shift @folders;
copy( "MANIFEST", catfile( $libdir, $target ) );
$installed = 1 if -f catfile( $libdir, $target );
}
if ( !$installed ) {
warn("Wasn't able to find a suitable place for libbtparse.dll!");
}
else {
print STDERR "libbtparse.dll will be installed in $libdir\n";
unlink catfile( $libdir, $target );
}
}
elsif ( $^O =~ /haiku/i ) {
$libdir =~ s/\bbin\b/lib/;
$hdrdir = $libdir;
$hdrdir =~ s!\blib\b!develop/headers!;
if ( $Config{archname} =~ /BePC/ ) {
$libdir .= "/x86";
$hdrdir .= "/x86";
}
}
else {
if ( $Config{archname} =~ /^x86_64|^ppc64|^s390x|^aarch64|^riscv64/ ) {
$libdir =~ s/\bbin\b/lib64/;
if ( !-d $libdir ) {
my $test = $libdir;
$test =~ s/lib64/lib/;
$libdir = $test if -d $test;
}
}
else {
$libdir =~ s/\bbin\b/lib/;
}
$hdrdir = $libdir;
$hdrdir =~ s!/[^/]+/?$!/include!
}
$builder->notes( 'btparse_version' => $version );
$builder->notes( 'lib_path' => $libdir );
$builder->add_build_element('usrlib');
$builder->install_path( 'usrlib' => $libdir );
if (defined($hdrdir)) {
$builder->add_build_element('usrinclude');
$builder->install_path( 'usrinclude' => $hdrdir );
}
$builder->create_build_script;
sub get_version {
my $version = undef;
open PM, "lib/Text/BibTeX.pm"
or die "Cannot open 'lib/Text/BibTeX.pm' for reading: $!\n";
while (<PM>) {
if (m!^our\s+\$VERSION\s*=\s*'([^']+)'!) {
$version = $1;
last;
}
}
close PM;
die "Could not find VERSION on your .pm file. Weirdo!\n" unless $version;
}