1 package ExtUtils::MM_Unix;
3 require 5.005_03; # Maybe further back, dunno
9 use Config qw(%Config);
10 use File::Basename qw(basename dirname fileparse);
14 use vars qw($VERSION @ISA
15 $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Win95 $Is_Dos $Is_VOS
16 $Is_QNX $Is_AIX $Is_OSF $Is_IRIX $Is_NetBSD $Is_BSD
17 $Is_SunOS4 $Is_Solaris $Is_SunOS
22 use ExtUtils::MakeMaker qw($Verbose neatvalue);
26 require ExtUtils::MM_Any;
27 @ISA = qw(ExtUtils::MM_Any);
29 $Is_OS2 = $^O eq 'os2';
30 $Is_Mac = $^O eq 'MacOS';
31 $Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
32 $Is_Win95 = $Is_Win32 && Win32::IsWin95();
33 $Is_Dos = $^O eq 'dos';
34 $Is_VOS = $^O eq 'vos';
35 $Is_VMS = $^O eq 'VMS';
36 $Is_QNX = $^O eq 'qnx';
37 $Is_AIX = $^O eq 'aix';
38 $Is_OSF = $^O eq 'dec_osf';
39 $Is_IRIX = $^O eq 'irix';
40 $Is_NetBSD = $^O eq 'netbsd';
41 $Is_SunOS4 = $^O eq 'sunos';
42 $Is_Solaris = $^O eq 'solaris';
43 $Is_SunOS = $Is_SunOS4 || $Is_Solaris;
44 $Is_BSD = $^O =~ /^(?:free|net|open)bsd|bsdos$/;
49 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
53 C<require ExtUtils::MM_Unix;>
57 The methods provided by this package are designed to be used in
58 conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
59 Makefile, it creates one or more objects that inherit their methods
60 from a package C<MM>. MM itself doesn't provide any methods, but it
61 ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
62 specific packages take the responsibility for all the methods provided
63 by MM_Unix. We are trying to reduce the number of the necessary
64 overrides by defining rather primitive operations within
67 If you are going to write a platform specific MM package, please try
68 to limit the necessary overrides to primitive methods, and if it is not
69 possible to do so, let's work out how to achieve that gain.
71 If you are overriding any of these methods in your Makefile.PL (in the
72 MY class), please report that to the makemaker mailing list. We are
73 trying to minimize the necessary method overrides and switch to data
74 driven Makefile.PLs wherever possible. In the long run less methods
75 will be overridable via the MY class.
79 The following description of methods is still under
80 development. Please refer to the code for not suitably documented
81 sections and complain loudly to the makemaker@perl.org mailing list.
82 Better yet, provide a patch.
84 Not all of the methods below are overridable in a
85 Makefile.PL. Overridable methods are marked as (o). All methods are
86 overridable by a platform specific MM_*.pm file (See
87 L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>).
91 # So we don't have to keep calling the methods over and over again,
92 # we have these globals to cache the values. Faster and shrtr.
93 my $Curdir = __PACKAGE__->curdir;
94 my $Rootdir = __PACKAGE__->rootdir;
95 my $Updir = __PACKAGE__->updir;
104 Simply says that we're Unix.
115 Defines the suffix rules to compile different flavors of C files to
121 # --- Translation Sections ---
124 return '' unless $self->needs_linking();
126 if (my $cpp = $Config{cpprun}) {
127 my $cpp_cmd = $self->const_cccmd;
128 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/;
131 '. $cpp_cmd . ' $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.c > $*.i
136 $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.c
140 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.c
144 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.C
145 ' if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific
148 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.cpp
151 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.cxx
154 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.cc
161 Does very much the same as the cflags script in the perl
162 distribution. It doesn't return the whole compiler command line, but
163 initializes all of its parts. The const_cccmd method then actually
164 returns the definition of the CCCMD macro which uses these parts.
171 my($self,$libperl)=@_;
172 return $self->{CFLAGS} if $self->{CFLAGS};
173 return '' unless $self->needs_linking();
175 my($prog, $uc, $perltype, %cflags);
176 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
177 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
179 @cflags{qw(cc ccflags optimize shellflags)}
180 = @Config{qw(cc ccflags optimize shellflags)};
183 $cflags{shellflags} ||= '';
188 DE => '-DDEBUGGING -DEMBED',
189 M => '-DEMBED -DMULTIPLICITY',
190 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
193 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
196 $uc = ""; # avoid warning
198 $perltype = $map{$uc} ? $map{$uc} : "";
206 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
207 if ($prog = $Config{$name}) {
208 # Expand hints for this extension via the shell
209 print STDOUT "Processing $name hint:\n" if $Verbose;
210 my(@o)=`cc=\"$cflags{cc}\"
211 ccflags=\"$cflags{ccflags}\"
212 optimize=\"$cflags{optimize}\"
213 perltype=\"$cflags{perltype}\"
214 optdebug=\"$cflags{optdebug}\"
217 echo ccflags=\$ccflags
218 echo optimize=\$optimize
219 echo perltype=\$perltype
220 echo optdebug=\$optdebug
225 if ($line =~ /(.*?)=\s*(.*)\s*$/){
227 print STDOUT " $1 = $2\n" if $Verbose;
229 print STDOUT "Unrecognised result from hint: '$line'\n";
235 $cflags{optimize} = $optdebug;
238 for (qw(ccflags optimize perltype)) {
240 $cflags{$_} =~ s/^\s+//;
241 $cflags{$_} =~ s/\s+/ /g;
242 $cflags{$_} =~ s/\s+$//;
243 $self->{uc $_} ||= $cflags{$_};
246 if ($self->{POLLUTE}) {
247 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
251 if ($Config{usemymalloc} and not $Config{bincompat5005}
252 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
253 and $self->{PERL_MALLOC_OK}) {
254 $pollute = '$(PERL_MALLOC_DEF)';
257 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS});
258 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE});
260 return $self->{CFLAGS} = qq{
261 CCFLAGS = $self->{CCFLAGS}
262 OPTIMIZE = $self->{OPTIMIZE}
263 PERLTYPE = $self->{PERLTYPE}
271 Defines the clean target.
276 # --- Cleanup and Distribution Sections ---
278 my($self, %attribs) = @_;
281 # Delete temporary files but do not touch installed files. We don\'t delete
282 # the Makefile here so a later make realclean still has a makefile to use.
284 clean :: clean_subdirs
287 my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
289 my @errfiles = @{$self->{C}};
293 push( @otherfiles, @errfiles, 'perlmain.err' );
295 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
296 push(@otherfiles, qw[./blib $(MAKE_APERL_FILE)
297 $(INST_ARCHAUTODIR)/extralibs.all
298 $(INST_ARCHAUTODIR)/extralibs.ld
299 perlmain.c tmon.out mon.out so_locations pm_to_blib
300 *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT)
301 $(BOOTSTRAP) $(BASEEXT).bso
302 $(BASEEXT).def lib$(BASEEXT).def
303 $(BASEEXT).exp $(BASEEXT).x
306 push(@otherfiles, qw[*.kp]);
309 push(@otherfiles, qw[core core.*perl.*.? *perl.core]);
312 push(@otherfiles, map { "core." . "[0-9]"x$_ } (1..5));
315 push @m, "\t-\$(RM_RF) @otherfiles\n";
316 # See realclean and ext/utils/make_ext for usage of Makefile.old
318 "\t-\$(MV) \$(FIRST_MAKEFILE) \$(MAKEFILE_OLD) \$(DEV_NULL)\n");
320 "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
325 =item clean_subdirs_target
327 my $make_frag = $MM->clean_subdirs_target;
329 Returns the clean_subdirs target. This is used by the clean target to
330 call clean on any subdirectories which contain Makefiles.
334 sub clean_subdirs_target {
337 # No subdirectories, no cleaning.
338 return <<'NOOP_FRAG' unless @{$self->{DIR}};
344 my $clean = "clean_subdirs :\n";
346 for my $dir (@{$self->{DIR}}) {
347 $clean .= sprintf <<'MAKE_FRAG', $dir;
348 -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) clean
356 =item const_cccmd (o)
358 Returns the full compiler call for C programs and stores the
359 definition in CONST_CCCMD.
364 my($self,$libperl)=@_;
365 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
366 return '' unless $self->needs_linking();
367 # PASTHRU_INC is defined explicitly by extensions
368 # wanting to do complex things.
369 return $self->{CONST_CCCMD} =
370 q{CCCMD = $(CC) -c $(INC) $(PASTHRU_INC) \\
371 $(CCFLAGS) $(OPTIMIZE) \\
372 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
373 $(XS_DEFINE_VERSION)};
376 =item const_config (o)
378 Defines a couple of constants in the Makefile that are imported from
384 # --- Constants Sections ---
388 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
389 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
391 foreach $m (@{$self->{CONFIG}}){
392 # SITE*EXP macros are defined in &constants; avoid duplicates here
393 next if $once_only{$m};
394 $self->{uc $m} = quote_paren($self->{uc $m});
395 push @m, uc($m) , ' = ' , $self->{uc $m}, "\n";
401 =item const_loadlibs (o)
403 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
404 L<ExtUtils::Liblist> for details.
410 return "" unless $self->needs_linking;
413 # $self->{NAME} might depend on some other libraries:
414 # See ExtUtils::Liblist for details
419 EXTRALIBS LDLOADLIBS BSLOADLIBS LD_RUN_PATH
421 next unless defined $self->{$tmp};
422 push @m, "$tmp = $self->{$tmp}\n";
429 my $make_frag = $mm->constants;
431 Prints out macros for lots of constants.
441 AR_STATIC_ARGS DIRFILESEP
443 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
444 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
445 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
446 INST_MAN1DIR INST_MAN3DIR
450 PERLPREFIX SITEPREFIX VENDORPREFIX
452 (map { ("INSTALL".$_,
454 } $self->installvars),
459 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
460 PERLMAINCC PERL_SRC PERL_INC
461 PERL FULLPERL ABSPERL
462 PERLRUN FULLPERLRUN ABSPERLRUN
463 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
469 next unless defined $self->{$macro};
471 # pathnames can have sharp signs in them; escape them so
472 # make doesn't think it is a comment-start character.
473 $self->{$macro} =~ s/#/\\#/g;
474 push @m, "$macro = $self->{$macro}\n";
478 MAKEMAKER = $self->{MAKEMAKER}
479 MM_VERSION = $self->{MM_VERSION}
480 MM_REVISION = $self->{MM_REVISION}
484 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
485 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
486 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
487 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
491 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
492 LDFROM LINKTYPE PM_FILTER
495 next unless defined $self->{$macro};
496 push @m, "$macro = $self->{$macro}\n";
500 # Handy lists of source code files:
501 XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
502 C_FILES = ".$self->wraplist(@{$self->{C}})."
503 O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."
504 H_FILES = ".$self->wraplist(@{$self->{H}})."
505 MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
506 MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
511 # Where is the Config information that we are using/depend on
512 CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h
517 # Where to build things
518 INST_LIBDIR = $self->{INST_LIBDIR}
519 INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
521 INST_AUTODIR = $self->{INST_AUTODIR}
522 INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
524 INST_STATIC = $self->{INST_STATIC}
525 INST_DYNAMIC = $self->{INST_DYNAMIC}
526 INST_BOOT = $self->{INST_BOOT}
532 EXPORT_LIST = $self->{EXPORT_LIST}
533 PERL_ARCHIVE = $self->{PERL_ARCHIVE}
534 PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
539 TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."
541 PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}})."
550 Same as macro for the depend attribute.
555 my($self,%attribs) = @_;
557 while (($key,$val) = each %attribs){
558 last unless defined $key;
559 push @m, "$key : $val\n";
566 Takes an array of directories that need to exist and returns a
567 Makefile entry for a .exists file in these directories. Returns
568 nothing, if the entry has already been processed. We're helpless
569 though, if the same directory comes as $(FOO) _and_ as "bar". Both of
570 them get an entry, that's why we use "::".
575 # --- Make-Directories section (internal method) ---
576 # dir_target(@array) returns a Makefile entry for the file .exists in each
577 # named directory. Returns nothing, if the entry has already been processed.
578 # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
579 # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
580 # prerequisite, because there has to be one, something that doesn't change
583 my($self,@dirs) = @_;
584 my(@m,$dir,$targdir);
585 foreach $dir (@dirs) {
586 my($src) = $self->catfile($self->{PERL_INC},'perl.h');
587 my($targ) = $self->catfile($dir,'.exists');
588 # catfile may have adapted syntax of $dir to target OS, so...
589 if ($Is_VMS) { # Just remove file name; dirspec is often in macro
590 ($targdir = $targ) =~ s:/?\.exists\z::;
592 else { # while elsewhere we expect to see the dir separator in $targ
593 $targdir = dirname($targ);
595 next if $self->{DIR_TARGET}{$self}{$targdir}++;
598 \$(NOECHO) \$(MKPATH) $targdir
599 \$(NOECHO) \$(EQUALIZE_TIMESTAMP) $src $targ
602 -\$(NOECHO) \$(CHMOD) \$(PERM_RWX) $targdir
612 Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
620 $self->{DESTDIR} ||= '';
622 # Make DEST variables.
623 foreach my $var ($self->installvars) {
624 my $destvar = 'DESTINSTALL'.$var;
625 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
634 Defines a lot of macros for distribution support.
636 macro description default
638 TAR tar command to use tar
639 TARFLAGS flags to pass to TAR cvf
641 ZIP zip command to use zip
642 ZIPFLAGS flags to pass to ZIP -r
644 COMPRESS compression command to gzip --best
646 SUFFIX suffix to put on .gz
649 SHAR shar command to use shar
651 PREOP extra commands to run before
653 POSTOP extra commands to run after
656 TO_UNIX a command to convert linefeeds
657 to Unix style in your archive
659 CI command to checkin your ci -u
660 sources to version control
661 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
664 DIST_CP $how argument to manicopy() best
665 when the distdir is created
667 DIST_DEFAULT default target to use to tardist
668 create a distribution
670 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
678 $self->{TAR} ||= 'tar';
679 $self->{TARFLAGS} ||= 'cvf';
680 $self->{ZIP} ||= 'zip';
681 $self->{ZIPFLAGS} ||= '-r';
682 $self->{COMPRESS} ||= 'gzip --best';
683 $self->{SUFFIX} ||= '.gz';
684 $self->{SHAR} ||= 'shar';
685 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
686 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
687 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
689 $self->{CI} ||= 'ci -u';
690 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
691 $self->{DIST_CP} ||= 'best';
692 $self->{DIST_DEFAULT} ||= 'tardist';
694 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
695 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
701 my $dist_macros = $mm->dist(%overrides);
703 Generates a make fragment defining all the macros initialized in
706 %overrides can be used to override any of the above.
711 my($self, %attribs) = @_;
715 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
717 CI RCS_LABEL DIST_CP DIST_DEFAULT
721 my $value = $attribs{$key} || $self->{$key};
722 $make .= "$key = $value\n";
728 =item dist_basics (o)
730 Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
737 return <<'MAKE_FRAG';
738 distclean :: realclean distcheck
742 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
745 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
748 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
750 veryclean : realclean
751 $(RM_F) *~ *.orig */*~ */*.orig
759 Defines a check in target for RCS.
767 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\
768 -e "@all = keys %{ maniread() };" \\
769 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\
770 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
776 my $dist_make_fragment = $MM->dist_core;
778 Puts the targets necessary for 'make dist' together into one make
787 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
790 my $method = $target.'_target';
792 $make_frag .= $self->$method();
801 my $make_frag = $MM->dist_target;
803 Returns the 'dist' target to make an archive for distribution. This
804 target simply checks to make sure the Makefile is up-to-date and
805 depends on $(DIST_DEFAULT).
812 my $date_check = $self->oneliner(<<'CODE', ['-l']);
813 print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
814 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
817 return sprintf <<'MAKE_FRAG', $date_check;
818 dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
823 =item B<tardist_target>
825 my $make_frag = $MM->tardist_target;
827 Returns the 'tardist' target which is simply so 'make tardist' works.
828 The real work is done by the dynamically named tardistfile_target()
829 method, tardist should have that as a dependency.
836 return <<'MAKE_FRAG';
837 tardist : $(DISTVNAME).tar$(SUFFIX)
842 =item B<zipdist_target>
844 my $make_frag = $MM->zipdist_target;
846 Returns the 'zipdist' target which is simply so 'make zipdist' works.
847 The real work is done by the dynamically named zipdistfile_target()
848 method, zipdist should have that as a dependency.
855 return <<'MAKE_FRAG';
856 zipdist : $(DISTVNAME).zip
861 =item B<tarfile_target>
863 my $make_frag = $MM->tarfile_target;
865 The name of this target is the name of the tarball generated by
866 tardist. This target does the actual work of turning the distdir into
874 return <<'MAKE_FRAG';
875 $(DISTVNAME).tar$(SUFFIX) : distdir
878 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
879 $(RM_RF) $(DISTVNAME)
880 $(COMPRESS) $(DISTVNAME).tar
887 my $make_frag = $MM->zipfile_target;
889 The name of this target is the name of the zip file generated by
890 zipdist. This target does the actual work of turning the distdir into
898 return <<'MAKE_FRAG';
899 $(DISTVNAME).zip : distdir
901 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
902 $(RM_RF) $(DISTVNAME)
907 =item uutardist_target
909 my $make_frag = $MM->uutardist_target;
911 Converts the tarfile into a uuencoded file
915 sub uutardist_target {
918 return <<'MAKE_FRAG';
919 uutardist : $(DISTVNAME).tar$(SUFFIX)
920 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
927 my $make_frag = $MM->shdist_target;
929 Converts the distdir into a shell archive.
936 return <<'MAKE_FRAG';
939 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
940 $(RM_RF) $(DISTVNAME)
947 Defines the scratch directory target that will hold the distribution
948 before tar-ing (or shar-ing).
952 # For backwards compatibility.
953 *dist_dir = *distdir;
958 return <<'MAKE_FRAG';
959 distdir : metafile metafile_addtomanifest
960 $(RM_RF) $(DISTVNAME)
961 $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
962 -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
970 Defines a target that produces the distribution in the
971 scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
981 cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
982 cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
983 cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
990 Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp
996 my($self,%attribs) = @_;
998 return '' unless ($Is_AIX && $self->needs_linking() );
1000 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
1001 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
1002 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
1006 dynamic :: $self->{BASEEXT}.exp
1008 ") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
1011 static :: $self->{BASEEXT}.exp
1013 ") unless $self->{SKIPHASH}{'static'}; # we avoid a warning if we tick them
1016 $self->{BASEEXT}.exp: Makefile.PL
1017 ",' $(PERLRUN) -e \'use ExtUtils::Mksymlists; \\
1018 Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
1019 neatvalue($funcs), ', "FUNCLIST" => ', neatvalue($funclist),
1020 ', "DL_VARS" => ', neatvalue($vars), ');\'
1028 Defines the dynamic target.
1033 # --- Dynamic Loading Sections ---
1037 dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
1042 =item dynamic_bs (o)
1044 Defines targets for bootstrap files.
1049 my($self, %attribs) = @_;
1052 ' unless $self->has_link_code();
1054 return <<'MAKE_FRAG';
1055 BOOTSTRAP = $(BASEEXT).bs
1057 # As Mkbootstrap might not write a file (if none is required)
1058 # we use touch to prevent make continually trying to remake it.
1059 # The DynaLoader only reads a non-empty file.
1060 $(BOOTSTRAP): $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
1061 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
1062 $(NOECHO) $(PERLRUN) \
1063 "-MExtUtils::Mkbootstrap" \
1064 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
1065 $(NOECHO) $(TOUCH) $(BOOTSTRAP)
1066 $(CHMOD) $(PERM_RW) $@
1068 $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
1069 $(NOECHO) $(RM_RF) $(INST_BOOT)
1070 -$(CP) $(BOOTSTRAP) $(INST_BOOT)
1071 $(CHMOD) $(PERM_RW) $@
1075 =item dynamic_lib (o)
1077 Defines how to produce the *.so (or equivalent) files.
1082 my($self, %attribs) = @_;
1083 return '' unless $self->needs_linking(); #might be because of a subdir
1085 return '' unless $self->has_link_code;
1087 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
1088 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
1089 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
1090 my($ldfrom) = '$(LDFROM)';
1091 $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':');
1093 my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
1094 my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : '';
1096 # This section creates the dynamically loadable $(INST_DYNAMIC)
1097 # from $(OBJECT) and possibly $(MYEXTLIB).
1098 ARMAYBE = '.$armaybe.'
1099 OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
1100 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
1101 INST_DYNAMIC_FIX = '.$ld_fix.'
1103 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
1105 if ($armaybe ne ':'){
1106 $ldfrom = 'tmp$(LIB_EXT)';
1107 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
1108 push(@m,' $(RANLIB) '."$ldfrom\n");
1110 $ldfrom = "-all $ldfrom -none" if $Is_OSF;
1112 # The IRIX linker doesn't use LD_RUN_PATH
1113 my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ?
1114 qq{-rpath "$self->{LD_RUN_PATH}"} : '';
1116 # For example in AIX the shared objects/libraries from previous builds
1117 # linger quite a while in the shared dynalinker cache even when nobody
1118 # is using them. This is painful if one for instance tries to restart
1119 # a failed build because the link command will fail unnecessarily 'cos
1120 # the shared object/library is 'busy'.
1121 push(@m,' $(RM_F) $@
1124 my $libs = '$(LDLOADLIBS)';
1127 # Use nothing on static perl platforms, and to the flags needed
1128 # to link against the shared libperl library on shared perl
1129 # platforms. We peek at lddlflags to see if we need -Wl,-R
1130 # or -R to add paths to the run-time library search path.
1131 if ($Config{'useshrplib'}) {
1132 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
1133 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -lperl';
1134 } elsif ($Config{'lddlflags'} =~ /-R/) {
1135 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -lperl';
1141 ' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
1142 ' $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) $(PERL_ARCHIVE) '.$libs.' $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) $(INST_DYNAMIC_FIX)');
1144 $(CHMOD) $(PERM_RWX) $@
1147 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1153 Deprecated method. Use libscan instead.
1158 my($self,$path) = @_;
1164 Called by init_others, and calls ext ExtUtils::Liblist. See
1165 L<ExtUtils::Liblist> for details.
1170 my($self,$libs) = @_;
1171 require ExtUtils::Liblist;
1172 $self->ext($libs, $Verbose);
1177 Finds the executables PERL and FULLPERL
1182 my($self, $ver, $names, $dirs, $trace) = @_;
1185 print "Looking for perl $ver by these names:
1192 my $stderr_duped = 0;
1195 if( open(STDERR_COPY, '>&STDERR') ) {
1200 find_perl() can't dup STDERR: $!
1201 You might see some garbage while we search for Perl
1206 foreach $name (@$names){
1207 foreach $dir (@$dirs){
1208 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1210 if ($self->file_name_is_absolute($name)) { # /foo/bar
1212 } elsif ($self->canonpath($name) eq
1213 $self->canonpath(basename($name))) { # foo
1214 $abs = $self->catfile($dir, $name);
1216 $abs = $self->catfile($Curdir, $name);
1218 print "Checking $abs\n" if ($trace >= 2);
1219 next unless $self->maybe_command($abs);
1220 print "Executing $abs\n" if ($trace >= 2);
1222 my $version_check = qq{$abs -e "require $ver; print qq{VER_OK\n}"};
1223 # To avoid using the unportable 2>&1 to supress STDERR,
1224 # we close it before running the command.
1225 # However, thanks to a thread library bug in many BSDs
1226 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1227 # we cannot use the fancier more portable way in here
1228 # but instead need to use the traditional 2>&1 construct.
1230 $val = `$version_check 2>&1`;
1232 close STDERR if $stderr_duped;
1233 $val = `$version_check`;
1234 open STDERR, '>&STDERR_COPY' if $stderr_duped;
1237 if ($val =~ /^VER_OK/) {
1238 print "Using PERL=$abs\n" if $trace;
1240 } elsif ($trace >= 2) {
1241 print "Result: '$val'\n";
1245 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1246 0; # false and not empty
1251 my $test = $mm->find_tests;
1253 Returns a string suitable for feeding to the shell to return all
1265 =head2 Methods to actually produce chunks of text for the Makefile
1267 The methods here are called for each MakeMaker object in the order
1268 specified by @ExtUtils::MakeMaker::MM_Sections.
1276 Inserts the sharpbang or equivalent magic number to a set of @files.
1280 sub fixin { # stolen from the pink Camel book, more or less
1281 my($self, @files) = @_;
1283 my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1284 for my $file (@files) {
1285 my $file_new = "$file.new";
1286 my $file_bak = "$file.bak";
1290 open(FIXIN, $file) or croak "Can't process '$file': $!";
1292 chomp(my $line = <FIXIN>);
1293 next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
1294 # Now figure out the interpreter name.
1295 my($cmd,$arg) = split ' ', $line, 2;
1298 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
1300 if ($cmd eq "perl") {
1301 if ($Config{startperl} =~ m,^\#!.*/perl,) {
1302 $interpreter = $Config{startperl};
1303 $interpreter =~ s,^\#!,,;
1305 $interpreter = $Config{perlpath};
1308 my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path;
1311 foreach $dir (@absdirs) {
1312 if ($self->maybe_command($cmd)) {
1313 warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter;
1314 $interpreter = $self->catfile($dir,$cmd);
1318 # Figure out how to invoke interpreter on this machine.
1322 print STDOUT "Changing sharpbang in $file to $interpreter" if $Verbose;
1323 # this is probably value-free on DOSISH platforms
1325 $shb .= "$Config{'sharpbang'}$interpreter";
1326 $shb .= ' ' . $arg if defined $arg;
1330 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
1331 if 0; # not running under some shell
1332 } unless $Is_Win32; # this won't work on win32, so don't
1334 warn "Can't find $cmd in PATH, $file unchanged"
1339 unless ( open(FIXOUT,">$file_new") ) {
1340 warn "Can't create new $file: $!\n";
1344 # Print out the new #! line (or equivalent).
1347 print FIXOUT $shb, <FIXIN>;
1351 chmod 0666, $file_bak;
1353 unless ( rename($file, $file_bak) ) {
1354 warn "Can't rename $file to $file_bak: $!";
1357 unless ( rename($file_new, $file) ) {
1358 warn "Can't rename $file_new to $file: $!";
1359 unless ( rename($file_bak, $file) ) {
1360 warn "Can't rename $file_bak back to $file either: $!";
1361 warn "Leaving $file renamed as $file_bak\n";
1367 close(FIXIN) if fileno(FIXIN);
1368 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
1380 '# Phony target to force checking subdirectories.
1388 Guess the name of this package by examining the working directory's
1389 name. MakeMaker calls this only if the developer has not supplied a
1399 my $name = basename(cwd());
1400 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
1401 # strip minus or underline
1402 # followed by a float or some such
1403 print "Warning: Guessing NAME [$name] from current directory name.\n";
1409 Returns true if C, XS, MYEXTLIB or similar objects exist within this
1410 object that need a compiler. Does not descend into subdirectories as
1411 needs_linking() does.
1417 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1418 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1419 $self->{HAS_LINK_CODE} = 1;
1422 return $self->{HAS_LINK_CODE} = 0;
1428 Scans the directory structure and initializes DIR, XS, XS_FILES, PM,
1429 C, C_FILES, O_FILES, H, H_FILES, PL_FILES, MAN*PODS, EXE_FILES.
1431 Called by init_main.
1435 sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1437 my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
1440 @ignore{qw(Makefile.PL test.pl t)} = (1,1,1);
1442 # ignore the distdir
1443 $Is_VMS ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1444 : $ignore{$self->{DISTVNAME}} = 1;
1446 @ignore{map lc, keys %ignore} = values %ignore if $Is_VMS;
1448 foreach $name ($self->lsdir($Curdir)){
1449 next if $name =~ /\#/;
1450 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
1451 next unless $self->libscan($name);
1453 next if -l $name; # We do not support symlinks at all
1454 next if $self->{NORECURS};
1455 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1456 } elsif ($name =~ /\.xs\z/){
1457 my($c); ($c = $name) =~ s/\.xs\z/.c/;
1460 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
1462 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1463 } elsif ($name =~ /\.h\z/i){
1465 } elsif ($name =~ /\.PL\z/) {
1466 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
1467 } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
1468 # case-insensitive filesystem, one dot per name, so foo.h.PL
1469 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
1470 local($/); open(PL,$name); my $txt = <PL>; close PL;
1471 if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
1472 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
1475 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1477 } elsif ($name =~ /\.(p[ml]|pod)\z/){
1478 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1482 # Some larger extensions often wish to install a number of *.pm/pl
1483 # files into the library in various locations.
1485 # The attribute PMLIBDIRS holds an array reference which lists
1486 # subdirectories which we should search for library files to
1487 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1488 # recursively search through the named directories (skipping any
1489 # which don't exist or contain Makefile.PL files).
1491 # For each *.pm or *.pl file found $self->libscan() is called with
1492 # the default installation path in $_[1]. The return value of
1493 # libscan defines the actual installation location. The default
1494 # libscan function simply returns the path. The file is skipped
1495 # if libscan returns false.
1497 # The default installation location passed to libscan in $_[1] is:
1499 # ./*.pm => $(INST_LIBDIR)/*.pm
1500 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1501 # ./lib/... => $(INST_LIB)/...
1503 # In this way the 'lib' directory is seen as the root of the actual
1504 # perl library whereas the others are relative to INST_LIBDIR
1505 # (which includes PARENT_NAME). This is a subtle distinction but one
1506 # that's important for nested modules.
1508 unless( $self->{PMLIBDIRS} ) {
1510 # Avoid logical name vs directory collisions
1511 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1514 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1518 #only existing directories that aren't in $dir are allowed
1520 # Avoid $_ wherever possible:
1521 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1522 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1524 @{$self->{PMLIBDIRS}} = ();
1525 foreach $pmlibdir (@pmlibdirs) {
1526 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1529 if (@{$self->{PMLIBDIRS}}){
1530 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1533 File::Find::find(sub {
1535 unless ($self->libscan($_)){
1536 $File::Find::prune = 1;
1541 return if /~$/; # emacs temp files
1542 return if /,v$/; # RCS files
1544 my $path = $File::Find::name;
1545 my $prefix = $self->{INST_LIBDIR};
1548 $prefix = $self->{INST_LIB}
1549 if ($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i;
1551 my($inst) = $self->catfile($prefix,$striplibpath);
1552 local($_) = $inst; # for backwards compatibility
1553 $inst = $self->libscan($inst);
1554 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1555 return unless $inst;
1557 }, @{$self->{PMLIBDIRS}});
1560 $self->{PM} ||= \%pm;
1561 $self->{PL_FILES} ||= \%pl_files;
1563 $self->{DIR} ||= [sort keys %dir];
1565 $self->{XS} ||= \%xs;
1566 $self->{C} ||= [sort keys %c];
1567 my @o_files = @{$self->{C}};
1568 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
1570 $self->{H} ||= [sort keys %h];
1572 # Set up names of manual pages to generate from pods
1574 foreach my $man (qw(MAN1 MAN3)) {
1575 unless ($self->{"${man}PODS"}) {
1576 $self->{"${man}PODS"} = {};
1577 $pods{$man} = 1 unless
1578 $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/;
1583 if ( exists $self->{EXE_FILES} ) {
1584 foreach $name (@{$self->{EXE_FILES}}) {
1587 if (open(FH,"<$name")) {
1589 if (/^=(?:head\d+|item|pod)\b/) {
1596 # If it doesn't exist yet, we assume, it has pods in it
1601 $self->{MAN1PODS}->{$name} =
1602 $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)");
1608 my %manifypods = (); # we collect the keys first, i.e. the files
1609 # we have to convert to pod
1610 foreach $name (keys %{$self->{PM}}) {
1611 if ($name =~ /\.pod\z/ ) {
1612 $manifypods{$name} = $self->{PM}{$name};
1613 } elsif ($name =~ /\.p[ml]\z/ ) {
1616 if (open(FH,"<$name")) {
1618 if (/^=head1\s+\w+/) {
1628 $manifypods{$name} = $self->{PM}{$name};
1633 # Remove "Configure.pm" and similar, if it's not the only pod listed
1634 # To force inclusion, just name it "Configure.pod", or override
1636 foreach $name (keys %manifypods) {
1637 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
1638 delete $manifypods{$name};
1641 my($manpagename) = $name;
1642 $manpagename =~ s/\.p(od|m|l)\z//;
1643 # everything below lib is ok
1644 unless($manpagename =~ s!^\W*lib\W+!!s) {
1645 $manpagename = $self->catfile(
1646 split(/::/,$self->{PARENT_NAME}),$manpagename
1650 $manpagename = $self->replace_manpage_separator($manpagename);
1651 $self->{MAN3PODS}->{$name} =
1652 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1658 =item init_DIRFILESEP
1660 Using / for Unix. Called by init_main.
1664 sub init_DIRFILESEP {
1667 $self->{DIRFILESEP} = '/';
1673 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1674 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1675 INSTALL*, INSTALLDIRS, LD, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1676 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1677 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1678 VERSION_SYM, XS_VERSION.
1685 # --- Initialize Module Name and Paths
1687 # NAME = Foo::Bar::Oracle
1688 # FULLEXT = Foo/Bar/Oracle
1690 # PARENT_NAME = Foo::Bar
1692 ### ($self->{FULLEXT} =
1693 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1694 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1697 # Copied from DynaLoader:
1699 my(@modparts) = split(/::/,$self->{NAME});
1700 my($modfname) = $modparts[-1];
1702 # Some systems have restrictions on files names for DLL's etc.
1703 # mod2fname returns appropriate file base name (typically truncated)
1704 # It may also edit @modparts if required.
1705 if (defined &DynaLoader::mod2fname) {
1706 $modfname = &DynaLoader::mod2fname(\@modparts);
1709 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1710 $self->{PARENT_NAME} ||= '';
1712 if (defined &DynaLoader::mod2fname) {
1713 # As of 5.001m, dl_os2 appends '_'
1714 $self->{DLBASE} = $modfname;
1716 $self->{DLBASE} = '$(BASEEXT)';
1720 # --- Initialize PERL_LIB, PERL_SRC
1722 # *Real* information: where did we get these two from? ...
1723 my $inc_config_dir = dirname($INC{'Config.pm'});
1724 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1726 unless ($self->{PERL_SRC}){
1728 foreach $dir ($Updir,
1729 $self->catdir($Updir,$Updir),
1730 $self->catdir($Updir,$Updir,$Updir),
1731 $self->catdir($Updir,$Updir,$Updir,$Updir),
1732 $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir))
1735 -f $self->catfile($dir,"config_h.SH")
1737 -f $self->catfile($dir,"perl.h")
1739 -f $self->catfile($dir,"lib","Exporter.pm")
1741 $self->{PERL_SRC}=$dir ;
1747 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1748 $self->{PERL_CORE} and !$self->{PERL_SRC};
1750 if ($self->{PERL_SRC}){
1751 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1753 if (defined $Cross::platform) {
1754 $self->{PERL_ARCHLIB} =
1755 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
1757 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
1758 $Is_Win32?("CORE"):());
1761 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1762 $self->{PERL_INC} = ($Is_Win32) ?
1763 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1766 # catch a situation that has occurred a few times in the past:
1768 -s $self->catfile($self->{PERL_SRC},'cflags')
1772 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1779 You cannot build extensions below the perl source tree after executing
1780 a 'make clean' in the perl source tree.
1782 To rebuild extensions distributed with the perl source you should
1783 simply Configure (to include those extensions) and then build perl as
1784 normal. After installing perl the source tree can be deleted. It is
1785 not needed for building extensions by running 'perl Makefile.PL'
1786 usually without extra arguments.
1788 It is recommended that you unpack and build additional extensions away
1789 from the perl source tree.
1793 # we should also consider $ENV{PERL5LIB} here
1794 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1795 $self->{PERL_LIB} ||= $Config{privlibexp};
1796 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1797 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1800 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1802 # Maybe somebody tries to build an extension with an
1803 # uninstalled Perl outside of Perl build tree
1805 for my $dir (@INC) {
1806 $found = $dir, last if -e $self->catdir($dir, "Config.pm");
1809 my $inc = dirname $found;
1810 if (-e $self->catdir($inc, "perl.h")) {
1811 $self->{PERL_LIB} = $found;
1812 $self->{PERL_ARCHLIB} = $found;
1813 $self->{PERL_INC} = $inc;
1814 $self->{UNINSTALLED_PERL} = 1;
1816 ... Detected uninstalled Perl. Trying to continue.
1822 unless(-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h")))
1825 Error: Unable to locate installed Perl libraries or Perl source code.
1827 It is recommended that you install perl in a standard location before
1828 building extensions. Some precompiled versions of perl do not contain
1829 these header files, so you cannot build extensions. In such a case,
1830 please build and install your perl from a fresh perl distribution. It
1831 usually solves this kind of problem.
1833 \(You get this message, because MakeMaker could not find "$perl_h"\)
1836 # print STDOUT "Using header files found in $self->{PERL_INC}\n"
1837 # if $Verbose && $self->needs_linking();
1841 # We get SITELIBEXP and SITEARCHEXP directly via
1842 # Get_from_Config. When we are running standard modules, these
1843 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1844 # set it to "site". I prefer that INSTALLDIRS be set from outside
1846 $self->{INSTALLDIRS} ||= "site";
1848 $self->{MAN1EXT} ||= $Config{man1ext};
1849 $self->{MAN3EXT} ||= $Config{man3ext};
1851 # Get some stuff out of %Config if we haven't yet done so
1852 print STDOUT "CONFIG must be an array ref\n"
1853 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1854 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1855 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1856 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1858 foreach my $m (@{$self->{CONFIG}}){
1859 next if $once_only{$m};
1860 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1861 unless exists $Config{$m};
1862 $self->{uc $m} ||= $Config{$m};
1866 # This is too dangerous:
1867 # if ($^O eq "next") {
1868 # $self->{AR} = "libtool";
1869 # $self->{AR_STATIC_ARGS} = "-o";
1871 # But I leave it as a placeholder
1873 $self->{AR_STATIC_ARGS} ||= "cr";
1875 # These should never be needed
1876 $self->{LD} ||= 'ld';
1877 $self->{OBJ_EXT} ||= '.o';
1878 $self->{LIB_EXT} ||= '.a';
1880 $self->{MAP_TARGET} ||= "perl";
1882 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1884 # make a simple check if we find Exporter
1885 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1886 (Exporter.pm not found)"
1887 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1888 $self->{NAME} eq "ExtUtils::MakeMaker";
1893 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH,
1894 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1895 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
1896 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1900 sub init_others { # --- Initialize Other Attributes
1903 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1904 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1905 # undefined. In any case we turn it into an anon array:
1907 # May check $Config{libs} too, thus not empty.
1908 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
1910 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
1911 $self->{LD_RUN_PATH} = "";
1913 foreach $libs ( @{$self->{LIBS}} ){
1914 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1915 my(@libs) = $self->extliblist($libs);
1916 if ($libs[0] or $libs[1] or $libs[2]){
1917 # LD_RUN_PATH now computed by ExtUtils::Liblist
1918 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1919 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1924 if ( $self->{OBJECT} ) {
1925 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1927 # init_dirscan should have found out, if we have C files
1928 $self->{OBJECT} = "";
1929 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1931 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1932 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1933 $self->{PERLMAINCC} ||= '$(CC)';
1934 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1936 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1937 # the 'dynamic' section of MM. We don't have this problem with
1938 # 'static', since we either must use it (%Config says we can't
1939 # use dynamic loading) or the caller asked for it explicitly.
1940 if (!$self->{LINKTYPE}) {
1941 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1943 : ($Config{usedl} ? 'dynamic' : 'static');
1946 $self->{NOOP} ||= '$(SHELL) -c true';
1947 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1949 $self->{MAKEFILE} ||= 'Makefile';
1950 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE};
1951 $self->{MAKEFILE_OLD} ||= '$(FIRST_MAKEFILE).old';
1952 $self->{MAKE_APERL_FILE} ||= '$(FIRST_MAKEFILE).aperl';
1954 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1956 $self->{ECHO} ||= 'echo';
1957 $self->{ECHO_N} ||= 'echo -n';
1958 $self->{RM_F} ||= "rm -f";
1959 $self->{RM_RF} ||= "rm -rf";
1960 $self->{TOUCH} ||= "touch";
1961 $self->{TEST_F} ||= "test -f";
1962 $self->{CP} ||= "cp";
1963 $self->{MV} ||= "mv";
1964 $self->{CHMOD} ||= "chmod";
1965 $self->{MKPATH} ||= '$(PERLRUN) "-MExtUtils::Command" -e mkpath';
1966 $self->{EQUALIZE_TIMESTAMP} ||=
1967 '$(PERLRUN) "-MExtUtils::Command" -e eqtime';
1969 $self->{UNINST} ||= 0;
1970 $self->{VERBINST} ||= 0;
1971 $self->{MOD_INSTALL} ||=
1972 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1973 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1975 $self->{DOC_INSTALL} ||=
1976 '$(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
1977 $self->{UNINSTALL} ||=
1978 '$(PERLRUN) "-MExtUtils::Command::MM" -e uninstall';
1979 $self->{WARN_IF_OLD_PACKLIST} ||=
1980 '$(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
1982 $self->{UMASK_NULL} ||= "umask 0";
1983 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1992 Called by init_main. Sets up all INST_* variables except those related
1993 to XS code. Those are handled in init_xs.
2000 $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
2001 $self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin');
2003 # INST_LIB typically pre-set if building an extension after
2004 # perl has been built and installed. Setting INST_LIB allows
2005 # you to build directly into, say $Config{privlibexp}.
2006 unless ($self->{INST_LIB}){
2007 if ($self->{PERL_CORE}) {
2008 if (defined $Cross::platform) {
2009 $self->{INST_LIB} = $self->{INST_ARCHLIB} =
2010 $self->catdir($self->{PERL_LIB},"..","xlib",
2014 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
2017 $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
2021 my @parentdir = split(/::/, $self->{PARENT_NAME});
2022 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir);
2023 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir);
2024 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto',
2026 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto',
2029 $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script');
2031 $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1');
2032 $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3');
2041 Called by init_main. Sets up all INSTALL_* variables (except
2042 INSTALLDIRS) and *PREFIX.
2049 $self->init_lib2arch;
2051 # Initialize installvendorman*dir if necessary
2052 foreach my $num (1, 3) {
2053 my $k = 'installvendorman'.$num.'dir';
2055 unless ($Config{$k}) {
2056 $Config_Override{$k} = $Config{usevendorprefix} ?
2057 $self->catdir($Config{vendorprefixexp}, 'man', "man$num") :
2062 my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
2063 $Config{prefixexp} || $Config{prefix} || '';
2064 my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : '';
2065 my $sprefix = $Config{siteprefixexp} || '';
2067 # 5.005_03 doesn't have a siteprefix.
2068 $sprefix = $iprefix unless $sprefix;
2070 # There are often no Config.pm defaults for these, but we can make
2072 unless( $Config{installsiteman1dir} ) {
2073 $Config_Override{installsiteman1dir} =
2074 $self->catdir($sprefix, 'man', 'man1');
2077 unless( $Config{installsiteman3dir} ) {
2078 $Config_Override{installsiteman3dir} =
2079 $self->catdir($sprefix, 'man', 'man3');
2082 unless( $Config{installsitebin} ) {
2083 $Config_Override{installsitebin} =
2084 $self->catdir($sprefix, 'bin');
2087 $self->{PREFIX} ||= '';
2089 if( $self->{PREFIX} ) {
2090 @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
2094 $self->{PERLPREFIX} ||= $iprefix;
2095 $self->{SITEPREFIX} ||= $sprefix;
2096 $self->{VENDORPREFIX} ||= $vprefix;
2099 my $arch = $Config{archname};
2100 my $version = $Config{version};
2103 my $libstyle = $Config{installstyle} || 'lib/perl5';
2106 if( $self->{LIBSTYLE} ) {
2107 $libstyle = $self->{LIBSTYLE};
2108 $manstyle = $self->{LIBSTYLE} eq 'lib/perl5' ? 'lib/perl5' : '';
2111 # Some systems, like VOS, set installman*dir to '' if they can't
2113 for my $num (1, 3) {
2114 $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
2115 unless $Config{'installman'.$num.'dir'};
2120 bin => { s => $iprefix,
2123 vendorbin => { s => $vprefix,
2126 sitebin => { s => $sprefix,
2129 script => { s => $iprefix,
2136 man1dir => { s => $iprefix,
2139 style => $manstyle, },
2140 siteman1dir => { s => $sprefix,
2143 style => $manstyle, },
2144 vendorman1dir => { s => $vprefix,
2147 style => $manstyle, },
2149 man3dir => { s => $iprefix,
2152 style => $manstyle, },
2153 siteman3dir => { s => $sprefix,
2156 style => $manstyle, },
2157 vendorman3dir => { s => $vprefix,
2160 style => $manstyle, },
2165 privlib => { s => $iprefix,
2168 style => $libstyle, },
2169 vendorlib => { s => $vprefix,
2172 style => $libstyle, },
2173 sitelib => { s => $sprefix,
2176 style => $libstyle, },
2178 archlib => { s => $iprefix,
2180 d => "$version/$arch",
2181 style => $libstyle },
2182 vendorarch => { s => $vprefix,
2184 d => "$version/$arch",
2185 style => $libstyle },
2186 sitearch => { s => $sprefix,
2188 d => "site_perl/$version/$arch",
2189 style => $libstyle },
2193 # Special case for LIB.
2194 if( $self->{LIB} ) {
2195 foreach my $var (keys %lib_layouts) {
2196 my $Installvar = uc "install$var";
2198 if( $var =~ /arch/ ) {
2199 $self->{$Installvar} ||=
2200 $self->catdir($self->{LIB}, $Config{archname});
2203 $self->{$Installvar} ||= $self->{LIB};
2208 my %type2prefix = ( perl => 'PERLPREFIX',
2209 site => 'SITEPREFIX',
2210 vendor => 'VENDORPREFIX'
2213 my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
2214 while( my($var, $layout) = each(%layouts) ) {
2215 my($s, $t, $d, $style) = @{$layout}{qw(s t d style)};
2216 my $r = '$('.$type2prefix{$t}.')';
2218 print STDERR "Prefixing $var\n" if $Verbose >= 2;
2220 my $installvar = "install$var";
2221 my $Installvar = uc $installvar;
2222 next if $self->{$Installvar};
2224 $d = "$style/$d" if $style;
2225 $self->prefixify($installvar, $s, $r, $d);
2227 print STDERR " $Installvar == $self->{$Installvar}\n"
2231 # Generate these if they weren't figured out.
2232 $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH};
2233 $self->{VENDORLIBEXP} ||= $self->{INSTALLVENDORLIB};
2240 Unix has no need of special linker flags.
2246 $self->{PERL_ARCHIVE} ||= '';
2247 $self->{PERL_ARCHIVE_AFTER} ||= '';
2248 $self->{EXPORT_LIST} ||= '';
2265 # The user who requests an installation directory explicitly
2266 # should not have to tell us an architecture installation directory
2267 # as well. We look if a directory exists that is named after the
2268 # architecture. If not we take it as a sign that it should be the
2269 # same as the requested installation directory. Otherwise we take
2271 for my $libpair ({l=>"privlib", a=>"archlib"},
2272 {l=>"sitelib", a=>"sitearch"},
2273 {l=>"vendorlib", a=>"vendorarch"},
2276 my $lib = "install$libpair->{l}";
2278 my $Arch = uc "install$libpair->{a}";
2279 if( $self->{$Lib} && ! $self->{$Arch} ){
2280 my($ilib) = $Config{$lib};
2282 $self->prefixify($Arch,$ilib,$self->{$Lib});
2284 unless (-d $self->{$Arch}) {
2285 print STDOUT "Directory $self->{$Arch} not found\n"
2287 $self->{$Arch} = $self->{$Lib};
2289 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
2299 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
2300 *PERLRUN* permutations.
2302 PERL is allowed to be miniperl
2303 FULLPERL must be a complete perl
2305 ABSPERL is PERL converted to an absolute path
2307 *PERLRUN contains everything necessary to run perl, find it's
2310 *PERLRUNINST is *PERLRUN + everything necessary to find the
2311 modules being built.
2319 foreach my $component ($self->{PERL_SRC}, $self->path(),
2322 push @defpath, $component if defined $component;
2325 # Build up a set of file names (not command names).
2326 my $thisperl = $self->canonpath($^X);
2327 $thisperl .= $Config{exe_ext} unless $thisperl =~ m/$Config{exe_ext}$/i;
2329 # We need a relative path to perl when in the core.
2330 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
2332 my @perls = ($thisperl);
2333 push @perls, map { "$_$Config{exe_ext}" }
2334 ('perl', 'perl5', "perl$Config{version}");
2336 # miniperl has priority over all but the cannonical perl when in the
2337 # core. Otherwise its a last resort.
2338 my $miniperl = "miniperl$Config{exe_ext}";
2339 if( $self->{PERL_CORE} ) {
2340 splice @perls, 1, 0, $miniperl;
2343 push @perls, $miniperl;
2347 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
2348 # don't check if perl is executable, maybe they have decided to
2349 # supply switches with perl
2351 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
2352 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
2353 unless $self->{FULLPERL};
2355 # Little hack to get around VMS's find_perl putting "MCR" in front
2357 $self->{ABSPERL} = $self->{PERL};
2358 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
2359 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
2360 $self->{ABSPERL} = '$(PERL)';
2363 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
2364 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
2367 # Are we building the core?
2368 $self->{PERL_CORE} = 0 unless exists $self->{PERL_CORE};
2370 # How do we run perl?
2371 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
2372 my $run = $perl.'RUN';
2374 $self->{$run} = "\$($perl)";
2376 # Make sure perl can find itself before it's installed.
2377 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
2378 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
2380 $self->{$perl.'RUNINST'} =
2381 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
2388 =item init_platform (o)
2390 Add MM_Unix_VERSION.
2392 =item platform_constants (o)
2399 $self->{MM_Unix_VERSION} = $VERSION;
2400 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2401 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2402 '-Dcalloc=Perl_calloc';
2406 sub platform_constants {
2410 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2412 next unless defined $self->{$macro};
2413 $make_frag .= "$macro = $self->{$macro}\n";
2424 Called by init_main. Initializes PERL_*
2431 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2432 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2442 Sets up macros having to do with XS code. Currently just INST_STATIC,
2443 INST_DYNAMIC and INST_BOOT.
2450 if ($self->has_link_code()) {
2451 $self->{INST_STATIC} =
2452 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2453 $self->{INST_DYNAMIC} =
2454 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2455 $self->{INST_BOOT} =
2456 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2458 $self->{INST_STATIC} = '';
2459 $self->{INST_DYNAMIC} = '';
2460 $self->{INST_BOOT} = '';
2466 Defines the install target.
2471 my($self, %attribs) = @_;
2475 install :: all pure_install doc_install
2477 install_perl :: all pure_perl_install doc_perl_install
2479 install_site :: all pure_site_install doc_site_install
2481 install_vendor :: all pure_vendor_install doc_vendor_install
2483 pure_install :: pure_$(INSTALLDIRS)_install
2485 doc_install :: doc_$(INSTALLDIRS)_install
2487 pure__install : pure_site_install
2488 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2490 doc__install : doc_site_install
2491 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2493 pure_perl_install ::
2494 $(NOECHO) $(MOD_INSTALL) \
2495 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2496 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2497 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2498 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2499 $(INST_BIN) $(DESTINSTALLBIN) \
2500 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2501 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2502 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2503 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2504 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2507 pure_site_install ::
2508 $(NOECHO) $(MOD_INSTALL) \
2509 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2510 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2511 $(INST_LIB) $(DESTINSTALLSITELIB) \
2512 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2513 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2514 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2515 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2516 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2517 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2518 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2520 pure_vendor_install ::
2521 $(NOECHO) $(MOD_INSTALL) \
2522 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2523 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2524 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2525 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2526 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2527 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2528 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2529 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2532 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2533 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2534 -$(NOECHO) $(DOC_INSTALL) \
2535 "Module" "$(NAME)" \
2536 "installed into" "$(INSTALLPRIVLIB)" \
2537 LINKTYPE "$(LINKTYPE)" \
2538 VERSION "$(VERSION)" \
2539 EXE_FILES "$(EXE_FILES)" \
2540 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2543 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2544 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2545 -$(NOECHO) $(DOC_INSTALL) \
2546 "Module" "$(NAME)" \
2547 "installed into" "$(INSTALLSITELIB)" \
2548 LINKTYPE "$(LINKTYPE)" \
2549 VERSION "$(VERSION)" \
2550 EXE_FILES "$(EXE_FILES)" \
2551 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2553 doc_vendor_install ::
2554 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2555 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2556 -$(NOECHO) $(DOC_INSTALL) \
2557 "Module" "$(NAME)" \
2558 "installed into" "$(INSTALLVENDORLIB)" \
2559 LINKTYPE "$(LINKTYPE)" \
2560 VERSION "$(VERSION)" \
2561 EXE_FILES "$(EXE_FILES)" \
2562 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2567 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2569 uninstall_from_perldirs ::
2570 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2572 uninstall_from_sitedirs ::
2573 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2575 uninstall_from_vendordirs ::
2576 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2582 =item installbin (o)
2584 Defines targets to make and to install EXE_FILES.
2590 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2591 return "" unless @{$self->{EXE_FILES}};
2592 my(@m, $from, $to, %fromto, @to);
2593 push @m, $self->dir_target(qw[$(INST_SCRIPT)]);
2594 for $from (@{$self->{EXE_FILES}}) {
2595 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2596 local($_) = $path; # for backwards compatibility
2597 $to = $self->libscan($path);
2598 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2601 @to = values %fromto;
2605 $fixin = $self->{PERL_CORE} ? '$(PERLRUN) ../../win32/bin/pl2bat.pl'
2609 $fixin = q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
2613 EXE_FILES = @{$self->{EXE_FILES}}
2624 while (($from,$to) = each %fromto) {
2625 last unless defined $from;
2626 my $todir = dirname($to);
2628 $to: $from \$(FIRST_MAKEFILE) " . $self->catdir($todir,'.exists') . "
2629 \$(NOECHO) \$(RM_F) $to
2632 -\$(NOECHO) \$(CHMOD) \$(PERM_RWX) $to
2641 Defines the linkext target which in turn defines the LINKTYPE.
2646 my($self, %attribs) = @_;
2647 # LINKTYPE => static or dynamic or ''
2648 my($linktype) = defined $attribs{LINKTYPE} ?
2649 $attribs{LINKTYPE} : '$(LINKTYPE)';
2651 linkext :: $linktype
2658 Takes as arguments a directory name and a regular expression. Returns
2659 all entries in the directory that match the regular expression.
2665 my($dir, $regex) = @_;
2667 my $dh = new DirHandle;
2668 $dh->open($dir || ".") or return ();
2671 @ls = grep(/$regex/, @ls) if $regex;
2677 Simple subroutine to insert the macros defined by the macro attribute
2683 my($self,%attribs) = @_;
2685 while (($key,$val) = each %attribs){
2686 last unless defined $key;
2687 push @m, "$key = $val\n";
2694 Called by staticmake. Defines how to write the Makefile to produce a
2697 By default the Makefile produced includes all the static extensions in
2698 the perl library. (Purified versions of library files, e.g.,
2699 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2704 my($self, %attribs) = @_;
2705 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2706 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2709 # --- MakeMaker makeaperl section ---
2710 MAP_TARGET = $target
2711 FULLPERL = $self->{FULLPERL}
2713 return join '', @m if $self->{PARENT};
2715 my($dir) = join ":", @{$self->{DIR}};
2717 unless ($self->{MAKEAPERL}) {
2719 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2720 $(MAKE) -f $(MAKE_APERL_FILE) $@
2722 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2723 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2724 $(NOECHO) $(PERLRUNINST) \
2725 Makefile.PL DIR=}, $dir, q{ \
2726 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2727 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2733 push @m, " \\\n\t\t$_";
2735 # push @m, map( " \\\n\t\t$_", @ARGV );
2743 my($cccmd, $linkcmd, $lperl);
2746 $cccmd = $self->const_cccmd($libperl);
2747 $cccmd =~ s/^CCCMD\s*=\s*//;
2748 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2749 $cccmd .= " $Config{cccdlflags}"
2750 if ($Config{useshrplib} eq 'true');
2751 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2753 # The front matter of the linkcommand...
2754 $linkcmd = join ' ', "\$(CC)",
2755 grep($_, @Config{qw(ldflags ccdlflags)});
2756 $linkcmd =~ s/\s+/ /g;
2757 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2759 # Which *.a files could we make use of...
2762 File::Find::find(sub {
2763 return unless m/\Q$self->{LIB_EXT}\E$/;
2764 return if m/^libperl/;
2765 # Skip purified versions of libraries (e.g., DynaLoader_pure_p1_c0_032.a)
2766 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2768 if( exists $self->{INCLUDE_EXT} ){
2773 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2777 # Throw away anything not explicitly marked for inclusion.
2778 # DynaLoader is implied.
2779 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2785 return unless $found;
2787 elsif( exists $self->{EXCLUDE_EXT} ){
2791 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2795 # Throw away anything explicitly marked for exclusion
2796 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2797 return if( $xx eq $excl );
2801 # don't include the installed version of this extension. I
2802 # leave this line here, although it is not necessary anymore:
2803 # I patched minimod.PL instead, so that Miniperl.pm won't
2804 # enclude duplicates
2806 # Once the patch to minimod.PL is in the distribution, I can
2808 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2810 $static{cwd() . "/" . $_}++;
2811 }, grep( -d $_, @{$searchdirs || []}) );
2813 # We trust that what has been handed in as argument, will be buildable
2814 $static = [] unless $static;
2815 @static{@{$static}} = (1) x @{$static};
2817 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2818 for (sort keys %static) {
2819 next unless /\Q$self->{LIB_EXT}\E\z/;
2820 $_ = dirname($_) . "/extralibs.ld";
2824 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
2829 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2830 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2831 # extralibs.all are computed correctly
2833 MAP_LINKCMD = $linkcmd
2834 MAP_PERLINC = @{$perlinc || []}
2836 join(" \\\n\t", reverse sort keys %static), "
2838 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2841 if (defined $libperl) {
2842 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2844 unless ($libperl && -f $lperl) { # Ilya's code...
2845 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2846 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2847 $libperl ||= "libperl$self->{LIB_EXT}";
2848 $libperl = "$dir/$libperl";
2849 $lperl ||= "libperl$self->{LIB_EXT}";
2850 $lperl = "$dir/$lperl";
2852 if (! -f $libperl and ! -f $lperl) {
2853 # We did not find a static libperl. Maybe there is a shared one?
2855 $lperl = $libperl = "$dir/$Config{libperl}";
2856 # SUNOS ld does not take the full path to a shared library
2857 $libperl = '' if $Is_SunOS4;
2861 print STDOUT "Warning: $libperl not found
2862 If you're going to build a static perl binary, make sure perl is installed
2863 otherwise ignore this warning\n"
2864 unless (-f $lperl || defined($self->{PERL_SRC}));
2867 # SUNOS ld does not take the full path to a shared library
2868 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2871 MAP_LIBPERL = $libperl
2872 LLIBPERL = $llibperl
2876 \$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)\$(DIRFILESEP).exists ".join(" \\\n\t", @$extra).'
2877 $(NOECHO) $(RM_F) $@
2878 $(NOECHO) $(TOUCH) $@
2882 foreach $catfile (@$extra){
2883 push @m, "\tcat $catfile >> \$\@\n";
2887 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2888 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2889 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2890 \$(NOECHO) \$(ECHO) ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2891 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2892 \$(NOECHO) \$(ECHO) ' make -f $makefilename map_clean'
2894 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2896 push @m, qq{\tcd $tmp && $cccmd "-I\$(PERL_INC)" perlmain.c\n};
2899 $tmp/perlmain.c: $makefilename}, q{
2900 $(NOECHO) $(ECHO) Writing $@
2901 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2902 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2905 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2906 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2911 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2912 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2913 -$(NOECHO) $(DOC_INSTALL) \
2914 "Perl binary" "$(MAP_TARGET)" \
2915 MAP_STATIC "$(MAP_STATIC)" \
2916 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2917 MAP_LIBPERL "$(MAP_LIBPERL)" \
2918 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2923 inst_perl: pure_inst_perl doc_inst_perl
2925 pure_inst_perl: $(MAP_TARGET)
2926 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2931 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2939 Defines how to rewrite the Makefile.
2946 # We do not know what target was originally specified so we
2947 # must force a manual rerun to be sure. But as it should only
2948 # happen very rarely it is not a significant problem.
2950 $(OBJECT) : $(FIRST_MAKEFILE)
2951 ' if $self->{OBJECT};
2954 # We take a very conservative approach here, but it's worth it.
2955 # We move Makefile to Makefile.old here to avoid gnu make looping.
2956 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2957 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?"
2958 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2959 $(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2960 $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2961 -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP)
2962 $(PERLRUN) Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{
2963 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2964 $(NOECHO) $(ECHO) "==> Please rerun the make command. <=="
2975 Returns true, if the argument is likely to be a command.
2980 my($self,$file) = @_;
2981 return $file if -x $file && ! -d $file;
2986 =item needs_linking (o)
2988 Does this module need linking? Looks into subdirectory objects (see
2989 also has_link_code())
2996 $caller = (caller(0))[3];
2997 confess("needs_linking called too early") if
2998 $caller =~ /^ExtUtils::MakeMaker::/;
2999 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
3000 if ($self->has_link_code or $self->{MAKEAPERL}){
3001 $self->{NEEDS_LINKING} = 1;
3004 foreach $child (keys %{$self->{CHILDREN}}) {
3005 if ($self->{CHILDREN}->{$child}->needs_linking) {
3006 $self->{NEEDS_LINKING} = 1;
3010 return $self->{NEEDS_LINKING} = 0;
3015 misnamed method (will have to be changed). The MM_Unix method just
3016 returns the argument without further processing.
3018 On VMS used to insure that colons marking targets are preceded by
3019 space - most Unix Makes don't need this, but it's necessary under VMS
3020 to distinguish the target delimiter from a colon appearing as part of
3026 my($self,$text) = @_;
3030 =item parse_abstract
3032 parse a file and return what you think is the ABSTRACT
3036 sub parse_abstract {
3037 my($self,$parsefile) = @_;
3041 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
3043 my $package = $self->{DISTNAME};
3044 $package =~ s/-/::/g;
3046 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
3049 next unless /^($package\s-\s)(.*)/;
3059 parse a file and return what you think is $VERSION in this file set to.
3060 It will return the string "undef" if it can't figure out what $VERSION
3061 is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
3062 are okay, but my $VERSION is not.
3067 my($self,$parsefile) = @_;
3071 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
3074 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
3075 next if $inpod || /^\s*#/;
3077 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
3079 package ExtUtils::MakeMaker::_version;
3088 $result = eval($eval);
3089 warn "Could not eval '$eval' in $parsefile: $@" if $@;
3094 $result = "undef" unless defined $result;
3101 Defines the string that is passed to recursive make calls in
3111 my($sep) = $Is_VMS ? ',' : '';
3114 foreach $key (qw(LIB LIBPERL_A LINKTYPE PREFIX OPTIMIZE INC DEFINE)) {
3115 next unless defined $self->{$key};
3116 if ($key eq 'INC') {
3117 # For INC we need to prepend parent directory but
3118 # only iff the parent directory is not absolute.
3119 my ($o, $i) = $Is_VMS ? ('/Include=', 'i') : ('-I', '');
3121 foreach (grep { /\S/ } parse_line(qr/\s*(?$i)$o/, 1, $self->{INC})) {
3123 my $dir = File::Spec->file_name_is_absolute($_) ? $_ : File::Spec->catdir(File::Spec->updir, $_);
3124 $dir = qq["$dir"] if $dir =~ / /;
3127 push @pasthru, "INC=\"$inc\"";
3129 push @pasthru, "$key=\"\$($key)\"";
3133 # PASTHRU_DEFINE and PASTHRU_INC are defined explicitly
3134 # by extensions wanting to do really complex things.
3135 foreach $key (qw(DEFINE INC)) {
3136 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
3139 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
3145 Takes one argument, a file name, and returns the file name, if the
3146 argument is likely to be a perl script. On MM_Unix this is true for
3147 any ordinary, readable file.
3152 my($self,$file) = @_;
3153 return $file if -r $file && -f _;
3157 =item perldepend (o)
3159 Defines the dependency from all *.h files that come with the perl
3168 # Check for unpropogated config.sh changes. Should never happen.
3169 # We do NOT just update config.h because that is not sufficient.
3170 # An out of date config.h is not fatal but complains loudly!
3171 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
3172 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
3174 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
3175 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
3176 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
3177 } if $self->{PERL_SRC};
3179 return join "", @m unless $self->needs_linking;
3183 $(PERL_INC)/EXTERN.h \
3184 $(PERL_INC)/INTERN.h \
3185 $(PERL_INC)/XSUB.h \
3187 $(PERL_INC)/cc_runtime.h \
3188 $(PERL_INC)/config.h \
3191 $(PERL_INC)/dosish.h \
3192 $(PERL_INC)/embed.h \
3193 $(PERL_INC)/embedvar.h \
3194 $(PERL_INC)/fakethr.h \
3195 $(PERL_INC)/form.h \
3197 $(PERL_INC)/handy.h \
3199 $(PERL_INC)/intrpvar.h \
3200 $(PERL_INC)/iperlsys.h \
3201 $(PERL_INC)/keywords.h \
3203 $(PERL_INC)/nostdio.h \
3205 $(PERL_INC)/opcode.h \
3206 $(PERL_INC)/patchlevel.h \
3207 $(PERL_INC)/perl.h \
3208 $(PERL_INC)/perlio.h \
3209 $(PERL_INC)/perlsdio.h \
3210 $(PERL_INC)/perlsfio.h \
3211 $(PERL_INC)/perlvars.h \
3212 $(PERL_INC)/perly.h \
3214 $(PERL_INC)/pp_proto.h \
3215 $(PERL_INC)/proto.h \
3216 $(PERL_INC)/regcomp.h \
3217 $(PERL_INC)/regexp.h \
3218 $(PERL_INC)/regnodes.h \
3219 $(PERL_INC)/scope.h \
3221 $(PERL_INC)/thrdvar.h \
3222 $(PERL_INC)/thread.h \
3223 $(PERL_INC)/unixish.h \
3226 $(OBJECT) : $(PERL_HDRS)
3227 } if $self->{OBJECT};
3229 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
3237 Returns the attribute C<PERM_RW> or the string C<644>.
3238 Used as the string that is passed
3239 to the C<chmod> command to set the permissions for read/writeable files.
3240 MakeMaker chooses C<644> because it has turned out in the past that
3241 relying on the umask provokes hard-to-track bug reports.
3242 When the return value is used by the perl function C<chmod>, it is
3243 interpreted as an octal value.
3248 return shift->{PERM_RW};
3253 Returns the attribute C<PERM_RWX> or the string C<755>,
3254 i.e. the string that is passed
3255 to the C<chmod> command to set the permissions for executable files.
3261 return shift->{PERM_RWX};
3266 Defines target that copies all files in the hash PM to their
3267 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
3273 my($autodir) = $self->catdir('$(INST_LIB)','auto');
3275 pm_to_blib: $(TO_INST_PM)
3278 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
3279 pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
3282 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
3284 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
3285 $r .= q{ $(NOECHO) $(TOUCH) $@};
3290 =item post_constants (o)
3292 Returns an empty string per default. Dedicated to overrides from
3293 within Makefile.PL after all constants have been defined.
3301 =item post_initialize (o)
3303 Returns an empty string per default. Used in Makefile.PLs to add some
3304 chunk of text to the Makefile after the object is initialized.
3308 sub post_initialize {
3314 Returns an empty string. Can be used in Makefile.PLs to write some
3315 text to the Makefile at the end.
3325 Defines target that creates a PPD (Perl Package Description) file
3326 for a binary distribution.
3333 if ($self->{ABSTRACT_FROM}){
3334 $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
3335 carp "WARNING: Setting ABSTRACT via file ".
3336 "'$self->{ABSTRACT_FROM}' failed\n";
3339 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
3341 my $abstract = $self->{ABSTRACT} || '';
3342 $abstract =~ s/\n/\\n/sg;
3343 $abstract =~ s/</</g;
3344 $abstract =~ s/>/>/g;
3346 my $author = $self->{AUTHOR} || '';
3347 $author =~ s/</</g;
3348 $author =~ s/>/>/g;
3350 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
3351 <SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
3352 <TITLE>$(DISTNAME)</TITLE>
3353 <ABSTRACT>%s</ABSTRACT>
3357 $ppd_xml .= " <IMPLEMENTATION>\n";
3358 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
3359 my $pre_req = $prereq;
3360 $pre_req =~ s/::/-/g;
3361 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
3363 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
3364 <DEPENDENCY NAME="%s" VERSION="%s" />
3369 $ppd_xml .= sprintf <<'PPD_OUT', $Config{archname};
3370 <OS NAME="$(OSNAME)" />
3371 <ARCHITECTURE NAME="%s" />
3374 if ($self->{PPM_INSTALL_SCRIPT}) {
3375 if ($self->{PPM_INSTALL_EXEC}) {
3376 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
3377 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
3380 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
3381 $self->{PPM_INSTALL_SCRIPT};
3385 my ($bin_location) = $self->{BINARY_LOCATION} || '';
3386 $bin_location =~ s/\\/\\\\/g;
3388 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
3389 <CODEBASE HREF="%s" />
3394 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
3396 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3397 # Creates a PPD (Perl Package Description) for a binary distribution.
3406 $MM->prefixify($var, $prefix, $new_prefix, $default);
3408 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3409 replace it's $prefix with a $new_prefix.
3411 Should the $prefix fail to match I<AND> a PREFIX was given as an
3412 argument to WriteMakefile() it will set it to the $new_prefix +
3413 $default. This is for systems whose file layouts don't neatly fit into
3414 our ideas of prefixes.
3416 This is for heuristics which attempt to create directory structures
3417 that mirror those of the installed perl.
3421 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3423 this will attempt to remove '/usr' from the front of the
3424 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3425 if necessary) and replace it with '/home/foo'. If this fails it will
3426 simply use '/home/foo/man/man1'.
3431 my($self,$var,$sprefix,$rprefix,$default) = @_;
3433 my $path = $self->{uc $var} ||
3434 $Config_Override{lc $var} || $Config{lc $var} || '';
3436 $rprefix .= '/' if $sprefix =~ m|/$|;
3438 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3439 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
3441 if( $path !~ s{^\Q$sprefix\E\b}{$rprefix}s && $self->{ARGS}{PREFIX} ) {
3443 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3444 print STDERR " no default!\n" if !$default && $Verbose >= 2;
3446 $path = $self->catdir($rprefix, $default) if $default;
3449 print " now $path\n" if $Verbose >= 2;
3450 return $self->{uc $var} = $path;
3456 Defines targets to run *.PL files.
3462 return "" unless $self->{PL_FILES};
3464 foreach $plfile (sort keys %{$self->{PL_FILES}}) {
3465 my $list = ref($self->{PL_FILES}->{$plfile})
3466 ? $self->{PL_FILES}->{$plfile}
3467 : [$self->{PL_FILES}->{$plfile}];
3469 foreach $target (@$list) {
3475 \$(PERLRUNINST) $plfile $target
3484 Backslashes parentheses C<()> in command line arguments.
3485 Doesn't handle recursive Makefile C<$(...)> constructs,
3486 but handles simple ones.
3492 $arg =~ s/\$\((.+?)\)/\$\\\\($1\\\\)/g; # protect $(...)
3493 $arg =~ s/(?<!\\)([()])/\\$1/g; # quote unprotected
3494 $arg =~ s/\$\\\\\((.+?)\\\\\)/\$($1)/g; # unprotect $(...)
3500 Defines the realclean target.
3505 my($self, %attribs) = @_;
3509 # Delete temporary files (via clean) and also delete installed files
3510 realclean purge :: clean realclean_subdirs
3511 $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
3512 $(RM_RF) $(DISTVNAME)
3515 if( $self->has_link_code ){
3516 push(@m, " \$(RM_F) \$(INST_DYNAMIC) \$(INST_BOOT)\n");
3517 push(@m, " \$(RM_F) \$(INST_STATIC)\n");
3520 my @files = values %{$self->{PM}};
3521 push @files, $attribs{FILES} if $attribs{FILES};
3522 push @files, '$(FIRST_MAKEFILE)', '$(MAKEFILE_OLD)';
3524 # Occasionally files are repeated several times from different sources
3525 { my(%f) = map { ($_,1) } @files; @files = keys %f; }
3527 # Issue a several little RM_F commands rather than risk creating a
3528 # very long command line (useful for extensions such as Encode
3529 # that have many files).
3531 foreach my $file (@files) {
3532 if (length($line) + length($file) > 200) {
3533 push @m, "\t\$(RM_F) $line\n";
3540 push @m, "\t\$(RM_F) $line\n" if $line;
3541 push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
3547 =item realclean_subdirs_target
3549 my $make_frag = $MM->realclean_subdirs_target;
3551 Returns the realclean_subdirs target. This is used by the realclean
3552 target to call realclean on any subdirectories which contain Makefiles.
3556 sub realclean_subdirs_target {
3559 return <<'NOOP_FRAG' unless @{$self->{DIR}};
3564 my $rclean = "realclean_subdirs :\n";
3566 foreach my $dir (@{$self->{DIR}}){
3567 $rclean .= sprintf <<'RCLEAN', $dir, $dir;
3568 -cd %s && $(TEST_F) $(MAKEFILE_OLD) && $(MAKE) -f $(MAKEFILE_OLD) realclean
3569 -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) realclean
3578 =item replace_manpage_separator
3580 my $man_name = $MM->replace_manpage_separator($file_path);
3582 Takes the name of a package, which may be a nested package, in the
3583 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3584 safe for a man page file name. Returns the replacement.
3588 sub replace_manpage_separator {
3589 my($self,$man) = @_;
3601 my($self, $cmd, $switches) = @_;
3602 $switches = [] unless defined $switches;
3604 # Strip leading and trailing newlines
3608 my @cmds = split /\n/, $cmd;
3609 $cmd = join " \n\t-e ", map $self->quote_literal($_), @cmds;
3610 $cmd = $self->escape_newlines($cmd);
3612 $switches = join ' ', @$switches;
3614 return qq{\$(PERLRUN) $switches -e $cmd};
3623 my($self, $text) = @_;
3625 # I think all we have to quote is single quotes and I think
3626 # this is a safe way to do it.
3627 $text =~ s{'}{'\\''}g;
3633 =item escape_newlines
3637 sub escape_newlines {
3638 my($self, $text) = @_;
3640 $text =~ s{\n}{\\\n}g;
3648 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3655 if (!defined $self->{_MAX_EXEC_LEN}) {
3656 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3657 $self->{_MAX_EXEC_LEN} = $arg_max;
3659 else { # POSIX minimum exec size
3660 $self->{_MAX_EXEC_LEN} = 4096;
3664 return $self->{_MAX_EXEC_LEN};
3670 Defines the static target.
3675 # --- Static Loading Sections ---
3679 ## $(INST_PM) has been moved to the all: target.
3680 ## It remains here for awhile to allow for old usage: "make static"
3681 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3686 =item static_lib (o)
3688 Defines how to produce the *.a (or equivalent) files.
3694 return '' unless $self->has_link_code;
3699 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
3703 # If this extension has its own library (eg SDBM_File)
3704 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3705 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3706 $(CP) $(MYEXTLIB) $@
3710 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3711 # Prefer the absolute pathed ar if available so that PATH
3712 # doesn't confuse us. Perl itself is built with the full_ar.
3717 push @m, sprintf <<'MAKE_FRAG', $ar;
3718 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3719 $(CHMOD) $(PERM_RWX) $@
3720 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3723 # Old mechanism - still available:
3724 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3725 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3728 push @m, "\n", $self->dir_target('$(INST_ARCHAUTODIR)');
3732 =item staticmake (o)
3739 my($self, %attribs) = @_;
3742 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3744 # And as it's not yet built, we add the current extension
3745 # but only if it has some C code (or XS code, which implies C code)
3746 if (@{$self->{C}}) {
3747 @static = $self->catfile($self->{INST_ARCHLIB},
3750 "$self->{BASEEXT}$self->{LIB_EXT}"
3754 # Either we determine now, which libraries we will produce in the
3755 # subdirectories or we do it at runtime of the make.
3757 # We could ask all subdir objects, but I cannot imagine, why it
3758 # would be necessary.
3760 # Instead we determine all libraries for the new perl at
3762 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3764 $self->makeaperl(MAKE => $self->{MAKEFILE},
3765 DIRS => \@searchdirs,
3768 TARGET => $self->{MAP_TARGET},
3770 LIBPERL => $self->{LIBPERL_A}
3776 Helper subroutine for subdirs
3781 my($self, $subdir) = @_;
3782 return sprintf <<'EOT', $subdir;
3785 $(NOECHO)cd %s && $(MAKE) -f $(FIRST_MAKEFILE) all $(PASTHRU)
3791 Defines targets to process subdirectories.
3796 # --- Sub-directory Sections ---
3799 # This method provides a mechanism to automatically deal with
3800 # subdirectories containing further Makefile.PL scripts.
3801 # It calls the subdir_x() method for each subdirectory.
3802 foreach $dir (@{$self->{DIR}}){
3803 push(@m, $self->subdir_x($dir));
3804 #### print "Including $dir subdirectory\n";
3808 # The default clean, realclean and test targets in this Makefile
3809 # have automatically been given entries for each subdir.
3813 push(@m, "\n# none")
3820 Defines the test targets.
3825 # --- Test and Installation Sections ---
3827 my($self, %attribs) = @_;
3828 my $tests = $attribs{TESTS} || '';
3829 if (!$tests && -d 't') {
3830 $tests = $self->find_tests;
3832 # note: 'test.pl' name is also hardcoded in init_dirscan()
3836 TEST_TYPE=test_\$(LINKTYPE)
3841 testdb :: testdb_\$(LINKTYPE)
3843 test :: \$(TEST_TYPE)
3847 push(@m, map(qq{\t\$(NOECHO) \$(PERLRUN) -e "exit unless -f shift; chdir '$_'; system q{\$(MAKE) test \$(PASTHRU)}" \$(FIRST_MAKEFILE)\n}, @{$self->{DIR}}));
3850 push(@m, map("\t\$(NOECHO) cd $_ && \$(TEST_F) \$(FIRST_MAKEFILE) && \$(MAKE) test \$(PASTHRU)\n", @{$self->{DIR}}));
3853 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3854 unless $tests or -f "test.pl" or @{$self->{DIR}};
3857 push(@m, "test_dynamic :: pure_all\n");
3858 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3860 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3864 push(@m, "testdb_dynamic :: pure_all\n");
3865 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3869 # Occasionally we may face this degenerate target:
3870 push @m, "test_ : test_dynamic\n\n";
3872 if ($self->needs_linking()) {
3873 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3874 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3875 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3877 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3878 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3881 push @m, "test_static :: test_dynamic\n";
3882 push @m, "testdb_static :: testdb_dynamic\n";
3887 =item test_via_harness (override)
3889 For some reason which I forget, Unix machines like to have
3890 PERL_DL_NONLAZY set for tests.
3894 sub test_via_harness {
3895 my($self, $perl, $tests) = @_;
3896 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3899 =item test_via_script (override)
3901 Again, the PERL_DL_NONLAZY thing.
3905 sub test_via_script {
3906 my($self, $perl, $script) = @_;
3907 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3911 =item tools_other (o)
3913 my $make_frag = $MM->tools_other;
3915 Returns a make fragment containing definitions for:
3917 SHELL, CHMOD, CP, MV, NOOP, NOECHO, RM_F, RM_RF, TEST_F, TOUCH,
3918 DEV_NULL, UMASK_NULL, MKPATH, EQUALIZE_TIMESTAMP,
3919 WARN_IF_OLD_PACKLIST, UNINST, VERBINST, MOD_INSTALL, DOC_INSTALL and
3922 init_others() initializes all these values.
3930 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
3931 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
3934 MOD_INSTALL DOC_INSTALL UNINSTALL
3935 WARN_IF_OLD_PACKLIST
3938 next unless defined $self->{$tool};
3939 push @m, "$tool = $self->{$tool}\n";
3945 =item tool_xsubpp (o)
3947 Determines typemaps, xsubpp version, prototype behaviour.
3953 return "" unless $self->needs_linking;
3956 foreach my $dir (@INC) {
3957 $xsdir = $self->catdir($dir, 'ExtUtils');
3958 if( -r $self->catfile($xsdir, "xsubpp") ) {
3963 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3964 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3965 if( $self->{TYPEMAPS} ){
3967 foreach $typemap (@{$self->{TYPEMAPS}}){
3968 if( ! -f $typemap ){
3969 warn "Typemap $typemap not found.\n";
3972 push(@tmdeps, $typemap);
3976 push(@tmdeps, "typemap") if -f "typemap";
3977 my(@tmargs) = map("-typemap $_", @tmdeps);
3978 if( exists $self->{XSOPT} ){
3979 unshift( @tmargs, $self->{XSOPT} );
3983 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3987 XSUBPP = \$(XSUBPPDIR)/xsubpp
3988 XSPROTOARG = $self->{XSPROTOARG}
3989 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3990 XSUBPPARGS = @tmargs
3998 Build man pages, too
4005 return <<'MAKE_EXT';
4006 all :: pure_all manifypods
4011 =item top_targets (o)
4013 Defines the targets all, subdirs, config, and O_FILES
4018 # --- Target Sections ---
4023 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
4026 pure_all :: config pm_to_blib subdirs linkext
4029 subdirs :: $(MYEXTLIB)
4032 config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists
4035 config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
4038 config :: $(INST_AUTODIR)$(DIRFILESEP).exists
4042 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
4044 if (%{$self->{MAN1PODS}}) {
4046 config :: $(INST_MAN1DIR)$(DIRFILESEP).exists
4050 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
4052 if (%{$self->{MAN3PODS}}) {
4054 config :: $(INST_MAN3DIR)$(DIRFILESEP).exists
4058 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
4062 $(O_FILES): $(H_FILES)
4063 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
4067 perldoc ExtUtils::MakeMaker
4075 Obsolete, deprecated method. Not used since Version 5.21.
4080 # --- perllocal.pod section ---
4081 my($self,$what,$name,@attribs)=@_;
4082 my $time = localtime;
4083 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
4084 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
4085 print "\n\n=back\n\n";
4090 Defines the suffix rules to compile XS files to C.
4096 return '' unless $self->needs_linking();
4099 $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
4105 Defines the suffix rules to compile XS files to C++.
4111 return '' unless $self->needs_linking();
4114 $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
4120 Defines suffix rules to go from XS to object files directly. This is
4121 only intended for broken make implementations.
4125 sub xs_o { # many makes are too dumb to use xs_c then c_o
4127 return '' unless $self->needs_linking();
4130 $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
4131 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
4142 L<ExtUtils::MakeMaker>