| 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.05'; |
| 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 | =item init_dist |
| 36 | |
| 37 | Define TO_UNIX to convert OS2 linefeeds to Unix style. |
| 38 | |
| 39 | =cut |
| 40 | |
| 41 | sub init_dist { |
| 42 | my($self) = @_; |
| 43 | |
| 44 | $self->{TO_UNIX} ||= <<'MAKE_TEXT'; |
| 45 | $(NOECHO) $(TEST_F) tmp.zip && $(RM_F) tmp.zip; $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM_F) tmp.zip |
| 46 | MAKE_TEXT |
| 47 | |
| 48 | $self->SUPER::init_dist; |
| 49 | } |
| 50 | |
| 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} || []; |
| 56 | my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || []; |
| 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; \\ |
| 66 | Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ', |
| 67 | '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ', |
| 68 | '"INSTALLDIRS" => "$(INSTALLDIRS)", ', |
| 69 | '"DL_FUNCS" => ',neatvalue($funcs), |
| 70 | ', "FUNCLIST" => ',neatvalue($funclist), |
| 71 | ', "IMPORTS" => ',neatvalue($imports), |
| 72 | ', "DL_VARS" => ', neatvalue($vars), ');\' |
| 73 | '); |
| 74 | } |
| 75 | if ($self->{IMPORTS} && %{$self->{IMPORTS}}) { |
| 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 | } |
| 92 | join('',@m); |
| 93 | } |
| 94 | |
| 95 | sub static_lib { |
| 96 | my($self) = @_; |
| 97 | my $old = $self->ExtUtils::MM_Unix::static_lib(); |
| 98 | return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}}; |
| 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 | |
| 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) = @_; |
| 117 | $file =~ s,[/\\]+,/,g; |
| 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 | |
| 124 | =item init_linker |
| 125 | |
| 126 | =cut |
| 127 | |
| 128 | sub init_linker { |
| 129 | my $self = shift; |
| 130 | |
| 131 | $self->{PERL_ARCHIVE} = "\$(PERL_INC)/libperl\$(LIB_EXT)"; |
| 132 | |
| 133 | $self->{PERL_ARCHIVE_AFTER} = $OS2::is_aout |
| 134 | ? '' |
| 135 | : '$(PERL_INC)/libperl_override$(LIB_EXT)'; |
| 136 | $self->{EXPORT_LIST} = '$(BASEEXT).def'; |
| 137 | } |
| 138 | |
| 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 | |
| 149 | =back |
| 150 | |
| 151 | =cut |
| 152 | |
| 153 | 1; |