1package ExtUtils::MM_Cygwin;
2
3use strict;
4use warnings;
5
6use ExtUtils::MakeMaker::Config;
7use File::Spec;
8
9require ExtUtils::MM_Unix;
10require ExtUtils::MM_Win32;
11our @ISA = qw( ExtUtils::MM_Unix );
12
13our $VERSION = '7.70';
14$VERSION =~ tr/_//d;
15
16
17=head1 NAME
18
19ExtUtils::MM_Cygwin - methods to override UN*X behaviour in ExtUtils::MakeMaker
20
21=head1 SYNOPSIS
22
23 use ExtUtils::MM_Cygwin; # Done internally by ExtUtils::MakeMaker if needed
24
25=head1 DESCRIPTION
26
27See L<ExtUtils::MM_Unix> for a documentation of the methods provided there.
28
29=over 4
30
31=item os_flavor
32
33We're Unix and Cygwin.
34
35=cut
36
37sub os_flavor {
38    return('Unix', 'Cygwin');
39}
40
41=item cflags
42
43if configured for dynamic loading, triggers #define EXT in EXTERN.h
44
45=cut
46
47sub cflags {
48    my($self,$libperl)=@_;
49    return $self->{CFLAGS} if $self->{CFLAGS};
50    return '' unless $self->needs_linking();
51
52    my $base = $self->SUPER::cflags($libperl);
53    foreach (split /\n/, $base) {
54        /^(\S*)\s*=\s*(\S*)$/ and $self->{$1} = $2;
55    };
56    $self->{CCFLAGS} .= " -DUSEIMPORTLIB" if ($Config{useshrplib} eq 'true');
57
58    return $self->{CFLAGS} = qq{
59CCFLAGS = $self->{CCFLAGS}
60OPTIMIZE = $self->{OPTIMIZE}
61PERLTYPE = $self->{PERLTYPE}
62};
63
64}
65
66
67=item replace_manpage_separator
68
69replaces strings '::' with '.' in MAN*POD man page names
70
71=cut
72
73sub replace_manpage_separator {
74    my($self, $man) = @_;
75    $man =~ s{/+}{.}g;
76    return $man;
77}
78
79=item init_linker
80
81points to libperl.a
82
83=cut
84
85sub init_linker {
86    my $self = shift;
87
88    if ($Config{useshrplib} eq 'true') {
89        my $libperl = '$(PERL_INC)' .'/'. "$Config{libperl}";
90        if( "$]" >= 5.006002 ) {
91            $libperl =~ s/(dll\.)?a$/dll.a/;
92        }
93        $self->{PERL_ARCHIVE} = $libperl;
94    } else {
95        $self->{PERL_ARCHIVE} =
96          '$(PERL_INC)' .'/'. ("$Config{libperl}" or "libperl.a");
97    }
98
99    $self->{PERL_ARCHIVEDEP} ||= '';
100    $self->{PERL_ARCHIVE_AFTER} ||= '';
101    $self->{EXPORT_LIST}  ||= '';
102}
103
104sub init_others {
105    my $self = shift;
106
107    $self->SUPER::init_others;
108
109    $self->{LDLOADLIBS} ||= $Config{perllibs};
110
111    return;
112}
113
114=item maybe_command
115
116Determine whether a file is native to Cygwin by checking whether it
117resides inside the Cygwin installation (using Windows paths). If so,
118use L<ExtUtils::MM_Unix> to determine if it may be a command.
119Otherwise use the tests from L<ExtUtils::MM_Win32>.
120
121=cut
122
123sub maybe_command {
124    my ($self, $file) = @_;
125
126    my $cygpath = Cygwin::posix_to_win_path('/', 1);
127    my $filepath = Cygwin::posix_to_win_path($file, 1);
128
129    return (substr($filepath,0,length($cygpath)) eq $cygpath)
130    ? $self->SUPER::maybe_command($file) # Unix
131    : ExtUtils::MM_Win32->maybe_command($file); # Win32
132}
133
134=item dynamic_lib
135
136Use the default to produce the *.dll's.
137But for new archdir dll's use the same rebase address if the old exists.
138
139=cut
140
141sub dynamic_lib {
142    my($self, %attribs) = @_;
143    my $s = ExtUtils::MM_Unix::dynamic_lib($self, %attribs);
144    return '' unless $s;
145    return $s unless %{$self->{XS}};
146
147    # do an ephemeral rebase so the new DLL fits to the current rebase map
148    $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} ));
149    $s;
150}
151
152=item install
153
154Rebase dll's with the global rebase database after installation.
155
156=cut
157
158sub install {
159    my($self, %attribs) = @_;
160    my $s = ExtUtils::MM_Unix::install($self, %attribs);
161    return '' unless $s;
162    return $s unless %{$self->{XS}};
163
164    my $INSTALLDIRS = $self->{INSTALLDIRS};
165    my $INSTALLLIB = $self->{"INSTALL". ($INSTALLDIRS eq 'perl' ? 'ARCHLIB' : uc($INSTALLDIRS)."ARCH")};
166    my $dop = "\$\(DESTDIR\)$INSTALLLIB/auto/";
167    my $dll = "$dop/$self->{FULLEXT}/$self->{BASEEXT}.$self->{DLEXT}";
168    $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} ));
169    $s;
170}
171
172=back
173
174=cut
175
1761;
177