| 1 | package ExtUtils::MM_OS2; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use ExtUtils::MakeMaker qw(neatvalue); | ||
| 6 | use File::Spec; | ||
| 7 | |||
| 8 | our $VERSION = '7.13_01'; | ||
| 9 | $VERSION = eval $VERSION; | ||
| 10 | |||
| 11 | require ExtUtils::MM_Any; | ||
| 12 | require ExtUtils::MM_Unix; | ||
| 13 | our @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 | if ($self->{IMPORTS} && %{$self->{IMPORTS}}) { | ||
| 54 | # Make import files (needed for static build) | ||
| 55 | -d 'tmp_imp' or mkdir 'tmp_imp', 0777 or die "Can't mkdir tmp_imp"; | ||
| 56 | open my $imp, '>', 'tmpimp.imp' or die "Can't open tmpimp.imp"; | ||
| 57 | foreach my $name (sort keys %{$self->{IMPORTS}}) { | ||
| 58 | my $exp = $self->{IMPORTS}->{$name}; | ||
| 59 | my ($lib, $id) = ($exp =~ /(.*)\.(.*)/) or die "Malformed IMPORT `$exp'"; | ||
| 60 | print $imp "$name $lib $id ?\n"; | ||
| 61 | } | ||
| 62 | close $imp or die "Can't close tmpimp.imp"; | ||
| 63 | # print "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp\n"; | ||
| 64 | system "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp" | ||
| 65 | and die "Cannot make import library: $!, \$?=$?"; | ||
| 66 | # May be running under miniperl, so have no glob... | ||
| 67 | eval { unlink <tmp_imp/*>; 1 } or system "rm tmp_imp/*"; | ||
| 68 | system "cd tmp_imp; $Config::Config{ar} x ../tmpimp$Config::Config{lib_ext}" | ||
| 69 | and die "Cannot extract import objects: $!, \$?=$?"; | ||
| 70 | } | ||
| 71 | return '' if $self->{SKIPHASH}{'dynamic'}; | ||
| 72 | $self->xs_dlsyms_iterator(\%attribs); | ||
| 73 | } | ||
| 74 | |||
| 75 | sub xs_dlsyms_ext { | ||
| 76 | '.def'; | ||
| 77 | } | ||
| 78 | |||
| 79 | sub xs_dlsyms_extra { | ||
| 80 | join '', map { qq{, "$_" => "\$($_)"} } qw(VERSION DISTNAME INSTALLDIRS); | ||
| 81 | } | ||
| 82 | |||
| 83 | sub static_lib_pure_cmd { | ||
| 84 | my($self) = @_; | ||
| 85 | my $old = $self->SUPER::static_lib_pure_cmd; | ||
| 86 | return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}}; | ||
| 87 | $old . <<'EOC'; | ||
| 88 | $(AR) $(AR_STATIC_ARGS) "$@" tmp_imp/* | ||
| 89 | $(RANLIB) "$@" | ||
| 90 | EOC | ||
| 91 | } | ||
| 92 | |||
| 93 | sub replace_manpage_separator { | ||
| 94 | my($self,$man) = @_; | ||
| 95 | $man =~ s,/+,.,g; | ||
| 96 | $man; | ||
| 97 | } | ||
| 98 | |||
| 99 | sub maybe_command { | ||
| 100 | my($self,$file) = @_; | ||
| 101 | $file =~ s,[/\\]+,/,g; | ||
| 102 | return $file if -x $file && ! -d _; | ||
| 103 | return "$file.exe" if -x "$file.exe" && ! -d _; | ||
| 104 | return "$file.cmd" if -x "$file.cmd" && ! -d _; | ||
| 105 | return; | ||
| 106 | } | ||
| 107 | |||
| 108 | =item init_linker | ||
| 109 | |||
| 110 | =cut | ||
| 111 | |||
| 112 | sub init_linker { | ||
| 113 | my $self = shift; | ||
| 114 | |||
| 115 | $self->{PERL_ARCHIVE} = "\$(PERL_INC)/libperl\$(LIB_EXT)"; | ||
| 116 | |||
| 117 | $self->{PERL_ARCHIVEDEP} ||= ''; | ||
| 118 | $self->{PERL_ARCHIVE_AFTER} = $OS2::is_aout | ||
| 119 | ? '' | ||
| 120 | : '$(PERL_INC)/libperl_override$(LIB_EXT)'; | ||
| 121 | $self->{EXPORT_LIST} = '$(BASEEXT).def'; | ||
| 122 | } | ||
| 123 | |||
| 124 | =item os_flavor | ||
| 125 | |||
| 126 | OS/2 is OS/2 | ||
| 127 | |||
| 128 | =cut | ||
| 129 | |||
| 130 | sub os_flavor { | ||
| 131 | return('OS/2'); | ||
| 132 | } | ||
| 133 | |||
| 134 | =back | ||
| 135 | |||
| 136 | =cut | ||
| 137 | |||
| 138 | 1; |