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