Commit | Line | Data |
---|---|---|
8e07c86e AD |
1 | package ExtUtils::MakeMaker::TieAtt; |
2 | # this package will go away again, when we don't have modules around | |
3 | # anymore that import %att It ties an empty %att and records in which | |
4 | # object this %att was tied. FETCH and STORE return/store-to the | |
5 | # appropriate value from %$self | |
005c1a0e | 6 | |
8e07c86e AD |
7 | # the warndirectuse method warns if somebody calls MM->something. It |
8 | # has nothing to do with the tie'd %att. | |
005c1a0e | 9 | |
8e07c86e | 10 | $Enough_limit = 5; |
a0d0e21e | 11 | |
8e07c86e AD |
12 | sub TIEHASH { |
13 | bless { SECRETHASH => $_[1]}; | |
005c1a0e | 14 | } |
42793c05 | 15 | |
8e07c86e | 16 | sub FETCH { |
4633a7c4 | 17 | print "Warning (non-fatal): Importing of %att is deprecated [$_[1]] |
8e07c86e AD |
18 | use \$self instead\n" unless ++$Enough>$Enough_limit; |
19 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit; | |
20 | $_[0]->{SECRETHASH}->{$_[1]}; | |
1aef975c | 21 | } |
42793c05 | 22 | |
8e07c86e | 23 | sub STORE { |
4633a7c4 | 24 | print "Warning (non-fatal): Importing of %att is deprecated [$_[1]][$_[2]] |
8e07c86e AD |
25 | use \$self instead\n" unless ++$Enough>$Enough_limit; |
26 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit; | |
27 | $_[0]->{SECRETHASH}->{$_[1]} = $_[2]; | |
28 | } | |
42793c05 | 29 | |
8e07c86e | 30 | sub FIRSTKEY { |
4633a7c4 | 31 | print "Warning (non-fatal): Importing of %att is deprecated [FIRSTKEY] |
8e07c86e AD |
32 | use \$self instead\n" unless ++$Enough>$Enough_limit; |
33 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit; | |
34 | each %{$_[0]->{SECRETHASH}}; | |
35 | } | |
42793c05 | 36 | |
8e07c86e AD |
37 | sub NEXTKEY { |
38 | each %{$_[0]->{SECRETHASH}}; | |
39 | } | |
005c1a0e | 40 | |
8e07c86e AD |
41 | sub DESTROY { |
42 | } | |
005c1a0e | 43 | |
8e07c86e AD |
44 | sub warndirectuse { |
45 | my($caller) = @_; | |
46 | return if $Enough>$Enough_limit; | |
4633a7c4 | 47 | print STDOUT "Warning (non-fatal): Direct use of class methods deprecated; use\n"; |
8e07c86e | 48 | my($method) = $caller =~ /.*:(\w+)$/; |
864a5fa8 | 49 | print STDOUT |
8e07c86e | 50 | ' my $self = shift; |
8e07c86e AD |
51 | $self->MM::', $method, "(); |
52 | instead\n"; | |
53 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" | |
54 | if ++$Enough==$Enough_limit; | |
55 | } | |
005c1a0e | 56 | |
8e07c86e | 57 | package ExtUtils::MakeMaker; |
005c1a0e | 58 | |
c07a80fd | 59 | # Last edited $Date: 1996/01/28 11:33:38 $ by Andreas Koenig |
60 | # $Id: MakeMaker.pm,v 1.141 1996/01/28 11:33:38 k Exp $ | |
42793c05 | 61 | |
c07a80fd | 62 | $Version = $VERSION = "5.18"; |
005c1a0e | 63 | |
c07a80fd | 64 | $ExtUtils::MakeMaker::Version_OK = "5.05"; # Makefiles older than $Version_OK will die |
8e07c86e | 65 | # (Will be checked from MakeMaker version 4.13 onwards) |
005c1a0e | 66 | |
8e07c86e AD |
67 | use Config; |
68 | use Carp; | |
69 | use Cwd; | |
70 | require Exporter; | |
71 | require ExtUtils::Manifest; | |
72 | require ExtUtils::Liblist; | |
73 | #use strict qw(refs); | |
005c1a0e | 74 | |
8e07c86e AD |
75 | eval {require DynaLoader;}; # Get mod2fname, if defined. Will fail |
76 | # with miniperl. | |
005c1a0e | 77 | |
8e07c86e AD |
78 | # print join "**\n**", "", %INC, ""; |
79 | %NORMAL_INC = %INC; | |
005c1a0e | 80 | |
42793c05 | 81 | |
42793c05 | 82 | |
8e07c86e AD |
83 | @ISA = qw(Exporter); |
84 | @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt); | |
85 | @EXPORT_OK = qw($Version $VERSION &Version_check | |
86 | &help &neatvalue &mkbootstrap &mksymlists | |
4633a7c4 | 87 | %att ## Import of %att is deprecated, please use OO features! |
8e07c86e | 88 | ); |
42793c05 | 89 | |
0d8023a2 | 90 | if ($Is_VMS = ($Config::Config{osname} eq 'VMS')) { |
91 | require ExtUtils::MM_VMS; | |
92 | require VMS::Filespec; | |
93 | import VMS::Filespec '&vmsify'; | |
94 | } | |
4633a7c4 | 95 | $Is_OS2 = $Config::Config{osname} =~ m|^os/?2$|i ; |
8e07c86e | 96 | $ENV{EMXSHELL} = 'sh' if $Is_OS2; # to run `commands` |
42793c05 | 97 | |
864a5fa8 | 98 | $ExtUtils::MakeMaker::Verbose = 0 unless defined $ExtUtils::MakeMaker::Verbose; |
8e07c86e AD |
99 | $^W=1; |
100 | #$SIG{__DIE__} = sub { print @_, Carp::longmess(); die; }; | |
101 | ####$SIG{__WARN__} = sub { print Carp::longmess(); warn @_; }; | |
864a5fa8 AD |
102 | $SIG{__WARN__} = sub { |
103 | $_[0] =~ /^Use of uninitialized value/ && return; | |
104 | $_[0] =~ /used only once/ && return; | |
105 | $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return; | |
106 | warn @_; | |
107 | }; | |
75f92628 | 108 | |
8e07c86e AD |
109 | # Setup dummy package: |
110 | # MY exists for overriding methods to be defined within | |
111 | unshift(@MY::ISA, qw(MM)); | |
42793c05 | 112 | |
8e07c86e AD |
113 | # Dummy package MM inherits actual methods from OS-specific |
114 | # default packages. We use this intermediate package so | |
115 | # MY::XYZ->func() can call MM->func() and get the proper | |
116 | # default routine without having to know under what OS | |
117 | # it's running. | |
4633a7c4 | 118 | |
c07a80fd | 119 | @MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::MakeMaker]; |
8e07c86e AD |
120 | unshift @MM::ISA, 'ExtUtils::MM_VMS' if $Is_VMS; |
121 | unshift @MM::ISA, 'ExtUtils::MM_OS2' if $Is_OS2; | |
8e07c86e AD |
122 | |
123 | ||
124 | @ExtUtils::MakeMaker::MM_Sections_spec = ( | |
125 | post_initialize => {}, | |
126 | const_config => {}, | |
127 | constants => {}, | |
128 | const_loadlibs => {}, | |
129 | const_cccmd => {}, # the last but one addition here (CONST_CCCMD) | |
130 | tool_autosplit => {}, | |
131 | tool_xsubpp => {}, | |
132 | tools_other => {}, | |
133 | dist => {}, | |
134 | macro => {}, | |
c07a80fd | 135 | depend => {}, |
8e07c86e AD |
136 | post_constants => {}, |
137 | pasthru => {}, | |
138 | c_o => {}, | |
139 | xs_c => {}, | |
140 | xs_o => {}, | |
141 | top_targets => {}, # currently the last section that adds a key to $self (DIR_TARGET) | |
142 | linkext => {}, | |
143 | dlsyms => {}, | |
144 | dynamic => {}, | |
145 | dynamic_bs => {}, | |
146 | dynamic_lib => {}, | |
147 | static => {}, | |
148 | static_lib => {}, | |
149 | installpm => {}, | |
150 | manifypods => {}, | |
151 | processPL => {}, | |
152 | installbin => {}, | |
153 | subdirs => {}, | |
154 | clean => {}, | |
155 | realclean => {}, | |
156 | dist_basics => {}, | |
157 | dist_core => {}, | |
158 | dist_dir => {}, | |
159 | dist_test => {}, | |
160 | dist_ci => {}, | |
161 | install => {}, | |
162 | force => {}, | |
163 | perldepend => {}, | |
164 | makefile => {}, | |
165 | staticmake => {}, # Sadly this defines more macros | |
166 | test => {}, | |
167 | postamble => {}, # should always be last the user has hands on | |
168 | selfdocument => {}, # well, he may override it, but he won't do it | |
169 | ); | |
0d8023a2 | 170 | # loses section ordering |
8e07c86e AD |
171 | %ExtUtils::MakeMaker::MM_Sections = @ExtUtils::MakeMaker::MM_Sections_spec; |
172 | # keeps order | |
173 | @ExtUtils::MakeMaker::MM_Sections = grep(!ref, @ExtUtils::MakeMaker::MM_Sections_spec); | |
42793c05 | 174 | |
8e07c86e | 175 | %ExtUtils::MakeMaker::Recognized_Att_Keys = %ExtUtils::MakeMaker::MM_Sections; # All sections are valid keys. |
864a5fa8 AD |
176 | |
177 | @ExtUtils::MakeMaker::Get_from_Config = qw( | |
178 | ar | |
179 | cc | |
180 | cccdlflags | |
181 | ccdlflags | |
182 | dlext | |
183 | dlsrc | |
184 | ld | |
185 | lddlflags | |
186 | ldflags | |
187 | libc | |
188 | lib_ext | |
189 | obj_ext | |
190 | ranlib | |
191 | so | |
192 | ); | |
193 | ||
194 | my $item; | |
195 | foreach $item (split(/\n/,attrib_help())){ | |
196 | next unless $item =~ m/^=item\s+(\w+)\s*$/; | |
8e07c86e AD |
197 | $ExtUtils::MakeMaker::Recognized_Att_Keys{$1} = $2; |
198 | print "Attribute '$1' => '$2'\n" if ($ExtUtils::MakeMaker::Verbose >= 2); | |
199 | } | |
864a5fa8 AD |
200 | foreach $item (@ExtUtils::MakeMaker::Get_from_Config) { |
201 | next unless $Config::Config{$item}; | |
202 | $ExtUtils::MakeMaker::Recognized_Att_Keys{uc $item} = $Config::Config{$item}; | |
203 | print "Attribute '\U$item\E' => '$Config::Config{$item}'\n" | |
204 | if ($ExtUtils::MakeMaker::Verbose >= 2); | |
205 | } | |
42793c05 | 206 | |
8e07c86e AD |
207 | %ExtUtils::MakeMaker::Prepend_dot_dot = qw( |
208 | INST_LIB 1 INST_ARCHLIB 1 INST_EXE 1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1 | |
4633a7c4 | 209 | PERL_SRC 1 PERL 1 FULLPERL 1 |
8e07c86e AD |
210 | ); |
211 | $PACKNAME = "PACK000"; | |
42793c05 | 212 | |
8e07c86e AD |
213 | sub writeMakefile { |
214 | die <<END; | |
232e078e | 215 | |
8e07c86e AD |
216 | The extension you are trying to build apparently is rather old and |
217 | most probably outdated. We detect that from the fact, that a | |
218 | subroutine "writeMakefile" is called, and this subroutine is not | |
219 | supported anymore since about October 1994. | |
40000a8c | 220 | |
4633a7c4 LW |
221 | Please contact the author or look into CPAN (details about CPAN can be |
222 | found in the FAQ and at http:/www.perl.com) for a more recent version | |
223 | of the extension. If you're really desperate, you can try to change | |
224 | the subroutine name from writeMakefile to WriteMakefile and rerun | |
225 | 'perl Makefile.PL', but you're most probably left alone, when you do | |
226 | so. | |
42793c05 | 227 | |
8e07c86e | 228 | The MakeMaker team |
1aef975c | 229 | |
42793c05 | 230 | END |
8e07c86e | 231 | } |
42793c05 | 232 | |
8e07c86e AD |
233 | sub WriteMakefile { |
234 | Carp::croak "WriteMakefile: Need even number of args" if @_ % 2; | |
235 | my %att = @_; | |
236 | MM->new(\%att)->flush; | |
42793c05 TB |
237 | } |
238 | ||
8e07c86e AD |
239 | sub new { |
240 | my($class,$self) = @_; | |
241 | my($key); | |
42793c05 | 242 | |
8e07c86e AD |
243 | print STDOUT "MakeMaker (v$ExtUtils::MakeMaker::VERSION)\n" if $ExtUtils::MakeMaker::Verbose; |
244 | if (-f "MANIFEST" && ! -f "Makefile"){ | |
245 | check_manifest(); | |
1aef975c | 246 | } |
42793c05 | 247 | |
8e07c86e | 248 | $self = {} unless (defined $self); |
005c1a0e | 249 | |
864a5fa8 | 250 | check_hints($self); |
4633a7c4 | 251 | |
8e07c86e | 252 | my(%initial_att) = %$self; # record initial attributes |
005c1a0e | 253 | |
8e07c86e AD |
254 | if (defined $self->{CONFIGURE}) { |
255 | if (ref $self->{CONFIGURE} eq 'CODE') { | |
256 | $self = { %$self, %{&{$self->{CONFIGURE}}}}; | |
005c1a0e | 257 | } else { |
8e07c86e | 258 | croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n"; |
005c1a0e AD |
259 | } |
260 | } | |
a0d0e21e | 261 | |
8e07c86e AD |
262 | # This is for old Makefiles written pre 5.00, will go away |
263 | if ( Carp::longmess("") =~ /runsubdirpl/s ){ | |
264 | $self->{Correct_relativ_directories}++; | |
265 | } else { | |
266 | $self->{Correct_relativ_directories}=0; | |
267 | } | |
5d94fbed | 268 | |
8e07c86e AD |
269 | my $class = ++$PACKNAME; |
270 | { | |
271 | # no strict; | |
272 | print "Blessing Object into class [$class]\n" if $ExtUtils::MakeMaker::Verbose; | |
273 | mv_all_methods("MY",$class); | |
274 | bless $self, $class; | |
275 | ######## tie %::att, ExtUtils::MakeMaker::TieAtt, $self; | |
276 | push @ExtUtils::MakeMaker::Parent, $self; | |
277 | @{"$class\:\:ISA"} = 'MM'; | |
278 | } | |
5d94fbed | 279 | |
8e07c86e AD |
280 | if (defined $ExtUtils::MakeMaker::Parent[-2]){ |
281 | $self->{PARENT} = $ExtUtils::MakeMaker::Parent[-2]; | |
282 | my $key; | |
283 | for $key (keys %ExtUtils::MakeMaker::Prepend_dot_dot) { | |
4633a7c4 | 284 | next unless defined $self->{PARENT}{$key}; |
8e07c86e AD |
285 | $self->{$key} = $self->{PARENT}{$key}; |
286 | $self->{$key} = $self->catdir("..",$self->{$key}) | |
287 | unless $self->{$key} =~ m!^/!; | |
288 | } | |
289 | $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT}; | |
290 | } else { | |
291 | parse_args($self,@ARGV); | |
292 | } | |
a0d0e21e | 293 | |
8e07c86e | 294 | $self->{NAME} ||= $self->guess_name; |
a0d0e21e | 295 | |
8e07c86e | 296 | ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g; |
a0d0e21e | 297 | |
8e07c86e AD |
298 | $self->init_main(); |
299 | ||
0d8023a2 | 300 | if (! $self->{PERL_SRC} ) { |
301 | my($pthinks) = $INC{'Config.pm'}; | |
302 | $pthinks = vmsify($pthinks) if $Is_VMS; | |
303 | if ($pthinks ne $self->catfile($Config::Config{archlibexp},'Config.pm')){ | |
304 | $pthinks =~ s!/Config\.pm$!!; | |
305 | $pthinks =~ s!.*/!!; | |
306 | print STDOUT <<END; | |
005c1a0e AD |
307 | Your perl and your Config.pm seem to have different ideas about the architecture |
308 | they are running on. | |
8e07c86e AD |
309 | Perl thinks: [$pthinks] |
310 | Config says: [$Config::Config{archname}] | |
005c1a0e AD |
311 | This may or may not cause problems. Please check your installation of perl if you |
312 | have problems building this extension. | |
313 | END | |
0d8023a2 | 314 | } |
005c1a0e AD |
315 | } |
316 | ||
8e07c86e AD |
317 | $self->init_dirscan(); |
318 | $self->init_others(); | |
75f92628 | 319 | |
8e07c86e AD |
320 | push @{$self->{RESULT}}, <<END; |
321 | # This Makefile is for the $self->{NAME} extension to perl. | |
322 | # | |
323 | # It was generated automatically by MakeMaker version $ExtUtils::MakeMaker::VERSION from the contents | |
324 | # of Makefile.PL. Don't edit this file, edit Makefile.PL instead. | |
325 | # | |
326 | # ANY CHANGES MADE HERE WILL BE LOST! | |
327 | # | |
328 | # MakeMaker Parameters: | |
329 | END | |
a0d0e21e | 330 | |
42793c05 TB |
331 | foreach $key (sort keys %initial_att){ |
332 | my($v) = neatvalue($initial_att{$key}); | |
8e07c86e | 333 | $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/; |
42793c05 | 334 | $v =~ tr/\n/ /s; |
8e07c86e | 335 | push @{$self->{RESULT}}, "# $key => $v"; |
42793c05 | 336 | } |
a0d0e21e | 337 | |
8e07c86e AD |
338 | # turn the SKIP array into a SKIPHASH hash |
339 | my (%skip,$skip); | |
340 | for $skip (@{$self->{SKIP} || []}) { | |
341 | $self->{SKIPHASH}{$skip} = 1; | |
342 | } | |
42793c05 | 343 | |
8e07c86e AD |
344 | # We run all the subdirectories now. They don't have much to query |
345 | # from the parent, but the parent has to query them: if they need linking! | |
346 | my($dir); | |
347 | unless ($self->{NORECURS}) { | |
348 | foreach $dir (@{$self->{DIR}}){ | |
349 | chdir $dir; | |
4633a7c4 | 350 | package main; |
8e07c86e AD |
351 | local *FH; |
352 | open FH, "Makefile.PL"; | |
353 | eval join "", <FH>; | |
354 | close FH; | |
355 | chdir ".."; | |
42793c05 TB |
356 | } |
357 | } | |
a0d0e21e | 358 | |
8e07c86e AD |
359 | tie %::att, ExtUtils::MakeMaker::TieAtt, $self; |
360 | my $section; | |
361 | foreach $section ( @ExtUtils::MakeMaker::MM_Sections ){ | |
362 | print "Processing Makefile '$section' section\n" if ($ExtUtils::MakeMaker::Verbose >= 2); | |
363 | my($skipit) = $self->skipcheck($section); | |
364 | if ($skipit){ | |
365 | push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit."; | |
4e68a208 | 366 | } else { |
8e07c86e AD |
367 | my(%a) = %{$self->{$section} || {}}; |
368 | push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:"; | |
369 | push @{$self->{RESULT}}, "# " . join ", ", %a if $ExtUtils::MakeMaker::Verbose && %a; | |
370 | push @{$self->{RESULT}}, $self->nicetext($self->$section( %a )); | |
42793c05 TB |
371 | } |
372 | } | |
a0d0e21e | 373 | |
8e07c86e AD |
374 | push @{$self->{RESULT}}, "\n# End."; |
375 | ######## untie %::att; | |
376 | pop @ExtUtils::MakeMaker::Parent; | |
a0d0e21e | 377 | |
8e07c86e | 378 | $self; |
a0d0e21e LW |
379 | } |
380 | ||
8e07c86e AD |
381 | sub check_manifest { |
382 | eval {require ExtUtils::Manifest}; | |
005c1a0e | 383 | if ($@){ |
8e07c86e AD |
384 | print STDOUT "Warning: you have not installed the ExtUtils::Manifest |
385 | module -- skipping check of the MANIFEST file\n"; | |
386 | } else { | |
387 | print STDOUT "Checking if your kit is complete...\n"; | |
388 | $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning | |
389 | my(@missed)=ExtUtils::Manifest::manicheck(); | |
390 | if (@missed){ | |
391 | print STDOUT "Warning: the following files are missing in your kit:\n"; | |
392 | print "\t", join "\n\t", @missed; | |
393 | print STDOUT "\n"; | |
394 | print STDOUT "Please inform the author.\n"; | |
395 | } else { | |
396 | print STDOUT "Looks good\n"; | |
397 | } | |
005c1a0e | 398 | } |
005c1a0e AD |
399 | } |
400 | ||
42793c05 | 401 | sub parse_args{ |
8e07c86e | 402 | my($self, @args) = @_; |
42793c05 | 403 | foreach (@args){ |
75f92628 AD |
404 | unless (m/(.*?)=(.*)/){ |
405 | help(),exit 1 if m/^help$/; | |
8e07c86e | 406 | ++$ExtUtils::MakeMaker::Verbose if m/^verb/; |
75f92628 AD |
407 | next; |
408 | } | |
409 | my($name, $value) = ($1, $2); | |
410 | if ($value =~ m/^~(\w+)?/){ # tilde with optional username | |
005c1a0e | 411 | $value =~ s [^~(\w*)] |
864a5fa8 AD |
412 | [$1 ? |
413 | ((getpwnam($1))[7] || "~$1") : | |
005c1a0e AD |
414 | (getpwuid($>))[7] |
415 | ]ex; | |
416 | } | |
4633a7c4 | 417 | # This may go away, in mid 1996 |
8e07c86e AD |
418 | if ($self->{Correct_relativ_directories}){ |
419 | $value = $self->catdir("..",$value) | |
4633a7c4 | 420 | if $ExtUtils::MakeMaker::Prepend_dot_dot{$name} && ! $value =~ m!^/!; |
75f92628 | 421 | } |
8e07c86e | 422 | $self->{$name} = $value; |
42793c05 | 423 | } |
4633a7c4 | 424 | # This may go away, in mid 1996 |
8e07c86e AD |
425 | delete $self->{Correct_relativ_directories}; |
426 | ||
42793c05 | 427 | # catch old-style 'potential_libs' and inform user how to 'upgrade' |
8e07c86e AD |
428 | if (defined $self->{potential_libs}){ |
429 | my($msg)="'potential_libs' => '$self->{potential_libs}' should be"; | |
430 | if ($self->{potential_libs}){ | |
431 | print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n"; | |
42793c05 | 432 | } else { |
fed7345c | 433 | print STDOUT "$msg deleted.\n"; |
42793c05 | 434 | } |
8e07c86e AD |
435 | $self->{LIBS} = [$self->{potential_libs}]; |
436 | delete $self->{potential_libs}; | |
42793c05 TB |
437 | } |
438 | # catch old-style 'ARMAYBE' and inform user how to 'upgrade' | |
8e07c86e AD |
439 | if (defined $self->{ARMAYBE}){ |
440 | my($armaybe) = $self->{ARMAYBE}; | |
fed7345c | 441 | print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n", |
42793c05 | 442 | "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n"; |
8e07c86e AD |
443 | my(%dl) = %{$self->{dynamic_lib} || {}}; |
444 | $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe}; | |
445 | delete $self->{ARMAYBE}; | |
42793c05 | 446 | } |
8e07c86e | 447 | if (defined $self->{LDTARGET}){ |
fed7345c | 448 | print STDOUT "LDTARGET should be changed to LDFROM\n"; |
8e07c86e AD |
449 | $self->{LDFROM} = $self->{LDTARGET}; |
450 | delete $self->{LDTARGET}; | |
75f92628 | 451 | } |
4633a7c4 LW |
452 | # Turn a DIR argument on the command line into an array |
453 | if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') { | |
454 | # So they can choose from the command line, which extensions they want | |
455 | # the grep enables them to have some colons too much in case they | |
456 | # have to build a list with the shell | |
457 | $self->{DIR} = [grep $_, split ":", $self->{DIR}]; | |
458 | } | |
8e07c86e AD |
459 | my $mmkey; |
460 | foreach $mmkey (sort keys %$self){ | |
461 | print STDOUT " $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $ExtUtils::MakeMaker::Verbose; | |
462 | print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n" | |
463 | unless exists $ExtUtils::MakeMaker::Recognized_Att_Keys{$mmkey}; | |
464 | } | |
465 | } | |
466 | ||
467 | sub check_hints { | |
468 | my($self) = @_; | |
469 | # We allow extension-specific hints files. | |
470 | ||
471 | return unless -d "hints"; | |
472 | ||
473 | # First we look for the best hintsfile we have | |
474 | my(@goodhints); | |
475 | my($hint)="$Config::Config{osname}_$Config::Config{osvers}"; | |
476 | $hint =~ s/\./_/g; | |
477 | $hint =~ s/_$//; | |
478 | return unless $hint; | |
479 | ||
480 | # Also try without trailing minor version numbers. | |
481 | while (1) { | |
482 | last if -f "hints/$hint.pl"; # found | |
483 | } continue { | |
484 | last unless $hint =~ s/_[^_]*$//; # nothing to cut off | |
42793c05 | 485 | } |
8e07c86e AD |
486 | return unless -f "hints/$hint.pl"; # really there |
487 | ||
488 | # execute the hintsfile: | |
4633a7c4 | 489 | local *HINTS; |
8e07c86e AD |
490 | open HINTS, "hints/$hint.pl"; |
491 | @goodhints = <HINTS>; | |
492 | close HINTS; | |
493 | print STDOUT "Processing hints file hints/$hint.pl\n"; | |
494 | eval join('',@goodhints); | |
495 | print STDOUT $@ if $@; | |
a0d0e21e LW |
496 | } |
497 | ||
8e07c86e AD |
498 | sub mv_all_methods { |
499 | my($from,$to) = @_; | |
500 | my($method); | |
0d8023a2 | 501 | my($symtab) = \%{"${from}::"}; |
8e07c86e AD |
502 | # no strict; |
503 | ||
864a5fa8 AD |
504 | # Here you see the *current* list of methods that are overridable |
505 | # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm | |
506 | # still trying to reduce the list to some reasonable minimum -- | |
507 | # because I want to make it easier for the user. A.K. | |
508 | ||
509 | foreach $method (@ExtUtils::MakeMaker::MM_Sections, qw[ dir_target | |
510 | exescan fileparse fileparse_set_fstype installpm_x libscan makeaperl | |
511 | mksymlists needs_linking runsubdirpl subdir_x test_via_harness | |
512 | test_via_script writedoc ]) { | |
8e07c86e AD |
513 | |
514 | # We cannot say "next" here. Nick might call MY->makeaperl | |
515 | # which isn't defined right now | |
516 | ||
517 | # next unless defined &{"${from}::$method"}; | |
518 | ||
519 | *{"${to}::$method"} = \&{"${from}::$method"}; | |
8e07c86e AD |
520 | |
521 | # delete would do, if we were sure, nobody ever called | |
522 | # MY->makeaperl directly | |
a0d0e21e | 523 | |
8e07c86e AD |
524 | # delete $symtab->{$method}; |
525 | ||
526 | # If we delete a method, then it will be undefined and cannot | |
527 | # be called. But as long as we have Makefile.PLs that rely on | |
528 | # %MY:: being intact, we have to fill the hole with an | |
529 | # inheriting method: | |
530 | ||
531 | eval "package MY; sub $method {local *$method; shift->MY::$method(\@_); }"; | |
532 | ||
864a5fa8 | 533 | } |
8e07c86e AD |
534 | |
535 | # We have to clean out %INC also, because the current directory is | |
536 | # changed frequently and Graham Barr prefers to get his version | |
537 | # out of a History.pl file which is "required" so woudn't get | |
538 | # loaded again in another extension requiring a History.pl | |
539 | ||
540 | my $inc; | |
541 | foreach $inc (keys %INC) { | |
542 | next if $ExtUtils::MakeMaker::NORMAL_INC{$inc}; | |
543 | #warn "***$inc*** deleted"; | |
544 | delete $INC{$inc}; | |
545 | } | |
546 | ||
547 | } | |
548 | ||
549 | sub prompt { | |
550 | my($mess,$def)=@_; | |
0d8023a2 | 551 | BEGIN { $ISA_TTY = -t STDIN && -t STDOUT } |
4633a7c4 | 552 | Carp::confess("prompt function called without an argument") unless defined $mess; |
8e07c86e AD |
553 | $def = "" unless defined $def; |
554 | my $dispdef = "[$def] "; | |
4633a7c4 LW |
555 | my $ans; |
556 | if ($ISA_TTY) { | |
557 | local $|=1; | |
558 | print "$mess $dispdef"; | |
559 | chop($ans = <STDIN>); | |
560 | } | |
561 | return $ans if defined $ans; | |
562 | return $def; | |
8e07c86e AD |
563 | } |
564 | ||
565 | sub attrib_help { | |
566 | return $Attrib_Help if $Attrib_Help; | |
567 | my $switch = 0; | |
568 | my $help; | |
569 | my $line; | |
570 | local *POD; | |
571 | #### local $/ = ""; # bug in 5.001m | |
572 | open POD, $INC{"ExtUtils/MakeMaker.pm"} | |
573 | or die "Open $INC{'ExtUtils/MakeMaker.pm'}: $!"; | |
574 | while ($line = <POD>) { | |
864a5fa8 | 575 | $switch ||= $line =~ /^=item C\s*$/; |
8e07c86e AD |
576 | next unless $switch; |
577 | last if $line =~ /^=cut/; | |
578 | $help .= $line; | |
579 | } | |
580 | close POD; | |
581 | $Attrib_Help = $help; | |
582 | } | |
583 | ||
584 | sub help {print &attrib_help, "\n";} | |
585 | ||
586 | sub skipcheck{ | |
587 | my($self) = shift; | |
588 | my($section) = @_; | |
589 | if ($section eq 'dynamic') { | |
590 | print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ", | |
591 | "in skipped section 'dynamic_bs'\n" | |
592 | if $self->{SKIPHASH}{dynamic_bs} && $ExtUtils::MakeMaker::Verbose; | |
593 | print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ", | |
594 | "in skipped section 'dynamic_lib'\n" | |
595 | if $self->{SKIPHASH}{dynamic_lib} && $ExtUtils::MakeMaker::Verbose; | |
596 | } | |
597 | if ($section eq 'dynamic_lib') { | |
598 | print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ", | |
599 | "targets in skipped section 'dynamic_bs'\n" | |
600 | if $self->{SKIPHASH}{dynamic_bs} && $ExtUtils::MakeMaker::Verbose; | |
601 | } | |
602 | if ($section eq 'static') { | |
603 | print STDOUT "Warning (non-fatal): Target 'static' depends on targets ", | |
604 | "in skipped section 'static_lib'\n" | |
605 | if $self->{SKIPHASH}{static_lib} && $ExtUtils::MakeMaker::Verbose; | |
606 | } | |
607 | return 'skipped' if $self->{SKIPHASH}{$section}; | |
608 | return ''; | |
609 | } | |
610 | ||
611 | sub flush { | |
612 | my $self = shift; | |
613 | my($chunk); | |
614 | local *MAKE; | |
615 | print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n"; | |
616 | ||
617 | unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ''); | |
618 | open MAKE, ">MakeMaker.tmp" or die "Unable to open MakeMaker.tmp: $!"; | |
619 | ||
620 | for $chunk (@{$self->{RESULT}}) { | |
621 | print MAKE "$chunk\n"; | |
622 | } | |
623 | ||
624 | close MAKE; | |
0d8023a2 | 625 | my($finalname) = $self->{MAKEFILE}; |
8e07c86e | 626 | rename("MakeMaker.tmp", $finalname); |
0d8023a2 | 627 | chmod 0644, $finalname unless $Is_VMS; |
8e07c86e AD |
628 | system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":"; |
629 | } | |
630 | ||
631 | sub Version_check { | |
632 | my($checkversion) = @_; | |
633 | die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion. | |
634 | Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable | |
635 | changes in the meantime. | |
636 | Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n" | |
c07a80fd | 637 | if $checkversion lt $ExtUtils::MakeMaker::Version_OK; |
4633a7c4 | 638 | printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v", |
8e07c86e AD |
639 | $checkversion, "Current Version is", $ExtUtils::MakeMaker::VERSION |
640 | unless $checkversion == $ExtUtils::MakeMaker::VERSION; | |
641 | } | |
642 | ||
8e07c86e AD |
643 | # The following mkbootstrap() is only for installations that are calling |
644 | # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker | |
645 | # writes Makefiles, that use ExtUtils::Mkbootstrap directly. | |
646 | sub mkbootstrap { | |
647 | die <<END; | |
648 | !!! Your Makefile has been built such a long time ago, !!! | |
649 | !!! that is unlikely to work with current MakeMaker. !!! | |
650 | !!! Please rebuild your Makefile !!! | |
651 | END | |
652 | } | |
653 | ||
c07a80fd | 654 | # Ditto for mksymlists() as of MakeMaker 5.17 |
655 | sub mksymlists { | |
656 | die <<END; | |
657 | !!! Your Makefile has been built such a long time ago, !!! | |
658 | !!! that is unlikely to work with current MakeMaker. !!! | |
659 | !!! Please rebuild your Makefile !!! | |
660 | END | |
661 | } | |
662 | ||
8e07c86e | 663 | sub neatvalue { |
42793c05 | 664 | my($v) = @_; |
fed7345c | 665 | return "undef" unless defined $v; |
42793c05 TB |
666 | my($t) = ref $v; |
667 | return "'$v'" unless $t; | |
8e07c86e AD |
668 | if ($t eq 'ARRAY') { |
669 | my(@m, $elem, @neat); | |
670 | push @m, "["; | |
671 | foreach $elem (@$v) { | |
672 | push @neat, "'$elem'"; | |
673 | } | |
674 | push @m, join ", ", @neat; | |
675 | push @m, "]"; | |
676 | return join "", @m; | |
677 | } | |
42793c05 TB |
678 | return "$v" unless $t eq 'HASH'; |
679 | my(@m, $key, $val); | |
680 | push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v); | |
681 | return "{ ".join(', ',@m)." }"; | |
682 | } | |
683 | ||
8e07c86e AD |
684 | sub selfdocument { |
685 | my($self) = @_; | |
686 | my(@m); | |
687 | if ($ExtUtils::MakeMaker::Verbose){ | |
688 | push @m, "\n# Full list of MakeMaker attribute values:"; | |
689 | foreach $key (sort keys %$self){ | |
690 | next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/; | |
691 | my($v) = neatvalue($self->{$key}); | |
692 | $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/; | |
693 | $v =~ tr/\n/ /s; | |
694 | push @m, "# $key => $v"; | |
695 | } | |
696 | } | |
697 | join "\n", @m; | |
698 | } | |
699 | ||
700 | ||
701 | # # # # # # | |
702 | ## ## ## ## # # # # # # # | |
703 | # # # # # # # # # # ## # # # # | |
704 | # # # # # # # # # # # # ## | |
705 | # # # # # # # # # # ## | |
706 | # # # # # # # ## # # # | |
707 | # # # # ####### ##### # # # # # | |
a0d0e21e | 708 | |
c07a80fd | 709 | package ExtUtils::MM_Unix; |
a0d0e21e LW |
710 | |
711 | use Config; | |
42793c05 TB |
712 | use Cwd; |
713 | use File::Basename; | |
a0d0e21e LW |
714 | require Exporter; |
715 | ||
42793c05 | 716 | Exporter::import('ExtUtils::MakeMaker', |
c07a80fd | 717 | qw( $Verbose &neatvalue)); |
a0d0e21e | 718 | |
42793c05 TB |
719 | # These attributes cannot be overridden externally |
720 | @Other_Att_Keys{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)} = (1) x 3; | |
a0d0e21e | 721 | |
8e07c86e | 722 | if ($Is_VMS = $Config::Config{osname} eq 'VMS') { |
748a9306 | 723 | require VMS::Filespec; |
0d8023a2 | 724 | import VMS::Filespec qw( &vmsify ); |
a0d0e21e LW |
725 | } |
726 | ||
8e07c86e AD |
727 | $Is_OS2 = $ExtUtils::MakeMaker::Is_OS2; |
728 | ||
0d8023a2 | 729 | sub guess_name { |
8e07c86e AD |
730 | my($self) = @_; |
731 | my $name = fastcwd(); | |
0d8023a2 | 732 | $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::); |
733 | $name =~ s#/#::#g; | |
734 | $name =~ s#[\-_][\d.\-]+$##; # this is new with MM 5.00 | |
8e07c86e AD |
735 | $name; |
736 | } | |
a0d0e21e | 737 | |
75f92628 | 738 | sub init_main { |
005c1a0e | 739 | my($self) = @_; |
8e07c86e AD |
740 | unless (ref $self){ |
741 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
742 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
743 | } | |
005c1a0e | 744 | |
005c1a0e AD |
745 | # --- Initialize Module Name and Paths |
746 | ||
747 | # NAME = The perl module name for this extension (eg DBD::Oracle). | |
748 | # FULLEXT = Pathname for extension directory (eg DBD/Oracle). | |
749 | # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. | |
750 | # ROOTEXT = Directory part of FULLEXT with leading /. | |
8e07c86e AD |
751 | ($self->{FULLEXT} = |
752 | $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket | |
753 | ||
754 | # Copied from DynaLoader: | |
755 | ||
756 | my(@modparts) = split(/::/,$self->{NAME}); | |
757 | my($modfname) = $modparts[-1]; | |
758 | ||
759 | # Some systems have restrictions on files names for DLL's etc. | |
760 | # mod2fname returns appropriate file base name (typically truncated) | |
761 | # It may also edit @modparts if required. | |
762 | if (defined &DynaLoader::mod2fname) { | |
763 | $modfname = &DynaLoader::mod2fname(\@modparts); | |
764 | } elsif ($Is_OS2) { # Need manual correction if run with miniperl:-( | |
765 | $modfname = substr($modfname, 0, 7) . '_'; | |
766 | } | |
767 | ||
768 | ||
769 | ($self->{BASEEXT} = | |
770 | $self->{NAME}) =~ s!.*::!! ; #eg. Socket | |
771 | ||
772 | if (defined &DynaLoader::mod2fname or $Is_OS2) { | |
773 | # As of 5.001m, dl_os2 appends '_' | |
774 | $self->{DLBASE} = $modfname; #eg. Socket_ | |
775 | } else { | |
776 | $self->{DLBASE} = '$(BASEEXT)'; | |
005c1a0e | 777 | } |
8e07c86e AD |
778 | |
779 | ($self->{ROOTEXT} = | |
780 | $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ; #eg. /BSD/Foo | |
781 | ||
4633a7c4 | 782 | $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT}; |
42793c05 | 783 | |
005c1a0e AD |
784 | |
785 | # --- Initialize PERL_LIB, INST_LIB, PERL_SRC | |
786 | ||
787 | # *Real* information: where did we get these two from? ... | |
788 | my $inc_config_dir = dirname($INC{'Config.pm'}); | |
789 | my $inc_carp_dir = dirname($INC{'Carp.pm'}); | |
790 | ||
791 | # Typically PERL_* and INST_* will be identical but that need | |
792 | # not be the case (e.g., installing into project libraries etc). | |
42793c05 TB |
793 | |
794 | # Perl Macro: With source No source | |
e1666bf5 | 795 | # PERL_SRC ../.. (undefined) |
4e68a208 AD |
796 | # PERL_LIB PERL_SRC/lib $Config{privlibexp} |
797 | # PERL_ARCHLIB PERL_SRC/lib $Config{archlibexp} | |
42793c05 | 798 | |
005c1a0e AD |
799 | # INST Macro: For standard for any other |
800 | # modules module | |
4633a7c4 LW |
801 | # INST_LIB PERL_SRC/lib ./blib |
802 | # INST_ARCHLIB PERL_SRC/lib ./blib/<archname> | |
8e07c86e AD |
803 | |
804 | unless ($self->{PERL_SRC}){ | |
805 | my($dir); | |
4633a7c4 | 806 | foreach $dir (qw(.. ../.. ../../..)){ |
864a5fa8 AD |
807 | if ( -f "$dir/config.sh" |
808 | && -f "$dir/perl.h" | |
8e07c86e AD |
809 | && -f "$dir/lib/Exporter.pm") { |
810 | $self->{PERL_SRC}=$dir ; | |
232e078e AD |
811 | last; |
812 | } | |
a0d0e21e | 813 | } |
a0d0e21e | 814 | } |
8e07c86e AD |
815 | if ($self->{PERL_SRC}){ |
816 | $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib"); | |
817 | $self->{PERL_ARCHLIB} = $self->{PERL_LIB}; | |
818 | $self->{PERL_INC} = $self->{PERL_SRC}; | |
0d8023a2 | 819 | # catch a situation that has occurred a few times in the past: |
8e07c86e AD |
820 | warn <<EOM unless -s "$self->{PERL_SRC}/cflags"; |
821 | You cannot build extensions below the perl source tree after executing | |
822 | a 'make clean' in the perl source tree. | |
823 | ||
824 | To rebuild extensions distributed with the perl source you should | |
825 | simply Configure (to include those extensions) and then build perl as | |
826 | normal. After installing perl the source tree can be deleted. It is not | |
827 | needed for building extensions. | |
828 | ||
829 | It is recommended that you unpack and build additional extensions away | |
830 | from the perl source tree. | |
831 | EOM | |
832 | } else { | |
42793c05 | 833 | # we should also consider $ENV{PERL5LIB} here |
8e07c86e AD |
834 | $self->{PERL_LIB} = $Config::Config{privlibexp} unless $self->{PERL_LIB}; |
835 | $self->{PERL_ARCHLIB} = $Config::Config{archlibexp} unless $self->{PERL_ARCHLIB}; | |
836 | $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now | |
837 | my $perl_h; | |
838 | die <<EOM unless (-f ($perl_h = $self->catfile("$self->{PERL_INC}","perl.h"))); | |
005c1a0e AD |
839 | Error: Unable to locate installed Perl libraries or Perl source code. |
840 | ||
841 | It is recommended that you install perl in a standard location before | |
842 | building extensions. You can say: | |
843 | ||
844 | $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory | |
845 | ||
846 | if you have not yet installed perl but still want to build this | |
847 | extension now. | |
8e07c86e | 848 | (You get this message, because MakeMaker could not find "$perl_h") |
005c1a0e AD |
849 | EOM |
850 | ||
8e07c86e AD |
851 | # print STDOUT "Using header files found in $self->{PERL_INC}\n" |
852 | # if $Verbose && $self->needs_linking(); | |
232e078e | 853 | |
42793c05 TB |
854 | } |
855 | ||
856 | # INST_LIB typically pre-set if building an extension after | |
857 | # perl has been built and installed. Setting INST_LIB allows | |
8e07c86e AD |
858 | # you to build directly into, say $Config::Config{privlibexp}. |
859 | unless ($self->{INST_LIB}){ | |
4633a7c4 LW |
860 | |
861 | ||
862 | ##### XXXXX We have to change this nonsense | |
863 | ||
8e07c86e AD |
864 | if (defined $self->{PERL_SRC}) { |
865 | $self->{INST_LIB} = $self->{PERL_LIB}; | |
3edbfbe5 | 866 | } else { |
8e07c86e | 867 | $self->{INST_LIB} = $self->catdir(".","blib"); |
3edbfbe5 TB |
868 | } |
869 | } | |
42793c05 | 870 | # Try to work out what INST_ARCHLIB should be if not set: |
8e07c86e | 871 | unless ($self->{INST_ARCHLIB}){ |
42793c05 | 872 | my(%archmap) = ( |
864a5fa8 AD |
873 | # our private build lib |
874 | $self->catdir(".","blib") => | |
875 | $self->catdir(".","blib",$Config::Config{archname}), | |
8e07c86e AD |
876 | $self->{PERL_LIB} => $self->{PERL_ARCHLIB}, |
877 | $Config::Config{privlibexp} => $Config::Config{archlibexp}, | |
42793c05 TB |
878 | $inc_carp_dir => $inc_config_dir, |
879 | ); | |
8e07c86e AD |
880 | $self->{INST_ARCHLIB} = $archmap{$self->{INST_LIB}}; |
881 | unless($self->{INST_ARCHLIB}){ | |
75f92628 | 882 | # Oh dear, we'll have to default it and warn the user |
8e07c86e AD |
883 | my($archname) = $Config::Config{archname}; |
884 | if (-d "$self->{INST_LIB}/$archname"){ | |
885 | $self->{INST_ARCHLIB} = $self->catdir("$self->{INST_LIB}","$archname"); | |
886 | print STDOUT "Defaulting INST_ARCHLIB to $self->{INST_ARCHLIB}\n"; | |
75f92628 | 887 | } else { |
8e07c86e | 888 | $self->{INST_ARCHLIB} = $self->{INST_LIB}; |
75f92628 AD |
889 | } |
890 | } | |
42793c05 | 891 | } |
8e07c86e | 892 | $self->{INST_EXE} ||= $self->catdir('.','blib',$Config::Config{archname}); |
42793c05 | 893 | |
0d8023a2 | 894 | my($prefix) = $Config{'prefix'}; |
895 | $prefix = VMS::Filespec::unixify($prefix) if $Is_VMS; | |
896 | unless ($self->{PREFIX}){ | |
897 | $self->{PREFIX} = $prefix; | |
898 | } | |
4e68a208 AD |
899 | # With perl5.002 it turns out, that we hardcoded some assumptions in here: |
900 | # $self->{INSTALLPRIVLIB} = $self->catdir($self->{PREFIX},"lib","perl5"); | |
901 | # $self->{INSTALLBIN} = $self->catdir($self->{PREFIX},"bin"); | |
902 | # $self->{INSTALLMAN3DIR} = $self->catdir($self->{PREFIX},"perl5","man","man3") | |
903 | # unless defined $self->{INSTALLMAN3DIR}; | |
904 | ||
0d8023a2 | 905 | # we have to look at the relation between $Config{prefix} and |
906 | # the requested values | |
907 | $self->{INSTALLPRIVLIB} = $Config{installprivlib}; | |
908 | $self->{INSTALLPRIVLIB} = VMS::Filespec::unixpath($self->{INSTALLPRIVLIB}) | |
909 | if $Is_VMS; | |
910 | $self->{INSTALLPRIVLIB} =~ s/\Q$prefix\E/\$(PREFIX)/; | |
911 | $self->{INSTALLBIN} = $Config{installbin}; | |
912 | $self->{INSTALLBIN} = VMS::Filespec::unixpath($self->{INSTALLBIN}) | |
913 | if $Is_VMS; | |
914 | $self->{INSTALLBIN} =~ s/\Q$prefix\E/\$(PREFIX)/; | |
915 | $self->{INSTALLMAN1DIR} = $Config{installman1dir}; | |
916 | $self->{INSTALLMAN1DIR} = VMS::Filespec::unixpath($self->{INSTALLMAN1DIR}) | |
917 | if $Is_VMS; | |
918 | $self->{INSTALLMAN1DIR} =~ s/\Q$prefix\E/\$(PREFIX)/; | |
919 | $self->{INSTALLMAN3DIR} = $Config{installman3dir}; | |
920 | $self->{INSTALLMAN3DIR} = VMS::Filespec::unixpath($self->{INSTALLMAN3DIR}) | |
921 | if $Is_VMS; | |
922 | $self->{INSTALLMAN3DIR} =~ s/\Q$prefix\E/\$(PREFIX)/; | |
8e07c86e AD |
923 | |
924 | if( $self->{INSTALLPRIVLIB} && ! $self->{INSTALLARCHLIB} ){ | |
4e68a208 AD |
925 | # Same as above here. With the unresolved versioned directory issue, we have to |
926 | # be more careful to follow Configure | |
927 | # my($archname) = $Config::Config{archname}; | |
928 | # if (-d $self->catdir($self->{INSTALLPRIVLIB},$archname)){ | |
929 | # $self->{INSTALLARCHLIB} = $self->catdir($self->{INSTALLPRIVLIB},$archname); | |
930 | # print STDOUT "Defaulting INSTALLARCHLIB to $self->{INSTALLARCHLIB}\n"; | |
931 | # } else { | |
932 | # $self->{INSTALLARCHLIB} = $self->{INSTALLPRIVLIB}; | |
933 | # } | |
0d8023a2 | 934 | my($installprivlib) = $Config{'installprivlib'}; |
935 | $installprivlib = VMS::Filespec::unixify($installprivlib) if $Is_VMS; | |
936 | $self->{INSTALLARCHLIB} = $Config{installarchlib}; | |
937 | $self->{INSTALLARCHLIB} = VMS::Filespec::unixpath($self->{INSTALLARCHLIB}) | |
938 | if $Is_VMS; | |
939 | $self->{INSTALLARCHLIB} =~ s/\Q$installprivlib\E/$self->{INSTALLPRIVLIB}/; | |
940 | ||
941 | # It's a pain to be so friendly to the user. I wish we wouldn't have been so nice. | |
942 | # Now we have '$(PREFIX)' in the string, and the directory won't exist | |
943 | my($installarchlib); | |
944 | ($installarchlib = $self->{INSTALLARCHLIB}) =~ s/\$\(PREFIX\)/$self->{PREFIX}/; | |
945 | if (-d $installarchlib) { | |
42793c05 | 946 | } else { |
0d8023a2 | 947 | print STDOUT "Directory $self->{INSTALLARCHLIB} not found, thusly\n" if $Verbose; |
8e07c86e | 948 | $self->{INSTALLARCHLIB} = $self->{INSTALLPRIVLIB}; |
42793c05 | 949 | } |
0d8023a2 | 950 | print STDOUT "Defaulting INSTALLARCHLIB to $self->{INSTALLARCHLIB}\n" if $Verbose; |
42793c05 | 951 | } |
4e68a208 | 952 | |
8e07c86e AD |
953 | $self->{INSTALLPRIVLIB} ||= $Config::Config{installprivlib}; |
954 | $self->{INSTALLARCHLIB} ||= $Config::Config{installarchlib}; | |
955 | $self->{INSTALLBIN} ||= $Config::Config{installbin}; | |
956 | ||
4633a7c4 LW |
957 | $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir} |
958 | unless defined $self->{INSTALLMAN1DIR}; | |
959 | unless (defined $self->{INST_MAN1DIR}){ | |
960 | if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){ | |
961 | $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR}; | |
962 | } else { | |
963 | $self->{INST_MAN1DIR} = $self->catdir('.','blib','man','man1'); | |
964 | } | |
965 | } | |
966 | $self->{MAN1EXT} ||= $Config::Config{man1ext}; | |
005c1a0e | 967 | |
4633a7c4 LW |
968 | $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir} |
969 | unless defined $self->{INSTALLMAN3DIR}; | |
970 | unless (defined $self->{INST_MAN3DIR}){ | |
971 | if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){ | |
972 | $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR}; | |
973 | } else { | |
974 | $self->{INST_MAN3DIR} = $self->catdir('.','blib','man','man3'); | |
975 | } | |
976 | } | |
977 | $self->{MAN3EXT} ||= $Config::Config{man3ext}; | |
8e07c86e | 978 | |
864a5fa8 AD |
979 | print STDOUT "CONFIG must be an array ref\n" |
980 | if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY'); | |
981 | $self->{CONFIG} = [] unless (ref $self->{CONFIG}); | |
982 | push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config); | |
983 | push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags}; | |
984 | my(%once_only,$m); | |
985 | foreach $m (@{$self->{CONFIG}}){ | |
986 | next if $once_only{$m}; | |
987 | print STDOUT "CONFIG key '$m' does not exist in Config.pm\n" | |
988 | unless exists $Config::Config{$m}; | |
989 | $self->{uc $m} ||= $Config::Config{$m}; | |
990 | $once_only{$m} = 1; | |
991 | } | |
992 | ||
993 | # These should never be needed | |
994 | $self->{LD} ||= 'ld'; | |
995 | $self->{OBJ_EXT} ||= '.o'; | |
996 | $self->{LIB_EXT} ||= '.a'; | |
8e07c86e | 997 | |
864a5fa8 | 998 | $self->{MAP_TARGET} ||= "perl"; |
8e07c86e AD |
999 | |
1000 | unless ($self->{LIBPERL_A}){ | |
0d8023a2 | 1001 | $self->{LIBPERL_A} = "libperl$self->{LIB_EXT}"; |
8e07c86e | 1002 | } |
005c1a0e AD |
1003 | |
1004 | # make a few simple checks | |
8e07c86e | 1005 | warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory |
005c1a0e | 1006 | (Exporter.pm not found)" |
8e07c86e | 1007 | unless (-f $self->catfile("$self->{PERL_LIB}","Exporter.pm")); |
42793c05 | 1008 | |
8e07c86e | 1009 | ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME}; |
0d8023a2 | 1010 | if ($self->{VERSION_FROM}){ |
1011 | local *PM; | |
1012 | open PM, $self->{VERSION_FROM} or die "Could not open '$self->{VERSION_FROM}' (attribute VERSION_FROM): $!"; | |
1013 | while (<PM>) { | |
1014 | chop; | |
1015 | next unless /\$([\w:]*\bVERSION)\b.*=/; | |
1016 | local $ExtUtils::MakeMaker::module_version_variable = $1; | |
1017 | my($eval) = "$_;"; | |
1018 | eval $eval; | |
1019 | die "Could not eval '$eval': $@" if $@; | |
1020 | if ($self->{VERSION} = $$ExtUtils::MakeMaker::module_version_variable){ | |
1021 | print "Setting VERSION to $self->{VERSION}\n" if $Verbose; | |
1022 | } else { | |
1023 | print "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n"; | |
1024 | } | |
1025 | last; | |
1026 | } | |
1027 | close PM; | |
1028 | } | |
8e07c86e AD |
1029 | $self->{VERSION} = "0.10" unless $self->{VERSION}; |
1030 | ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g; | |
42793c05 | 1031 | |
4e68a208 AD |
1032 | # Graham Barr and Paul Marquess had some ideas how to ensure |
1033 | # version compatibility between the *.pm file and the | |
1034 | # corresponding *.xs file. The bottomline was, that we need an | |
1035 | # XS_VERSION macro that defaults to VERSION: | |
0d8023a2 | 1036 | $self->{XS_VERSION} ||= $self->{VERSION}; |
42793c05 TB |
1037 | |
1038 | # --- Initialize Perl Binary Locations | |
1039 | ||
1040 | # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL' | |
75f92628 AD |
1041 | # will be working versions of perl 5. miniperl has priority over perl |
1042 | # for PERL to ensure that $(PERL) is usable while building ./ext/* | |
8e07c86e | 1043 | my ($component,@defpath); |
4e68a208 | 1044 | foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) { |
8e07c86e AD |
1045 | push @defpath, $component if defined $component; |
1046 | } | |
864a5fa8 | 1047 | $self->{PERL} = |
8e07c86e AD |
1048 | $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ], |
1049 | \@defpath, $ExtUtils::MakeMaker::Verbose ) unless ($self->{PERL}); | |
1050 | # don't check, if perl is executable, maybe they | |
1051 | # have decided to supply switches with perl | |
a0d0e21e | 1052 | |
42793c05 | 1053 | # Define 'FULLPERL' to be a non-miniperl (used in test: target) |
8e07c86e AD |
1054 | ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i |
1055 | unless ($self->{FULLPERL}); | |
75f92628 | 1056 | } |
42793c05 | 1057 | |
4e68a208 AD |
1058 | # Ilya's suggestion, will have to go into ExtUtils::MM_OS2 and MM_VMS |
1059 | sub path { | |
1060 | my($self) = @_; | |
1061 | my $path_sep = $Is_OS2 ? ";" : $Is_VMS ? "/" : ":"; | |
1062 | my $path = $ENV{PATH}; | |
1063 | $path =~ s:\\:/:g if $Is_OS2; | |
1064 | my @path = split $path_sep, $path; | |
1065 | } | |
1066 | ||
f06db76b | 1067 | sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) |
8e07c86e AD |
1068 | my($self) = @_; |
1069 | unless (ref $self){ | |
1070 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1071 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1072 | } | |
1073 | my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods); | |
75f92628 AD |
1074 | local(%pm); #the sub in find() has to see this hash |
1075 | $ignore{'test.pl'} = 1; | |
1076 | $ignore{'makefile.pl'} = 1 if $Is_VMS; | |
8e07c86e | 1077 | foreach $name ($self->lsdir(".")){ |
75f92628 AD |
1078 | next if ($name =~ /^\./ or $ignore{$name}); |
1079 | if (-d $name){ | |
1080 | $dir{$name} = $name if (-f "$name/Makefile.PL"); | |
1081 | } elsif ($name =~ /\.xs$/){ | |
1082 | my($c); ($c = $name) =~ s/\.xs$/.c/; | |
1083 | $xs{$name} = $c; | |
1084 | $c{$c} = 1; | |
864a5fa8 | 1085 | } elsif ($name =~ /\.c$/i){ |
e50aee73 AD |
1086 | $c{$name} = 1 |
1087 | unless $name =~ m/perlmain\.c/; # See MAP_TARGET | |
864a5fa8 | 1088 | } elsif ($name =~ /\.h$/i){ |
75f92628 | 1089 | $h{$name} = 1; |
f06db76b | 1090 | } elsif ($name =~ /\.(p[ml]|pod)$/){ |
c07a80fd | 1091 | $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name); |
232e078e AD |
1092 | } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") { |
1093 | ($pl_files{$name} = $name) =~ s/\.PL$// ; | |
0d8023a2 | 1094 | } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' && |
1095 | $name ne 'test.pl') { # case-insensitive filesystem | |
1096 | ($pl_files{$name} = $name) =~ s/\.pl$// ; | |
3edbfbe5 | 1097 | } |
75f92628 | 1098 | } |
3edbfbe5 | 1099 | |
75f92628 AD |
1100 | # Some larger extensions often wish to install a number of *.pm/pl |
1101 | # files into the library in various locations. | |
1102 | ||
1103 | # The attribute PMLIBDIRS holds an array reference which lists | |
1104 | # subdirectories which we should search for library files to | |
864a5fa8 AD |
1105 | # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We |
1106 | # recursively search through the named directories (skipping any | |
1107 | # which don't exist or contain Makefile.PL files). | |
75f92628 | 1108 | |
8e07c86e AD |
1109 | # For each *.pm or *.pl file found $self->libscan() is called with |
1110 | # the default installation path in $_[1]. The return value of | |
1111 | # libscan defines the actual installation location. The default | |
1112 | # libscan function simply returns the path. The file is skipped | |
1113 | # if libscan returns false. | |
75f92628 | 1114 | |
8e07c86e | 1115 | # The default installation location passed to libscan in $_[1] is: |
75f92628 AD |
1116 | # |
1117 | # ./*.pm => $(INST_LIBDIR)/*.pm | |
1118 | # ./xyz/... => $(INST_LIBDIR)/xyz/... | |
1119 | # ./lib/... => $(INST_LIB)/... | |
1120 | # | |
1121 | # In this way the 'lib' directory is seen as the root of the actual | |
1122 | # perl library whereas the others are relative to INST_LIBDIR | |
1123 | # (which includes ROOTEXT). This is a subtle distinction but one | |
1124 | # that's important for nested modules. | |
1125 | ||
864a5fa8 AD |
1126 | $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}] |
1127 | unless $self->{PMLIBDIRS}; | |
75f92628 AD |
1128 | |
1129 | #only existing directories that aren't in $dir are allowed | |
75f92628 | 1130 | |
8e07c86e AD |
1131 | # Avoid $_ wherever possible: |
1132 | # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}}; | |
1133 | my (@pmlibdirs) = @{$self->{PMLIBDIRS}}; | |
1134 | my ($pmlibdir); | |
1135 | @{$self->{PMLIBDIRS}} = (); | |
1136 | foreach $pmlibdir (@pmlibdirs) { | |
1137 | -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir; | |
1138 | } | |
1139 | ||
1140 | if (@{$self->{PMLIBDIRS}}){ | |
1141 | print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n" | |
1142 | if ($ExtUtils::MakeMaker::Verbose >= 2); | |
75f92628 AD |
1143 | use File::Find; # try changing to require ! |
1144 | File::Find::find(sub { | |
8e07c86e AD |
1145 | if (-d $_){ |
1146 | if ($_ eq "CVS" || $_ eq "RCS"){ | |
1147 | $File::Find::prune = 1; | |
1148 | } | |
1149 | return; | |
1150 | } | |
1151 | my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)'); | |
0d8023a2 | 1152 | my($striplibpath,$striplibname); |
1153 | $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:); | |
1154 | ($striplibname,$striplibpath) = fileparse($striplibpath); | |
c07a80fd | 1155 | my($inst) = $self->catfile($prefix,$striplibpath,$striplibname); |
8e07c86e AD |
1156 | local($_) = $inst; # for backwards compatibility |
1157 | $inst = $self->libscan($inst); | |
1158 | print "libscan($path) => '$inst'\n" if ($ExtUtils::MakeMaker::Verbose >= 2); | |
1159 | return unless $inst; | |
1160 | $pm{$path} = $inst; | |
1161 | }, @{$self->{PMLIBDIRS}}); | |
1162 | } | |
1163 | ||
1164 | $self->{DIR} = [sort keys %dir] unless $self->{DIR}; | |
1165 | $self->{XS} = \%xs unless $self->{XS}; | |
1166 | $self->{PM} = \%pm unless $self->{PM}; | |
1167 | $self->{C} = [sort keys %c] unless $self->{C}; | |
1168 | my(@o_files) = @{$self->{C}}; | |
864a5fa8 | 1169 | $self->{O_FILES} = [grep s/\.c$/$self->{OBJ_EXT}/i, @o_files] ; |
8e07c86e AD |
1170 | $self->{H} = [sort keys %h] unless $self->{H}; |
1171 | $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES}; | |
864a5fa8 | 1172 | |
8e07c86e | 1173 | # Set up names of manual pages to generate from pods |
864a5fa8 AD |
1174 | if ($self->{MAN1PODS}) { |
1175 | } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) { | |
1176 | $self->{MAN1PODS} = {}; | |
1177 | } else { | |
1178 | my %manifypods = (); | |
0d8023a2 | 1179 | if ( exists $self->{EXE_FILES} ) { |
1180 | foreach $name (@{$self->{EXE_FILES}}) { | |
1181 | local(*TESTPOD); | |
1182 | my($ispod)=0; | |
1183 | # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?) | |
1184 | if (open(TESTPOD,"<$name")) { | |
1185 | my $testpodline; | |
1186 | while ($testpodline = <TESTPOD>) { | |
1187 | if($testpodline =~ /^=head1\s+\w+/) { | |
1188 | $ispod=1; | |
1189 | last; | |
cb1a09d0 | 1190 | } |
864a5fa8 | 1191 | } |
0d8023a2 | 1192 | close(TESTPOD); |
1193 | } else { | |
1194 | # If it doesn't exist yet, we assume, it has pods in it | |
1195 | $ispod = 1; | |
864a5fa8 | 1196 | } |
0d8023a2 | 1197 | if( $ispod ) { |
1198 | $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)'); | |
1199 | } | |
1200 | } | |
864a5fa8 | 1201 | } |
864a5fa8 AD |
1202 | $self->{MAN1PODS} = \%manifypods; |
1203 | } | |
1204 | if ($self->{MAN3PODS}) { | |
8e07c86e | 1205 | } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) { |
864a5fa8 | 1206 | $self->{MAN3PODS} = {}; |
8e07c86e AD |
1207 | } else { |
1208 | my %manifypods = (); # we collect the keys first, i.e. the files | |
1209 | # we have to convert to pod | |
1210 | foreach $name (keys %{$self->{PM}}) { | |
1211 | if ($name =~ /\.pod$/ ) { | |
1212 | $manifypods{$name} = $self->{PM}{$name}; | |
1213 | } elsif ($name =~ /\.p[ml]$/ ) { | |
1214 | local(*TESTPOD); | |
1215 | my($ispod)=0; | |
1216 | open(TESTPOD,"<$name"); | |
1217 | my $testpodline; | |
1218 | while ($testpodline = <TESTPOD>) { | |
1219 | if($testpodline =~ /^=head/) { | |
1220 | $ispod=1; | |
1221 | last; | |
1222 | } | |
1223 | #Speculation on the future (K.A., not A.K. :) | |
1224 | #if(/^=don't\S+install/) { $ispod=0; last} | |
1225 | } | |
1226 | close(TESTPOD); | |
1227 | ||
1228 | if( $ispod ) { | |
1229 | $manifypods{$name} = $self->{PM}{$name}; | |
1230 | } | |
1231 | } | |
1232 | } | |
1233 | ||
1234 | # Remove "Configure.pm" and similar, if it's not the only pod listed | |
864a5fa8 | 1235 | # To force inclusion, just name it "Configure.pod", or override MAN3PODS |
8e07c86e AD |
1236 | foreach $name (keys %manifypods) { |
1237 | if ($name =~ /(config|install|setup).*\.pm/i) { | |
1238 | delete $manifypods{$name}; | |
1239 | next; | |
1240 | } | |
1241 | my($manpagename) = $name; | |
0d8023a2 | 1242 | unless ($manpagename =~ s!^(\W*)lib\W!$1!) { |
1243 | $manpagename = $self->catfile($self->{ROOTEXT},$manpagename); | |
8e07c86e AD |
1244 | } |
1245 | $manpagename =~ s/\.p(od|m|l)$//; | |
1246 | # Strip leading slashes | |
1247 | $manpagename =~ s!^/+!!; | |
1248 | # Turn other slashes into colons | |
1249 | # $manpagename =~ s,/+,::,g; | |
0d8023a2 | 1250 | $manpagename = $self->replace_manpage_separator($manpagename); |
1251 | $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)"); | |
8e07c86e | 1252 | } |
864a5fa8 | 1253 | $self->{MAN3PODS} = \%manifypods; |
8e07c86e AD |
1254 | } |
1255 | } | |
1256 | ||
1257 | sub lsdir { | |
1258 | my($self) = shift; | |
1259 | my($dir, $regex) = @_; | |
1260 | local(*DIR, @ls); | |
1261 | opendir(DIR, $dir || ".") or return (); | |
1262 | @ls = readdir(DIR); | |
1263 | closedir(DIR); | |
1264 | @ls = grep(/$regex/, @ls) if $regex; | |
1265 | @ls; | |
75f92628 AD |
1266 | } |
1267 | ||
0d8023a2 | 1268 | sub replace_manpage_separator { |
8e07c86e AD |
1269 | my($self,$man) = @_; |
1270 | $man =~ s,/+,::,g; | |
1271 | $man; | |
1272 | } | |
75f92628 AD |
1273 | |
1274 | sub libscan { | |
8e07c86e | 1275 | my($self,$path) = @_; |
0d8023a2 | 1276 | return '' if $path =~ m:/(RCS|SCCS)/: ; |
8e07c86e | 1277 | $path; |
75f92628 AD |
1278 | } |
1279 | ||
75f92628 | 1280 | sub init_others { # --- Initialize Other Attributes |
8e07c86e AD |
1281 | my($self) = shift; |
1282 | unless (ref $self){ | |
1283 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1284 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
a0d0e21e LW |
1285 | } |
1286 | ||
8e07c86e AD |
1287 | # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS} |
1288 | # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or | |
42793c05 | 1289 | # undefined. In any case we turn it into an anon array: |
cb1a09d0 AD |
1290 | |
1291 | # May check $Config{libs} too, thus not empty. | |
1292 | $self->{LIBS}=[''] unless $self->{LIBS}; | |
1293 | ||
8e07c86e AD |
1294 | $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq SCALAR; |
1295 | $self->{LD_RUN_PATH} = ""; | |
1296 | my($libs); | |
1297 | foreach $libs ( @{$self->{LIBS}} ){ | |
1298 | $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace | |
1299 | my(@libs) = $self->extliblist($libs); | |
42793c05 | 1300 | if ($libs[0] or $libs[1] or $libs[2]){ |
4633a7c4 LW |
1301 | # LD_RUN_PATH now computed by ExtUtils::Liblist |
1302 | ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs; | |
42793c05 TB |
1303 | last; |
1304 | } | |
1305 | } | |
a0d0e21e | 1306 | |
8e07c86e AD |
1307 | unless ( $self->{OBJECT} ){ |
1308 | # init_dirscan should have found out, if we have C files | |
4633a7c4 | 1309 | $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]}; |
a0d0e21e | 1310 | } |
8e07c86e AD |
1311 | $self->{OBJECT} =~ s/\n+/ \\\n\t/g; |
1312 | $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : ""; | |
4633a7c4 | 1313 | $self->{PERLMAINCC} ||= '$(CC)'; |
8e07c86e AD |
1314 | $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM}; |
1315 | ||
1aef975c AD |
1316 | # Sanity check: don't define LINKTYPE = dynamic if we're skipping |
1317 | # the 'dynamic' section of MM. We don't have this problem with | |
1318 | # 'static', since we either must use it (%Config says we can't | |
1319 | # use dynamic loading) or the caller asked for it explicitly. | |
8e07c86e AD |
1320 | if (!$self->{LINKTYPE}) { |
1321 | $self->{LINKTYPE} = grep(/dynamic/,@{$self->{SKIP} || []}) | |
1aef975c | 1322 | ? 'static' |
8e07c86e | 1323 | : ($Config::Config{usedl} ? 'dynamic' : 'static'); |
1aef975c | 1324 | }; |
42793c05 | 1325 | |
3edbfbe5 | 1326 | # These get overridden for VMS and maybe some other systems |
0d8023a2 | 1327 | $self->{NOOP} ||= ""; |
4633a7c4 LW |
1328 | $self->{FIRST_MAKEFILE} ||= "Makefile"; |
1329 | $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE}; | |
1330 | $self->{MAKE_APERL_FILE} ||= "Makefile.aperl"; | |
0d8023a2 | 1331 | $self->{NOECHO} ||= '@'; |
1332 | $self->{RM_F} ||= "rm -f"; | |
1333 | $self->{RM_RF} ||= "rm -rf"; | |
1334 | $self->{TOUCH} ||= "touch"; | |
1335 | $self->{CP} ||= "cp"; | |
1336 | $self->{MV} ||= "mv"; | |
1337 | $self->{CHMOD} ||= "chmod"; | |
1338 | $self->{UMASK_NULL} ||= "umask 0"; | |
42793c05 TB |
1339 | } |
1340 | ||
cb1a09d0 | 1341 | sub find_perl { |
42793c05 | 1342 | my($self, $ver, $names, $dirs, $trace) = @_; |
8e07c86e AD |
1343 | unless (ref $self){ |
1344 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1345 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1346 | } | |
42793c05 | 1347 | my($name, $dir); |
5d94fbed | 1348 | if ($trace >= 2){ |
8e07c86e AD |
1349 | print "Looking for perl $ver by these names: |
1350 | @$names | |
1351 | in these dirs: | |
1352 | @$dirs | |
1353 | "; | |
fed7345c | 1354 | } |
42793c05 | 1355 | foreach $dir (@$dirs){ |
8e07c86e | 1356 | next unless defined $dir; # $self->{PERL_SRC} may be undefined |
42793c05 | 1357 | foreach $name (@$names){ |
8e07c86e | 1358 | my $abs; |
cb1a09d0 | 1359 | if ($self->file_name_is_absolute($name)) { |
8e07c86e | 1360 | $abs = $name; |
0d8023a2 | 1361 | } elsif (($name =~ m|/|) && ($name !~ m|^\.{1,2}/|)) { |
1362 | # name is a path that does not begin with dot or dotdot | |
cb1a09d0 | 1363 | $abs = $self->catfile(".", $name); |
42793c05 | 1364 | } else { |
8e07c86e | 1365 | $abs = $self->catfile($dir, $name); |
42793c05 | 1366 | } |
8e07c86e | 1367 | print "Checking $abs\n" if ($trace >= 2); |
4633a7c4 | 1368 | next unless $self->maybe_command($abs); |
8e07c86e AD |
1369 | print "Executing $abs\n" if ($trace >= 2); |
1370 | if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) { | |
1371 | print "Using PERL=$abs\n" if $trace; | |
1372 | return $abs; | |
5d94fbed | 1373 | } |
a0d0e21e LW |
1374 | } |
1375 | } | |
fed7345c | 1376 | print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n"; |
42793c05 | 1377 | 0; # false and not empty |
a0d0e21e LW |
1378 | } |
1379 | ||
4e68a208 AD |
1380 | |
1381 | # Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here | |
1382 | sub maybe_command_in_dirs { # $ver is optional argument if looking for perl | |
1383 | my($self, $names, $dirs, $trace, $ver) = @_; | |
1384 | my($name, $dir); | |
1385 | foreach $dir (@$dirs){ | |
1386 | next unless defined $dir; # $self->{PERL_SRC} may be undefined | |
1387 | foreach $name (@$names){ | |
1388 | my($abs,$tryabs); | |
1389 | if ($self->file_name_is_absolute($name)) { | |
1390 | $abs = $name; | |
1391 | } elsif ($name =~ m|/|) { | |
1392 | $abs = $self->catfile(".", $name); # not absolute | |
1393 | } else { | |
1394 | $abs = $self->catfile($dir, $name); | |
1395 | } | |
1396 | print "Checking $abs for $name\n" if ($trace >= 2); | |
1397 | next unless $tryabs = $self->maybe_command($abs); | |
1398 | print "Substituting $tryabs instead of $abs\n" | |
1399 | if ($trace >= 2 and $tryabs ne $abs); | |
1400 | $abs = $tryabs; | |
1401 | if (defined $ver) { | |
1402 | print "Executing $abs\n" if ($trace >= 2); | |
1403 | if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) { | |
1404 | print "Using PERL=$abs\n" if $trace; | |
1405 | return $abs; | |
1406 | } | |
1407 | } else { # Do not look for perl | |
1408 | return $abs; | |
1409 | } | |
1410 | } | |
1411 | } | |
1412 | } | |
1413 | ||
4633a7c4 LW |
1414 | sub maybe_command { |
1415 | my($self,$file) = @_; | |
4e68a208 | 1416 | return $file if -x $file && ! -d $file; |
4633a7c4 LW |
1417 | return; |
1418 | } | |
1419 | ||
cb1a09d0 AD |
1420 | sub perl_script { |
1421 | my($self,$file) = @_; | |
1422 | return 1 if -r $file && ! -d $file; | |
1423 | return; | |
1424 | } | |
1425 | ||
4e68a208 AD |
1426 | # Ilya's suggestion, not yet used |
1427 | sub file_name_is_absolute { | |
1428 | my($self,$file) = @_; | |
1429 | $file =~ m:^/: ; | |
1430 | } | |
1431 | ||
8e07c86e AD |
1432 | sub post_initialize { |
1433 | my($self) = shift; | |
1434 | unless (ref $self){ | |
1435 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1436 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1437 | } | |
a0d0e21e LW |
1438 | ""; |
1439 | } | |
fed7345c | 1440 | |
8e07c86e AD |
1441 | # --- Constants Sections --- |
1442 | ||
1443 | sub const_config { | |
1444 | my($self) = shift; | |
1445 | unless (ref $self){ | |
1446 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1447 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1448 | } | |
1449 | my(@m,$m); | |
1450 | push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n"); | |
864a5fa8 | 1451 | push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n"); |
8e07c86e AD |
1452 | my(%once_only); |
1453 | foreach $m (@{$self->{CONFIG}}){ | |
1454 | next if $once_only{$m}; | |
864a5fa8 | 1455 | push @m, "\U$m\E = ".$self->{uc $m}."\n"; |
8e07c86e AD |
1456 | $once_only{$m} = 1; |
1457 | } | |
1458 | join('', @m); | |
005c1a0e | 1459 | } |
a0d0e21e LW |
1460 | |
1461 | sub constants { | |
005c1a0e | 1462 | my($self) = @_; |
8e07c86e AD |
1463 | unless (ref $self){ |
1464 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1465 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1466 | } | |
8e07c86e | 1467 | my(@m,$tmp); |
a0d0e21e | 1468 | |
a0d0e21e | 1469 | push @m, " |
8e07c86e AD |
1470 | NAME = $self->{NAME} |
1471 | DISTNAME = $self->{DISTNAME} | |
1472 | NAME_SYM = $self->{NAME_SYM} | |
1473 | VERSION = $self->{VERSION} | |
1474 | VERSION_SYM = $self->{VERSION_SYM} | |
1475 | VERSION_MACRO = VERSION | |
1476 | DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\" | |
0d8023a2 | 1477 | XS_VERSION = $self->{XS_VERSION} |
1478 | XS_VERSION_MACRO = XS_VERSION | |
1479 | XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\" | |
a0d0e21e | 1480 | |
005c1a0e AD |
1481 | # In which directory should we put this extension during 'make'? |
1482 | # This is typically ./blib. | |
42793c05 | 1483 | # (also see INST_LIBDIR and relationship to ROOTEXT) |
8e07c86e AD |
1484 | INST_LIB = $self->{INST_LIB} |
1485 | INST_ARCHLIB = $self->{INST_ARCHLIB} | |
1486 | INST_EXE = $self->{INST_EXE} | |
42793c05 | 1487 | |
0d8023a2 | 1488 | PREFIX = $self->{PREFIX} |
1489 | ||
005c1a0e AD |
1490 | # AFS users will want to set the installation directories for |
1491 | # the final 'make install' early without setting INST_LIB, | |
1492 | # INST_ARCHLIB, and INST_EXE for the testing phase | |
8e07c86e AD |
1493 | INSTALLPRIVLIB = $self->{INSTALLPRIVLIB} |
1494 | INSTALLARCHLIB = $self->{INSTALLARCHLIB} | |
1495 | INSTALLBIN = $self->{INSTALLBIN} | |
005c1a0e | 1496 | |
42793c05 | 1497 | # Perl library to use when building the extension |
8e07c86e AD |
1498 | PERL_LIB = $self->{PERL_LIB} |
1499 | PERL_ARCHLIB = $self->{PERL_ARCHLIB} | |
1500 | LIBPERL_A = $self->{LIBPERL_A} | |
005c1a0e AD |
1501 | |
1502 | MAKEMAKER = \$(PERL_LIB)/ExtUtils/MakeMaker.pm | |
8e07c86e | 1503 | MM_VERSION = $ExtUtils::MakeMaker::VERSION |
4633a7c4 LW |
1504 | FIRST_MAKEFILE = $self->{FIRST_MAKEFILE} |
1505 | MAKE_APERL_FILE = $self->{MAKE_APERL_FILE} | |
42793c05 | 1506 | |
4633a7c4 | 1507 | PERLMAINCC = $self->{PERLMAINCC} |
8e07c86e | 1508 | "; |
75f92628 AD |
1509 | |
1510 | push @m, " | |
fed7345c | 1511 | # Where is the perl source code located? |
8e07c86e | 1512 | PERL_SRC = $self->{PERL_SRC}\n" if $self->{PERL_SRC}; |
fed7345c AD |
1513 | |
1514 | push @m, " | |
42793c05 | 1515 | # Perl header files (will eventually be under PERL_LIB) |
8e07c86e | 1516 | PERL_INC = $self->{PERL_INC} |
42793c05 | 1517 | # Perl binaries |
8e07c86e AD |
1518 | PERL = $self->{PERL} |
1519 | FULLPERL = $self->{FULLPERL} | |
75f92628 AD |
1520 | "; |
1521 | push @m, " | |
42793c05 TB |
1522 | # FULLEXT = Pathname for extension directory (eg DBD/Oracle). |
1523 | # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. | |
1524 | # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) | |
8e07c86e AD |
1525 | # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. |
1526 | FULLEXT = $self->{FULLEXT} | |
1527 | BASEEXT = $self->{BASEEXT} | |
1528 | ROOTEXT = $self->{ROOTEXT} | |
1529 | DLBASE = $self->{DLBASE} | |
75f92628 | 1530 | "; |
0d8023a2 | 1531 | |
1532 | push @m, " | |
1533 | VERSION_FROM = $self->{VERSION_FROM} | |
1534 | " if defined $self->{VERSION_FROM}; | |
1535 | ||
75f92628 | 1536 | push @m, " |
8e07c86e AD |
1537 | INC = $self->{INC} |
1538 | DEFINE = $self->{DEFINE} | |
1539 | OBJECT = $self->{OBJECT} | |
1540 | LDFROM = $self->{LDFROM} | |
1541 | LINKTYPE = $self->{LINKTYPE} | |
a0d0e21e | 1542 | |
75f92628 | 1543 | # Handy lists of source code files: |
8e07c86e AD |
1544 | XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})." |
1545 | C_FILES = ".join(" \\\n\t", @{$self->{C}})." | |
1546 | O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})." | |
1547 | H_FILES = ".join(" \\\n\t", @{$self->{H}})." | |
864a5fa8 AD |
1548 | MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})." |
1549 | MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})." | |
a0d0e21e | 1550 | |
8e07c86e AD |
1551 | # Man installation stuff: |
1552 | INST_MAN1DIR = $self->{INST_MAN1DIR} | |
1553 | INSTALLMAN1DIR = $self->{INSTALLMAN1DIR} | |
1554 | MAN1EXT = $self->{MAN1EXT} | |
a0d0e21e | 1555 | |
8e07c86e AD |
1556 | INST_MAN3DIR = $self->{INST_MAN3DIR} |
1557 | INSTALLMAN3DIR = $self->{INSTALLMAN3DIR} | |
1558 | MAN3EXT = $self->{MAN3EXT} | |
1559 | ||
1560 | ||
1561 | # work around a famous dec-osf make(1) feature(?): | |
1562 | makemakerdflt: all | |
42793c05 | 1563 | |
864a5fa8 | 1564 | .SUFFIXES: .xs .c .C \$(OBJ_EXT) |
8e07c86e | 1565 | |
4633a7c4 | 1566 | # .PRECIOUS: Makefile # seems to be not necessary anymore |
005c1a0e | 1567 | |
75f92628 | 1568 | .PHONY: all config static dynamic test linkext |
42793c05 TB |
1569 | |
1570 | # This extension may link to it's own library (see SDBM_File) | |
8e07c86e | 1571 | MYEXTLIB = $self->{MYEXTLIB} |
42793c05 | 1572 | |
75f92628 | 1573 | # Where is the Config information that we are using/depend on |
0d8023a2 | 1574 | CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h \$(VERSION_FROM) |
a0d0e21e LW |
1575 | "; |
1576 | ||
1577 | push @m, ' | |
1578 | # Where to put things: | |
42793c05 TB |
1579 | INST_LIBDIR = $(INST_LIB)$(ROOTEXT) |
1580 | INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT) | |
1581 | ||
3edbfbe5 TB |
1582 | INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) |
1583 | INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) | |
1584 | '; | |
42793c05 | 1585 | |
8e07c86e | 1586 | if ($self->has_link_code()) { |
005c1a0e | 1587 | push @m, ' |
4633a7c4 | 1588 | INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT) |
8e07c86e | 1589 | INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT) |
75f92628 | 1590 | INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs |
005c1a0e AD |
1591 | '; |
1592 | } else { | |
1593 | push @m, ' | |
1594 | INST_STATIC = | |
1595 | INST_DYNAMIC = | |
1596 | INST_BOOT = | |
1597 | '; | |
1598 | } | |
1599 | ||
8e07c86e AD |
1600 | if ($Is_OS2) { |
1601 | $tmp = "$self->{BASEEXT}.def"; | |
1602 | } else { | |
1603 | $tmp = ""; | |
1604 | } | |
1605 | push @m, " | |
1606 | EXPORT_LIST = $tmp | |
1607 | "; | |
864a5fa8 | 1608 | |
8e07c86e AD |
1609 | if ($Is_OS2) { |
1610 | $tmp = "\$(PERL_INC)/libperl.lib"; | |
1611 | } else { | |
1612 | $tmp = ""; | |
1613 | } | |
1614 | push @m, " | |
1615 | PERL_ARCHIVE = $tmp | |
1616 | "; | |
1617 | ||
005c1a0e | 1618 | push @m, ' |
8e07c86e | 1619 | INST_PM = '.join(" \\\n\t", sort values %{$self->{PM}}).' |
42793c05 TB |
1620 | '; |
1621 | ||
1622 | join('',@m); | |
1623 | } | |
1624 | ||
8e07c86e AD |
1625 | sub const_loadlibs { |
1626 | my($self) = shift; | |
1627 | unless (ref $self){ | |
1628 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1629 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1630 | } | |
1631 | return "" unless $self->needs_linking; | |
864a5fa8 AD |
1632 | # This description can be deleted after ExtUtils::Liblist is in |
1633 | # the perl dist with pods | |
8e07c86e AD |
1634 | " |
1635 | # $self->{NAME} might depend on some other libraries: | |
1636 | # (These comments may need revising:) | |
1637 | # | |
1638 | # Dependent libraries can be linked in one of three ways: | |
1639 | # | |
1640 | # 1. (For static extensions) by the ld command when the perl binary | |
1641 | # is linked with the extension library. See EXTRALIBS below. | |
1642 | # | |
1643 | # 2. (For dynamic extensions) by the ld command when the shared | |
1644 | # object is built/linked. See LDLOADLIBS below. | |
1645 | # | |
1646 | # 3. (For dynamic extensions) by the DynaLoader when the shared | |
1647 | # object is loaded. See BSLOADLIBS below. | |
1648 | # | |
1649 | # EXTRALIBS = List of libraries that need to be linked with when | |
1650 | # linking a perl binary which includes this extension | |
1651 | # Only those libraries that actually exist are included. | |
1652 | # These are written to a file and used when linking perl. | |
1653 | # | |
1654 | # LDLOADLIBS = List of those libraries which can or must be linked into | |
1655 | # the shared library when created using ld. These may be | |
1656 | # static or dynamic libraries. | |
1657 | # LD_RUN_PATH is a colon separated list of the directories | |
1658 | # in LDLOADLIBS. It is passed as an environment variable to | |
1659 | # the process that links the shared library. | |
1660 | # | |
1661 | # BSLOADLIBS = List of those libraries that are needed but can be | |
1662 | # linked in dynamically at run time on this platform. | |
1663 | # SunOS/Solaris does not need this because ld records | |
1664 | # the information (from LDLOADLIBS) into the object file. | |
1665 | # This list is used to create a .bs (bootstrap) file. | |
1666 | # | |
1667 | EXTRALIBS = $self->{EXTRALIBS} | |
1668 | LDLOADLIBS = $self->{LDLOADLIBS} | |
1669 | BSLOADLIBS = $self->{BSLOADLIBS} | |
1670 | LD_RUN_PATH= $self->{LD_RUN_PATH} | |
1671 | "; | |
1672 | } | |
42793c05 | 1673 | |
8e07c86e | 1674 | sub const_cccmd { |
40000a8c | 1675 | my($self,$libperl)=@_; |
8e07c86e AD |
1676 | unless (ref $self){ |
1677 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1678 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1679 | } | |
1680 | return $self->{CONST_CCCMD} if $self->{CONST_CCCMD}; | |
1681 | return '' unless $self->needs_linking(); | |
4633a7c4 LW |
1682 | $libperl or $libperl = $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ; |
1683 | $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/; | |
75f92628 AD |
1684 | # This is implemented in the same manner as extliblist, |
1685 | # e.g., do both and compare results during the transition period. | |
1686 | my($cc,$ccflags,$optimize,$large,$split, $shflags) | |
1687 | = @Config{qw(cc ccflags optimize large split shellflags)}; | |
8e07c86e | 1688 | my($optdebug) = ""; |
232e078e | 1689 | |
75f92628 | 1690 | $shflags = '' unless $shflags; |
864a5fa8 | 1691 | my($prog, $uc, $perltype); |
e1666bf5 | 1692 | |
40000a8c AD |
1693 | my(%map) = ( |
1694 | D => '-DDEBUGGING', | |
1695 | E => '-DEMBED', | |
1696 | DE => '-DDEBUGGING -DEMBED', | |
1697 | M => '-DEMBED -DMULTIPLICITY', | |
1698 | DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY', | |
1699 | ); | |
1700 | ||
4633a7c4 | 1701 | if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){ |
40000a8c AD |
1702 | $uc = uc($1); |
1703 | } else { | |
1704 | $uc = ""; # avoid warning | |
1705 | } | |
1706 | $perltype = $map{$uc} ? $map{$uc} : ""; | |
1707 | ||
1708 | if ($uc =~ /^D/) { | |
1709 | $optdebug = "-g"; | |
1710 | } | |
1711 | ||
1712 | ||
1aef975c | 1713 | my($name); |
8e07c86e AD |
1714 | ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ; |
1715 | if ($prog = $Config::Config{$name}) { | |
75f92628 | 1716 | # Expand hints for this extension via the shell |
8e07c86e | 1717 | print STDOUT "Processing $name hint:\n" if $ExtUtils::MakeMaker::Verbose; |
75f92628 AD |
1718 | my(@o)=`cc=\"$cc\" |
1719 | ccflags=\"$ccflags\" | |
1720 | optimize=\"$optimize\" | |
40000a8c AD |
1721 | perltype=\"$perltype\" |
1722 | optdebug=\"$optdebug\" | |
75f92628 AD |
1723 | large=\"$large\" |
1724 | split=\"$split\" | |
1725 | eval '$prog' | |
1726 | echo cc=\$cc | |
1727 | echo ccflags=\$ccflags | |
1728 | echo optimize=\$optimize | |
40000a8c AD |
1729 | echo perltype=\$perltype |
1730 | echo optdebug=\$optdebug | |
75f92628 AD |
1731 | echo large=\$large |
1732 | echo split=\$split | |
1733 | `; | |
232e078e | 1734 | my(%cflags,$line); |
75f92628 AD |
1735 | foreach $line (@o){ |
1736 | chomp $line; | |
1737 | if ($line =~ /(.*?)=\s*(.*)\s*$/){ | |
1738 | $cflags{$1} = $2; | |
8e07c86e | 1739 | print STDOUT " $1 = $2\n" if $ExtUtils::MakeMaker::Verbose; |
75f92628 | 1740 | } else { |
fed7345c | 1741 | print STDOUT "Unrecognised result from hint: '$line'\n"; |
75f92628 AD |
1742 | } |
1743 | } | |
40000a8c AD |
1744 | ( $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split )=@cflags{ |
1745 | qw( cc ccflags perltype optdebug optimize large split)}; | |
1746 | } | |
1747 | ||
1748 | if ($optdebug) { | |
1749 | $optimize = $optdebug; | |
75f92628 AD |
1750 | } |
1751 | ||
4633a7c4 | 1752 | my($new) = "$cc -c \$(INC) $ccflags $optimize $perltype $large $split"; |
005c1a0e | 1753 | $new =~ s/^\s+//; $new =~ s/\s+/ /g; $new =~ s/\s+$//; |
864a5fa8 AD |
1754 | |
1755 | my($cccmd) = $new; | |
8e07c86e | 1756 | $cccmd =~ s/^\s*\Q$Config::Config{cc}\E\s/\$(CC) /; |
4e68a208 | 1757 | $cccmd .= " \$(DEFINE_VERSION) \$(XS_DEFINE_VERSION)"; |
8e07c86e | 1758 | $self->{CONST_CCCMD} = "CCCMD = $cccmd\n"; |
42793c05 | 1759 | } |
a0d0e21e | 1760 | |
42793c05 | 1761 | # --- Tool Sections --- |
a0d0e21e | 1762 | |
8e07c86e | 1763 | sub tool_autosplit { |
42793c05 | 1764 | my($self, %attribs) = @_; |
8e07c86e AD |
1765 | unless (ref $self){ |
1766 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1767 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1768 | } | |
42793c05 TB |
1769 | my($asl) = ""; |
1770 | $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN}; | |
1771 | q{ | |
42793c05 | 1772 | # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto |
005c1a0e | 1773 | AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;' |
42793c05 TB |
1774 | }; |
1775 | } | |
a0d0e21e | 1776 | |
8e07c86e AD |
1777 | sub tool_xsubpp { |
1778 | my($self) = shift; | |
1779 | unless (ref $self){ | |
1780 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1781 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1782 | } | |
864a5fa8 | 1783 | my($xsdir) = "$self->{PERL_LIB}/ExtUtils"; |
e1666bf5 | 1784 | # drop back to old location if xsubpp is not in new location yet |
864a5fa8 | 1785 | $xsdir = "$self->{PERL_SRC}/ext" unless (-f "$self->{PERL_LIB}/ExtUtils/xsubpp"); |
e1666bf5 | 1786 | my(@tmdeps) = ('$(XSUBPPDIR)/typemap'); |
8e07c86e AD |
1787 | if( $self->{TYPEMAPS} ){ |
1788 | my $typemap; | |
1789 | foreach $typemap (@{$self->{TYPEMAPS}}){ | |
1790 | if( ! -f $typemap ){ | |
1791 | warn "Typemap $typemap not found.\n"; | |
1792 | } | |
1793 | else{ | |
1794 | push(@tmdeps, $typemap); | |
1795 | } | |
1796 | } | |
1797 | } | |
42793c05 TB |
1798 | push(@tmdeps, "typemap") if -f "typemap"; |
1799 | my(@tmargs) = map("-typemap $_", @tmdeps); | |
4633a7c4 | 1800 | if( exists $self->{XSOPT} ){ |
864a5fa8 AD |
1801 | unshift( @tmargs, $self->{XSOPT} ); |
1802 | } | |
1803 | ||
1804 | my $xsubpp_version = $self->xsubpp_version("$xsdir/xsubpp"); | |
1805 | ||
1806 | # What are the correct thresholds for version 1 && 2 Paul? | |
1807 | if ( $xsubpp_version > 1.923 ){ | |
4e68a208 | 1808 | $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG}; |
864a5fa8 AD |
1809 | } else { |
1810 | if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) { | |
1811 | print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp. | |
1812 | Your version of xsubpp is $xsubpp_version and cannot handle this. | |
1813 | Please upgrade to a more recent version of xsubpp. | |
1814 | }; | |
1815 | } else { | |
1816 | $self->{XSPROTOARG} = ""; | |
1817 | } | |
4633a7c4 | 1818 | } |
864a5fa8 | 1819 | |
42793c05 | 1820 | " |
e1666bf5 TB |
1821 | XSUBPPDIR = $xsdir |
1822 | XSUBPP = \$(XSUBPPDIR)/xsubpp | |
864a5fa8 | 1823 | XSPROTOARG = $self->{XSPROTOARG} |
42793c05 TB |
1824 | XSUBPPDEPS = @tmdeps |
1825 | XSUBPPARGS = @tmargs | |
1826 | "; | |
1827 | }; | |
a0d0e21e | 1828 | |
864a5fa8 AD |
1829 | sub xsubpp_version |
1830 | { | |
1831 | my($self,$xsubpp) = @_; | |
1832 | my ($version) ; | |
1833 | ||
1834 | # try to figure out the version number of the xsubpp on the system | |
1835 | ||
1836 | # first try the -v flag, introduced in 1.921 & 2.000a2 | |
1837 | ||
1838 | my $command = "$self->{PERL} $xsubpp -v 2>&1"; | |
1839 | print "Running: $command\n" if $Verbose; | |
1840 | $version = `$command` ; | |
4e68a208 | 1841 | warn "Running '$command' exits with status " . ($?>>8) if $?; |
864a5fa8 AD |
1842 | chop $version ; |
1843 | ||
1844 | return $1 if $version =~ /^xsubpp version (.*)/ ; | |
1845 | ||
1846 | # nope, then try something else | |
1847 | ||
1848 | my $counter = '000'; | |
1849 | my ($file) = 'temp' ; | |
1850 | $counter++ while -e "$file$counter"; # don't overwrite anything | |
1851 | $file .= $counter; | |
1852 | ||
1853 | open(F, ">$file") or die "Cannot open file '$file': $!\n" ; | |
1854 | print F <<EOM ; | |
1855 | MODULE = fred PACKAGE = fred | |
1856 | ||
1857 | int | |
1858 | fred(a) | |
1859 | int a; | |
1860 | EOM | |
1861 | ||
1862 | close F ; | |
1863 | ||
1864 | $command = "$self->{PERL} $xsubpp $file 2>&1"; | |
1865 | print "Running: $command\n" if $Verbose; | |
1866 | my $text = `$command` ; | |
4e68a208 | 1867 | warn "Running '$command' exits with status " . ($?>>8) if $?; |
864a5fa8 AD |
1868 | unlink $file ; |
1869 | ||
1870 | # gets 1.2 -> 1.92 and 2.000a1 | |
1871 | return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ; | |
1872 | ||
1873 | # it is either 1.0 or 1.1 | |
1874 | return 1.1 if $text =~ /^Warning: ignored semicolon/ ; | |
1875 | ||
1876 | # none of the above, so 1.0 | |
1877 | return "1.0" ; | |
1878 | } | |
1879 | ||
8e07c86e AD |
1880 | sub tools_other { |
1881 | my($self) = shift; | |
1882 | unless (ref $self){ | |
1883 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1884 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1885 | } | |
e1666bf5 | 1886 | " |
42793c05 | 1887 | SHELL = /bin/sh |
8e07c86e AD |
1888 | LD = $self->{LD} |
1889 | TOUCH = $self->{TOUCH} | |
1890 | CP = $self->{CP} | |
1891 | MV = $self->{MV} | |
1892 | RM_F = $self->{RM_F} | |
1893 | RM_RF = $self->{RM_RF} | |
1894 | CHMOD = $self->{CHMOD} | |
1895 | UMASK_NULL = $self->{UMASK_NULL} | |
e1666bf5 | 1896 | ".q{ |
42793c05 | 1897 | # The following is a portable way to say mkdir -p |
8e07c86e AD |
1898 | # To see which directories are created, change the if 0 to if 1 |
1899 | MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){' \\ | |
1900 | -e 'next if -d $$p; my(@p); foreach(split(/\//,$$p)){' \\ | |
1901 | -e 'push(@p,$$_); next if -d "@p/"; print "mkdir @p" if 0;' \\ | |
1902 | -e 'mkdir("@p",0777)||die $$! } } exit 0;' | |
c07a80fd | 1903 | |
1904 | # This helps us to minimize the effect of the .exists files A yet | |
1905 | # better solution would be to have a stable file in the perl | |
1906 | # distribution with a timestamp of zero. But this solution doesn't | |
1907 | # need any changes to the core distribution and works with older perls | |
1908 | EQUALIZE_TIMESTAMP = $(PERL) -we 'open F, ">$$ARGV[1]"; close F;' \\ | |
1909 | -e 'utime ((stat("$$ARGV[0]"))[8,9], $$ARGV[1])' | |
42793c05 | 1910 | }; |
a0d0e21e LW |
1911 | } |
1912 | ||
8e07c86e AD |
1913 | sub dist { |
1914 | my($self, %attribs) = @_; | |
1915 | unless (ref $self){ | |
1916 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1917 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1918 | } | |
1919 | my(@m); | |
1920 | # VERSION should be sanitised before use as a file name | |
864a5fa8 AD |
1921 | my($name) = $attribs{NAME} || '$(DISTVNAME)'; |
1922 | my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar | |
1923 | my($tarflags) = $attribs{TARFLAGS} || 'cvf'; | |
1924 | my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip | |
1925 | my($suffix) = $attribs{SUFFIX} || 'Z'; # eg gz | |
1926 | my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip" | |
0d8023a2 | 1927 | my($preop) = $attribs{PREOP} || "$self->{NOECHO}true"; # eg update MANIFEST |
1928 | my($postop) = $attribs{POSTOP} || "$self->{NOECHO}true"; # eg remove the distdir | |
8e07c86e AD |
1929 | my($ci) = $attribs{CI} || 'ci -u'; |
1930 | my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q'; | |
4633a7c4 | 1931 | my($dist_cp) = $attribs{DIST_CP} || 'best'; |
8e07c86e | 1932 | my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist'; |
a0d0e21e | 1933 | |
8e07c86e AD |
1934 | push @m, " |
1935 | DISTVNAME = \$(DISTNAME)-\$(VERSION) | |
1936 | TAR = $tar | |
1937 | TARFLAGS = $tarflags | |
1938 | COMPRESS = $compress | |
1939 | SUFFIX = $suffix | |
1940 | SHAR = $shar | |
1941 | PREOP = $preop | |
1942 | POSTOP = $postop | |
1943 | CI = $ci | |
1944 | RCS_LABEL = $rcs_label | |
1945 | DIST_CP = $dist_cp | |
1946 | DIST_DEFAULT = $dist_default | |
1947 | "; | |
1948 | join "", @m; | |
a0d0e21e LW |
1949 | } |
1950 | ||
005c1a0e AD |
1951 | sub macro { |
1952 | my($self,%attribs) = @_; | |
8e07c86e AD |
1953 | unless (ref $self){ |
1954 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1955 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1956 | } | |
005c1a0e AD |
1957 | my(@m,$key,$val); |
1958 | while (($key,$val) = each %attribs){ | |
1959 | push @m, "$key = $val\n"; | |
1960 | } | |
1961 | join "", @m; | |
1962 | } | |
1963 | ||
c07a80fd | 1964 | sub depend { |
1965 | my($self,%attribs) = @_; | |
1966 | unless (ref $self){ | |
1967 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1968 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1969 | } | |
1970 | my(@m,$key,$val); | |
1971 | while (($key,$val) = each %attribs){ | |
1972 | push @m, "$key: $val\n"; | |
1973 | } | |
1974 | join "", @m; | |
1975 | } | |
1976 | ||
8e07c86e AD |
1977 | sub post_constants{ |
1978 | my($self) = shift; | |
1979 | unless (ref $self){ | |
1980 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1981 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1982 | } | |
1983 | ""; | |
1984 | } | |
1985 | ||
232e078e | 1986 | sub pasthru { |
8e07c86e AD |
1987 | my($self) = shift; |
1988 | unless (ref $self){ | |
1989 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
1990 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
1991 | } | |
005c1a0e | 1992 | my(@m,$key); |
005c1a0e | 1993 | |
4633a7c4 | 1994 | my(@pasthru); |
005c1a0e | 1995 | |
864a5fa8 | 1996 | foreach $key (qw(INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN |
4633a7c4 | 1997 | INSTALLMAN1DIR INSTALLMAN3DIR LIBPERL_A |
c07a80fd | 1998 | LINKTYPE PREFIX)){ |
8e07c86e | 1999 | push @pasthru, "$key=\"\$($key)\""; |
232e078e | 2000 | } |
005c1a0e | 2001 | |
8e07c86e | 2002 | push @m, "\nPASTHRU = ", join ("\\\n\t", @pasthru), "\n"; |
232e078e AD |
2003 | join "", @m; |
2004 | } | |
a0d0e21e | 2005 | |
42793c05 | 2006 | # --- Translation Sections --- |
a0d0e21e | 2007 | |
42793c05 | 2008 | sub c_o { |
8e07c86e AD |
2009 | my($self) = shift; |
2010 | unless (ref $self){ | |
2011 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2012 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2013 | } | |
2014 | return '' unless $self->needs_linking(); | |
40000a8c | 2015 | my(@m); |
fed7345c | 2016 | push @m, ' |
4633a7c4 LW |
2017 | .c$(OBJ_EXT): |
2018 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c | |
864a5fa8 AD |
2019 | |
2020 | .C$(OBJ_EXT): | |
2021 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C | |
42793c05 | 2022 | '; |
fed7345c | 2023 | join "", @m; |
a0d0e21e LW |
2024 | } |
2025 | ||
42793c05 | 2026 | sub xs_c { |
8e07c86e AD |
2027 | my($self) = shift; |
2028 | unless (ref $self){ | |
2029 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2030 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2031 | } | |
2032 | return '' unless $self->needs_linking(); | |
42793c05 TB |
2033 | ' |
2034 | .xs.c: | |
864a5fa8 | 2035 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@ |
42793c05 TB |
2036 | '; |
2037 | } | |
a0d0e21e | 2038 | |
42793c05 | 2039 | sub xs_o { # many makes are too dumb to use xs_c then c_o |
8e07c86e AD |
2040 | my($self) = shift; |
2041 | unless (ref $self){ | |
2042 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2043 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2044 | } | |
2045 | return '' unless $self->needs_linking(); | |
a0d0e21e | 2046 | ' |
4633a7c4 | 2047 | .xs$(OBJ_EXT): |
864a5fa8 | 2048 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c |
4633a7c4 | 2049 | $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c |
a0d0e21e LW |
2050 | '; |
2051 | } | |
2052 | ||
42793c05 TB |
2053 | # --- Target Sections --- |
2054 | ||
8e07c86e AD |
2055 | sub top_targets { |
2056 | my($self) = shift; | |
2057 | unless (ref $self){ | |
2058 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2059 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2060 | } | |
40000a8c | 2061 | my(@m); |
fed7345c | 2062 | push @m, ' |
0d8023a2 | 2063 | all :: config $(INST_PM) subdirs linkext manifypods reorg_packlist |
8e07c86e AD |
2064 | |
2065 | subdirs :: $(MYEXTLIB) | |
2066 | ||
2067 | '.$self->{NOOP}.' | |
2068 | ||
2069 | config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists | |
42793c05 | 2070 | |
8e07c86e AD |
2071 | config :: $(INST_ARCHAUTODIR)/.exists Version_check |
2072 | ||
2073 | config :: $(INST_AUTODIR)/.exists | |
a0d0e21e | 2074 | '; |
fed7345c | 2075 | |
864a5fa8 | 2076 | push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]); |
8e07c86e | 2077 | |
864a5fa8 AD |
2078 | if (%{$self->{MAN1PODS}}) { |
2079 | push @m, q[ | |
2080 | config :: $(INST_MAN1DIR)/.exists | |
8e07c86e | 2081 | |
864a5fa8 AD |
2082 | ]; |
2083 | push @m, $self->dir_target(qw[$(INST_MAN1DIR)]); | |
8e07c86e | 2084 | } |
864a5fa8 AD |
2085 | if (%{$self->{MAN3PODS}}) { |
2086 | push @m, q[ | |
2087 | config :: $(INST_MAN3DIR)/.exists | |
8e07c86e | 2088 | |
864a5fa8 AD |
2089 | ]; |
2090 | push @m, $self->dir_target(qw[$(INST_MAN3DIR)]); | |
2091 | } | |
232e078e | 2092 | |
fed7345c AD |
2093 | push @m, ' |
2094 | $(O_FILES): $(H_FILES) | |
8e07c86e | 2095 | ' if @{$self->{O_FILES} || []} && @{$self->{H} || []}; |
005c1a0e AD |
2096 | |
2097 | push @m, q{ | |
2098 | help: | |
8e07c86e | 2099 | perldoc ExtUtils::MakeMaker |
005c1a0e AD |
2100 | }; |
2101 | ||
2102 | push @m, q{ | |
2103 | Version_check: | |
0d8023a2 | 2104 | }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ |
8e07c86e | 2105 | -e 'use ExtUtils::MakeMaker qw($$Version &Version_check);' \ |
4633a7c4 | 2106 | -e '&Version_check("$(MM_VERSION)")' |
005c1a0e AD |
2107 | }; |
2108 | ||
fed7345c | 2109 | join('',@m); |
a0d0e21e LW |
2110 | } |
2111 | ||
42793c05 TB |
2112 | sub linkext { |
2113 | my($self, %attribs) = @_; | |
8e07c86e AD |
2114 | unless (ref $self){ |
2115 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2116 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2117 | } | |
005c1a0e | 2118 | # LINKTYPE => static or dynamic or '' |
864a5fa8 | 2119 | my($linktype) = defined $attribs{LINKTYPE} ? |
005c1a0e | 2120 | $attribs{LINKTYPE} : '$(LINKTYPE)'; |
42793c05 TB |
2121 | " |
2122 | linkext :: $linktype | |
8e07c86e | 2123 | $self->{NOOP} |
42793c05 TB |
2124 | "; |
2125 | } | |
2126 | ||
1aef975c AD |
2127 | sub dlsyms { |
2128 | my($self,%attribs) = @_; | |
8e07c86e AD |
2129 | unless (ref $self){ |
2130 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2131 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2132 | } | |
1aef975c | 2133 | |
0d8023a2 | 2134 | return '' unless ($Config::Config{osname} eq 'aix' && $self->needs_linking() ); |
1aef975c | 2135 | |
8e07c86e AD |
2136 | my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; |
2137 | my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; | |
1aef975c AD |
2138 | my(@m); |
2139 | ||
2140 | push(@m," | |
8e07c86e | 2141 | dynamic :: $self->{BASEEXT}.exp |
1aef975c | 2142 | |
8e07c86e | 2143 | ") unless $self->{SKIPHASH}{dynamic}; |
1aef975c AD |
2144 | |
2145 | push(@m," | |
8e07c86e | 2146 | static :: $self->{BASEEXT}.exp |
1aef975c | 2147 | |
8e07c86e | 2148 | ") unless $self->{SKIPHASH}{static}; |
1aef975c AD |
2149 | |
2150 | push(@m," | |
8e07c86e | 2151 | $self->{BASEEXT}.exp: Makefile.PL |
c07a80fd | 2152 | ",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\ |
2153 | Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ', | |
2154 | neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\' | |
2155 | '); | |
1aef975c AD |
2156 | |
2157 | join('',@m); | |
2158 | } | |
42793c05 TB |
2159 | |
2160 | # --- Dynamic Loading Sections --- | |
a0d0e21e LW |
2161 | |
2162 | sub dynamic { | |
8e07c86e AD |
2163 | my($self) = shift; |
2164 | unless (ref $self){ | |
2165 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2166 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2167 | } | |
a0d0e21e | 2168 | ' |
42793c05 TB |
2169 | # $(INST_PM) has been moved to the all: target. |
2170 | # It remains here for awhile to allow for old usage: "make dynamic" | |
8e07c86e AD |
2171 | dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM) |
2172 | '.$self->{NOOP}.' | |
42793c05 TB |
2173 | '; |
2174 | } | |
a0d0e21e | 2175 | |
42793c05 TB |
2176 | sub dynamic_bs { |
2177 | my($self, %attribs) = @_; | |
8e07c86e AD |
2178 | unless (ref $self){ |
2179 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2180 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2181 | } | |
0d8023a2 | 2182 | return ' |
2183 | BOOTSTRAP = | |
2184 | ' unless $self->has_link_code(); | |
2185 | ||
2186 | return ' | |
8e07c86e | 2187 | BOOTSTRAP = '."$self->{BASEEXT}.bs".' |
a0d0e21e | 2188 | |
005c1a0e | 2189 | # As Mkbootstrap might not write a file (if none is required) |
42793c05 TB |
2190 | # we use touch to prevent make continually trying to remake it. |
2191 | # The DynaLoader only reads a non-empty file. | |
0d8023a2 | 2192 | $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists |
2193 | '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" | |
2194 | '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \ | |
005c1a0e AD |
2195 | -e \'use ExtUtils::Mkbootstrap;\' \ |
2196 | -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\' | |
0d8023a2 | 2197 | '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP) |
005c1a0e | 2198 | $(CHMOD) 644 $@ |
0d8023a2 | 2199 | '.$self->{NOECHO}.'echo $@ >> $(INST_ARCHAUTODIR)/.packlist |
a0d0e21e | 2200 | |
0d8023a2 | 2201 | $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists |
2202 | '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT) | |
8e07c86e | 2203 | -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT) |
005c1a0e | 2204 | $(CHMOD) 644 $@ |
0d8023a2 | 2205 | '.$self->{NOECHO}.'echo $@ >> $(INST_ARCHAUTODIR)/.packlist |
a0d0e21e LW |
2206 | '; |
2207 | } | |
2208 | ||
42793c05 TB |
2209 | sub dynamic_lib { |
2210 | my($self, %attribs) = @_; | |
8e07c86e AD |
2211 | unless (ref $self){ |
2212 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2213 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2214 | } | |
2215 | return '' unless $self->needs_linking(); #might be because of a subdir | |
2216 | ||
0d8023a2 | 2217 | return '' unless $self->has_link_code; |
8e07c86e | 2218 | |
42793c05 | 2219 | my($otherldflags) = $attribs{OTHERLDFLAGS} || ""; |
0d8023a2 | 2220 | my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || ""; |
8e07c86e | 2221 | my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":"; |
3edbfbe5 | 2222 | my($ldfrom) = '$(LDFROM)'; |
8e07c86e | 2223 | my($osname) = $Config::Config{osname}; |
75f92628 | 2224 | $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':'); |
3edbfbe5 TB |
2225 | my(@m); |
2226 | push(@m,' | |
75f92628 AD |
2227 | # This section creates the dynamically loadable $(INST_DYNAMIC) |
2228 | # from $(OBJECT) and possibly $(MYEXTLIB). | |
42793c05 TB |
2229 | ARMAYBE = '.$armaybe.' |
2230 | OTHERLDFLAGS = '.$otherldflags.' | |
0d8023a2 | 2231 | INST_DYNAMIC_DEP = '.$inst_dynamic_dep.' |
a0d0e21e | 2232 | |
0d8023a2 | 2233 | $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP) |
3edbfbe5 TB |
2234 | '); |
2235 | if ($armaybe ne ':'){ | |
4633a7c4 | 2236 | $ldfrom = 'tmp$(LIB_EXT)'; |
3edbfbe5 TB |
2237 | push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n"); |
2238 | push(@m,' $(RANLIB) '."$ldfrom\n"); | |
2239 | } | |
75f92628 | 2240 | $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf'); |
005c1a0e | 2241 | push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom. |
8e07c86e | 2242 | ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS) $(EXPORT_LIST) $(PERL_ARCHIVE)'); |
005c1a0e AD |
2243 | push @m, ' |
2244 | $(CHMOD) 755 $@ | |
0d8023a2 | 2245 | '.$self->{NOECHO}.'echo $@ >> $(INST_ARCHAUTODIR)/.packlist |
005c1a0e | 2246 | '; |
232e078e | 2247 | |
8e07c86e | 2248 | push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); |
3edbfbe5 | 2249 | join('',@m); |
a0d0e21e LW |
2250 | } |
2251 | ||
42793c05 TB |
2252 | # --- Static Loading Sections --- |
2253 | ||
2254 | sub static { | |
8e07c86e AD |
2255 | my($self) = shift; |
2256 | unless (ref $self){ | |
2257 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2258 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2259 | } | |
a0d0e21e | 2260 | ' |
42793c05 TB |
2261 | # $(INST_PM) has been moved to the all: target. |
2262 | # It remains here for awhile to allow for old usage: "make static" | |
8e07c86e AD |
2263 | static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM) |
2264 | '.$self->{NOOP}.' | |
a0d0e21e LW |
2265 | '; |
2266 | } | |
2267 | ||
8e07c86e | 2268 | sub static_lib { |
005c1a0e | 2269 | my($self) = @_; |
8e07c86e AD |
2270 | unless (ref $self){ |
2271 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2272 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2273 | } | |
0d8023a2 | 2274 | # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC |
2275 | # return '' unless $self->needs_linking(); #might be because of a subdir | |
8e07c86e | 2276 | |
0d8023a2 | 2277 | return '' unless $self->has_link_code; |
8e07c86e | 2278 | |
42793c05 TB |
2279 | my(@m); |
2280 | push(@m, <<'END'); | |
232e078e | 2281 | $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists |
42793c05 TB |
2282 | END |
2283 | # If this extension has it's own library (eg SDBM_File) | |
2284 | # then copy that to $(INST_STATIC) and add $(OBJECT) into it. | |
0d8023a2 | 2285 | push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB}; |
42793c05 | 2286 | |
0d8023a2 | 2287 | push @m, |
2288 | q{ $(AR) cr $@ $(OBJECT) && $(RANLIB) $@ | |
2289 | }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld | |
005c1a0e | 2290 | $(CHMOD) 755 $@ |
0d8023a2 | 2291 | }.$self->{NOECHO}.q{echo $@ >> $(INST_ARCHAUTODIR)/.packlist |
2292 | }; | |
fed7345c AD |
2293 | |
2294 | # Old mechanism - still available: | |
2295 | ||
0d8023a2 | 2296 | push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs}."\n\n" |
2297 | if $self->{PERL_SRC}; | |
005c1a0e | 2298 | |
8e07c86e | 2299 | push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); |
42793c05 TB |
2300 | join('', "\n",@m); |
2301 | } | |
2302 | ||
a0d0e21e | 2303 | sub installpm { |
42793c05 | 2304 | my($self, %attribs) = @_; |
8e07c86e AD |
2305 | unless (ref $self){ |
2306 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2307 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2308 | } | |
42793c05 TB |
2309 | # By default .pm files are split into the architecture independent |
2310 | # library. This is a good thing. If a specific module requires that | |
2311 | # it's .pm files are split into the architecture specific library | |
2312 | # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'} | |
2313 | # Note that installperl currently interferes with this (Config.pm) | |
2314 | # User can disable split by saying: installpm => {SPLITLIB=>''} | |
2315 | my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default | |
2316 | $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB}; | |
2317 | my(@m, $dist); | |
8e07c86e AD |
2318 | push @m, "inst_pm :: \$(INST_PM)\n\n"; |
2319 | foreach $dist (sort keys %{$self->{PM}}){ | |
2320 | my($inst) = $self->{PM}->{$dist}; | |
42793c05 | 2321 | push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n"); |
8e07c86e | 2322 | push(@m, $self->installpm_x($dist, $inst, $splitlib)); |
42793c05 TB |
2323 | push(@m, "\n"); |
2324 | } | |
2325 | join('', @m); | |
a0d0e21e LW |
2326 | } |
2327 | ||
42793c05 TB |
2328 | sub installpm_x { # called by installpm per file |
2329 | my($self, $dist, $inst, $splitlib) = @_; | |
8e07c86e AD |
2330 | unless (ref $self){ |
2331 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2332 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2333 | } | |
0d8023a2 | 2334 | if ($inst =~ m,[:\#],){ |
2335 | warn "Warning: 'make' would have problems processing this file: '$inst', SKIPPED\n"; | |
2336 | return ''; | |
2337 | } | |
42793c05 TB |
2338 | my($instdir) = $inst =~ m|(.*)/|; |
2339 | my(@m); | |
2340 | push(@m," | |
0d8023a2 | 2341 | $inst: $dist $self->{MAKEFILE} $instdir/.exists \$(INST_ARCHAUTODIR)/.exists |
2342 | $self->{NOECHO}$self->{RM_F}".' $@ | |
2343 | $(UMASK_NULL) && '."$self->{CP} $dist \$\@ | |
2344 | $self->{NOECHO}echo ".'$@ >> $(INST_ARCHAUTODIR)/.packlist | |
42793c05 | 2345 | '); |
0d8023a2 | 2346 | push(@m, "\t$self->{NOECHO}\$(AUTOSPLITFILE) \$@ $splitlib/auto\n") |
42793c05 | 2347 | if ($splitlib and $inst =~ m/\.pm$/); |
232e078e | 2348 | |
8e07c86e AD |
2349 | push @m, $self->dir_target($instdir); |
2350 | join('', @m); | |
2351 | } | |
2352 | ||
2353 | sub manifypods { | |
2354 | my($self, %attribs) = @_; | |
2355 | unless (ref $self){ | |
2356 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2357 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2358 | } | |
864a5fa8 | 2359 | return "\nmanifypods :\n" unless %{$self->{MAN3PODS}}; |
8e07c86e | 2360 | my($dist); |
4633a7c4 LW |
2361 | my($pod2man_exe); |
2362 | if (defined $self->{PERL_SRC}) { | |
0d8023a2 | 2363 | $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man'); |
4633a7c4 | 2364 | } else { |
0d8023a2 | 2365 | $pod2man_exe = $self->catfile($Config{bin},'pod2man'); |
4633a7c4 | 2366 | } |
cb1a09d0 | 2367 | unless ($self->perl_script($pod2man_exe)) { |
864a5fa8 | 2368 | # No pod2man but some MAN3PODS to be installed |
4633a7c4 LW |
2369 | print <<END; |
2370 | ||
2371 | Warning: I could not locate your pod2man program. Please make sure, | |
2372 | your pod2man program is in your PATH before you execute 'make' | |
2373 | ||
2374 | END | |
2375 | $pod2man_exe = "-S pod2man"; | |
2376 | } | |
8e07c86e | 2377 | my(@m); |
4633a7c4 LW |
2378 | push @m, |
2379 | qq[POD2MAN_EXE = $pod2man_exe\n], | |
8e07c86e | 2380 | q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\ |
864a5fa8 | 2381 | -e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\ |
8e07c86e | 2382 | -e 'print "Installing $$m{$$_}\n";' \\ |
0d8023a2 | 2383 | -e 'system("$$^X \\"-I$(PERL_ARCHLIB)\\" \\"-I$(PERL_LIB)\\" $(POD2MAN_EXE) $$_>$$m{$$_}")==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\ |
8e07c86e AD |
2384 | -e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}' |
2385 | ]; | |
4e68a208 AD |
2386 | push @m, "\nmanifypods : "; |
2387 | push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}; | |
8e07c86e AD |
2388 | |
2389 | push(@m,"\n"); | |
864a5fa8 | 2390 | if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) { |
0d8023a2 | 2391 | push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t"; |
864a5fa8 | 2392 | push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}}; |
8e07c86e | 2393 | } |
42793c05 TB |
2394 | join('', @m); |
2395 | } | |
a0d0e21e | 2396 | |
232e078e | 2397 | sub processPL { |
8e07c86e AD |
2398 | my($self) = shift; |
2399 | unless (ref $self){ | |
2400 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2401 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2402 | } | |
2403 | return "" unless $self->{PL_FILES}; | |
232e078e | 2404 | my(@m, $plfile); |
8e07c86e | 2405 | foreach $plfile (sort keys %{$self->{PL_FILES}}) { |
232e078e | 2406 | push @m, " |
8e07c86e | 2407 | all :: $self->{PL_FILES}->{$plfile} |
232e078e | 2408 | |
8e07c86e | 2409 | $self->{PL_FILES}->{$plfile} :: $plfile |
232e078e AD |
2410 | \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile |
2411 | "; | |
2412 | } | |
2413 | join "", @m; | |
2414 | } | |
2415 | ||
40000a8c | 2416 | sub installbin { |
8e07c86e AD |
2417 | my($self) = shift; |
2418 | return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY"; | |
cb1a09d0 | 2419 | return "" unless @{$self->{EXE_FILES}}; |
40000a8c | 2420 | my(@m, $from, $to, %fromto, @to); |
8e07c86e AD |
2421 | push @m, $self->dir_target(qw[$(INST_EXE)]); |
2422 | for $from (@{$self->{EXE_FILES}}) { | |
2423 | my($path)= '$(INST_EXE)/' . basename($from); | |
2424 | local($_) = $path; # for backwards compatibility | |
2425 | $to = $self->exescan($path); | |
2426 | print "exescan($from) => '$to'\n" if ($ExtUtils::MakeMaker::Verbose >=2); | |
40000a8c AD |
2427 | $fromto{$from}=$to; |
2428 | } | |
2429 | @to = values %fromto; | |
2430 | push(@m, " | |
8e07c86e | 2431 | EXE_FILES = @{$self->{EXE_FILES}} |
40000a8c AD |
2432 | |
2433 | all :: @to | |
2434 | ||
2435 | realclean :: | |
8e07c86e | 2436 | $self->{RM_F} @to |
40000a8c AD |
2437 | "); |
2438 | ||
2439 | while (($from,$to) = each %fromto) { | |
005c1a0e | 2440 | my $todir = dirname($to); |
40000a8c | 2441 | push @m, " |
8e07c86e AD |
2442 | $to: $from $self->{MAKEFILE} $todir/.exists |
2443 | $self->{CP} $from $to | |
40000a8c AD |
2444 | "; |
2445 | } | |
2446 | join "", @m; | |
2447 | } | |
42793c05 | 2448 | |
40000a8c | 2449 | sub exescan { |
8e07c86e AD |
2450 | my($self,$path) = @_; |
2451 | $path; | |
40000a8c | 2452 | } |
42793c05 TB |
2453 | # --- Sub-directory Sections --- |
2454 | ||
2455 | sub subdirs { | |
8e07c86e AD |
2456 | my($self) = shift; |
2457 | unless (ref $self){ | |
2458 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2459 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2460 | } | |
2461 | my(@m,$dir); | |
42793c05 TB |
2462 | # This method provides a mechanism to automatically deal with |
2463 | # subdirectories containing further Makefile.PL scripts. | |
2464 | # It calls the subdir_x() method for each subdirectory. | |
8e07c86e AD |
2465 | foreach $dir (@{$self->{DIR}}){ |
2466 | push(@m, $self->subdir_x($dir)); | |
4633a7c4 | 2467 | #### print "Including $dir subdirectory\n"; |
42793c05 TB |
2468 | } |
2469 | if (@m){ | |
2470 | unshift(@m, " | |
2471 | # The default clean, realclean and test targets in this Makefile | |
2472 | # have automatically been given entries for each subdir. | |
2473 | ||
42793c05 TB |
2474 | "); |
2475 | } else { | |
2476 | push(@m, "\n# none") | |
2477 | } | |
2478 | join('',@m); | |
2479 | } | |
2480 | ||
2481 | sub runsubdirpl{ # Experimental! See subdir_x section | |
2482 | my($self,$subdir) = @_; | |
8e07c86e AD |
2483 | unless (ref $self){ |
2484 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2485 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2486 | } | |
42793c05 | 2487 | chdir($subdir) or die "chdir($subdir): $!"; |
005c1a0e | 2488 | package main; |
42793c05 | 2489 | require "Makefile.PL"; |
a0d0e21e LW |
2490 | } |
2491 | ||
42793c05 TB |
2492 | sub subdir_x { |
2493 | my($self, $subdir) = @_; | |
8e07c86e AD |
2494 | unless (ref $self){ |
2495 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2496 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2497 | } | |
42793c05 | 2498 | my(@m); |
42793c05 | 2499 | qq{ |
42793c05 TB |
2500 | |
2501 | subdirs :: | |
0d8023a2 | 2502 | $self->{NOECHO}-cd $subdir && \$(MAKE) all \$(PASTHRU) |
42793c05 TB |
2503 | |
2504 | }; | |
2505 | } | |
2506 | ||
42793c05 TB |
2507 | # --- Cleanup and Distribution Sections --- |
2508 | ||
2509 | sub clean { | |
2510 | my($self, %attribs) = @_; | |
8e07c86e AD |
2511 | unless (ref $self){ |
2512 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2513 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2514 | } | |
2515 | my(@m,$dir); | |
42793c05 TB |
2516 | push(@m, ' |
2517 | # Delete temporary files but do not touch installed files. We don\'t delete | |
2518 | # the Makefile here so a later make realclean still has a makefile to use. | |
2519 | ||
2520 | clean :: | |
2521 | '); | |
2522 | # clean subdirectories first | |
8e07c86e AD |
2523 | for $dir (@{$self->{DIR}}) { |
2524 | push @m, "\t-cd $dir && test -f $self->{MAKEFILE} && \$(MAKE) clean\n"; | |
2525 | } | |
2526 | ||
2527 | my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files | |
42793c05 | 2528 | push(@otherfiles, $attribs{FILES}) if $attribs{FILES}; |
0d8023a2 | 2529 | push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all |
8e07c86e | 2530 | perlmain.c mon.out core so_locations |
864a5fa8 | 2531 | *~ */*~ */*/*~ |
4633a7c4 | 2532 | *$(OBJ_EXT) *$(LIB_EXT) |
864a5fa8 | 2533 | perl.exe $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def $(BASEEXT).exp |
8e07c86e AD |
2534 | ]); |
2535 | push @m, "\t-$self->{RM_RF} @otherfiles\n"; | |
75f92628 | 2536 | # See realclean and ext/utils/make_ext for usage of Makefile.old |
8e07c86e AD |
2537 | push(@m, |
2538 | "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old 2>/dev/null\n"); | |
2539 | push(@m, | |
2540 | "\t$attribs{POSTOP}\n") if $attribs{POSTOP}; | |
42793c05 TB |
2541 | join("", @m); |
2542 | } | |
a0d0e21e LW |
2543 | |
2544 | sub realclean { | |
42793c05 | 2545 | my($self, %attribs) = @_; |
8e07c86e AD |
2546 | unless (ref $self){ |
2547 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2548 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2549 | } | |
42793c05 TB |
2550 | my(@m); |
2551 | push(@m,' | |
2552 | # Delete temporary files (via clean) and also delete installed files | |
2553 | realclean purge :: clean | |
2554 | '); | |
75f92628 | 2555 | # realclean subdirectories first (already cleaned) |
232e078e | 2556 | my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n"; |
8e07c86e AD |
2557 | foreach(@{$self->{DIR}}){ |
2558 | push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old")); | |
2559 | push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",'')); | |
2560 | } | |
2561 | push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n"); | |
2562 | push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n"); | |
2563 | push(@m, " $self->{RM_F} \$(INST_STATIC) \$(INST_PM)\n"); | |
864a5fa8 | 2564 | my(@otherfiles) = ($self->{MAKEFILE}, |
8e07c86e | 2565 | "$self->{MAKEFILE}.old"); # Makefiles last |
42793c05 | 2566 | push(@otherfiles, $attribs{FILES}) if $attribs{FILES}; |
8e07c86e | 2567 | push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles; |
42793c05 TB |
2568 | push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP}; |
2569 | join("", @m); | |
2570 | } | |
a0d0e21e | 2571 | |
8e07c86e AD |
2572 | sub dist_basics { |
2573 | my($self) = shift; | |
2574 | unless (ref $self){ | |
2575 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2576 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
005c1a0e | 2577 | } |
8e07c86e | 2578 | my @m; |
005c1a0e AD |
2579 | push @m, q{ |
2580 | distclean :: realclean distcheck | |
8e07c86e | 2581 | }; |
005c1a0e | 2582 | |
8e07c86e | 2583 | push @m, q{ |
005c1a0e | 2584 | distcheck : |
8e07c86e | 2585 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\ |
005c1a0e | 2586 | -e 'fullcheck();' |
8e07c86e | 2587 | }; |
005c1a0e | 2588 | |
8e07c86e | 2589 | push @m, q{ |
4633a7c4 LW |
2590 | skipcheck : |
2591 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&skipcheck";' \\ | |
2592 | -e 'skipcheck();' | |
2593 | }; | |
2594 | ||
2595 | push @m, q{ | |
005c1a0e | 2596 | manifest : |
8e07c86e | 2597 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\ |
005c1a0e | 2598 | -e 'mkmanifest();' |
8e07c86e AD |
2599 | }; |
2600 | join "", @m; | |
2601 | } | |
005c1a0e | 2602 | |
8e07c86e AD |
2603 | sub dist_core { |
2604 | my($self) = shift; | |
2605 | unless (ref $self){ | |
2606 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2607 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2608 | } | |
2609 | my @m; | |
2610 | push @m, q{ | |
005c1a0e AD |
2611 | dist : $(DIST_DEFAULT) |
2612 | ||
8e07c86e | 2613 | tardist : $(DISTVNAME).tar.$(SUFFIX) |
005c1a0e | 2614 | |
8e07c86e | 2615 | $(DISTVNAME).tar.$(SUFFIX) : distdir |
005c1a0e | 2616 | $(PREOP) |
8e07c86e AD |
2617 | $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) |
2618 | $(RM_RF) $(DISTVNAME) | |
2619 | $(COMPRESS) $(DISTVNAME).tar | |
005c1a0e AD |
2620 | $(POSTOP) |
2621 | ||
8e07c86e AD |
2622 | uutardist : $(DISTVNAME).tar.$(SUFFIX) |
2623 | uuencode $(DISTVNAME).tar.$(SUFFIX) \\ | |
2624 | $(DISTVNAME).tar.$(SUFFIX) > \\ | |
2625 | $(DISTVNAME).tar.$(SUFFIX).uu | |
005c1a0e AD |
2626 | |
2627 | shdist : distdir | |
2628 | $(PREOP) | |
8e07c86e AD |
2629 | $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar |
2630 | $(RM_RF) $(DISTVNAME) | |
005c1a0e | 2631 | $(POSTOP) |
005c1a0e AD |
2632 | }; |
2633 | join "", @m; | |
a0d0e21e LW |
2634 | } |
2635 | ||
8e07c86e AD |
2636 | sub dist_dir { |
2637 | my($self) = shift; | |
2638 | unless (ref $self){ | |
2639 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2640 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2641 | } | |
2642 | my @m; | |
2643 | push @m, q{ | |
2644 | distdir : | |
2645 | $(RM_RF) $(DISTVNAME) | |
2646 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "/mani/";' \\ | |
2647 | -e 'manicopy(maniread(),"$(DISTVNAME)", "$(DIST_CP)");' | |
2648 | }; | |
2649 | join "", @m; | |
a0d0e21e LW |
2650 | } |
2651 | ||
8e07c86e AD |
2652 | sub dist_test { |
2653 | my($self) = shift; | |
2654 | unless (ref $self){ | |
2655 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2656 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2657 | } | |
2658 | my @m; | |
2659 | push @m, q{ | |
2660 | disttest : distdir | |
2661 | cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL | |
2662 | cd $(DISTVNAME) && $(MAKE) | |
2663 | cd $(DISTVNAME) && $(MAKE) test | |
2664 | }; | |
2665 | join "", @m; | |
e50aee73 AD |
2666 | } |
2667 | ||
8e07c86e AD |
2668 | sub dist_ci { |
2669 | my($self) = shift; | |
2670 | unless (ref $self){ | |
2671 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2672 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2673 | } | |
2674 | my @m; | |
2675 | push @m, q{ | |
2676 | ci : | |
2677 | $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\ | |
2678 | -e '@all = keys %{ maniread() };' \\ | |
2679 | -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\ | |
2680 | -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");' | |
2681 | }; | |
2682 | join "", @m; | |
e50aee73 AD |
2683 | } |
2684 | ||
a0d0e21e | 2685 | sub install { |
3edbfbe5 | 2686 | my($self, %attribs) = @_; |
8e07c86e AD |
2687 | unless (ref $self){ |
2688 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2689 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2690 | } | |
3edbfbe5 | 2691 | my(@m); |
40000a8c AD |
2692 | push @m, q{ |
2693 | doc_install :: | |
0d8023a2 | 2694 | }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod |
2695 | }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \\ | |
8e07c86e | 2696 | -e "use ExtUtils::MakeMaker; MY->new({})->writedoc('Module', '$(NAME)', \\ |
0d8023a2 | 2697 | 'LINKTYPE=$(LINKTYPE)', 'VERSION=$(VERSION)', 'XS_VERSION=$(XS_VERSION)', \\ |
005c1a0e | 2698 | 'EXE_FILES=$(EXE_FILES)')" >> $(INSTALLARCHLIB)/perllocal.pod |
40000a8c AD |
2699 | }; |
2700 | ||
3edbfbe5 | 2701 | push(@m, " |
40000a8c AD |
2702 | install :: pure_install doc_install |
2703 | ||
005c1a0e | 2704 | pure_install :: |
3edbfbe5 TB |
2705 | "); |
2706 | # install subdirectories first | |
8e07c86e AD |
2707 | push(@m, map("\tcd $_ && test -f $self->{MAKEFILE} && \$(MAKE) install\n", |
2708 | @{$self->{DIR}})); | |
2709 | ||
0d8023a2 | 2710 | push(@m, "\t$self->{NOECHO}".q{$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'require File::Path;' \ |
2711 | -e '$$message = q[ You do not have permissions to install into];' \ | |
2712 | -e 'File::Path::mkpath(@ARGV);' \ | |
2713 | -e 'foreach (@ARGV){ die qq{ $$message $$_\\n} unless -w $$_}' \ | |
2714 | $(INSTALLPRIVLIB) $(INSTALLARCHLIB) | |
2715 | $(MAKE) INST_LIB=$(INSTALLPRIVLIB) INST_ARCHLIB=$(INSTALLARCHLIB) \ | |
2716 | INST_EXE=$(INSTALLBIN) INST_MAN1DIR=$(INSTALLMAN1DIR) \ | |
2717 | INST_MAN3DIR=$(INSTALLMAN3DIR) all | |
2718 | ||
2719 | reorg_packlist: | |
2720 | }.$self->{NOECHO}.q{$(PERL) -ne 'BEGIN{die "Need 2 arguments to reorg .packlist" unless @ARGV==2;' \ | |
2721 | -e '$$out=$$ARGV[1]; shift @ARGV while @ARGV && ! -f $$ARGV[0]; exit unless @ARGV;}' \ | |
2722 | -e 'push @lines, $$_ unless $$seen{$$_}++;' \ | |
2723 | -e 'END{open STDOUT, ">$$out" or die "Cannot write to $$out: $$!";' \ | |
2724 | -e 'print @lines;}' $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ | |
2725 | $(INST_ARCHAUTODIR)/.packlist | |
2726 | }); | |
2727 | ||
2728 | # From MM 5.16: | |
2729 | ||
2730 | push @m, q[ | |
2731 | # Comment on .packlist rewrite above: | |
2732 | # Read both .packlist files: the old one in PERL_ARCHLIB/auto/FULLEXT, and the new one | |
2733 | # in INSTARCHAUTODIR. Don't croak if they are missing. Write to the one | |
2734 | # in INSTARCHAUTODIR. | |
4e68a208 | 2735 | |
005c1a0e AD |
2736 | #### UNINSTALL IS STILL EXPERIMENTAL #### |
2737 | uninstall :: | |
0d8023a2 | 2738 | ]; |
005c1a0e | 2739 | |
8e07c86e AD |
2740 | push(@m, map("\tcd $_ && test -f $self->{MAKEFILE} && \$(MAKE) uninstall\n", |
2741 | @{$self->{DIR}})); | |
4e68a208 | 2742 | push @m, "\t".'$(RM_RF) `cat $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist` |
005c1a0e AD |
2743 | '; |
2744 | ||
3edbfbe5 TB |
2745 | join("",@m); |
2746 | } | |
a0d0e21e | 2747 | |
8e07c86e | 2748 | |
42793c05 | 2749 | sub force { |
8e07c86e AD |
2750 | my($self) = shift; |
2751 | unless (ref $self){ | |
2752 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2753 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2754 | } | |
42793c05 TB |
2755 | '# Phony target to force checking subdirectories. |
2756 | FORCE: | |
a0d0e21e LW |
2757 | '; |
2758 | } | |
2759 | ||
2760 | ||
2761 | sub perldepend { | |
8e07c86e AD |
2762 | my($self) = shift; |
2763 | unless (ref $self){ | |
2764 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2765 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2766 | } | |
005c1a0e | 2767 | my(@m); |
42793c05 TB |
2768 | push(@m,' |
2769 | PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \ | |
2770 | $(PERL_INC)/XSUB.h $(PERL_INC)/av.h $(PERL_INC)/cop.h \ | |
2771 | $(PERL_INC)/cv.h $(PERL_INC)/dosish.h $(PERL_INC)/embed.h \ | |
2772 | $(PERL_INC)/form.h $(PERL_INC)/gv.h $(PERL_INC)/handy.h \ | |
2773 | $(PERL_INC)/hv.h $(PERL_INC)/keywords.h $(PERL_INC)/mg.h \ | |
2774 | $(PERL_INC)/op.h $(PERL_INC)/opcode.h $(PERL_INC)/patchlevel.h \ | |
2775 | $(PERL_INC)/perl.h $(PERL_INC)/perly.h $(PERL_INC)/pp.h \ | |
2776 | $(PERL_INC)/proto.h $(PERL_INC)/regcomp.h $(PERL_INC)/regexp.h \ | |
2777 | $(PERL_INC)/scope.h $(PERL_INC)/sv.h $(PERL_INC)/unixish.h \ | |
75f92628 | 2778 | $(PERL_INC)/util.h $(PERL_INC)/config.h |
42793c05 | 2779 | |
42793c05 | 2780 | '); |
e1666bf5 | 2781 | |
005c1a0e AD |
2782 | push @m, ' |
2783 | $(OBJECT) : $(PERL_HDRS) | |
8e07c86e | 2784 | ' if $self->{OBJECT}; |
005c1a0e | 2785 | |
42793c05 | 2786 | push(@m,' |
75f92628 AD |
2787 | # Check for unpropogated config.sh changes. Should never happen. |
2788 | # We do NOT just update config.h because that is not sufficient. | |
2789 | # An out of date config.h is not fatal but complains loudly! | |
2790 | $(PERL_INC)/config.h: $(PERL_SRC)/config.sh | |
0d8023a2 | 2791 | -'.$self->{NOECHO}.'echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false |
75f92628 | 2792 | |
75f92628 | 2793 | $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh |
0d8023a2 | 2794 | '.$self->{NOECHO}.'echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh" |
232e078e | 2795 | cd $(PERL_SRC) && $(MAKE) lib/Config.pm |
8e07c86e | 2796 | ') if $self->{PERL_SRC}; |
e1666bf5 | 2797 | |
8e07c86e AD |
2798 | push(@m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n") |
2799 | if %{$self->{XS}}; | |
42793c05 TB |
2800 | join("\n",@m); |
2801 | } | |
2802 | ||
42793c05 | 2803 | sub makefile { |
8e07c86e AD |
2804 | my($self) = shift; |
2805 | unless (ref $self){ | |
2806 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2807 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2808 | } | |
005c1a0e | 2809 | my @m; |
42793c05 | 2810 | # We do not know what target was originally specified so we |
75f92628 | 2811 | # must force a manual rerun to be sure. But as it should only |
42793c05 | 2812 | # happen very rarely it is not a significant problem. |
005c1a0e | 2813 | push @m, ' |
4633a7c4 | 2814 | $(OBJECT) : $(FIRST_MAKEFILE) |
8e07c86e | 2815 | ' if $self->{OBJECT}; |
75f92628 | 2816 | |
8e07c86e | 2817 | push @m, ' |
75f92628 AD |
2818 | # We take a very conservative approach here, but it\'s worth it. |
2819 | # We move Makefile to Makefile.old here to avoid gnu make looping. | |
8e07c86e | 2820 | '.$self->{MAKEFILE}.' : Makefile.PL $(CONFIGDEP) |
0d8023a2 | 2821 | '.$self->{NOECHO}.'echo "Makefile out-of-date with respect to $?" |
2822 | '.$self->{NOECHO}.'echo "Cleaning current config before rebuilding Makefile..." | |
2823 | -'.$self->{NOECHO}.'mv '."$self->{MAKEFILE} $self->{MAKEFILE}.old".' | |
8e07c86e | 2824 | -$(MAKE) -f '.$self->{MAKEFILE}.'.old clean >/dev/null 2>&1 || true |
005c1a0e | 2825 | $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL '."@ARGV".' |
0d8023a2 | 2826 | '.$self->{NOECHO}.'echo ">>> Your Makefile has been rebuilt. <<<" |
2827 | '.$self->{NOECHO}.'echo ">>> Please rerun the make command. <<<"; false | |
a0d0e21e | 2828 | '; |
005c1a0e AD |
2829 | |
2830 | join "", @m; | |
a0d0e21e LW |
2831 | } |
2832 | ||
8e07c86e AD |
2833 | sub staticmake { |
2834 | my($self, %attribs) = @_; | |
2835 | unless (ref $self){ | |
2836 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2837 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2838 | } | |
2839 | my(@static); | |
a0d0e21e | 2840 | |
8e07c86e AD |
2841 | my(%searchdirs)=($self->{PERL_ARCHLIB} => 1, $self->{INST_ARCHLIB} => 1); |
2842 | my(@searchdirs)=keys %searchdirs; | |
232e078e | 2843 | |
8e07c86e AD |
2844 | # And as it's not yet built, we add the current extension |
2845 | # but only if it has some C code (or XS code, which implies C code) | |
2846 | if (@{$self->{C}}) { | |
4633a7c4 | 2847 | @static="$self->{INST_ARCHLIB}/auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}"; |
232e078e | 2848 | } |
8e07c86e AD |
2849 | |
2850 | # Either we determine now, which libraries we will produce in the | |
2851 | # subdirectories or we do it at runtime of the make. | |
2852 | ||
2853 | # We could ask all subdir objects, but I cannot imagine, why it | |
2854 | # would be necessary. | |
2855 | ||
2856 | # Instead we determine all libraries for the new perl at | |
2857 | # runtime. | |
2858 | my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB}); | |
2859 | ||
864a5fa8 AD |
2860 | $self->makeaperl(MAKE => $self->{MAKEFILE}, |
2861 | DIRS => \@searchdirs, | |
2862 | STAT => \@static, | |
8e07c86e AD |
2863 | INCL => \@perlinc, |
2864 | TARGET => $self->{MAP_TARGET}, | |
2865 | TMP => "", | |
2866 | LIBPERL => $self->{LIBPERL_A} | |
2867 | ); | |
232e078e AD |
2868 | } |
2869 | ||
8e07c86e | 2870 | # --- Test and Installation Sections --- |
fed7345c | 2871 | |
8e07c86e | 2872 | sub test { |
fed7345c | 2873 | my($self, %attribs) = @_; |
8e07c86e AD |
2874 | unless (ref $self){ |
2875 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2876 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2877 | } | |
2878 | my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : ""); | |
2879 | my(@m); | |
2880 | push(@m," | |
2881 | TEST_VERBOSE=0 | |
2882 | TEST_TYPE=test_\$(LINKTYPE) | |
fed7345c | 2883 | |
8e07c86e AD |
2884 | test :: \$(TEST_TYPE) |
2885 | "); | |
0d8023a2 | 2886 | push(@m, map("\t$self->{NOECHO}cd $_ && test -f $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n", |
8e07c86e | 2887 | @{$self->{DIR}})); |
0d8023a2 | 2888 | push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n") |
8e07c86e AD |
2889 | unless $tests or -f "test.pl" or @{$self->{DIR}}; |
2890 | push(@m, "\n"); | |
2891 | ||
2892 | push(@m, "test_dynamic :: all\n"); | |
2893 | push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests; | |
2894 | push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl"; | |
2895 | push(@m, "\n"); | |
2896 | ||
0d8023a2 | 2897 | # Occasionally we may face this degenerate target: |
8e07c86e AD |
2898 | push @m, "test_ : test_dynamic\n\n"; |
2899 | ||
2900 | if ($self->needs_linking()) { | |
2901 | push(@m, "test_static :: all \$(MAP_TARGET)\n"); | |
2902 | push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests; | |
2903 | push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl"; | |
2904 | push(@m, "\n"); | |
2905 | } else { | |
2906 | push @m, "test_static :: test_dynamic\n"; | |
2907 | } | |
2908 | join("", @m); | |
2909 | } | |
2910 | ||
2911 | sub test_via_harness { | |
2912 | my($self, $perl, $tests) = @_; | |
2913 | unless (ref $self){ | |
2914 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2915 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2916 | } | |
2917 | "\tPERL_DL_NONLAZY=1 $perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n"; | |
2918 | } | |
2919 | ||
2920 | sub test_via_script { | |
2921 | my($self, $perl, $script) = @_; | |
2922 | unless (ref $self){ | |
2923 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2924 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2925 | } | |
2926 | "\tPERL_DL_NONLAZY=1 $perl".' -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl | |
2927 | '; | |
2928 | } | |
2929 | ||
2930 | ||
2931 | sub postamble { | |
2932 | my($self) = shift; | |
2933 | unless (ref $self){ | |
2934 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2935 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2936 | } | |
2937 | ""; | |
fed7345c AD |
2938 | } |
2939 | ||
2940 | sub makeaperl { | |
2941 | my($self, %attribs) = @_; | |
8e07c86e AD |
2942 | unless (ref $self){ |
2943 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
2944 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
2945 | } | |
864a5fa8 | 2946 | my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) = |
8e07c86e | 2947 | @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)}; |
fed7345c | 2948 | my(@m); |
8e07c86e AD |
2949 | push @m, " |
2950 | # --- MakeMaker makeaperl section --- | |
2951 | MAP_TARGET = $target | |
2952 | FULLPERL = $self->{FULLPERL} | |
2953 | "; | |
2954 | return join '', @m if $self->{PARENT}; | |
2955 | ||
4633a7c4 LW |
2956 | my($dir) = join ":", @{$self->{DIR}}; |
2957 | ||
8e07c86e | 2958 | unless ($self->{MAKEAPERL}) { |
4633a7c4 LW |
2959 | push @m, q{ |
2960 | $(MAP_TARGET) :: $(MAKE_APERL_FILE) | |
0d8023a2 | 2961 | $(MAKE) -f $(MAKE_APERL_FILE) static $@ |
4633a7c4 LW |
2962 | |
2963 | $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) | |
0d8023a2 | 2964 | }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) |
2965 | }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ | |
4633a7c4 LW |
2966 | Makefile.PL DIR=}, $dir, q{ \ |
2967 | MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ | |
0d8023a2 | 2968 | MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=}; |
4633a7c4 LW |
2969 | |
2970 | push @m, map( " \\\n\t\t$_", @ARGV ); | |
2971 | push @m, "\n"; | |
2972 | ||
8e07c86e AD |
2973 | return join '', @m; |
2974 | } | |
2975 | ||
864a5fa8 | 2976 | |
8e07c86e AD |
2977 | |
2978 | my($cccmd, $linkcmd, $lperl); | |
2979 | ||
fed7345c | 2980 | |
8e07c86e | 2981 | $cccmd = $self->const_cccmd($libperl); |
fed7345c | 2982 | $cccmd =~ s/^CCCMD\s*=\s*//; |
4633a7c4 | 2983 | $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /; |
8e07c86e AD |
2984 | $cccmd .= " $Config::Config{cccdlflags}" if ($Config::Config{d_shrplib}); |
2985 | $cccmd =~ s/\n/ /g; # yes I've seen "\n", don't ask me where it came from. A.K. | |
864a5fa8 | 2986 | $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/; |
fed7345c AD |
2987 | |
2988 | # The front matter of the linkcommand... | |
5d94fbed | 2989 | $linkcmd = join ' ', "\$(CC)", |
fed7345c AD |
2990 | grep($_, @Config{qw(large split ldflags ccdlflags)}); |
2991 | $linkcmd =~ s/\s+/ /g; | |
2992 | ||
2993 | # Which *.a files could we make use of... | |
40000a8c | 2994 | local(%static); |
fed7345c | 2995 | File::Find::find(sub { |
4e68a208 | 2996 | return unless m/\Q$self->{LIB_EXT}\E$/; |
40000a8c | 2997 | return if m/^libperl/; |
8e07c86e AD |
2998 | # don't include the installed version of this extension. I |
2999 | # leave this line here, although it is not necessary anymore: | |
3000 | # I patched minimod.PL instead, so that Miniperl.pm won't | |
3001 | # enclude duplicates | |
3002 | ||
3003 | # Once the patch to minimod.PL is in the distribution, I can | |
3004 | # drop it | |
4633a7c4 | 3005 | return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:; |
40000a8c | 3006 | $static{fastcwd() . "/" . $_}++; |
fed7345c AD |
3007 | }, grep( -d $_, @{$searchdirs || []}) ); |
3008 | ||
40000a8c AD |
3009 | # We trust that what has been handed in as argument, will be buildable |
3010 | $static = [] unless $static; | |
3011 | @static{@{$static}} = (1) x @{$static}; | |
3012 | ||
fed7345c AD |
3013 | $extra = [] unless $extra && ref $extra eq 'ARRAY'; |
3014 | for (sort keys %static) { | |
4e68a208 | 3015 | next unless /\Q$self->{LIB_EXT}\E$/; |
40000a8c | 3016 | $_ = dirname($_) . "/extralibs.ld"; |
5d94fbed | 3017 | push @$extra, $_; |
fed7345c AD |
3018 | } |
3019 | ||
8e07c86e | 3020 | grep(s/^/-I/, @{$perlinc || []}); |
fed7345c AD |
3021 | |
3022 | $target = "perl" unless $target; | |
3023 | $tmp = "." unless $tmp; | |
3024 | ||
8e07c86e AD |
3025 | # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we |
3026 | # regenerate the Makefiles, MAP_STATIC and the dependencies for | |
3027 | # extralibs.all are computed correctly | |
fed7345c | 3028 | push @m, " |
fed7345c | 3029 | MAP_LINKCMD = $linkcmd |
8e07c86e | 3030 | MAP_PERLINC = @{$perlinc || []} |
fed7345c | 3031 | MAP_STATIC = ", |
4633a7c4 | 3032 | join(" \\\n\t", reverse sort keys %static), " |
8e07c86e AD |
3033 | |
3034 | MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib} | |
fed7345c | 3035 | "; |
232e078e | 3036 | |
8e07c86e AD |
3037 | if (defined $libperl) { |
3038 | ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/; | |
3039 | } | |
3040 | unless ($libperl && -f $lperl) { # Could quite follow your idea her, Ilya | |
3041 | my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE"; | |
4633a7c4 | 3042 | $libperl ||= "libperl$self->{LIB_EXT}"; |
8e07c86e | 3043 | $libperl = "$dir/$libperl"; |
4633a7c4 | 3044 | $lperl ||= "libperl$self->{LIB_EXT}"; |
8e07c86e AD |
3045 | $lperl = "$dir/$lperl"; |
3046 | print STDOUT "Warning: $libperl not found | |
3047 | If you're going to build a static perl binary, make sure perl is installed | |
3048 | otherwise ignore this warning\n" | |
3049 | unless (-f $lperl || defined($self->{PERL_SRC})); | |
40000a8c | 3050 | } |
fed7345c | 3051 | |
40000a8c AD |
3052 | push @m, " |
3053 | MAP_LIBPERL = $libperl | |
fed7345c | 3054 | "; |
fed7345c | 3055 | |
40000a8c | 3056 | push @m, " |
8e07c86e | 3057 | \$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)." |
0d8023a2 | 3058 | $self->{NOECHO}$self->{RM_F} \$\@ |
3059 | $self->{NOECHO}\$(TOUCH) \$\@ | |
5d94fbed AD |
3060 | "; |
3061 | ||
8e07c86e AD |
3062 | my $catfile; |
3063 | foreach $catfile (@$extra){ | |
3064 | push @m, "\tcat $catfile >> \$\@\n"; | |
5d94fbed AD |
3065 | } |
3066 | ||
3067 | push @m, " | |
4633a7c4 LW |
3068 | \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all |
3069 | \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS) | |
0d8023a2 | 3070 | $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call' |
3071 | $self->{NOECHO}echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)' | |
3072 | $self->{NOECHO}echo 'To remove the intermediate files say' | |
3073 | $self->{NOECHO}echo ' make -f $makefilename map_clean' | |
40000a8c | 3074 | |
4633a7c4 | 3075 | $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c |
40000a8c | 3076 | "; |
4633a7c4 | 3077 | push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n"; |
fed7345c AD |
3078 | |
3079 | push @m, qq{ | |
3080 | $tmp/perlmain.c: $makefilename}, q{ | |
0d8023a2 | 3081 | }.$self->{NOECHO}.q{echo Writing $@ |
3082 | }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\ | |
40000a8c AD |
3083 | writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@ |
3084 | ||
3085 | }; | |
fed7345c | 3086 | |
5d94fbed | 3087 | # We write EXTRA outside the perl program to have it eval'd by the shell |
40000a8c AD |
3088 | push @m, q{ |
3089 | doc_inst_perl: | |
0d8023a2 | 3090 | }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod |
3091 | }.$self->{NOECHO}.q{$(FULLPERL) -e 'use ExtUtils::MakeMaker; MY->new->writedoc("Perl binary",' \\ | |
232e078e | 3092 | -e '"$(MAP_TARGET)", "MAP_STATIC=$(MAP_STATIC)",' \\ |
005c1a0e | 3093 | -e '"MAP_EXTRA=@ARGV", "MAP_LIBPERL=$(MAP_LIBPERL)")' \\ |
8e07c86e | 3094 | -- `cat $(INST_ARCHAUTODIR)/extralibs.all` >> $(INSTALLARCHLIB)/perllocal.pod |
fed7345c AD |
3095 | }; |
3096 | ||
3097 | push @m, qq{ | |
40000a8c AD |
3098 | inst_perl: pure_inst_perl doc_inst_perl |
3099 | ||
3100 | pure_inst_perl: \$(MAP_TARGET) | |
8e07c86e | 3101 | $self->{CP} \$(MAP_TARGET) \$(INSTALLBIN)/\$(MAP_TARGET) |
fed7345c | 3102 | |
e50aee73 | 3103 | clean :: map_clean |
40000a8c AD |
3104 | |
3105 | map_clean : | |
4633a7c4 | 3106 | $self->{RM_F} $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all |
fed7345c AD |
3107 | }; |
3108 | ||
3109 | join '', @m; | |
3110 | } | |
a0d0e21e | 3111 | |
005c1a0e AD |
3112 | sub extliblist { |
3113 | my($self,$libs) = @_; | |
8e07c86e AD |
3114 | unless (ref $self){ |
3115 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
3116 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
3117 | } | |
005c1a0e | 3118 | require ExtUtils::Liblist; |
8e07c86e | 3119 | ExtUtils::Liblist::ext($libs, $ExtUtils::MakeMaker::Verbose); |
a0d0e21e LW |
3120 | } |
3121 | ||
8e07c86e AD |
3122 | # --- Make-Directories section (internal method) --- |
3123 | # dir_target(@array) returns a Makefile entry for the file .exists in each | |
3124 | # named directory. Returns nothing, if the entry has already been processed. | |
3125 | # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar". | |
864a5fa8 AD |
3126 | # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the |
3127 | # prerequisite, because there has to be one, something that doesn't change | |
8e07c86e AD |
3128 | # too often :) |
3129 | ||
3130 | sub dir_target { | |
3131 | my($self,@dirs) = @_; | |
3132 | unless (ref $self){ | |
3133 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
3134 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
3135 | } | |
3136 | my(@m,$dir); | |
3137 | foreach $dir (@dirs) { | |
3138 | next if $self->{DIR_TARGET}{$self}{$dir}++; | |
3139 | push @m, " | |
3140 | $dir/.exists :: \$(PERL) | |
0d8023a2 | 3141 | $self->{NOECHO}\$(MKPATH) $dir |
c07a80fd | 3142 | $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) \$(PERL) $dir/.exists |
0d8023a2 | 3143 | $self->{NOECHO}-\$(CHMOD) 755 $dir |
8e07c86e AD |
3144 | "; |
3145 | } | |
3146 | join "", @m; | |
3147 | } | |
3148 | ||
42793c05 | 3149 | # --- Output postprocessing section --- |
8e07c86e | 3150 | # nicetext is included to make VMS support easier |
42793c05 TB |
3151 | sub nicetext { # Just return the input - no action needed |
3152 | my($self,$text) = @_; | |
8e07c86e AD |
3153 | unless (ref $self){ |
3154 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
3155 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
3156 | } | |
42793c05 TB |
3157 | $text; |
3158 | } | |
fed7345c | 3159 | |
8e07c86e AD |
3160 | sub needs_linking { # Does this module need linking? Looks into |
3161 | # subdirectory objects (see also has_link_code() | |
3162 | my($self) = shift; | |
3163 | my($child,$caller); | |
3164 | $caller = (caller(0))[3]; | |
3165 | unless (ref $self){ | |
3166 | ExtUtils::MakeMaker::TieAtt::warndirectuse($caller); | |
3167 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
3168 | } | |
3169 | Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/; | |
3170 | return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING}; | |
3171 | # print "DEBUG:\n"; | |
3172 | # print Carp::longmess(); | |
3173 | # print "EO_DEBUG\n"; | |
4633a7c4 | 3174 | if ($self->has_link_code or $self->{MAKEAPERL}){ |
8e07c86e AD |
3175 | $self->{NEEDS_LINKING} = 1; |
3176 | return 1; | |
3177 | } | |
3178 | foreach $child (keys %{$self->{CHILDREN}}) { | |
3179 | if ($self->{CHILDREN}->{$child}->needs_linking) { | |
3180 | $self->{NEEDS_LINKING} = 1; | |
3181 | return 1; | |
3182 | } | |
3183 | } | |
3184 | return $self->{NEEDS_LINKING} = 0; | |
3185 | } | |
3186 | ||
3187 | sub has_link_code { | |
3188 | my($self) = shift; | |
3189 | return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE}; | |
4633a7c4 | 3190 | if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){ |
8e07c86e AD |
3191 | $self->{HAS_LINK_CODE} = 1; |
3192 | return 1; | |
3193 | } | |
3194 | return $self->{HAS_LINK_CODE} = 0; | |
3195 | } | |
3196 | ||
3197 | # --- perllocal.pod section --- | |
3198 | sub writedoc { | |
3199 | my($self,$what,$name,@attribs)=@_; | |
3200 | unless (ref $self){ | |
3201 | ExtUtils::MakeMaker::TieAtt::warndirectuse((caller(0))[3]); | |
3202 | $self = $ExtUtils::MakeMaker::Parent[-1]; | |
3203 | } | |
0d8023a2 | 3204 | my($time) = localtime; |
8e07c86e AD |
3205 | print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n"; |
3206 | print join "\n\n=item *\n\n", map("C<$_>",@attribs); | |
3207 | print "\n\n=back\n\n"; | |
3208 | } | |
3209 | ||
0d8023a2 | 3210 | sub catdir { shift; my $result = join('/',@_); $result =~ s:/+:/:g; $result; } |
3211 | sub catfile { shift; my $result = join('/',@_); $result =~ s:/+:/:g; $result; } | |
8e07c86e AD |
3212 | |
3213 | package ExtUtils::MM_OS2; | |
3214 | ||
3215 | #use Config; | |
3216 | #use Cwd; | |
3217 | #use File::Basename; | |
3218 | require Exporter; | |
3219 | ||
3220 | Exporter::import('ExtUtils::MakeMaker', | |
c07a80fd | 3221 | qw( $Verbose &neatvalue)); |
8e07c86e AD |
3222 | |
3223 | sub dlsyms { | |
3224 | my($self,%attribs) = @_; | |
3225 | ||
3226 | my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}; | |
3227 | my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || []; | |
3228 | my(@m); | |
3229 | (my $boot = $self->{NAME}) =~ s/:/_/g; | |
3230 | ||
3231 | if (not $self->{SKIPHASH}{'dynamic'}) { | |
3232 | push(@m," | |
c07a80fd | 3233 | $self->{BASEEXT}.def: Makefile.PL |
3234 | ",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\ | |
3235 | Mksymlists("NAME" => "',$self->{NAME},'", "DLBASE" => "',$self->{DLBASE}, | |
3236 | '", "DL_FUNCS" => ',neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\' | |
3237 | '); | |
8e07c86e | 3238 | } |
8e07c86e | 3239 | join('',@m); |
40000a8c AD |
3240 | } |
3241 | ||
0d8023a2 | 3242 | sub replace_manpage_separator { |
8e07c86e AD |
3243 | my($self,$man) = @_; |
3244 | $man =~ s,/+,.,g; | |
3245 | $man; | |
3246 | } | |
005c1a0e | 3247 | |
4633a7c4 LW |
3248 | sub maybe_command { |
3249 | my($self,$file) = @_; | |
4e68a208 AD |
3250 | return $file if -x $file && ! -d _; |
3251 | return "$file.exe" if -x "$file.exe" && ! -d _; | |
3252 | return "$file.cmd" if -x "$file.cmd" && ! -d _; | |
4633a7c4 LW |
3253 | return; |
3254 | } | |
3255 | ||
4e68a208 AD |
3256 | sub file_name_is_absolute { |
3257 | my($self,$file) = @_; | |
3258 | $file =~ m{^([a-z]:)?[\\/]}i ; | |
3259 | } | |
3260 | ||
3261 | ||
005c1a0e AD |
3262 | # the following keeps AutoSplit happy |
3263 | package ExtUtils::MakeMaker; | |
3264 | 1; | |
3265 | ||
3266 | __END__ | |
3267 | ||
3268 | =head1 NAME | |
3269 | ||
3270 | ExtUtils::MakeMaker - create an extension Makefile | |
3271 | ||
3272 | =head1 SYNOPSIS | |
3273 | ||
3274 | C<use ExtUtils::MakeMaker;> | |
3275 | ||
3276 | C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );> | |
3277 | ||
8e07c86e AD |
3278 | which is really |
3279 | ||
3280 | C<MM-E<gt>new(\%att)-E<gt>flush;> | |
3281 | ||
005c1a0e AD |
3282 | =head1 DESCRIPTION |
3283 | ||
3284 | This utility is designed to write a Makefile for an extension module | |
3285 | from a Makefile.PL. It is based on the Makefile.SH model provided by | |
3286 | Andy Dougherty and the perl5-porters. | |
3287 | ||
3288 | It splits the task of generating the Makefile into several subroutines | |
3289 | that can be individually overridden. Each subroutine returns the text | |
3290 | it wishes to have written to the Makefile. | |
3291 | ||
4633a7c4 LW |
3292 | =head2 Hintsfile support |
3293 | ||
005c1a0e | 3294 | MakeMaker.pm uses the architecture specific information from |
8e07c86e AD |
3295 | Config.pm. In addition it evaluates architecture specific hints files |
3296 | in a C<hints/> directory. The hints files are expected to be named | |
3297 | like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file | |
3298 | name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by | |
3299 | MakeMaker within the WriteMakefile() subroutine, and can be used to | |
3300 | execute commands as well as to include special variables. The rules | |
3301 | which hintsfile is chosen are the same as in Configure. | |
3302 | ||
4633a7c4 LW |
3303 | The hintsfile is eval()ed immediately after the arguments given to |
3304 | WriteMakefile are stuffed into a hash reference $self but before this | |
3305 | reference becomes blessed. So if you want to do the equivalent to | |
3306 | override or create an attribute you would say something like | |
3307 | ||
3308 | $self->{LIBS} = ['-ldbm -lucb -lc']; | |
3309 | ||
8e07c86e AD |
3310 | =head2 What's new in version 5 of MakeMaker |
3311 | ||
3312 | MakeMaker 5 is pure object oriented. This allows us to write an | |
3313 | unlimited number of Makefiles with a single perl process. 'perl | |
3314 | Makefile.PL' with MakeMaker 5 goes through all subdirectories | |
3315 | immediately and evaluates any Makefile.PL found in the next level | |
3316 | subdirectories. The benefit of this approach comes in useful for both | |
3317 | single and multi directories extensions. | |
3318 | ||
3319 | Multi directory extensions have an immediately visible speed | |
3320 | advantage, because there's no startup penalty for any single | |
3321 | subdirectory Makefile. | |
3322 | ||
3323 | Single directory packages benefit from the much improved | |
3324 | needs_linking() method. As the main Makefile knows everything about | |
3325 | the subdirectories, a needs_linking() method can now query all | |
3326 | subdirectories if there is any linking involved down in the tree. The | |
3327 | speedup for PM-only Makefiles seems to be around 1 second on my | |
3328 | Indy 100 MHz. | |
3329 | ||
3330 | =head2 Incompatibilities between MakeMaker 5.00 and 4.23 | |
3331 | ||
3332 | There are no incompatibilities in the short term, as all changes are | |
3333 | accompanied by short-term workarounds that guarantee full backwards | |
3334 | compatibility. | |
3335 | ||
4633a7c4 | 3336 | You are likely to face a few warnings that expose deprecations which |
8e07c86e AD |
3337 | will result in incompatibilities in the long run: |
3338 | ||
3339 | You should not use %att directly anymore. Instead any subroutine you | |
3340 | override in the MY package will be called by the object method, so you | |
3341 | can access all object attributes directly via the object in $_[0]. | |
3342 | ||
3343 | You should not call the class methos MM->something anymore. Instead | |
3344 | you should call the superclass. Something like | |
3345 | ||
3346 | sub MY::constants { | |
3347 | my $self = shift; | |
8e07c86e AD |
3348 | $self->MM::constants(); |
3349 | } | |
3350 | ||
3351 | Especially the libscan() and exescan() methods should be altered | |
3352 | towards OO programming, that means do not expect that $_ to contain | |
3353 | the path but rather $_[1]. | |
3354 | ||
3355 | You should program with more care. Watch out for any MakeMaker | |
3356 | variables. Do not try to alter them, somebody else might depend on | |
3357 | them. E.g. do not overwrite the ExtUtils::MakeMaker::VERSION variable | |
3358 | (this happens if you import it and then set it to the version number | |
3359 | of your package), do not expect that the INST_LIB variable will be | |
3360 | ./blib (do not 'unshift @INC, "./blib" and do not use | |
3361 | "blib/FindBin.pm"). Do not croak in your Makefile.PL, let it fail with | |
3362 | a warning instead. | |
3363 | ||
3364 | Try to build several extensions simultanously to debug your | |
3365 | Makefile.PL. You can unpack a bunch of distributed packages, so your | |
3366 | directory looks like | |
3367 | ||
3368 | Alias-1.00/ Net-FTP-1.01a/ Set-Scalar-0.001/ | |
3369 | ExtUtils-Peek-0.4/ Net-Ping-1.00/ SetDualVar-1.0/ | |
3370 | Filter-1.06/ NetTools-1.01a/ Storable-0.1/ | |
3371 | GD-1.00/ Religion-1.04/ Sys-Domain-1.05/ | |
3372 | MailTools-1.03/ SNMP-1.5b/ Term-ReadLine-0.7/ | |
3373 | ||
3374 | and write a dummy Makefile.PL that contains nothing but | |
3375 | ||
3376 | use ExtUtils::MakeMaker; | |
3377 | WriteMakefile(); | |
3378 | ||
3379 | That's actually fun to watch :) | |
3380 | ||
3381 | Final suggestion: Try to delete all of your MY:: subroutines and | |
3382 | watch, if you really still need them. MakeMaker might already do what | |
3383 | you want without them. That's all about it. | |
3384 | ||
005c1a0e AD |
3385 | |
3386 | =head2 Default Makefile Behaviour | |
3387 | ||
3388 | The automatically generated Makefile enables the user of the extension | |
3389 | to invoke | |
3390 | ||
3391 | perl Makefile.PL # optionally "perl Makefile.PL verbose" | |
3392 | make | |
8e07c86e AD |
3393 | make test # optionally set TEST_VERBOSE=1 |
3394 | make install # See below | |
005c1a0e AD |
3395 | |
3396 | The Makefile to be produced may be altered by adding arguments of the | |
3397 | form C<KEY=VALUE>. If the user wants to work with a different perl | |
8e07c86e | 3398 | than the default, this can be achieved with |
005c1a0e AD |
3399 | |
3400 | perl Makefile.PL PERL=/tmp/myperl5 | |
3401 | ||
3402 | Other interesting targets in the generated Makefile are | |
3403 | ||
3404 | make config # to check if the Makefile is up-to-date | |
8e07c86e AD |
3405 | make clean # delete local temp files (M |