summaryrefslogtreecommitdiff
path: root/ext/DynaLoader/Makefile.PL
blob: 76c3bc0c7eb619aa8626d67eebf8e5f43283adef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use strict;
use ExtUtils::MakeMaker;

my $is_mswin    = $^O eq 'MSWin32';
my $is_netware  = $^O eq 'NetWare';
my $is_vms      = $^O eq 'VMS';

WriteMakefile(
    NAME => 'DynaLoader',
    LINKTYPE	=> 'static',
    DEFINE	=> '-DLIBC="$(LIBC)"',
    SKIP	=> [qw(dynamic dynamic_lib dynamic_bs)],
    XSPROTOARG => '-noprototypes', 		# XXX remove later?
    VERSION_FROM => 'DynaLoader_pm.PL',
    PL_FILES	=> {'DynaLoader_pm.PL'=>'DynaLoader.pm'},
    PM		=> {'DynaLoader.pm' => '$(INST_LIBDIR)/DynaLoader.pm'},
    depend      => {'DynaLoader$(OBJ_EXT)' => 'dlutils.c'},
    clean	=> {FILES => 'DynaLoader.c DynaLoader.xs DynaLoader.pm'},
);

sub MY::cflags {
  package MY;
  my $flags = shift->SUPER::cflags(@_);
  if ($flags =~ /-DUSEIMPORTLIB/m) {
    $flags =~ s/-DUSEIMPORTLIB/-UUSEIMPORTLIB/m;
  }
  $flags;
}

sub MY::postamble {
    my $test_xs;

    if ($is_mswin || $is_netware || $is_vms) {
	$test_xs = '';
    } else {
	$test_xs = <<'EOT';

# Perform very simple tests just to check for major gaffs.
# We can\'t do much more for platforms we are not executing on.
test-xs:
	for i in dl_*xs; \
	    do $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSUBPPARGS) $$i > /dev/null; \
	done
EOT
    }

    return '
DynaLoader.xs: $(DLSRC)
	$(RM_F) $@
	$(CP) $? $@
' . $test_xs;
}

sub MY::static {
    my $object;
    if ($is_mswin || $is_netware) {
	$object = '$(PERL_SRC)\\$(OBJECT)';
    } elsif ($is_vms) {
	$object = '$(PERL_SRC)$(OBJECT)';
    } else {
	$object = '$(PERL_SRC)/$(OBJECT)';
    }


    return "
$object : \$(FIRST_MAKEFILE) \$(OBJECT)
	\$(RM_RF) $object
	\$(CP) \$(OBJECT) $object

static :: $object
";
}