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