1package ExtUtils::MM_OS2;
2
3use strict;
4use warnings;
5
6use ExtUtils::MakeMaker qw(neatvalue);
7use File::Spec;
8
9our $VERSION = '7.70';
10$VERSION =~ tr/_//d;
11
12require ExtUtils::MM_Any;
13require ExtUtils::MM_Unix;
14our @ISA = qw(ExtUtils::MM_Any ExtUtils::MM_Unix);
15
16=pod
17
18=head1 NAME
19
20ExtUtils::MM_OS2 - methods to override UN*X behaviour in ExtUtils::MakeMaker
21
22=head1 SYNOPSIS
23
24 use ExtUtils::MM_OS2; # Done internally by ExtUtils::MakeMaker if needed
25
26=head1 DESCRIPTION
27
28See L<ExtUtils::MM_Unix> for a documentation of the methods provided
29there. This package overrides the implementation of these methods, not
30the semantics.
31
32=head1 METHODS
33
34=over 4
35
36=item init_dist
37
38Define TO_UNIX to convert OS2 linefeeds to Unix style.
39
40=cut
41
42sub init_dist {
43    my($self) = @_;
44
45    $self->{TO_UNIX} ||= <<'MAKE_TEXT';
46$(NOECHO) $(TEST_F) tmp.zip && $(RM_F) tmp.zip; $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM_F) tmp.zip
47MAKE_TEXT
48
49    $self->SUPER::init_dist;
50}
51
52sub dlsyms {
53    my($self,%attribs) = @_;
54    if ($self->{IMPORTS} && %{$self->{IMPORTS}}) {
55	# Make import files (needed for static build)
56	-d 'tmp_imp' or mkdir 'tmp_imp', 0777 or die "Can't mkdir tmp_imp";
57	open my $imp, '>', 'tmpimp.imp' or die "Can't open tmpimp.imp";
58	foreach my $name (sort keys %{$self->{IMPORTS}}) {
59	    my $exp = $self->{IMPORTS}->{$name};
60	    my ($lib, $id) = ($exp =~ /(.*)\.(.*)/) or die "Malformed IMPORT `$exp'";
61	    print $imp "$name $lib $id ?\n";
62	}
63	close $imp or die "Can't close tmpimp.imp";
64	# print "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp\n";
65	system "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp"
66	    and die "Cannot make import library: $!, \$?=$?";
67	# May be running under miniperl, so have no glob...
68	eval { unlink <tmp_imp/*>; 1 } or system "rm tmp_imp/*";
69	system "cd tmp_imp; $Config::Config{ar} x ../tmpimp$Config::Config{lib_ext}"
70	    and die "Cannot extract import objects: $!, \$?=$?";
71    }
72    return '' if $self->{SKIPHASH}{'dynamic'};
73    $self->xs_dlsyms_iterator(\%attribs);
74}
75
76sub xs_dlsyms_ext {
77    '.def';
78}
79
80sub xs_dlsyms_extra {
81    join '', map { qq{, "$_" => "\$($_)"} } qw(VERSION DISTNAME INSTALLDIRS);
82}
83
84sub static_lib_pure_cmd {
85    my($self) = @_;
86    my $old = $self->SUPER::static_lib_pure_cmd;
87    return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}};
88    $old . <<'EOC';
89	$(AR) $(AR_STATIC_ARGS) "$@" tmp_imp/*
90	$(RANLIB) "$@"
91EOC
92}
93
94sub replace_manpage_separator {
95    my($self,$man) = @_;
96    $man =~ s,/+,.,g;
97    $man;
98}
99
100sub maybe_command {
101    my($self,$file) = @_;
102    $file =~ s,[/\\]+,/,g;
103    return $file if -x $file && ! -d _;
104    return "$file.exe" if -x "$file.exe" && ! -d _;
105    return "$file.cmd" if -x "$file.cmd" && ! -d _;
106    return;
107}
108
109=item init_linker
110
111=cut
112
113sub init_linker {
114    my $self = shift;
115
116    $self->{PERL_ARCHIVE} = "\$(PERL_INC)/libperl\$(LIB_EXT)";
117
118    $self->{PERL_ARCHIVEDEP} ||= '';
119    $self->{PERL_ARCHIVE_AFTER} = $OS2::is_aout
120      ? ''
121      : '$(PERL_INC)/libperl_override$(LIB_EXT)';
122    $self->{EXPORT_LIST} = '$(BASEEXT).def';
123}
124
125=item os_flavor
126
127OS/2 is OS/2
128
129=cut
130
131sub os_flavor {
132    return('OS/2');
133}
134
135=item xs_static_lib_is_xs
136
137=cut
138
139sub xs_static_lib_is_xs {
140    return 1;
141}
142
143=back
144
145=cut
146
1471;
148