]> Dogcows Code - chaz/p5-File-KDBX-XS/blob - Makefile.PL
4e627012a3e34d2dc31001ba8aaaa3cf8d154f57
[chaz/p5-File-KDBX-XS] / Makefile.PL
1 #!/usr/bin/env perl
2
3 use warnings;
4 use strict;
5
6 use Config;
7 use ExtUtils::MakeMaker;
8
9 ##{ $share_dir_code{preamble} || '' ##}
10
11 my (@EUMM_INC_LIB, $myarflags, $mycflags);
12
13 # use bundled libtomcrypt
14 my @myobjs = map { /^(.*)\.c$/ ? "$1.$Config{obj_ext}" : () } qw(
15 libtomcrypt/src/ciphers/aes/aes.c
16 libtomcrypt/src/misc/compare_testvector.c
17 libtomcrypt/src/misc/crypt/crypt_argchk.c
18 libtomcrypt/src/misc/zeromem.c
19 );
20 $mycflags = " $Config{ccflags} $Config{cccdlflags} $Config{optimize} "; # keep leading + trailing spaces
21
22 #FIX: this is particularly useful for Debian https://github.com/DCIT/perl-CryptX/pull/39
23 $mycflags .= " $ENV{CFLAGS} " if $ENV{CFLAGS};
24 $mycflags .= " $ENV{CPPFLAGS} " if $ENV{CPPFLAGS};
25
26 #### remove all lto hacks - https://github.com/DCIT/perl-CryptX/issues/70
27 ## #FIX: gcc with -flto is a trouble maker see https://github.com/DCIT/perl-CryptX/issues/32
28 ## #FIX: another issue with "-flto=auto" see https://github.com/DCIT/perl-CryptX/pull/66
29 ## $mycflags =~ s/\s-flto\S+\s/ /g; # -flto -flto=auto -flto=jobserver -flto=N ...
30
31 #FIX: avoid -Wwrite-strings -Wcast-qual -pedantic -pedantic-errors -ansi -std=c89
32 $mycflags =~ s/\s-pedantic-errors\s/ /g;
33 $mycflags =~ s/\s-pedantic\s/ /g;
34 $mycflags =~ s/\s-std=c89\s/ /g;
35 $mycflags =~ s/\s-ansi\s/ /g;
36 $mycflags =~ s/\s-Wwrite-strings\s/ /g;
37 $mycflags =~ s/\s-Wcast-qual\s/ /g;
38
39 #FIX: avoid "ar: fatal: Numeric group ID too large" see https://github.com/DCIT/perl-CryptX/issues/33
40 $myarflags = '$(AR_STATIC_ARGS)';
41 if ($^O ne 'MSWin32' && $Config{ar}) {
42 # for ar's "deterministic mode" we need GNU binutils 2.20+ (2009-10-16)
43 my $arver = `$Config{ar} --version 2>/dev/null`;
44 my ($maj, $min) = $arver =~ /^GNU ar [^\d]*(\d)\.(\d+)\.\d+/s;
45 $myarflags = 'rcD' if ($maj && $min && $maj >= 2 && $min >= 20) || $arver=~ /^BSD ar /;
46 }
47
48 # turn on extra warnings in AUTHOR_MODE (it is gcc only!!)
49 $mycflags = "$mycflags -Wall -Werror -Wextra" if $ENV{AUTHOR_MODE};
50
51 @EUMM_INC_LIB = (
52 INC => $ENV{AUTHOR_MODE} ? '-DLTM_DESC -Ilibtomcrypt/src/headers -Wall -Werror -Wextra' # gcc only
53 : '-DLTM_DESC -Ilibtomcrypt/src/headers',
54 MYEXTLIB => "libtomcrypt/libonlyaes$Config{lib_ext}",
55 clean => { FILES => join(' ', @myobjs, "libtomcrypt/libonlyaes$Config{lib_ext}") },
56 );
57
58 #FIX: https://github.com/DCIT/perl-CryptX/pull/79
59 # not needed on MS Windows
60 # does not work on macos - Apple LLVM 12.0.5 (clang-1205.0.22.9) ld: unknown option: --exclude-libs
61 # does not work on solaris - gcc 9.3.0 - ld: fatal: unrecognized option '--exclude-libs'
62 if ($^O !~ /^(MSWin32|darwin|solaris)$/ && ($Config{ld} =~ /gcc|g\+\+/ || $Config{gccversion})) {
63 push @EUMM_INC_LIB, (LDDLFLAGS => "$Config{lddlflags} -Wl,--exclude-libs,ALL");
64 }
65
66 my %eumm_args = (
67 ##{ $plugin->get_default(qw{ABSTRACT AUTHOR DISTNAME LICENSE MIN_PERL_VERSION NAME VERSION test}) ##}
68 ##{ $plugin->get_prereqs(1) ##}
69 @EUMM_INC_LIB,
70 );
71
72 my $eumm_ver = eval $ExtUtils::MakeMaker::VERSION;
73 delete $eumm_args{MIN_PERL_VERSION} if $eumm_ver < 6.48;
74 delete $eumm_args{META_ADD} if $eumm_ver < 6.46;
75 delete $eumm_args{META_MERGE} if $eumm_ver < 6.46;
76 delete $eumm_args{LICENSE} if $eumm_ver < 6.31;
77 delete $eumm_args{CONFIGURE_REQUIRES} if $eumm_ver < 6.52;
78 delete $eumm_args{BUILD_REQUIRES} if $eumm_ver < 6.56;
79 delete $eumm_args{TEST_REQUIRES} if $eumm_ver < 6.64;
80
81 WriteMakefile(%eumm_args);
82
83 sub MY::postamble {
84 return "" unless $mycflags && $myarflags;
85
86 my $extra_targets = qq{
87 \$(MYEXTLIB): libtomcrypt/Makefile
88 \tcd libtomcrypt && \$(MAKE) ARFLAGS="$myarflags" RANLIB="\$(RANLIB)" AR="\$(AR)" CC="\$(CC)" LIB_EXT=\$(LIB_EXT) OBJ_EXT=\$(OBJ_EXT) CFLAGS="$mycflags"
89 };
90
91 $extra_targets = qq{
92 \$(MYEXTLIB): libtomcrypt/Makefile
93 \tcd libtomcrypt && \$(MAKE) -f Makefile.nmake CFLAGS="$mycflags"
94 } if $^O eq 'MSWin32' && $Config{make} =~ /nmake/ && $Config{cc} =~ /cl/;
95
96 $extra_targets = qq{
97 \$(MYEXTLIB): libtomcrypt/Makefile
98 \tcd libtomcrypt && \$(MAKE) CC="$Config{cc}" CFLAGS="$mycflags"
99 } if $^O eq 'MSWin32' && $Config{cc} =~ /gcc/;
100
101 return $extra_targets;
102 }
103
104 ##{ $share_dir_code{postamble} || '' ##}
This page took 0.037157 seconds and 3 git commands to generate.