xref: /openbsd-src/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_NW5.pm (revision be691f3bb6417f04a68938fadbcaee2d5795e764)
1package ExtUtils::MM_NW5;
2
3=head1 NAME
4
5ExtUtils::MM_NW5 - methods to override UN*X behaviour in ExtUtils::MakeMaker
6
7=head1 SYNOPSIS
8
9 use ExtUtils::MM_NW5; # Done internally by ExtUtils::MakeMaker if needed
10
11=head1 DESCRIPTION
12
13See L<ExtUtils::MM_Unix> for a documentation of the methods provided
14there. This package overrides the implementation of these methods, not
15the semantics.
16
17=over
18
19=cut
20
21use strict;
22use ExtUtils::MakeMaker::Config;
23use File::Basename;
24
25our $VERSION = '7.44';
26$VERSION =~ tr/_//d;
27
28require ExtUtils::MM_Win32;
29our @ISA = qw(ExtUtils::MM_Win32);
30
31use ExtUtils::MakeMaker qw(&neatvalue &_sprintf562);
32
33$ENV{EMXSHELL} = 'sh'; # to run `commands`
34
35my $BORLAND  = $Config{'cc'} =~ /\bbcc/i;
36my $GCC      = $Config{'cc'} =~ /\bgcc/i;
37
38
39=item os_flavor
40
41We're Netware in addition to being Windows.
42
43=cut
44
45sub os_flavor {
46    my $self = shift;
47    return ($self->SUPER::os_flavor, 'Netware');
48}
49
50=item init_platform
51
52Add Netware macros.
53
54LIBPTH, BASE_IMPORT, NLM_VERSION, MPKTOOL, TOOLPATH, BOOT_SYMBOL,
55NLM_SHORT_NAME, INCLUDE, PATH, MM_NW5_REVISION
56
57
58=item platform_constants
59
60Add Netware macros initialized above to the Makefile.
61
62=cut
63
64sub init_platform {
65    my($self) = shift;
66
67    # To get Win32's setup.
68    $self->SUPER::init_platform;
69
70    # incpath is copied to makefile var INCLUDE in constants sub, here just
71    # make it empty
72    my $libpth = $Config{'libpth'};
73    $libpth =~ s( )(;);
74    $self->{'LIBPTH'} = $libpth;
75
76    $self->{'BASE_IMPORT'} = $Config{'base_import'};
77
78    # Additional import file specified from Makefile.pl
79    if($self->{'base_import'}) {
80        $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'};
81    }
82
83    $self->{'NLM_VERSION'} = $Config{'nlm_version'};
84    $self->{'MPKTOOL'}	= $Config{'mpktool'};
85    $self->{'TOOLPATH'}	= $Config{'toolpath'};
86
87    (my $boot = $self->{'NAME'}) =~ s/:/_/g;
88    $self->{'BOOT_SYMBOL'}=$boot;
89
90    # If the final binary name is greater than 8 chars,
91    # truncate it here.
92    if(length($self->{'BASEEXT'}) > 8) {
93        $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8);
94    }
95
96    # Get the include path and replace the spaces with ;
97    # Copy this to makefile as INCLUDE = d:\...;d:\;
98    ($self->{INCLUDE} = $Config{'incpath'}) =~ s/([ ]*)-I/;/g;
99
100    # Set the path to CodeWarrior binaries which might not have been set in
101    # any other place
102    $self->{PATH} = '$(PATH);$(TOOLPATH)';
103
104    $self->{MM_NW5_VERSION} = $VERSION;
105}
106
107sub platform_constants {
108    my($self) = shift;
109    my $make_frag = '';
110
111    # Setup Win32's constants.
112    $make_frag .= $self->SUPER::platform_constants;
113
114    foreach my $macro (qw(LIBPTH BASE_IMPORT NLM_VERSION MPKTOOL
115                          TOOLPATH BOOT_SYMBOL NLM_SHORT_NAME INCLUDE PATH
116                          MM_NW5_VERSION
117                      ))
118    {
119        next unless defined $self->{$macro};
120        $make_frag .= "$macro = $self->{$macro}\n";
121    }
122
123    return $make_frag;
124}
125
126=item static_lib_pure_cmd
127
128Defines how to run the archive utility
129
130=cut
131
132sub static_lib_pure_cmd {
133    my ($self, $src) = @_;
134    $src =~ s/(\$\(\w+)(\))/$1:^"+"$2/g if $BORLAND;
135    sprintf qq{\t\$(AR) %s\n}, ($BORLAND ? '$@ ' . $src
136                          : ($GCC ? '-ru $@ ' . $src
137                                  : '-type library -o $@ ' . $src));
138}
139
140=item xs_static_lib_is_xs
141
142=cut
143
144sub xs_static_lib_is_xs {
145    return 1;
146}
147
148=item dynamic_lib
149
150Override of utility methods for OS-specific work.
151
152=cut
153
154sub xs_make_dynamic_lib {
155    my ($self, $attribs, $from, $to, $todir, $ldfrom, $exportlist) = @_;
156    my @m;
157    # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc
158    if ($to =~ /^\$/) {
159        if ($self->{NLM_SHORT_NAME}) {
160            # deal with shortnames
161            my $newto = q{$(INST_AUTODIR)\\$(NLM_SHORT_NAME).$(DLEXT)};
162            push @m, "$to: $newto\n\n";
163            $to = $newto;
164        }
165    } else {
166        my ($v, $d, $f) = File::Spec->splitpath($to);
167        # relies on $f having a literal "." in it, unlike for $(OBJ_EXT)
168        if ($f =~ /[^\.]{9}\./) {
169            # 9+ chars before '.', need to shorten
170            $f = substr $f, 0, 8;
171        }
172        my $newto = File::Spec->catpath($v, $d, $f);
173        push @m, "$to: $newto\n\n";
174        $to = $newto;
175    }
176    # bits below should be in dlsyms, not here
177    #                                   1    2      3       4
178    push @m, _sprintf562 <<'MAKE_FRAG', $to, $from, $todir, $exportlist;
179# Create xdc data for an MT safe NLM in case of mpk build
180%1$s: %2$s $(MYEXTLIB) $(BOOTSTRAP) %3$s$(DFSEP).exists
181	$(NOECHO) $(ECHO) Export boot_$(BOOT_SYMBOL) > %4$s
182	$(NOECHO) $(ECHO) $(BASE_IMPORT) >> %4$s
183	$(NOECHO) $(ECHO) Import @$(PERL_INC)\perl.imp >> %4$s
184MAKE_FRAG
185    if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) {
186        (my $xdc = $exportlist) =~ s#def\z#xdc#;
187        $xdc = '$(BASEEXT).xdc';
188        push @m, sprintf <<'MAKE_FRAG', $xdc, $exportlist;
189	$(MPKTOOL) $(XDCFLAGS) %s
190	$(NOECHO) $(ECHO) xdcdata $(BASEEXT).xdc >> %s
191MAKE_FRAG
192    }
193    # Reconstruct the X.Y.Z version.
194    my $version = join '.', map { sprintf "%d", $_ }
195                              "$]" =~ /(\d)\.(\d{3})(\d{2})/;
196    push @m, sprintf <<'EOF', $from, $version, $to, $exportlist;
197	$(LD) $(LDFLAGS) %s -desc "Perl %s Extension ($(BASEEXT))  XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) -o %s $(MYEXTLIB) $(PERL_INC)\Main.lib -commandfile %s
198	$(CHMOD) 755 $@
199EOF
200    join '', @m;
201}
202
2031;
204__END__
205
206=back
207
208=cut
209