[PATCH] is() undef/'' behavior change
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_OS2.pm
CommitLineData
1e44e2bf 1package ExtUtils::MM_OS2;
2
b75c8c73 3use strict;
4
5our $VERSION = '1.00';
6
1e44e2bf 7#use Config;
8#use Cwd;
9#use File::Basename;
10require Exporter;
11
b75c8c73 12require ExtUtils::MakeMaker;
13ExtUtils::MakeMaker->import(qw( $Verbose &neatvalue));
1e44e2bf 14
ecf68df6 15use File::Spec;
16
1e44e2bf 17unshift @MM::ISA, 'ExtUtils::MM_OS2';
18
bbc7dcd2 19=pod
20
21=head1 NAME
22
23ExtUtils::MM_OS2 - methods to override UN*X behaviour in ExtUtils::MakeMaker
24
25=head1 SYNOPSIS
26
27 use ExtUtils::MM_OS2; # Done internally by ExtUtils::MakeMaker if needed
28
29=head1 DESCRIPTION
30
31See ExtUtils::MM_Unix for a documentation of the methods provided
32there. This package overrides the implementation of these methods, not
33the semantics.
34
35=head1 METHODS
36
37=over 4
38
39=cut
40
1e44e2bf 41sub dlsyms {
42 my($self,%attribs) = @_;
43
44 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
45 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
762efda7 46 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
1e44e2bf 47 my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
48 my(@m);
49 (my $boot = $self->{NAME}) =~ s/:/_/g;
50
51 if (not $self->{SKIPHASH}{'dynamic'}) {
52 push(@m,"
53$self->{BASEEXT}.def: Makefile.PL
54",
55 ' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
3cfae81b 56 Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ',
57 '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ',
58 '"INSTALLDIRS" => "$(INSTALLDIRS)", ',
59 '"DL_FUNCS" => ',neatvalue($funcs),
017f25f1 60 ', "FUNCLIST" => ',neatvalue($funclist),
1e44e2bf 61 ', "IMPORTS" => ',neatvalue($imports),
3cfae81b 62 ', "DL_VARS" => ', neatvalue($vars), ');\'
1e44e2bf 63');
64 }
659f4fc5 65 if ($self->{IMPORTS} && %{$self->{IMPORTS}}) {
017f25f1 66 # Make import files (needed for static build)
67 -d 'tmp_imp' or mkdir 'tmp_imp', 0777 or die "Can't mkdir tmp_imp";
68 open IMP, '>tmpimp.imp' or die "Can't open tmpimp.imp";
69 my ($name, $exp);
70 while (($name, $exp)= each %{$self->{IMPORTS}}) {
71 my ($lib, $id) = ($exp =~ /(.*)\.(.*)/) or die "Malformed IMPORT `$exp'";
72 print IMP "$name $lib $id ?\n";
73 }
74 close IMP or die "Can't close tmpimp.imp";
75 # print "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp\n";
76 system "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp"
77 and die "Cannot make import library: $!, \$?=$?";
78 unlink <tmp_imp/*>;
79 system "cd tmp_imp; $Config::Config{ar} x ../tmpimp$Config::Config{lib_ext}"
80 and die "Cannot extract import objects: $!, \$?=$?";
81 }
1e44e2bf 82 join('',@m);
83}
84
017f25f1 85sub static_lib {
86 my($self) = @_;
87 my $old = $self->ExtUtils::MM_Unix::static_lib();
659f4fc5 88 return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}};
017f25f1 89
90 my @chunks = split /\n{2,}/, $old;
91 shift @chunks unless length $chunks[0]; # Empty lines at the start
92 $chunks[0] .= <<'EOC';
93
94 $(AR) $(AR_STATIC_ARGS) $@ tmp_imp/* && $(RANLIB) $@
95EOC
96 return join "\n\n". '', @chunks;
97}
98
1e44e2bf 99sub replace_manpage_separator {
100 my($self,$man) = @_;
101 $man =~ s,/+,.,g;
102 $man;
103}
104
105sub maybe_command {
106 my($self,$file) = @_;
13bc20ff 107 $file =~ s,[/\\]+,/,g;
1e44e2bf 108 return $file if -x $file && ! -d _;
109 return "$file.exe" if -x "$file.exe" && ! -d _;
110 return "$file.cmd" if -x "$file.cmd" && ! -d _;
111 return;
112}
113
114sub file_name_is_absolute {
ecf68df6 115 shift;
116 return File::Spec->file_name_is_absolute(@_);
1e44e2bf 117}
118
68dc0745 119sub perl_archive
120{
121 return "\$(PERL_INC)/libperl\$(LIB_EXT)";
122}
123
5ba48348 124=item perl_archive_after
125
126This is an internal method that returns path to a library which
127should be put on the linker command line I<after> the external libraries
128to be linked to dynamic extensions. This may be needed if the linker
129is one-pass, and Perl includes some overrides for C RTL functions,
130such as malloc().
131
132=cut
133
134sub perl_archive_after
135{
136 return "\$(PERL_INC)/libperl_override\$(LIB_EXT)" unless $OS2::is_aout;
137 return "";
138}
139
68dc0745 140sub export_list
141{
142 my ($self) = @_;
143 return "$self->{BASEEXT}.def";
144}
145
1e44e2bf 1461;
1e44e2bf 147
bbc7dcd2 148__END__
a5f75d66 149
bbc7dcd2 150=pod
1e44e2bf 151
bbc7dcd2 152=back
1e44e2bf 153
bbc7dcd2 154=cut