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