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