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