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