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