Commit | Line | Data |
---|---|---|
f89d6eaa EF |
1 | package ExtUtils::MM_Cygwin; |
2 | ||
b75c8c73 | 3 | use strict; |
b75c8c73 | 4 | |
7292dc67 | 5 | use ExtUtils::MakeMaker::Config; |
ecf68df6 DR |
6 | use File::Spec; |
7 | ||
f6d6199c | 8 | require ExtUtils::MM_Unix; |
5bdf71cc RGS |
9 | require ExtUtils::MM_Win32; |
10 | our @ISA = qw( ExtUtils::MM_Unix ); | |
f89d6eaa | 11 | |
b7da5e65 | 12 | our $VERSION = '7.44'; |
3000ebb8 | 13 | $VERSION =~ tr/_//d; |
479d2113 MS |
14 | |
15 | ||
16 | =head1 NAME | |
17 | ||
18 | ExtUtils::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 | 26 | See 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 | |
32 | We're Unix and Cygwin. | |
33 | ||
34 | =cut | |
35 | ||
36 | sub os_flavor { | |
37 | return('Unix', 'Cygwin'); | |
38 | } | |
39 | ||
7292dc67 | 40 | =item cflags |
479d2113 MS |
41 | |
42 | if configured for dynamic loading, triggers #define EXT in EXTERN.h | |
43 | ||
44 | =cut | |
f89d6eaa EF |
45 | |
46 | sub 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{ | |
58 | CCFLAGS = $self->{CCFLAGS} | |
59 | OPTIMIZE = $self->{OPTIMIZE} | |
60 | PERLTYPE = $self->{PERLTYPE} | |
f89d6eaa EF |
61 | }; |
62 | ||
63 | } | |
64 | ||
f89d6eaa | 65 | |
7292dc67 | 66 | =item replace_manpage_separator |
f89d6eaa | 67 | |
479d2113 MS |
68 | replaces strings '::' with '.' in MAN*POD man page names |
69 | ||
70 | =cut | |
71 | ||
72 | sub 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 | ||
80 | points to libperl.a | |
81 | ||
82 | =cut | |
83 | ||
84 | sub 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 |
105 | Determine whether a file is native to Cygwin by checking whether it |
106 | resides inside the Cygwin installation (using Windows paths). If so, | |
0896c457 CBW |
107 | use L<ExtUtils::MM_Unix> to determine if it may be a command. |
108 | Otherwise use the tests from L<ExtUtils::MM_Win32>. | |
5bdf71cc RGS |
109 | |
110 | =cut | |
111 | ||
112 | sub 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 | ||
125 | Use the default to produce the *.dll's. | |
126 | But for new archdir dll's use the same rebase address if the old exists. | |
127 | ||
128 | =cut | |
129 | ||
130 | sub 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 | ||
143 | Rebase dll's with the global rebase database after installation. | |
144 | ||
145 | =cut | |
146 | ||
147 | sub 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 | 165 | 1; |