Commit | Line | Data |
---|---|---|
e05e23b1 | 1 | package main; |
2 | use vars qw(%att); | |
3 | ||
4 | # $Id: MakeMaker.pm,v 1.174 1996/02/06 17:03:12 k Exp $ | |
5 | ||
8e07c86e AD |
6 | package ExtUtils::MakeMaker::TieAtt; |
7 | # this package will go away again, when we don't have modules around | |
8 | # anymore that import %att It ties an empty %att and records in which | |
9 | # object this %att was tied. FETCH and STORE return/store-to the | |
10 | # appropriate value from %$self | |
005c1a0e | 11 | |
8e07c86e AD |
12 | # the warndirectuse method warns if somebody calls MM->something. It |
13 | # has nothing to do with the tie'd %att. | |
005c1a0e | 14 | |
8e07c86e | 15 | $Enough_limit = 5; |
a0d0e21e | 16 | |
8e07c86e AD |
17 | sub TIEHASH { |
18 | bless { SECRETHASH => $_[1]}; | |
005c1a0e | 19 | } |
42793c05 | 20 | |
8e07c86e | 21 | sub FETCH { |
4633a7c4 | 22 | print "Warning (non-fatal): Importing of %att is deprecated [$_[1]] |
8e07c86e AD |
23 | use \$self instead\n" unless ++$Enough>$Enough_limit; |
24 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit; | |
25 | $_[0]->{SECRETHASH}->{$_[1]}; | |
1aef975c | 26 | } |
42793c05 | 27 | |
8e07c86e | 28 | sub STORE { |
4633a7c4 | 29 | print "Warning (non-fatal): Importing of %att is deprecated [$_[1]][$_[2]] |
8e07c86e AD |
30 | use \$self instead\n" unless ++$Enough>$Enough_limit; |
31 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit; | |
32 | $_[0]->{SECRETHASH}->{$_[1]} = $_[2]; | |
33 | } | |
42793c05 | 34 | |
8e07c86e | 35 | sub FIRSTKEY { |
4633a7c4 | 36 | print "Warning (non-fatal): Importing of %att is deprecated [FIRSTKEY] |
8e07c86e AD |
37 | use \$self instead\n" unless ++$Enough>$Enough_limit; |
38 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" if $Enough==$Enough_limit; | |
39 | each %{$_[0]->{SECRETHASH}}; | |
40 | } | |
42793c05 | 41 | |
8e07c86e AD |
42 | sub NEXTKEY { |
43 | each %{$_[0]->{SECRETHASH}}; | |
44 | } | |
005c1a0e | 45 | |
8e07c86e AD |
46 | sub DESTROY { |
47 | } | |
005c1a0e | 48 | |
8e07c86e AD |
49 | sub warndirectuse { |
50 | my($caller) = @_; | |
51 | return if $Enough>$Enough_limit; | |
4633a7c4 | 52 | print STDOUT "Warning (non-fatal): Direct use of class methods deprecated; use\n"; |
8e07c86e | 53 | my($method) = $caller =~ /.*:(\w+)$/; |
864a5fa8 | 54 | print STDOUT |
8e07c86e | 55 | ' my $self = shift; |
8e07c86e AD |
56 | $self->MM::', $method, "(); |
57 | instead\n"; | |
58 | print "Further ExtUtils::MakeMaker::TieAtt warnings suppressed\n" | |
59 | if ++$Enough==$Enough_limit; | |
60 | } | |
005c1a0e | 61 | |
005c1a0e | 62 | |
42793c05 | 63 | |
005c1a0e | 64 | |
e05e23b1 | 65 | |
66 | ||
67 | package ExtUtils::MakeMaker; | |
68 | ||
69 | $Version = $VERSION = "5.21"; | |
70 | $Version_OK = "5.05"; # Makefiles older than $Version_OK will die | |
8e07c86e | 71 | # (Will be checked from MakeMaker version 4.13 onwards) |
e05e23b1 | 72 | ($Revision = substr(q$Revision: 1.174 $, 10)) =~ s/\s+$//; |
73 | ||
74 | ||
005c1a0e | 75 | |
8e07c86e AD |
76 | use Config; |
77 | use Carp; | |
78 | use Cwd; | |
79 | require Exporter; | |
80 | require ExtUtils::Manifest; | |
e05e23b1 | 81 | { |
82 | # Current (5.21) FileHandle doesn't work with miniperl, so we roll our own | |
83 | # that's all copy & paste code from FileHandle.pm, version of perl5.002b3 | |
84 | package FileHandle; | |
85 | use Symbol; | |
86 | sub new { | |
87 | @_ >= 1 && @_ <= 3 or croak('usage: new FileHandle [FILENAME [,MODE]]'); | |
88 | my $class = shift; | |
89 | my $fh = gensym; | |
90 | if (@_) { | |
91 | FileHandle::open($fh, @_) | |
92 | or return undef; | |
93 | } | |
94 | bless $fh, $class; | |
95 | } | |
96 | sub open { | |
97 | @_ >= 2 && @_ <= 4 or croak('usage: $fh->open(FILENAME [,MODE [,PERMS]])'); | |
98 | my ($fh, $file) = @_; | |
99 | if (@_ > 2) { | |
100 | my ($mode, $perms) = @_[2, 3]; | |
101 | if ($mode =~ /^\d+$/) { | |
102 | defined $perms or $perms = 0666; | |
103 | return sysopen($fh, $file, $mode, $perms); | |
104 | } | |
105 | $file = "./" . $file unless $file =~ m#^/#; | |
106 | $file = _open_mode_string($mode) . " $file\0"; | |
107 | } | |
108 | open($fh, $file); | |
109 | } | |
110 | sub close { | |
111 | @_ == 1 or croak('usage: $fh->close()'); | |
112 | close($_[0]); | |
113 | } | |
114 | } | |
115 | ||
116 | use vars qw( | |
117 | $VERSION $Version_OK $Revision | |
118 | $Verbose %MM_Sections | |
119 | @MM_Sections %Recognized_Att_Keys @Get_from_Config | |
120 | %Prepend_dot_dot %Config @Parent %NORMAL_INC | |
121 | $Setup_done | |
122 | ); | |
8e07c86e | 123 | #use strict qw(refs); |
005c1a0e | 124 | |
8e07c86e AD |
125 | eval {require DynaLoader;}; # Get mod2fname, if defined. Will fail |
126 | # with miniperl. | |
005c1a0e | 127 | |
e05e23b1 | 128 | # |
129 | # Set up the inheritance before we pull in the MM_* packages, because they | |
130 | # import variables and functions from here | |
131 | # | |
132 | @ISA = qw(Exporter); | |
133 | @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt); | |
134 | @EXPORT_OK = qw($VERSION &Version_check &help &neatvalue &mkbootstrap &mksymlists | |
135 | $Version %att); ## Import of %att is deprecated, please use OO features! | |
136 | # $Version in mixed case will go away! | |
005c1a0e | 137 | |
e05e23b1 | 138 | # |
139 | # Dummy package MM inherits actual methods from OS-specific | |
140 | # default packages. We use this intermediate package so | |
141 | # MY::XYZ->func() can call MM->func() and get the proper | |
142 | # default routine without having to know under what OS | |
143 | # it's running. | |
144 | # | |
145 | @MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::Liblist ExtUtils::MakeMaker]; | |
42793c05 | 146 | |
e05e23b1 | 147 | # |
148 | # Setup dummy package: | |
149 | # MY exists for overriding methods to be defined within | |
150 | # | |
151 | { | |
152 | package MY; | |
153 | @ISA = qw(MM); | |
154 | } | |
42793c05 | 155 | |
e05e23b1 | 156 | { |
157 | package MM; | |
158 | # From somwhere they will want to inherit DESTROY | |
159 | sub DESTROY {} | |
160 | } | |
42793c05 | 161 | |
e05e23b1 | 162 | # |
a5f75d66 AD |
163 | # Now we can can pull in the friends |
164 | # Since they will require us back, we would better prepare the needed | |
165 | # data _before_ we require them. | |
e05e23b1 | 166 | # |
a5f75d66 AD |
167 | $Is_VMS = ($Config{osname} eq 'VMS'); |
168 | $Is_OS2 = ($Config{osname} =~ m|^os/?2$|i); | |
169 | ||
e05e23b1 | 170 | require ExtUtils::MM_Unix; |
a5f75d66 | 171 | if ($Is_VMS) { |
0d8023a2 | 172 | require ExtUtils::MM_VMS; |
173 | require VMS::Filespec; | |
174 | import VMS::Filespec '&vmsify'; | |
175 | } | |
a5f75d66 | 176 | if ($Is_OS2) { |
e05e23b1 | 177 | require ExtUtils::MM_OS2; |
178 | } | |
75f92628 | 179 | |
e05e23b1 | 180 | %NORMAL_INC = %INC; |
181 | # package name for the classes into which the first object will be blessed | |
182 | $PACKNAME = "PACK000"; | |
42793c05 | 183 | |
e05e23b1 | 184 | ##### |
185 | # # # # ##### | |
186 | # # # # # | |
187 | ##### # # ##### | |
188 | # # # # # | |
189 | # # # # # # | |
190 | ##### #### ##### | |
4633a7c4 | 191 | |
864a5fa8 | 192 | |
e05e23b1 | 193 | # |
194 | # MakeMaker serves currently (v 5.20) only for two purposes: | |
195 | # Version_Check, and WriteMakefile. For WriteMakefile SelfLoader | |
196 | # doesn't buy us anything. But for Version_Check we win with | |
197 | # SelfLoader more than a second. | |
198 | # | |
199 | # The only subroutine we do not SelfLoad is Version_Check because it's | |
200 | # called so often. Loading this minimum still requires 1.2 secs on my | |
201 | # Indy :-( | |
202 | # | |
203 | ||
204 | sub Version_check { | |
205 | my($checkversion) = @_; | |
206 | die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion. | |
207 | Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable | |
208 | changes in the meantime. | |
209 | Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n" | |
210 | if $checkversion < $Version_OK; | |
211 | printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v", | |
212 | $checkversion, "Current Version is", $VERSION | |
213 | unless $checkversion == $VERSION; | |
8e07c86e | 214 | } |
e05e23b1 | 215 | |
216 | # We don't selfload this, because chdir sometimes has problems | |
217 | sub eval_in_subdirs { | |
218 | my($self) = @_; | |
219 | my($dir); | |
220 | # print "Starting to wade through directories:\n"; | |
221 | # print join "\n", @{$self->{DIR}}, "\n"; | |
222 | my $pwd = cwd(); | |
223 | ||
224 | # As strange things happened twice in the history of MakeMaker to $self->{DIR}, | |
225 | # lets be careful, maybe it helps some: | |
226 | # my(@copy_of_DIR) = @{$self->{DIR}}; | |
227 | # my %copy; | |
228 | # @copy{@copy_od_DIR} = (1) x @copy_of_DIR; | |
229 | ||
230 | # with Tk-9.02 these give me as third directory "1": | |
231 | # foreach $dir (@($self->{DIR}){ | |
232 | # foreach $dir (@copy_of_DIR){ | |
233 | ||
234 | # this gives mi as third directory a core dump: | |
235 | # while ($dir = shift @copy_of_DIR){ | |
236 | ||
237 | # this finishes the loop immediately: | |
238 | # foreach $dir (keys %copy){ | |
239 | # print "Next to come: $dir\n"; | |
240 | # chdir $dir or die "Couldn't change to directory $dir: $!"; | |
241 | # package main; | |
242 | # my $fh = new FileHandle; | |
243 | # $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir"); | |
244 | # my $eval = join "", <$fh>; | |
245 | # $fh->close; | |
246 | # eval $eval; | |
247 | # warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@; | |
248 | # chdir $pwd or die "Couldn't change to directory $pwd: $!"; | |
249 | # } | |
250 | ||
251 | ||
252 | # So this did the trick (did it?) | |
253 | foreach $dir (@{$self->{DIR}}){ | |
254 | # print "Next to come: $dir\n"; | |
255 | my($abs) = $self->catdir($pwd,$dir); | |
256 | $self->eval_in_x($abs); | |
257 | } | |
258 | ||
259 | chdir $pwd; | |
260 | ||
261 | # print "Proudly presenting you self->{DIR}:\n"; | |
262 | # print join "\n", @{$self->{DIR}}, "\n"; | |
263 | ||
864a5fa8 | 264 | } |
42793c05 | 265 | |
e05e23b1 | 266 | sub eval_in_x { |
267 | my($self,$dir) = @_; | |
268 | package main; | |
269 | chdir $dir or carp("Couldn't change to directory $dir: $!"); | |
270 | my $fh = new FileHandle; | |
271 | $fh->open("Makefile.PL") or carp("Couldn't open Makefile.PL in $dir"); | |
272 | my $eval = join "", <$fh>; | |
273 | $fh->close; | |
274 | eval $eval; | |
275 | warn "WARNING from evaluation of $dir/Makefile.PL: $@" if $@; | |
276 | } | |
277 | ||
278 | # use SelfLoader; | |
279 | # sub ExtUtils::MakeMaker::full_setup ; | |
280 | # sub ExtUtils::MakeMaker::attrib_help ; | |
281 | # sub ExtUtils::MakeMaker::writeMakefile ; | |
282 | # sub ExtUtils::MakeMaker::WriteMakefile ; | |
283 | # sub ExtUtils::MakeMaker::new ; | |
284 | # sub ExtUtils::MakeMaker::check_manifest ; | |
285 | # sub ExtUtils::MakeMaker::parse_args ; | |
286 | # sub ExtUtils::MakeMaker::check_hints ; | |
287 | # sub ExtUtils::MakeMaker::mv_all_methods ; | |
288 | # sub ExtUtils::MakeMaker::prompt ; | |
289 | # sub ExtUtils::MakeMaker::help ; | |
290 | # sub ExtUtils::MakeMaker::skipcheck ; | |
291 | # sub ExtUtils::MakeMaker::flush ; | |
292 | # sub ExtUtils::MakeMaker::mkbootstrap ; | |
293 | # sub ExtUtils::MakeMaker::mksymlists ; | |
294 | # sub ExtUtils::MakeMaker::neatvalue ; | |
295 | # sub ExtUtils::MakeMaker::selfdocument ; | |
296 | ||
297 | # 1; | |
298 | ||
299 | # __DATA__ | |
300 | ||
301 | # | |
302 | # We're done with inheritance setup. As we have two frequently called | |
303 | # things: Check_Version() and mod_install(), we want to reduce startup | |
304 | # time. Only WriteMakefile needs all the power here. | |
305 | # | |
306 | ||
307 | sub full_setup { | |
308 | $Verbose ||= 0; | |
309 | $^W=1; | |
310 | $SIG{__WARN__} = sub { | |
311 | $_[0] =~ /^Use of uninitialized value/ && return; | |
312 | $_[0] =~ /used only once/ && return; | |
313 | $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return; | |
314 | warn @_; | |
315 | }; | |
316 | ||
317 | @MM_Sections = | |
318 | qw( | |
319 | post_initialize const_config constants const_loadlibs | |
320 | const_cccmd tool_autosplit tool_xsubpp tools_other dist macro | |
321 | depend post_constants pasthru c_o xs_c xs_o top_targets | |
322 | linkext dlsyms dynamic dynamic_bs dynamic_lib static | |
323 | static_lib installpm manifypods processPL installbin subdirs | |
324 | clean realclean dist_basics dist_core dist_dir dist_test | |
325 | dist_ci install force perldepend makefile staticmake test | |
326 | postamble selfdocument | |
327 | ); # loses section ordering | |
328 | ||
329 | @MM_Sections{@MM_Sections} = {} x @MM_Sections; | |
330 | ||
331 | # All sections are valid keys. | |
332 | %Recognized_Att_Keys = %MM_Sections; | |
333 | ||
334 | # we will use all these variables in the Makefile | |
335 | @Get_from_Config = | |
336 | qw( | |
337 | ar cc cccdlflags ccdlflags dlext dlsrc ld lddlflags ldflags libc | |
338 | lib_ext obj_ext ranlib sitelibexp sitearchexp so | |
339 | ); | |
340 | ||
341 | my $item; | |
342 | foreach $item (split(/\n/,attrib_help())){ | |
343 | next unless $item =~ m/^=item\s+(\w+)\s*$/; | |
344 | $Recognized_Att_Keys{$1} = $2; | |
345 | print "Attribute '$1' => '$2'\n" if ($Verbose >= 2); | |
346 | } | |
347 | foreach $item (@Get_from_Config) { | |
348 | $Recognized_Att_Keys{uc $item} = $Config{$item}; | |
349 | print "Attribute '\U$item\E' => '$Config{$item}'\n" | |
350 | if ($Verbose >= 2); | |
351 | } | |
352 | ||
353 | # | |
354 | # When we pass these through to a Makefile.PL in a subdirectory, we prepend | |
355 | # "..", so that all files to be installed end up below ./blib | |
356 | # | |
357 | %Prepend_dot_dot = | |
358 | qw( | |
359 | INST_LIB 1 INST_ARCHLIB 1 INST_EXE 1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1 | |
360 | PERL_SRC 1 PERL 1 FULLPERL 1 | |
361 | ); | |
362 | ||
363 | } | |
364 | ||
365 | sub attrib_help { | |
366 | return $Attrib_Help if $Attrib_Help; | |
367 | my $switch = 0; | |
368 | my $help = ""; | |
369 | my $line; | |
370 | while ($line = <DATA>) { | |
371 | $switch ||= $line =~ /^=item C\s*$/; | |
372 | next unless $switch; | |
373 | last if $line =~ /^=cut/; | |
374 | $help .= $line; | |
375 | } | |
376 | # close DATA; | |
377 | $Attrib_Help = $help; | |
378 | } | |
42793c05 | 379 | |
8e07c86e AD |
380 | sub writeMakefile { |
381 | die <<END; | |
232e078e | 382 | |
8e07c86e AD |
383 | The extension you are trying to build apparently is rather old and |
384 | most probably outdated. We detect that from the fact, that a | |
385 | subroutine "writeMakefile" is called, and this subroutine is not | |
386 | supported anymore since about October 1994. | |
40000a8c | 387 | |
4633a7c4 LW |
388 | Please contact the author or look into CPAN (details about CPAN can be |
389 | found in the FAQ and at http:/www.perl.com) for a more recent version | |
390 | of the extension. If you're really desperate, you can try to change | |
391 | the subroutine name from writeMakefile to WriteMakefile and rerun | |
392 | 'perl Makefile.PL', but you're most probably left alone, when you do | |
393 | so. | |
42793c05 | 394 | |
8e07c86e | 395 | The MakeMaker team |
1aef975c | 396 | |
42793c05 | 397 | END |
8e07c86e | 398 | } |
42793c05 | 399 | |
8e07c86e AD |
400 | sub WriteMakefile { |
401 | Carp::croak "WriteMakefile: Need even number of args" if @_ % 2; | |
402 | my %att = @_; | |
403 | MM->new(\%att)->flush; | |
42793c05 TB |
404 | } |
405 | ||
8e07c86e AD |
406 | sub new { |
407 | my($class,$self) = @_; | |
e05e23b1 | 408 | full_setup() unless $Setup_done++; |
409 | ||
8e07c86e | 410 | my($key); |
42793c05 | 411 | |
e05e23b1 | 412 | print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose; |
8e07c86e AD |
413 | if (-f "MANIFEST" && ! -f "Makefile"){ |
414 | check_manifest(); | |
1aef975c | 415 | } |
42793c05 | 416 | |
8e07c86e | 417 | $self = {} unless (defined $self); |
005c1a0e | 418 | |
864a5fa8 | 419 | check_hints($self); |
4633a7c4 | 420 | |
8e07c86e | 421 | my(%initial_att) = %$self; # record initial attributes |
005c1a0e | 422 | |
8e07c86e AD |
423 | if (defined $self->{CONFIGURE}) { |
424 | if (ref $self->{CONFIGURE} eq 'CODE') { | |
425 | $self = { %$self, %{&{$self->{CONFIGURE}}}}; | |
005c1a0e | 426 | } else { |
8e07c86e | 427 | croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n"; |
005c1a0e AD |
428 | } |
429 | } | |
a0d0e21e | 430 | |
8e07c86e AD |
431 | # This is for old Makefiles written pre 5.00, will go away |
432 | if ( Carp::longmess("") =~ /runsubdirpl/s ){ | |
e05e23b1 | 433 | #$self->{Correct_relativ_directories}++; |
434 | carp("WARNING: Please rerun 'perl Makefile.PL' to regenerate your Makefiles\n"); | |
8e07c86e AD |
435 | } else { |
436 | $self->{Correct_relativ_directories}=0; | |
437 | } | |
5d94fbed | 438 | |
8e07c86e AD |
439 | my $class = ++$PACKNAME; |
440 | { | |
441 | # no strict; | |
e05e23b1 | 442 | print "Blessing Object into class [$class]\n" if $Verbose>=2; |
8e07c86e AD |
443 | mv_all_methods("MY",$class); |
444 | bless $self, $class; | |
e05e23b1 | 445 | push @Parent, $self; |
8e07c86e AD |
446 | @{"$class\:\:ISA"} = 'MM'; |
447 | } | |
5d94fbed | 448 | |
e05e23b1 | 449 | if (defined $Parent[-2]){ |
450 | $self->{PARENT} = $Parent[-2]; | |
8e07c86e | 451 | my $key; |
e05e23b1 | 452 | for $key (keys %Prepend_dot_dot) { |
4633a7c4 | 453 | next unless defined $self->{PARENT}{$key}; |
8e07c86e AD |
454 | $self->{$key} = $self->{PARENT}{$key}; |
455 | $self->{$key} = $self->catdir("..",$self->{$key}) | |
456 | unless $self->{$key} =~ m!^/!; | |
457 | } | |
458 | $self->{PARENT}->{CHILDREN}->{$class} = $self if $self->{PARENT}; | |
459 | } else { | |
460 | parse_args($self,@ARGV); | |
461 | } | |
a0d0e21e | 462 | |
8e07c86e | 463 | $self->{NAME} ||= $self->guess_name; |
a0d0e21e | 464 | |
8e07c86e | 465 | ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g; |
a0d0e21e | 466 | |
8e07c86e AD |
467 | $self->init_main(); |
468 | ||
0d8023a2 | 469 | if (! $self->{PERL_SRC} ) { |
470 | my($pthinks) = $INC{'Config.pm'}; | |
471 | $pthinks = vmsify($pthinks) if $Is_VMS; | |
e05e23b1 | 472 | if ($pthinks ne $self->catfile($Config{archlibexp},'Config.pm')){ |
0d8023a2 | 473 | $pthinks =~ s!/Config\.pm$!!; |
474 | $pthinks =~ s!.*/!!; | |
475 | print STDOUT <<END; | |
005c1a0e AD |
476 | Your perl and your Config.pm seem to have different ideas about the architecture |
477 | they are running on. | |
8e07c86e | 478 | Perl thinks: [$pthinks] |
e05e23b1 | 479 | Config says: [$Config{archname}] |
005c1a0e AD |
480 | This may or may not cause problems. Please check your installation of perl if you |
481 | have problems building this extension. | |
482 | END | |
0d8023a2 | 483 | } |
005c1a0e AD |
484 | } |
485 | ||
8e07c86e AD |
486 | $self->init_dirscan(); |
487 | $self->init_others(); | |
75f92628 | 488 | |
8e07c86e AD |
489 | push @{$self->{RESULT}}, <<END; |
490 | # This Makefile is for the $self->{NAME} extension to perl. | |
491 | # | |
e05e23b1 | 492 | # It was generated automatically by MakeMaker version |
493 | # $VERSION (Revision: $Revision) from the contents of | |
494 | # Makefile.PL. Don't edit this file, edit Makefile.PL instead. | |
8e07c86e AD |
495 | # |
496 | # ANY CHANGES MADE HERE WILL BE LOST! | |
497 | # | |
498 | # MakeMaker Parameters: | |
499 | END | |
a0d0e21e | 500 | |
42793c05 TB |
501 | foreach $key (sort keys %initial_att){ |
502 | my($v) = neatvalue($initial_att{$key}); | |
8e07c86e | 503 | $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/; |
42793c05 | 504 | $v =~ tr/\n/ /s; |
8e07c86e | 505 | push @{$self->{RESULT}}, "# $key => $v"; |
42793c05 | 506 | } |
a0d0e21e | 507 | |
8e07c86e AD |
508 | # turn the SKIP array into a SKIPHASH hash |
509 | my (%skip,$skip); | |
510 | for $skip (@{$self->{SKIP} || []}) { | |
511 | $self->{SKIPHASH}{$skip} = 1; | |
512 | } | |
42793c05 | 513 | |
8e07c86e AD |
514 | # We run all the subdirectories now. They don't have much to query |
515 | # from the parent, but the parent has to query them: if they need linking! | |
8e07c86e | 516 | unless ($self->{NORECURS}) { |
e05e23b1 | 517 | $self->eval_in_subdirs if @{$self->{DIR}}; |
42793c05 | 518 | } |
a0d0e21e | 519 | |
8e07c86e AD |
520 | tie %::att, ExtUtils::MakeMaker::TieAtt, $self; |
521 | my $section; | |
e05e23b1 | 522 | foreach $section ( @MM_Sections ){ |
523 | print "Processing Makefile '$section' section\n" if ($Verbose >= 2); | |
8e07c86e AD |
524 | my($skipit) = $self->skipcheck($section); |
525 | if ($skipit){ | |
526 | push @{$self->{RESULT}}, "\n# --- MakeMaker $section section $skipit."; | |
4e68a208 | 527 | } else { |
8e07c86e AD |
528 | my(%a) = %{$self->{$section} || {}}; |
529 | push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:"; | |
e05e23b1 | 530 | push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a; |
8e07c86e | 531 | push @{$self->{RESULT}}, $self->nicetext($self->$section( %a )); |
e05e23b1 | 532 | } |
232e078e | 533 | } |
8e07c86e | 534 | |
e05e23b1 | 535 | push @{$self->{RESULT}}, "\n# End."; |
536 | pop @Parent; | |
8e07c86e | 537 | |
e05e23b1 | 538 | $self; |
232e078e AD |
539 | } |
540 | ||
e05e23b1 | 541 | sub check_manifest { |
542 | print STDOUT "Checking if your kit is complete...\n"; | |
543 | $ExtUtils::Manifest::Quiet=$ExtUtils::Manifest::Quiet=1; #avoid warning | |
544 | my(@missed)=ExtUtils::Manifest::manicheck(); | |
545 | if (@missed){ | |
546 | print STDOUT "Warning: the following files are missing in your kit:\n"; | |
547 | print "\t", join "\n\t", @missed; | |
548 | print STDOUT "\n"; | |
549 | print STDOUT "Please inform the author.\n"; | |
8e07c86e | 550 | } else { |
e05e23b1 | 551 | print STDOUT "Looks good\n"; |
8e07c86e | 552 | } |
8e07c86e AD |
553 | } |
554 | ||
e05e23b1 | 555 | sub parse_args{ |
556 | my($self, @args) = @_; | |
557 | foreach (@args){ | |
558 | unless (m/(.*?)=(.*)/){ | |
559 | help(),exit 1 if m/^help$/; | |
560 | ++$Verbose if m/^verb/; | |
561 | next; | |
562 | } | |
563 | my($name, $value) = ($1, $2); | |
564 | if ($value =~ m/^~(\w+)?/){ # tilde with optional username | |
565 | $value =~ s [^~(\w*)] | |
566 | [$1 ? | |
567 | ((getpwnam($1))[7] || "~$1") : | |
568 | (getpwuid($>))[7] | |
569 | ]ex; | |
570 | } | |
571 | # This may go away, in mid 1996 | |
572 | if ($self->{Correct_relativ_directories}){ | |
573 | $value = $self->catdir("..",$value) | |
574 | if $Prepend_dot_dot{$name} && ! $value =~ m!^/!; | |
575 | } | |
a5f75d66 | 576 | $self->{uc($name)} = $value; |
8e07c86e | 577 | } |
e05e23b1 | 578 | # This may go away, in mid 1996 |
579 | delete $self->{Correct_relativ_directories}; | |
8e07c86e | 580 | |
e05e23b1 | 581 | # catch old-style 'potential_libs' and inform user how to 'upgrade' |
582 | if (defined $self->{potential_libs}){ | |
583 | my($msg)="'potential_libs' => '$self->{potential_libs}' should be"; | |
584 | if ($self->{potential_libs}){ | |
585 | print STDOUT "$msg changed to:\n\t'LIBS' => ['$self->{potential_libs}']\n"; | |
586 | } else { | |
587 | print STDOUT "$msg deleted.\n"; | |
588 | } | |
589 | $self->{LIBS} = [$self->{potential_libs}]; | |
590 | delete $self->{potential_libs}; | |
8e07c86e | 591 | } |
e05e23b1 | 592 | # catch old-style 'ARMAYBE' and inform user how to 'upgrade' |
593 | if (defined $self->{ARMAYBE}){ | |
594 | my($armaybe) = $self->{ARMAYBE}; | |
595 | print STDOUT "ARMAYBE => '$armaybe' should be changed to:\n", | |
596 | "\t'dynamic_lib' => {ARMAYBE => '$armaybe'}\n"; | |
597 | my(%dl) = %{$self->{dynamic_lib} || {}}; | |
598 | $self->{dynamic_lib} = { %dl, ARMAYBE => $armaybe}; | |
599 | delete $self->{ARMAYBE}; | |
8e07c86e | 600 | } |
e05e23b1 | 601 | if (defined $self->{LDTARGET}){ |
602 | print STDOUT "LDTARGET should be changed to LDFROM\n"; | |
603 | $self->{LDFROM} = $self->{LDTARGET}; | |
604 | delete $self->{LDTARGET}; | |
8e07c86e | 605 | } |
e05e23b1 | 606 | # Turn a DIR argument on the command line into an array |
607 | if (defined $self->{DIR} && ref \$self->{DIR} eq 'SCALAR') { | |
608 | # So they can choose from the command line, which extensions they want | |
609 | # the grep enables them to have some colons too much in case they | |
610 | # have to build a list with the shell | |
611 | $self->{DIR} = [grep $_, split ":", $self->{DIR}]; | |
8e07c86e | 612 | } |
e05e23b1 | 613 | my $mmkey; |
614 | foreach $mmkey (sort keys %$self){ | |
615 | print STDOUT " $mmkey => ", neatvalue($self->{$mmkey}), "\n" if $Verbose; | |
616 | print STDOUT "'$mmkey' is not a known MakeMaker parameter name.\n" | |
617 | unless exists $Recognized_Att_Keys{$mmkey}; | |
618 | } | |
619 | } | |
8e07c86e | 620 | |
e05e23b1 | 621 | sub check_hints { |
622 | my($self) = @_; | |
623 | # We allow extension-specific hints files. | |
864a5fa8 | 624 | |
e05e23b1 | 625 | return unless -d "hints"; |
8e07c86e | 626 | |
e05e23b1 | 627 | # First we look for the best hintsfile we have |
628 | my(@goodhints); | |
629 | my($hint)="$Config{osname}_$Config{osvers}"; | |
630 | $hint =~ s/\./_/g; | |
631 | $hint =~ s/_$//; | |
632 | return unless $hint; | |
fed7345c | 633 | |
e05e23b1 | 634 | # Also try without trailing minor version numbers. |
635 | while (1) { | |
636 | last if -f "hints/$hint.pl"; # found | |
637 | } continue { | |
638 | last unless $hint =~ s/_[^_]*$//; # nothing to cut off | |
639 | } | |
640 | return unless -f "hints/$hint.pl"; # really there | |
fed7345c | 641 | |
e05e23b1 | 642 | # execute the hintsfile: |
643 | my $fh = new FileHandle; | |
644 | $fh->open("hints/$hint.pl"); | |
645 | @goodhints = <$fh>; | |
646 | $fh->close; | |
647 | print STDOUT "Processing hints file hints/$hint.pl\n"; | |
648 | eval join('',@goodhints); | |
649 | print STDOUT $@ if $@; | |
650 | } | |
8e07c86e | 651 | |
e05e23b1 | 652 | sub mv_all_methods { |
653 | my($from,$to) = @_; | |
654 | my($method); | |
655 | my($symtab) = \%{"${from}::"}; | |
656 | # no strict; | |
fed7345c | 657 | |
e05e23b1 | 658 | # Here you see the *current* list of methods that are overridable |
659 | # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm | |
660 | # still trying to reduce the list to some reasonable minimum -- | |
661 | # because I want to make it easier for the user. A.K. | |
40000a8c | 662 | |
e05e23b1 | 663 | foreach $method (@MM_Sections, qw[ dir_target |
664 | fileparse fileparse_set_fstype installpm_x libscan makeaperl | |
665 | mksymlists needs_linking subdir_x test_via_harness | |
666 | test_via_script writedoc ]) { | |
fed7345c | 667 | |
e05e23b1 | 668 | # We cannot say "next" here. Nick might call MY->makeaperl |
669 | # which isn't defined right now | |
fed7345c | 670 | |
e05e23b1 | 671 | # next unless defined &{"${from}::$method"}; |
fed7345c | 672 | |
e05e23b1 | 673 | *{"${to}::$method"} = \&{"${from}::$method"}; |
8e07c86e | 674 | |
e05e23b1 | 675 | # delete would do, if we were sure, nobody ever called |
676 | # MY->makeaperl directly | |
232e078e | 677 | |
e05e23b1 | 678 | # delete $symtab->{$method}; |
fed7345c | 679 | |
e05e23b1 | 680 | # If we delete a method, then it will be undefined and cannot |
681 | # be called. But as long as we have Makefile.PLs that rely on | |
682 | # %MY:: being intact, we have to fill the hole with an | |
683 | # inheriting method: | |
fed7345c | 684 | |
e05e23b1 | 685 | eval "package MY; sub $method {local *$method; shift->MY::$method(\@_); }"; |
5d94fbed | 686 | |
5d94fbed AD |
687 | } |
688 | ||
e05e23b1 | 689 | # We have to clean out %INC also, because the current directory is |
690 | # changed frequently and Graham Barr prefers to get his version | |
691 | # out of a History.pl file which is "required" so woudn't get | |
692 | # loaded again in another extension requiring a History.pl | |
a0d0e21e | 693 | |
e05e23b1 | 694 | my $inc; |
695 | foreach $inc (keys %INC) { | |
696 | next if $NORMAL_INC{$inc}; | |
697 | #warn "***$inc*** deleted"; | |
698 | delete $INC{$inc}; | |
8e07c86e | 699 | } |
a0d0e21e | 700 | |
8e07c86e AD |
701 | } |
702 | ||
e05e23b1 | 703 | sub prompt { |
704 | my($mess,$def)=@_; | |
705 | BEGIN { $ISA_TTY = -t STDIN && -t STDOUT } | |
706 | Carp::confess("prompt function called without an argument") unless defined $mess; | |
707 | $def = "" unless defined $def; | |
708 | my $dispdef = "[$def] "; | |
709 | my $ans; | |
710 | if ($ISA_TTY) { | |
711 | local $|=1; | |
712 | print "$mess $dispdef"; | |
713 | chop($ans = <STDIN>); | |
8e07c86e | 714 | } |
e05e23b1 | 715 | return $ans if defined $ans; |
716 | return $def; | |
42793c05 | 717 | } |
fed7345c | 718 | |
e05e23b1 | 719 | sub help {print &attrib_help, "\n";} |
8e07c86e | 720 | |
e05e23b1 | 721 | sub skipcheck{ |
8e07c86e | 722 | my($self) = shift; |
e05e23b1 | 723 | my($section) = @_; |
724 | if ($section eq 'dynamic') { | |
725 | print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ", | |
726 | "in skipped section 'dynamic_bs'\n" | |
727 | if $self->{SKIPHASH}{dynamic_bs} && $Verbose; | |
728 | print STDOUT "Warning (non-fatal): Target 'dynamic' depends on targets ", | |
729 | "in skipped section 'dynamic_lib'\n" | |
730 | if $self->{SKIPHASH}{dynamic_lib} && $Verbose; | |
8e07c86e | 731 | } |
e05e23b1 | 732 | if ($section eq 'dynamic_lib') { |
733 | print STDOUT "Warning (non-fatal): Target '\$(INST_DYNAMIC)' depends on ", | |
734 | "targets in skipped section 'dynamic_bs'\n" | |
735 | if $self->{SKIPHASH}{dynamic_bs} && $Verbose; | |
736 | } | |
737 | if ($section eq 'static') { | |
738 | print STDOUT "Warning (non-fatal): Target 'static' depends on targets ", | |
739 | "in skipped section 'static_lib'\n" | |
740 | if $self->{SKIPHASH}{static_lib} && $Verbose; | |
8e07c86e | 741 | } |
e05e23b1 | 742 | return 'skipped' if $self->{SKIPHASH}{$section}; |
743 | return ''; | |
8e07c86e AD |
744 | } |
745 | ||
e05e23b1 | 746 | sub flush { |
747 | my $self = shift; | |
748 | my($chunk); | |
749 | my $fh = new FileHandle; | |
750 | print STDOUT "Writing $self->{MAKEFILE} for $self->{NAME}\n"; | |
8e07c86e | 751 | |
e05e23b1 | 752 | unlink($self->{MAKEFILE}, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ''); |
753 | $fh->open(">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!"; | |
8e07c86e | 754 | |
e05e23b1 | 755 | for $chunk (@{$self->{RESULT}}) { |
756 | print $fh "$chunk\n"; | |
8e07c86e | 757 | } |
e05e23b1 | 758 | |
759 | $fh->close; | |
760 | my($finalname) = $self->{MAKEFILE}; | |
761 | rename("MakeMaker.tmp", $finalname); | |
762 | chmod 0644, $finalname unless $Is_VMS; | |
763 | system("$Config::Config{eunicefix} $finalname") unless $Config::Config{eunicefix} eq ":"; | |
40000a8c AD |
764 | } |
765 | ||
e05e23b1 | 766 | # The following mkbootstrap() is only for installations that are calling |
767 | # the pre-4.1 mkbootstrap() from their old Makefiles. This MakeMaker | |
768 | # writes Makefiles, that use ExtUtils::Mkbootstrap directly. | |
769 | sub mkbootstrap { | |
770 | die <<END; | |
771 | !!! Your Makefile has been built such a long time ago, !!! | |
772 | !!! that is unlikely to work with current MakeMaker. !!! | |
773 | !!! Please rebuild your Makefile !!! | |
774 | END | |
8e07c86e | 775 | } |
005c1a0e | 776 | |
e05e23b1 | 777 | # Ditto for mksymlists() as of MakeMaker 5.17 |
778 | sub mksymlists { | |
779 | die <<END; | |
780 | !!! Your Makefile has been built such a long time ago, !!! | |
781 | !!! that is unlikely to work with current MakeMaker. !!! | |
782 | !!! Please rebuild your Makefile !!! | |
783 | END | |
4633a7c4 LW |
784 | } |
785 | ||
e05e23b1 | 786 | sub neatvalue { |
787 | my($v) = @_; | |
788 | return "undef" unless defined $v; | |
789 | my($t) = ref $v; | |
790 | return "q[$v]" unless $t; | |
791 | if ($t eq 'ARRAY') { | |
792 | my(@m, $elem, @neat); | |
793 | push @m, "["; | |
794 | foreach $elem (@$v) { | |
795 | push @neat, "q[$elem]"; | |
796 | } | |
797 | push @m, join ", ", @neat; | |
798 | push @m, "]"; | |
799 | return join "", @m; | |
800 | } | |
801 | return "$v" unless $t eq 'HASH'; | |
802 | my(@m, $key, $val); | |
803 | push(@m,"$key=>".neatvalue($val)) while (($key,$val) = each %$v); | |
804 | return "{ ".join(', ',@m)." }"; | |
4e68a208 AD |
805 | } |
806 | ||
e05e23b1 | 807 | sub selfdocument { |
808 | my($self) = @_; | |
809 | my(@m); | |
810 | if ($Verbose){ | |
811 | push @m, "\n# Full list of MakeMaker attribute values:"; | |
812 | foreach $key (sort keys %$self){ | |
813 | next if $key eq 'RESULT' || $key =~ /^[A-Z][a-z]/; | |
814 | my($v) = neatvalue($self->{$key}); | |
815 | $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/; | |
816 | $v =~ tr/\n/ /s; | |
817 | push @m, "# $key => $v"; | |
818 | } | |
819 | } | |
820 | join "\n", @m; | |
821 | } | |
4e68a208 | 822 | |
005c1a0e AD |
823 | package ExtUtils::MakeMaker; |
824 | 1; | |
825 | ||
e05e23b1 | 826 | # Without selfLoader we need |
827 | __DATA__ | |
828 | ||
829 | ||
830 | # For SelfLoader we need | |
831 | # __END__ DATA | |
832 | ||
005c1a0e AD |
833 | |
834 | =head1 NAME | |
835 | ||
836 | ExtUtils::MakeMaker - create an extension Makefile | |
837 | ||
838 | =head1 SYNOPSIS | |
839 | ||
840 | C<use ExtUtils::MakeMaker;> | |
841 | ||
842 | C<WriteMakefile( ATTRIBUTE =E<gt> VALUE [, ...] );> | |
843 | ||
8e07c86e AD |
844 | which is really |
845 | ||
846 | C<MM-E<gt>new(\%att)-E<gt>flush;> | |
847 | ||
005c1a0e AD |
848 | =head1 DESCRIPTION |
849 | ||
850 | This utility is designed to write a Makefile for an extension module | |
851 | from a Makefile.PL. It is based on the Makefile.SH model provided by | |
852 | Andy Dougherty and the perl5-porters. | |
853 | ||
854 | It splits the task of generating the Makefile into several subroutines | |
855 | that can be individually overridden. Each subroutine returns the text | |
856 | it wishes to have written to the Makefile. | |
857 | ||
4633a7c4 LW |
858 | =head2 Hintsfile support |
859 | ||
005c1a0e | 860 | MakeMaker.pm uses the architecture specific information from |
8e07c86e AD |
861 | Config.pm. In addition it evaluates architecture specific hints files |
862 | in a C<hints/> directory. The hints files are expected to be named | |
863 | like their counterparts in C<PERL_SRC/hints>, but with an C<.pl> file | |
864 | name extension (eg. C<next_3_2.pl>). They are simply C<eval>ed by | |
865 | MakeMaker within the WriteMakefile() subroutine, and can be used to | |
866 | execute commands as well as to include special variables. The rules | |
867 | which hintsfile is chosen are the same as in Configure. | |
868 | ||
4633a7c4 LW |
869 | The hintsfile is eval()ed immediately after the arguments given to |
870 | WriteMakefile are stuffed into a hash reference $self but before this | |
871 | reference becomes blessed. So if you want to do the equivalent to | |
872 | override or create an attribute you would say something like | |
873 | ||
874 | $self->{LIBS} = ['-ldbm -lucb -lc']; | |
875 | ||
8e07c86e AD |
876 | =head2 What's new in version 5 of MakeMaker |
877 | ||
878 | MakeMaker 5 is pure object oriented. This allows us to write an | |
879 | unlimited number of Makefiles with a single perl process. 'perl | |
880 | Makefile.PL' with MakeMaker 5 goes through all subdirectories | |
881 | immediately and evaluates any Makefile.PL found in the next level | |
882 | subdirectories. The benefit of this approach comes in useful for both | |
883 | single and multi directories extensions. | |
884 | ||
885 | Multi directory extensions have an immediately visible speed | |
886 | advantage, because there's no startup penalty for any single | |
887 | subdirectory Makefile. | |
888 | ||
889 | Single directory packages benefit from the much improved | |
890 | needs_linking() method. As the main Makefile knows everything about | |
891 | the subdirectories, a needs_linking() method can now query all | |
892 | subdirectories if there is any linking involved down in the tree. The | |
893 | speedup for PM-only Makefiles seems to be around 1 second on my | |
894 | Indy 100 MHz. | |
895 | ||
896 | =head2 Incompatibilities between MakeMaker 5.00 and 4.23 | |
897 | ||
898 | There are no incompatibilities in the short term, as all changes are | |
899 | accompanied by short-term workarounds that guarantee full backwards | |
900 | compatibility. | |
901 | ||
4633a7c4 | 902 | You are likely to face a few warnings that expose deprecations which |
8e07c86e AD |
903 | will result in incompatibilities in the long run: |
904 | ||
905 | You should not use %att directly anymore. Instead any subroutine you | |
906 | override in the MY package will be called by the object method, so you | |
907 | can access all object attributes directly via the object in $_[0]. | |
908 | ||
909 | You should not call the class methos MM->something anymore. Instead | |
910 | you should call the superclass. Something like | |
911 | ||
912 | sub MY::constants { | |
913 | my $self = shift; | |
8e07c86e AD |
914 | $self->MM::constants(); |
915 | } | |
916 | ||
917 | Especially the libscan() and exescan() methods should be altered | |
918 | towards OO programming, that means do not expect that $_ to contain | |
919 | the path but rather $_[1]. | |
920 | ||
8e07c86e | 921 | Try to build several extensions simultanously to debug your |
e05e23b1 | 922 | Makefile.PL. You can unpack a bunch of distributed packages within one |
923 | directory and run | |
8e07c86e | 924 | |
e05e23b1 | 925 | perl -MExtUtils::MakeMaker -e 'WriteMakefile()' |
8e07c86e AD |
926 | |
927 | That's actually fun to watch :) | |
928 | ||
929 | Final suggestion: Try to delete all of your MY:: subroutines and | |
930 | watch, if you really still need them. MakeMaker might already do what | |
931 | you want without them. That's all about it. | |
932 | ||
005c1a0e AD |
933 | |
934 | =head2 Default Makefile Behaviour | |
935 | ||
936 | The automatically generated Makefile enables the user of the extension | |
937 | to invoke | |
938 | ||
939 | perl Makefile.PL # optionally "perl Makefile.PL verbose" | |
940 | make | |
8e07c86e AD |
941 | make test # optionally set TEST_VERBOSE=1 |
942 | make install # See below | |
005c1a0e AD |
943 | |
944 | The Makefile to be produced may be altered by adding arguments of the | |
e05e23b1 | 945 | form C<KEY=VALUE>. E.g. |
005c1a0e | 946 | |
e05e23b1 | 947 | perl Makefile.PL PREFIX=/tmp/myperl5 |
005c1a0e AD |
948 | |
949 | Other interesting targets in the generated Makefile are | |
950 | ||
951 | make config # to check if the Makefile is up-to-date | |
8e07c86e AD |
952 | make clean # delete local temp files (Makefile gets renamed) |
953 | make realclean # delete derived files (including ./blib) | |
e05e23b1 | 954 | make ci # check in all the files in the MANIFEST file |
005c1a0e AD |
955 | make dist # see below the Distribution Support section |
956 | ||
e05e23b1 | 957 | =head2 make test |
958 | ||
959 | MakeMaker checks for the existence of a file named "test.pl" in the | |
960 | current directory and if it exists it adds commands to the test target | |
961 | of the generated Makefile that will execute the script with the proper | |
962 | set of perl C<-I> options. | |
963 | ||
964 | MakeMaker also checks for any files matching glob("t/*.t"). It will | |
965 | add commands to the test target of the generated Makefile that execute | |
966 | all matching files via the L<Test::Harness> module with the C<-I> | |
967 | switches set correctly. | |
968 | ||
969 | =head2 make install | |
005c1a0e | 970 | |
8e07c86e AD |
971 | make alone puts all relevant files into directories that are named by |
972 | the macros INST_LIB, INST_ARCHLIB, INST_EXE, INST_MAN1DIR, and | |
e05e23b1 | 973 | INST_MAN3DIR. All these default to something below ./blib if |
8e07c86e AD |
974 | you are I<not> building below the perl source directory. If you I<are> |
975 | building below the perl source, INST_LIB and INST_ARCHLIB default to | |
4633a7c4 | 976 | ../../lib, and INST_EXE is not defined. |
005c1a0e | 977 | |
e05e23b1 | 978 | The I<install> target of the generated Makefile copies the files found |
979 | below each of the INST_* directories to their INSTALL* | |
980 | counterparts. Which counterparts are chosen depends on the setting of | |
981 | INSTALLDIRS according to the following table: | |
005c1a0e | 982 | |
e05e23b1 | 983 | INSTALLDIRS set to |
984 | perl site | |
985 | ||
986 | INST_LIB INSTALLPRIVLIB INSTALLSITELIB | |
987 | INST_ARCHLIB INSTALLARCHLIB INSTALLSITEARCH | |
988 | INST_EXE INSTALLBIN | |
989 | INST_MAN1DIR INSTALLMAN1DIR | |
990 | INST_MAN3DIR INSTALLMAN3DIR | |
005c1a0e | 991 | |
8e07c86e AD |
992 | The INSTALL... macros in turn default to their %Config |
993 | ($Config{installprivlib}, $Config{installarchlib}, etc.) counterparts. | |
005c1a0e | 994 | |
e05e23b1 | 995 | If you don't want to keep the defaults, MakeMaker helps you to |
996 | minimize the typing needed: the usual relationship between | |
997 | INSTALLPRIVLIB and INSTALLARCHLIB is determined by Configure at perl | |
998 | compilation time. MakeMaker supports the user who sets | |
999 | INSTALLPRIVLIB. If INSTALLPRIVLIB is set, but INSTALLARCHLIB not, then | |
1000 | MakeMaker defaults the latter to be the same subdirectory of | |
1001 | INSTALLPRIVLIB as Configure decided for the counterparts in %Config , | |
1002 | otherwise it defaults to INSTALLPRIVLIB. The same relationship holds | |
1003 | for INSTALLSITELIB and INSTALLSITEARCH. | |
005c1a0e AD |
1004 | |
1005 | MakeMaker gives you much more freedom than needed to configure | |
1006 | internal variables and get different results. It is worth to mention, | |
1007 | that make(1) also lets you configure most of the variables that are | |
1008 | used in the Makefile. But in the majority of situations this will not | |
1009 | be necessary, and should only be done, if the author of a package | |
1010 | recommends it. | |
1011 | ||
005c1a0e | 1012 | |
8e07c86e | 1013 | =head2 PREFIX attribute |
005c1a0e | 1014 | |
0d8023a2 | 1015 | The PREFIX attribute can be used to set the INSTALL* attributes in one |
1016 | go. The quickest way to install a module in a non-standard place | |
005c1a0e | 1017 | |
8e07c86e | 1018 | perl Makefile.PL PREFIX=~ |
005c1a0e | 1019 | |
0d8023a2 | 1020 | This will replace the string specified by $Config{prefix} in all |
1021 | $Config{install*} values. | |
005c1a0e AD |
1022 | |
1023 | Note, that the tilde expansion is done by MakeMaker, not by perl by | |
8e07c86e | 1024 | default, nor by make. |
005c1a0e | 1025 | |
005c1a0e AD |
1026 | If the user has superuser privileges, and is not working on AFS |
1027 | (Andrew File System) or relatives, then the defaults for | |
8e07c86e | 1028 | INSTALLPRIVLIB, INSTALLARCHLIB, INSTALLBIN, etc. will be appropriate, |
005c1a0e AD |
1029 | and this incantation will be the best: |
1030 | ||
1031 | perl Makefile.PL; make; make test | |
1032 | make install | |
1033 | ||
8e07c86e | 1034 | make install per default writes some documentation of what has been |
e05e23b1 | 1035 | done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This feature |
1036 | can be bypassed by calling make pure_install. | |
8e07c86e AD |
1037 | |
1038 | =head2 AFS users | |
1039 | ||
1040 | will have to specify the installation directories as these most | |
1041 | probably have changed since perl itself has been installed. They will | |
1042 | have to do this by calling | |
1043 | ||
e05e23b1 | 1044 | perl Makefile.PL INSTALLSITELIB=/afs/here/today \ |
8e07c86e AD |
1045 | INSTALLBIN=/afs/there/now INSTALLMAN3DIR=/afs/for/manpages |
1046 | make | |
1047 | ||
e05e23b1 | 1048 | Be careful to repeat this procedure every time you recompile an |
1049 | extension, unless you are sure the AFS installation directories are | |
1050 | still valid. | |
005c1a0e | 1051 | |
8e07c86e | 1052 | =head2 Static Linking of a new Perl Binary |
005c1a0e AD |
1053 | |
1054 | An extension that is built with the above steps is ready to use on | |
1055 | systems supporting dynamic loading. On systems that do not support | |
1056 | dynamic loading, any newly created extension has to be linked together | |
1057 | with the available resources. MakeMaker supports the linking process | |
1058 | by creating appropriate targets in the Makefile whenever an extension | |
1059 | is built. You can invoke the corresponding section of the makefile with | |
1060 | ||
1061 | make perl | |
1062 | ||
1063 | That produces a new perl binary in the current directory with all | |
e05e23b1 | 1064 | extensions linked in that can be found in INST_ARCHLIB , SITELIBEXP, |
1065 | and PERL_ARCHLIB. To do that, MakeMaker writes a new Makefile, on | |
1066 | UNIX, this is called Makefile.aperl (may be system dependent). If you | |
1067 | want to force the creation of a new perl, it is recommended, that you | |
1068 | delete this Makefile.aperl, so the directories are searched-through | |
1069 | for linkable libraries again. | |
005c1a0e AD |
1070 | |
1071 | The binary can be installed into the directory where perl normally | |
1072 | resides on your machine with | |
1073 | ||
1074 | make inst_perl | |
1075 | ||
1076 | To produce a perl binary with a different name than C<perl>, either say | |
1077 | ||
1078 | perl Makefile.PL MAP_TARGET=myperl | |
1079 | make myperl | |
1080 | make inst_perl | |
1081 | ||
1082 | or say | |
1083 | ||
1084 | perl Makefile.PL | |
1085 | make myperl MAP_TARGET=myperl | |
1086 | make inst_perl MAP_TARGET=myperl | |
1087 | ||
1088 | In any case you will be prompted with the correct invocation of the | |
1089 | C<inst_perl> target that installs the new binary into INSTALLBIN. | |
1090 | ||
8e07c86e AD |
1091 | make inst_perl per default writes some documentation of what has been |
1092 | done into the file C<$(INSTALLARCHLIB)/perllocal.pod>. This | |
1093 | can be bypassed by calling make pure_inst_perl. | |
005c1a0e | 1094 | |
e05e23b1 | 1095 | Warning: the inst_perl: target will most probably overwrite your |
1096 | existing perl binary. Use with care! | |
005c1a0e | 1097 | |
8e07c86e AD |
1098 | Sometimes you might want to build a statically linked perl although |
1099 | your system supports dynamic loading. In this case you may explicitly | |
1100 | set the linktype with the invocation of the Makefile.PL or make: | |
1101 | ||
1102 | perl Makefile.PL LINKTYPE=static # recommended | |
1103 | ||
1104 | or | |
1105 | ||
1106 | make LINKTYPE=static # works on most systems | |
1107 | ||
005c1a0e AD |
1108 | =head2 Determination of Perl Library and Installation Locations |
1109 | ||
1110 | MakeMaker needs to know, or to guess, where certain things are | |
e05e23b1 | 1111 | located. Especially INST_LIB and INST_ARCHLIB (where to put the files |
1112 | during the make(1) run), PERL_LIB and PERL_ARCHLIB (where to read | |
1113 | existing modules from), and PERL_INC (header files and C<libperl*.*>). | |
005c1a0e AD |
1114 | |
1115 | Extensions may be built either using the contents of the perl source | |
e05e23b1 | 1116 | directory tree or from the installed perl library. The recommended way |
1117 | is to build extensions after you have run 'make install' on perl | |
1118 | itself. You can do that in any directory on your hard disk that is not | |
1119 | below the perl source tree. The support for extensions below the ext | |
1120 | directory of the perl distribution is only good for the standard | |
1121 | extensions that come with perl. | |
005c1a0e AD |
1122 | |
1123 | If an extension is being built below the C<ext/> directory of the perl | |
e05e23b1 | 1124 | source then MakeMaker will set PERL_SRC automatically (e.g., |
1125 | C<../..>). If PERL_SRC is defined and the extension is recognized as | |
1126 | a standard extension, then other variables default to the following: | |
005c1a0e AD |
1127 | |
1128 | PERL_INC = PERL_SRC | |
1129 | PERL_LIB = PERL_SRC/lib | |
1130 | PERL_ARCHLIB = PERL_SRC/lib | |
1131 | INST_LIB = PERL_LIB | |
1132 | INST_ARCHLIB = PERL_ARCHLIB | |
1133 | ||
1134 | If an extension is being built away from the perl source then MakeMaker | |
1135 | will leave PERL_SRC undefined and default to using the installed copy | |
1136 | of the perl library. The other variables default to the following: | |
1137 | ||
e05e23b1 | 1138 | PERL_INC = $archlibexp/CORE |
1139 | PERL_LIB = $privlibexp | |
1140 | PERL_ARCHLIB = $archlibexp | |
1141 | INST_LIB = ./blib/lib | |
1142 | INST_ARCHLIB = ./blib/arch | |
005c1a0e AD |
1143 | |
1144 | If perl has not yet been installed then PERL_SRC can be defined on the | |
1145 | command line as shown in the previous section. | |
1146 | ||
1147 | =head2 Useful Default Makefile Macros | |
1148 | ||
1149 | FULLEXT = Pathname for extension directory (eg DBD/Oracle). | |
1150 | ||
1151 | BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. | |
1152 | ||
1153 | ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) | |
1154 | ||
005c1a0e AD |
1155 | INST_LIBDIR = C<$(INST_LIB)$(ROOTEXT)> |
1156 | ||
1157 | INST_AUTODIR = C<$(INST_LIB)/auto/$(FULLEXT)> | |
1158 | ||
1159 | INST_ARCHAUTODIR = C<$(INST_ARCHLIB)/auto/$(FULLEXT)> | |
1160 | ||
e05e23b1 | 1161 | =head2 Using Attributes and Parameters |
005c1a0e AD |
1162 | |
1163 | The following attributes can be specified as arguments to WriteMakefile() | |
1164 | or as NAME=VALUE pairs on the command line: | |
1165 | ||
8e07c86e | 1166 | =cut |
005c1a0e | 1167 | |
864a5fa8 | 1168 | # The following "=item C" is used by the attrib_help routine |
8e07c86e AD |
1169 | # likewise the "=back" below. So be careful when changing it! |
1170 | ||
1171 | =over 2 | |
1172 | ||
864a5fa8 | 1173 | =item C |
8e07c86e | 1174 | |
864a5fa8 AD |
1175 | Ref to array of *.c file names. Initialised from a directory scan |
1176 | and the values portion of the XS attribute hash. This is not | |
1177 | currently used by MakeMaker but may be handy in Makefile.PLs. | |
8e07c86e | 1178 | |
864a5fa8 | 1179 | =item CONFIG |
8e07c86e | 1180 | |
864a5fa8 AD |
1181 | Arrayref. E.g. [qw(archname manext)] defines ARCHNAME & MANEXT from |
1182 | config.sh. MakeMaker will add to CONFIG the following values anyway: | |
1183 | ar | |
1184 | cc | |
1185 | cccdlflags | |
1186 | ccdlflags | |
1187 | dlext | |
1188 | dlsrc | |
1189 | ld | |
1190 | lddlflags | |
1191 | ldflags | |
1192 | libc | |
1193 | lib_ext | |
1194 | obj_ext | |
1195 | ranlib | |
e05e23b1 | 1196 | sitelibexp |
1197 | sitearchexp | |
864a5fa8 | 1198 | so |
8e07c86e AD |
1199 | |
1200 | =item CONFIGURE | |
1201 | ||
e05e23b1 | 1202 | CODE reference. The subroutine should return a hash reference. The |
1203 | hash may contain further attributes, e.g. {LIBS => ...}, that have to | |
8e07c86e AD |
1204 | be determined by some evaluation method. |
1205 | ||
864a5fa8 | 1206 | =item DEFINE |
8e07c86e | 1207 | |
864a5fa8 | 1208 | Something like C<"-DHAVE_UNISTD_H"> |
8e07c86e | 1209 | |
864a5fa8 | 1210 | =item DIR |
8e07c86e | 1211 | |
864a5fa8 AD |
1212 | Ref to array of subdirectories containing Makefile.PLs e.g. [ 'sdbm' |
1213 | ] in ext/SDBM_File | |
8e07c86e | 1214 | |
864a5fa8 | 1215 | =item DISTNAME |
8e07c86e | 1216 | |
e05e23b1 | 1217 | Your name for distributing the package (by tar file). This defaults to |
864a5fa8 | 1218 | NAME above. |
8e07c86e | 1219 | |
864a5fa8 | 1220 | =item DL_FUNCS |
8e07c86e | 1221 | |
864a5fa8 AD |
1222 | Hashref of symbol names for routines to be made available as |
1223 | universal symbols. Each key/value pair consists of the package name | |
1224 | and an array of routine names in that package. Used only under AIX | |
1225 | (export lists) and VMS (linker options) at present. The routine | |
1226 | names supplied will be expanded in the same way as XSUB names are | |
1227 | expanded by the XS() macro. Defaults to | |
8e07c86e | 1228 | |
864a5fa8 | 1229 | {"$(NAME)" => ["boot_$(NAME)" ] } |
8e07c86e | 1230 | |
864a5fa8 | 1231 | e.g. |
8e07c86e | 1232 | |
864a5fa8 AD |
1233 | {"RPC" => [qw( boot_rpcb rpcb_gettime getnetconfigent )], |
1234 | "NetconfigPtr" => [ 'DESTROY'] } | |
8e07c86e | 1235 | |
864a5fa8 | 1236 | =item DL_VARS |
8e07c86e | 1237 | |
864a5fa8 AD |
1238 | Array of symbol names for variables to be made available as |
1239 | universal symbols. Used only under AIX (export lists) and VMS | |
1240 | (linker options) at present. Defaults to []. (e.g. [ qw( | |
1241 | Foo_version Foo_numstreams Foo_tree ) ]) | |
8e07c86e | 1242 | |
864a5fa8 | 1243 | =item EXE_FILES |
8e07c86e | 1244 | |
864a5fa8 AD |
1245 | Ref to array of executable files. The files will be copied to the |
1246 | INST_EXE directory. Make realclean will delete them from there | |
1247 | again. | |
8e07c86e | 1248 | |
864a5fa8 AD |
1249 | =item FIRST_MAKEFILE |
1250 | ||
1251 | The name of the Makefile to be produced. Defaults to the contents of | |
1252 | MAKEFILE, but can be overridden. This is used for the second Makefile | |
1253 | that will be produced for the MAP_TARGET. | |
1254 | ||
1255 | =item FULLPERL | |
8e07c86e | 1256 | |
864a5fa8 AD |
1257 | Perl binary able to run this extension. |
1258 | ||
1259 | =item H | |
1260 | ||
1261 | Ref to array of *.h file names. Similar to C. | |
1262 | ||
1263 | =item INC | |
1264 | ||
1265 | Include file dirs eg: C<"-I/usr/5include -I/path/to/inc"> | |
1266 | ||
1267 | =item INSTALLARCHLIB | |
1268 | ||
e05e23b1 | 1269 | Used by 'make install', which copies files from INST_ARCHLIB to this |
1270 | directory if INSTALLDIRS is set to perl. | |
864a5fa8 AD |
1271 | |
1272 | =item INSTALLBIN | |
1273 | ||
e05e23b1 | 1274 | Used by 'make install' which copies files from INST_EXE to this |
1275 | directory. | |
1276 | ||
1277 | =item INSTALLDIRS | |
1278 | ||
1279 | Determines which of the two sets of installation directories to | |
1280 | choose: installprivlib and installarchlib versus installsitelib and | |
1281 | installsitearch. The first pair is chosen with INSTALLDIRS=perl, the | |
1282 | second with INSTALLDIRS=site. Default is site. | |
8e07c86e AD |
1283 | |
1284 | =item INSTALLMAN1DIR | |
1285 | ||
864a5fa8 AD |
1286 | This directory gets the man pages at 'make install' time. Defaults to |
1287 | $Config{installman1dir}. | |
1288 | ||
8e07c86e AD |
1289 | =item INSTALLMAN3DIR |
1290 | ||
864a5fa8 AD |
1291 | This directory gets the man pages at 'make install' time. Defaults to |
1292 | $Config{installman3dir}. | |
8e07c86e | 1293 | |
864a5fa8 | 1294 | =item INSTALLPRIVLIB |
8e07c86e | 1295 | |
e05e23b1 | 1296 | Used by 'make install', which copies files from INST_LIB to this |
1297 | directory if INSTALLDIRS is set to perl. | |
1298 | ||
1299 | =item INSTALLSITELIB | |
1300 | ||
1301 | Used by 'make install', which copies files from INST_LIB to this | |
1302 | directory if INSTALLDIRS is set to site (default). | |
1303 | ||
1304 | =item INSTALLSITEARCH | |
1305 | ||
1306 | Used by 'make install', which copies files from INST_ARCHLIB to this | |
1307 | directory if INSTALLDIRS is set to site (default). | |
8e07c86e | 1308 | |
864a5fa8 | 1309 | =item INST_ARCHLIB |
8e07c86e | 1310 | |
864a5fa8 | 1311 | Same as INST_LIB for architecture dependent files. |
8e07c86e | 1312 | |
864a5fa8 | 1313 | =item INST_EXE |
8e07c86e | 1314 | |
864a5fa8 | 1315 | Directory, where executable scripts should be installed during |
e05e23b1 | 1316 | 'make'. Defaults to "./blib/bin", just to have a dummy location during |
1317 | testing. make install will copy the files in INST_EXE to INSTALLBIN. | |
8e07c86e | 1318 | |
864a5fa8 | 1319 | =item INST_LIB |
8e07c86e | 1320 | |
864a5fa8 AD |
1321 | Directory where we put library files of this extension while building |
1322 | it. | |
8e07c86e | 1323 | |
864a5fa8 | 1324 | =item INST_MAN1DIR |
8e07c86e | 1325 | |
864a5fa8 | 1326 | Directory to hold the man pages at 'make' time |
8e07c86e | 1327 | |
864a5fa8 | 1328 | =item INST_MAN3DIR |
8e07c86e | 1329 | |
864a5fa8 | 1330 | Directory to hold the man pages at 'make' time |
8e07c86e | 1331 | |
864a5fa8 | 1332 | =item LDFROM |
8e07c86e | 1333 | |
864a5fa8 AD |
1334 | defaults to "$(OBJECT)" and is used in the ld command to specify |
1335 | what files to link/load from (also see dynamic_lib below for how to | |
1336 | specify ld flags) | |
8e07c86e | 1337 | |
864a5fa8 | 1338 | =item LIBPERL_A |
8e07c86e | 1339 | |
864a5fa8 AD |
1340 | The filename of the perllibrary that will be used together with this |
1341 | extension. Defaults to libperl.a. | |
8e07c86e AD |
1342 | |
1343 | =item LIBS | |
1344 | ||
1345 | An anonymous array of alternative library | |
1346 | specifications to be searched for (in order) until | |
864a5fa8 | 1347 | at least one library is found. E.g. |
8e07c86e AD |
1348 | |
1349 | 'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"] | |
1350 | ||
1351 | Mind, that any element of the array | |
1352 | contains a complete set of arguments for the ld | |
1353 | command. So do not specify | |
1354 | ||
1355 | 'LIBS' => ["-ltcl", "-ltk", "-lX11"] | |
1356 | ||
1357 | See ODBM_File/Makefile.PL for an example, where an array is needed. If | |
1358 | you specify a scalar as in | |
1359 | ||
1360 | 'LIBS' => "-ltcl -ltk -lX11" | |
1361 | ||
1362 | MakeMaker will turn it into an array with one element. | |
1363 | ||
864a5fa8 | 1364 | =item LINKTYPE |
8e07c86e | 1365 | |
e05e23b1 | 1366 | 'static' or 'dynamic' (default unless usedl=undef in |
1367 | config.sh). Should only be used to force static linking (also see | |
864a5fa8 | 1368 | linkext below). |
8e07c86e | 1369 | |
864a5fa8 | 1370 | =item MAKEAPERL |
8e07c86e | 1371 | |
864a5fa8 AD |
1372 | Boolean which tells MakeMaker, that it should include the rules to |
1373 | make a perl. This is handled automatically as a switch by | |
1374 | MakeMaker. The user normally does not need it. | |
8e07c86e | 1375 | |
864a5fa8 | 1376 | =item MAKEFILE |
8e07c86e | 1377 | |
864a5fa8 | 1378 | The name of the Makefile to be produced. |
8e07c86e | 1379 | |
864a5fa8 | 1380 | =item MAN1PODS |
8e07c86e | 1381 | |
864a5fa8 AD |
1382 | Hashref of pod-containing files. MakeMaker will default this to all |
1383 | EXE_FILES files that include POD directives. The files listed | |
1384 | here will be converted to man pages and installed as was requested | |
1385 | at Configure time. | |
8e07c86e | 1386 | |
864a5fa8 | 1387 | =item MAN3PODS |
8e07c86e | 1388 | |
864a5fa8 AD |
1389 | Hashref of .pm and .pod files. MakeMaker will default this to all |
1390 | .pod and any .pm files that include POD directives. The files listed | |
1391 | here will be converted to man pages and installed as was requested | |
1392 | at Configure time. | |
8e07c86e | 1393 | |
864a5fa8 | 1394 | =item MAP_TARGET |
8e07c86e | 1395 | |
864a5fa8 AD |
1396 | If it is intended, that a new perl binary be produced, this variable |
1397 | may hold a name for that binary. Defaults to perl | |
8e07c86e | 1398 | |
864a5fa8 | 1399 | =item MYEXTLIB |
4633a7c4 | 1400 | |
864a5fa8 AD |
1401 | If the extension links to a library that it builds set this to the |
1402 | name of the library (see SDBM_File) | |
4633a7c4 | 1403 | |
864a5fa8 | 1404 | =item NAME |
8e07c86e | 1405 | |
864a5fa8 AD |
1406 | Perl module name for this extension (DBD::Oracle). This will default |
1407 | to the directory name but should be explicitly defined in the | |
1408 | Makefile.PL. | |
8e07c86e | 1409 | |
864a5fa8 | 1410 | =item NEEDS_LINKING |
8e07c86e | 1411 | |
864a5fa8 AD |
1412 | MakeMaker will figure out, if an extension contains linkable code |
1413 | anywhere down the directory tree, and will set this variable | |
1414 | accordingly, but you can speed it up a very little bit, if you define | |
1415 | this boolean variable yourself. | |
8e07c86e | 1416 | |
e05e23b1 | 1417 | =item NOECHO |
1418 | ||
1419 | Defaults the C<@>. By setting it to an empty string you can generate a | |
1420 | Makefile that echos all commands. Mainly used in debugging MakeMaker | |
1421 | itself. | |
1422 | ||
864a5fa8 | 1423 | =item NORECURS |
8e07c86e | 1424 | |
e05e23b1 | 1425 | Boolean. Attribute to inhibit descending into subdirectories. |
8e07c86e | 1426 | |
864a5fa8 | 1427 | =item OBJECT |
8e07c86e | 1428 | |
864a5fa8 AD |
1429 | List of object files, defaults to '$(BASEEXT)$(OBJ_EXT)', but can be a long |
1430 | string containing all object files, e.g. "tkpBind.o | |
1431 | tkpButton.o tkpCanvas.o" | |
8e07c86e | 1432 | |
864a5fa8 | 1433 | =item PERL |
8e07c86e | 1434 | |
864a5fa8 | 1435 | Perl binary for tasks that can be done by miniperl |
8e07c86e | 1436 | |
864a5fa8 | 1437 | =item PERLMAINCC |
005c1a0e | 1438 | |
864a5fa8 AD |
1439 | The call to the program that is able to compile perlmain.c. Defaults |
1440 | to $(CC). | |
005c1a0e | 1441 | |
864a5fa8 | 1442 | =item PERL_ARCHLIB |
005c1a0e | 1443 | |
864a5fa8 | 1444 | Same as above for architecture dependent files |
8e07c86e | 1445 | |
864a5fa8 | 1446 | =item PERL_LIB |
8e07c86e | 1447 | |
864a5fa8 | 1448 | Directory containing the Perl library to use. |
8e07c86e | 1449 | |
864a5fa8 | 1450 | =item PERL_SRC |
8e07c86e | 1451 | |
864a5fa8 AD |
1452 | Directory containing the Perl source code (use of this should be |
1453 | avoided, it may be undefined) | |
8e07c86e | 1454 | |
864a5fa8 | 1455 | =item PL_FILES |
8e07c86e | 1456 | |
864a5fa8 AD |
1457 | Ref to hash of files to be processed as perl programs. MakeMaker |
1458 | will default to any found *.PL file (except Makefile.PL) being keys | |
1459 | and the basename of the file being the value. E.g. | |
8e07c86e | 1460 | |
864a5fa8 | 1461 | {'foobar.PL' => 'foobar'} |
8e07c86e | 1462 | |
864a5fa8 AD |
1463 | The *.PL files are expected to produce output to the target files |
1464 | themselves. | |
8e07c86e | 1465 | |
864a5fa8 | 1466 | =item PM |
8e07c86e | 1467 | |
864a5fa8 | 1468 | Hashref of .pm files and *.pl files to be installed. e.g. |
8e07c86e | 1469 | |
864a5fa8 | 1470 | {'name_of_file.pm' => '$(INST_LIBDIR)/install_as.pm'} |
8e07c86e | 1471 | |
864a5fa8 AD |
1472 | By default this will include *.pm and *.pl. If a lib directory |
1473 | exists and is not listed in DIR (above) then any *.pm and *.pl files | |
1474 | it contains will also be included by default. Defining PM in the | |
1475 | Makefile.PL will override PMLIBDIRS. | |
8e07c86e | 1476 | |
864a5fa8 | 1477 | =item PMLIBDIRS |
8e07c86e | 1478 | |
864a5fa8 AD |
1479 | Ref to array of subdirectories containing library files. Defaults to |
1480 | [ 'lib', $(BASEEXT) ]. The directories will be scanned and any files | |
1481 | they contain will be installed in the corresponding location in the | |
1482 | library. A libscan() method can be used to alter the behaviour. | |
1483 | Defining PM in the Makefile.PL will override PMLIBDIRS. | |
8e07c86e | 1484 | |
864a5fa8 | 1485 | =item PREFIX |
8e07c86e | 1486 | |
864a5fa8 | 1487 | Can be used to set the three INSTALL* attributes in one go (except for |
e05e23b1 | 1488 | probably INSTALLMAN1DIR, if it is not below PREFIX according to |
1489 | %Config). They will have PREFIX as a common directory node and will | |
1490 | branch from that node into lib/, lib/ARCHNAME or whatever Configure | |
1491 | decided at the build time of your perl (unless you override one of | |
1492 | them, of course). | |
8e07c86e | 1493 | |
864a5fa8 | 1494 | =item PREREQ |
8e07c86e | 1495 | |
864a5fa8 AD |
1496 | Placeholder, not yet implemented. Will eventually be a hashref: Names |
1497 | of modules that need to be available to run this extension (e.g. Fcntl | |
1498 | for SDBM_File) are the keys of the hash and the desired version is the | |
1499 | value. Needs further evaluation, should probably allow to define | |
1500 | prerequisites among header files, libraries, perl version, etc. | |
8e07c86e | 1501 | |
864a5fa8 | 1502 | =item SKIP |
8e07c86e | 1503 | |
864a5fa8 AD |
1504 | Arryref. E.g. [qw(name1 name2)] skip (do not write) sections of the |
1505 | Makefile | |
8e07c86e | 1506 | |
864a5fa8 | 1507 | =item TYPEMAPS |
8e07c86e | 1508 | |
864a5fa8 AD |
1509 | Ref to array of typemap file names. Use this when the typemaps are |
1510 | in some directory other than the current directory or when they are | |
1511 | not named B<typemap>. The last typemap in the list takes | |
1512 | precedence. A typemap in the current directory has highest | |
1513 | precedence, even if it isn't listed in TYPEMAPS. The default system | |
1514 | typemap has lowest precedence. | |
8e07c86e | 1515 | |
864a5fa8 | 1516 | =item VERSION |
8e07c86e | 1517 | |
864a5fa8 AD |
1518 | Your version number for distributing the package. This defaults to |
1519 | 0.1. | |
8e07c86e | 1520 | |
0d8023a2 | 1521 | =item VERSION_FROM |
1522 | ||
1523 | Instead of specifying the VERSION in the Makefile.PL you can let | |
1524 | MakeMaker parse a file to determine the version number. The parsing | |
1525 | routine requires that the file named by VERSION_FROM contains one | |
1526 | single line to compute the version number. The first line in the file | |
1527 | that contains the regular expression | |
1528 | ||
1529 | /(\$[\w:]*\bVERSION)\b.*=/ | |
1530 | ||
1531 | will be evaluated with eval() and the value of the named variable | |
1532 | B<after> the eval() will be assigned to the VERSION attribute of the | |
1533 | MakeMaker object. The following lines will be parsed o.k.: | |
1534 | ||
1535 | $VERSION = '1.00'; | |
e05e23b1 | 1536 | ( $VERSION ) = '$Revision: 1.174 $ ' =~ /\$Revision:\s+([^\s]+)/; |
0d8023a2 | 1537 | $FOO::VERSION = '1.10'; |
1538 | ||
1539 | but these will fail: | |
1540 | ||
1541 | my $VERSION = '1.01'; | |
1542 | local $VERSION = '1.02'; | |
1543 | local $FOO::VERSION = '1.30'; | |
1544 | ||
1545 | The file named in VERSION_FROM is added as a dependency to Makefile to | |
1546 | guarantee, that the Makefile contains the correct VERSION macro after | |
1547 | a change of the file. | |
1548 | ||
864a5fa8 | 1549 | =item XS |
8e07c86e | 1550 | |
864a5fa8 | 1551 | Hashref of .xs files. MakeMaker will default this. e.g. |
8e07c86e | 1552 | |
864a5fa8 | 1553 | {'name_of_file.xs' => 'name_of_file.c'} |
8e07c86e | 1554 | |
864a5fa8 AD |
1555 | The .c files will automatically be included in the list of files |
1556 | deleted by a make clean. | |
4633a7c4 | 1557 | |
864a5fa8 | 1558 | =item XSOPT |
8e07c86e | 1559 | |
864a5fa8 AD |
1560 | String of options to pass to xsubpp. This might include C<-C++> or |
1561 | C<-extern>. Do not include typemaps here; the TYPEMAP parameter exists for | |
1562 | that purpose. | |
8e07c86e | 1563 | |
864a5fa8 | 1564 | =item XSPROTOARG |
4633a7c4 | 1565 | |
4e68a208 | 1566 | May be set to an empty string, which is identical to C<-prototypes>, or |
864a5fa8 | 1567 | C<-noprototypes>. See the xsubpp documentation for details. MakeMaker |
4e68a208 AD |
1568 | defaults to the empty string. |
1569 | ||
0d8023a2 | 1570 | =item XS_VERSION |
1571 | ||
1572 | Your version number for the .xs file of this package. This defaults | |
1573 | to the value of the VERSION attribute. | |
1574 | ||
8e07c86e AD |
1575 | =back |
1576 | ||
1577 | =head2 Additional lowercase attributes | |
1578 | ||
1579 | can be used to pass parameters to the methods which implement that | |
1580 | part of the Makefile. These are not normally required: | |
1581 | ||
1582 | =over 2 | |
1583 | ||
864a5fa8 | 1584 | =item clean |
8e07c86e | 1585 | |
864a5fa8 AD |
1586 | {FILES => "*.xyz foo"} |
1587 | ||
c07a80fd | 1588 | =item depend |
1589 | ||
1590 | {ANY_TARGET => ANY_DEPENDECY, ...} | |
1591 | ||
864a5fa8 AD |
1592 | =item dist |
1593 | ||
1594 | {TARFLAGS => 'cvfF', COMPRESS => 'gzip', SUFFIX => 'gz', | |
1595 | SHAR => 'shar -m', DIST_CP => 'ln'} | |
1596 | ||
1597 | If you specify COMPRESS, then SUFFIX should also be altered, as it is | |
1598 | needed to tell make the target file of the compression. Setting | |
1599 | DIST_CP to ln can be useful, if you need to preserve the timestamps on | |
1600 | your files. DIST_CP can take the values 'cp', which copies the file, | |
1601 | 'ln', which links the file, and 'best' which copies symbolic links and | |
1602 | links the rest. Default is 'best'. | |
1603 | ||
1604 | =item dynamic_lib | |
1605 | ||
0d8023a2 | 1606 | {ARMAYBE => 'ar', OTHERLDFLAGS => '...', INST_DYNAMIC_DEP => '...'} |
8e07c86e AD |
1607 | |
1608 | =item installpm | |
1609 | ||
1610 | {SPLITLIB => '$(INST_LIB)' (default) or '$(INST_ARCHLIB)'} | |
1611 | ||
1612 | =item linkext | |
1613 | ||
1614 | {LINKTYPE => 'static', 'dynamic' or ''} | |
1615 | ||
864a5fa8 | 1616 | NB: Extensions that have nothing but *.pm files had to say |
8e07c86e AD |
1617 | |
1618 | {LINKTYPE => ''} | |
1619 | ||
864a5fa8 AD |
1620 | with Pre-5.0 MakeMakers. Since version 5.00 of MakeMaker such a line |
1621 | can be deleted safely. MakeMaker recognizes, when there's nothing to | |
1622 | be linked. | |
8e07c86e | 1623 | |
864a5fa8 | 1624 | =item macro |
8e07c86e | 1625 | |
864a5fa8 | 1626 | {ANY_MACRO => ANY_VALUE, ...} |
8e07c86e AD |
1627 | |
1628 | =item realclean | |
1629 | ||
1630 | {FILES => '$(INST_ARCHAUTODIR)/*.xyz'} | |
1631 | ||
8e07c86e AD |
1632 | =item tool_autosplit |
1633 | ||
1634 | {MAXLEN =E<gt> 8} | |
005c1a0e AD |
1635 | |
1636 | =back | |
1637 | ||
8e07c86e AD |
1638 | =cut |
1639 | ||
1640 | # bug in pod2html, so leave the =back | |
1641 | ||
1642 | # Don't delete this cut, MM depends on it! | |
1643 | ||
005c1a0e AD |
1644 | =head2 Overriding MakeMaker Methods |
1645 | ||
1646 | If you cannot achieve the desired Makefile behaviour by specifying | |
1647 | attributes you may define private subroutines in the Makefile.PL. | |
1648 | Each subroutines returns the text it wishes to have written to | |
1649 | the Makefile. To override a section of the Makefile you can | |
1650 | either say: | |
1651 | ||
1652 | sub MY::c_o { "new literal text" } | |
1653 | ||
1654 | or you can edit the default by saying something like: | |
1655 | ||
8e07c86e AD |
1656 | sub MY::c_o { |
1657 | my $self = shift; | |
1658 | local *c_o; | |
1659 | $_=$self->MM::c_o; | |
1660 | s/old text/new text/; | |
1661 | $_; | |
1662 | } | |
1663 | ||
1664 | Both methods above are available for backwards compatibility with | |
1665 | older Makefile.PLs. | |
005c1a0e AD |
1666 | |
1667 | If you still need a different solution, try to develop another | |
1668 | subroutine, that fits your needs and submit the diffs to | |
8e07c86e | 1669 | F<perl5-porters@nicoh.com> or F<comp.lang.perl.misc> as appropriate. |
005c1a0e AD |
1670 | |
1671 | =head2 Distribution Support | |
1672 | ||
1673 | For authors of extensions MakeMaker provides several Makefile | |
1674 | targets. Most of the support comes from the ExtUtils::Manifest module, | |
1675 | where additional documentation can be found. | |
1676 | ||
1677 | =over 4 | |
1678 | ||
1679 | =item make distcheck | |
8e07c86e | 1680 | |
005c1a0e AD |
1681 | reports which files are below the build directory but not in the |
1682 | MANIFEST file and vice versa. (See ExtUtils::Manifest::fullcheck() for | |
1683 | details) | |
1684 | ||
4633a7c4 LW |
1685 | =item make skipcheck |
1686 | ||
1687 | reports which files are skipped due to the entries in the | |
1688 | C<MANIFEST.SKIP> file (See ExtUtils::Manifest::skipcheck() for | |
1689 | details) | |
1690 | ||
005c1a0e | 1691 | =item make distclean |
8e07c86e | 1692 | |
005c1a0e AD |
1693 | does a realclean first and then the distcheck. Note that this is not |
1694 | needed to build a new distribution as long as you are sure, that the | |
1695 | MANIFEST file is ok. | |
1696 | ||
1697 | =item make manifest | |
8e07c86e | 1698 | |
005c1a0e AD |
1699 | rewrites the MANIFEST file, adding all remaining files found (See |
1700 | ExtUtils::Manifest::mkmanifest() for details) | |
1701 | ||
1702 | =item make distdir | |
8e07c86e | 1703 | |
005c1a0e AD |
1704 | Copies all the files that are in the MANIFEST file to a newly created |
1705 | directory with the name C<$(DISTNAME)-$(VERSION)>. If that directory | |
1706 | exists, it will be removed first. | |
1707 | ||
8e07c86e AD |
1708 | =item make disttest |
1709 | ||
1710 | Makes a distdir first, and runs a C<perl Makefile.PL>, a make, and | |
4633a7c4 | 1711 | a make test in that directory. |
8e07c86e | 1712 | |
005c1a0e | 1713 | =item make tardist |
8e07c86e | 1714 | |
005c1a0e AD |
1715 | First does a command $(PREOP) which defaults to a null command. Does a |
1716 | distdir next and runs C<tar> on that directory into a tarfile. Then | |
1717 | deletes the distdir. Finishes with a command $(POSTOP) which defaults | |
1718 | to a null command. | |
1719 | ||
1720 | =item make dist | |
8e07c86e | 1721 | |
005c1a0e AD |
1722 | Defaults to $(DIST_DEFAULT) which in turn defaults to tardist. |
1723 | ||
1724 | =item make uutardist | |
8e07c86e | 1725 | |
005c1a0e AD |
1726 | Runs a tardist first and uuencodes the tarfile. |
1727 | ||
1728 | =item make shdist | |
8e07c86e | 1729 | |
005c1a0e AD |
1730 | First does a command $(PREOP) which defaults to a null command. Does a |
1731 | distdir next and runs C<shar> on that directory into a sharfile. Then | |
1732 | deletes the distdir. Finishes with a command $(POSTOP) which defaults | |
1733 | to a null command. Note: For shdist to work properly a C<shar> | |
1734 | program that can handle directories is mandatory. | |
1735 | ||
1736 | =item make ci | |
8e07c86e AD |
1737 | |
1738 | Does a $(CI) and a $(RCS_LABEL) on all files in the MANIFEST file. | |
1739 | ||
1740 | =back | |
005c1a0e AD |
1741 | |
1742 | Customization of the dist targets can be done by specifying a hash | |
1743 | reference to the dist attribute of the WriteMakefile call. The | |
1744 | following parameters are recognized: | |
1745 | ||
8e07c86e | 1746 | CI ('ci -u') |
005c1a0e | 1747 | COMPRESS ('compress') |
005c1a0e | 1748 | POSTOP ('@ :') |
8e07c86e AD |
1749 | PREOP ('@ :') |
1750 | RCS_LABEL ('rcs -q -Nv$(VERSION_SYM):') | |
1751 | SHAR ('shar') | |
1752 | SUFFIX ('Z') | |
1753 | TAR ('tar') | |
1754 | TARFLAGS ('cvf') | |
005c1a0e AD |
1755 | |
1756 | An example: | |
1757 | ||
1758 | WriteMakefile( 'dist' => { COMPRESS=>"gzip", SUFFIX=>"gz" }) | |
1759 | ||
005c1a0e | 1760 | |
e05e23b1 | 1761 | =head1 AUTHORS |
fed7345c AD |
1762 | |
1763 | Andy Dougherty F<E<lt>doughera@lafcol.lafayette.eduE<gt>>, Andreas | |
8e07c86e | 1764 | KE<ouml>nig F<E<lt>A.Koenig@franz.ww.TU-Berlin.DEE<gt>>, Tim Bunce |
fed7345c | 1765 | F<E<lt>Tim.Bunce@ig.co.ukE<gt>>. VMS support by Charles Bailey |
a5f75d66 | 1766 | F<E<lt>bailey@genetics.upenn.eduE<gt>>. OS/2 support by Ilya |
e05e23b1 | 1767 | Zakharevich F<E<lt>ilya@math.ohio-state.eduE<gt>>. Contact the |
1768 | makemaker mailing list C<mailto:makemaker@franz.ww.tu-berlin.de>, if | |
1769 | you have any questions. | |
fed7345c AD |
1770 | |
1771 | =head1 MODIFICATION HISTORY | |
1772 | ||
8e07c86e AD |
1773 | For a more complete documentation see the file Changes in the |
1774 | MakeMaker distribution package. | |
e50aee73 | 1775 | |
005c1a0e | 1776 | =head1 TODO |
f06db76b | 1777 | |
8e07c86e | 1778 | See the file Todo in the MakeMaker distribution package. |
005c1a0e AD |
1779 | |
1780 | =cut |