my
(
@EUMM_INC_LIB
,
$myarflags
,
$mycflags
);
if
(
$ENV
{CRYPTX_CFLAGS} ||
$ENV
{CRYPTX_LDFLAGS}) {
print
"CRYPTX_CFLAGS = $ENV{CRYPTX_CFLAGS}\n"
if
$ENV
{CRYPTX_CFLAGS};
print
"CRYPTX_LDFLAGS = $ENV{CRYPTX_LDFLAGS}\n"
if
$ENV
{CRYPTX_LDFLAGS};
@EUMM_INC_LIB
= (
INC
=>
$ENV
{CRYPTX_CFLAGS},
LIBS
=> [
$ENV
{CRYPTX_LDFLAGS} ],
);
}
else
{
my
@myobjs
=
map
{ s|.c$|
$Config
{obj_ext}|;
$_
}
grep
{
$_
!~ m|^src/ltc/\.
*tab
\.c$| } (
glob
(
'src/ltm/*.c'
),
glob
(
'src/ltc/*/*.c'
),
glob
(
'src/ltc/*/*/*.c'
),
glob
(
'src/ltc/*/*/*/*.c'
),
glob
(
'src/ltc/*/*/*/*/*.c'
),
);
$mycflags
=
" $Config{ccflags} $Config{cccdlflags} $Config{optimize} "
;
my
$try_aes_ni
= 0;
$try_aes_ni
= 1
if
$Config
{archname} =~ /x86_64/;
$try_aes_ni
= 1
if
$Config
{archname} =~ /MSWin32-x64/;
$try_aes_ni
= 1
if
$Config
{archname} =~ /amd64/;
$try_aes_ni
= 1
if
$Config
{archname} =~ /darwin/ &&
$Config
{myuname} =~ /x86_64/;
$try_aes_ni
= 1
if
$Config
{archname} =~ /i86pc-solaris(-.+)?-64/;
if
(
$try_aes_ni
&&
$Config
{gccversion}) {
my
$ver1
;
$ver1
||= $1
if
$Config
{gccversion} =~ /^([0-9]+)\./;
$ver1
||= $1
if
$Config
{gccversion} =~ /LLVM ([0-9]+)\./i;
$ver1
||= $1
if
$Config
{gccversion} =~ /Clang ([0-9]+)\./i;
$mycflags
.=
" -DLTC_AES_NI"
if
$ver1
> 4;
}
$mycflags
.=
" $ENV{CFLAGS} "
if
$ENV
{CFLAGS};
$mycflags
.=
" $ENV{CPPFLAGS} "
if
$ENV
{CPPFLAGS};
$mycflags
=~ s/\s-pedantic-errors\s/ /g;
$mycflags
=~ s/\s-pedantic\s/ /g;
$mycflags
=~ s/\s-std=c89\s/ /g;
$mycflags
=~ s/\s-ansi\s/ /g;
$mycflags
=~ s/\s-Wwrite-strings\s/ /g;
$mycflags
=~ s/\s-Wcast-qual\s/ /g;
$myarflags
=
'$(AR_STATIC_ARGS)'
;
if
($^O ne
'MSWin32'
&&
$Config
{ar}) {
my
$arver
= `
$Config
{ar} --version 2>/dev/null`;
my
(
$maj
,
$min
) =
$arver
=~ /^GNU ar [^\d]*(\d)\.(\d+)\.\d+/s;
$myarflags
=
'rcD'
if
(
$maj
&&
$min
&&
$maj
>= 2 &&
$min
>= 20) ||
$arver
=~ /^BSD ar /;
}
$mycflags
=
"$mycflags -Wall -Werror -Wextra"
if
$ENV
{AUTHOR_MODE};
@EUMM_INC_LIB
= (
INC
=>
$ENV
{AUTHOR_MODE} ?
'-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm -Wall -Werror -Wextra'
:
'-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm'
,
MYEXTLIB
=>
"src/liballinone$Config{lib_ext}"
,
clean
=> {
'FILES'
=>
join
(
' '
,
@myobjs
,
"src/liballinone$Config{lib_ext}"
) },
);
if
($^O !~ /^(MSWin32|darwin|solaris|aix)$/ && (
$Config
{ld} =~ /gcc|g\+\+/ ||
$Config
{gccversion})) {
push
@EUMM_INC_LIB
, (
LDDLFLAGS
=>
"$Config{lddlflags} -Wl,--exclude-libs,ALL"
);
}
}
my
%eumm_args
= (
NAME
=>
'CryptX'
,
VERSION_FROM
=>
'lib/CryptX.pm'
,
AUTHOR
=>
'Karel Miko'
,
ABSTRACT
=>
'Cryptographic toolkit'
,
MIN_PERL_VERSION
=>
'5.006'
,
LICENSE
=>
'perl_5'
,
PREREQ_PM
=> {
'Math::BigInt'
=> 0 },
TEST_REQUIRES
=> {
'Test::More'
=> 0 },
dist
=> {
PREOP
=>
'perldoc -u lib/CryptX.pm | pod2markdown > README.md'
,
TARFLAGS
=>
'--owner=0 --group=0 -cvf'
},
@EUMM_INC_LIB
);
my
$eumm_ver
=
eval
$ExtUtils::MakeMaker::VERSION
;
delete
$eumm_args
{MIN_PERL_VERSION}
if
$eumm_ver
< 6.48;
delete
$eumm_args
{META_ADD}
if
$eumm_ver
< 6.46;
delete
$eumm_args
{META_MERGE}
if
$eumm_ver
< 6.46;
delete
$eumm_args
{LICENSE}
if
$eumm_ver
< 6.31;
delete
$eumm_args
{CONFIGURE_REQUIRES}
if
$eumm_ver
< 6.52;
delete
$eumm_args
{BUILD_REQUIRES}
if
$eumm_ver
< 6.56;
delete
$eumm_args
{TEST_REQUIRES}
if
$eumm_ver
< 6.64;
WriteMakefile(
%eumm_args
);
sub
MY::postamble {
return
""
unless
$mycflags
&&
$myarflags
;
my
$extra_targets
=
qq{
\$(MYEXTLIB): src/Makefile
cd src && \$(MAKE) ARFLAGS="$myarflags" RANLIB="\$(RANLIB)" AR="\$(AR)" CC="\$(CC)" LIB_EXT=\$(LIB_EXT) OBJ_EXT=\$(OBJ_EXT) CFLAGS="$mycflags"
}
;
$extra_targets
=
qq{
\$(MYEXTLIB): src/Makefile
cd src && \$(MAKE) -f Makefile.nmake CFLAGS="$mycflags"
}
if
$^O eq
'MSWin32'
&&
$Config
{make} =~ /nmake/ &&
$Config
{cc} =~ /cl/;
$extra_targets
=
qq{
\$(MYEXTLIB): src/Makefile
cd src && \$(MAKE) CC="$Config{cc}
" CFLAGS=
"$mycflags"
}
if
$^O eq
'MSWin32'
&&
$Config
{cc} =~ /gcc/;
$extra_targets
.=
q{
update-libtom:
$(NOECHO) perl src/update-libtom.pl
versionsync:
$(NOECHO) perl _generators/version_patch.pl sync
versioninc:
$(NOECHO) perl _generators/version_patch.pl inc
versionincdev:
$(NOECHO) perl _generators/version_patch.pl incdev
versiondec:
$(NOECHO) perl _generators/version_patch.pl dec
versiondecdev:
$(NOECHO) perl _generators/version_patch.pl decdev
gencode:
$(NOECHO) perl _generators/gen.pl gencode
gentest: all
$(NOECHO) perl _generators/gen.pl gentest
openssltest: all
$(NOECHO) perl -Mblib t/openssl/dsa-test.pl
$(NOECHO) perl -Mblib t/openssl/ecc-test.pl
$(NOECHO) perl -Mblib t/openssl/rsa-test.pl
rebuild-pre:
$(RM_F) src/liballinone.a
$(TOUCH) CryptX.xs
rebuild: rebuild-pre all
}
;
return
$extra_targets
;
}