This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Once again syncing after too long an absence
[perl5.git] / lib / ExtUtils / MM_Cygwin.pm
1 package ExtUtils::MM_Cygwin;
2
3 use strict;
4
5 our $VERSION = '1.00';
6
7 use Config;
8 #use Cwd;
9 #use File::Basename;
10 require Exporter;
11
12 require ExtUtils::MakeMaker;
13 ExtUtils::MakeMaker->import(qw( $Verbose &neatvalue));
14
15 unshift @MM::ISA, 'ExtUtils::MM_Cygwin';
16
17 sub canonpath {
18     my($self,$path) = @_;
19     $path =~ s|\\|/|g;
20     return $self->ExtUtils::MM_Unix::canonpath($path);
21 }
22
23 sub cflags {
24     my($self,$libperl)=@_;
25     return $self->{CFLAGS} if $self->{CFLAGS};
26     my $base =$self->ExtUtils::MM_Unix::cflags($libperl);
27     foreach (split /\n/, $base) {
28       / *= */ and $self->{$`} = $';
29     };
30     $self->{CCFLAGS} .= " -DUSEIMPORTLIB" if ($Config{useshrplib} eq 'true');
31
32     return $self->{CFLAGS} = qq{
33 CCFLAGS = $self->{CCFLAGS}
34 OPTIMIZE = $self->{OPTIMIZE}
35 PERLTYPE = $self->{PERLTYPE}
36 LARGE = $self->{LARGE}
37 SPLIT = $self->{SPLIT}
38 };
39
40 }
41
42 sub manifypods {
43     my($self, %attribs) = @_;
44     return "\nmanifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
45         %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
46     my($dist);
47     my($pod2man_exe);
48     if (defined $self->{PERL_SRC}) {
49         $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
50     } else {
51         $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
52     }
53     unless ($self->perl_script($pod2man_exe)) {
54         # No pod2man but some MAN3PODS to be installed
55         print <<END;
56
57 Warning: I could not locate your pod2man program. Please make sure,
58          your pod2man program is in your PATH before you execute 'make'
59
60 END
61         $pod2man_exe = "-S pod2man";
62     }
63     my(@m);
64     push @m,
65 qq[POD2MAN_EXE = $pod2man_exe\n],
66 qq[POD2MAN = \$(PERL) -we '%m=\@ARGV;for (keys %m){' \\\n],
67 q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "],
68  $self->{MAKEFILE}, q[";' \\
69 -e 'print "Manifying $$m{$$_}\n"; $$m{$$_} =~ s/::/./g;' \\
70 -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
71 -e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'
72 ];
73     push @m, "\nmanifypods : pure_all ";
74     push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
75
76     push(@m,"\n");
77     if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
78         grep { $self->{MAN1PODS}{$_} =~ s/::/./g } keys %{$self->{MAN1PODS}};
79         grep { $self->{MAN3PODS}{$_} =~ s/::/./g } keys %{$self->{MAN3PODS}};
80         push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
81         push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
82     }
83     join('', @m);
84 }
85
86 sub perl_archive
87 {
88  return '$(PERL_INC)' .'/'. ("$Config{libperl}" or "libperl.a");
89 }
90
91 1;
92 __END__
93
94 =head1 NAME
95
96 ExtUtils::MM_Cygwin - methods to override UN*X behaviour in ExtUtils::MakeMaker
97
98 =head1 SYNOPSIS
99
100  use ExtUtils::MM_Cygwin; # Done internally by ExtUtils::MakeMaker if needed
101
102 =head1 DESCRIPTION
103
104 See ExtUtils::MM_Unix for a documentation of the methods provided there.
105
106 =over
107
108 =item canonpath
109
110 replaces backslashes with forward ones.  then acts as *nixish.
111
112 =item cflags
113
114 if configured for dynamic loading, triggers #define EXT in EXTERN.h
115
116 =item manifypods
117
118 replaces strings '::' with '.' in man page names
119
120 =item perl_archive
121
122 points to libperl.a
123
124 =back
125
126 =cut
127