#! perl -w
require
5.006 ;
my
$WALL
=
''
;
$WALL
=
' -Wall -Wno-comment '
if
$Config
{
'cc'
} =~ /gcc/ ;
my
$LIBLZMA_LIB
;
my
$LIBLZMA_INCLUDE
;
my
$LIBS
=
'-llzma'
;
ParseCONFIG() ;
UpDowngrade(getPerlFiles(
'MANIFEST'
))
unless
$ENV
{PERL_CORE};
WriteMakefile(
NAME
=>
'Compress::Raw::Lzma'
,
VERSION_FROM
=>
'lib/Compress/Raw/Lzma.pm'
,
INC
=>
"-I$LIBLZMA_INCLUDE"
,
LIBS
=> [
"-L${LIBLZMA_LIB} $LIBS"
],
DEFINE
=>
"$WALL "
,
XS
=> {
'Lzma.xs'
=>
'Lzma.c'
},
depend
=> {
Makefile
=>
'config.in'
,
manifypods
=>
'READMEmd'
},
postamble
=> {
name
=>
'Lzma'
},
dist
=> {
COMPRESS
=>
'gzip'
,
TARFLAGS
=>
'-chvf'
,
SUFFIX
=>
'gz'
,
DIST_DEFAULT
=>
'MyTrebleCheck tardist'
,
},
(
$ENV
{SKIP_FOR_CORE}
? (
MAN3PODS
=> {})
: ()
),
(
$] >= 5.005
? (
ABSTRACT_FROM
=>
'lib/Compress/Raw/Lzma.pm'
,
AUTHOR
=>
'Paul Marquess <pmqs@cpan.org>'
)
: ()
),
(
eval
{ ExtUtils::MakeMaker->VERSION(6.46) }
? (
META_MERGE
=> {
"meta-spec"
=> {
version
=> 2 },
no_index
=> {
directory
=> [
't'
,
'private'
],
},
resources
=> {
bugtracker
=> {
},
repository
=> {
type
=>
'git'
,
},
},
}
)
: ()
),
((ExtUtils::MakeMaker->VERSION() gt
'6.55_03'
)
? (
'BUILD_REQUIRES'
=> {
"ExtUtils::MakeMaker"
=> 0,
'Pod::Markdown'
=> 0,
}
)
: ()),
((ExtUtils::MakeMaker->VERSION() gt
'6.30'
) ?
(
'LICENSE'
=>
'perl'
) : ()),
) ;
my
@names
;
while
(<DATA>)
{
chomp
;
s/^\s*//;
s/\s*$//;
next
if
/^[^A-Z]/i || /^$/;
my
(
$name
,
$type
) =
split
/\s+/,
$_
;
if
(
defined
$type
&&
$type
=~ /enum/i)
{
push
@names
, {
name
=>
$name
,
macro
=> [
"#if 1\n"
,
"#endif\n"
] } }
elsif
(
defined
$type
&&
$type
=~ /string/i)
{
push
@names
, {
name
=>
$name
,
type
=>
"PV"
,
macro
=> [
"#ifdef $name \n"
,
"#endif\n"
] } }
elsif
(
defined
$type
&&
$type
=~ /
int
/i)
{
push
@names
, {
name
=>
$name
,
type
=>
"IV"
,
macro
=> [
"#if 1\n"
,
"#endif\n"
] } }
else
{
push
@names
, {
name
=>
$name
} }
}
my
%names
=
map
{
$_
=> 1 }
map
{
$_
->{name} }
@names
;
open
F,
"<lib/Compress/Raw/Lzma.pm"
or
die
"Cannot open Lzma.pm: $!\n"
;
while
(<F>)
{
last
if
/^\s*\
@EXPORT
\s+=\s+
qw\(/ ;
}
while (<F>)
{
last if /^\
s*\)/ ;
/(\S+)/ ;
delete
$names
{$1}
if
defined
$1 ;
}
close
F ;
if
(
keys
%names
)
{
my
$missing
=
join
(
"\n\t"
,
sort
keys
%names
) ;
die
"The following names are missing from \@EXPORT in Lzma.pm\n"
.
"\t$missing\n"
;
}
ExtUtils::Constant::WriteConstants(
NAME
=>
'Lzma'
,
NAMES
=> \
@names
,
C_FILE
=>
'constants.h'
,
XS_FILE
=>
'constants.xs'
,
);
}
else
{
foreach
my
$name
(
qw( constants.h constants.xs )
)
{
my
$from
= catfile(
'fallback'
,
$name
);
copy (
$from
,
$name
)
or
die
"Can't copy $from to $name: $!"
;
}
}
sub
ParseCONFIG
{
my
(
$k
,
$v
) ;
my
@badkey
= () ;
my
%Info
= () ;
my
@Options
=
qw( INCLUDE LIB )
;
my
%ValidOption
=
map
{
$_
, 1}
@Options
;
my
%Parsed
=
%ValidOption
;
my
$CONFIG
=
'config.in'
;
print
"Parsing $CONFIG...\n"
;
open
(F,
"<$CONFIG"
) or
die
"Cannot open file $CONFIG: $!\n"
;
while
(<F>) {
s/^\s*|\s*$//g ;
next
if
/^\s*$/ or /^\s*
s/\s*
(
$k
,
$v
) =
split
(/\s+=\s+/,
$_
, 2) ;
$k
=
uc
$k
;
if
(
$ValidOption
{
$k
}) {
delete
$Parsed
{
$k
} ;
$Info
{
$k
} =
$v
;
}
else
{
push
(
@badkey
,
$k
) ;
}
}
close
F ;
print
"Unknown keys in $CONFIG ignored [@badkey]\n"
if
@badkey
;
my
@missing
= () ;
die
"The following keys are missing from $CONFIG [@missing]\n"
if
@missing
=
keys
%Parsed
;
$LIBLZMA_INCLUDE
=
defined
$ENV
{
'LIBLZMA_INCLUDE'
}
?
$ENV
{
'LIBLZMA_INCLUDE'
}
:
$Info
{
'INCLUDE'
} ;
$LIBLZMA_LIB
=
defined
$ENV
{
'LIBLZMA_LIB'
}
?
$ENV
{
'LIBLZMA_LIB'
}
:
$Info
{
'LIB'
} ;
if
($^O eq
'VMS'
) {
$LIBLZMA_INCLUDE
= VMS::Filespec::vmspath(
$LIBLZMA_INCLUDE
);
$LIBLZMA_LIB
= VMS::Filespec::vmspath(
$LIBLZMA_LIB
);
}
print
<<EOM if 0 ;
INCLUDE [$LIBLZMA_INCLUDE]
LIB [$LIBLZMA_LIB]
EOM
print
"Looks Good.\n"
;
}