This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update ExtUtils-MakeMaker to CPAN version 7.44
[perl5.git] / cpan / ExtUtils-MakeMaker / lib / ExtUtils / MM_Cygwin.pm
CommitLineData
f89d6eaa
EF
1package ExtUtils::MM_Cygwin;
2
b75c8c73 3use strict;
b75c8c73 4
7292dc67 5use ExtUtils::MakeMaker::Config;
ecf68df6
DR
6use File::Spec;
7
f6d6199c 8require ExtUtils::MM_Unix;
5bdf71cc
RGS
9require ExtUtils::MM_Win32;
10our @ISA = qw( ExtUtils::MM_Unix );
f89d6eaa 11
b7da5e65 12our $VERSION = '7.44';
3000ebb8 13$VERSION =~ tr/_//d;
479d2113
MS
14
15
16=head1 NAME
17
18ExtUtils::MM_Cygwin - methods to override UN*X behaviour in ExtUtils::MakeMaker
19
20=head1 SYNOPSIS
21
22 use ExtUtils::MM_Cygwin; # Done internally by ExtUtils::MakeMaker if needed
23
24=head1 DESCRIPTION
25
0896c457 26See L<ExtUtils::MM_Unix> for a documentation of the methods provided there.
479d2113
MS
27
28=over 4
29
7292dc67 30=item os_flavor
dedf98bc
MS
31
32We're Unix and Cygwin.
33
34=cut
35
36sub os_flavor {
37 return('Unix', 'Cygwin');
38}
39
7292dc67 40=item cflags
479d2113
MS
41
42if configured for dynamic loading, triggers #define EXT in EXTERN.h
43
44=cut
f89d6eaa
EF
45
46sub cflags {
47 my($self,$libperl)=@_;
48 return $self->{CFLAGS} if $self->{CFLAGS};
e0678a30 49 return '' unless $self->needs_linking();
f6d6199c
MS
50
51 my $base = $self->SUPER::cflags($libperl);
f89d6eaa 52 foreach (split /\n/, $base) {
45bc4d3a 53 /^(\S*)\s*=\s*(\S*)$/ and $self->{$1} = $2;
f89d6eaa
EF
54 };
55 $self->{CCFLAGS} .= " -DUSEIMPORTLIB" if ($Config{useshrplib} eq 'true');
f89d6eaa
EF
56
57 return $self->{CFLAGS} = qq{
58CCFLAGS = $self->{CCFLAGS}
59OPTIMIZE = $self->{OPTIMIZE}
60PERLTYPE = $self->{PERLTYPE}
f89d6eaa
EF
61};
62
63}
64
f89d6eaa 65
7292dc67 66=item replace_manpage_separator
f89d6eaa 67
479d2113
MS
68replaces strings '::' with '.' in MAN*POD man page names
69
70=cut
71
72sub replace_manpage_separator {
73 my($self, $man) = @_;
74 $man =~ s{/+}{.}g;
75 return $man;
f89d6eaa
EF
76}
77
479d2113
MS
78=item init_linker
79
80points to libperl.a
81
82=cut
83
84sub init_linker {
85 my $self = shift;
86
f6d6199c
MS
87 if ($Config{useshrplib} eq 'true') {
88 my $libperl = '$(PERL_INC)' .'/'. "$Config{libperl}";
3000ebb8 89 if( "$]" >= 5.006002 ) {
a0138d8f 90 $libperl =~ s/(dll\.)?a$/dll.a/;
a884ca7c 91 }
479d2113 92 $self->{PERL_ARCHIVE} = $libperl;
f6d6199c 93 } else {
eb7cfb31 94 $self->{PERL_ARCHIVE} =
479d2113 95 '$(PERL_INC)' .'/'. ("$Config{libperl}" or "libperl.a");
f6d6199c 96 }
f89d6eaa 97
88e24181 98 $self->{PERL_ARCHIVEDEP} ||= '';
479d2113
MS
99 $self->{PERL_ARCHIVE_AFTER} ||= '';
100 $self->{EXPORT_LIST} ||= '';
101}
1cab015a 102
5bdf71cc
RGS
103=item maybe_command
104
eb7cfb31
CBW
105Determine whether a file is native to Cygwin by checking whether it
106resides inside the Cygwin installation (using Windows paths). If so,
0896c457
CBW
107use L<ExtUtils::MM_Unix> to determine if it may be a command.
108Otherwise use the tests from L<ExtUtils::MM_Win32>.
5bdf71cc
RGS
109
110=cut
111
112sub maybe_command {
113 my ($self, $file) = @_;
114
eb7cfb31
CBW
115 my $cygpath = Cygwin::posix_to_win_path('/', 1);
116 my $filepath = Cygwin::posix_to_win_path($file, 1);
5bdf71cc 117
eb7cfb31
CBW
118 return (substr($filepath,0,length($cygpath)) eq $cygpath)
119 ? $self->SUPER::maybe_command($file) # Unix
120 : ExtUtils::MM_Win32->maybe_command($file); # Win32
5bdf71cc
RGS
121}
122
17283063
RU
123=item dynamic_lib
124
125Use the default to produce the *.dll's.
126But for new archdir dll's use the same rebase address if the old exists.
127
128=cut
129
130sub dynamic_lib {
131 my($self, %attribs) = @_;
132 my $s = ExtUtils::MM_Unix::dynamic_lib($self, %attribs);
f68c5403
CBW
133 return '' unless $s;
134 return $s unless %{$self->{XS}};
135
136 # do an ephemeral rebase so the new DLL fits to the current rebase map
137 $s .= "\t/bin/find \$\(INST_ARCHLIB\)/auto -xdev -name \\*.$self->{DLEXT} | /bin/rebase -sOT -" if (( $Config{myarchname} eq 'i686-cygwin' ) and not ( exists $ENV{CYGPORT_PACKAGE_VERSION} ));
138 $s;
139}
140
141=item install
142
143Rebase dll's with the global rebase database after installation.
144
145=cut
146
147sub install {
148 my($self, %attribs) = @_;
149 my $s = ExtUtils::MM_Unix::install($self, %attribs);
150 return '' unless $s;
151 return $s unless %{$self->{XS}};
152
153 my $INSTALLDIRS = $self->{INSTALLDIRS};
154 my $INSTALLLIB = $self->{"INSTALL". ($INSTALLDIRS eq 'perl' ? 'ARCHLIB' : uc($INSTALLDIRS)."ARCH")};
155 my $dop = "\$\(DESTDIR\)$INSTALLLIB/auto/";
156 my $dll = "$dop/$self->{FULLEXT}/$self->{BASEEXT}.$self->{DLEXT}";
157 $s =~ s|^(pure_install :: pure_\$\(INSTALLDIRS\)_install\n\t)\$\(NOECHO\) \$\(NOOP\)\n|$1\$(CHMOD) \$(PERM_RWX) $dll\n\t/bin/find $dop -xdev -name \\*.$self->{DLEXT} \| /bin/rebase -sOT -\n|m if (( $Config{myarchname} eq 'i686-cygwin') and not ( exists $ENV{CYGPORT_PACKAGE_VERSION} ));
17283063
RU
158 $s;
159}
160
1cab015a
EF
161=back
162
163=cut
164
479d2113 1651;