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