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 | |
6d6be53e |
9 | $VERSION = '6.42'; |
f6d6199c |
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 | |
7292dc67 |
35 | =item init_dist |
479d2113 |
36 | |
37 | Define TO_UNIX to convert OS2 linefeeds to Unix style. |
38 | |
bbc7dcd2 |
39 | =cut |
40 | |
479d2113 |
41 | sub init_dist { |
42 | my($self) = @_; |
f6d6199c |
43 | |
479d2113 |
44 | $self->{TO_UNIX} ||= <<'MAKE_TEXT'; |
dedf98bc |
45 | $(NOECHO) $(TEST_F) tmp.zip && $(RM_F) tmp.zip; $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM_F) tmp.zip |
f6d6199c |
46 | MAKE_TEXT |
47 | |
479d2113 |
48 | $self->SUPER::init_dist; |
f6d6199c |
49 | } |
50 | |
1e44e2bf |
51 | sub dlsyms { |
52 | my($self,%attribs) = @_; |
53 | |
54 | my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; |
55 | my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; |
762efda7 |
56 | my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || []; |
1e44e2bf |
57 | my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {}; |
58 | my(@m); |
59 | (my $boot = $self->{NAME}) =~ s/:/_/g; |
60 | |
61 | if (not $self->{SKIPHASH}{'dynamic'}) { |
62 | push(@m," |
63 | $self->{BASEEXT}.def: Makefile.PL |
64 | ", |
65 | ' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\ |
3cfae81b |
66 | Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ', |
67 | '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ', |
68 | '"INSTALLDIRS" => "$(INSTALLDIRS)", ', |
69 | '"DL_FUNCS" => ',neatvalue($funcs), |
017f25f1 |
70 | ', "FUNCLIST" => ',neatvalue($funclist), |
1e44e2bf |
71 | ', "IMPORTS" => ',neatvalue($imports), |
3cfae81b |
72 | ', "DL_VARS" => ', neatvalue($vars), ');\' |
1e44e2bf |
73 | '); |
74 | } |
659f4fc5 |
75 | if ($self->{IMPORTS} && %{$self->{IMPORTS}}) { |
017f25f1 |
76 | # Make import files (needed for static build) |
77 | -d 'tmp_imp' or mkdir 'tmp_imp', 0777 or die "Can't mkdir tmp_imp"; |
78 | open IMP, '>tmpimp.imp' or die "Can't open tmpimp.imp"; |
79 | my ($name, $exp); |
80 | while (($name, $exp)= each %{$self->{IMPORTS}}) { |
81 | my ($lib, $id) = ($exp =~ /(.*)\.(.*)/) or die "Malformed IMPORT `$exp'"; |
82 | print IMP "$name $lib $id ?\n"; |
83 | } |
84 | close IMP or die "Can't close tmpimp.imp"; |
85 | # print "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp\n"; |
86 | system "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp" |
87 | and die "Cannot make import library: $!, \$?=$?"; |
88 | unlink <tmp_imp/*>; |
89 | system "cd tmp_imp; $Config::Config{ar} x ../tmpimp$Config::Config{lib_ext}" |
90 | and die "Cannot extract import objects: $!, \$?=$?"; |
91 | } |
1e44e2bf |
92 | join('',@m); |
93 | } |
94 | |
017f25f1 |
95 | sub static_lib { |
96 | my($self) = @_; |
97 | my $old = $self->ExtUtils::MM_Unix::static_lib(); |
659f4fc5 |
98 | return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}}; |
017f25f1 |
99 | |
100 | my @chunks = split /\n{2,}/, $old; |
101 | shift @chunks unless length $chunks[0]; # Empty lines at the start |
102 | $chunks[0] .= <<'EOC'; |
103 | |
104 | $(AR) $(AR_STATIC_ARGS) $@ tmp_imp/* && $(RANLIB) $@ |
105 | EOC |
106 | return join "\n\n". '', @chunks; |
107 | } |
108 | |
1e44e2bf |
109 | sub replace_manpage_separator { |
110 | my($self,$man) = @_; |
111 | $man =~ s,/+,.,g; |
112 | $man; |
113 | } |
114 | |
115 | sub maybe_command { |
116 | my($self,$file) = @_; |
13bc20ff |
117 | $file =~ s,[/\\]+,/,g; |
1e44e2bf |
118 | return $file if -x $file && ! -d _; |
119 | return "$file.exe" if -x "$file.exe" && ! -d _; |
120 | return "$file.cmd" if -x "$file.cmd" && ! -d _; |
121 | return; |
122 | } |
123 | |
479d2113 |
124 | =item init_linker |
68dc0745 |
125 | |
479d2113 |
126 | =cut |
5ba48348 |
127 | |
479d2113 |
128 | sub init_linker { |
129 | my $self = shift; |
5ba48348 |
130 | |
479d2113 |
131 | $self->{PERL_ARCHIVE} = "\$(PERL_INC)/libperl\$(LIB_EXT)"; |
5ba48348 |
132 | |
ad2f23df |
133 | $self->{PERL_ARCHIVE_AFTER} = $OS2::is_aout |
134 | ? '' |
135 | : '$(PERL_INC)/libperl_override$(LIB_EXT)'; |
479d2113 |
136 | $self->{EXPORT_LIST} = '$(BASEEXT).def'; |
68dc0745 |
137 | } |
138 | |
dedf98bc |
139 | =item os_flavor |
140 | |
141 | OS/2 is OS/2 |
142 | |
143 | =cut |
144 | |
145 | sub os_flavor { |
146 | return('OS/2'); |
147 | } |
148 | |
bbc7dcd2 |
149 | =back |
1e44e2bf |
150 | |
bbc7dcd2 |
151 | =cut |
479d2113 |
152 | |
153 | 1; |