1package ExtUtils::MM_Cygwin; 2 3use strict; 4 5use ExtUtils::MakeMaker::Config; 6use File::Spec; 7 8require ExtUtils::MM_Unix; 9require ExtUtils::MM_Win32; 10our @ISA = qw( ExtUtils::MM_Unix ); 11 12our $VERSION = '7.44'; 13$VERSION =~ tr/_//d; 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 26See L<ExtUtils::MM_Unix> for a documentation of the methods provided there. 27 28=over 4 29 30=item os_flavor 31 32We're Unix and Cygwin. 33 34=cut 35 36sub os_flavor { 37 return('Unix', 'Cygwin'); 38} 39 40=item cflags 41 42if configured for dynamic loading, triggers #define EXT in EXTERN.h 43 44=cut 45 46sub cflags { 47 my($self,$libperl)=@_; 48 return $self->{CFLAGS} if $self->{CFLAGS}; 49 return '' unless $self->needs_linking(); 50 51 my $base = $self->SUPER::cflags($libperl); 52 foreach (split /\n/, $base) { 53 /^(\S*)\s*=\s*(\S*)$/ and $self->{$1} = $2; 54 }; 55 $self->{CCFLAGS} .= " -DUSEIMPORTLIB" if ($Config{useshrplib} eq 'true'); 56 57 return $self->{CFLAGS} = qq{ 58CCFLAGS = $self->{CCFLAGS} 59OPTIMIZE = $self->{OPTIMIZE} 60PERLTYPE = $self->{PERLTYPE} 61}; 62 63} 64 65 66=item replace_manpage_separator 67 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; 76} 77 78=item init_linker 79 80points to libperl.a 81 82=cut 83 84sub init_linker { 85 my $self = shift; 86 87 if ($Config{useshrplib} eq 'true') { 88 my $libperl = '$(PERL_INC)' .'/'. "$Config{libperl}"; 89 if( "$]" >= 5.006002 ) { 90 $libperl =~ s/(dll\.)?a$/dll.a/; 91 } 92 $self->{PERL_ARCHIVE} = $libperl; 93 } else { 94 $self->{PERL_ARCHIVE} = 95 '$(PERL_INC)' .'/'. ("$Config{libperl}" or "libperl.a"); 96 } 97 98 $self->{PERL_ARCHIVEDEP} ||= ''; 99 $self->{PERL_ARCHIVE_AFTER} ||= ''; 100 $self->{EXPORT_LIST} ||= ''; 101} 102 103=item maybe_command 104 105Determine whether a file is native to Cygwin by checking whether it 106resides inside the Cygwin installation (using Windows paths). If so, 107use L<ExtUtils::MM_Unix> to determine if it may be a command. 108Otherwise use the tests from L<ExtUtils::MM_Win32>. 109 110=cut 111 112sub maybe_command { 113 my ($self, $file) = @_; 114 115 my $cygpath = Cygwin::posix_to_win_path('/', 1); 116 my $filepath = Cygwin::posix_to_win_path($file, 1); 117 118 return (substr($filepath,0,length($cygpath)) eq $cygpath) 119 ? $self->SUPER::maybe_command($file) # Unix 120 : ExtUtils::MM_Win32->maybe_command($file); # Win32 121} 122 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); 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} )); 158 $s; 159} 160 161=back 162 163=cut 164 1651; 166