This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract a common closure.
[perl5.git] / ext / DynaLoader / Makefile.PL
CommitLineData
28161c97 1use strict;
42793c05
TB
2use ExtUtils::MakeMaker;
3
28161c97
NC
4my $is_mswin = $^O eq 'MSWin32';
5my $is_netware = $^O eq 'NetWare';
6my $is_vms = $^O eq 'VMS';
7
42793c05 8WriteMakefile(
d2cedf73 9 NAME => 'DynaLoader',
4ad3186e 10 LINKTYPE => 'static',
ec29429e 11 DEFINE => '-DLIBC="$(LIBC)"',
4ad3186e 12 SKIP => [qw(dynamic dynamic_lib dynamic_bs)],
13 XSPROTOARG => '-noprototypes', # XXX remove later?
bfab39a2 14 VERSION_FROM => 'DynaLoader_pm.PL',
c440907b
NC
15 PL_FILES => {'DynaLoader_pm.PL'=>'DynaLoader.pm'},
16 PM => {'DynaLoader.pm' => '$(INST_LIBDIR)/DynaLoader.pm'},
25785bc1 17 depend => {'DynaLoader$(OBJ_EXT)' => 'dlutils.c'},
c440907b 18 clean => {FILES => 'DynaLoader.c DynaLoader.xs DynaLoader.pm'},
42793c05
TB
19);
20
cc7e77fd
RU
21sub MY::cflags {
22 package MY;
23 my $flags = shift->SUPER::cflags(@_);
24 if ($flags =~ /-DUSEIMPORTLIB/m) {
25 $flags =~ s/-DUSEIMPORTLIB/-UUSEIMPORTLIB/m;
26 }
27 $flags;
28}
29
42793c05 30sub MY::postamble {
28161c97
NC
31 my $test_xs;
32
33 if ($is_mswin || $is_netware || $is_vms) {
34 $test_xs = '';
35 } else {
36 $test_xs = <<'EOT';
42793c05
TB
37
38# Perform very simple tests just to check for major gaffs.
39# We can\'t do much more for platforms we are not executing on.
40test-xs:
41 for i in dl_*xs; \
005c1a0e 42 do $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSUBPPARGS) $$i > /dev/null; \
42793c05 43 done
28161c97
NC
44EOT
45 }
46
47 return '
48DynaLoader.xs: $(DLSRC)
49 $(RM_F) $@
50 $(CP) $? $@
51' . $test_xs;
42793c05
TB
52}
53
908fcb8b 54sub MY::static {
28161c97
NC
55 my $object;
56 if ($is_mswin || $is_netware) {
57 $object = '$(PERL_SRC)\\$(OBJECT)';
58 } elsif ($is_vms) {
b49e011f 59 $object = '$(PERL_SRC)$(OBJECT)';
28161c97
NC
60 } else {
61 $object = '$(PERL_SRC)/$(OBJECT)';
62 }
63
64
65 return "
66$object : \$(FIRST_MAKEFILE) \$(OBJECT)
67 \$(RM_RF) $object
68 \$(CP) \$(OBJECT) $object
5836a66f 69
28161c97
NC
70static :: $object
71";
908fcb8b 72}