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
1 package ExtUtils::MM_OS2;
2
3 use strict;
4
5 our $VERSION = '1.00';
6
7 #use Config;
8 #use Cwd;
9 #use File::Basename;
10 require Exporter;
11
12 require ExtUtils::MakeMaker;
13 ExtUtils::MakeMaker->import(qw( $Verbose &neatvalue));
14
15 unshift @MM::ISA, 'ExtUtils::MM_OS2';
16
17 =pod
18
19 =head1 NAME
20
21 ExtUtils::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
29 See ExtUtils::MM_Unix for a documentation of the methods provided
30 there. This package overrides the implementation of these methods, not
31 the semantics.
32
33 =head1 METHODS
34
35 =over 4
36
37 =cut
38
39 sub dlsyms {
40     my($self,%attribs) = @_;
41
42     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
43     my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
44     my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
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; \\
54      Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ',
55      '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ',
56      '"INSTALLDIRS" => "$(INSTALLDIRS)", ',
57      '"DL_FUNCS" => ',neatvalue($funcs),
58      ', "FUNCLIST" => ',neatvalue($funclist),
59      ', "IMPORTS" => ',neatvalue($imports),
60      ', "DL_VARS" => ', neatvalue($vars), ');\'
61 ');
62     }
63     if ($self->{IMPORTS} && %{$self->{IMPORTS}}) {
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     }
80     join('',@m);
81 }
82
83 sub static_lib {
84     my($self) = @_;
85     my $old = $self->ExtUtils::MM_Unix::static_lib();
86     return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}};
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) $@
93 EOC
94     return join "\n\n". '', @chunks;
95 }
96
97 sub replace_manpage_separator {
98     my($self,$man) = @_;
99     $man =~ s,/+,.,g;
100     $man;
101 }
102
103 sub maybe_command {
104     my($self,$file) = @_;
105     $file =~ s,[/\\]+,/,g;
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
112 sub file_name_is_absolute {
113     my($self,$file) = @_;
114     $file =~ m{^([a-z]:)?[\\/]}i ;
115 }
116
117 sub perl_archive
118 {
119  return "\$(PERL_INC)/libperl\$(LIB_EXT)";
120 }
121
122 =item perl_archive_after
123
124 This is an internal method that returns path to a library which
125 should be put on the linker command line I<after> the external libraries
126 to be linked to dynamic extensions.  This may be needed if the linker
127 is one-pass, and Perl includes some overrides for C RTL functions,
128 such as malloc().
129
130 =cut 
131
132 sub perl_archive_after
133 {
134  return "\$(PERL_INC)/libperl_override\$(LIB_EXT)" unless $OS2::is_aout;
135  return "";
136 }
137
138 sub export_list
139 {
140  my ($self) = @_;
141  return "$self->{BASEEXT}.def";
142 }
143
144 1;
145
146 __END__
147
148 =pod
149
150 =back
151
152 =cut