1 package ExtUtils::MM_Unix;
8 use ExtUtils::MakeMaker::Config;
9 use File::Basename qw(basename dirname);
14 use ExtUtils::MakeMaker qw($Verbose neatvalue);
16 # If we make $VERSION an our variable parse_version() breaks
17 use vars qw($VERSION);
19 $VERSION = eval $VERSION; ## no critic [BuiltinFunctions::ProhibitStringyEval]
21 require ExtUtils::MM_Any;
22 our @ISA = qw(ExtUtils::MM_Any);
26 $Is{OS2} = $^O eq 'os2';
27 $Is{Win32} = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
28 $Is{Dos} = $^O eq 'dos';
29 $Is{VMS} = $^O eq 'VMS';
30 $Is{OSF} = $^O eq 'dec_osf';
31 $Is{IRIX} = $^O eq 'irix';
32 $Is{NetBSD} = $^O eq 'netbsd';
33 $Is{Interix} = $^O eq 'interix';
34 $Is{SunOS4} = $^O eq 'sunos';
35 $Is{Solaris} = $^O eq 'solaris';
36 $Is{SunOS} = $Is{SunOS4} || $Is{Solaris};
37 $Is{BSD} = ($^O =~ /^(?:free|net|open)bsd$/ or
38 grep( $^O eq $_, qw(bsdos interix dragonfly) )
40 $Is{Android} = $^O =~ /android/;
45 # For things like vmsify()
46 require VMS::Filespec;
47 VMS::Filespec->import;
54 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
58 C<require ExtUtils::MM_Unix;>
62 The methods provided by this package are designed to be used in
63 conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
64 Makefile, it creates one or more objects that inherit their methods
65 from a package C<MM>. MM itself doesn't provide any methods, but it
66 ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
67 specific packages take the responsibility for all the methods provided
68 by MM_Unix. We are trying to reduce the number of the necessary
69 overrides by defining rather primitive operations within
72 If you are going to write a platform specific MM package, please try
73 to limit the necessary overrides to primitive methods, and if it is not
74 possible to do so, let's work out how to achieve that gain.
76 If you are overriding any of these methods in your Makefile.PL (in the
77 MY class), please report that to the makemaker mailing list. We are
78 trying to minimize the necessary method overrides and switch to data
79 driven Makefile.PLs wherever possible. In the long run less methods
80 will be overridable via the MY class.
84 The following description of methods is still under
85 development. Please refer to the code for not suitably documented
86 sections and complain loudly to the makemaker@perl.org mailing list.
87 Better yet, provide a patch.
89 Not all of the methods below are overridable in a
90 Makefile.PL. Overridable methods are marked as (o). All methods are
91 overridable by a platform specific MM_*.pm file.
93 Cross-platform methods are being moved into MM_Any. If you can't find
94 something that used to be in here, look in MM_Any.
98 # So we don't have to keep calling the methods over and over again,
99 # we have these globals to cache the values. Faster and shrtr.
100 my $Curdir = __PACKAGE__->curdir;
101 my $Rootdir = __PACKAGE__->rootdir;
102 my $Updir = __PACKAGE__->updir;
111 Simply says that we're Unix.
122 Defines the suffix rules to compile different flavors of C files to
128 # --- Translation Sections ---
131 return '' unless $self->needs_linking();
134 my $command = '$(CCCMD)';
135 my $flags = '$(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE)';
137 if (my $cpp = $Config{cpprun}) {
138 my $cpp_cmd = $self->const_cccmd;
139 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/;
142 $cpp_cmd $flags \$*.c > \$*.i
148 $command -S $flags \$*.c
151 $command $flags \$*.c
154 $command $flags \$*.cpp
157 $command $flags \$*.cxx
160 $command $flags \$*.cc
165 $command $flags \$*.C
166 } if !$Is{OS2} and !$Is{Win32} and !$Is{Dos}; #Case-specific
173 Does very much the same as the cflags script in the perl
174 distribution. It doesn't return the whole compiler command line, but
175 initializes all of its parts. The const_cccmd method then actually
176 returns the definition of the CCCMD macro which uses these parts.
183 my($self,$libperl)=@_;
184 return $self->{CFLAGS} if $self->{CFLAGS};
185 return '' unless $self->needs_linking();
187 my($prog, $uc, $perltype, %cflags);
188 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
189 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
191 @cflags{qw(cc ccflags optimize shellflags)}
192 = @Config{qw(cc ccflags optimize shellflags)};
195 $cflags{shellflags} ||= '';
200 DE => '-DDEBUGGING -DEMBED',
201 M => '-DEMBED -DMULTIPLICITY',
202 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
205 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
208 $uc = ""; # avoid warning
210 $perltype = $map{$uc} ? $map{$uc} : "";
218 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
219 if ($prog = $Config{$name}) {
220 # Expand hints for this extension via the shell
221 print "Processing $name hint:\n" if $Verbose;
222 my(@o)=`cc=\"$cflags{cc}\"
223 ccflags=\"$cflags{ccflags}\"
224 optimize=\"$cflags{optimize}\"
225 perltype=\"$cflags{perltype}\"
226 optdebug=\"$cflags{optdebug}\"
229 echo ccflags=\$ccflags
230 echo optimize=\$optimize
231 echo perltype=\$perltype
232 echo optdebug=\$optdebug
234 foreach my $line (@o){
236 if ($line =~ /(.*?)=\s*(.*)\s*$/){
238 print " $1 = $2\n" if $Verbose;
240 print "Unrecognised result from hint: '$line'\n";
246 $cflags{optimize} = $optdebug;
249 for (qw(ccflags optimize perltype)) {
251 $cflags{$_} =~ s/^\s+//;
252 $cflags{$_} =~ s/\s+/ /g;
253 $cflags{$_} =~ s/\s+$//;
254 $self->{uc $_} ||= $cflags{$_};
257 if ($self->{POLLUTE}) {
258 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
262 if ($Config{usemymalloc} and not $Config{bincompat5005}
263 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
264 and $self->{PERL_MALLOC_OK}) {
265 $pollute = '$(PERL_MALLOC_DEF)';
268 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS});
269 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE});
271 return $self->{CFLAGS} = qq{
272 CCFLAGS = $self->{CCFLAGS}
273 OPTIMIZE = $self->{OPTIMIZE}
274 PERLTYPE = $self->{PERLTYPE}
281 =item const_cccmd (o)
283 Returns the full compiler call for C programs and stores the
284 definition in CONST_CCCMD.
289 my($self,$libperl)=@_;
290 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
291 return '' unless $self->needs_linking();
292 return $self->{CONST_CCCMD} =
293 q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
294 $(CCFLAGS) $(OPTIMIZE) \\
295 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
296 $(XS_DEFINE_VERSION)};
299 =item const_config (o)
301 Defines a couple of constants in the Makefile that are imported from
307 # --- Constants Sections ---
312 # These definitions are from config.sh (via $INC{'Config.pm'}).
313 # They may have been overridden via Makefile.PL or on the command line.
317 foreach my $key (@{$self->{CONFIG}}){
318 # SITE*EXP macros are defined in &constants; avoid duplicates here
319 next if $once_only{$key};
320 $self->{uc $key} = quote_paren($self->{uc $key});
321 push @m, uc($key) , ' = ' , $self->{uc $key}, "\n";
322 $once_only{$key} = 1;
327 =item const_loadlibs (o)
329 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
330 L<ExtUtils::Liblist> for details.
336 return "" unless $self->needs_linking;
339 # $self->{NAME} might depend on some other libraries:
340 # See ExtUtils::Liblist for details
344 EXTRALIBS LDLOADLIBS BSLOADLIBS
346 next unless defined $self->{$tmp};
347 push @m, "$tmp = $self->{$tmp}\n";
349 # don't set LD_RUN_PATH if empty
353 next unless $self->{$tmp};
354 push @m, "$tmp = $self->{$tmp}\n";
361 my $make_frag = $mm->constants;
363 Prints out macros for lots of constants.
371 $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use
375 AR_STATIC_ARGS DIRFILESEP DFSEP
377 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
378 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
379 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
380 INST_MAN1DIR INST_MAN3DIR
382 INSTALLDIRS INSTALL_BASE DESTDIR PREFIX
383 PERLPREFIX SITEPREFIX VENDORPREFIX
385 (map { ("INSTALL".$_,
387 } $self->installvars),
392 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
393 PERLMAINCC PERL_SRC PERL_INC
394 PERL FULLPERL ABSPERL
395 PERLRUN FULLPERLRUN ABSPERLRUN
396 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
398 PERM_DIR PERM_RW PERM_RWX
402 next unless defined $self->{$macro};
404 # pathnames can have sharp signs in them; escape them so
405 # make doesn't think it is a comment-start character.
406 $self->{$macro} =~ s/#/\\#/g;
407 push @m, "$macro = $self->{$macro}\n";
411 MAKEMAKER = $self->{MAKEMAKER}
412 MM_VERSION = $self->{MM_VERSION}
413 MM_REVISION = $self->{MM_REVISION}
417 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
418 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
419 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
420 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
425 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
426 LDFROM LINKTYPE BOOTDEP
429 next unless defined $self->{$macro};
430 push @m, "$macro = $self->{$macro}\n";
434 # Handy lists of source code files:
435 XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
436 C_FILES = ".$self->wraplist(@{$self->{C}})."
437 O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."
438 H_FILES = ".$self->wraplist(@{$self->{H}})."
439 MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
440 MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
445 # Where is the Config information that we are using/depend on
446 CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
447 } if -e File::Spec->catfile( $self->{PERL_INC}, 'config.h' );
451 # Where to build things
452 INST_LIBDIR = $self->{INST_LIBDIR}
453 INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
455 INST_AUTODIR = $self->{INST_AUTODIR}
456 INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
458 INST_STATIC = $self->{INST_STATIC}
459 INST_DYNAMIC = $self->{INST_DYNAMIC}
460 INST_BOOT = $self->{INST_BOOT}
466 EXPORT_LIST = $self->{EXPORT_LIST}
467 PERL_ARCHIVE = $self->{PERL_ARCHIVE}
468 PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
473 TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."
475 PM_TO_BLIB = ".$self->wraplist(map { ($_ => $self->{PM}->{$_}) } sort keys %{$self->{PM}})."
484 Same as macro for the depend attribute.
489 my($self,%attribs) = @_;
491 while (($key,$val) = each %attribs){
492 last unless defined $key;
493 push @m, "$key : $val\n";
503 Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
511 $self->{DESTDIR} ||= '';
513 # Make DEST variables.
514 foreach my $var ($self->installvars) {
515 my $destvar = 'DESTINSTALL'.$var;
516 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
525 Defines a lot of macros for distribution support.
527 macro description default
529 TAR tar command to use tar
530 TARFLAGS flags to pass to TAR cvf
532 ZIP zip command to use zip
533 ZIPFLAGS flags to pass to ZIP -r
535 COMPRESS compression command to gzip --best
537 SUFFIX suffix to put on .gz
540 SHAR shar command to use shar
542 PREOP extra commands to run before
544 POSTOP extra commands to run after
547 TO_UNIX a command to convert linefeeds
548 to Unix style in your archive
550 CI command to checkin your ci -u
551 sources to version control
552 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
555 DIST_CP $how argument to manicopy() best
556 when the distdir is created
558 DIST_DEFAULT default target to use to tardist
559 create a distribution
561 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
569 $self->{TAR} ||= 'tar';
570 $self->{TARFLAGS} ||= 'cvf';
571 $self->{ZIP} ||= 'zip';
572 $self->{ZIPFLAGS} ||= '-r';
573 $self->{COMPRESS} ||= 'gzip --best';
574 $self->{SUFFIX} ||= '.gz';
575 $self->{SHAR} ||= 'shar';
576 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
577 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
578 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
580 $self->{CI} ||= 'ci -u';
581 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
582 $self->{DIST_CP} ||= 'best';
583 $self->{DIST_DEFAULT} ||= 'tardist';
585 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
586 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
591 my $dist_macros = $mm->dist(%overrides);
593 Generates a make fragment defining all the macros initialized in
596 %overrides can be used to override any of the above.
601 my($self, %attribs) = @_;
604 if ( $attribs{SUFFIX} && $attribs{SUFFIX} !~ m!^\.! ) {
605 $attribs{SUFFIX} = '.' . $attribs{SUFFIX};
608 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
610 CI RCS_LABEL DIST_CP DIST_DEFAULT
614 my $value = $attribs{$key} || $self->{$key};
615 $make .= "$key = $value\n";
621 =item dist_basics (o)
623 Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
630 return <<'MAKE_FRAG';
631 distclean :: realclean distcheck
635 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
638 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
641 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
643 veryclean : realclean
644 $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old
652 Defines a check in target for RCS.
660 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\
661 -e "@all = keys %{ maniread() };" \\
662 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\
663 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
669 my $dist_make_fragment = $MM->dist_core;
671 Puts the targets necessary for 'make dist' together into one make
680 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
683 my $method = $target.'_target';
685 $make_frag .= $self->$method();
694 my $make_frag = $MM->dist_target;
696 Returns the 'dist' target to make an archive for distribution. This
697 target simply checks to make sure the Makefile is up-to-date and
698 depends on $(DIST_DEFAULT).
705 my $date_check = $self->oneliner(<<'CODE', ['-l']);
706 print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
707 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
710 return sprintf <<'MAKE_FRAG', $date_check;
711 dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
716 =item B<tardist_target>
718 my $make_frag = $MM->tardist_target;
720 Returns the 'tardist' target which is simply so 'make tardist' works.
721 The real work is done by the dynamically named tardistfile_target()
722 method, tardist should have that as a dependency.
729 return <<'MAKE_FRAG';
730 tardist : $(DISTVNAME).tar$(SUFFIX)
735 =item B<zipdist_target>
737 my $make_frag = $MM->zipdist_target;
739 Returns the 'zipdist' target which is simply so 'make zipdist' works.
740 The real work is done by the dynamically named zipdistfile_target()
741 method, zipdist should have that as a dependency.
748 return <<'MAKE_FRAG';
749 zipdist : $(DISTVNAME).zip
754 =item B<tarfile_target>
756 my $make_frag = $MM->tarfile_target;
758 The name of this target is the name of the tarball generated by
759 tardist. This target does the actual work of turning the distdir into
767 return <<'MAKE_FRAG';
768 $(DISTVNAME).tar$(SUFFIX) : distdir
771 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
772 $(RM_RF) $(DISTVNAME)
773 $(COMPRESS) $(DISTVNAME).tar
774 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)'
781 my $make_frag = $MM->zipfile_target;
783 The name of this target is the name of the zip file generated by
784 zipdist. This target does the actual work of turning the distdir into
792 return <<'MAKE_FRAG';
793 $(DISTVNAME).zip : distdir
795 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
796 $(RM_RF) $(DISTVNAME)
797 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).zip'
802 =item uutardist_target
804 my $make_frag = $MM->uutardist_target;
806 Converts the tarfile into a uuencoded file
810 sub uutardist_target {
813 return <<'MAKE_FRAG';
814 uutardist : $(DISTVNAME).tar$(SUFFIX)
815 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
816 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)_uu'
823 my $make_frag = $MM->shdist_target;
825 Converts the distdir into a shell archive.
832 return <<'MAKE_FRAG';
835 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
836 $(RM_RF) $(DISTVNAME)
837 $(NOECHO) $(ECHO) 'Created $(DISTVNAME).shar'
845 Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files.
847 Normally just returns an empty string.
858 Defines targets for bootstrap files.
863 my($self, %attribs) = @_;
866 ' unless $self->has_link_code();
868 my $target = $Is{VMS} ? '$(MMS$TARGET)' : '$@';
870 return sprintf <<'MAKE_FRAG', ($target) x 2;
871 BOOTSTRAP = $(BASEEXT).bs
873 # As Mkbootstrap might not write a file (if none is required)
874 # we use touch to prevent make continually trying to remake it.
875 # The DynaLoader only reads a non-empty file.
876 $(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
877 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
878 $(NOECHO) $(PERLRUN) \
879 "-MExtUtils::Mkbootstrap" \
880 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
881 $(NOECHO) $(TOUCH) %s
882 $(CHMOD) $(PERM_RW) %s
886 =item dynamic_lib (o)
888 Defines how to produce the *.so (or equivalent) files.
893 my($self, %attribs) = @_;
894 return '' unless $self->needs_linking(); #might be because of a subdir
896 return '' unless $self->has_link_code;
898 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
899 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
900 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
901 my($ldfrom) = '$(LDFROM)';
902 $armaybe = 'ar' if ($Is{OSF} and $armaybe eq ':');
904 my $ld_opt = $Is{OS2} ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
905 my $ld_fix = $Is{OS2} ? '|| ( $(RM_F) $@ && sh -c false )' : '';
907 # This section creates the dynamically loadable $(INST_DYNAMIC)
908 # from $(OBJECT) and possibly $(MYEXTLIB).
909 ARMAYBE = '.$armaybe.'
910 OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
911 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
912 INST_DYNAMIC_FIX = '.$ld_fix.'
914 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
916 if ($armaybe ne ':'){
917 $ldfrom = 'tmp$(LIB_EXT)';
918 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
919 push(@m,' $(RANLIB) '."$ldfrom\n");
921 $ldfrom = "-all $ldfrom -none" if $Is{OSF};
923 # The IRIX linker doesn't use LD_RUN_PATH
924 my $ldrun = $Is{IRIX} && $self->{LD_RUN_PATH} ?
925 qq{-rpath "$self->{LD_RUN_PATH}"} : '';
927 # For example in AIX the shared objects/libraries from previous builds
928 # linger quite a while in the shared dynalinker cache even when nobody
929 # is using them. This is painful if one for instance tries to restart
930 # a failed build because the link command will fail unnecessarily 'cos
931 # the shared object/library is 'busy'.
935 my $libs = '$(LDLOADLIBS)';
937 if (($Is{NetBSD} || $Is{Interix} || $Is{Android}) && $Config{'useshrplib'} eq 'true') {
938 # Use nothing on static perl platforms, and to the flags needed
939 # to link against the shared libperl library on shared perl
940 # platforms. We peek at lddlflags to see if we need -Wl,-R
941 # or -R to add paths to the run-time library search path.
942 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
943 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
944 } elsif ($Config{'lddlflags'} =~ /-R/) {
945 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
946 } elsif ( $Is{Android} ) {
947 # The Android linker will not recognize symbols from
948 # libperl unless the module explicitly depends on it.
949 $libs .= ' -L$(PERL_INC) -lperl';
953 my $ld_run_path_shell = "";
954 if ($self->{LD_RUN_PATH} ne "") {
955 $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
958 push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs;
959 %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
960 $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
965 $(CHMOD) $(PERM_RWX) $@
966 $(NOECHO) $(RM_RF) $(BOOTSTRAP)
967 - $(CP_NONEMPTY) $(BOOTSTRAP) $(INST_BOOT) $(PERM_RW)
975 Deprecated method. Use libscan instead.
980 my($self,$path) = @_;
986 Called by init_others, and calls ext ExtUtils::Liblist. See
987 L<ExtUtils::Liblist> for details.
992 my($self,$libs) = @_;
993 require ExtUtils::Liblist;
994 $self->ext($libs, $Verbose);
999 Finds the executables PERL and FULLPERL
1004 my($self, $ver, $names, $dirs, $trace) = @_;
1007 print "Looking for perl $ver by these names:
1014 my $stderr_duped = 0;
1018 # >& and lexical filehandles together give 5.6.2 indigestion
1019 if( open(STDERR_COPY, '>&STDERR') ) { ## no critic
1024 find_perl() can't dup STDERR: $!
1025 You might see some garbage while we search for Perl
1030 foreach my $name (@$names){
1031 foreach my $dir (@$dirs){
1032 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1034 if ($self->file_name_is_absolute($name)) { # /foo/bar
1036 } elsif ($self->canonpath($name) eq
1037 $self->canonpath(basename($name))) { # foo
1038 $abs = $self->catfile($dir, $name);
1040 $abs = $self->catfile($Curdir, $name);
1042 print "Checking $abs\n" if ($trace >= 2);
1043 next unless $self->maybe_command($abs);
1044 print "Executing $abs\n" if ($trace >= 2);
1046 my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"};
1048 # To avoid using the unportable 2>&1 to suppress STDERR,
1049 # we close it before running the command.
1050 # However, thanks to a thread library bug in many BSDs
1051 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1052 # we cannot use the fancier more portable way in here
1053 # but instead need to use the traditional 2>&1 construct.
1055 $val = `$version_check 2>&1`;
1057 close STDERR if $stderr_duped;
1058 $val = `$version_check`;
1060 # 5.6.2's 3-arg open doesn't work with >&
1061 open STDERR, ">&STDERR_COPY" ## no critic
1065 if ($val =~ /^VER_OK/m) {
1066 print "Using PERL=$abs\n" if $trace;
1068 } elsif ($trace >= 2) {
1069 print "Result: '$val' ".($? >> 8)."\n";
1073 print "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1074 0; # false and not empty
1082 Inserts the sharpbang or equivalent magic number to a set of @files.
1086 sub fixin { # stolen from the pink Camel book, more or less
1087 my ( $self, @files ) = @_;
1089 for my $file (@files) {
1090 my $file_new = "$file.new";
1091 my $file_bak = "$file.bak";
1093 open( my $fixin, '<', $file ) or croak "Can't process '$file': $!";
1095 chomp( my $line = <$fixin> );
1096 next unless $line =~ s/^\s*\#!\s*//; # Not a shebang file.
1098 my $shb = $self->_fixin_replace_shebang( $file, $line );
1099 next unless defined $shb;
1101 open( my $fixout, ">", "$file_new" ) or do {
1102 warn "Can't create new $file: $!\n";
1106 # Print out the new #! line (or equivalent).
1109 print $fixout $shb, <$fixin>;
1113 chmod 0666, $file_bak;
1115 unless ( _rename( $file, $file_bak ) ) {
1116 warn "Can't rename $file to $file_bak: $!";
1119 unless ( _rename( $file_new, $file ) ) {
1120 warn "Can't rename $file_new to $file: $!";
1121 unless ( _rename( $file_bak, $file ) ) {
1122 warn "Can't rename $file_bak back to $file either: $!";
1123 warn "Leaving $file renamed as $file_bak\n";
1130 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
1136 my($old, $new) = @_;
1138 foreach my $file ($old, $new) {
1139 if( $Is{VMS} and basename($file) !~ /\./ ) {
1140 # rename() in 5.8.0 on VMS will not rename a file if it
1141 # does not contain a dot yet it returns success.
1146 return rename($old, $new);
1149 sub _fixin_replace_shebang {
1150 my ( $self, $file, $line ) = @_;
1152 # Now figure out the interpreter name.
1153 my ( $cmd, $arg ) = split ' ', $line, 2;
1156 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
1158 if ( $cmd =~ m{^perl(?:\z|[^a-z])} ) {
1159 if ( $Config{startperl} =~ m,^\#!.*/perl, ) {
1160 $interpreter = $Config{startperl};
1161 $interpreter =~ s,^\#!,,;
1164 $interpreter = $Config{perlpath};
1169 = reverse grep { $self->file_name_is_absolute($_) } $self->path;
1172 foreach my $dir (@absdirs) {
1173 if ( $self->maybe_command($cmd) ) {
1174 warn "Ignoring $interpreter in $file\n"
1175 if $Verbose && $interpreter;
1176 $interpreter = $self->catfile( $dir, $cmd );
1181 # Figure out how to invoke interpreter on this machine.
1183 my ($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1186 print "Changing sharpbang in $file to $interpreter"
1188 # this is probably value-free on DOSISH platforms
1190 $shb .= "$Config{'sharpbang'}$interpreter";
1191 $shb .= ' ' . $arg if defined $arg;
1195 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
1196 if 0; # not running under some shell
1197 } unless $Is{Win32}; # this won't work on win32, so don't
1200 warn "Can't find $cmd in PATH, $file unchanged"
1209 Writes an empty FORCE: target.
1215 '# Phony target to force checking subdirectories.
1223 Guess the name of this package by examining the working directory's
1224 name. MakeMaker calls this only if the developer has not supplied a
1234 my $name = basename(cwd());
1235 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
1236 # strip minus or underline
1237 # followed by a float or some such
1238 print "Warning: Guessing NAME [$name] from current directory name.\n";
1244 Returns true if C, XS, MYEXTLIB or similar objects exist within this
1245 object that need a compiler. Does not descend into subdirectories as
1246 needs_linking() does.
1252 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1253 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1254 $self->{HAS_LINK_CODE} = 1;
1257 return $self->{HAS_LINK_CODE} = 0;
1263 Scans the directory structure and initializes DIR, XS, XS_FILES,
1264 C, C_FILES, O_FILES, H, H_FILES, PL_FILES, EXE_FILES.
1266 Called by init_main.
1270 sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1272 my(%dir, %xs, %c, %o, %h, %pl_files, %pm);
1274 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
1276 # ignore the distdir
1277 $Is{VMS} ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1278 : $ignore{$self->{DISTVNAME}} = 1;
1280 my $distprefix = $Is{VMS} ? qr/^\Q$self->{DISTNAME}\E-.*\.dir$/i
1281 : qr/^\Q$self->{DISTNAME}-/;
1283 @ignore{map lc, keys %ignore} = values %ignore if $Is{VMS};
1285 if ( defined $self->{XS} and !defined $self->{C} ) {
1286 my @c_files = grep { m/\.c(pp|xx)?\z/i } values %{$self->{XS}};
1287 my @o_files = grep { m/(?:.(?:o(?:bj)?)|\$\(OBJ_EXT\))\z/i } values %{$self->{XS}};
1288 %c = map { $_ => 1 } @c_files;
1289 %o = map { $_ => 1 } @o_files;
1292 foreach my $name ($self->lsdir($Curdir)){
1293 next if $name =~ /\#/;
1294 next if $name =~ $distprefix;
1295 $name = lc($name) if $Is{VMS};
1296 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
1297 next unless $self->libscan($name);
1299 next if -l $name; # We do not support symlinks at all
1300 next if $self->{NORECURS};
1301 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1302 } elsif ($name =~ /\.xs\z/){
1303 my($c); ($c = $name) =~ s/\.xs\z/.c/;
1306 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
1308 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1309 } elsif ($name =~ /\.h\z/i){
1311 } elsif ($name =~ /\.PL\z/) {
1312 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
1313 } elsif (($Is{VMS} || $Is{Dos}) && $name =~ /[._]pl$/i) {
1314 # case-insensitive filesystem, one dot per name, so foo.h.PL
1315 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
1316 local($/); open(my $pl, '<', $name); my $txt = <$pl>; close $pl;
1317 if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
1318 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
1321 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1323 } elsif ($name =~ /\.(p[ml]|pod)\z/){
1324 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1328 $self->{PL_FILES} ||= \%pl_files;
1329 $self->{DIR} ||= [sort keys %dir];
1330 $self->{XS} ||= \%xs;
1331 $self->{C} ||= [sort keys %c];
1332 $self->{H} ||= [sort keys %h];
1333 $self->{PM} ||= \%pm;
1335 my @o_files = @{$self->{C}};
1336 %o = (%o, map { $_ => 1 } grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files);
1337 $self->{O_FILES} = [sort keys %o];
1343 Determines if man pages should be generated and initializes MAN1PODS
1344 and MAN3PODS as appropriate.
1351 # Set up names of manual pages to generate from pods
1352 foreach my $man (qw(MAN1 MAN3)) {
1353 if ( $self->{"${man}PODS"}
1354 or $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/
1356 $self->{"${man}PODS"} ||= {};
1359 my $init_method = "init_${man}PODS";
1360 $self->$init_method();
1367 my($self, $file) = @_;
1370 if (open( my $fh, '<', $file )) {
1372 if (/^=(?:head\d+|item|pod)\b/) {
1379 # If it doesn't exist yet, we assume, it has pods in it
1389 Initializes MAN1PODS from the list of EXE_FILES.
1396 if ( exists $self->{EXE_FILES} ) {
1397 foreach my $name (@{$self->{EXE_FILES}}) {
1398 next unless $self->_has_pod($name);
1400 $self->{MAN1PODS}->{$name} =
1401 $self->catfile("\$(INST_MAN1DIR)",
1402 basename($name).".\$(MAN1EXT)");
1410 Initializes MAN3PODS from the list of PM files.
1417 my %manifypods = (); # we collect the keys first, i.e. the files
1418 # we have to convert to pod
1420 foreach my $name (keys %{$self->{PM}}) {
1421 if ($name =~ /\.pod\z/ ) {
1422 $manifypods{$name} = $self->{PM}{$name};
1423 } elsif ($name =~ /\.p[ml]\z/ ) {
1424 if( $self->_has_pod($name) ) {
1425 $manifypods{$name} = $self->{PM}{$name};
1430 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1432 # Remove "Configure.pm" and similar, if it's not the only pod listed
1433 # To force inclusion, just name it "Configure.pod", or override
1435 foreach my $name (keys %manifypods) {
1436 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
1437 delete $manifypods{$name};
1440 my($manpagename) = $name;
1441 $manpagename =~ s/\.p(od|m|l)\z//;
1442 # everything below lib is ok
1443 unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1444 $manpagename = $self->catfile(
1445 split(/::/,$self->{PARENT_NAME}),$manpagename
1448 $manpagename = $self->replace_manpage_separator($manpagename);
1449 $self->{MAN3PODS}->{$name} =
1450 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1457 Initializes PMLIBDIRS and PM from PMLIBDIRS.
1464 # Some larger extensions often wish to install a number of *.pm/pl
1465 # files into the library in various locations.
1467 # The attribute PMLIBDIRS holds an array reference which lists
1468 # subdirectories which we should search for library files to
1469 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1470 # recursively search through the named directories (skipping any
1471 # which don't exist or contain Makefile.PL files).
1473 # For each *.pm or *.pl file found $self->libscan() is called with
1474 # the default installation path in $_[1]. The return value of
1475 # libscan defines the actual installation location. The default
1476 # libscan function simply returns the path. The file is skipped
1477 # if libscan returns false.
1479 # The default installation location passed to libscan in $_[1] is:
1481 # ./*.pm => $(INST_LIBDIR)/*.pm
1482 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1483 # ./lib/... => $(INST_LIB)/...
1485 # In this way the 'lib' directory is seen as the root of the actual
1486 # perl library whereas the others are relative to INST_LIBDIR
1487 # (which includes PARENT_NAME). This is a subtle distinction but one
1488 # that's important for nested modules.
1490 unless( $self->{PMLIBDIRS} ) {
1492 # Avoid logical name vs directory collisions
1493 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1496 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1500 #only existing directories that aren't in $dir are allowed
1502 # Avoid $_ wherever possible:
1503 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1504 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1505 @{$self->{PMLIBDIRS}} = ();
1506 my %dir = map { ($_ => $_) } @{$self->{DIR}};
1507 foreach my $pmlibdir (@pmlibdirs) {
1508 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1511 unless( $self->{PMLIBPARENTDIRS} ) {
1512 @{$self->{PMLIBPARENTDIRS}} = ('lib');
1515 return if $self->{PM} and $self->{ARGS}{PM};
1517 if (@{$self->{PMLIBDIRS}}){
1518 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1521 File::Find::find(sub {
1523 unless ($self->libscan($_)){
1524 $File::Find::prune = 1;
1529 return if /~$/; # emacs temp files
1530 return if /,v$/; # RCS files
1531 return if m{\.swp$}; # vim swap files
1533 my $path = $File::Find::name;
1534 my $prefix = $self->{INST_LIBDIR};
1537 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1538 $prefix = $self->{INST_LIB}
1539 if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W}
1542 my($inst) = $self->catfile($prefix,$striplibpath);
1543 local($_) = $inst; # for backwards compatibility
1544 $inst = $self->libscan($inst);
1545 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1546 return unless $inst;
1547 $self->{PM}{$path} = $inst;
1548 }, @{$self->{PMLIBDIRS}});
1553 =item init_DIRFILESEP
1555 Using / for Unix. Called by init_main.
1559 sub init_DIRFILESEP {
1562 $self->{DIRFILESEP} = '/';
1568 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1569 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1570 INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1571 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1572 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1573 VERSION_SYM, XS_VERSION.
1580 # --- Initialize Module Name and Paths
1582 # NAME = Foo::Bar::Oracle
1583 # FULLEXT = Foo/Bar/Oracle
1585 # PARENT_NAME = Foo::Bar
1587 ### ($self->{FULLEXT} =
1588 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1589 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1592 # Copied from DynaLoader:
1594 my(@modparts) = split(/::/,$self->{NAME});
1595 my($modfname) = $modparts[-1];
1597 # Some systems have restrictions on files names for DLL's etc.
1598 # mod2fname returns appropriate file base name (typically truncated)
1599 # It may also edit @modparts if required.
1600 # We require DynaLoader to make sure that mod2fname is loaded
1601 eval { require DynaLoader };
1602 if (defined &DynaLoader::mod2fname) {
1603 $modfname = &DynaLoader::mod2fname(\@modparts);
1606 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1607 $self->{PARENT_NAME} ||= '';
1609 if (defined &DynaLoader::mod2fname) {
1610 # As of 5.001m, dl_os2 appends '_'
1611 $self->{DLBASE} = $modfname;
1613 $self->{DLBASE} = '$(BASEEXT)';
1617 # --- Initialize PERL_LIB, PERL_SRC
1619 # *Real* information: where did we get these two from? ...
1620 my $inc_config_dir = dirname($INC{'Config.pm'});
1621 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1623 unless ($self->{PERL_SRC}){
1624 foreach my $dir_count (1..8) { # 8 is the VMS limit for nesting
1625 my $dir = $self->catdir(($Updir) x $dir_count);
1627 if (-f $self->catfile($dir,"config_h.SH") &&
1628 -f $self->catfile($dir,"perl.h") &&
1629 -f $self->catfile($dir,"lib","strict.pm")
1631 $self->{PERL_SRC}=$dir ;
1637 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1638 $self->{PERL_CORE} and !$self->{PERL_SRC};
1640 if ($self->{PERL_SRC}){
1641 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1643 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1644 $self->{PERL_INC} = ($Is{Win32}) ?
1645 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1647 # catch a situation that has occurred a few times in the past:
1649 -s $self->catfile($self->{PERL_SRC},'cflags')
1653 -s $self->catfile($self->{PERL_SRC},'vmsish.h')
1658 You cannot build extensions below the perl source tree after executing
1659 a 'make clean' in the perl source tree.
1661 To rebuild extensions distributed with the perl source you should
1662 simply Configure (to include those extensions) and then build perl as
1663 normal. After installing perl the source tree can be deleted. It is
1664 not needed for building extensions by running 'perl Makefile.PL'
1665 usually without extra arguments.
1667 It is recommended that you unpack and build additional extensions away
1668 from the perl source tree.
1672 # we should also consider $ENV{PERL5LIB} here
1673 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1674 $self->{PERL_LIB} ||= $Config{privlibexp};
1675 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1676 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1679 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1681 # Maybe somebody tries to build an extension with an
1682 # uninstalled Perl outside of Perl build tree
1684 for my $dir (@INC) {
1685 $lib = $dir, last if -e $self->catfile($dir, "Config.pm");
1688 # Win32 puts its header files in /perl/src/lib/CORE.
1689 # Unix leaves them in /perl/src.
1690 my $inc = $Is{Win32} ? $self->catdir($lib, "CORE" )
1692 if (-e $self->catfile($inc, "perl.h")) {
1693 $self->{PERL_LIB} = $lib;
1694 $self->{PERL_ARCHLIB} = $lib;
1695 $self->{PERL_INC} = $inc;
1696 $self->{UNINSTALLED_PERL} = 1;
1698 ... Detected uninstalled Perl. Trying to continue.
1706 # Android fun times!
1707 # ../../perl -I../../lib -MFile::Glob -e1 works
1708 # ../../../perl -I../../../lib -MFile::Glob -e1 fails to find
1709 # the .so for File::Glob.
1710 # This always affects core perl, but may also affect an installed
1711 # perl built with -Duserelocatableinc.
1712 $self->{PERL_LIB} = File::Spec->rel2abs($self->{PERL_LIB});
1713 $self->{PERL_ARCHLIB} = File::Spec->rel2abs($self->{PERL_ARCHLIB});
1716 # We get SITELIBEXP and SITEARCHEXP directly via
1717 # Get_from_Config. When we are running standard modules, these
1718 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1719 # set it to "site". I prefer that INSTALLDIRS be set from outside
1721 $self->{INSTALLDIRS} ||= "site";
1723 $self->{MAN1EXT} ||= $Config{man1ext};
1724 $self->{MAN3EXT} ||= $Config{man3ext};
1726 # Get some stuff out of %Config if we haven't yet done so
1727 print "CONFIG must be an array ref\n"
1728 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1729 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1730 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1731 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1733 foreach my $m (@{$self->{CONFIG}}){
1734 next if $once_only{$m};
1735 print "CONFIG key '$m' does not exist in Config.pm\n"
1736 unless exists $Config{$m};
1737 $self->{uc $m} ||= $Config{$m};
1741 # This is too dangerous:
1742 # if ($^O eq "next") {
1743 # $self->{AR} = "libtool";
1744 # $self->{AR_STATIC_ARGS} = "-o";
1746 # But I leave it as a placeholder
1748 $self->{AR_STATIC_ARGS} ||= "cr";
1750 # These should never be needed
1751 $self->{OBJ_EXT} ||= '.o';
1752 $self->{LIB_EXT} ||= '.a';
1754 $self->{MAP_TARGET} ||= "perl";
1756 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1758 # make a simple check if we find strict
1759 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1760 (strict.pm not found)"
1761 unless -f $self->catfile("$self->{PERL_LIB}","strict.pm") ||
1762 $self->{NAME} eq "ExtUtils::MakeMaker";
1767 Initializes tools to use their common (and faster) Unix commands.
1774 $self->{ECHO} ||= 'echo';
1775 $self->{ECHO_N} ||= 'echo -n';
1776 $self->{RM_F} ||= "rm -f";
1777 $self->{RM_RF} ||= "rm -rf";
1778 $self->{TOUCH} ||= "touch";
1779 $self->{TEST_F} ||= "test -f";
1780 $self->{TEST_S} ||= "test -s";
1781 $self->{CP} ||= "cp";
1782 $self->{MV} ||= "mv";
1783 $self->{CHMOD} ||= "chmod";
1784 $self->{FALSE} ||= 'false';
1785 $self->{TRUE} ||= 'true';
1787 $self->{LD} ||= 'ld';
1789 return $self->SUPER::init_tools(@_);
1791 # After SUPER::init_tools so $Config{shell} has a
1792 # chance to get set.
1793 $self->{SHELL} ||= '/bin/sh';
1801 Unix has no need of special linker flags.
1807 $self->{PERL_ARCHIVE} ||= '';
1808 $self->{PERL_ARCHIVE_AFTER} ||= '';
1809 $self->{EXPORT_LIST} ||= '';
1826 # The user who requests an installation directory explicitly
1827 # should not have to tell us an architecture installation directory
1828 # as well. We look if a directory exists that is named after the
1829 # architecture. If not we take it as a sign that it should be the
1830 # same as the requested installation directory. Otherwise we take
1832 for my $libpair ({l=>"privlib", a=>"archlib"},
1833 {l=>"sitelib", a=>"sitearch"},
1834 {l=>"vendorlib", a=>"vendorarch"},
1837 my $lib = "install$libpair->{l}";
1839 my $Arch = uc "install$libpair->{a}";
1840 if( $self->{$Lib} && ! $self->{$Arch} ){
1841 my($ilib) = $Config{$lib};
1843 $self->prefixify($Arch,$ilib,$self->{$Lib});
1845 unless (-d $self->{$Arch}) {
1846 print "Directory $self->{$Arch} not found\n"
1848 $self->{$Arch} = $self->{$Lib};
1850 print "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1860 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1861 *PERLRUN* permutations.
1863 PERL is allowed to be miniperl
1864 FULLPERL must be a complete perl
1866 ABSPERL is PERL converted to an absolute path
1868 *PERLRUN contains everything necessary to run perl, find it's
1871 *PERLRUNINST is *PERLRUN + everything necessary to find the
1872 modules being built.
1880 foreach my $component ($self->{PERL_SRC}, $self->path(),
1883 push @defpath, $component if defined $component;
1886 # Build up a set of file names (not command names).
1887 my $thisperl = $self->canonpath($^X);
1888 $thisperl .= $Config{exe_ext} unless
1889 # VMS might have a file version # at the end
1890 $Is{VMS} ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
1891 : $thisperl =~ m/$Config{exe_ext}$/i;
1893 # We need a relative path to perl when in the core.
1894 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
1896 my @perls = ($thisperl);
1897 push @perls, map { "$_$Config{exe_ext}" }
1898 ("perl$Config{version}", 'perl5', 'perl');
1900 # miniperl has priority over all but the canonical perl when in the
1901 # core. Otherwise its a last resort.
1902 my $miniperl = "miniperl$Config{exe_ext}";
1903 if( $self->{PERL_CORE} ) {
1904 splice @perls, 1, 0, $miniperl;
1907 push @perls, $miniperl;
1911 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
1912 # don't check if perl is executable, maybe they have decided to
1913 # supply switches with perl
1915 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
1916 my $perl_name = 'perl';
1917 $perl_name = 'ndbgperl' if $Is{VMS} &&
1918 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
1920 # XXX This logic is flawed. If "miniperl" is anywhere in the path
1921 # it will get confused. It should be fixed to work only on the filename.
1922 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1923 ($self->{FULLPERL} = $self->{PERL}) =~ s/\Q$miniperl\E$/$perl_name$Config{exe_ext}/i
1924 unless $self->{FULLPERL};
1926 # Little hack to get around VMS's find_perl putting "MCR" in front
1928 $self->{ABSPERL} = $self->{PERL};
1929 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
1930 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
1931 $self->{ABSPERL} = '$(PERL)';
1934 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
1936 # Quote the perl command if it contains whitespace
1937 $self->{ABSPERL} = $self->quote_literal($self->{ABSPERL})
1938 if $self->{ABSPERL} =~ /\s/;
1940 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
1943 # Are we building the core?
1944 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1945 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
1947 # How do we run perl?
1948 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
1949 my $run = $perl.'RUN';
1951 $self->{$run} = "\$($perl)";
1953 # Make sure perl can find itself before it's installed.
1954 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
1955 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
1957 $self->{$perl.'RUNINST'} =
1958 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
1967 =item platform_constants
1969 Add MM_Unix_VERSION.
1976 $self->{MM_Unix_VERSION} = $VERSION;
1977 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
1978 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
1979 '-Dcalloc=Perl_calloc';
1983 sub platform_constants {
1987 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
1989 next unless defined $self->{$macro};
1990 $make_frag .= "$macro = $self->{$macro}\n";
2001 Called by init_main. Initializes PERL_*
2008 $self->{PERM_DIR} = 755 unless defined $self->{PERM_DIR};
2009 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2010 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2020 Sets up macros having to do with XS code. Currently just INST_STATIC,
2021 INST_DYNAMIC and INST_BOOT.
2028 if ($self->has_link_code()) {
2029 $self->{INST_STATIC} =
2030 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2031 $self->{INST_DYNAMIC} =
2032 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2033 $self->{INST_BOOT} =
2034 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2036 $self->{INST_STATIC} = '';
2037 $self->{INST_DYNAMIC} = '';
2038 $self->{INST_BOOT} = '';
2044 Defines the install target.
2049 my($self, %attribs) = @_;
2053 install :: pure_install doc_install
2056 install_perl :: pure_perl_install doc_perl_install
2059 install_site :: pure_site_install doc_site_install
2062 install_vendor :: pure_vendor_install doc_vendor_install
2065 pure_install :: pure_$(INSTALLDIRS)_install
2068 doc_install :: doc_$(INSTALLDIRS)_install
2071 pure__install : pure_site_install
2072 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2074 doc__install : doc_site_install
2075 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2077 pure_perl_install :: all
2078 $(NOECHO) $(MOD_INSTALL) \
2082 q{ read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2083 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2084 } unless $self->{NO_PACKLIST};
2087 q{ $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2088 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2089 $(INST_BIN) $(DESTINSTALLBIN) \
2090 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2091 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2092 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2093 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2094 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2097 pure_site_install :: all
2098 $(NOECHO) $(MOD_INSTALL) \
2101 q{ read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2102 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2103 } unless $self->{NO_PACKLIST};
2106 q{ $(INST_LIB) $(DESTINSTALLSITELIB) \
2107 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2108 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2109 $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
2110 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2111 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2112 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2113 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2115 pure_vendor_install :: all
2116 $(NOECHO) $(MOD_INSTALL) \
2119 q{ read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2120 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2121 } unless $self->{NO_PACKLIST};
2124 q{ $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2125 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2126 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2127 $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
2128 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2129 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2134 doc_perl_install :: all
2137 doc_site_install :: all
2140 doc_vendor_install :: all
2143 } if $self->{NO_PERLLOCAL};
2146 doc_perl_install :: all
2147 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2148 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2149 -$(NOECHO) $(DOC_INSTALL) \
2150 "Module" "$(NAME)" \
2151 "installed into" "$(INSTALLPRIVLIB)" \
2152 LINKTYPE "$(LINKTYPE)" \
2153 VERSION "$(VERSION)" \
2154 EXE_FILES "$(EXE_FILES)" \
2155 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2157 doc_site_install :: all
2158 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2159 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2160 -$(NOECHO) $(DOC_INSTALL) \
2161 "Module" "$(NAME)" \
2162 "installed into" "$(INSTALLSITELIB)" \
2163 LINKTYPE "$(LINKTYPE)" \
2164 VERSION "$(VERSION)" \
2165 EXE_FILES "$(EXE_FILES)" \
2166 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2168 doc_vendor_install :: all
2169 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2170 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2171 -$(NOECHO) $(DOC_INSTALL) \
2172 "Module" "$(NAME)" \
2173 "installed into" "$(INSTALLVENDORLIB)" \
2174 LINKTYPE "$(LINKTYPE)" \
2175 VERSION "$(VERSION)" \
2176 EXE_FILES "$(EXE_FILES)" \
2177 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2179 } unless $self->{NO_PERLLOCAL};
2182 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2185 uninstall_from_perldirs ::
2186 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2188 uninstall_from_sitedirs ::
2189 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2191 uninstall_from_vendordirs ::
2192 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2198 =item installbin (o)
2200 Defines targets to make and to install EXE_FILES.
2207 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2208 my @exefiles = @{$self->{EXE_FILES}};
2209 return "" unless @exefiles;
2211 @exefiles = map vmsify($_), @exefiles if $Is{VMS};
2214 for my $from (@exefiles) {
2215 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2217 local($_) = $path; # for backwards compatibility
2218 my $to = $self->libscan($path);
2219 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2221 $to = vmsify($to) if $Is{VMS};
2222 $fromto{$from} = $to;
2224 my @to = values %fromto;
2228 EXE_FILES = @exefiles
2236 # realclean can get rather large.
2237 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2241 # A target for each exe file.
2242 while (my($from,$to) = each %fromto) {
2243 last unless defined $from;
2245 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
2246 %s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2247 $(NOECHO) $(RM_F) %s
2250 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
2262 Defines the linkext target which in turn defines the LINKTYPE.
2267 my($self, %attribs) = @_;
2268 # LINKTYPE => static or dynamic or ''
2269 my($linktype) = defined $attribs{LINKTYPE} ?
2270 $attribs{LINKTYPE} : '$(LINKTYPE)';
2272 linkext :: $linktype
2279 Takes as arguments a directory name and a regular expression. Returns
2280 all entries in the directory that match the regular expression.
2286 my($dir, $regex) = @_;
2288 my $dh = new DirHandle;
2289 $dh->open($dir || ".") or return ();
2292 @ls = grep(/$regex/, @ls) if $regex;
2298 Simple subroutine to insert the macros defined by the macro attribute
2304 my($self,%attribs) = @_;
2306 while (($key,$val) = each %attribs){
2307 last unless defined $key;
2308 push @m, "$key = $val\n";
2315 Called by staticmake. Defines how to write the Makefile to produce a
2318 By default the Makefile produced includes all the static extensions in
2319 the perl library. (Purified versions of library files, e.g.,
2320 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2325 my($self, %attribs) = @_;
2326 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2327 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2330 # --- MakeMaker makeaperl section ---
2331 MAP_TARGET = $target
2332 FULLPERL = $self->{FULLPERL}
2334 return join '', @m if $self->{PARENT};
2336 my($dir) = join ":", @{$self->{DIR}};
2338 unless ($self->{MAKEAPERL}) {
2340 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2341 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
2343 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
2344 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2345 $(NOECHO) $(PERLRUNINST) \
2346 Makefile.PL DIR=}, $dir, q{ \
2347 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2348 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2354 push @m, " \\\n\t\t$_";
2356 # push @m, map( " \\\n\t\t$_", @ARGV );
2364 my($cccmd, $linkcmd, $lperl);
2367 $cccmd = $self->const_cccmd($libperl);
2368 $cccmd =~ s/^CCCMD\s*=\s*//;
2369 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2370 $cccmd .= " $Config{cccdlflags}"
2371 if ($Config{useshrplib} eq 'true');
2372 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2374 # The front matter of the linkcommand...
2375 $linkcmd = join ' ', "\$(CC)",
2376 grep($_, @Config{qw(ldflags ccdlflags)});
2377 $linkcmd =~ s/\s+/ /g;
2378 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2380 # Which *.a files could we make use of...
2383 File::Find::find(sub {
2384 return unless m/\Q$self->{LIB_EXT}\E$/;
2386 # Skip perl's libraries.
2387 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2389 # Skip purified versions of libraries
2390 # (e.g., DynaLoader_pure_p1_c0_032.a)
2391 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2393 if( exists $self->{INCLUDE_EXT} ){
2396 (my $xx = $File::Find::name) =~ s,.*?/auto/,,s;
2400 # Throw away anything not explicitly marked for inclusion.
2401 # DynaLoader is implied.
2402 foreach my $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2408 return unless $found;
2410 elsif( exists $self->{EXCLUDE_EXT} ){
2411 (my $xx = $File::Find::name) =~ s,.*?/auto/,,s;
2415 # Throw away anything explicitly marked for exclusion
2416 foreach my $excl (@{$self->{EXCLUDE_EXT}}){
2417 return if( $xx eq $excl );
2421 # don't include the installed version of this extension. I
2422 # leave this line here, although it is not necessary anymore:
2423 # I patched minimod.PL instead, so that Miniperl.pm won't
2424 # include duplicates
2426 # Once the patch to minimod.PL is in the distribution, I can
2428 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2430 $static{cwd() . "/" . $_}++;
2431 }, grep( -d $_, @{$searchdirs || []}) );
2433 # We trust that what has been handed in as argument, will be buildable
2434 $static = [] unless $static;
2435 @static{@{$static}} = (1) x @{$static};
2437 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2438 for (sort keys %static) {
2439 next unless /\Q$self->{LIB_EXT}\E\z/;
2440 $_ = dirname($_) . "/extralibs.ld";
2444 s/^(.*)/"-I$1"/ for @{$perlinc || []};
2449 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2450 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2451 # extralibs.all are computed correctly
2453 MAP_LINKCMD = $linkcmd
2454 MAP_PERLINC = @{$perlinc || []}
2456 join(" \\\n\t", reverse sort keys %static), "
2458 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2461 if (defined $libperl) {
2462 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2464 unless ($libperl && -f $lperl) { # Ilya's code...
2465 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2466 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2467 $libperl ||= "libperl$self->{LIB_EXT}";
2468 $libperl = "$dir/$libperl";
2469 $lperl ||= "libperl$self->{LIB_EXT}";
2470 $lperl = "$dir/$lperl";
2472 if (! -f $libperl and ! -f $lperl) {
2473 # We did not find a static libperl. Maybe there is a shared one?
2475 $lperl = $libperl = "$dir/$Config{libperl}";
2476 # SUNOS ld does not take the full path to a shared library
2477 $libperl = '' if $Is{SunOS4};
2481 print "Warning: $libperl not found
2482 If you're going to build a static perl binary, make sure perl is installed
2483 otherwise ignore this warning\n"
2484 unless (-f $lperl || defined($self->{PERL_SRC}));
2487 # SUNOS ld does not take the full path to a shared library
2488 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2491 MAP_LIBPERL = $libperl
2492 LLIBPERL = $llibperl
2496 $(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
2497 $(NOECHO) $(RM_F) $@
2498 $(NOECHO) $(TOUCH) $@
2501 foreach my $catfile (@$extra){
2502 push @m, "\tcat $catfile >> \$\@\n";
2506 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2507 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2508 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2509 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2510 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2511 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
2513 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2515 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
2518 $tmp/perlmain.c: $makefilename}, q{
2519 $(NOECHO) $(ECHO) Writing $@
2520 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2521 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2524 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2525 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2530 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2531 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2532 -$(NOECHO) $(DOC_INSTALL) \
2533 "Perl binary" "$(MAP_TARGET)" \
2534 MAP_STATIC "$(MAP_STATIC)" \
2535 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2536 MAP_LIBPERL "$(MAP_LIBPERL)" \
2537 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2542 inst_perl : pure_inst_perl doc_inst_perl
2544 pure_inst_perl : $(MAP_TARGET)
2545 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2550 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2558 Defines how to rewrite the Makefile.
2565 # We do not know what target was originally specified so we
2566 # must force a manual rerun to be sure. But as it should only
2567 # happen very rarely it is not a significant problem.
2569 $(OBJECT) : $(FIRST_MAKEFILE)
2571 ' if $self->{OBJECT};
2573 my $newer_than_target = $Is{VMS} ? '$(MMS$SOURCE_LIST)' : '$?';
2574 my $mpl_args = join " ", map qq["$_"], @ARGV;
2576 if (defined $::Cross::platform) {
2577 # Inherited from win32/buildext.pl
2578 $cross = "-MCross=$::Cross::platform ";
2580 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $cross, $mpl_args;
2581 # We take a very conservative approach here, but it's worth it.
2582 # We move Makefile to Makefile.old here to avoid gnu make looping.
2583 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2584 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
2585 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2586 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2587 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2588 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2589 $(PERLRUN) %sMakefile.PL %s
2590 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2591 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
2602 Returns true, if the argument is likely to be a command.
2607 my($self,$file) = @_;
2608 return $file if -x $file && ! -d $file;
2613 =item needs_linking (o)
2615 Does this module need linking? Looks into subdirectory objects (see
2616 also has_link_code())
2623 my $caller = (caller(0))[3];
2624 confess("needs_linking called too early") if
2625 $caller =~ /^ExtUtils::MakeMaker::/;
2626 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2627 if ($self->has_link_code or $self->{MAKEAPERL}){
2628 $self->{NEEDS_LINKING} = 1;
2631 foreach my $child (keys %{$self->{CHILDREN}}) {
2632 if ($self->{CHILDREN}->{$child}->needs_linking) {
2633 $self->{NEEDS_LINKING} = 1;
2637 return $self->{NEEDS_LINKING} = 0;
2641 =item parse_abstract
2643 parse a file and return what you think is the ABSTRACT
2647 sub parse_abstract {
2648 my($self,$parsefile) = @_;
2652 open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!";
2654 my $package = $self->{DISTNAME};
2655 $package =~ s/-/::/g;
2657 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2660 if ( /^($package(?:\.pm)? \s+ -+ \s+)(.*)/x ) {
2664 next unless $result;
2665 if ( $result && ( /^\s*$/ || /^\=/ ) ) {
2668 $result = join ' ', $result, $_;
2677 my $version = MM->parse_version($file);
2679 Parse a $file and return what $VERSION is set to by the first assignment.
2680 It will return the string "undef" if it can't figure out what $VERSION
2681 is. $VERSION should be for all to see, so C<our $VERSION> or plain $VERSION
2682 are okay, but C<my $VERSION> is not.
2684 C<<package Foo VERSION>> is also checked for. The first version
2685 declaration found is used, but this may change as it differs from how
2688 parse_version() will try to C<use version> before checking for
2689 C<$VERSION> so the following will work.
2691 $VERSION = qv(1.2.3);
2696 my($self,$parsefile) = @_;
2701 open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!";
2704 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2705 next if $inpod || /^\s*#/;
2707 next if /^\s*(if|unless|elsif)/;
2708 if ( m{^ \s* package \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* ; }x ) {
2712 elsif ( m{(?<!\\) ([\$*]) (([\w\:\']*) \bVERSION)\b .* (?<![<>=!])\=[^=]}x ) {
2713 $result = $self->get_version($parsefile, $1, $2);
2718 last if defined $result;
2722 if ( defined $result && $result !~ /^v?[\d_\.]+$/ ) {
2724 my $normal = eval { version->parse( $result ) };
2725 $result = $normal if defined $normal;
2727 $result = "undef" unless defined $result;
2733 my ($self, $parsefile, $sigil, $name) = @_;
2735 package ExtUtils::MakeMaker::_version;
2738 # Ensure any version() routine which might have leaked
2739 # into this package has been deleted. Interferes with
2753 $eval = $1 if $eval =~ m{^(.+)}s;
2755 my $result = eval($eval); ## no critic
2756 warn "Could not eval '$eval' in $parsefile: $@" if $@;
2763 Defines the string that is passed to recursive make calls in
2773 my($sep) = $Is{VMS} ? ',' : '';
2776 foreach my $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
2777 PREFIX INSTALL_BASE)
2780 next unless defined $self->{$key};
2781 push @pasthru, "$key=\"\$($key)\"";
2784 foreach my $key (qw(DEFINE INC)) {
2785 next unless defined $self->{$key};
2786 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
2789 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
2795 Takes one argument, a file name, and returns the file name, if the
2796 argument is likely to be a perl script. On MM_Unix this is true for
2797 any ordinary, readable file.
2802 my($self,$file) = @_;
2803 return $file if -r $file && -f _;
2807 =item perldepend (o)
2809 Defines the dependency from all *.h files that come with the perl
2818 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
2820 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
2821 # Check for unpropogated config.sh changes. Should never happen.
2822 # We do NOT just update config.h because that is not sufficient.
2823 # An out of date config.h is not fatal but complains loudly!
2824 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2825 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; $(FALSE)
2827 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2828 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2832 return join "", @m unless $self->needs_linking;
2834 if ($self->{OBJECT}) {
2835 # Need to add an object file dependency on the perl headers.
2836 # this is very important for XS modules in perl.git development.
2837 push @m, $self->_perl_header_files_fragment("/"); # Directory separator between $(PERL_INC)/header.h
2840 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2842 return join "\n", @m;
2848 Defines target that copies all files in the hash PM to their
2849 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
2855 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2857 pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)
2860 # VMS will swallow '' and PM_FILTER is often empty. So use q[]
2861 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
2862 pm_to_blib({\@ARGV}, '$autodir', q[\$(PM_FILTER)], '\$(PERM_DIR)')
2865 my @cmds = $self->split_command($pm_to_blib,
2866 map { ($_, $self->{PM}->{$_}) } sort keys %{$self->{PM}});
2868 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
2869 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
2874 =item post_constants (o)
2876 Returns an empty string per default. Dedicated to overrides from
2877 within Makefile.PL after all constants have been defined.
2885 =item post_initialize (o)
2887 Returns an empty string per default. Used in Makefile.PLs to add some
2888 chunk of text to the Makefile after the object is initialized.
2892 sub post_initialize {
2898 Returns an empty string. Can be used in Makefile.PLs to write some
2899 text to the Makefile at the end.
2907 # transform dot-separated version string into comma-separated quadruple
2908 # examples: '1.2.3.4.5' => '1,2,3,4'
2909 # '1.2.3' => '1,2,3,0'
2911 my ($self, $string) = @_;
2912 return join ',', ((split /\./, $string), (0) x 4)[0..3];
2917 Defines target that creates a PPD (Perl Package Description) file
2918 for a binary distribution.
2925 my $abstract = $self->{ABSTRACT} || '';
2926 $abstract =~ s/\n/\\n/sg;
2927 $abstract =~ s/</</g;
2928 $abstract =~ s/>/>/g;
2930 my $author = join(', ',@{$self->{AUTHOR} || []});
2931 $author =~ s/</</g;
2932 $author =~ s/>/>/g;
2934 my $ppd_file = '$(DISTNAME).ppd';
2936 my @ppd_cmds = $self->echo(<<'PPD_HTML', $ppd_file, { append => 0, allow_variables => 1 });
2937 <SOFTPKG NAME="$(DISTNAME)" VERSION="$(VERSION)">
2940 my $ppd_xml = sprintf <<'PPD_HTML', $abstract, $author;
2941 <ABSTRACT>%s</ABSTRACT>
2945 $ppd_xml .= " <IMPLEMENTATION>\n";
2946 if ( $self->{MIN_PERL_VERSION} ) {
2947 my $min_perl_version = $self->_ppd_version($self->{MIN_PERL_VERSION});
2948 $ppd_xml .= sprintf <<'PPD_PERLVERS', $min_perl_version;
2949 <PERLCORE VERSION="%s" />
2954 # Don't add "perl" to requires. perl dependencies are
2955 # handles by ARCHITECTURE.
2956 my %prereqs = %{$self->{PREREQ_PM}};
2957 delete $prereqs{perl};
2960 foreach my $prereq (sort keys %prereqs) {
2962 $name .= '::' unless $name =~ /::/;
2963 my $version = $prereqs{$prereq}+0; # force numification
2965 my %attrs = ( NAME => $name );
2966 $attrs{VERSION} = $version if $version;
2967 my $attrs = join " ", map { qq[$_="$attrs{$_}"] } keys %attrs;
2968 $ppd_xml .= qq( <REQUIRE $attrs />\n);
2971 my $archname = $Config{archname};
2973 # archname did not change from 5.6 to 5.8, but those versions may
2974 # not be not binary compatible so now we append the part of the
2975 # version that changes when binary compatibility may change
2976 $archname .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
2978 $ppd_xml .= sprintf <<'PPD_OUT', $archname;
2979 <ARCHITECTURE NAME="%s" />
2982 if ($self->{PPM_INSTALL_SCRIPT}) {
2983 if ($self->{PPM_INSTALL_EXEC}) {
2984 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
2985 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
2988 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
2989 $self->{PPM_INSTALL_SCRIPT};
2993 if ($self->{PPM_UNINSTALL_SCRIPT}) {
2994 if ($self->{PPM_UNINSTALL_EXEC}) {
2995 $ppd_xml .= sprintf qq{ <UNINSTALL EXEC="%s">%s</UNINSTALL>\n},
2996 $self->{PPM_UNINSTALL_EXEC}, $self->{PPM_UNINSTALL_SCRIPT};
2999 $ppd_xml .= sprintf qq{ <UNINSTALL>%s</UNINSTALL>\n},
3000 $self->{PPM_UNINSTALL_SCRIPT};
3004 my ($bin_location) = $self->{BINARY_LOCATION} || '';
3005 $bin_location =~ s/\\/\\\\/g;
3007 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
3008 <CODEBASE HREF="%s" />
3013 push @ppd_cmds, $self->echo($ppd_xml, $ppd_file, { append => 1 });
3015 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3016 # Creates a PPD (Perl Package Description) for a binary distribution.
3025 $MM->prefixify($var, $prefix, $new_prefix, $default);
3027 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3028 replace it's $prefix with a $new_prefix.
3030 Should the $prefix fail to match I<AND> a PREFIX was given as an
3031 argument to WriteMakefile() it will set it to the $new_prefix +
3032 $default. This is for systems whose file layouts don't neatly fit into
3033 our ideas of prefixes.
3035 This is for heuristics which attempt to create directory structures
3036 that mirror those of the installed perl.
3040 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3042 this will attempt to remove '/usr' from the front of the
3043 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3044 if necessary) and replace it with '/home/foo'. If this fails it will
3045 simply use '/home/foo/man/man1'.
3050 my($self,$var,$sprefix,$rprefix,$default) = @_;
3052 my $path = $self->{uc $var} ||
3053 $Config_Override{lc $var} || $Config{lc $var} || '';
3055 $rprefix .= '/' if $sprefix =~ m|/$|;
3057 warn " prefixify $var => $path\n" if $Verbose >= 2;
3058 warn " from $sprefix to $rprefix\n" if $Verbose >= 2;
3060 if( $self->{ARGS}{PREFIX} &&
3061 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3064 warn " cannot prefix, using default.\n" if $Verbose >= 2;
3065 warn " no default!\n" if !$default && $Verbose >= 2;
3067 $path = $self->catdir($rprefix, $default) if $default;
3070 print " now $path\n" if $Verbose >= 2;
3071 return $self->{uc $var} = $path;
3077 Defines targets to run *.PL files.
3083 my $pl_files = $self->{PL_FILES};
3085 return "" unless $pl_files;
3088 foreach my $plfile (sort keys %$pl_files) {
3089 my $list = ref($pl_files->{$plfile})
3090 ? $pl_files->{$plfile}
3091 : [$pl_files->{$plfile}];
3093 foreach my $target (@$list) {
3095 $plfile = vmsify($self->eliminate_macros($plfile));
3096 $target = vmsify($self->eliminate_macros($target));
3099 # Normally a .PL file runs AFTER pm_to_blib so it can have
3100 # blib in its @INC and load the just built modules. BUT if
3101 # the generated module is something in $(TO_INST_PM) which
3102 # pm_to_blib depends on then it can't depend on pm_to_blib
3103 # else we have a dependency loop.
3106 if( defined $self->{PM}{$target} ) {
3108 $perlrun = 'PERLRUN';
3111 $pm_dep = 'pm_to_blib';
3112 $perlrun = 'PERLRUNINST';
3120 $target :: $plfile $pm_dep
3121 \$($perlrun) $plfile $target
3132 Backslashes parentheses C<()> in command line arguments.
3133 Doesn't handle recursive Makefile C<$(...)> constructs,
3134 but handles simple ones.
3140 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3141 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3142 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
3146 =item replace_manpage_separator
3148 my $man_name = $MM->replace_manpage_separator($file_path);
3150 Takes the name of a package, which may be a nested package, in the
3151 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3152 safe for a man page file name. Returns the replacement.
3156 sub replace_manpage_separator {
3157 my($self,$man) = @_;
3169 my($self, $dir, @cmds) = @_;
3171 # No leading tab and no trailing newline makes for easier embedding
3172 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3182 my($self, $cmd, $switches) = @_;
3183 $switches = [] unless defined $switches;
3185 # Strip leading and trailing newlines
3189 my @cmds = split /\n/, $cmd;
3190 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
3191 $cmd = $self->escape_newlines($cmd);
3193 $switches = join ' ', @$switches;
3195 return qq{\$(ABSPERLRUN) $switches -e $cmd --};
3204 my($self, $text, $opts) = @_;
3205 $opts->{allow_variables} = 1 unless defined $opts->{allow_variables};
3207 # Quote single quotes
3208 $text =~ s{'}{'\\''}g;
3210 $text = $opts->{allow_variables}
3211 ? $self->escape_dollarsigns($text) : $self->escape_all_dollarsigns($text);
3217 =item escape_newlines
3221 sub escape_newlines {
3222 my($self, $text) = @_;
3224 $text =~ s{\n}{\\\n}g;
3232 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3239 if (!defined $self->{_MAX_EXEC_LEN}) {
3240 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3241 $self->{_MAX_EXEC_LEN} = $arg_max;
3243 else { # POSIX minimum exec size
3244 $self->{_MAX_EXEC_LEN} = 4096;
3248 return $self->{_MAX_EXEC_LEN};
3254 Defines the static target.
3259 # --- Static Loading Sections ---
3263 ## $(INST_PM) has been moved to the all: target.
3264 ## It remains here for awhile to allow for old usage: "make static"
3265 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3270 =item static_lib (o)
3272 Defines how to produce the *.a (or equivalent) files.
3278 return '' unless $self->has_link_code;
3283 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
3287 # If this extension has its own library (eg SDBM_File)
3288 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3289 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3290 $(CP) $(MYEXTLIB) $@
3294 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3295 # Prefer the absolute pathed ar if available so that PATH
3296 # doesn't confuse us. Perl itself is built with the full_ar.
3301 push @m, sprintf <<'MAKE_FRAG', $ar;
3302 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3303 $(CHMOD) $(PERM_RWX) $@
3304 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3307 # Old mechanism - still available:
3308 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3309 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3315 =item staticmake (o)
3322 my($self, %attribs) = @_;
3325 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3327 # And as it's not yet built, we add the current extension
3328 # but only if it has some C code (or XS code, which implies C code)
3329 if (@{$self->{C}}) {
3330 @static = $self->catfile($self->{INST_ARCHLIB},
3333 "$self->{BASEEXT}$self->{LIB_EXT}"
3337 # Either we determine now, which libraries we will produce in the
3338 # subdirectories or we do it at runtime of the make.
3340 # We could ask all subdir objects, but I cannot imagine, why it
3341 # would be necessary.
3343 # Instead we determine all libraries for the new perl at
3345 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3347 $self->makeaperl(MAKE => $self->{MAKEFILE},
3348 DIRS => \@searchdirs,
3351 TARGET => $self->{MAP_TARGET},
3353 LIBPERL => $self->{LIBPERL_A}
3359 Helper subroutine for subdirs
3364 my($self, $subdir) = @_;
3366 my $subdir_cmd = $self->cd($subdir,
3367 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3369 return sprintf <<'EOT', $subdir_cmd;
3379 Defines targets to process subdirectories.
3384 # --- Sub-directory Sections ---
3387 # This method provides a mechanism to automatically deal with
3388 # subdirectories containing further Makefile.PL scripts.
3389 # It calls the subdir_x() method for each subdirectory.
3390 foreach my $dir (@{$self->{DIR}}){
3391 push(@m, $self->subdir_x($dir));
3392 #### print "Including $dir subdirectory\n";
3396 # The default clean, realclean and test targets in this Makefile
3397 # have automatically been given entries for each subdir.
3401 push(@m, "\n# none")
3408 Defines the test targets.
3413 # --- Test and Installation Sections ---
3415 my($self, %attribs) = @_;
3416 my $tests = $attribs{TESTS} || '';
3417 if (!$tests && -d 't' && defined $attribs{RECURSIVE_TEST_FILES}) {
3418 $tests = $self->find_tests_recursive;
3420 elsif (!$tests && -d 't') {
3421 $tests = $self->find_tests;
3423 # note: 'test.pl' name is also hardcoded in init_dirscan()
3427 TEST_TYPE=test_\$(LINKTYPE)
3432 testdb :: testdb_\$(LINKTYPE)
3434 test :: \$(TEST_TYPE) subdirs-test
3441 foreach my $dir (@{ $self->{DIR} }) {
3442 my $test = $self->cd($dir, '$(MAKE) test $(PASTHRU)');
3451 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3452 unless $tests or -f "test.pl" or @{$self->{DIR}};
3455 push(@m, "test_dynamic :: pure_all\n");
3456 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3458 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3462 push(@m, "testdb_dynamic :: pure_all\n");
3463 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3467 # Occasionally we may face this degenerate target:
3468 push @m, "test_ : test_dynamic\n\n";
3470 if ($self->needs_linking()) {
3471 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3472 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3473 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3475 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3476 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3479 push @m, "test_static :: test_dynamic\n";
3480 push @m, "testdb_static :: testdb_dynamic\n";
3485 =item test_via_harness (override)
3487 For some reason which I forget, Unix machines like to have
3488 PERL_DL_NONLAZY set for tests.
3492 sub test_via_harness {
3493 my($self, $perl, $tests) = @_;
3494 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3497 =item test_via_script (override)
3499 Again, the PERL_DL_NONLAZY thing.
3503 sub test_via_script {
3504 my($self, $perl, $script) = @_;
3505 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3509 =item tool_xsubpp (o)
3511 Determines typemaps, xsubpp version, prototype behaviour.
3517 return "" unless $self->needs_linking;
3520 my @xsubpp_dirs = @INC;
3522 # Make sure we pick up the new xsubpp if we're building perl.
3523 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3525 my $foundxsubpp = 0;
3526 foreach my $dir (@xsubpp_dirs) {
3527 $xsdir = $self->catdir($dir, 'ExtUtils');
3528 if( -r $self->catfile($xsdir, "xsubpp") ) {
3533 die "ExtUtils::MM_Unix::tool_xsubpp : Can't find xsubpp" if !$foundxsubpp;
3535 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3536 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3537 if( $self->{TYPEMAPS} ){
3538 foreach my $typemap (@{$self->{TYPEMAPS}}){
3539 if( ! -f $typemap ) {
3540 warn "Typemap $typemap not found.\n";
3543 push(@tmdeps, $typemap);
3547 push(@tmdeps, "typemap") if -f "typemap";
3548 my(@tmargs) = map("-typemap $_", @tmdeps);
3549 if( exists $self->{XSOPT} ){
3550 unshift( @tmargs, $self->{XSOPT} );
3554 $Config{'ldflags'} &&
3555 $Config{'ldflags'} =~ m!/Debug!i &&
3556 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
3559 unshift(@tmargs,'-nolinenumbers');
3563 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3567 XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp
3568 XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
3569 XSPROTOARG = $self->{XSPROTOARG}
3570 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3571 XSUBPPARGS = @tmargs
3579 Build man pages, too
3586 return <<'MAKE_EXT';
3587 all :: pure_all manifypods
3592 =item top_targets (o)
3594 Defines the targets all, subdirs, config, and O_FILES
3599 # --- Target Sections ---
3604 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3607 pure_all :: config pm_to_blib subdirs linkext
3610 subdirs :: $(MYEXTLIB)
3613 config :: $(FIRST_MAKEFILE) blibdirs
3618 $(O_FILES): $(H_FILES)
3619 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3623 perldoc ExtUtils::MakeMaker
3631 Obsolete, deprecated method. Not used since Version 5.21.
3636 # --- perllocal.pod section ---
3637 my($self,$what,$name,@attribs)=@_;
3638 my $time = localtime;
3639 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3640 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3641 print "\n\n=back\n\n";
3646 Defines the suffix rules to compile XS files to C.
3652 return '' unless $self->needs_linking();
3655 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3661 Defines the suffix rules to compile XS files to C++.
3667 return '' unless $self->needs_linking();
3670 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
3676 Defines suffix rules to go from XS to object files directly. This is
3677 only intended for broken make implementations.
3681 sub xs_o { # many makes are too dumb to use xs_c then c_o
3683 return '' unless $self->needs_linking();
3686 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3687 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
3698 L<ExtUtils::MakeMaker>