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);
13 use vars qw($VERSION @ISA
14 $Is_OS2 $Is_VMS $Is_Win32 $Is_Win95 $Is_Dos $Is_VOS
15 $Is_QNX $Is_AIX $Is_OSF $Is_IRIX $Is_NetBSD $Is_BSD
16 $Is_SunOS4 $Is_Solaris $Is_SunOS
21 use ExtUtils::MakeMaker qw($Verbose neatvalue);
25 require ExtUtils::MM_Any;
26 @ISA = qw(ExtUtils::MM_Any);
28 $Is_OS2 = $^O eq 'os2';
29 $Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
30 $Is_Win95 = $Is_Win32 && Win32::IsWin95();
31 $Is_Dos = $^O eq 'dos';
32 $Is_VOS = $^O eq 'vos';
33 $Is_VMS = $^O eq 'VMS';
34 $Is_QNX = $^O eq 'qnx';
35 $Is_AIX = $^O eq 'aix';
36 $Is_OSF = $^O eq 'dec_osf';
37 $Is_IRIX = $^O eq 'irix';
38 $Is_NetBSD = $^O eq 'netbsd';
39 $Is_SunOS4 = $^O eq 'sunos';
40 $Is_Solaris = $^O eq 'solaris';
41 $Is_SunOS = $Is_SunOS4 || $Is_Solaris;
42 $Is_BSD = $^O =~ /^(?:free|net|open)bsd|bsdos$/;
47 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
51 C<require ExtUtils::MM_Unix;>
55 The methods provided by this package are designed to be used in
56 conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
57 Makefile, it creates one or more objects that inherit their methods
58 from a package C<MM>. MM itself doesn't provide any methods, but it
59 ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
60 specific packages take the responsibility for all the methods provided
61 by MM_Unix. We are trying to reduce the number of the necessary
62 overrides by defining rather primitive operations within
65 If you are going to write a platform specific MM package, please try
66 to limit the necessary overrides to primitive methods, and if it is not
67 possible to do so, let's work out how to achieve that gain.
69 If you are overriding any of these methods in your Makefile.PL (in the
70 MY class), please report that to the makemaker mailing list. We are
71 trying to minimize the necessary method overrides and switch to data
72 driven Makefile.PLs wherever possible. In the long run less methods
73 will be overridable via the MY class.
77 The following description of methods is still under
78 development. Please refer to the code for not suitably documented
79 sections and complain loudly to the makemaker@perl.org mailing list.
80 Better yet, provide a patch.
82 Not all of the methods below are overridable in a
83 Makefile.PL. Overridable methods are marked as (o). All methods are
84 overridable by a platform specific MM_*.pm file (See
85 L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>).
89 # So we don't have to keep calling the methods over and over again,
90 # we have these globals to cache the values. Faster and shrtr.
91 my $Curdir = __PACKAGE__->curdir;
92 my $Rootdir = __PACKAGE__->rootdir;
93 my $Updir = __PACKAGE__->updir;
102 Simply says that we're Unix.
113 Defines the suffix rules to compile different flavors of C files to
119 # --- Translation Sections ---
122 return '' unless $self->needs_linking();
124 if (my $cpp = $Config{cpprun}) {
125 my $cpp_cmd = $self->const_cccmd;
126 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/;
129 '. $cpp_cmd . ' $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i
134 $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
138 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
142 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C
143 ' if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific
146 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp
149 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx
152 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc
159 Does very much the same as the cflags script in the perl
160 distribution. It doesn't return the whole compiler command line, but
161 initializes all of its parts. The const_cccmd method then actually
162 returns the definition of the CCCMD macro which uses these parts.
169 my($self,$libperl)=@_;
170 return $self->{CFLAGS} if $self->{CFLAGS};
171 return '' unless $self->needs_linking();
173 my($prog, $uc, $perltype, %cflags);
174 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
175 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
177 @cflags{qw(cc ccflags optimize shellflags)}
178 = @Config{qw(cc ccflags optimize shellflags)};
181 $cflags{shellflags} ||= '';
186 DE => '-DDEBUGGING -DEMBED',
187 M => '-DEMBED -DMULTIPLICITY',
188 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
191 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
194 $uc = ""; # avoid warning
196 $perltype = $map{$uc} ? $map{$uc} : "";
204 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
205 if ($prog = $Config{$name}) {
206 # Expand hints for this extension via the shell
207 print STDOUT "Processing $name hint:\n" if $Verbose;
208 my(@o)=`cc=\"$cflags{cc}\"
209 ccflags=\"$cflags{ccflags}\"
210 optimize=\"$cflags{optimize}\"
211 perltype=\"$cflags{perltype}\"
212 optdebug=\"$cflags{optdebug}\"
215 echo ccflags=\$ccflags
216 echo optimize=\$optimize
217 echo perltype=\$perltype
218 echo optdebug=\$optdebug
223 if ($line =~ /(.*?)=\s*(.*)\s*$/){
225 print STDOUT " $1 = $2\n" if $Verbose;
227 print STDOUT "Unrecognised result from hint: '$line'\n";
233 $cflags{optimize} = $optdebug;
236 for (qw(ccflags optimize perltype)) {
238 $cflags{$_} =~ s/^\s+//;
239 $cflags{$_} =~ s/\s+/ /g;
240 $cflags{$_} =~ s/\s+$//;
241 $self->{uc $_} ||= $cflags{$_};
244 if ($self->{POLLUTE}) {
245 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
249 if ($Config{usemymalloc} and not $Config{bincompat5005}
250 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
251 and $self->{PERL_MALLOC_OK}) {
252 $pollute = '$(PERL_MALLOC_DEF)';
255 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS});
256 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE});
258 return $self->{CFLAGS} = qq{
259 CCFLAGS = $self->{CCFLAGS}
260 OPTIMIZE = $self->{OPTIMIZE}
261 PERLTYPE = $self->{PERLTYPE}
269 Defines the clean target.
274 # --- Cleanup and Distribution Sections ---
276 my($self, %attribs) = @_;
279 # Delete temporary files but do not touch installed files. We don\'t delete
280 # the Makefile here so a later make realclean still has a makefile to use.
282 clean :: clean_subdirs
285 my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
287 my @errfiles = @{$self->{C}};
291 push( @otherfiles, @errfiles, 'perlmain.err' );
293 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
294 push(@otherfiles, qw[./blib $(MAKE_APERL_FILE)
295 $(INST_ARCHAUTODIR)/extralibs.all
296 $(INST_ARCHAUTODIR)/extralibs.ld
297 perlmain.c tmon.out mon.out so_locations
298 blibdirs.ts pm_to_blib.ts
299 *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT)
300 $(BOOTSTRAP) $(BASEEXT).bso
301 $(BASEEXT).def lib$(BASEEXT).def
302 $(BASEEXT).exp $(BASEEXT).x
305 push(@otherfiles, qw[*.kp]);
308 push(@otherfiles, qw[core core.*perl.*.? *perl.core]);
311 push(@otherfiles, map { "core." . "[0-9]"x$_ } (1..5));
314 push @m, "\t-\$(RM_RF) @otherfiles\n";
315 # See realclean and ext/utils/make_ext for usage of Makefile.old
317 "\t-\$(MV) \$(FIRST_MAKEFILE) \$(MAKEFILE_OLD) \$(DEV_NULL)\n");
319 "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
324 =item clean_subdirs_target
326 my $make_frag = $MM->clean_subdirs_target;
328 Returns the clean_subdirs target. This is used by the clean target to
329 call clean on any subdirectories which contain Makefiles.
333 sub clean_subdirs_target {
336 # No subdirectories, no cleaning.
337 return <<'NOOP_FRAG' unless @{$self->{DIR}};
343 my $clean = "clean_subdirs :\n";
345 for my $dir (@{$self->{DIR}}) {
346 $clean .= sprintf <<'MAKE_FRAG', $dir;
347 -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) clean
355 =item const_cccmd (o)
357 Returns the full compiler call for C programs and stores the
358 definition in CONST_CCCMD.
363 my($self,$libperl)=@_;
364 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
365 return '' unless $self->needs_linking();
366 return $self->{CONST_CCCMD} =
367 q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
368 $(CCFLAGS) $(OPTIMIZE) \\
369 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
370 $(XS_DEFINE_VERSION)};
373 =item const_config (o)
375 Defines a couple of constants in the Makefile that are imported from
381 # --- Constants Sections ---
385 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
386 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
388 foreach $m (@{$self->{CONFIG}}){
389 # SITE*EXP macros are defined in &constants; avoid duplicates here
390 next if $once_only{$m};
391 $self->{uc $m} = quote_paren($self->{uc $m});
392 push @m, uc($m) , ' = ' , $self->{uc $m}, "\n";
398 =item const_loadlibs (o)
400 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
401 L<ExtUtils::Liblist> for details.
407 return "" unless $self->needs_linking;
410 # $self->{NAME} might depend on some other libraries:
411 # See ExtUtils::Liblist for details
416 EXTRALIBS LDLOADLIBS BSLOADLIBS
418 next unless defined $self->{$tmp};
419 push @m, "$tmp = $self->{$tmp}\n";
421 # don't set LD_RUN_PATH if empty
425 next unless $self->{$tmp};
426 push @m, "$tmp = $self->{$tmp}\n";
433 my $make_frag = $mm->constants;
435 Prints out macros for lots of constants.
445 AR_STATIC_ARGS DIRFILESEP
447 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
448 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
449 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
450 INST_MAN1DIR INST_MAN3DIR
454 PERLPREFIX SITEPREFIX VENDORPREFIX
456 (map { ("INSTALL".$_,
458 } $self->installvars),
463 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
464 PERLMAINCC PERL_SRC PERL_INC
465 PERL FULLPERL ABSPERL
466 PERLRUN FULLPERLRUN ABSPERLRUN
467 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
473 next unless defined $self->{$macro};
475 # pathnames can have sharp signs in them; escape them so
476 # make doesn't think it is a comment-start character.
477 $self->{$macro} =~ s/#/\\#/g;
478 push @m, "$macro = $self->{$macro}\n";
482 MAKEMAKER = $self->{MAKEMAKER}
483 MM_VERSION = $self->{MM_VERSION}
484 MM_REVISION = $self->{MM_REVISION}
488 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
489 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
490 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
491 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
495 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
496 LDFROM LINKTYPE PM_FILTER
499 next unless defined $self->{$macro};
500 push @m, "$macro = $self->{$macro}\n";
504 # Handy lists of source code files:
505 XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
506 C_FILES = ".$self->wraplist(@{$self->{C}})."
507 O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."
508 H_FILES = ".$self->wraplist(@{$self->{H}})."
509 MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
510 MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
515 # Where is the Config information that we are using/depend on
516 CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h
521 # Where to build things
522 INST_LIBDIR = $self->{INST_LIBDIR}
523 INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
525 INST_AUTODIR = $self->{INST_AUTODIR}
526 INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
528 INST_STATIC = $self->{INST_STATIC}
529 INST_DYNAMIC = $self->{INST_DYNAMIC}
530 INST_BOOT = $self->{INST_BOOT}
536 EXPORT_LIST = $self->{EXPORT_LIST}
537 PERL_ARCHIVE = $self->{PERL_ARCHIVE}
538 PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
543 TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."
545 PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}})."
554 Same as macro for the depend attribute.
559 my($self,%attribs) = @_;
561 while (($key,$val) = each %attribs){
562 last unless defined $key;
563 push @m, "$key : $val\n";
573 Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
581 $self->{DESTDIR} ||= '';
583 # Make DEST variables.
584 foreach my $var ($self->installvars) {
585 my $destvar = 'DESTINSTALL'.$var;
586 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
595 Defines a lot of macros for distribution support.
597 macro description default
599 TAR tar command to use tar
600 TARFLAGS flags to pass to TAR cvf
602 ZIP zip command to use zip
603 ZIPFLAGS flags to pass to ZIP -r
605 COMPRESS compression command to gzip --best
607 SUFFIX suffix to put on .gz
610 SHAR shar command to use shar
612 PREOP extra commands to run before
614 POSTOP extra commands to run after
617 TO_UNIX a command to convert linefeeds
618 to Unix style in your archive
620 CI command to checkin your ci -u
621 sources to version control
622 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
625 DIST_CP $how argument to manicopy() best
626 when the distdir is created
628 DIST_DEFAULT default target to use to tardist
629 create a distribution
631 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
639 $self->{TAR} ||= 'tar';
640 $self->{TARFLAGS} ||= 'cvf';
641 $self->{ZIP} ||= 'zip';
642 $self->{ZIPFLAGS} ||= '-r';
643 $self->{COMPRESS} ||= 'gzip --best';
644 $self->{SUFFIX} ||= '.gz';
645 $self->{SHAR} ||= 'shar';
646 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
647 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
648 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
650 $self->{CI} ||= 'ci -u';
651 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
652 $self->{DIST_CP} ||= 'best';
653 $self->{DIST_DEFAULT} ||= 'tardist';
655 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
656 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
662 my $dist_macros = $mm->dist(%overrides);
664 Generates a make fragment defining all the macros initialized in
667 %overrides can be used to override any of the above.
672 my($self, %attribs) = @_;
676 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
678 CI RCS_LABEL DIST_CP DIST_DEFAULT
682 my $value = $attribs{$key} || $self->{$key};
683 $make .= "$key = $value\n";
689 =item dist_basics (o)
691 Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
698 return <<'MAKE_FRAG';
699 distclean :: realclean distcheck
703 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
706 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
709 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
711 veryclean : realclean
712 $(RM_F) *~ *.orig */*~ */*.orig
720 Defines a check in target for RCS.
728 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\
729 -e "@all = keys %{ maniread() };" \\
730 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\
731 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
737 my $dist_make_fragment = $MM->dist_core;
739 Puts the targets necessary for 'make dist' together into one make
748 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
751 my $method = $target.'_target';
753 $make_frag .= $self->$method();
762 my $make_frag = $MM->dist_target;
764 Returns the 'dist' target to make an archive for distribution. This
765 target simply checks to make sure the Makefile is up-to-date and
766 depends on $(DIST_DEFAULT).
773 my $date_check = $self->oneliner(<<'CODE', ['-l']);
774 print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
775 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
778 return sprintf <<'MAKE_FRAG', $date_check;
779 dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
784 =item B<tardist_target>
786 my $make_frag = $MM->tardist_target;
788 Returns the 'tardist' target which is simply so 'make tardist' works.
789 The real work is done by the dynamically named tardistfile_target()
790 method, tardist should have that as a dependency.
797 return <<'MAKE_FRAG';
798 tardist : $(DISTVNAME).tar$(SUFFIX)
803 =item B<zipdist_target>
805 my $make_frag = $MM->zipdist_target;
807 Returns the 'zipdist' target which is simply so 'make zipdist' works.
808 The real work is done by the dynamically named zipdistfile_target()
809 method, zipdist should have that as a dependency.
816 return <<'MAKE_FRAG';
817 zipdist : $(DISTVNAME).zip
822 =item B<tarfile_target>
824 my $make_frag = $MM->tarfile_target;
826 The name of this target is the name of the tarball generated by
827 tardist. This target does the actual work of turning the distdir into
835 return <<'MAKE_FRAG';
836 $(DISTVNAME).tar$(SUFFIX) : distdir
839 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
840 $(RM_RF) $(DISTVNAME)
841 $(COMPRESS) $(DISTVNAME).tar
848 my $make_frag = $MM->zipfile_target;
850 The name of this target is the name of the zip file generated by
851 zipdist. This target does the actual work of turning the distdir into
859 return <<'MAKE_FRAG';
860 $(DISTVNAME).zip : distdir
862 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
863 $(RM_RF) $(DISTVNAME)
868 =item uutardist_target
870 my $make_frag = $MM->uutardist_target;
872 Converts the tarfile into a uuencoded file
876 sub uutardist_target {
879 return <<'MAKE_FRAG';
880 uutardist : $(DISTVNAME).tar$(SUFFIX)
881 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
888 my $make_frag = $MM->shdist_target;
890 Converts the distdir into a shell archive.
897 return <<'MAKE_FRAG';
900 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
901 $(RM_RF) $(DISTVNAME)
908 Defines the scratch directory target that will hold the distribution
909 before tar-ing (or shar-ing).
913 # For backwards compatibility.
914 *dist_dir = *distdir;
919 return <<'MAKE_FRAG';
920 distdir : metafile metafile_addtomanifest signature
921 $(RM_RF) $(DISTVNAME)
922 $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
923 -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
931 Defines a target that produces the distribution in the
932 scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
942 cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
943 cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
944 cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
951 Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp
957 my($self,%attribs) = @_;
959 return '' unless ($Is_AIX && $self->needs_linking() );
961 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
962 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
963 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
967 dynamic :: $self->{BASEEXT}.exp
969 ") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
972 static :: $self->{BASEEXT}.exp
974 ") unless $self->{SKIPHASH}{'static'}; # we avoid a warning if we tick them
977 $self->{BASEEXT}.exp: Makefile.PL
978 ",' $(PERLRUN) -e \'use ExtUtils::Mksymlists; \\
979 Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
980 neatvalue($funcs), ', "FUNCLIST" => ', neatvalue($funclist),
981 ', "DL_VARS" => ', neatvalue($vars), ');\'
989 Defines the dynamic target.
994 # --- Dynamic Loading Sections ---
998 dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
1003 =item dynamic_bs (o)
1005 Defines targets for bootstrap files.
1010 my($self, %attribs) = @_;
1013 ' unless $self->has_link_code();
1015 return <<'MAKE_FRAG';
1016 BOOTSTRAP = $(BASEEXT).bs
1018 # As Mkbootstrap might not write a file (if none is required)
1019 # we use touch to prevent make continually trying to remake it.
1020 # The DynaLoader only reads a non-empty file.
1021 $(BOOTSTRAP): $(FIRST_MAKEFILE) $(BOOTDEP) blibdirs.ts
1022 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
1023 $(NOECHO) $(PERLRUN) \
1024 "-MExtUtils::Mkbootstrap" \
1025 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
1026 $(NOECHO) $(TOUCH) $@
1027 $(CHMOD) $(PERM_RW) $@
1029 $(INST_BOOT): $(BOOTSTRAP) blibdirs.ts
1030 $(NOECHO) $(RM_RF) $@
1031 -$(CP) $(BOOTSTRAP) $@
1032 $(CHMOD) $(PERM_RW) $@
1036 =item dynamic_lib (o)
1038 Defines how to produce the *.so (or equivalent) files.
1043 my($self, %attribs) = @_;
1044 return '' unless $self->needs_linking(); #might be because of a subdir
1046 return '' unless $self->has_link_code;
1048 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
1049 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
1050 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
1051 my($ldfrom) = '$(LDFROM)';
1052 $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':');
1054 my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
1055 my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : '';
1057 # This section creates the dynamically loadable $(INST_DYNAMIC)
1058 # from $(OBJECT) and possibly $(MYEXTLIB).
1059 ARMAYBE = '.$armaybe.'
1060 OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
1061 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
1062 INST_DYNAMIC_FIX = '.$ld_fix.'
1064 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) blibdirs.ts $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
1066 if ($armaybe ne ':'){
1067 $ldfrom = 'tmp$(LIB_EXT)';
1068 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
1069 push(@m,' $(RANLIB) '."$ldfrom\n");
1071 $ldfrom = "-all $ldfrom -none" if $Is_OSF;
1073 # The IRIX linker doesn't use LD_RUN_PATH
1074 my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ?
1075 qq{-rpath "$self->{LD_RUN_PATH}"} : '';
1077 # For example in AIX the shared objects/libraries from previous builds
1078 # linger quite a while in the shared dynalinker cache even when nobody
1079 # is using them. This is painful if one for instance tries to restart
1080 # a failed build because the link command will fail unnecessarily 'cos
1081 # the shared object/library is 'busy'.
1082 push(@m,' $(RM_F) $@
1085 my $libs = '$(LDLOADLIBS)';
1087 if ($Is_NetBSD && $Config{'useshrplib'}) {
1088 # Use nothing on static perl platforms, and to the flags needed
1089 # to link against the shared libperl library on shared perl
1090 # platforms. We peek at lddlflags to see if we need -Wl,-R
1091 # or -R to add paths to the run-time library search path.
1092 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
1093 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
1094 } elsif ($Config{'lddlflags'} =~ /-R/) {
1095 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
1099 my $ld_run_path_shell = "";
1100 if ($self->{LD_RUN_PATH} ne "") {
1101 $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
1104 push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs;
1105 %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
1106 $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
1111 $(CHMOD) $(PERM_RWX) $@
1119 Deprecated method. Use libscan instead.
1124 my($self,$path) = @_;
1130 Called by init_others, and calls ext ExtUtils::Liblist. See
1131 L<ExtUtils::Liblist> for details.
1136 my($self,$libs) = @_;
1137 require ExtUtils::Liblist;
1138 $self->ext($libs, $Verbose);
1143 Finds the executables PERL and FULLPERL
1148 my($self, $ver, $names, $dirs, $trace) = @_;
1151 print "Looking for perl $ver by these names:
1158 my $stderr_duped = 0;
1161 if( open(STDERR_COPY, '>&STDERR') ) {
1166 find_perl() can't dup STDERR: $!
1167 You might see some garbage while we search for Perl
1172 foreach $name (@$names){
1173 foreach $dir (@$dirs){
1174 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1176 if ($self->file_name_is_absolute($name)) { # /foo/bar
1178 } elsif ($self->canonpath($name) eq
1179 $self->canonpath(basename($name))) { # foo
1180 $abs = $self->catfile($dir, $name);
1182 $abs = $self->catfile($Curdir, $name);
1184 print "Checking $abs\n" if ($trace >= 2);
1185 next unless $self->maybe_command($abs);
1186 print "Executing $abs\n" if ($trace >= 2);
1188 my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"};
1189 # To avoid using the unportable 2>&1 to supress STDERR,
1190 # we close it before running the command.
1191 # However, thanks to a thread library bug in many BSDs
1192 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1193 # we cannot use the fancier more portable way in here
1194 # but instead need to use the traditional 2>&1 construct.
1196 $val = `$version_check 2>&1`;
1198 close STDERR if $stderr_duped;
1199 $val = `$version_check`;
1200 open STDERR, '>&STDERR_COPY' if $stderr_duped;
1203 if ($val =~ /^VER_OK/) {
1204 print "Using PERL=$abs\n" if $trace;
1206 } elsif ($trace >= 2) {
1207 print "Result: '$val'\n";
1211 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1212 0; # false and not empty
1217 my $test = $mm->find_tests;
1219 Returns a string suitable for feeding to the shell to return all
1231 =head2 Methods to actually produce chunks of text for the Makefile
1233 The methods here are called for each MakeMaker object in the order
1234 specified by @ExtUtils::MakeMaker::MM_Sections.
1242 Inserts the sharpbang or equivalent magic number to a set of @files.
1246 sub fixin { # stolen from the pink Camel book, more or less
1247 my($self, @files) = @_;
1249 my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1250 for my $file (@files) {
1251 my $file_new = "$file.new";
1252 my $file_bak = "$file.bak";
1256 open(FIXIN, $file) or croak "Can't process '$file': $!";
1258 chomp(my $line = <FIXIN>);
1259 next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
1260 # Now figure out the interpreter name.
1261 my($cmd,$arg) = split ' ', $line, 2;
1264 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
1266 if ($cmd eq "perl") {
1267 if ($Config{startperl} =~ m,^\#!.*/perl,) {
1268 $interpreter = $Config{startperl};
1269 $interpreter =~ s,^\#!,,;
1271 $interpreter = $Config{perlpath};
1274 my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path;
1277 foreach $dir (@absdirs) {
1278 if ($self->maybe_command($cmd)) {
1279 warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter;
1280 $interpreter = $self->catfile($dir,$cmd);
1284 # Figure out how to invoke interpreter on this machine.
1288 print STDOUT "Changing sharpbang in $file to $interpreter" if $Verbose;
1289 # this is probably value-free on DOSISH platforms
1291 $shb .= "$Config{'sharpbang'}$interpreter";
1292 $shb .= ' ' . $arg if defined $arg;
1296 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
1297 if 0; # not running under some shell
1298 } unless $Is_Win32; # this won't work on win32, so don't
1300 warn "Can't find $cmd in PATH, $file unchanged"
1305 unless ( open(FIXOUT,">$file_new") ) {
1306 warn "Can't create new $file: $!\n";
1310 # Print out the new #! line (or equivalent).
1313 print FIXOUT $shb, <FIXIN>;
1317 chmod 0666, $file_bak;
1319 unless ( rename($file, $file_bak) ) {
1320 warn "Can't rename $file to $file_bak: $!";
1323 unless ( rename($file_new, $file) ) {
1324 warn "Can't rename $file_new to $file: $!";
1325 unless ( rename($file_bak, $file) ) {
1326 warn "Can't rename $file_bak back to $file either: $!";
1327 warn "Leaving $file renamed as $file_bak\n";
1333 close(FIXIN) if fileno(FIXIN);
1334 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
1346 '# Phony target to force checking subdirectories.
1354 Guess the name of this package by examining the working directory's
1355 name. MakeMaker calls this only if the developer has not supplied a
1365 my $name = basename(cwd());
1366 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
1367 # strip minus or underline
1368 # followed by a float or some such
1369 print "Warning: Guessing NAME [$name] from current directory name.\n";
1375 Returns true if C, XS, MYEXTLIB or similar objects exist within this
1376 object that need a compiler. Does not descend into subdirectories as
1377 needs_linking() does.
1383 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1384 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1385 $self->{HAS_LINK_CODE} = 1;
1388 return $self->{HAS_LINK_CODE} = 0;
1394 Scans the directory structure and initializes DIR, XS, XS_FILES, PM,
1395 C, C_FILES, O_FILES, H, H_FILES, PL_FILES, MAN*PODS, EXE_FILES.
1397 Called by init_main.
1401 sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1403 my($name, %dir, %xs, %c, %h, %pl_files, %manifypods);
1406 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
1408 # ignore the distdir
1409 $Is_VMS ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1410 : $ignore{$self->{DISTVNAME}} = 1;
1412 @ignore{map lc, keys %ignore} = values %ignore if $Is_VMS;
1414 foreach $name ($self->lsdir($Curdir)){
1415 next if $name =~ /\#/;
1416 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
1417 next unless $self->libscan($name);
1419 next if -l $name; # We do not support symlinks at all
1420 next if $self->{NORECURS};
1421 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1422 } elsif ($name =~ /\.xs\z/){
1423 my($c); ($c = $name) =~ s/\.xs\z/.c/;
1426 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
1428 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1429 } elsif ($name =~ /\.h\z/i){
1431 } elsif ($name =~ /\.PL\z/) {
1432 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
1433 } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
1434 # case-insensitive filesystem, one dot per name, so foo.h.PL
1435 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
1436 local($/); open(PL,$name); my $txt = <PL>; close PL;
1437 if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
1438 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
1441 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1443 } elsif ($name =~ /\.(p[ml]|pod)\z/){
1444 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1448 # Some larger extensions often wish to install a number of *.pm/pl
1449 # files into the library in various locations.
1451 # The attribute PMLIBDIRS holds an array reference which lists
1452 # subdirectories which we should search for library files to
1453 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1454 # recursively search through the named directories (skipping any
1455 # which don't exist or contain Makefile.PL files).
1457 # For each *.pm or *.pl file found $self->libscan() is called with
1458 # the default installation path in $_[1]. The return value of
1459 # libscan defines the actual installation location. The default
1460 # libscan function simply returns the path. The file is skipped
1461 # if libscan returns false.
1463 # The default installation location passed to libscan in $_[1] is:
1465 # ./*.pm => $(INST_LIBDIR)/*.pm
1466 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1467 # ./lib/... => $(INST_LIB)/...
1469 # In this way the 'lib' directory is seen as the root of the actual
1470 # perl library whereas the others are relative to INST_LIBDIR
1471 # (which includes PARENT_NAME). This is a subtle distinction but one
1472 # that's important for nested modules.
1474 unless( $self->{PMLIBDIRS} ) {
1476 # Avoid logical name vs directory collisions
1477 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1480 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1484 #only existing directories that aren't in $dir are allowed
1486 # Avoid $_ wherever possible:
1487 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1488 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1490 @{$self->{PMLIBDIRS}} = ();
1491 foreach $pmlibdir (@pmlibdirs) {
1492 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1495 if (@{$self->{PMLIBDIRS}}){
1496 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1499 File::Find::find(sub {
1501 unless ($self->libscan($_)){
1502 $File::Find::prune = 1;
1507 return if /~$/; # emacs temp files
1508 return if /,v$/; # RCS files
1510 my $path = $File::Find::name;
1511 my $prefix = $self->{INST_LIBDIR};
1514 $prefix = $self->{INST_LIB}
1515 if ($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i;
1517 my($inst) = $self->catfile($prefix,$striplibpath);
1518 local($_) = $inst; # for backwards compatibility
1519 $inst = $self->libscan($inst);
1520 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1521 return unless $inst;
1523 }, @{$self->{PMLIBDIRS}});
1526 $self->{PM} ||= \%pm;
1527 $self->{PL_FILES} ||= \%pl_files;
1529 $self->{DIR} ||= [sort keys %dir];
1531 $self->{XS} ||= \%xs;
1532 $self->{C} ||= [sort keys %c];
1533 my @o_files = @{$self->{C}};
1534 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
1536 $self->{H} ||= [sort keys %h];
1538 # Set up names of manual pages to generate from pods
1540 foreach my $man (qw(MAN1 MAN3)) {
1541 unless ($self->{"${man}PODS"}) {
1542 $self->{"${man}PODS"} = {};
1543 $pods{$man} = 1 unless
1544 $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/;
1549 if ( exists $self->{EXE_FILES} ) {
1550 foreach $name (@{$self->{EXE_FILES}}) {
1553 if (open(FH,"<$name")) {
1555 if (/^=(?:head\d+|item|pod)\b/) {
1562 # If it doesn't exist yet, we assume, it has pods in it
1567 $self->{MAN1PODS}->{$name} =
1568 $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)");
1574 my %manifypods = (); # we collect the keys first, i.e. the files
1575 # we have to convert to pod
1576 foreach $name (keys %{$self->{PM}}) {
1577 if ($name =~ /\.pod\z/ ) {
1578 $manifypods{$name} = $self->{PM}{$name};
1579 } elsif ($name =~ /\.p[ml]\z/ ) {
1582 if (open(FH,"<$name")) {
1584 if (/^=head1\s+\w+/) {
1594 $manifypods{$name} = $self->{PM}{$name};
1599 # Remove "Configure.pm" and similar, if it's not the only pod listed
1600 # To force inclusion, just name it "Configure.pod", or override
1602 foreach $name (keys %manifypods) {
1603 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
1604 delete $manifypods{$name};
1607 my($manpagename) = $name;
1608 $manpagename =~ s/\.p(od|m|l)\z//;
1609 # everything below lib is ok
1610 unless($manpagename =~ s!^\W*lib\W+!!s) {
1611 $manpagename = $self->catfile(
1612 split(/::/,$self->{PARENT_NAME}),$manpagename
1616 $manpagename = $self->replace_manpage_separator($manpagename);
1617 $self->{MAN3PODS}->{$name} =
1618 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1624 =item init_DIRFILESEP
1626 Using / for Unix. Called by init_main.
1630 sub init_DIRFILESEP {
1633 $self->{DIRFILESEP} = '/';
1639 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1640 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1641 INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1642 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1643 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1644 VERSION_SYM, XS_VERSION.
1651 # --- Initialize Module Name and Paths
1653 # NAME = Foo::Bar::Oracle
1654 # FULLEXT = Foo/Bar/Oracle
1656 # PARENT_NAME = Foo::Bar
1658 ### ($self->{FULLEXT} =
1659 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1660 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1663 # Copied from DynaLoader:
1665 my(@modparts) = split(/::/,$self->{NAME});
1666 my($modfname) = $modparts[-1];
1668 # Some systems have restrictions on files names for DLL's etc.
1669 # mod2fname returns appropriate file base name (typically truncated)
1670 # It may also edit @modparts if required.
1671 if (defined &DynaLoader::mod2fname) {
1672 $modfname = &DynaLoader::mod2fname(\@modparts);
1675 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1676 $self->{PARENT_NAME} ||= '';
1678 if (defined &DynaLoader::mod2fname) {
1679 # As of 5.001m, dl_os2 appends '_'
1680 $self->{DLBASE} = $modfname;
1682 $self->{DLBASE} = '$(BASEEXT)';
1686 # --- Initialize PERL_LIB, PERL_SRC
1688 # *Real* information: where did we get these two from? ...
1689 my $inc_config_dir = dirname($INC{'Config.pm'});
1690 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1692 unless ($self->{PERL_SRC}){
1694 foreach $dir ($Updir,
1695 $self->catdir($Updir,$Updir),
1696 $self->catdir($Updir,$Updir,$Updir),
1697 $self->catdir($Updir,$Updir,$Updir,$Updir),
1698 $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir))
1701 -f $self->catfile($dir,"config_h.SH")
1703 -f $self->catfile($dir,"perl.h")
1705 -f $self->catfile($dir,"lib","Exporter.pm")
1707 $self->{PERL_SRC}=$dir ;
1713 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1714 $self->{PERL_CORE} and !$self->{PERL_SRC};
1716 if ($self->{PERL_SRC}){
1717 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1719 if (defined $Cross::platform) {
1720 $self->{PERL_ARCHLIB} =
1721 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
1723 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
1724 $Is_Win32?("CORE"):());
1727 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1728 $self->{PERL_INC} = ($Is_Win32) ?
1729 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1732 # catch a situation that has occurred a few times in the past:
1734 -s $self->catfile($self->{PERL_SRC},'cflags')
1738 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1743 You cannot build extensions below the perl source tree after executing
1744 a 'make clean' in the perl source tree.
1746 To rebuild extensions distributed with the perl source you should
1747 simply Configure (to include those extensions) and then build perl as
1748 normal. After installing perl the source tree can be deleted. It is
1749 not needed for building extensions by running 'perl Makefile.PL'
1750 usually without extra arguments.
1752 It is recommended that you unpack and build additional extensions away
1753 from the perl source tree.
1757 # we should also consider $ENV{PERL5LIB} here
1758 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1759 $self->{PERL_LIB} ||= $Config{privlibexp};
1760 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1761 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1764 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1766 # Maybe somebody tries to build an extension with an
1767 # uninstalled Perl outside of Perl build tree
1769 for my $dir (@INC) {
1770 $found = $dir, last if -e $self->catdir($dir, "Config.pm");
1773 my $inc = dirname $found;
1774 if (-e $self->catdir($inc, "perl.h")) {
1775 $self->{PERL_LIB} = $found;
1776 $self->{PERL_ARCHLIB} = $found;
1777 $self->{PERL_INC} = $inc;
1778 $self->{UNINSTALLED_PERL} = 1;
1780 ... Detected uninstalled Perl. Trying to continue.
1787 # We get SITELIBEXP and SITEARCHEXP directly via
1788 # Get_from_Config. When we are running standard modules, these
1789 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1790 # set it to "site". I prefer that INSTALLDIRS be set from outside
1792 $self->{INSTALLDIRS} ||= "site";
1794 $self->{MAN1EXT} ||= $Config{man1ext};
1795 $self->{MAN3EXT} ||= $Config{man3ext};
1797 # Get some stuff out of %Config if we haven't yet done so
1798 print STDOUT "CONFIG must be an array ref\n"
1799 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1800 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1801 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1802 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1804 foreach my $m (@{$self->{CONFIG}}){
1805 next if $once_only{$m};
1806 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1807 unless exists $Config{$m};
1808 $self->{uc $m} ||= $Config{$m};
1812 # This is too dangerous:
1813 # if ($^O eq "next") {
1814 # $self->{AR} = "libtool";
1815 # $self->{AR_STATIC_ARGS} = "-o";
1817 # But I leave it as a placeholder
1819 $self->{AR_STATIC_ARGS} ||= "cr";
1821 # These should never be needed
1822 $self->{OBJ_EXT} ||= '.o';
1823 $self->{LIB_EXT} ||= '.a';
1825 $self->{MAP_TARGET} ||= "perl";
1827 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1829 # make a simple check if we find Exporter
1830 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1831 (Exporter.pm not found)"
1832 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1833 $self->{NAME} eq "ExtUtils::MakeMaker";
1838 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
1839 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1840 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
1841 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1845 sub init_others { # --- Initialize Other Attributes
1848 $self->{LD} ||= 'ld';
1850 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1851 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1852 # undefined. In any case we turn it into an anon array:
1854 # May check $Config{libs} too, thus not empty.
1855 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
1857 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
1858 $self->{LD_RUN_PATH} = "";
1860 foreach $libs ( @{$self->{LIBS}} ){
1861 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1862 my(@libs) = $self->extliblist($libs);
1863 if ($libs[0] or $libs[1] or $libs[2]){
1864 # LD_RUN_PATH now computed by ExtUtils::Liblist
1865 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1866 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1871 if ( $self->{OBJECT} ) {
1872 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1874 # init_dirscan should have found out, if we have C files
1875 $self->{OBJECT} = "";
1876 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1878 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1879 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1880 $self->{PERLMAINCC} ||= '$(CC)';
1881 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1883 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1884 # the 'dynamic' section of MM. We don't have this problem with
1885 # 'static', since we either must use it (%Config says we can't
1886 # use dynamic loading) or the caller asked for it explicitly.
1887 if (!$self->{LINKTYPE}) {
1888 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1890 : ($Config{usedl} ? 'dynamic' : 'static');
1893 $self->{NOOP} ||= '$(SHELL) -c true';
1894 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1896 $self->{FIRST_MAKEFILE} ||= 'Makefile';
1897 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1898 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1899 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1901 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1903 $self->{ECHO} ||= 'echo';
1904 $self->{ECHO_N} ||= 'echo -n';
1905 $self->{RM_F} ||= "rm -f";
1906 $self->{RM_RF} ||= "rm -rf";
1907 $self->{TOUCH} ||= "touch";
1908 $self->{TEST_F} ||= "test -f";
1909 $self->{CP} ||= "cp";
1910 $self->{MV} ||= "mv";
1911 $self->{CHMOD} ||= "chmod";
1912 $self->{MKPATH} ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
1913 $self->{EQUALIZE_TIMESTAMP} ||=
1914 '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
1916 $self->{UNINST} ||= 0;
1917 $self->{VERBINST} ||= 0;
1918 $self->{MOD_INSTALL} ||=
1919 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1920 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1922 $self->{DOC_INSTALL} ||=
1923 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
1924 $self->{UNINSTALL} ||=
1925 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
1926 $self->{WARN_IF_OLD_PACKLIST} ||=
1927 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
1929 $self->{UMASK_NULL} ||= "umask 0";
1930 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1939 Called by init_main. Sets up all INST_* variables except those related
1940 to XS code. Those are handled in init_xs.
1947 $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
1948 $self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin');
1950 # INST_LIB typically pre-set if building an extension after
1951 # perl has been built and installed. Setting INST_LIB allows
1952 # you to build directly into, say $Config{privlibexp}.
1953 unless ($self->{INST_LIB}){
1954 if ($self->{PERL_CORE}) {
1955 if (defined $Cross::platform) {
1956 $self->{INST_LIB} = $self->{INST_ARCHLIB} =
1957 $self->catdir($self->{PERL_LIB},"..","xlib",
1961 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
1964 $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
1968 my @parentdir = split(/::/, $self->{PARENT_NAME});
1969 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir);
1970 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir);
1971 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto',
1973 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto',
1976 $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script');
1978 $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1');
1979 $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3');
1988 Called by init_main. Sets up all INSTALL_* variables (except
1989 INSTALLDIRS) and *PREFIX.
1996 $self->init_lib2arch;
1998 # There are often no Config.pm defaults for these new man variables so
1999 # we fall back to the old behavior which is to use installman*dir
2000 foreach my $num (1, 3) {
2001 my $k = 'installsiteman'.$num.'dir';
2003 $self->{uc $k} ||= uc "\$(installman${num}dir)"
2007 foreach my $num (1, 3) {
2008 my $k = 'installvendorman'.$num.'dir';
2010 unless( $Config{$k} ) {
2011 $self->{uc $k} ||= $Config{usevendorprefix}
2012 ? uc "\$(installman${num}dir)"
2017 $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)'
2018 unless $Config{installsitebin};
2020 unless( $Config{installvendorbin} ) {
2021 $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix}
2022 ? $Config{installbin}
2027 my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
2028 $Config{prefixexp} || $Config{prefix} || '';
2029 my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : '';
2030 my $sprefix = $Config{siteprefixexp} || '';
2032 # 5.005_03 doesn't have a siteprefix.
2033 $sprefix = $iprefix unless $sprefix;
2036 $self->{PREFIX} ||= '';
2038 if( $self->{PREFIX} ) {
2039 @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
2043 $self->{PERLPREFIX} ||= $iprefix;
2044 $self->{SITEPREFIX} ||= $sprefix;
2045 $self->{VENDORPREFIX} ||= $vprefix;
2047 # Lots of MM extension authors like to use $(PREFIX) so we
2048 # put something sensible in there no matter what.
2049 $self->{PREFIX} = '$('.uc $self->{INSTALLDIRS}.'PREFIX)';
2052 my $arch = $Config{archname};
2053 my $version = $Config{version};
2056 my $libstyle = $Config{installstyle} || 'lib/perl5';
2059 if( $self->{LIBSTYLE} ) {
2060 $libstyle = $self->{LIBSTYLE};
2061 $manstyle = $self->{LIBSTYLE} eq 'lib/perl5' ? 'lib/perl5' : '';
2064 # Some systems, like VOS, set installman*dir to '' if they can't
2066 for my $num (1, 3) {
2067 $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
2068 unless $Config{'installman'.$num.'dir'};
2073 bin => { s => $iprefix,
2076 vendorbin => { s => $vprefix,
2079 sitebin => { s => $sprefix,
2082 script => { s => $iprefix,
2089 man1dir => { s => $iprefix,
2092 style => $manstyle, },
2093 siteman1dir => { s => $sprefix,
2096 style => $manstyle, },
2097 vendorman1dir => { s => $vprefix,
2100 style => $manstyle, },
2102 man3dir => { s => $iprefix,
2105 style => $manstyle, },
2106 siteman3dir => { s => $sprefix,
2109 style => $manstyle, },
2110 vendorman3dir => { s => $vprefix,
2113 style => $manstyle, },
2118 privlib => { s => $iprefix,
2121 style => $libstyle, },
2122 vendorlib => { s => $vprefix,
2125 style => $libstyle, },
2126 sitelib => { s => $sprefix,
2129 style => $libstyle, },
2131 archlib => { s => $iprefix,
2133 d => "$version/$arch",
2134 style => $libstyle },
2135 vendorarch => { s => $vprefix,
2137 d => "$version/$arch",
2138 style => $libstyle },
2139 sitearch => { s => $sprefix,
2141 d => "site_perl/$version/$arch",
2142 style => $libstyle },
2146 # Special case for LIB.
2147 if( $self->{LIB} ) {
2148 foreach my $var (keys %lib_layouts) {
2149 my $Installvar = uc "install$var";
2151 if( $var =~ /arch/ ) {
2152 $self->{$Installvar} ||=
2153 $self->catdir($self->{LIB}, $Config{archname});
2156 $self->{$Installvar} ||= $self->{LIB};
2161 my %type2prefix = ( perl => 'PERLPREFIX',
2162 site => 'SITEPREFIX',
2163 vendor => 'VENDORPREFIX'
2166 my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
2167 while( my($var, $layout) = each(%layouts) ) {
2168 my($s, $t, $d, $style) = @{$layout}{qw(s t d style)};
2169 my $r = '$('.$type2prefix{$t}.')';
2171 print STDERR "Prefixing $var\n" if $Verbose >= 2;
2173 my $installvar = "install$var";
2174 my $Installvar = uc $installvar;
2175 next if $self->{$Installvar};
2177 $d = "$style/$d" if $style;
2178 $self->prefixify($installvar, $s, $r, $d);
2180 print STDERR " $Installvar == $self->{$Installvar}\n"
2184 # Generate these if they weren't figured out.
2185 $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH};
2186 $self->{VENDORLIBEXP} ||= $self->{INSTALLVENDORLIB};
2193 Unix has no need of special linker flags.
2199 $self->{PERL_ARCHIVE} ||= '';
2200 $self->{PERL_ARCHIVE_AFTER} ||= '';
2201 $self->{EXPORT_LIST} ||= '';
2218 # The user who requests an installation directory explicitly
2219 # should not have to tell us an architecture installation directory
2220 # as well. We look if a directory exists that is named after the
2221 # architecture. If not we take it as a sign that it should be the
2222 # same as the requested installation directory. Otherwise we take
2224 for my $libpair ({l=>"privlib", a=>"archlib"},
2225 {l=>"sitelib", a=>"sitearch"},
2226 {l=>"vendorlib", a=>"vendorarch"},
2229 my $lib = "install$libpair->{l}";
2231 my $Arch = uc "install$libpair->{a}";
2232 if( $self->{$Lib} && ! $self->{$Arch} ){
2233 my($ilib) = $Config{$lib};
2235 $self->prefixify($Arch,$ilib,$self->{$Lib});
2237 unless (-d $self->{$Arch}) {
2238 print STDOUT "Directory $self->{$Arch} not found\n"
2240 $self->{$Arch} = $self->{$Lib};
2242 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
2252 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
2253 *PERLRUN* permutations.
2255 PERL is allowed to be miniperl
2256 FULLPERL must be a complete perl
2258 ABSPERL is PERL converted to an absolute path
2260 *PERLRUN contains everything necessary to run perl, find it's
2263 *PERLRUNINST is *PERLRUN + everything necessary to find the
2264 modules being built.
2272 foreach my $component ($self->{PERL_SRC}, $self->path(),
2275 push @defpath, $component if defined $component;
2278 # Build up a set of file names (not command names).
2279 my $thisperl = $self->canonpath($^X);
2280 $thisperl .= $Config{exe_ext} unless
2281 # VMS might have a file version # at the end
2282 $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
2283 : $thisperl =~ m/$Config{exe_ext}$/i;
2285 # We need a relative path to perl when in the core.
2286 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
2288 my @perls = ($thisperl);
2289 push @perls, map { "$_$Config{exe_ext}" }
2290 ('perl', 'perl5', "perl$Config{version}");
2292 # miniperl has priority over all but the cannonical perl when in the
2293 # core. Otherwise its a last resort.
2294 my $miniperl = "miniperl$Config{exe_ext}";
2295 if( $self->{PERL_CORE} ) {
2296 splice @perls, 1, 0, $miniperl;
2299 push @perls, $miniperl;
2303 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
2304 # don't check if perl is executable, maybe they have decided to
2305 # supply switches with perl
2307 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
2308 my $perl_name = 'perl';
2309 $perl_name = 'ndbgperl' if $Is_VMS &&
2310 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
2312 # XXX This logic is flawed. If "miniperl" is anywhere in the path
2313 # it will get confused. It should be fixed to work only on the filename.
2314 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
2315 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
2316 unless $self->{FULLPERL};
2318 # Little hack to get around VMS's find_perl putting "MCR" in front
2320 $self->{ABSPERL} = $self->{PERL};
2321 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
2322 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
2323 $self->{ABSPERL} = '$(PERL)';
2326 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
2327 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
2330 # Are we building the core?
2331 $self->{PERL_CORE} = 0 unless exists $self->{PERL_CORE};
2333 # How do we run perl?
2334 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
2335 my $run = $perl.'RUN';
2337 $self->{$run} = "\$($perl)";
2339 # Make sure perl can find itself before it's installed.
2340 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
2341 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
2343 $self->{$perl.'RUNINST'} =
2344 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
2351 =item init_platform (o)
2353 Add MM_Unix_VERSION.
2355 =item platform_constants (o)
2362 $self->{MM_Unix_VERSION} = $VERSION;
2363 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2364 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2365 '-Dcalloc=Perl_calloc';
2369 sub platform_constants {
2373 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2375 next unless defined $self->{$macro};
2376 $make_frag .= "$macro = $self->{$macro}\n";
2387 Called by init_main. Initializes PERL_*
2394 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2395 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2405 Sets up macros having to do with XS code. Currently just INST_STATIC,
2406 INST_DYNAMIC and INST_BOOT.
2413 if ($self->has_link_code()) {
2414 $self->{INST_STATIC} =
2415 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2416 $self->{INST_DYNAMIC} =
2417 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2418 $self->{INST_BOOT} =
2419 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2421 $self->{INST_STATIC} = '';
2422 $self->{INST_DYNAMIC} = '';
2423 $self->{INST_BOOT} = '';
2429 Defines the install target.
2434 my($self, %attribs) = @_;
2438 install :: all pure_install doc_install
2440 install_perl :: all pure_perl_install doc_perl_install
2442 install_site :: all pure_site_install doc_site_install
2444 install_vendor :: all pure_vendor_install doc_vendor_install
2446 pure_install :: pure_$(INSTALLDIRS)_install
2448 doc_install :: doc_$(INSTALLDIRS)_install
2450 pure__install : pure_site_install
2451 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2453 doc__install : doc_site_install
2454 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2456 pure_perl_install ::
2457 $(NOECHO) $(MOD_INSTALL) \
2458 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2459 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2460 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2461 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2462 $(INST_BIN) $(DESTINSTALLBIN) \
2463 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2464 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2465 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2466 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2467 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2470 pure_site_install ::
2471 $(NOECHO) $(MOD_INSTALL) \
2472 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2473 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2474 $(INST_LIB) $(DESTINSTALLSITELIB) \
2475 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2476 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2477 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2478 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2479 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2480 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2481 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2483 pure_vendor_install ::
2484 $(NOECHO) $(MOD_INSTALL) \
2485 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2486 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2487 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2488 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2489 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2490 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2491 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2492 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2495 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2496 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2497 -$(NOECHO) $(DOC_INSTALL) \
2498 "Module" "$(NAME)" \
2499 "installed into" "$(INSTALLPRIVLIB)" \
2500 LINKTYPE "$(LINKTYPE)" \
2501 VERSION "$(VERSION)" \
2502 EXE_FILES "$(EXE_FILES)" \
2503 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2506 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2507 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2508 -$(NOECHO) $(DOC_INSTALL) \
2509 "Module" "$(NAME)" \
2510 "installed into" "$(INSTALLSITELIB)" \
2511 LINKTYPE "$(LINKTYPE)" \
2512 VERSION "$(VERSION)" \
2513 EXE_FILES "$(EXE_FILES)" \
2514 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2516 doc_vendor_install ::
2517 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2518 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2519 -$(NOECHO) $(DOC_INSTALL) \
2520 "Module" "$(NAME)" \
2521 "installed into" "$(INSTALLVENDORLIB)" \
2522 LINKTYPE "$(LINKTYPE)" \
2523 VERSION "$(VERSION)" \
2524 EXE_FILES "$(EXE_FILES)" \
2525 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2530 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2532 uninstall_from_perldirs ::
2533 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2535 uninstall_from_sitedirs ::
2536 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2538 uninstall_from_vendordirs ::
2539 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2545 =item installbin (o)
2547 Defines targets to make and to install EXE_FILES.
2553 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2554 return "" unless @{$self->{EXE_FILES}};
2555 my(@m, $from, $to, %fromto, @to);
2556 for $from (@{$self->{EXE_FILES}}) {
2557 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2558 local($_) = $path; # for backwards compatibility
2559 $to = $self->libscan($path);
2560 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2563 @to = values %fromto;
2567 $fixin = $self->{PERL_CORE} ? '$(PERLRUN) ../../win32/bin/pl2bat.pl'
2571 $fixin = q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
2575 EXE_FILES = @{$self->{EXE_FILES}}
2586 while (($from,$to) = each %fromto) {
2587 last unless defined $from;
2588 my $todir = dirname($to);
2590 $to : $from \$(FIRST_MAKEFILE) blibdirs.ts
2591 \$(NOECHO) \$(RM_F) $to
2594 -\$(NOECHO) \$(CHMOD) \$(PERM_RWX) $to
2603 Defines the linkext target which in turn defines the LINKTYPE.
2608 my($self, %attribs) = @_;
2609 # LINKTYPE => static or dynamic or ''
2610 my($linktype) = defined $attribs{LINKTYPE} ?
2611 $attribs{LINKTYPE} : '$(LINKTYPE)';
2613 linkext :: $linktype
2620 Takes as arguments a directory name and a regular expression. Returns
2621 all entries in the directory that match the regular expression.
2627 my($dir, $regex) = @_;
2629 my $dh = new DirHandle;
2630 $dh->open($dir || ".") or return ();
2633 @ls = grep(/$regex/, @ls) if $regex;
2639 Simple subroutine to insert the macros defined by the macro attribute
2645 my($self,%attribs) = @_;
2647 while (($key,$val) = each %attribs){
2648 last unless defined $key;
2649 push @m, "$key = $val\n";
2656 Called by staticmake. Defines how to write the Makefile to produce a
2659 By default the Makefile produced includes all the static extensions in
2660 the perl library. (Purified versions of library files, e.g.,
2661 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2666 my($self, %attribs) = @_;
2667 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2668 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2671 # --- MakeMaker makeaperl section ---
2672 MAP_TARGET = $target
2673 FULLPERL = $self->{FULLPERL}
2675 return join '', @m if $self->{PARENT};
2677 my($dir) = join ":", @{$self->{DIR}};
2679 unless ($self->{MAKEAPERL}) {
2681 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2682 $(MAKE) -f $(MAKE_APERL_FILE) $@
2684 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2685 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2686 $(NOECHO) $(PERLRUNINST) \
2687 Makefile.PL DIR=}, $dir, q{ \
2688 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2689 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2695 push @m, " \\\n\t\t$_";
2697 # push @m, map( " \\\n\t\t$_", @ARGV );
2705 my($cccmd, $linkcmd, $lperl);
2708 $cccmd = $self->const_cccmd($libperl);
2709 $cccmd =~ s/^CCCMD\s*=\s*//;
2710 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2711 $cccmd .= " $Config{cccdlflags}"
2712 if ($Config{useshrplib} eq 'true');
2713 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2715 # The front matter of the linkcommand...
2716 $linkcmd = join ' ', "\$(CC)",
2717 grep($_, @Config{qw(ldflags ccdlflags)});
2718 $linkcmd =~ s/\s+/ /g;
2719 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2721 # Which *.a files could we make use of...
2724 File::Find::find(sub {
2725 return unless m/\Q$self->{LIB_EXT}\E$/;
2727 # Skip perl's libraries.
2728 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2730 # Skip purified versions of libraries
2731 # (e.g., DynaLoader_pure_p1_c0_032.a)
2732 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2734 if( exists $self->{INCLUDE_EXT} ){
2739 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2743 # Throw away anything not explicitly marked for inclusion.
2744 # DynaLoader is implied.
2745 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2751 return unless $found;
2753 elsif( exists $self->{EXCLUDE_EXT} ){
2757 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2761 # Throw away anything explicitly marked for exclusion
2762 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2763 return if( $xx eq $excl );
2767 # don't include the installed version of this extension. I
2768 # leave this line here, although it is not necessary anymore:
2769 # I patched minimod.PL instead, so that Miniperl.pm won't
2770 # enclude duplicates
2772 # Once the patch to minimod.PL is in the distribution, I can
2774 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2776 $static{cwd() . "/" . $_}++;
2777 }, grep( -d $_, @{$searchdirs || []}) );
2779 # We trust that what has been handed in as argument, will be buildable
2780 $static = [] unless $static;
2781 @static{@{$static}} = (1) x @{$static};
2783 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2784 for (sort keys %static) {
2785 next unless /\Q$self->{LIB_EXT}\E\z/;
2786 $_ = dirname($_) . "/extralibs.ld";
2790 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
2795 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2796 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2797 # extralibs.all are computed correctly
2799 MAP_LINKCMD = $linkcmd
2800 MAP_PERLINC = @{$perlinc || []}
2802 join(" \\\n\t", reverse sort keys %static), "
2804 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2807 if (defined $libperl) {
2808 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2810 unless ($libperl && -f $lperl) { # Ilya's code...
2811 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2812 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2813 $libperl ||= "libperl$self->{LIB_EXT}";
2814 $libperl = "$dir/$libperl";
2815 $lperl ||= "libperl$self->{LIB_EXT}";
2816 $lperl = "$dir/$lperl";
2818 if (! -f $libperl and ! -f $lperl) {
2819 # We did not find a static libperl. Maybe there is a shared one?
2821 $lperl = $libperl = "$dir/$Config{libperl}";
2822 # SUNOS ld does not take the full path to a shared library
2823 $libperl = '' if $Is_SunOS4;
2827 print STDOUT "Warning: $libperl not found
2828 If you're going to build a static perl binary, make sure perl is installed
2829 otherwise ignore this warning\n"
2830 unless (-f $lperl || defined($self->{PERL_SRC}));
2833 # SUNOS ld does not take the full path to a shared library
2834 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2837 MAP_LIBPERL = $libperl
2838 LLIBPERL = $llibperl
2842 \$(INST_ARCHAUTODIR)/extralibs.all: blibdirs.ts ".join(" \\\n\t", @$extra).'
2843 $(NOECHO) $(RM_F) $@
2844 $(NOECHO) $(TOUCH) $@
2848 foreach $catfile (@$extra){
2849 push @m, "\tcat $catfile >> \$\@\n";
2853 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2854 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2855 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2856 \$(NOECHO) \$(ECHO) ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2857 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2858 \$(NOECHO) \$(ECHO) ' make -f $makefilename map_clean'
2860 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2862 push @m, qq{\tcd $tmp && $cccmd "-I\$(PERL_INC)" perlmain.c\n};
2865 $tmp/perlmain.c: $makefilename}, q{
2866 $(NOECHO) $(ECHO) Writing $@
2867 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2868 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2871 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2872 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2877 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2878 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2879 -$(NOECHO) $(DOC_INSTALL) \
2880 "Perl binary" "$(MAP_TARGET)" \
2881 MAP_STATIC "$(MAP_STATIC)" \
2882 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2883 MAP_LIBPERL "$(MAP_LIBPERL)" \
2884 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2889 inst_perl: pure_inst_perl doc_inst_perl
2891 pure_inst_perl: $(MAP_TARGET)
2892 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2897 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2905 Defines how to rewrite the Makefile.
2912 # We do not know what target was originally specified so we
2913 # must force a manual rerun to be sure. But as it should only
2914 # happen very rarely it is not a significant problem.
2916 $(OBJECT) : $(FIRST_MAKEFILE)
2917 ' if $self->{OBJECT};
2920 # We take a very conservative approach here, but it's worth it.
2921 # We move Makefile to Makefile.old here to avoid gnu make looping.
2922 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2923 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?"
2924 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2925 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2926 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2927 -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP)
2928 $(PERLRUN) Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{
2929 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2930 $(NOECHO) $(ECHO) "==> Please rerun the make command. <=="
2941 Returns true, if the argument is likely to be a command.
2946 my($self,$file) = @_;
2947 return $file if -x $file && ! -d $file;
2952 =item needs_linking (o)
2954 Does this module need linking? Looks into subdirectory objects (see
2955 also has_link_code())
2962 $caller = (caller(0))[3];
2963 confess("needs_linking called too early") if
2964 $caller =~ /^ExtUtils::MakeMaker::/;
2965 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2966 if ($self->has_link_code or $self->{MAKEAPERL}){
2967 $self->{NEEDS_LINKING} = 1;
2970 foreach $child (keys %{$self->{CHILDREN}}) {
2971 if ($self->{CHILDREN}->{$child}->needs_linking) {
2972 $self->{NEEDS_LINKING} = 1;
2976 return $self->{NEEDS_LINKING} = 0;
2981 misnamed method (will have to be changed). The MM_Unix method just
2982 returns the argument without further processing.
2984 On VMS used to insure that colons marking targets are preceded by
2985 space - most Unix Makes don't need this, but it's necessary under VMS
2986 to distinguish the target delimiter from a colon appearing as part of
2992 my($self,$text) = @_;
2996 =item parse_abstract
2998 parse a file and return what you think is the ABSTRACT
3002 sub parse_abstract {
3003 my($self,$parsefile) = @_;
3007 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
3009 my $package = $self->{DISTNAME};
3010 $package =~ s/-/::/g;
3012 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
3015 next unless /^($package\s-\s)(.*)/;
3025 parse a file and return what you think is $VERSION in this file set to.
3026 It will return the string "undef" if it can't figure out what $VERSION
3027 is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
3028 are okay, but my $VERSION is not.
3033 my($self,$parsefile) = @_;
3038 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
3041 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
3042 next if $inpod || /^\s*#/;
3044 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
3046 package ExtUtils::MakeMaker::_version;
3055 $result = eval($eval);
3056 warn "Could not eval '$eval' in $parsefile: $@" if $@;
3061 $result = "undef" unless defined $result;
3068 Defines the string that is passed to recursive make calls in
3078 my($sep) = $Is_VMS ? ',' : '';
3081 foreach $key (qw(LIB LIBPERL_A LINKTYPE PREFIX OPTIMIZE)) {
3082 next unless defined $self->{$key};
3083 push @pasthru, "$key=\"\$($key)\"";
3086 foreach $key (qw(DEFINE INC)) {
3087 next unless defined $self->{$key};
3088 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
3091 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
3097 Takes one argument, a file name, and returns the file name, if the
3098 argument is likely to be a perl script. On MM_Unix this is true for
3099 any ordinary, readable file.
3104 my($self,$file) = @_;
3105 return $file if -r $file && -f _;
3109 =item perldepend (o)
3111 Defines the dependency from all *.h files that come with the perl
3120 # Check for unpropogated config.sh changes. Should never happen.
3121 # We do NOT just update config.h because that is not sufficient.
3122 # An out of date config.h is not fatal but complains loudly!
3123 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
3124 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
3126 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
3127 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
3128 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
3129 } if $self->{PERL_SRC};
3131 return join "", @m unless $self->needs_linking;
3135 $(PERL_INC)/EXTERN.h \
3136 $(PERL_INC)/INTERN.h \
3137 $(PERL_INC)/XSUB.h \
3139 $(PERL_INC)/cc_runtime.h \
3140 $(PERL_INC)/config.h \
3143 $(PERL_INC)/dosish.h \
3144 $(PERL_INC)/embed.h \
3145 $(PERL_INC)/embedvar.h \
3146 $(PERL_INC)/fakethr.h \
3147 $(PERL_INC)/form.h \
3149 $(PERL_INC)/handy.h \
3151 $(PERL_INC)/intrpvar.h \
3152 $(PERL_INC)/iperlsys.h \
3153 $(PERL_INC)/keywords.h \
3155 $(PERL_INC)/nostdio.h \
3157 $(PERL_INC)/opcode.h \
3158 $(PERL_INC)/patchlevel.h \
3159 $(PERL_INC)/perl.h \
3160 $(PERL_INC)/perlio.h \
3161 $(PERL_INC)/perlsdio.h \
3162 $(PERL_INC)/perlsfio.h \
3163 $(PERL_INC)/perlvars.h \
3164 $(PERL_INC)/perly.h \
3166 $(PERL_INC)/pp_proto.h \
3167 $(PERL_INC)/proto.h \
3168 $(PERL_INC)/regcomp.h \
3169 $(PERL_INC)/regexp.h \
3170 $(PERL_INC)/regnodes.h \
3171 $(PERL_INC)/scope.h \
3173 $(PERL_INC)/thrdvar.h \
3174 $(PERL_INC)/thread.h \
3175 $(PERL_INC)/unixish.h \
3178 $(OBJECT) : $(PERL_HDRS)
3179 } if $self->{OBJECT};
3181 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
3189 Returns the attribute C<PERM_RW> or the string C<644>.
3190 Used as the string that is passed
3191 to the C<chmod> command to set the permissions for read/writeable files.
3192 MakeMaker chooses C<644> because it has turned out in the past that
3193 relying on the umask provokes hard-to-track bug reports.
3194 When the return value is used by the perl function C<chmod>, it is
3195 interpreted as an octal value.
3200 return shift->{PERM_RW};
3205 Returns the attribute C<PERM_RWX> or the string C<755>,
3206 i.e. the string that is passed
3207 to the C<chmod> command to set the permissions for executable files.
3213 return shift->{PERM_RWX};
3218 Defines target that copies all files in the hash PM to their
3219 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
3225 my($autodir) = $self->catdir('$(INST_LIB)','auto');
3227 # For backwards compat with anything that referenced this target.
3228 pm_to_blib: pm_to_blib.ts
3231 pm_to_blib.ts: $(TO_INST_PM)
3234 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
3235 pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
3238 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
3240 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
3241 $r .= q{ $(NOECHO) $(TOUCH) $@};
3246 =item post_constants (o)
3248 Returns an empty string per default. Dedicated to overrides from
3249 within Makefile.PL after all constants have been defined.
3257 =item post_initialize (o)
3259 Returns an empty string per default. Used in Makefile.PLs to add some
3260 chunk of text to the Makefile after the object is initialized.
3264 sub post_initialize {
3270 Returns an empty string. Can be used in Makefile.PLs to write some
3271 text to the Makefile at the end.
3281 Defines target that creates a PPD (Perl Package Description) file
3282 for a binary distribution.
3289 if ($self->{ABSTRACT_FROM}){
3290 $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
3291 carp "WARNING: Setting ABSTRACT via file ".
3292 "'$self->{ABSTRACT_FROM}' failed\n";
3295 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
3297 my $abstract = $self->{ABSTRACT} || '';
3298 $abstract =~ s/\n/\\n/sg;
3299 $abstract =~ s/</</g;
3300 $abstract =~ s/>/>/g;
3302 my $author = $self->{AUTHOR} || '';
3303 $author =~ s/</</g;
3304 $author =~ s/>/>/g;
3306 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
3307 <SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
3308 <TITLE>$(DISTNAME)</TITLE>
3309 <ABSTRACT>%s</ABSTRACT>
3313 $ppd_xml .= " <IMPLEMENTATION>\n";
3314 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
3315 my $pre_req = $prereq;
3316 $pre_req =~ s/::/-/g;
3317 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
3319 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
3320 <DEPENDENCY NAME="%s" VERSION="%s" />
3325 $ppd_xml .= sprintf <<'PPD_OUT', $Config{archname};
3326 <OS NAME="$(OSNAME)" />
3327 <ARCHITECTURE NAME="%s" />
3330 if ($self->{PPM_INSTALL_SCRIPT}) {
3331 if ($self->{PPM_INSTALL_EXEC}) {
3332 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
3333 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
3336 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
3337 $self->{PPM_INSTALL_SCRIPT};
3341 my ($bin_location) = $self->{BINARY_LOCATION} || '';
3342 $bin_location =~ s/\\/\\\\/g;
3344 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
3345 <CODEBASE HREF="%s" />
3350 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
3352 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3353 # Creates a PPD (Perl Package Description) for a binary distribution.
3362 $MM->prefixify($var, $prefix, $new_prefix, $default);
3364 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3365 replace it's $prefix with a $new_prefix.
3367 Should the $prefix fail to match I<AND> a PREFIX was given as an
3368 argument to WriteMakefile() it will set it to the $new_prefix +
3369 $default. This is for systems whose file layouts don't neatly fit into
3370 our ideas of prefixes.
3372 This is for heuristics which attempt to create directory structures
3373 that mirror those of the installed perl.
3377 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3379 this will attempt to remove '/usr' from the front of the
3380 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3381 if necessary) and replace it with '/home/foo'. If this fails it will
3382 simply use '/home/foo/man/man1'.
3387 my($self,$var,$sprefix,$rprefix,$default) = @_;
3389 my $path = $self->{uc $var} ||
3390 $Config_Override{lc $var} || $Config{lc $var} || '';
3392 $rprefix .= '/' if $sprefix =~ m|/$|;
3394 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3395 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
3397 if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) &&
3398 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3401 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3402 print STDERR " no default!\n" if !$default && $Verbose >= 2;
3404 $path = $self->catdir($rprefix, $default) if $default;
3407 print " now $path\n" if $Verbose >= 2;
3408 return $self->{uc $var} = $path;
3414 Defines targets to run *.PL files.
3420 return "" unless $self->{PL_FILES};
3422 foreach $plfile (sort keys %{$self->{PL_FILES}}) {
3423 my $list = ref($self->{PL_FILES}->{$plfile})
3424 ? $self->{PL_FILES}->{$plfile}
3425 : [$self->{PL_FILES}->{$plfile}];
3427 foreach $target (@$list) {
3433 \$(PERLRUNINST) $plfile $target
3442 Backslashes parentheses C<()> in command line arguments.
3443 Doesn't handle recursive Makefile C<$(...)> constructs,
3444 but handles simple ones.
3450 $arg =~ s/\$\((.+?)\)/\$\\\\($1\\\\)/g; # protect $(...)
3451 $arg =~ s/(?<!\\)([()])/\\$1/g; # quote unprotected
3452 $arg =~ s/\$\\\\\((.+?)\\\\\)/\$($1)/g; # unprotect $(...)
3458 Defines the realclean target.
3463 my($self, %attribs) = @_;
3467 # Delete temporary files (via clean) and also delete installed files
3468 realclean purge :: clean realclean_subdirs
3469 $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
3470 $(RM_RF) $(DISTVNAME)
3473 if( $self->has_link_code ){
3474 push(@m, " \$(RM_F) \$(INST_DYNAMIC) \$(INST_BOOT)\n");
3475 push(@m, " \$(RM_F) \$(INST_STATIC)\n");
3478 my @files = values %{$self->{PM}};
3479 push @files, $attribs{FILES} if $attribs{FILES};
3480 push @files, '$(FIRST_MAKEFILE)', '$(MAKEFILE_OLD)';
3482 # Occasionally files are repeated several times from different sources
3483 { my(%f) = map { ($_,1) } @files; @files = keys %f; }
3485 # Issue a several little RM_RF commands rather than risk creating a
3486 # very long command line (useful for extensions such as Encode
3487 # that have many files).
3489 foreach my $file (@files) {
3490 if (length($line) + length($file) > 200) {
3491 push @m, "\t\$(RM_RF) $line\n";
3498 push @m, "\t\$(RM_RF) $line\n" if $line;
3499 push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
3505 =item realclean_subdirs_target
3507 my $make_frag = $MM->realclean_subdirs_target;
3509 Returns the realclean_subdirs target. This is used by the realclean
3510 target to call realclean on any subdirectories which contain Makefiles.
3514 sub realclean_subdirs_target {
3517 return <<'NOOP_FRAG' unless @{$self->{DIR}};
3522 my $rclean = "realclean_subdirs :\n";
3524 foreach my $dir (@{$self->{DIR}}){
3525 $rclean .= sprintf <<'RCLEAN', $dir, $dir;
3526 -cd %s && $(TEST_F) $(MAKEFILE_OLD) && $(MAKE) -f $(MAKEFILE_OLD) realclean
3527 -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) realclean
3536 =item replace_manpage_separator
3538 my $man_name = $MM->replace_manpage_separator($file_path);
3540 Takes the name of a package, which may be a nested package, in the
3541 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3542 safe for a man page file name. Returns the replacement.
3546 sub replace_manpage_separator {
3547 my($self,$man) = @_;
3559 my($self, $cmd, $switches) = @_;
3560 $switches = [] unless defined $switches;
3562 # Strip leading and trailing newlines
3566 my @cmds = split /\n/, $cmd;
3567 $cmd = join " \n\t-e ", map $self->quote_literal($_), @cmds;
3568 $cmd = $self->escape_newlines($cmd);
3570 $switches = join ' ', @$switches;
3572 return qq{\$(ABSPERLRUN) $switches -e $cmd};
3581 my($self, $text) = @_;
3583 # I think all we have to quote is single quotes and I think
3584 # this is a safe way to do it.
3585 $text =~ s{'}{'\\''}g;
3591 =item escape_newlines
3595 sub escape_newlines {
3596 my($self, $text) = @_;
3598 $text =~ s{\n}{\\\n}g;
3606 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3613 if (!defined $self->{_MAX_EXEC_LEN}) {
3614 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3615 $self->{_MAX_EXEC_LEN} = $arg_max;
3617 else { # POSIX minimum exec size
3618 $self->{_MAX_EXEC_LEN} = 4096;
3622 return $self->{_MAX_EXEC_LEN};
3628 Defines the static target.
3633 # --- Static Loading Sections ---
3637 ## $(INST_PM) has been moved to the all: target.
3638 ## It remains here for awhile to allow for old usage: "make static"
3639 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3644 =item static_lib (o)
3646 Defines how to produce the *.a (or equivalent) files.
3652 return '' unless $self->has_link_code;
3657 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) blibdirs.ts
3661 # If this extension has its own library (eg SDBM_File)
3662 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3663 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3664 $(CP) $(MYEXTLIB) $@
3668 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3669 # Prefer the absolute pathed ar if available so that PATH
3670 # doesn't confuse us. Perl itself is built with the full_ar.
3675 push @m, sprintf <<'MAKE_FRAG', $ar;
3676 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3677 $(CHMOD) $(PERM_RWX) $@
3678 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3681 # Old mechanism - still available:
3682 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3683 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3689 =item staticmake (o)
3696 my($self, %attribs) = @_;
3699 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3701 # And as it's not yet built, we add the current extension
3702 # but only if it has some C code (or XS code, which implies C code)
3703 if (@{$self->{C}}) {
3704 @static = $self->catfile($self->{INST_ARCHLIB},
3707 "$self->{BASEEXT}$self->{LIB_EXT}"
3711 # Either we determine now, which libraries we will produce in the
3712 # subdirectories or we do it at runtime of the make.
3714 # We could ask all subdir objects, but I cannot imagine, why it
3715 # would be necessary.
3717 # Instead we determine all libraries for the new perl at
3719 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3721 $self->makeaperl(MAKE => $self->{MAKEFILE},
3722 DIRS => \@searchdirs,
3725 TARGET => $self->{MAP_TARGET},
3727 LIBPERL => $self->{LIBPERL_A}
3733 Helper subroutine for subdirs
3738 my($self, $subdir) = @_;
3739 return sprintf <<'EOT', $subdir;
3742 $(NOECHO)cd %s && $(MAKE) -f $(FIRST_MAKEFILE) all $(PASTHRU)
3748 Defines targets to process subdirectories.
3753 # --- Sub-directory Sections ---
3756 # This method provides a mechanism to automatically deal with
3757 # subdirectories containing further Makefile.PL scripts.
3758 # It calls the subdir_x() method for each subdirectory.
3759 foreach $dir (@{$self->{DIR}}){
3760 push(@m, $self->subdir_x($dir));
3761 #### print "Including $dir subdirectory\n";
3765 # The default clean, realclean and test targets in this Makefile
3766 # have automatically been given entries for each subdir.
3770 push(@m, "\n# none")
3777 Defines the test targets.
3782 # --- Test and Installation Sections ---
3784 my($self, %attribs) = @_;
3785 my $tests = $attribs{TESTS} || '';
3786 if (!$tests && -d 't') {
3787 $tests = $self->find_tests;
3789 # note: 'test.pl' name is also hardcoded in init_dirscan()
3793 TEST_TYPE=test_\$(LINKTYPE)
3798 testdb :: testdb_\$(LINKTYPE)
3800 test :: \$(TEST_TYPE)
3804 push(@m, map(qq{\t\$(NOECHO) \$(PERLRUN) -e "exit unless -f shift; chdir '$_'; system q[\$(MAKE) test \$(PASTHRU)]" \$(FIRST_MAKEFILE)\n}, @{$self->{DIR}}));
3807 push(@m, map("\t\$(NOECHO) cd $_ && \$(TEST_F) \$(FIRST_MAKEFILE) && \$(MAKE) test \$(PASTHRU)\n", @{$self->{DIR}}));
3810 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3811 unless $tests or -f "test.pl" or @{$self->{DIR}};
3814 push(@m, "test_dynamic :: pure_all\n");
3815 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3817 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3821 push(@m, "testdb_dynamic :: pure_all\n");
3822 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3826 # Occasionally we may face this degenerate target:
3827 push @m, "test_ : test_dynamic\n\n";
3829 if ($self->needs_linking()) {
3830 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3831 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3832 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3834 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3835 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3838 push @m, "test_static :: test_dynamic\n";
3839 push @m, "testdb_static :: testdb_dynamic\n";
3844 =item test_via_harness (override)
3846 For some reason which I forget, Unix machines like to have
3847 PERL_DL_NONLAZY set for tests.
3851 sub test_via_harness {
3852 my($self, $perl, $tests) = @_;
3853 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3856 =item test_via_script (override)
3858 Again, the PERL_DL_NONLAZY thing.
3862 sub test_via_script {
3863 my($self, $perl, $script) = @_;
3864 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3868 =item tools_other (o)
3870 my $make_frag = $MM->tools_other;
3872 Returns a make fragment containing definitions for:
3874 SHELL, CHMOD, CP, MV, NOOP, NOECHO, RM_F, RM_RF, TEST_F, TOUCH,
3875 DEV_NULL, UMASK_NULL, MKPATH, EQUALIZE_TIMESTAMP,
3876 WARN_IF_OLD_PACKLIST, UNINST, VERBINST, MOD_INSTALL, DOC_INSTALL and
3879 init_others() initializes all these values.
3887 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
3888 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
3891 MOD_INSTALL DOC_INSTALL UNINSTALL
3892 WARN_IF_OLD_PACKLIST
3895 next unless defined $self->{$tool};
3896 push @m, "$tool = $self->{$tool}\n";
3902 =item tool_xsubpp (o)
3904 Determines typemaps, xsubpp version, prototype behaviour.
3910 return "" unless $self->needs_linking;
3913 my @xsubpp_dirs = @INC;
3915 # Make sure we pick up the new xsubpp if we're building perl.
3916 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3918 foreach my $dir (@xsubpp_dirs) {
3919 $xsdir = $self->catdir($dir, 'ExtUtils');
3920 if( -r $self->catfile($xsdir, "xsubpp") ) {
3925 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3926 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3927 if( $self->{TYPEMAPS} ){
3929 foreach $typemap (@{$self->{TYPEMAPS}}){
3930 if( ! -f $typemap ){
3931 warn "Typemap $typemap not found.\n";
3934 push(@tmdeps, $typemap);
3938 push(@tmdeps, "typemap") if -f "typemap";
3939 my(@tmargs) = map("-typemap $_", @tmdeps);
3940 if( exists $self->{XSOPT} ){
3941 unshift( @tmargs, $self->{XSOPT} );
3945 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3949 XSUBPP = \$(XSUBPPDIR)/xsubpp
3950 XSPROTOARG = $self->{XSPROTOARG}
3951 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3952 XSUBPPARGS = @tmargs
3960 Build man pages, too
3967 return <<'MAKE_EXT';
3968 all :: pure_all manifypods
3973 =item top_targets (o)
3975 Defines the targets all, subdirs, config, and O_FILES
3980 # --- Target Sections ---
3985 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3988 pure_all :: config pm_to_blib.ts subdirs linkext
3991 subdirs :: $(MYEXTLIB)
3994 config :: $(FIRST_MAKEFILE) blibdirs.ts
3999 $(O_FILES): $(H_FILES)
4000 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
4004 perldoc ExtUtils::MakeMaker
4012 Obsolete, deprecated method. Not used since Version 5.21.
4017 # --- perllocal.pod section ---
4018 my($self,$what,$name,@attribs)=@_;
4019 my $time = localtime;
4020 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
4021 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
4022 print "\n\n=back\n\n";
4027 Defines the suffix rules to compile XS files to C.
4033 return '' unless $self->needs_linking();
4036 $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
4042 Defines the suffix rules to compile XS files to C++.
4048 return '' unless $self->needs_linking();
4051 $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
4057 Defines suffix rules to go from XS to object files directly. This is
4058 only intended for broken make implementations.
4062 sub xs_o { # many makes are too dumb to use xs_c then c_o
4064 return '' unless $self->needs_linking();
4067 $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
4068 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
4079 L<ExtUtils::MakeMaker>