File Coverage

Makefile.PL
Criterion Covered Total %
statement n/a
branch n/a
condition n/a
subroutine n/a
pod n/a
total n/a


line stmt bran cond sub pod time code
1             use 5.010;
2             use strict;
3             use warnings;
4             use ExtUtils::MakeMaker;
5             use Config;
6              
7             # Platform-specific linker flags for symbol export.
8             # Other XS modules can use funcutil_callbacks.h to register C-level callbacks.
9             # Solaris/SunOS use their own native ld (not GNU ld) which rejects
10             # --export-dynamic; their default behaviour already exports symbols.
11             my %platform_args;
12             if ($^O eq 'linux' || $^O eq 'freebsd' || $^O eq 'openbsd' || $^O eq 'netbsd' ||
13             $^O eq 'dragonfly') {
14             $platform_args{LDDLFLAGS} = $Config{lddlflags} . ' -Wl,--export-dynamic';
15             }
16             elsif ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys') {
17             $platform_args{LDDLFLAGS} = ($Config{lddlflags} || '') . ' -Wl,--export-all-symbols';
18             }
19              
20             my %WriteMakefileArgs = (
21             NAME => 'Func::Util',
22             AUTHOR => ['LNATION '],
23             VERSION_FROM => 'lib/Func/Util.pm',
24             ABSTRACT_FROM => 'lib/Func/Util.pm',
25             LICENSE => 'artistic_2',
26             MIN_PERL_VERSION => '5.010',
27             macro => { TARFLAGS => "--format=ustar -c -v -f" },
28             CONFIGURE_REQUIRES => {
29             'ExtUtils::MakeMaker' => '0',
30             },
31             TEST_REQUIRES => {
32             'Test::More' => '0',
33             },
34             PREREQ_PM => {},
35             OBJECT => 'FuncUtil$(OBJ_EXT)',
36             C => ['FuncUtil.c'],
37             XS => {},
38             INC => '-Iinclude',
39             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
40             clean => { FILES => 'Func-Util-*' },
41             %platform_args,
42             );
43              
44             # Compatibility with old versions of ExtUtils::MakeMaker
45             unless (eval { ExtUtils::MakeMaker->VERSION('6.64'); 1 }) {
46             my $test_requires = delete $WriteMakefileArgs{TEST_REQUIRES} || {};
47             @{$WriteMakefileArgs{PREREQ_PM}}{keys %$test_requires} = values %$test_requires;
48             }
49              
50             unless (eval { ExtUtils::MakeMaker->VERSION('6.55_03'); 1 }) {
51             my $build_requires = delete $WriteMakefileArgs{BUILD_REQUIRES} || {};
52             @{$WriteMakefileArgs{PREREQ_PM}}{keys %$build_requires} = values %$build_requires;
53             }
54              
55             delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
56             unless eval { ExtUtils::MakeMaker->VERSION('6.52'); 1 };
57             delete $WriteMakefileArgs{MIN_PERL_VERSION}
58             unless eval { ExtUtils::MakeMaker->VERSION('6.48'); 1 };
59             delete $WriteMakefileArgs{LICENSE}
60             unless eval { ExtUtils::MakeMaker->VERSION('6.31'); 1 };
61              
62             WriteMakefile(%WriteMakefileArgs);
63              
64             # Build the test XS helper module (funcutil_export_test) before running tests
65             sub MY::postamble {
66             return <<'MAKE';
67             # Build the XS test helper that exercises the C export registry API
68             # Uses a stamp file to avoid recompiling on every make test
69             t/xs/funcutil_export_test/.built :: $(INST_DYNAMIC) t/xs/funcutil_export_test/funcutil_export_test.c t/xs/funcutil_export_test/Makefile.PL
70             cd t/xs/funcutil_export_test && $(PERLRUN) Makefile.PL && $(MAKE)
71             $(NOECHO) $(TOUCH) t/xs/funcutil_export_test/.built
72              
73             # pure_all is a prerequisite of test_dynamic, so this ensures the helper
74             # is built after the main module but before the test harness runs
75             pure_all :: t/xs/funcutil_export_test/.built
76              
77             clean ::
78             -cd t/xs/funcutil_export_test && $(MAKE) clean 2>/dev/null || true
79             -$(RM_F) t/xs/funcutil_export_test/.built
80             MAKE
81             }