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