This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
This is my patch patch.1k for perl5.001.
[perl5.git] / lib / ExtUtils / MakeMaker.pm
CommitLineData
a0d0e21e
LW
1package ExtUtils::MakeMaker;
2
005c1a0e
AD
3$Version = 4.15; # Last edited $Date: 1995/06/06 14:04:00 $ by Andreas Koenig
4
5$Version_OK = 4.13; # Makefiles older than $Version_OK will die
6 # (Will be checked from MakeMaker version 4.13 onwards)
7
8# $Id: MakeMaker.pm,v 1.21 1995/06/06 06:14:16 k Exp k $
a0d0e21e
LW
9
10use Config;
42793c05
TB
11use Carp;
12use Cwd;
13
a0d0e21e
LW
14require Exporter;
15@ISA = qw(Exporter);
005c1a0e
AD
16@EXPORT = qw(&WriteMakefile $Verbose &prompt);
17@EXPORT_OK = qw($Version &Version_check %att %skip %Recognized_Att_Keys
3edbfbe5 18 @MM_Sections %MM_Sections
005c1a0e 19 &help &neatvalue &mkbootstrap &mksymlists);
a0d0e21e 20
42793c05
TB
21$Is_VMS = $Config{'osname'} eq 'VMS';
22require ExtUtils::MM_VMS if $Is_VMS;
a0d0e21e 23
42793c05 24use strict qw(refs);
a0d0e21e 25
42793c05 26$Version = $Version;# avoid typo warning
a0d0e21e 27$Verbose = 0;
a0d0e21e
LW
28$^W=1;
29
005c1a0e
AD
30sub prompt {
31 my($mess,$def)=@_;
32 local $\="";
33 local $/="\n";
34 local $|=1;
35 die "prompt function called without an argument" unless defined $mess;
36 $def = "" unless defined $def;
37 my $dispdef = "[$def] ";
38 print "$mess $dispdef";
39 chop(my $ans = <STDIN>);
40 $ans || $def;
41}
42793c05 42
1aef975c 43sub check_hints {
5d94fbed 44 # We allow extension-specific hints files.
1aef975c
AD
45
46 # First we look for the best hintsfile we have
47 my(@goodhints);
48 my($hint)="$Config{'osname'}_$Config{'osvers'}";
49 $hint =~ s/\./_/g;
50 $hint =~ s/_$//;
005c1a0e 51 local(*DIR);
1aef975c
AD
52 opendir DIR, "hints";
53 while (defined ($_ = readdir DIR)) {
54 next if /^\./;
fed7345c 55 next unless s/\.pl$//;
1aef975c
AD
56 next unless /^$Config{'osname'}/;
57 # Don't trust a hintfile for a later OS version:
58 next if $_ gt $hint;
59 push @goodhints, $_;
60 if ($_ eq $hint){
61 @goodhints=$_;
62 last;
63 }
64 }
65 closedir DIR;
66 return unless @goodhints; # There was no hintsfile
67 # the last one in lexical ordering is our choice:
5d94fbed 68 $hint=(sort @goodhints)[-1];
1aef975c
AD
69
70 # execute the hintsfile:
748a9306
LW
71 open HINTS, "hints/$hint.pl";
72 @goodhints = <HINTS>;
73 close HINTS;
5d94fbed 74 print STDOUT "Processing hints file hints/$hint.pl";
748a9306 75 eval join('',@goodhints);
5d94fbed 76 print STDOUT $@ if $@;
1aef975c 77}
42793c05
TB
78
79# Setup dummy package:
80# MY exists for overriding methods to be defined within
81unshift(@MY::ISA, qw(MM));
82
83# Dummy package MM inherits actual methods from OS-specific
84# default packages. We use this intermediate package so
85# MY->func() can call MM->func() and get the proper
86# default routine without having to know under what OS
87# it's running.
88unshift(@MM::ISA, $Is_VMS ? qw(ExtUtils::MM_VMS MM_Unix) : qw(MM_Unix));
89
90$Attrib_Help = <<'END';
91 NAME: Perl module name for this extension (DBD::Oracle)
75f92628
AD
92 This will default to the directory name but should
93 be explicitly defined in the Makefile.PL.
42793c05
TB
94
95 DISTNAME: Your name for distributing the package (by tar file)
96 This defaults to NAME above.
97
98 VERSION: Your version number for distributing the package.
99 This defaults to 0.1.
100
005c1a0e
AD
101 INST_LIB: Perl library directory to directly install
102 into during 'make'.
103
104 INSTALLPRIVLIB:Used by 'make install', which sets INST_LIB to this value.
105
106 INST_ARCHLIB: Perl architecture-dependent library to directly install
107 into during 'make'.
108
109 INSTALLARCHLIB:Used by 'make install', which sets INST_ARCHLIB to this value.
110
111 INST_EXE: Directory, where executable scripts should be installed during
112 'make'. Defaults to "./blib", just to have a dummy location
113 during testing. C<make install> will set INST_EXE to INSTALLBIN.
114
115 INSTALLBIN: Used by 'make install' which sets INST_EXE to this value.
42793c05
TB
116
117 PERL_LIB: Directory containing the Perl library to use.
005c1a0e
AD
118
119 PERL_ARCHLIB: Architectur dependent directory containing the Perl library to use.
120
42793c05 121 PERL_SRC: Directory containing the Perl source code
e1666bf5 122 (use of this should be avoided, it may be undefined)
42793c05
TB
123
124 INC: Include file dirs eg: '-I/usr/5include -I/path/to/inc'
005c1a0e 125
42793c05 126 DEFINE: something like "-DHAVE_UNISTD_H"
005c1a0e 127
42793c05
TB
128 OBJECT: List of object files, defaults to '$(BASEEXT).o',
129 but can be a long string containing all object files,
130 e.g. "tkpBind.o tkpButton.o tkpCanvas.o"
005c1a0e 131
42793c05
TB
132 MYEXTLIB: If the extension links to a library that it builds
133 set this to the name of the library (see SDBM_File)
134
135 LIBS: An anonymous array of alternative library specifications
136 to be searched for (in order) until at least one library
137 is found.
138 'LIBS' => [ "-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs" ]
139 Mind, that any element of the array contains a complete
140 set of arguments for the ld command. So do not specify
141 'LIBS' => ["-ltcl", "-ltk", "-lX11" ], #wrong
142 See ODBM_File/Makefile.PL for an example, where an
143 array is needed. If you specify a scalar as in
144 'LIBS' => "-ltcl -ltk -lX11"
145 MakeMaker will turn it into an array with one element.
146
3edbfbe5
TB
147 LDFROM: defaults to "$(OBJECT)" and is used in the ld command
148 to specify what files to link/load from
149 (also see dynamic_lib below for how to specify ld flags)
42793c05
TB
150
151 DIR: Ref to array of subdirectories containing Makefile.PLs
152 e.g. [ 'sdbm' ] in ext/SDBM_File
153
75f92628
AD
154 PMLIBDIRS: Ref to array of subdirectories containing library files.
155 Defaults to [ 'lib', $(BASEEXT) ]. The directories will
40000a8c 156 be scanned and any files they contain will
75f92628
AD
157 be installed in the corresponding location in the library.
158 A MY::libscan() function can be used to alter the behaviour.
159 Defining PM in the Makefile.PL will override PMLIBDIRS.
160
42793c05
TB
161 PM: Hashref of .pm files and *.pl files to be installed.
162 e.g. { 'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm' }
163 By default this will include *.pm and *.pl. If a lib directory
164 exists and is not listed in DIR (above) then any *.pm and
165 *.pl files it contains will also be included by default.
75f92628 166 Defining PM in the Makefile.PL will override PMLIBDIRS.
42793c05
TB
167
168 XS: Hashref of .xs files. MakeMaker will default this.
169 e.g. { 'name_of_file.xs' => 'name_of_file.c' }
170 The .c files will automatically be included in the list
171 of files deleted by a make clean.
172
173 C: Ref to array of *.c file names. Initialised from a directory scan
174 and the values portion of the XS attribute hash. This is not
175 currently used by MakeMaker but may be handy in Makefile.PLs.
176
177 H: Ref to array of *.h file names. Similar to C: above.
178
232e078e
AD
179 PL_FILES: Ref to hash of files to be processed as perl programs. MakeMaker
180 will default to any found C<*.PL> file (except C<Makefile.PL>) being
181 keys and the basename of the file being the value. E.g.
182 C<{ 'foobar.PL' => 'foobar' }>. The C<*.PL> files are expected to
183 produce output to the target files themselves.
184
40000a8c 185 EXE_FILES: Ref to array of executable files. The files will be copied to
005c1a0e
AD
186 the INST_EXE directory. Make realclean will delete them from
187 there again.
40000a8c 188
42793c05
TB
189 LINKTYPE: =>'static' or 'dynamic' (default unless usedl=undef in config.sh)
190 Should only be used to force static linking (also see linkext below).
191
1aef975c
AD
192 DL_FUNCS: Hashref of symbol names for routines to be made available as
193 universal symbols. Each key/value pair consists of the package
194 name and an array of routine names in that package. Used only
195 under AIX (export lists) and VMS (linker options) at present.
196 The routine names supplied will be expanded in the same way
197 as XSUB names are expanded by the XS() macro.
198 Defaults to { "$(NAME)" => [ "boot_$(NAME)" ] }.
199 (e.g. { "RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )],
200 "NetconfigPtr" => [ 'DESTROY'] } )
201
202 DL_VARS: Array of symbol names for variables to be made available as
203 universal symbols. Used only under AIX (export lists) and VMS
204 (linker options) at present. Defaults to [].
205 (e.g. [ qw( Foo_version Foo_numstreams Foo_tree ) ])
fed7345c 206
42793c05 207 CONFIG: =>[qw(archname manext)] defines ARCHNAME & MANEXT from config.sh
005c1a0e 208
42793c05
TB
209 SKIP: =>[qw(name1 name2)] skip (do not write) sections of the Makefile
210
40000a8c
AD
211 MAP_TARGET: If it is intended, that a new perl binary be produced, this variable
212 may hold a name for that binary. Defaults to C<perl>
213
214 LIBPERL_A: The filename of the perllibrary that will be used together
215 with this extension. Defaults to C<libperl.a>.
216
42793c05
TB
217 PERL:
218 FULLPERL:
219
220Additional lowercase attributes can be used to pass parameters to the
221methods which implement that part of the Makefile. These are not
222normally required:
223
005c1a0e 224 macro: {ANY_MACRO => ANY_VALUE, ...}
42793c05
TB
225 installpm: {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'}
226 linkext: {LINKTYPE => 'static', 'dynamic' or ''}
75f92628 227 dynamic_lib: {ARMAYBE => 'ar', OTHERLDFLAGS => '...'}
42793c05 228 clean: {FILES => "*.xyz foo"}
3edbfbe5 229 realclean: {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
005c1a0e 230 dist: {TARFLAGS=>'cvfF', COMPRESS=>'gzip', SUFFIX=>'gz', SHAR=>'shar -m'}
42793c05
TB
231 tool_autosplit: {MAXLEN => 8}
232END
233
3edbfbe5
TB
234sub help {print $Attrib_Help;}
235
42793c05
TB
236@MM_Sections_spec = (
237 'post_initialize' => {},
42793c05 238 'const_config' => {},
1aef975c 239 'constants' => {},
42793c05
TB
240 'const_loadlibs' => {},
241 'const_cccmd' => {},
242 'tool_autosplit' => {},
243 'tool_xsubpp' => {},
244 'tools_other' => {},
005c1a0e 245 'macro' => {},
42793c05 246 'post_constants' => {},
232e078e 247 'pasthru' => {},
42793c05
TB
248 'c_o' => {},
249 'xs_c' => {},
250 'xs_o' => {},
251 'top_targets' => {},
252 'linkext' => {},
1aef975c 253 'dlsyms' => {},
42793c05
TB
254 'dynamic' => {},
255 'dynamic_bs' => {},
256 'dynamic_lib' => {},
257 'static' => {},
258 'static_lib' => {},
259 'installpm' => {},
232e078e 260 'processPL' => {},
40000a8c 261 'installbin' => {},
42793c05
TB
262 'subdirs' => {},
263 'clean' => {},
264 'realclean' => {},
5d94fbed 265 'dist' => {},
42793c05
TB
266 'test' => {},
267 'install' => {},
268 'force' => {},
269 'perldepend' => {},
270 'makefile' => {},
271 'postamble' => {},
fed7345c 272 'staticmake' => {},
42793c05
TB
273);
274%MM_Sections = @MM_Sections_spec; # looses section ordering
275@MM_Sections = grep(!ref, @MM_Sections_spec); # keeps order
276
277%Recognized_Att_Keys = %MM_Sections; # All sections are valid keys.
278foreach(split(/\n/,$Attrib_Help)){
279 chomp;
280 next unless m/^\s*(\w+):\s*(.*)/;
281 $Recognized_Att_Keys{$1} = $2;
282 print "Attribute '$1' => '$2'\n" if ($Verbose >= 2);
283}
284
285%att = ();
286%skip = ();
287
288sub skipcheck{
289 my($section) = @_;
1aef975c 290 if ($section eq 'dynamic') {
fed7345c 291 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets "
1aef975c
AD
292 . "in skipped section 'dynamic_bs'\n"
293 if $skip{'dynamic_bs'} && $Verbose;
fed7345c 294 print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets "
1aef975c
AD
295 . "in skipped section 'dynamic_lib'\n"
296 if $skip{'dynamic_lib'} && $Verbose;
297 }
298 if ($section eq 'dynamic_lib') {
fed7345c 299 print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on "
1aef975c
AD
300 . "targets in skipped section 'dynamic_bs'\n"
301 if $skip{'dynamic_bs'} && $Verbose;
302 }
303 if ($section eq 'static') {
fed7345c 304 print STDOUT "Warning (non-fatal): Target 'static' depends on targets "
1aef975c
AD
305 . "in skipped section 'static_lib'\n"
306 if $skip{'static_lib'} && $Verbose;
307 }
42793c05
TB
308 return 'skipped' if $skip{$section};
309 return '';
310}
311
312
313sub WriteMakefile {
a0d0e21e
LW
314 %att = @_;
315 local($\)="\n";
316
005c1a0e
AD
317 print STDOUT "MakeMaker (v$Version)" if $Verbose;
318
319 if ( Carp::longmess("") =~ "runsubdirpl" ){
320 $Correct_relativ_directories++;
321 } else {
322 $Correct_relativ_directories=0;
323 }
324
325 if (-f "MANIFEST"){
326 eval {require ExtUtils::Manifest};
327 if ($@){
328 print STDOUT "Warning: you have not installed the ExtUtils::Manifest
329 module -- skipping check of the MANIFEST file";
330 } else {
331 print STDOUT "Checking if your kit is complete...";
332 $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning
333 my(@missed)=ExtUtils::Manifest::manicheck();
334 if (@missed){
335 print STDOUT "Warning: the following files are missing in your kit:";
336 print "\t", join "\n\t", @missed;
337 print STDOUT "Please inform the author.\n";
338 } else {
339 print STDOUT "Looks good";
340 }
341 }
342 }
a0d0e21e 343
42793c05
TB
344 parse_args(\%att, @ARGV);
345 my(%initial_att) = %att; # record initial attributes
5d94fbed
AD
346
347 check_hints();
348
232e078e 349 my($key);
a0d0e21e 350
75f92628 351 MY->init_main();
a0d0e21e 352
42793c05 353 print STDOUT "Writing Makefile for $att{NAME}";
a0d0e21e 354
005c1a0e
AD
355 if (! $att{PERL_SRC} &&
356 $INC{'Config.pm'} ne "$Config{'archlib'}/Config.pm"){
357 (my $pthinks = $INC{'Config.pm'}) =~ s!/Config\.pm$!!;
358 $pthinks =~ s!.*/!!;
359 print STDOUT <<END;
360Your perl and your Config.pm seem to have different ideas about the architecture
361they are running on.
362Perl thinks: $pthinks
363Config says: $Config{"archname"}
364This may or may not cause problems. Please check your installation of perl if you
365have problems building this extension.
366END
367 }
368
75f92628
AD
369 MY->init_dirscan();
370 MY->init_others();
371
42793c05
TB
372 unlink("Makefile", "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : '');
373 open MAKE, ">MakeMaker.tmp" or die "Unable to open MakeMaker.tmp: $!";
374 select MAKE; $|=1; select STDOUT;
a0d0e21e 375
42793c05 376 print MAKE "# This Makefile is for the $att{NAME} extension to perl.\n#";
75f92628 377 print MAKE "# It was generated automatically by MakeMaker version $Version from the contents";
42793c05
TB
378 print MAKE "# of Makefile.PL. Don't edit this file, edit Makefile.PL instead.";
379 print MAKE "#\n# ANY CHANGES MADE HERE WILL BE LOST! \n#";
380 print MAKE "# MakeMaker Parameters: ";
381 foreach $key (sort keys %initial_att){
382 my($v) = neatvalue($initial_att{$key});
383 $v =~ tr/\n/ /s;
384 print MAKE "# $key => $v";
385 }
a0d0e21e 386
42793c05
TB
387 # build hash for SKIP to make testing easy
388 %skip = map( ($_,1), @{$att{'SKIP'} || []});
389
232e078e 390 my $section;
42793c05
TB
391 foreach $section ( @MM_Sections ){
392 print "Processing Makefile '$section' section" if ($Verbose >= 2);
393 my($skipit) = skipcheck($section);
394 if ($skipit){
395 print MAKE "\n# --- MakeMaker $section section $skipit.";
396 } else {
397 my(%a) = %{$att{$section} || {}};
398 print MAKE "\n# --- MakeMaker $section section:";
5d94fbed 399 print MAKE "# ", join ", ", %a if $Verbose;
42793c05
TB
400 print(MAKE MY->nicetext(MY->$section( %a )));
401 }
402 }
a0d0e21e 403
42793c05
TB
404 if ($Verbose){
405 print MAKE "\n# Full list of MakeMaker attribute values:";
406 foreach $key (sort keys %att){
407 my($v) = neatvalue($att{$key});
408 $v =~ tr/\n/ /s;
409 print MAKE "# $key => $v";
410 }
411 }
a0d0e21e 412
42793c05 413 print MAKE "\n# End.";
a0d0e21e 414 close MAKE;
42793c05
TB
415 my($finalname) = $Is_VMS ? "Descrip.MMS" : "Makefile";
416 rename("MakeMaker.tmp", $finalname);
417
418 chmod 0644, $finalname;
419 system("$Config{'eunicefix'} $finalname") unless $Config{'eunicefix'} eq ":";
a0d0e21e
LW
420
421 1;
422}
423
005c1a0e
AD
424sub Version_check {
425 my($checkversion) = @_;
426 die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
427Current Version is $Version. There have been considerable changes in the meantime.
428Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n" if $checkversion < $Version_OK;
429 print STDOUT "Makefile built with ExtUtils::MakeMaker v $checkversion. Current Version is $Version." unless $checkversion == $Version;
a0d0e21e
LW
430}
431
1aef975c
AD
432sub mksymlists{
433 %att = @_;
434 parse_args(\%att, @ARGV);
435 MY->mksymlists(@_);
436}
a0d0e21e 437
005c1a0e
AD
438# The following mkbootstrap() is only for installations that are calling
439# the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker
440# write Makefiles, that use ExtUtils::Mkbootstrap directly.
441sub mkbootstrap{
442 parse_args(\%att, @ARGV);
443 MY->init_main() unless defined $att{BASEEXT};
444 eval {require ExtUtils::Mkbootstrap};
445 if ($@){
446 # Very difficult to arrive here, I suppose
447 carp "Error: $@\nVersion mismatch: This MakeMaker (v$Version) needs the ExtUtils::Mkbootstrap package. Please check your installation.";
448 }
449 ExtUtils::Mkbootstrap::Mkbootstrap($att{BASEEXT},@_);
450}
451
42793c05
TB
452sub parse_args{
453 my($attr, @args) = @_;
454 foreach (@args){
75f92628
AD
455 unless (m/(.*?)=(.*)/){
456 help(),exit 1 if m/^help$/;
457 ++$Verbose if m/^verb/;
458 next;
459 }
460 my($name, $value) = ($1, $2);
461 if ($value =~ m/^~(\w+)?/){ # tilde with optional username
005c1a0e
AD
462 $value =~ s [^~(\w*)]
463 [$1 ?
464 ((getpwnam($1))[7] || "~$1") :
465 (getpwuid($>))[7]
466 ]ex;
467 }
468 if ($Correct_relativ_directories){
469 # This is experimental, so we don't care for efficiency
470 my @dirs = qw(INST_LIB INST_ARCHLIB INST_EXE);
471 my %dirs;
472 @dirs{@dirs}=@dirs;
473 if ($dirs{$name} && $value !~ m!^/!){ # a relativ directory
474 $value = "../$value";
475 }
75f92628 476 }
005c1a0e 477
75f92628 478 $$attr{$name} = $value;
42793c05
TB
479 }
480 # catch old-style 'potential_libs' and inform user how to 'upgrade'
481 if (defined $$attr{'potential_libs'}){
482 my($msg)="'potential_libs' => '$$attr{potential_libs}' should be";
483 if ($$attr{'potential_libs'}){
fed7345c 484 print STDOUT "$msg changed to:\n\t'LIBS' => ['$$attr{potential_libs}']\n";
42793c05 485 } else {
fed7345c 486 print STDOUT "$msg deleted.\n";
42793c05
TB
487 }
488 $$attr{LIBS} = [$$attr{'potential_libs'}];
489 delete $$attr{'potential_libs'};
490 }
491 # catch old-style 'ARMAYBE' and inform user how to 'upgrade'
492 if (defined $$attr{'ARMAYBE'}){
493 my($armaybe) = $$attr{'ARMAYBE'};
fed7345c 494 print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n",
42793c05
TB
495 "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n";
496 my(%dl) = %{$$attr{'dynamic_lib'} || {}};
497 $$attr{'dynamic_lib'} = { %dl, ARMAYBE => $armaybe};
498 delete $$attr{'ARMAYBE'};
499 }
75f92628 500 if (defined $$attr{'LDTARGET'}){
fed7345c 501 print STDOUT "LDTARGET should be changed to LDFROM\n";
75f92628
AD
502 $$attr{'LDFROM'} = $$attr{'LDTARGET'};
503 delete $$attr{'LDTARGET'};
504 }
42793c05
TB
505 foreach(sort keys %{$attr}){
506 print STDOUT " $_ => ".neatvalue($$attr{$_}) if ($Verbose);
fed7345c 507 print STDOUT "'$_' is not a known MakeMaker parameter name.\n"
42793c05
TB
508 unless exists $Recognized_Att_Keys{$_};
509 }
a0d0e21e
LW
510}
511
512
42793c05
TB
513sub neatvalue{
514 my($v) = @_;
fed7345c 515 return "undef" unless defined $v;
42793c05
TB
516 my($t) = ref $v;
517 return "'$v'" unless $t;
518 return "[ ".join(', ',map("'$_'",@$v))." ]" if ($t eq 'ARRAY');
519 return "$v" unless $t eq 'HASH';
520 my(@m, $key, $val);
521 push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v);
522 return "{ ".join(', ',@m)." }";
523}
524
42793c05 525# ------ Define the MakeMaker default methods in package MM_Unix ------
a0d0e21e 526
42793c05 527package MM_Unix;
a0d0e21e
LW
528
529use Config;
42793c05
TB
530use Cwd;
531use File::Basename;
a0d0e21e
LW
532require Exporter;
533
42793c05
TB
534Exporter::import('ExtUtils::MakeMaker',
535 qw(%att %skip %Recognized_Att_Keys $Verbose));
a0d0e21e 536
42793c05
TB
537# These attributes cannot be overridden externally
538@Other_Att_Keys{qw(EXTRALIBS BSLOADLIBS LDLOADLIBS)} = (1) x 3;
a0d0e21e 539
42793c05 540if ($Is_VMS = $Config{'osname'} eq 'VMS') {
748a9306
LW
541 require VMS::Filespec;
542 import VMS::Filespec 'vmsify';
a0d0e21e
LW
543}
544
545
75f92628 546sub init_main {
005c1a0e
AD
547 my($self) = @_;
548
42793c05
TB
549 # Find out directory name. This may contain the extension name.
550 my($pwd) = fastcwd(); # from Cwd.pm
005c1a0e
AD
551 # --- Initialize Module Name and Paths
552
553 # NAME = The perl module name for this extension (eg DBD::Oracle).
554 # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
555 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
556 # ROOTEXT = Directory part of FULLEXT with leading /.
557 unless($att{NAME}){ # we have to guess our name
558 my($name) = $pwd;
559 if ($Is_VMS) {
560 $name =~ s:.*?([^.\]]+)\]:$1: unless ($name =~ s:.*[.\[]ext\.(.*)\]:$1:i);
561 ($att{NAME}=$name) =~ s#[.\]]#::#g;
562 } else {
563 $name =~ s:.*/:: unless ($name =~ s:^.*/ext/::);
564 ($att{NAME} =$name) =~ s#/#::#g;
565 }
566 }
567 ($att{FULLEXT} =$att{NAME}) =~ s#::#/#g ; #eg. BSD/Foo/Socket
568 ($att{BASEEXT} =$att{NAME}) =~ s#.*::##; #eg. Socket
569 ($att{ROOTEXT} =$att{FULLEXT}) =~ s#/?\Q$att{BASEEXT}\E$## ; # eg. /BSD/Foo
570 $att{ROOTEXT} = ($Is_VMS ? '' : '/') . $att{ROOTEXT} if $att{ROOTEXT};
42793c05 571
005c1a0e
AD
572
573 # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
574
575 # *Real* information: where did we get these two from? ...
576 my $inc_config_dir = dirname($INC{'Config.pm'});
577 my $inc_carp_dir = dirname($INC{'Carp.pm'});
578
579 # Typically PERL_* and INST_* will be identical but that need
580 # not be the case (e.g., installing into project libraries etc).
42793c05
TB
581
582 # Perl Macro: With source No source
583 # PERL_LIB ../../lib /usr/local/lib/perl5
584 # PERL_ARCHLIB ../../lib /usr/local/lib/perl5/sun4-sunos
e1666bf5 585 # PERL_SRC ../.. (undefined)
42793c05 586
005c1a0e
AD
587 # INST Macro: For standard for any other
588 # modules module
3edbfbe5
TB
589 # INST_LIB ../../lib ./blib
590 # INST_ARCHLIB ../../lib ./blib
42793c05
TB
591
592 unless ($att{PERL_SRC}){
005c1a0e
AD
593 foreach (qw(../.. ../../.. ../../../..)){
594 if ( -f "$_/config.sh"
595 && -f "$_/perl.h"
596 && -f "$_/lib/Exporter.pm") {
232e078e
AD
597 $att{PERL_SRC}=$_ ;
598 last;
599 }
a0d0e21e 600 }
a0d0e21e 601 }
42793c05 602 unless ($att{PERL_SRC}){
42793c05
TB
603 # we should also consider $ENV{PERL5LIB} here
604 $att{PERL_LIB} = $Config{'privlib'} unless $att{PERL_LIB};
605 $att{PERL_ARCHLIB} = $Config{'archlib'} unless $att{PERL_ARCHLIB};
e1666bf5 606 $att{PERL_INC} = "$att{PERL_ARCHLIB}/CORE"; # wild guess for now
005c1a0e
AD
607 die <<EOM unless (-f "$att{PERL_INC}/perl.h");
608Error: Unable to locate installed Perl libraries or Perl source code.
609
610It is recommended that you install perl in a standard location before
611building extensions. You can say:
612
613 $^X Makefile.PL PERL_SRC=/path/to/perl/source/directory
614
615if you have not yet installed perl but still want to build this
616extension now.
617EOM
618
619 print STDOUT "Using header files found in $att{PERL_INC}" if $Verbose && $self->needs_linking;
620
621 } else { # PERL_SRC is defined here...
622
42793c05
TB
623 $att{PERL_LIB} = "$att{PERL_SRC}/lib" unless $att{PERL_LIB};
624 $att{PERL_ARCHLIB} = $att{PERL_LIB};
e1666bf5 625 $att{PERL_INC} = $att{PERL_SRC};
232e078e
AD
626 # catch an situation that has occurred a few times in the past:
627 warn <<EOM unless -s "$att{PERL_SRC}/cflags";
628You cannot build extensions below the perl source tree after executing
629a 'make clean' in the perl source tree.
630
631To rebuild extensions distributed with the perl source you should
632simply Configure (to include those extensions) and then build perl as
633normal. After installing perl the source tree can be deleted. It is not
634needed for building extensions.
635
636It is recommended that you unpack and build additional extensions away
637from the perl source tree.
638EOM
42793c05
TB
639 }
640
641 # INST_LIB typically pre-set if building an extension after
642 # perl has been built and installed. Setting INST_LIB allows
005c1a0e 643 # you to build directly into, say $Config{'privlib'}.
3edbfbe5
TB
644 unless ($att{INST_LIB}){
645 if (defined $att{PERL_SRC}) {
005c1a0e
AD
646# require ExtUtils::Manifest;
647# my $file;
648 my $standard = 0;
649# my $mani = ExtUtils::Manifest::maniread("$att{PERL_SRC}/MANIFEST");
650# foreach $file (keys %$mani){
651# if ($file =~ m!^ext/\Q$att{FULLEXT}!){
652# $standard++;
653# last;
654# }
655# }
656
657#### Temporary solution for perl5.001f:
658$standard = 1;
659#### This is just the same as was MakeMaker 4.094, but everything's prepared to
660#### switch to a different behaviour after 5.001f
661
662 if ($standard){
663 $att{INST_LIB} = $att{PERL_LIB};
664 } else {
665 $att{INST_LIB} = "./blib";
666 print STDOUT <<END;
667Warning: The $att{NAME} extension will not be installed by 'make install' in the
668perl source directory. Please install it with 'make install' from the
669 $pwd
670directory.
671END
672 }
3edbfbe5 673 } else {
232e078e 674 $att{INST_LIB} = "./blib";
3edbfbe5
TB
675 }
676 }
42793c05
TB
677 # Try to work out what INST_ARCHLIB should be if not set:
678 unless ($att{INST_ARCHLIB}){
679 my(%archmap) = (
232e078e 680 "./blib" => "./blib", # our private build lib
42793c05
TB
681 $att{PERL_LIB} => $att{PERL_ARCHLIB},
682 $Config{'privlib'} => $Config{'archlib'},
42793c05
TB
683 $inc_carp_dir => $inc_config_dir,
684 );
685 $att{INST_ARCHLIB} = $archmap{$att{INST_LIB}};
75f92628
AD
686 unless($att{INST_ARCHLIB}){
687 # Oh dear, we'll have to default it and warn the user
688 my($archname) = $Config{'archname'};
689 if (-d "$att{INST_LIB}/$archname"){
690 $att{INST_ARCHLIB} = "$att{INST_LIB}/$archname";
fed7345c 691 print STDOUT "Defaulting INST_ARCHLIB to INST_LIB/$archname\n";
75f92628
AD
692 } else {
693 $att{INST_ARCHLIB} = $att{INST_LIB};
fed7345c 694 print STDOUT "Warning: Defaulting INST_ARCHLIB to INST_LIB ",
75f92628
AD
695 "(not architecture independent).\n";
696 }
697 }
42793c05 698 }
005c1a0e 699 $att{INST_EXE} = "./blib" unless $att{INST_EXE};
42793c05 700
005c1a0e
AD
701 if( $att{INSTALLPRIVLIB} && ! $att{INSTALLARCHLIB} ){
702 my($archname) = $Config{'archname'};
703 if (-d "$att{INSTALLPRIVLIB}/$archname"){
704 $att{INSTALLARCHLIB} = "$att{INSTALLPRIVLIB}/$archname";
705 print STDOUT "Defaulting INSTALLARCHLIB to INSTALLPRIVLIB/$archname\n";
42793c05 706 } else {
005c1a0e
AD
707 $att{INSTALLARCHLIB} = $att{INSTALLPRIVLIB};
708 print STDOUT "Warning: Defaulting INSTALLARCHLIB to INSTALLPRIVLIB ",
709 "(not architecture independent).\n";
42793c05
TB
710 }
711 }
005c1a0e
AD
712 $att{INSTALLPRIVLIB} ||= $Config{'installprivlib'};
713 $att{INSTALLARCHLIB} ||= $Config{'installarchlib'};
714 $att{INSTALLBIN} ||= $Config{'installbin'};
715
716 $att{MAP_TARGET} = "perl" unless $att{MAP_TARGET};
717 $att{LIBPERL_A} = $Is_VMS ? 'libperl.olb' : 'libperl.a'
718 unless $att{LIBPERL_A};
719
720 # make a few simple checks
721 warn "Warning: PERL_LIB ($att{PERL_LIB}) seems not to be a perl library directory
722 (Exporter.pm not found)"
723 unless (-f "$att{PERL_LIB}/Exporter.pm");
42793c05 724
fed7345c 725 ($att{DISTNAME}=$att{NAME}) =~ s#(::)#-#g unless $att{DISTNAME};
42793c05 726 $att{VERSION} = "0.1" unless $att{VERSION};
005c1a0e 727 ($att{VERSION_SYM} = $att{VERSION}) =~ s/\W/_/g;
42793c05
TB
728
729
730 # --- Initialize Perl Binary Locations
731
732 # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
75f92628
AD
733 # will be working versions of perl 5. miniperl has priority over perl
734 # for PERL to ensure that $(PERL) is usable while building ./ext/*
005c1a0e
AD
735 $att{'PERL'} =
736 MY->find_perl(5.0, ['miniperl','perl','perl5',"perl$]" ],
737 [ grep defined $_, $att{PERL_SRC}, split(":", $ENV{PATH}),
738 $Config{'bin'} ], $Verbose )
739 unless ($att{'PERL'}); # don't check, if perl is executable, maybe they
740 # they have decided to supply switches with perl
a0d0e21e 741
42793c05
TB
742 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
743 ($att{'FULLPERL'} = $att{'PERL'}) =~ s/miniperl/perl/
744 unless ($att{'FULLPERL'} && -x $att{'FULLPERL'});
a0d0e21e 745
42793c05 746 if ($Is_VMS) {
1aef975c
AD
747 $att{'PERL'} = 'MCR ' . vmsify($att{'PERL'});
748 $att{'FULLPERL'} = 'MCR ' . vmsify($att{'FULLPERL'});
42793c05 749 }
75f92628 750}
42793c05 751
42793c05 752
f06db76b 753sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
75f92628 754
232e078e 755 my($name, %dir, %xs, %c, %h, %ignore, %pl_files);
75f92628
AD
756 local(%pm); #the sub in find() has to see this hash
757 $ignore{'test.pl'} = 1;
758 $ignore{'makefile.pl'} = 1 if $Is_VMS;
759 foreach $name (lsdir(".")){
760 next if ($name =~ /^\./ or $ignore{$name});
761 if (-d $name){
762 $dir{$name} = $name if (-f "$name/Makefile.PL");
763 } elsif ($name =~ /\.xs$/){
764 my($c); ($c = $name) =~ s/\.xs$/.c/;
765 $xs{$name} = $c;
766 $c{$c} = 1;
767 } elsif ($name =~ /\.c$/){
768 $c{$name} = 1;
769 } elsif ($name =~ /\.h$/){
770 $h{$name} = 1;
f06db76b 771 } elsif ($name =~ /\.(p[ml]|pod)$/){
75f92628 772 $pm{$name} = "\$(INST_LIBDIR)/$name";
232e078e
AD
773 } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
774 ($pl_files{$name} = $name) =~ s/\.PL$// ;
3edbfbe5 775 }
75f92628 776 }
3edbfbe5 777
75f92628
AD
778 # Some larger extensions often wish to install a number of *.pm/pl
779 # files into the library in various locations.
780
781 # The attribute PMLIBDIRS holds an array reference which lists
782 # subdirectories which we should search for library files to
783 # install. PMLIBDIRS defaults to [ 'lib', $att{BASEEXT} ].
784 # We recursively search through the named directories (skipping
785 # any which don't exist or contain Makefile.PL files).
786
787 # For each *.pm or *.pl file found MY->libscan() is called with
788 # the default installation path in $_. The return value of libscan
789 # defines the actual installation location.
790 # The default libscan function simply returns $_.
791 # The file is skipped if libscan returns false.
792
793 # The default installation location passed to libscan in $_ is:
794 #
795 # ./*.pm => $(INST_LIBDIR)/*.pm
796 # ./xyz/... => $(INST_LIBDIR)/xyz/...
797 # ./lib/... => $(INST_LIB)/...
798 #
799 # In this way the 'lib' directory is seen as the root of the actual
800 # perl library whereas the others are relative to INST_LIBDIR
801 # (which includes ROOTEXT). This is a subtle distinction but one
802 # that's important for nested modules.
803
804 $att{PMLIBDIRS} = [ 'lib', $att{BASEEXT} ] unless $att{PMLIBDIRS};
805
806 #only existing directories that aren't in $dir are allowed
807 @{$att{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$att{PMLIBDIRS}};
808
809 if (@{$att{PMLIBDIRS}}){
810 print "Searching PMLIBDIRS: @{$att{PMLIBDIRS}}"
811 if ($Verbose >= 2);
812 use File::Find; # try changing to require !
813 File::Find::find(sub {
fed7345c
AD
814# We now allow any file in PMLIBDIRS to be installed. nTk needs that, and
815# we should allow it.
816# return unless m/\.p[ml]$/;
817 return if -d $_; # anything else that Can't be copied?
75f92628 818 my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
40000a8c
AD
819 my $striplibpath;
820 $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^lib/::);
821 local($_) = "$prefix/$striplibpath";
75f92628
AD
822 my($inst) = MY->libscan();
823 print "libscan($path) => '$inst'" if ($Verbose >= 2);
824 return unless $inst;
1aef975c 825 $pm{$path} = $inst;
75f92628 826 }, @{$att{PMLIBDIRS}});
42793c05
TB
827 }
828
75f92628
AD
829 $att{DIR} = [sort keys %dir] unless $att{DIRS};
830 $att{XS} = \%xs unless $att{XS};
831 $att{PM} = \%pm unless $att{PM};
832 $att{C} = [sort keys %c] unless $att{C};
1aef975c
AD
833 my(@o_files) = @{$att{C}};
834 my($sufx) = $Is_VMS ? '.obj' : '.o';
835 $att{O_FILES} = [grep s/\.c$/$sufx/, @o_files] ;
75f92628 836 $att{H} = [sort keys %h] unless $att{H};
232e078e 837 $att{PL_FILES} = \%pl_files unless $att{PL_FILES};
75f92628
AD
838}
839
840
841sub libscan {
005c1a0e 842 return '' if m:/RCS/: ; # return undef triggered warnings with $Verbose>=2
75f92628
AD
843 $_;
844}
845
75f92628 846sub init_others { # --- Initialize Other Attributes
232e078e 847 my($key);
42793c05 848 for $key (keys(%Recognized_Att_Keys), keys(%Other_Att_Keys)){
a0d0e21e 849 # avoid warnings for uninitialized vars
42793c05
TB
850 next if exists $att{$key};
851 $att{$key} = "";
a0d0e21e
LW
852 }
853
42793c05
TB
854 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $att{'LIBS'}
855 # Lets look at $att{LIBS} carefully: It may be an anon array, a string or
856 # undefined. In any case we turn it into an anon array:
857 $att{LIBS}=[] unless $att{LIBS};
858 $att{LIBS}=[$att{LIBS}] if ref \$att{LIBS} eq SCALAR;
005c1a0e 859 $att{LD_RUN_PATH} = "";
42793c05
TB
860 foreach ( @{$att{'LIBS'}} ){
861 s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
862 my(@libs) = MY->extliblist($_);
863 if ($libs[0] or $libs[1] or $libs[2]){
864 @att{EXTRALIBS, BSLOADLIBS, LDLOADLIBS} = @libs;
005c1a0e
AD
865 if ($libs[2]) {
866 $att{LD_RUN_PATH} = join(":",grep($_=~s/^-L//,split(" ", $libs[2])));
867 }
42793c05
TB
868 last;
869 }
870 }
a0d0e21e 871
fed7345c 872 print STDOUT "CONFIG must be an array ref\n"
42793c05
TB
873 if ($att{CONFIG} and ref $att{CONFIG} ne 'ARRAY');
874 $att{CONFIG} = [] unless (ref $att{CONFIG});
875 push(@{$att{CONFIG}},
005c1a0e
AD
876 qw(cc libc ldflags lddlflags ccdlflags cccdlflags
877 ranlib so dlext dlsrc
42793c05
TB
878 ));
879 push(@{$att{CONFIG}}, 'shellflags') if $Config{'shellflags'};
880
881 if ($Is_VMS) {
42793c05
TB
882 $att{OBJECT} = '$(BASEEXT).obj' unless $att{OBJECT};
883 $att{OBJECT} =~ s/[^,\s]\s+/, /g;
884 $att{OBJECT} =~ s/\n+/, /g;
1aef975c 885 $att{OBJECT} =~ s#\.o,#\.obj,#;
42793c05
TB
886 } else {
887 $att{OBJECT} = '$(BASEEXT).o' unless $att{OBJECT};
888 $att{OBJECT} =~ s/\n+/ \\\n\t/g;
a0d0e21e 889 }
42793c05 890 $att{BOOTDEP} = (-f "$att{BASEEXT}_BS") ? "$att{BASEEXT}_BS" : "";
e1666bf5 891 $att{LD} = ($Config{'ld'} || 'ld') unless $att{LD};
3edbfbe5 892 $att{LDFROM} = '$(OBJECT)' unless $att{LDFROM};
1aef975c
AD
893 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
894 # the 'dynamic' section of MM. We don't have this problem with
895 # 'static', since we either must use it (%Config says we can't
896 # use dynamic loading) or the caller asked for it explicitly.
897 if (!$att{LINKTYPE}) {
898 $att{LINKTYPE} = grep(/dynamic/,@{$att{SKIP} || []})
899 ? 'static'
900 : ($Config{'usedl'} ? 'dynamic' : 'static');
901 };
42793c05 902
3edbfbe5
TB
903 # These get overridden for VMS and maybe some other systems
904 $att{NOOP} = "";
1aef975c 905 $att{MAKEFILE} = "Makefile";
3edbfbe5
TB
906 $att{RM_F} = "rm -f";
907 $att{RM_RF} = "rm -rf";
908 $att{TOUCH} = "touch";
909 $att{CP} = "cp";
75f92628 910 $att{MV} = "mv";
005c1a0e 911 $att{CHMOD} = "chmod";
a0d0e21e
LW
912}
913
914
42793c05 915sub lsdir{
3edbfbe5 916 my($dir, $regex) = @_;
42793c05
TB
917 local(*DIR, @ls);
918 opendir(DIR, $_[0] || ".") or die "opendir: $!";
919 @ls = readdir(DIR);
920 closedir(DIR);
3edbfbe5 921 @ls = grep(/$regex/, @ls) if $regex;
42793c05
TB
922 @ls;
923}
924
925
926sub find_perl{
927 my($self, $ver, $names, $dirs, $trace) = @_;
928 my($name, $dir);
5d94fbed 929 if ($trace >= 2){
fed7345c
AD
930 print "Looking for perl $ver by these names: ";
931 print "@$names, ";
932 print "in these dirs:";
933 print "@$dirs";
934 }
42793c05 935 foreach $dir (@$dirs){
3edbfbe5 936 next unless defined $dir; # $att{PERL_SRC} may be undefined
42793c05 937 foreach $name (@$names){
748a9306 938 print "Checking $dir/$name " if ($trace >= 2);
42793c05
TB
939 if ($Is_VMS) {
940 $name .= ".exe" unless -x "$dir/$name";
941 }
942 next unless -x "$dir/$name";
5d94fbed 943 print "Executing $dir/$name" if ($trace >= 2);
42793c05
TB
944 my($out);
945 if ($Is_VMS) {
946 my($vmscmd) = 'MCR ' . vmsify("$dir/$name");
947 $out = `$vmscmd -e "require $ver; print ""VER_OK\n"""`;
948 } else {
949 $out = `$dir/$name -e 'require $ver; print "VER_OK\n" ' 2>&1`;
950 }
5d94fbed 951 if ($out =~ /VER_OK/) {
005c1a0e 952 print "Using PERL=$dir/$name" if $trace;
5d94fbed
AD
953 return "$dir/$name";
954 }
a0d0e21e
LW
955 }
956 }
fed7345c 957 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
42793c05 958 0; # false and not empty
a0d0e21e
LW
959}
960
961
962sub post_initialize{
963 "";
964}
fed7345c 965
005c1a0e
AD
966sub needs_linking { # Does this module need linking?
967 return 1 if $att{OBJECT} or @{$att{C} || []} or $att{MYEXTLIB};
968 return 0;
969}
a0d0e21e
LW
970
971sub constants {
005c1a0e 972 my($self) = @_;
a0d0e21e
LW
973 my(@m);
974
a0d0e21e 975 push @m, "
42793c05 976NAME = $att{NAME}
a0d0e21e
LW
977DISTNAME = $att{DISTNAME}
978VERSION = $att{VERSION}
005c1a0e 979VERSION_SYM = $att{VERSION_SYM}
a0d0e21e 980
005c1a0e
AD
981# In which directory should we put this extension during 'make'?
982# This is typically ./blib.
42793c05
TB
983# (also see INST_LIBDIR and relationship to ROOTEXT)
984INST_LIB = $att{INST_LIB}
985INST_ARCHLIB = $att{INST_ARCHLIB}
40000a8c 986INST_EXE = $att{INST_EXE}
42793c05 987
005c1a0e
AD
988# AFS users will want to set the installation directories for
989# the final 'make install' early without setting INST_LIB,
990# INST_ARCHLIB, and INST_EXE for the testing phase
991INSTALLPRIVLIB = $att{INSTALLPRIVLIB}
992INSTALLARCHLIB = $att{INSTALLARCHLIB}
993INSTALLBIN = $att{INSTALLBIN}
994
42793c05
TB
995# Perl library to use when building the extension
996PERL_LIB = $att{PERL_LIB}
997PERL_ARCHLIB = $att{PERL_ARCHLIB}
40000a8c 998LIBPERL_A = $att{LIBPERL_A}
005c1a0e
AD
999
1000MAKEMAKER = \$(PERL_LIB)/ExtUtils/MakeMaker.pm
1001MM_VERSION = $ExtUtils::MakeMaker::Version
75f92628 1002";
42793c05 1003
75f92628
AD
1004 # Define I_PERL_LIBS to include the required -Ipaths
1005 # To be cute we only include PERL_ARCHLIB if different
005c1a0e
AD
1006
1007 #### Deprecated from Version 4.11: We want to avoid different
1008 #### behavior for variables with make(1) and perl(1)
1009
75f92628
AD
1010 # To be portable we add quotes for VMS
1011 my(@i_perl_libs) = qw{-I$(PERL_ARCHLIB) -I$(PERL_LIB)};
1012 shift(@i_perl_libs) if ($att{PERL_ARCHLIB} eq $att{PERL_LIB});
1013 if ($Is_VMS){
1014 push @m, "I_PERL_LIBS = \"".join('" "',@i_perl_libs)."\"\n";
1015 } else {
1016 push @m, "I_PERL_LIBS = ".join(' ',@i_perl_libs)."\n";
1017 }
1018
1019 push @m, "
fed7345c
AD
1020# Where is the perl source code located?
1021PERL_SRC = $att{PERL_SRC}\n" if $att{PERL_SRC};
1022
1023 push @m, "
42793c05 1024# Perl header files (will eventually be under PERL_LIB)
e1666bf5 1025PERL_INC = $att{PERL_INC}
42793c05
TB
1026# Perl binaries
1027PERL = $att{'PERL'}
1028FULLPERL = $att{'FULLPERL'}
75f92628
AD
1029";
1030 push @m, "
42793c05
TB
1031# FULLEXT = Pathname for extension directory (eg DBD/Oracle).
1032# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
1033# ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
1034FULLEXT = $att{FULLEXT}
1035BASEEXT = $att{BASEEXT}
1036ROOTEXT = $att{ROOTEXT}
75f92628
AD
1037";
1038 push @m, "
a0d0e21e
LW
1039INC = $att{INC}
1040DEFINE = $att{DEFINE}
1041OBJECT = $att{OBJECT}
3edbfbe5 1042LDFROM = $att{LDFROM}
a0d0e21e 1043LINKTYPE = $att{LINKTYPE}
a0d0e21e 1044
75f92628
AD
1045# Handy lists of source code files:
1046XS_FILES= ".join(" \\\n\t", sort keys %{$att{XS}})."
1047C_FILES = ".join(" \\\n\t", @{$att{C}})."
1aef975c 1048O_FILES = ".join(" \\\n\t", @{$att{O_FILES}})."
75f92628 1049H_FILES = ".join(" \\\n\t", @{$att{H}})."
a0d0e21e 1050
42793c05 1051.SUFFIXES: .xs
a0d0e21e 1052
42793c05
TB
1053.PRECIOUS: Makefile
1054
005c1a0e
AD
1055.NO_PARALLEL:
1056
75f92628 1057.PHONY: all config static dynamic test linkext
42793c05
TB
1058
1059# This extension may link to it's own library (see SDBM_File)
1060MYEXTLIB = $att{MYEXTLIB}
1061
75f92628
AD
1062# Where is the Config information that we are using/depend on
1063CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h
a0d0e21e
LW
1064";
1065
1066 push @m, '
1067# Where to put things:
42793c05
TB
1068INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
1069INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
1070
3edbfbe5
TB
1071INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
1072INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
1073';
42793c05 1074
005c1a0e
AD
1075 if ($self->needs_linking) {
1076 push @m, '
75f92628 1077INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT).a
42793c05 1078INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(BASEEXT).$(DLEXT)
75f92628 1079INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
005c1a0e
AD
1080';
1081 } else {
1082 push @m, '
1083INST_STATIC =
1084INST_DYNAMIC =
1085INST_BOOT =
1086';
1087 }
1088
1089 push @m, '
42793c05
TB
1090INST_PM = '.join(" \\\n\t", sort values %{$att{PM}}).'
1091';
1092
1093 join('',@m);
1094}
1095
232e078e 1096$Const_cccmd=0; # package global
42793c05
TB
1097
1098sub const_cccmd{
40000a8c
AD
1099 my($self,$libperl)=@_;
1100 $libperl or $libperl = $att{LIBPERL_A} || "libperl.a" ;
75f92628
AD
1101 # This is implemented in the same manner as extliblist,
1102 # e.g., do both and compare results during the transition period.
1103 my($cc,$ccflags,$optimize,$large,$split, $shflags)
1104 = @Config{qw(cc ccflags optimize large split shellflags)};
232e078e
AD
1105 my($optdebug)="";
1106
75f92628 1107 $shflags = '' unless $shflags;
40000a8c 1108 my($prog, $old, $uc, $perltype);
75f92628 1109
232e078e
AD
1110 unless ($Const_cccmd++){
1111 chop($old = `cd $att{PERL_SRC}; sh $shflags ./cflags $libperl $att{BASEEXT}.c`)
1112 if $att{PERL_SRC};
1113 $Const_cccmd++; # shut up typo warning
1114 }
e1666bf5 1115
40000a8c
AD
1116 my(%map) = (
1117 D => '-DDEBUGGING',
1118 E => '-DEMBED',
1119 DE => '-DDEBUGGING -DEMBED',
1120 M => '-DEMBED -DMULTIPLICITY',
1121 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
1122 );
1123
1124 if ($libperl =~ /libperl(\w*)\.a/){
1125 $uc = uc($1);
1126 } else {
1127 $uc = ""; # avoid warning
1128 }
1129 $perltype = $map{$uc} ? $map{$uc} : "";
1130
1131 if ($uc =~ /^D/) {
1132 $optdebug = "-g";
1133 }
1134
1135
1aef975c
AD
1136 my($name);
1137 ( $name = $att{NAME} . "_cflags" ) =~ s/:/_/g ;
1138 if ($prog = $Config{$name}) {
75f92628 1139 # Expand hints for this extension via the shell
fed7345c 1140 print STDOUT "Processing $name hint:\n" if $Verbose;
75f92628
AD
1141 my(@o)=`cc=\"$cc\"
1142 ccflags=\"$ccflags\"
1143 optimize=\"$optimize\"
40000a8c
AD
1144 perltype=\"$perltype\"
1145 optdebug=\"$optdebug\"
75f92628
AD
1146 large=\"$large\"
1147 split=\"$split\"
1148 eval '$prog'
1149 echo cc=\$cc
1150 echo ccflags=\$ccflags
1151 echo optimize=\$optimize
40000a8c
AD
1152 echo perltype=\$perltype
1153 echo optdebug=\$optdebug
75f92628
AD
1154 echo large=\$large
1155 echo split=\$split
1156 `;
232e078e 1157 my(%cflags,$line);
75f92628
AD
1158 foreach $line (@o){
1159 chomp $line;
1160 if ($line =~ /(.*?)=\s*(.*)\s*$/){
1161 $cflags{$1} = $2;
fed7345c 1162 print STDOUT " $1 = $2" if $Verbose;
75f92628 1163 } else {
fed7345c 1164 print STDOUT "Unrecognised result from hint: '$line'\n";
75f92628
AD
1165 }
1166 }
40000a8c
AD
1167 ( $cc,$ccflags,$perltype,$optdebug,$optimize,$large,$split )=@cflags{
1168 qw( cc ccflags perltype optdebug optimize large split)};
1169 }
1170
1171 if ($optdebug) {
1172 $optimize = $optdebug;
75f92628
AD
1173 }
1174
40000a8c 1175 my($new) = "$cc -c $ccflags $optimize $perltype $large $split";
005c1a0e
AD
1176 $new =~ s/^\s+//; $new =~ s/\s+/ /g; $new =~ s/\s+$//;
1177 if (defined($old)){
1178 $old =~ s/^\s+//; $old =~ s/\s+/ /g; $old =~ s/\s+$//;
1179 if ($new ne $old) {
1180 print STDOUT "Warning (non-fatal): cflags evaluation in "
1181 ."MakeMaker ($ExtUtils::MakeMaker::Version) "
1182 ."differs from shell output\n"
1183 ." package: $att{NAME}\n"
1184 ." old: $old\n"
1185 ." new: $new\n"
1186 ." Using 'old' set.\n"
1187 . Config::myconfig()
1188 ."\nPlease send these details to perl5-porters\@nicoh.com\n";
1189 }
42793c05 1190 }
75f92628 1191 my($cccmd)=($old) ? $old : $new;
f0b7e567 1192 $cccmd =~ s/^\s*\Q$Config{'cc'}\E\s/\$(CC) /;
75f92628 1193 "CCCMD = $cccmd\n";
42793c05
TB
1194}
1195
1196
1197# --- Constants Sections ---
1198
1199sub const_config{
1200 my(@m,$m);
1201 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
1202 my(%once_only);
1203 foreach $m (@{$att{'CONFIG'}}){
1204 next if $once_only{$m};
fed7345c 1205 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
42793c05
TB
1206 unless exists $Config{$m};
1207 push @m, "\U$m\E = $Config{$m}\n";
1208 $once_only{$m} = 1;
1209 }
1210 join('', @m);
1211}
1212
1213
1214sub const_loadlibs{
1215 "
1216# $att{NAME} might depend on some other libraries:
1217# (These comments may need revising:)
1218#
1219# Dependent libraries can be linked in one of three ways:
1220#
1221# 1. (For static extensions) by the ld command when the perl binary
1222# is linked with the extension library. See EXTRALIBS below.
1223#
1224# 2. (For dynamic extensions) by the ld command when the shared
1225# object is built/linked. See LDLOADLIBS below.
1226#
1227# 3. (For dynamic extensions) by the DynaLoader when the shared
1228# object is loaded. See BSLOADLIBS below.
1229#
1230# EXTRALIBS = List of libraries that need to be linked with when
1231# linking a perl binary which includes this extension
1232# Only those libraries that actually exist are included.
1233# These are written to a file and used when linking perl.
1234#
1235# LDLOADLIBS = List of those libraries which can or must be linked into
1236# the shared library when created using ld. These may be
1237# static or dynamic libraries.
005c1a0e
AD
1238# LD_RUN_PATH is a colon separated list of the directories
1239# in LDLOADLIBS. It is passed as an environment variable to
1240# the process that links the shared library.
42793c05
TB
1241#
1242# BSLOADLIBS = List of those libraries that are needed but can be
1243# linked in dynamically at run time on this platform.
1244# SunOS/Solaris does not need this because ld records
1245# the information (from LDLOADLIBS) into the object file.
1246# This list is used to create a .bs (bootstrap) file.
42793c05
TB
1247#
1248EXTRALIBS = $att{'EXTRALIBS'}
1249LDLOADLIBS = $att{'LDLOADLIBS'}
1250BSLOADLIBS = $att{'BSLOADLIBS'}
005c1a0e 1251LD_RUN_PATH= $att{'LD_RUN_PATH'}
a0d0e21e 1252";
42793c05 1253}
a0d0e21e 1254
a0d0e21e 1255
42793c05 1256# --- Tool Sections ---
a0d0e21e 1257
42793c05
TB
1258sub tool_autosplit{
1259 my($self, %attribs) = @_;
1260 my($asl) = "";
1261 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
1262 q{
42793c05 1263# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
005c1a0e 1264AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
42793c05
TB
1265};
1266}
a0d0e21e 1267
a0d0e21e 1268
42793c05 1269sub tool_xsubpp{
e1666bf5
TB
1270 my($xsdir) = '$(PERL_LIB)/ExtUtils';
1271 # drop back to old location if xsubpp is not in new location yet
1272 $xsdir = '$(PERL_SRC)/ext' unless (-f "$att{PERL_LIB}/ExtUtils/xsubpp");
1273 my(@tmdeps) = ('$(XSUBPPDIR)/typemap');
42793c05
TB
1274 push(@tmdeps, "typemap") if -f "typemap";
1275 my(@tmargs) = map("-typemap $_", @tmdeps);
1276 "
e1666bf5
TB
1277XSUBPPDIR = $xsdir
1278XSUBPP = \$(XSUBPPDIR)/xsubpp
42793c05
TB
1279XSUBPPDEPS = @tmdeps
1280XSUBPPARGS = @tmargs
1281";
1282};
a0d0e21e 1283
a0d0e21e 1284
42793c05 1285sub tools_other{
e1666bf5 1286 "
42793c05 1287SHELL = /bin/sh
e1666bf5 1288LD = $att{LD}
3edbfbe5
TB
1289TOUCH = $att{TOUCH}
1290CP = $att{CP}
75f92628 1291MV = $att{MV}
3edbfbe5
TB
1292RM_F = $att{RM_F}
1293RM_RF = $att{RM_RF}
005c1a0e 1294CHMOD = $att{CHMOD}
e1666bf5 1295".q{
42793c05 1296# The following is a portable way to say mkdir -p
75f92628 1297MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){ next if -d $$p; my(@p); foreach(split(/\//,$$p)){ push(@p,$$_); next if -d "@p/"; print "mkdir @p"; mkdir("@p",0777)||die $$! }} exit 0;'
42793c05 1298};
a0d0e21e
LW
1299}
1300
1301
1302sub post_constants{
1303 "";
1304}
1305
005c1a0e
AD
1306sub macro {
1307 my($self,%attribs) = @_;
1308 my(@m,$key,$val);
1309 while (($key,$val) = each %attribs){
1310 push @m, "$key = $val\n";
1311 }
1312 join "", @m;
1313}
1314
232e078e 1315sub pasthru {
005c1a0e
AD
1316 my(@m,$key);
1317 # It has to be considered carefully, which variables are apt
1318 # to be passed through, e.g. ALL RELATIV DIRECTORIES are
1319 # not suited for PASTHRU to subdirectories.
1320 # Moreover: No directories at all have a chance, because we
1321 # don't know yet, if the directories are absolute or relativ
1322
1323 # PASTHRU2 is a conservative approach, that hardly changed
232e078e 1324 # MakeMaker between version 4.086 and 4.09.
005c1a0e
AD
1325
1326 # PASTHRU1 is a revolutionary approach :), it cares for having
1327 # a prepended "../" whenever runsubdirpl is called, but only
1328 # for the three crucial INST_* directories.
1329
1330 my(@pasthru1,@pasthru2); # 1 for runsubdirpl, 2 for the rest
1331
1332 foreach $key (qw(INST_LIB INST_ARCHLIB INST_EXE)){
1333 push @pasthru1, "$key=\"\$($key)\"";
1334 }
1335
1336 foreach $key (qw(INSTALLPRIVLIB INSTALLARCHLIB INSTALLBIN LIBPERL_A LINKTYPE)){
1337 push @pasthru1, "$key=\"\$($key)\"";
1338 push @pasthru2, "$key=\"\$($key)\"";
232e078e 1339 }
005c1a0e
AD
1340
1341 push @m, "\nPASTHRU1 = ", join ("\\\n\t", @pasthru1), "\n";
1342 push @m, "\nPASTHRU2 = ", join ("\\\n\t", @pasthru2), "\n";
232e078e
AD
1343 join "", @m;
1344}
a0d0e21e 1345
42793c05 1346# --- Translation Sections ---
a0d0e21e 1347
42793c05 1348sub c_o {
40000a8c 1349 my(@m);
fed7345c 1350 push @m, '
42793c05
TB
1351.c.o:
1352 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
1353';
fed7345c 1354 join "", @m;
a0d0e21e
LW
1355}
1356
42793c05
TB
1357sub xs_c {
1358 '
1359.xs.c:
005c1a0e 1360 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
42793c05
TB
1361';
1362}
a0d0e21e 1363
42793c05 1364sub xs_o { # many makes are too dumb to use xs_c then c_o
a0d0e21e 1365 '
42793c05 1366.xs.o:
005c1a0e 1367 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
42793c05 1368 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $(INC) $*.c
a0d0e21e
LW
1369';
1370}
1371
1372
42793c05
TB
1373# --- Target Sections ---
1374
1375sub top_targets{
40000a8c 1376 my(@m);
fed7345c 1377 push @m, '
42793c05 1378all :: config linkext $(INST_PM)
3edbfbe5 1379'.$att{NOOP}.'
42793c05 1380
005c1a0e 1381config :: '.$att{MAKEFILE}.' $(INST_LIBDIR)/.exists $(INST_ARCHAUTODIR)/.exists Version_check
a0d0e21e 1382';
fed7345c 1383
005c1a0e 1384 push @m, MM->dir_target('$(INST_LIBDIR)', '$(INST_ARCHAUTODIR)', '$(INST_EXE)');
232e078e 1385
fed7345c
AD
1386 push @m, '
1387$(O_FILES): $(H_FILES)
1388' if @{$att{O_FILES} || []} && @{$att{H} || []};
005c1a0e
AD
1389
1390 push @m, q{
1391help:
1392 $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::MakeMaker "&help"; &help;'
1393};
1394
1395 push @m, q{
1396Version_check:
1397 @$(PERL) -I$(PERL_LIB) -e 'use ExtUtils::MakeMaker qw($$Version &Version_check);' \
1398 -e '&Version_check($(MM_VERSION))'
1399};
1400
fed7345c 1401 join('',@m);
a0d0e21e
LW
1402}
1403
42793c05
TB
1404sub linkext {
1405 my($self, %attribs) = @_;
005c1a0e
AD
1406 # LINKTYPE => static or dynamic or ''
1407 my($linktype) = defined $attribs{LINKTYPE} ?
1408 $attribs{LINKTYPE} : '$(LINKTYPE)';
42793c05
TB
1409 "
1410linkext :: $linktype
3edbfbe5 1411$att{NOOP}
42793c05
TB
1412";
1413}
1414
1aef975c
AD
1415sub dlsyms {
1416 my($self,%attribs) = @_;
1417
40000a8c 1418 return '' if ($Config{'osname'} ne 'aix');
1aef975c
AD
1419
1420 my($funcs) = $attribs{DL_FUNCS} || $att{DL_FUNCS} || {};
1421 my($vars) = $attribs{DL_VARS} || $att{DL_VARS} || [];
1422 my(@m);
1423
1424 push(@m,"
1425dynamic :: $att{BASEEXT}.exp
1426
1427") unless $skip{'dynamic'};
1428
1429 push(@m,"
1430static :: $att{BASEEXT}.exp
1431
1432") unless $skip{'static'};
1433
1434 push(@m,"
1435$att{BASEEXT}.exp: Makefile.PL
005c1a0e 1436",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::MakeMaker qw(&mksymlists); \\
232e078e 1437 &mksymlists(DL_FUNCS => ',
40000a8c 1438 %$funcs ? neatvalue($funcs) : '""',', DL_VARS => ',
fec02dd3 1439 @$vars ? neatvalue($vars) : '""', ", NAME => \"$att{NAME}\")'
fed7345c 1440");
1aef975c
AD
1441
1442 join('',@m);
1443}
42793c05
TB
1444
1445# --- Dynamic Loading Sections ---
a0d0e21e
LW
1446
1447sub dynamic {
1448 '
42793c05
TB
1449# $(INST_PM) has been moved to the all: target.
1450# It remains here for awhile to allow for old usage: "make dynamic"
1aef975c 1451dynamic :: '.$att{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
3edbfbe5 1452'.$att{NOOP}.'
42793c05
TB
1453';
1454}
a0d0e21e 1455
42793c05
TB
1456sub dynamic_bs {
1457 my($self, %attribs) = @_;
005c1a0e 1458 return '' unless $self->needs_linking;
42793c05
TB
1459 '
1460BOOTSTRAP = '."$att{BASEEXT}.bs".'
a0d0e21e 1461
005c1a0e 1462# As Mkbootstrap might not write a file (if none is required)
42793c05
TB
1463# we use touch to prevent make continually trying to remake it.
1464# The DynaLoader only reads a non-empty file.
1aef975c 1465$(BOOTSTRAP): '."$att{MAKEFILE} $att{BOOTDEP}".'
005c1a0e
AD
1466 @ echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
1467 @ $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
1468 -e \'use ExtUtils::Mkbootstrap;\' \
1469 -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\'
fed7345c 1470 @ $(TOUCH) $(BOOTSTRAP)
005c1a0e
AD
1471 $(CHMOD) 644 $@
1472 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
a0d0e21e
LW
1473
1474$(INST_BOOT): $(BOOTSTRAP)
fed7345c 1475 @ '.$att{RM_RF}.' $(INST_BOOT)
40000a8c 1476 -'.$att{CP}.' $(BOOTSTRAP) $(INST_BOOT)
005c1a0e
AD
1477 $(CHMOD) 644 $@
1478 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
a0d0e21e
LW
1479';
1480}
1481
75f92628 1482
42793c05
TB
1483sub dynamic_lib {
1484 my($self, %attribs) = @_;
1485 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
1486 my($armaybe) = $attribs{ARMAYBE} || $att{ARMAYBE} || ":";
3edbfbe5 1487 my($ldfrom) = '$(LDFROM)';
005c1a0e 1488 return '' unless $self->needs_linking;
75f92628
AD
1489 my($osname) = $Config{'osname'};
1490 $armaybe = 'ar' if ($osname eq 'dec_osf' and $armaybe eq ':');
3edbfbe5
TB
1491 my(@m);
1492 push(@m,'
75f92628
AD
1493# This section creates the dynamically loadable $(INST_DYNAMIC)
1494# from $(OBJECT) and possibly $(MYEXTLIB).
42793c05
TB
1495ARMAYBE = '.$armaybe.'
1496OTHERLDFLAGS = '.$otherldflags.'
a0d0e21e 1497
232e078e 1498$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
3edbfbe5
TB
1499');
1500 if ($armaybe ne ':'){
1501 $ldfrom = "tmp.a";
1502 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
1503 push(@m,' $(RANLIB) '."$ldfrom\n");
1504 }
75f92628 1505 $ldfrom = "-all $ldfrom -none" if ($osname eq 'dec_osf');
005c1a0e
AD
1506 push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
1507 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS)');
1508 push @m, '
1509 $(CHMOD) 755 $@
1510 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
1511';
232e078e
AD
1512
1513 push @m, MM->dir_target('$(INST_ARCHAUTODIR)');
3edbfbe5 1514 join('',@m);
a0d0e21e
LW
1515}
1516
1517
42793c05
TB
1518# --- Static Loading Sections ---
1519
1520sub static {
a0d0e21e 1521 '
42793c05
TB
1522# $(INST_PM) has been moved to the all: target.
1523# It remains here for awhile to allow for old usage: "make static"
fed7345c 1524static :: '.$att{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
3edbfbe5 1525'.$att{NOOP}.'
a0d0e21e
LW
1526';
1527}
1528
42793c05 1529sub static_lib{
005c1a0e
AD
1530 my($self) = @_;
1531 return '' unless $self->needs_linking;
42793c05
TB
1532 my(@m);
1533 push(@m, <<'END');
232e078e 1534$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
42793c05
TB
1535END
1536 # If this extension has it's own library (eg SDBM_File)
1537 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3edbfbe5 1538 push(@m, " $att{CP} \$(MYEXTLIB) \$\@\n") if $att{MYEXTLIB};
42793c05
TB
1539
1540 push(@m, <<'END');
1541 ar cr $@ $(OBJECT) && $(RANLIB) $@
75f92628 1542 @echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
005c1a0e
AD
1543 $(CHMOD) 755 $@
1544 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
42793c05 1545END
fed7345c
AD
1546
1547# Old mechanism - still available:
1548
e1666bf5 1549 push(@m, <<'END') if $att{PERL_SRC};
fed7345c 1550 @ echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
e1666bf5 1551END
005c1a0e 1552
232e078e 1553 push @m, MM->dir_target('$(INST_ARCHAUTODIR)');
42793c05
TB
1554 join('', "\n",@m);
1555}
1556
a0d0e21e
LW
1557
1558sub installpm {
42793c05
TB
1559 my($self, %attribs) = @_;
1560 # By default .pm files are split into the architecture independent
1561 # library. This is a good thing. If a specific module requires that
1562 # it's .pm files are split into the architecture specific library
1563 # then it should use: installpm => {SPLITLIB=>'$(INST_ARCHLIB)'}
1564 # Note that installperl currently interferes with this (Config.pm)
1565 # User can disable split by saying: installpm => {SPLITLIB=>''}
1566 my($splitlib) = '$(INST_LIB)'; # NOT arch specific by default
1567 $splitlib = $attribs{SPLITLIB} if exists $attribs{SPLITLIB};
1568 my(@m, $dist);
1569 foreach $dist (sort keys %{$att{PM}}){
1570 my($inst) = $att{PM}->{$dist};
1571 push(@m, "\n# installpm: $dist => $inst, splitlib=$splitlib\n");
1572 push(@m, MY->installpm_x($dist, $inst, $splitlib));
1573 push(@m, "\n");
1574 }
1575 join('', @m);
a0d0e21e
LW
1576}
1577
42793c05
TB
1578sub installpm_x { # called by installpm per file
1579 my($self, $dist, $inst, $splitlib) = @_;
005c1a0e
AD
1580 warn "Warning: Most probably 'make' will have problems processing this file: $inst\n"
1581 if $inst =~ m![:#]!;
42793c05
TB
1582 my($instdir) = $inst =~ m|(.*)/|;
1583 my(@m);
1584 push(@m,"
005c1a0e 1585$inst: $dist $att{MAKEFILE} $instdir/.exists
fed7345c 1586".' @ '.$att{RM_F}.' $@
fed7345c 1587 '."$att{CP} $dist".' $@
005c1a0e
AD
1588 $(CHMOD) 644 $@
1589 @echo $@ >> $(INST_ARCHAUTODIR)/.packlist
42793c05 1590');
40000a8c 1591 push(@m, "\t\@\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
42793c05 1592 if ($splitlib and $inst =~ m/\.pm$/);
232e078e
AD
1593
1594 push @m, MM->dir_target($instdir);
42793c05
TB
1595 join('', @m);
1596}
a0d0e21e 1597
232e078e
AD
1598sub processPL {
1599 return "" unless $att{PL_FILES};
1600 my(@m, $plfile);
1601 foreach $plfile (sort keys %{$att{PL_FILES}}) {
1602 push @m, "
1603all :: $att{PL_FILES}->{$plfile}
1604
1605$att{PL_FILES}->{$plfile} :: $plfile
1606 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
1607";
1608 }
1609 join "", @m;
1610}
1611
40000a8c
AD
1612sub installbin {
1613 return "" unless $att{EXE_FILES} && ref $att{EXE_FILES} eq "ARRAY";
1614 my(@m, $from, $to, %fromto, @to);
1615 for $from (@{$att{EXE_FILES}}) {
1616 local($_)= '$(INST_EXE)/' . basename($from);
1617 $to = MY->exescan();
1618 print "exescan($from) => '$to'" if ($Verbose >=2);
1619 $fromto{$from}=$to;
1620 }
1621 @to = values %fromto;
1622 push(@m, "
1623EXE_FILES = @{$att{EXE_FILES}}
1624
1625all :: @to
1626
1627realclean ::
1628 $att{RM_F} @to
1629");
1630
1631 while (($from,$to) = each %fromto) {
005c1a0e 1632 my $todir = dirname($to);
40000a8c 1633 push @m, "
005c1a0e 1634$to: $from $att{MAKEFILE} $todir/.exists
40000a8c
AD
1635 $att{CP} $from $to
1636";
1637 }
1638 join "", @m;
1639}
42793c05 1640
40000a8c
AD
1641sub exescan {
1642 $_;
1643}
42793c05
TB
1644# --- Sub-directory Sections ---
1645
1646sub subdirs {
1647 my(@m);
1648 # This method provides a mechanism to automatically deal with
1649 # subdirectories containing further Makefile.PL scripts.
1650 # It calls the subdir_x() method for each subdirectory.
5d94fbed
AD
1651 foreach(grep -d, &lsdir()){
1652 next if /^\./;
1653 next unless -f "$_/Makefile\.PL" ;
42793c05
TB
1654 print "Including $_ subdirectory" if ($Verbose);
1655 push(@m, MY->subdir_x($_));
1656 }
1657 if (@m){
1658 unshift(@m, "
1659# The default clean, realclean and test targets in this Makefile
1660# have automatically been given entries for each subdir.
1661
1662all :: subdirs
1663");
1664 } else {
1665 push(@m, "\n# none")
1666 }
1667 join('',@m);
1668}
1669
1670sub runsubdirpl{ # Experimental! See subdir_x section
1671 my($self,$subdir) = @_;
1672 chdir($subdir) or die "chdir($subdir): $!";
1aef975c 1673 ExtUtils::MakeMaker::check_hints();
005c1a0e 1674 package main;
42793c05 1675 require "Makefile.PL";
a0d0e21e
LW
1676}
1677
42793c05
TB
1678sub subdir_x {
1679 my($self, $subdir) = @_;
1680 my(@m);
1681 # The intention is that the calling Makefile.PL should define the
1682 # $(SUBDIR_MAKEFILE_PL_ARGS) make macro to contain whatever
1683 # information needs to be passed down to the other Makefile.PL scripts.
1684 # If this does not suit your needs you'll need to write your own
1685 # MY::subdir_x() method to override this one.
1686 qq{
1aef975c 1687config :: $subdir/$att{MAKEFILE}
005c1a0e 1688 cd $subdir && \$(MAKE) config \$(PASTHRU2) \$(SUBDIR_MAKEFILE_PL_ARGS)
42793c05 1689
1aef975c 1690$subdir/$att{MAKEFILE}: $subdir/Makefile.PL \$(CONFIGDEP)
42793c05 1691}.' @echo "Rebuilding $@ ..."
005c1a0e 1692 @$(PERL) -I"$(PERL_ARCHLIB)" -I"$(PERL_LIB)" \\
42793c05 1693 -e "use ExtUtils::MakeMaker; MM->runsubdirpl(qw('.$subdir.'))" \\
232e078e 1694 $(PASTHRU1) $(SUBDIR_MAKEFILE_PL_ARGS)
42793c05
TB
1695 @echo "Rebuild of $@ complete."
1696'.qq{
1697
1698subdirs ::
005c1a0e 1699 cd $subdir && \$(MAKE) all \$(PASTHRU2)
42793c05
TB
1700
1701};
1702}
1703
1704
1705# --- Cleanup and Distribution Sections ---
1706
1707sub clean {
1708 my($self, %attribs) = @_;
1709 my(@m);
1710 push(@m, '
1711# Delete temporary files but do not touch installed files. We don\'t delete
1712# the Makefile here so a later make realclean still has a makefile to use.
1713
1714clean ::
1715');
1716 # clean subdirectories first
1aef975c 1717 push(@m, map("\t-cd $_ && test -f $att{MAKEFILE} && \$(MAKE) clean\n",@{$att{DIR}}));
75f92628 1718 my(@otherfiles) = values %{$att{XS}}; # .c files from *.xs files
42793c05 1719 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
1aef975c 1720 push(@otherfiles, "./blib");
75f92628 1721 push(@m, " -$att{RM_RF} *~ t/*~ *.o *.a mon.out core so_locations "
40000a8c 1722 ."\$(BOOTSTRAP) \$(BASEEXT).bso \$(BASEEXT).exp @otherfiles\n");
75f92628 1723 # See realclean and ext/utils/make_ext for usage of Makefile.old
1aef975c 1724 push(@m, " -$att{MV} $att{MAKEFILE} $att{MAKEFILE}.old 2>/dev/null\n");
42793c05
TB
1725 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
1726 join("", @m);
1727}
a0d0e21e
LW
1728
1729sub realclean {
42793c05
TB
1730 my($self, %attribs) = @_;
1731 my(@m);
1732 push(@m,'
1733# Delete temporary files (via clean) and also delete installed files
1734realclean purge :: clean
1735');
75f92628 1736 # realclean subdirectories first (already cleaned)
232e078e 1737 my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
75f92628 1738 foreach(@{$att{DIR}}){
1aef975c
AD
1739 push(@m, sprintf($sub,$_,"$att{MAKEFILE}.old","-f $att{MAKEFILE}.old"));
1740 push(@m, sprintf($sub,$_,"$att{MAKEFILE}",''));
75f92628 1741 }
3edbfbe5 1742 push(@m, " $att{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
75f92628
AD
1743 push(@m, " $att{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
1744 push(@m, " $att{RM_F} \$(INST_STATIC) \$(INST_PM)\n");
fed7345c 1745 my(@otherfiles) = ($att{MAKEFILE},
40000a8c 1746 "$att{MAKEFILE}.old"); # Makefiles last
42793c05 1747 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
3edbfbe5 1748 push(@m, " $att{RM_RF} @otherfiles\n") if @otherfiles;
42793c05
TB
1749 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
1750 join("", @m);
1751}
a0d0e21e 1752
42793c05 1753
5d94fbed 1754sub dist {
42793c05 1755 my($self, %attribs) = @_;
005c1a0e 1756 my(@m);
42793c05 1757 # VERSION should be sanitised before use as a file name
005c1a0e
AD
1758 if ($attribs{TARNAME}){
1759 print STDOUT "Error (fatal): Attribute TARNAME for target dist is deprecated
1760Please use DISTNAME and VERSION";
1761 }
1762 my($name) = $attribs{NAME} || '$(DISTNAME)-$(VERSION)';
1763 my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar
1764 my($tarflags) = $attribs{TARFLAGS} || 'cvf';
1765 my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip
1766 my($suffix) = $attribs{SUFFIX} || 'Z'; # eg gz
1767 my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip"
1768 my($preop) = $attribs{PREOP} || '@ :'; # eg update MANIFEST
1769 my($postop) = $attribs{POSTOP} || '@ :'; # eg remove the distdir
1770 my($ci) = $attribs{CI} || 'ci -u';
1771 my($rcs) = $attribs{RCS} || 'rcs -Nv$(VERSION_SYM):';
1772 my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
1773
1774 push @m, "
1775TAR = $tar
1776TARFLAGS = $tarflags
1777COMPRESS = $compress
1778SUFFIX = $suffix
1779SHAR = $shar
1780PREOP = $preop
1781POSTOP = $postop
1782CI = $ci
1783RCS = $rcs
1784DIST_DEFAULT = $dist_default
42793c05 1785";
005c1a0e
AD
1786
1787 push @m, q{
1788distclean :: realclean distcheck
1789
1790distcheck :
1791 $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\
1792 -e 'fullcheck();'
1793
1794manifest :
1795 $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\
1796 -e 'mkmanifest();'
1797
1798dist : $(DIST_DEFAULT)
1799
1800tardist : $(DISTNAME)-$(VERSION).tar.$(SUFFIX)
1801
1802$(DISTNAME)-$(VERSION).tar.$(SUFFIX) : distdir
1803 $(PREOP)
1804 $(TAR) $(TARFLAGS) $(DISTNAME)-$(VERSION).tar $(DISTNAME)-$(VERSION)
1805 $(COMPRESS) $(DISTNAME)-$(VERSION).tar
1806 $(RM_RF) $(DISTNAME)-$(VERSION)
1807 $(POSTOP)
1808
1809uutardist : $(DISTNAME)-$(VERSION).tar.$(SUFFIX)
1810 uuencode $(DISTNAME)-$(VERSION).tar.$(SUFFIX) \\
1811 $(DISTNAME)-$(VERSION).tar.$(SUFFIX) > \\
1812 $(DISTNAME)-$(VERSION).tar.$(SUFFIX).uu
1813
1814shdist : distdir
1815 $(PREOP)
1816 $(SHAR) $(DISTNAME)-$(VERSION) > $(DISTNAME)-$(VERSION).shar
1817 $(RM_RF) $(DISTNAME)-$(VERSION)
1818 $(POSTOP)
1819
1820distdir :
1821 $(RM_RF) $(DISTNAME)-$(VERSION)
1822 $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "/mani/";' \\
1823 -e 'manicopy(maniread(),"$(DISTNAME)-$(VERSION)");'
1824
1825
1826ci :
1827 $(PERL) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\
1828 -e '@all = keys %{maniread()};' \\
1829 -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
1830 -e 'print("Executing $(RCS) ...\n"); system("$(RCS) @all");'
1831
1832};
1833 join "", @m;
a0d0e21e
LW
1834}
1835
1836
42793c05
TB
1837# --- Test and Installation Sections ---
1838
a0d0e21e 1839sub test {
42793c05
TB
1840 my($self, %attribs) = @_;
1841 my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
1842 my(@m);
1843 push(@m,"
40000a8c
AD
1844TEST_VERBOSE=0
1845
42793c05
TB
1846test :: all
1847");
1848 push(@m, <<"END") if $tests;
40000a8c 1849 \$(FULLPERL) -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
42793c05
TB
1850END
1851 push(@m, <<'END') if -f "test.pl";
fed7345c 1852 $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
42793c05 1853END
005c1a0e 1854 push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) test \$(PASTHRU2)\n",
40000a8c 1855 @{$att{DIR}}));
42793c05
TB
1856 push(@m, "\t\@echo 'No tests defined for \$(NAME) extension.'\n") unless @m > 1;
1857 join("", @m);
a0d0e21e
LW
1858}
1859
1860
1861sub install {
3edbfbe5
TB
1862 my($self, %attribs) = @_;
1863 my(@m);
40000a8c
AD
1864 push @m, q{
1865doc_install ::
005c1a0e 1866 @ echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
40000a8c 1867 @ $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \\
232e078e 1868 -e "use ExtUtils::MakeMaker; MM->writedoc('Module', '$(NAME)', \\
005c1a0e
AD
1869 'LINKTYPE=$(LINKTYPE)', 'VERSION=$(VERSION)', \\
1870 'EXE_FILES=$(EXE_FILES)')" >> $(INSTALLARCHLIB)/perllocal.pod
40000a8c
AD
1871};
1872
3edbfbe5 1873 push(@m, "
40000a8c
AD
1874install :: pure_install doc_install
1875
005c1a0e 1876pure_install ::
3edbfbe5
TB
1877");
1878 # install subdirectories first
005c1a0e
AD
1879 push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) install\n",
1880 @{$att{DIR}}));
3edbfbe5 1881
005c1a0e
AD
1882 push(@m, "\t\@\$(PERL) -e 'foreach (\@ARGV){die qq{You do not have permissions to install into \$\$_\\n} unless -w \$\$_}' \$(INSTALLPRIVLIB) \$(INSTALLARCHLIB)
1883 : perl5.000 and MM pre 3.8 autosplit into INST_ARCHLIB, we delete these old files here
1884 $att{RM_F} \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.al
1885 $att{RM_F} \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.ix
1886 \$(MAKE) INST_LIB=\$(INSTALLPRIVLIB) INST_ARCHLIB=\$(INSTALLARCHLIB) INST_EXE=\$(INSTALLBIN)
1887 \@\$(PERL) -i.bak -lne 'print unless \$\$seen{\$\$_}++' \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/.packlist
3edbfbe5 1888");
a0d0e21e 1889
005c1a0e
AD
1890 push @m, '
1891#### UNINSTALL IS STILL EXPERIMENTAL ####
1892uninstall ::
1893';
1894
1895 push(@m, map("\tcd $_ && test -f $att{MAKEFILE} && \$(MAKE) uninstall\n",
1896 @{$att{DIR}}));
1897 push @m, "\t".'$(RM_RF) `cat $(INSTALLARCHLIB)/auto/$(FULLEXT)/.packlist`
1898';
1899
3edbfbe5
TB
1900 join("",@m);
1901}
a0d0e21e 1902
42793c05
TB
1903sub force {
1904 '# Phony target to force checking subdirectories.
1905FORCE:
a0d0e21e
LW
1906';
1907}
1908
1909
1910sub perldepend {
005c1a0e 1911 my(@m);
42793c05
TB
1912 push(@m,'
1913PERL_HDRS = $(PERL_INC)/EXTERN.h $(PERL_INC)/INTERN.h \
1914 $(PERL_INC)/XSUB.h $(PERL_INC)/av.h $(PERL_INC)/cop.h \
1915 $(PERL_INC)/cv.h $(PERL_INC)/dosish.h $(PERL_INC)/embed.h \
1916 $(PERL_INC)/form.h $(PERL_INC)/gv.h $(PERL_INC)/handy.h \
1917 $(PERL_INC)/hv.h $(PERL_INC)/keywords.h $(PERL_INC)/mg.h \
1918 $(PERL_INC)/op.h $(PERL_INC)/opcode.h $(PERL_INC)/patchlevel.h \
1919 $(PERL_INC)/perl.h $(PERL_INC)/perly.h $(PERL_INC)/pp.h \
1920 $(PERL_INC)/proto.h $(PERL_INC)/regcomp.h $(PERL_INC)/regexp.h \
1921 $(PERL_INC)/scope.h $(PERL_INC)/sv.h $(PERL_INC)/unixish.h \
75f92628 1922 $(PERL_INC)/util.h $(PERL_INC)/config.h
42793c05 1923
42793c05 1924');
e1666bf5 1925
005c1a0e
AD
1926 push @m, '
1927$(OBJECT) : $(PERL_HDRS)
1928' if $att{OBJECT};
1929
42793c05 1930 push(@m,'
75f92628
AD
1931# Check for unpropogated config.sh changes. Should never happen.
1932# We do NOT just update config.h because that is not sufficient.
1933# An out of date config.h is not fatal but complains loudly!
1934$(PERL_INC)/config.h: $(PERL_SRC)/config.sh
1935 -@echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
1936
75f92628 1937$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
1aef975c 1938 @echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
232e078e 1939 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
e1666bf5
TB
1940') if $att{PERL_SRC};
1941
42793c05
TB
1942 push(@m, join(" ", values %{$att{XS}})." : \$(XSUBPPDEPS)\n")
1943 if %{$att{XS}};
1944 join("\n",@m);
1945}
1946
1947
1948sub makefile {
005c1a0e 1949 my @m;
42793c05 1950 # We do not know what target was originally specified so we
75f92628 1951 # must force a manual rerun to be sure. But as it should only
42793c05 1952 # happen very rarely it is not a significant problem.
005c1a0e 1953 push @m, '
1aef975c 1954$(OBJECT) : '.$att{MAKEFILE}.'
75f92628
AD
1955
1956# We take a very conservative approach here, but it\'s worth it.
1957# We move Makefile to Makefile.old here to avoid gnu make looping.
005c1a0e 1958'.$att{MAKEFILE}.' : Makefile.PL $(CONFIGDEP)
75f92628
AD
1959 @echo "Makefile out-of-date with respect to $?"
1960 @echo "Cleaning current config before rebuilding Makefile..."
1aef975c
AD
1961 -@mv '."$att{MAKEFILE} $att{MAKEFILE}.old".'
1962 -$(MAKE) -f '.$att{MAKEFILE}.'.old clean >/dev/null 2>&1 || true
005c1a0e 1963 $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL '."@ARGV".'
42793c05 1964 @echo "Now you must rerun make."; false
a0d0e21e 1965';
005c1a0e
AD
1966
1967 join "", @m;
a0d0e21e
LW
1968}
1969
a0d0e21e
LW
1970sub postamble{
1971 "";
1972}
1973
232e078e
AD
1974# --- Make-Directories section (internal method) ---
1975# dir_target(@array) returns a Makefile entry for the file .exists in each
1976# named directory. Returns nothing, if the entry has already been processed.
1977# We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
1978# Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
1979# prerequisite, because there has to be one, something that doesn't change
1980# too often :)
1981%Dir_Target = (); # package global
1982
1983sub dir_target {
005c1a0e 1984 my($self,@dirs) = @_;
232e078e
AD
1985 my(@m,$dir);
1986 foreach $dir (@dirs) {
1987 next if $Dir_Target{$dir};
1988 push @m, "
1989$dir/.exists :: \$(PERL)
1990 \@ \$(MKPATH) $dir
1991 \@ \$(TOUCH) $dir/.exists
1992";
1993 $Dir_Target{$dir}++;
1994 }
1995 join "", @m;
1996}
1997
fed7345c
AD
1998# --- Make-A-Perl section ---
1999
2000sub staticmake {
2001 my($self, %attribs) = @_;
2002
2003 my(%searchdirs)=($att{PERL_ARCHLIB} => 1, $att{INST_ARCHLIB} => 1);
2004 my(@searchdirs)=keys %searchdirs;
2005 # And as it's not yet built, we add the current extension
2006 my(@static)="$att{INST_ARCHLIB}/auto/$att{FULLEXT}/$att{BASEEXT}.a";
fed7345c
AD
2007 my(@perlinc) = ($att{INST_ARCHLIB}, $att{INST_LIB}, $att{PERL_ARCHLIB}, $att{PERL_LIB});
2008 MY->makeaperl('MAKE' => $att{MAKEFILE},
2009 'DIRS' => \@searchdirs,
2010 'STAT' => \@static,
fed7345c 2011 'INCL' => \@perlinc,
40000a8c 2012 'TARGET' => $att{MAP_TARGET},
fed7345c 2013 'TMP' => "",
40000a8c 2014 'LIBPERL' => $att{LIBPERL_A}
fed7345c
AD
2015 );
2016}
2017
2018sub makeaperl {
2019 my($self, %attribs) = @_;
2020 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2021 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2022 my(@m);
40000a8c 2023 my($cccmd, $linkcmd);
fed7345c
AD
2024
2025 # This emulates cflags to get the compiler invocation...
40000a8c 2026 $cccmd = MY->const_cccmd($libperl);
fed7345c
AD
2027 $cccmd =~ s/^CCCMD\s*=\s*//;
2028 chomp $cccmd;
2029 $cccmd =~ s/\s/ -I$att{PERL_INC} /;
2030 $cccmd .= " $Config{'cccdlflags'}" if ($Config{'d_shrplib'});
2031
2032 # The front matter of the linkcommand...
5d94fbed 2033 $linkcmd = join ' ', "\$(CC)",
fed7345c
AD
2034 grep($_, @Config{qw(large split ldflags ccdlflags)});
2035 $linkcmd =~ s/\s+/ /g;
2036
2037 # Which *.a files could we make use of...
40000a8c 2038 local(%static);
fed7345c
AD
2039 File::Find::find(sub {
2040 return unless m/\.a$/;
40000a8c 2041 return if m/^libperl/;
232e078e
AD
2042 # don't include the installed version of this extension
2043 return if $File::Find::name =~ m:auto/$att{FULLEXT}/$att{BASEEXT}.a$:;
40000a8c 2044 $static{fastcwd() . "/" . $_}++;
fed7345c
AD
2045 }, grep( -d $_, @{$searchdirs || []}) );
2046
40000a8c
AD
2047 # We trust that what has been handed in as argument, will be buildable
2048 $static = [] unless $static;
2049 @static{@{$static}} = (1) x @{$static};
2050
fed7345c
AD
2051 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2052 for (sort keys %static) {
2053 next unless /\.a$/;
40000a8c 2054 $_ = dirname($_) . "/extralibs.ld";
5d94fbed 2055 push @$extra, $_;
fed7345c
AD
2056 }
2057
fed7345c
AD
2058 grep(s/^/-I/, @$perlinc);
2059
2060 $target = "perl" unless $target;
2061 $tmp = "." unless $tmp;
2062
2063 push @m, "
40000a8c 2064# --- MakeMaker makeaperl section ---
fed7345c
AD
2065MAP_TARGET = $target
2066FULLPERL = $att{'FULLPERL'}
2067MAP_LINKCMD = $linkcmd
2068MAP_PERLINC = @{$perlinc}
2069MAP_STATIC = ",
2070join(" ", sort keys %static), "
fed7345c
AD
2071MAP_PRELIBS = $Config{'libs'} $Config{'cryptlib'}
2072";
232e078e
AD
2073
2074 unless ($libperl && -f $libperl) {
005c1a0e
AD
2075 my $dir = $att{PERL_SRC} || "$att{PERL_ARCHLIB}/CORE";
2076 $libperl ||= "libperl.a";
232e078e
AD
2077 $libperl = "$dir/$libperl";
2078 print STDOUT "Warning: $libperl not found"
2079 unless (-f $libperl || defined($att{PERL_SRC}));
40000a8c 2080 }
fed7345c 2081
40000a8c
AD
2082 push @m, "
2083MAP_LIBPERL = $libperl
fed7345c 2084";
fed7345c 2085
40000a8c 2086 push @m, "
5d94fbed
AD
2087extralibs.ld: @$extra
2088 \@ $att{RM_F} \$\@
2089 \@ \$(TOUCH) \$\@
2090";
2091
2092 foreach (@$extra){
2093 push @m, "\tcat $_ >> \$\@\n";
2094 }
2095
2096 push @m, "
2097\$(MAP_TARGET): $tmp/perlmain.o \$(MAP_LIBPERL) \$(MAP_STATIC) extralibs.ld
2098 \$(MAP_LINKCMD) -o \$\@ $tmp/perlmain.o \$(MAP_LIBPERL) \$(MAP_STATIC) `cat extralibs.ld` \$(MAP_PRELIBS)
40000a8c
AD
2099 @ echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
2100 @ echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2101 @ echo 'To remove the intermediate files say'
2102 @ echo ' make -f $makefilename map_clean'
2103
2104$tmp/perlmain.o: $tmp/perlmain.c
2105";
2106 push @m, "\tcd $tmp && $cccmd perlmain.c\n";
fed7345c
AD
2107
2108 push @m, qq{
2109$tmp/perlmain.c: $makefilename}, q{
40000a8c
AD
2110 @ echo Writing $@
2111 @ $(FULLPERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
2112 writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@.tmp && mv $@.tmp $@
2113
2114};
fed7345c 2115
5d94fbed 2116# We write EXTRA outside the perl program to have it eval'd by the shell
40000a8c
AD
2117 push @m, q{
2118doc_inst_perl:
005c1a0e 2119 @ echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
232e078e
AD
2120 @ $(FULLPERL) -e 'use ExtUtils::MakeMaker; MM->writedoc("Perl binary",' \\
2121 -e '"$(MAP_TARGET)", "MAP_STATIC=$(MAP_STATIC)",' \\
005c1a0e
AD
2122 -e '"MAP_EXTRA=@ARGV", "MAP_LIBPERL=$(MAP_LIBPERL)")' \\
2123 -- `cat extralibs.ld` >> $(INSTALLARCHLIB)/perllocal.pod
fed7345c
AD
2124};
2125
2126 push @m, qq{
40000a8c
AD
2127inst_perl: pure_inst_perl doc_inst_perl
2128
2129pure_inst_perl: \$(MAP_TARGET)
005c1a0e 2130 $att{CP} \$(MAP_TARGET) \$(INSTALLBIN)/\$(MAP_TARGET)
fed7345c 2131
40000a8c
AD
2132realclean :: map_clean
2133
2134map_clean :
005c1a0e 2135 $att{RM_F} $tmp/perlmain.o $tmp/perlmain.c $makefilename extralibs.ld
fed7345c
AD
2136};
2137
2138 join '', @m;
2139}
a0d0e21e 2140
005c1a0e
AD
2141sub extliblist {
2142 my($self,$libs) = @_;
2143 require ExtUtils::Liblist;
2144 ExtUtils::Liblist::ext($libs, $Verbose);
a0d0e21e
LW
2145}
2146
1aef975c
AD
2147sub mksymlists {
2148 my($self) = shift;
232e078e 2149 my($pkg);
1aef975c
AD
2150
2151 # only AIX requires a symbol list at this point
2152 # (so does VMS, but that's handled by the MM_VMS package)
40000a8c 2153 return '' unless $Config{'osname'} eq 'aix';
1aef975c
AD
2154
2155 init_main(@ARGV) unless defined $att{'BASEEXT'};
94b6baf5 2156 if (! $att{DL_FUNCS}) {
40000a8c
AD
2157 my($bootfunc);
2158 ($bootfunc = $att{NAME}) =~ s/\W/_/g;
2159 $att{DL_FUNCS} = {$att{BASEEXT} => ["boot_$bootfunc"]};
1aef975c
AD
2160 }
2161 rename "$att{BASEEXT}.exp", "$att{BASEEXT}.exp_old";
2162
2163 open(EXP,">$att{BASEEXT}.exp") or die $!;
40000a8c
AD
2164 print EXP join("\n",@{$att{DL_VARS}}) if $att{DL_VARS};
2165 foreach $pkg (keys %{$att{DL_FUNCS}}) {
1aef975c 2166 (my($prefix) = $pkg) =~ s/\W/_/g;
232e078e 2167 my $func;
40000a8c 2168 foreach $func (@{$att{DL_FUNCS}->{$pkg}}) {
1aef975c
AD
2169 $func = "XS_${prefix}_$func" unless $func =~ /^boot_/;
2170 print EXP "$func\n";
2171 }
2172 }
2173 close EXP;
2174}
42793c05
TB
2175
2176# --- Output postprocessing section ---
2177#nicetext is included to make VMS support easier
2178sub nicetext { # Just return the input - no action needed
2179 my($self,$text) = @_;
2180 $text;
2181}
fed7345c 2182
40000a8c
AD
2183# --- perllocal.pod section ---
2184sub writedoc {
2185 my($self,$what,$name,@attribs)=@_;
005c1a0e
AD
2186# the following would have to move to a ExtUtils::Perllocal.pm, if we want it
2187# it's dangerous wrt AFS, and it's against the philosophy that MakeMaker
2188# should never write to files. We write to stdout and append to the file
2189# during make install, but we cannot rely on '-f $Config{"installarchlib"},
2190# as there is a time window between the WriteMakefile and the make.
2191# -w $Config{'installarchlib'} or die "No write permission to $Config{'installarchlib'}";
2192# my($localpod) = "$Config{'installarchlib'}/perllocal.pod";
40000a8c 2193 my($time);
005c1a0e
AD
2194# if (-f $localpod) {
2195# print "Appending installation info to $localpod\n";
2196# open POD, ">>$localpod" or die "Couldn't open $localpod";
2197# } else {
2198# print "Writing new file $localpod\n";
2199# open POD, ">$localpod" or die "Couldn't open $localpod";
2200# print POD "=head1 NAME
2201#
2202#perllocal - locally installed modules and perl binaries
2203#\n=head1 HISTORY OF LOCAL INSTALLATIONS
2204#
2205#";
2206# }
40000a8c
AD
2207 require "ctime.pl";
2208 chop($time = ctime(time));
005c1a0e
AD
2209 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
2210 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
2211 print "\n\n=back\n\n";
2212# close POD;
40000a8c
AD
2213}
2214
232e078e 2215
005c1a0e
AD
2216
2217# the following keeps AutoSplit happy
2218package ExtUtils::MakeMaker;
22191;
2220
2221__END__
2222
2223=head1 NAME
2224
2225ExtUtils::MakeMaker - create an extension Makefile
2226
2227=head1 SYNOPSIS
2228
2229C<use ExtUtils::MakeMaker;>
2230
2231C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );>
2232
2233=head1 DESCRIPTION
2234
2235This utility is designed to write a Makefile for an extension module
2236from a Makefile.PL. It is based on the Makefile.SH model provided by
2237Andy Dougherty and the perl5-porters.
2238
2239It splits the task of generating the Makefile into several subroutines
2240that can be individually overridden. Each subroutine returns the text
2241it wishes to have written to the Makefile.
2242
2243MakeMaker.pm uses the architecture specific information from
2244Config.pm. In addition the extension may contribute to the C<%Config>
2245hash table of Config.pm by supplying hints files in a C<hints/>
2246directory. The hints files are expected to be named like their
2247counterparts in C<PERL_SRC/hints>, but with an C<.pl> file name
2248extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by MakeMaker
2249within the WriteMakefile() subroutine, and can be used to execute
2250commands as well as to include special variables. If there is no
2251hintsfile for the actual system, but for some previous releases of the
2252same operating system, the latest one of those is used.
2253
2254=head2 Default Makefile Behaviour
2255
2256The automatically generated Makefile enables the user of the extension
2257to invoke
2258
2259 perl Makefile.PL # optionally "perl Makefile.PL verbose"
2260 make
2261 make test # optionally set TEST_VERBOSE=1
2262 make install # See below
2263
2264The Makefile to be produced may be altered by adding arguments of the
2265form C<KEY=VALUE>. If the user wants to work with a different perl
2266than the default, this is achieved by specifying
2267
2268 perl Makefile.PL PERL=/tmp/myperl5
2269
2270Other interesting targets in the generated Makefile are
2271
2272 make config # to check if the Makefile is up-to-date
2273 make clean # delete local temporary files (Makefile gets renamed)
2274 make realclean # delete all derived files (including installed files)
2275 make dist # see below the Distribution Support section
2276
2277=head2 Special case C<make install>
2278
2279C<make> alone puts all relevant files into directories that are named
2280by the macros INST_LIB, INST_ARCHLIB, and INST_EXE. All three default
2281to ./blib if you are I<not> building below the perl source directory. If
2282you I<are> building below the perl source, INST_LIB and INST_ARCHLIB
2283default to ../../lib, and INST_EXE is not defined.
2284
2285The I<install> target of the generated Makefile is a recursive call to
2286make which sets
2287
2288 INST_LIB to INSTALLPRIVLIB
2289 INST_ARCHLIB to INSTALLARCHLIB
2290 INST_EXE to INSTALLBIN
2291
2292The three INSTALL... macros in turn default to
2293$Config{installprivlib}, $Config{installarchlib}, and
2294$Config{installbin} respectively.
2295
2296The recommended way to proceed is to set only the INSTALL* macros, not
2297the INST_* targets. In doing so, you give room to the compilation
2298process without affecting important directories. Usually a 'make test'
2299will succeed after the make, and a 'make install' can finish the game.
2300
2301MakeMaker gives you much more freedom than needed to configure
2302internal variables and get different results. It is worth to mention,
2303that make(1) also lets you configure most of the variables that are
2304used in the Makefile. But in the majority of situations this will not
2305be necessary, and should only be done, if the author of a package
2306recommends it.
2307
2308The usual relationship between INSTALLPRIVLIB and INSTALLARCHLIB is
2309that the latter is a subdirectory of the former with the name
2310C<$Config{'archname'}>, MakeMaker supports the user who sets
2311INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then
2312MakeMaker defaults the latter to be INSTALLPRIVLIB/ARCHNAME if that
2313directory exists, otherwise it defaults to INSTALLPRIVLIB.
2314
2315Previous versions of MakeMaker suggested to use the INST_* macros. For
2316backwards compatibility, these are still supported but deprecated in
2317favor of the INSTALL* macros.
2318
2319Here is the description, what they are used for: If the user specifies
2320the final destination for the INST_... macros, then there is no need
2321to call 'make install', because 'make' will already put all files in
2322place.
2323
2324If there is a need to first build everything in the C<./blib>
2325directory and test the product, then it's appropriate to use the
2326INSTALL... macros. So the users have the choice to either say
2327
2328 # case: trust the module
2329 perl Makefile.PL INST_LIB=~/perllib INST_EXE=~/bin
2330 make
2331 make test
2332
2333or
2334
2335 perl Makefile.PL INSTALLPRIVLIB=~/foo \
2336 INSTALLARCHLIB=~/foo/bar INSTALLBIN=~/bin
2337 make
2338 make test
2339 make install
2340
2341Note, that the tilde expansion is done by MakeMaker, not by perl by
2342default, nor by make. So be careful to use the tilde only with the
2343C<perl Makefile.PL> call.
2344
2345It is important to know, that the INSTALL* macros should be absolute
2346paths, never relativ ones. Packages with multiple Makefile.PLs in
2347different directories get the contents of the INSTALL* macros
2348propagated verbatim. (The INST_* macros will be corrected, if they are
2349relativ paths, but not the INSTALL* macros.)
2350
2351If the user has superuser privileges, and is not working on AFS
2352(Andrew File System) or relatives, then the defaults for
2353INSTALLPRIVLIB, INSTALLARCHLIB, and INSTALLBIN will be appropriate,
2354and this incantation will be the best:
2355
2356 perl Makefile.PL; make; make test
2357 make install
2358
2359(I<make test> is not necessarily supported for all modules.)
2360
2361C<make install> per default writes some documentation of what has been
2362done into the file C<$Config{'installarchlib'}/perllocal.pod>. This is
2363an experimental feature. It can be bypassed by calling C<make
2364pure_install>.
2365
2366=head2 Support to Link a new Perl Binary (eg dynamic loading not available)
2367
2368An extension that is built with the above steps is ready to use on
2369systems supporting dynamic loading. On systems that do not support
2370dynamic loading, any newly created extension has to be linked together
2371with the available resources. MakeMaker supports the linking process
2372by creating appropriate targets in the Makefile whenever an extension
2373is built. You can invoke the corresponding section of the makefile with
2374
2375 make perl
2376
2377That produces a new perl binary in the current directory with all
2378extensions linked in that can be found in INST_ARCHLIB (usually
2379C<./blib>) and PERL_ARCHLIB.
2380
2381The binary can be installed into the directory where perl normally
2382resides on your machine with
2383
2384 make inst_perl
2385
2386To produce a perl binary with a different name than C<perl>, either say
2387
2388 perl Makefile.PL MAP_TARGET=myperl
2389 make myperl
2390 make inst_perl
2391
2392or say
2393
2394 perl Makefile.PL
2395 make myperl MAP_TARGET=myperl
2396 make inst_perl MAP_TARGET=myperl
2397
2398In any case you will be prompted with the correct invocation of the
2399C<inst_perl> target that installs the new binary into INSTALLBIN.
2400
2401Note, that there is a C<makeaperl> scipt in the perl distribution,
2402that supports the linking of a new perl binary in a similar fashion,
2403but with more options.
2404
2405C<make inst_perl> per default writes some documentation of what has been
2406done into the file C<$Config{'installarchlib'}/perllocal.pod>. This
2407can be bypassed by calling C<make pure_inst_perl>.
2408
2409Warning: the inst_perl: target is rather mighty and will probably
2410overwrite your existing perl binary. Use with care!
2411
2412=head2 Determination of Perl Library and Installation Locations
2413
2414MakeMaker needs to know, or to guess, where certain things are
2415located. Especially INST_LIB and INST_ARCHLIB (where to install files
2416into), PERL_LIB and PERL_ARCHLIB (where to read existing modules
2417from), and PERL_INC (header files and C<libperl*.*>).
2418
2419Extensions may be built either using the contents of the perl source
2420directory tree or from an installed copy of the perl library.
2421
2422If an extension is being built below the C<ext/> directory of the perl
2423source then MakeMaker will set PERL_SRC automatically (e.g., C<../..>).
2424If PERL_SRC is defined then other variables default to the following:
2425
2426 PERL_INC = PERL_SRC
2427 PERL_LIB = PERL_SRC/lib
2428 PERL_ARCHLIB = PERL_SRC/lib
2429 INST_LIB = PERL_LIB
2430 INST_ARCHLIB = PERL_ARCHLIB
2431
2432If an extension is being built away from the perl source then MakeMaker
2433will leave PERL_SRC undefined and default to using the installed copy
2434of the perl library. The other variables default to the following:
2435
2436 PERL_INC = $archlib/CORE
2437 PERL_LIB = $privlib
2438 PERL_ARCHLIB = $archlib
2439 INST_LIB = ./blib
2440 INST_ARCHLIB = ./blib
2441
2442If perl has not yet been installed then PERL_SRC can be defined on the
2443command line as shown in the previous section.
2444
2445=head2 Useful Default Makefile Macros
2446
2447FULLEXT = Pathname for extension directory (eg DBD/Oracle).
2448
2449BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
2450
2451ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
2452
2453PERL_LIB = Directory where we read the perl library files
2454
2455PERL_ARCHLIB = Same as above for architecture dependent files
2456
2457INST_LIB = Directory where we put library files of this extension
2458while building it. If we are building below PERL_SRC/ext
2459we default to PERL_SRC/lib, else we default to ./blib.
2460
2461INST_ARCHLIB = Same as above for architecture dependent files
2462
2463INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)>
2464
2465INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)>
2466
2467INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)>
2468
2469=head2 Customizing The Generated Makefile
2470
2471If the Makefile generated does not fit your purpose you can change it
2472using the mechanisms described below.
2473
2474=head2 Using Attributes (and Parameters)
2475
2476The following attributes can be specified as arguments to WriteMakefile()
2477or as NAME=VALUE pairs on the command line:
2478
2479This description is not yet documented; you can get at the description
2480with one of the commands
2481
2482=over 4
2483
2484=item C<perl Makefile.PL help>
2485(if you already have a basic Makefile.PL)
2486
2487=item C<make help>
2488(if you already have a Makefile)
2489
2490=item C<perl -e 'use ExtUtils::MakeMaker "&help"; &help;'>
2491(if you have neither nor)
2492
2493=back
2494
2495=head2 Overriding MakeMaker Methods
2496
2497If you cannot achieve the desired Makefile behaviour by specifying
2498attributes you may define private subroutines in the Makefile.PL.
2499Each subroutines returns the text it wishes to have written to
2500the Makefile. To override a section of the Makefile you can
2501either say:
2502
2503 sub MY::c_o { "new literal text" }
2504
2505or you can edit the default by saying something like:
2506
2507 sub MY::c_o { $_=MM->c_o; s/old text/new text/; $_ }
2508
2509If you still need a different solution, try to develop another
2510subroutine, that fits your needs and submit the diffs to
2511F<perl5-porters@nicoh.com> or F<comp.lang.perl> as appropriate.
2512
2513=head2 Distribution Support
2514
2515For authors of extensions MakeMaker provides several Makefile
2516targets. Most of the support comes from the ExtUtils::Manifest module,
2517where additional documentation can be found.
2518
2519=over 4
2520
2521=item make distcheck
2522reports which files are below the build directory but not in the
2523MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for
2524details)
2525
2526=item make distclean
2527does a realclean first and then the distcheck. Note that this is not
2528needed to build a new distribution as long as you are sure, that the
2529MANIFEST file is ok.
2530
2531=item make manifest
2532rewrites the MANIFEST file, adding all remaining files found (See
2533ExtUtils::Manifest::mkmanifest() for details)
2534
2535=item make distdir
2536Copies all the files that are in the MANIFEST file to a newly created
2537directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory
2538exists, it will be removed first.
2539
2540=item make tardist
2541First does a command $(PREOP) which defaults to a null command. Does a
2542distdir next and runs C<tar> on that directory into a tarfile. Then
2543deletes the distdir. Finishes with a command $(POSTOP) which defaults
2544to a null command.
2545
2546=item make dist
2547Defaults to $(DIST_DEFAULT) which in turn defaults to tardist.
2548
2549=item make uutardist
2550Runs a tardist first and uuencodes the tarfile.
2551
2552=item make shdist
2553First does a command $(PREOP) which defaults to a null command. Does a
2554distdir next and runs C<shar> on that directory into a sharfile. Then
2555deletes the distdir. Finishes with a command $(POSTOP) which defaults
2556to a null command. Note: For shdist to work properly a C<shar>
2557program that can handle directories is mandatory.
2558
2559=item make ci
2560Does a $(CI) (defaults to C<ci -u>) and a $(RCS) (C<rcs -q
2561-Nv$(VERSION_SYM):>) on all files in the MANIFEST file
2562
2563Customization of the dist targets can be done by specifying a hash
2564reference to the dist attribute of the WriteMakefile call. The
2565following parameters are recognized:
2566
2567 TAR ('tar')
2568 TARFLAGS ('cvf')
2569 COMPRESS ('compress')
2570 SUFFIX ('Z')
2571 SHAR ('shar')
2572 PREOP ('@ :')
2573 POSTOP ('@ :')
2574
2575An example:
2576
2577 WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" })
2578
2579=back
2580
fed7345c
AD
2581=head1 AUTHORS
2582
2583Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas
2584Koenig F<E<lt>k@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce
2585F<E<lt>Tim.Bunce@ig.co.ukE<gt>>. VMS support by Charles Bailey
005c1a0e
AD
2586F<E<lt>bailey@HMIVAX.HUMGEN.UPENN.EDUE<gt>>. Contact the makemaker
2587mailing list L<mailto:makemaker@franz.ww.tu-berlin.de>, if you have any
2588questions.
fed7345c
AD
2589
2590=head1 MODIFICATION HISTORY
2591
2592v1, August 1994; by Andreas Koenig. Based on Andy Dougherty's Makefile.SH.
2593v2, September 1994 by Tim Bunce.
2594v3.0 October 1994 by Tim Bunce.
2595v3.1 November 11th 1994 by Tim Bunce.
2596v3.2 November 18th 1994 by Tim Bunce.
2597v3.3 November 27th 1994 by Andreas Koenig.
2598v3.4 December 7th 1994 by Andreas Koenig and Tim Bunce.
2599v3.5 December 15th 1994 by Tim Bunce.
2600v3.6 December 15th 1994 by Tim Bunce.
2601v3.7 December 30th 1994 By Tim Bunce
2602v3.8 January 17th 1995 By Andreas Koenig and Tim Bunce
2603v3.9 January 19th 1995 By Tim Bunce
fed7345c 2604v3.10 January 23rd 1995 By Tim Bunce
fed7345c 2605v3.11 January 24th 1995 By Andreas Koenig
fed7345c 2606v4.00 January 24th 1995 By Tim Bunce
fed7345c 2607v4.01 January 25th 1995 By Tim Bunce
fed7345c 2608v4.02 January 29th 1995 By Andreas Koenig
40000a8c
AD
2609v4.03 January 30th 1995 By Andreas Koenig
2610v4.04 Februeary 5th 1995 By Andreas Koenig
2611v4.05 February 8th 1995 By Andreas Koenig
2612v4.06 February 10th 1995 By Andreas Koenig
40000a8c 2613v4.061 February 12th 1995 By Andreas Koenig
40000a8c 2614v4.08 - 4.085 February 14th-21st 1995 by Andreas Koenig
005c1a0e
AD
2615v4.086 March 9 1995 by Andy Dougherty
2616v4.09 March 31 1995 by Andreas Koenig
2617v4.091 April 3 1995 by Andy Dougherty
2618v4.092 April 11 1995 by Andreas Koenig
2619v4.093 April 12 1995 by Andy Dougherty
2620v4.094 April 12 1995 by Andy Dougherty
fed7345c 2621
005c1a0e 2622v4.100 May 10 1995 by Andreas Koenig
fed7345c 2623
005c1a0e
AD
2624Broken out Mkbootstrap to make the file smaller and easier to manage,
2625and to speed up the build process.
fed7345c 2626
005c1a0e
AD
2627Added ExtUtils::Manifest as an extra module that is used to streamline
2628distributions. (See pod section I<distribution support>).
fed7345c 2629
005c1a0e
AD
2630Added a VERSION_SYM macro, that is derived from VERSION but all C<\W>
2631characters replaced by an underscore.
fed7345c 2632
005c1a0e 2633Moved the whole documentation below __END__ for easier maintanance.
fed7345c 2634
005c1a0e 2635linkext =E<gt> { LINKTYPE =E<gt> '' } should work now as expected.
fed7345c 2636
005c1a0e
AD
2637Rechecked the use of INST_LIB, INST_ARCHLIB, and INST_EXE from the
2638perspective of an AFS user (thanks to Rudolph T Maceyko for the
2639hint). With full backward compatiblity it is now possible, to set
2640INSTALLPRIVLIB, INSTALLARCHLIB, and INSTALLBIN either with 'perl
2641Makefile.PL' or with 'make install'. A bare 'make' ignores these
2642settings. The effect of this change is that it is no longer
2643recommended to set the INST_* attributes directly, although it doesn't
2644hurt, if they do so. The PASTHRU variables (now PASTHRU1 and PASTHRU2)
2645are fully aware of their duty: the INST_* attributes are only
2646propagated to runsubdirpl, not to 'cd subdir && make config' and 'cd
2647subdir && make all'.
fed7345c 2648
005c1a0e 2649Included Tim's "Unable to locate Perl library" patch.
fed7345c 2650
005c1a0e
AD
2651Eliminated any excess of spaces in the $old/$new comparison in
2652const_cccmd().
fed7345c 2653
005c1a0e 2654Added a prompt function with usage $answer = prompt $message, $default.
fed7345c 2655
005c1a0e
AD
2656Included Tim's patch that searches for perl5 and perl$] as well as
2657perl and miniperl.
fec02dd3 2658
005c1a0e
AD
2659Added .NO_PARALLEL for the time until I have a multiple cpu machine
2660myself :)
fec02dd3 2661
005c1a0e
AD
2662Introduced a macro() subroutine. WriteMakefile("macro" =E<gt> { FOO
2663=E<gt> BAR }) defines the macro FOO = BAR in the generated Makefile.
232e078e 2664
005c1a0e 2665Rolled in Tim's patch for needs_linking.
232e078e 2666
005c1a0e
AD
2667writedoc now tries to be less clever. It was trying to determine, if a
2668perllocal.pod had to be created or appended to. As we have now the
2669possibility, that INSTALLARCHLIB is determined at make's runtime, we
2670cannot do this anymore. We append to that file in any case.
232e078e 2671
005c1a0e 2672Added Kenneth's pod installation patch.
232e078e 2673
005c1a0e 2674v4.110 May 19 1995 by Andreas Koenig
232e078e 2675
005c1a0e 2676=head1 NEW in 4.11
232e078e 2677
005c1a0e
AD
2678MANIFEST.SKIP now contains only regular expressions. RCS directories
2679are no longer skipped by default, as this may be configured in the
2680SKIP file.
232e078e 2681
005c1a0e 2682The manifest target now does no realclean anymore.
232e078e 2683
005c1a0e
AD
2684I_PERL_LIBS depreciated (no longer used). (unless you speak up, of
2685course)
232e078e 2686
005c1a0e
AD
2687I could not justify that we rebuild the Makefile when MakeMaker has
2688changed (as Kenneth suggested). If this is really a strong desire,
2689please convince me. But a minor change of the MakeMaker should not
2690trigger a 60 minutes rebuild of Tk, IMO.
232e078e 2691
005c1a0e
AD
2692Broken out extliblist into the new module ExtUtils::Liblist. Should
2693help extension writers for their own Configure scripts. The breaking
2694into pieces should be done now, I suppose.
232e078e 2695
005c1a0e
AD
2696Added an (experimenta!!) uninstall target that works with a
2697packlist. AutoSplit files are not yet in the packlist. This needs a
2698patch to AutoSplit, doesn't it? The packlist file is installed in
2699INST_ARCHAUTODIR/.packlist. It doesn't have means to decide, if a file
2700is architecture dependent or not, we just collect as much as we can
2701get. make -n recommended before actually executing. (I leave this
2702target undocumented in the pod section). Suggestions welcome!
232e078e 2703
005c1a0e
AD
2704Added basic chmod support. Nothing spectacular. *.so and *.a files get
2705permission 755, because I seem to recall, that some systems need
2706execute permissions in some weird constellations. The rest becomes
2707644. What else do we need to make this flexible?
232e078e 2708
005c1a0e
AD
2709Then I took Tim's word serious: no bloat. No turning all packages into
2710perl scripts. Leaving shar, tar, uu be what they are... Sorry,
2711Kenneth, we still have to convince Larry that a growing MakeMaker
2712makes sense :)
232e078e 2713
005c1a0e
AD
2714Added an extra check whenever they install below the perl source tree:
2715is this extension a standard extension? If it is, everything behaves
2716as we are used to. If it is not, the three INST_ macros are set to
2717./blib, and they get a warning that this extension has to be
2718installed manually with 'make install'.
232e078e 2719
005c1a0e
AD
2720Added a warning for targets that have a colon or a hashmark within
2721their names, because most make(1)s will not be able to process them.
232e078e 2722
005c1a0e
AD
2723Applied Hallvard's patch to ~user evaluation for cases where user does
2724not exist.
5d94fbed 2725
005c1a0e 2726Added a ci target that checks in all files from the MANIFEST into rcs.
5d94fbed 2727
005c1a0e 2728=head1 new in 4.12/4.13
5d94fbed 2729
005c1a0e
AD
2730"Please notify perl5-porters" message is now accompanied by
2731Config::myconfig().
5d94fbed 2732
005c1a0e
AD
2733(Manifest.pm) Change delimiter for the evaluation of the regexes from
2734MANIFEST.SKIP to from "!" to "/". I had overlooked the fact, that ! no
2735has a meaning in regular expressions.
5d94fbed 2736
005c1a0e
AD
2737Disabled the new logic that prevents non-standard extensions from
2738writing to PERL_SRC/lib to give Andy room for 5.001f.
5d94fbed 2739
005c1a0e
AD
2740Added a Version_check target that calls MakeMaker for a simple Version
2741control function on every invocation of 'make' in the future. Doesn't
2742have an effect currently.
5d94fbed 2743
005c1a0e
AD
2744Target dist is still defaulting to tardist, but the level of
2745indirection has changed. The Makefile macro DIST_DEFAULT takes it's
2746place. This allows me to make dist dependent from whatever I intend as
2747my standard distribution.
5d94fbed 2748
005c1a0e 2749Made sure that INST_EXE is created for extensions that need it.
5d94fbed 2750
005c1a0e 27514.13 is just a cleanup/documentation patch. And it adds a MakeMaker FAQ :)
5d94fbed 2752
005c1a0e 2753=head v4.14 June 5, 1995, by Andreas Koenig
5d94fbed 2754
005c1a0e
AD
2755Reintroduces the LD_RUN_PATH macro. LD_RUN_PATH is passed as an
2756environment variable to the ld run. It is needed on Sun OS, and does
2757no harm on other systems. It is a colon seperated list of the
2758directories in LDLOADLIBS.
f0b7e567 2759
005c1a0e 2760=head v4.15 June 6, 1995, by Andreas Koenig
5d94fbed 2761
005c1a0e 2762Add -I$(PERL_ARCHLIB) -I$(PERL_LIB) to calls to xsubpp.
f06db76b 2763
005c1a0e 2764=head1 TODO
f06db76b 2765
005c1a0e 2766Needs more complete documentation.
f06db76b 2767
005c1a0e
AD
2768Add a C<html:> target when there has been found a general solution to
2769installing html files.
fed7345c 2770
005c1a0e
AD
2771Add a FLAVOR variable that makes it easier to build debugging,
2772embedded or multiplicity perls. Currently the easiest way to produce a
2773debugging perl seems to be (after haveing built perl):
2774 make clobber
2775 ./Configure -D"archname=IP22-irix-d" -des
2776 make perllib=libperld.a
2777 make test perllib=libperld.a
2778 mv /usr/local/bin/perl /usr/local/bin/perl/O_perl5.001e
2779 make install perllib=libperld.a
2780 cp /usr/local/bin/perl/O_perl5.001e /usr/local/bin/perl
2781It would be nice, if the Configure step could be dropped. Also nice, but
2782maybe expensive, if 'make clobber' wouldn't be needed.
fed7345c 2783
005c1a0e 2784The uninstall target has to be completed, it's just a sketch.
fed7345c 2785
005c1a0e
AD
2786Reconsider Makefile macros. The output of macro() should be the last
2787before PASTHRU and none should come after that -- tough work.
fed7345c 2788
005c1a0e
AD
2789Think about Nick's desire, that the pTk subdirectory needs a special
2790treatment.
5d94fbed 2791
005c1a0e
AD
2792Find a way to have multiple MYEXTLIB archive files combined into
2793one. Actually I need some scenario, where this problem can be
2794illustrated. I currently don't see the problem.
5d94fbed 2795
005c1a0e 2796Test if .NOPARALLEL can be omitted.
fed7345c 2797
005c1a0e
AD
2798Don't let extensions write to PERL_SRC/lib anymore, build perl from
2799the extensions found below ext, run 'make test' and 'make install' on
2800each extension (giving room for letting them fail). Move some of the
2801tests from t/lib/* to the libraries.
a0d0e21e 2802
005c1a0e
AD
2803Streamline the production of a new perl binary on systems that DO have
2804dynamic loading (especially make test needs further support, as test
2805most probably needs the new binary).
2806
2807=cut