1 package ExtUtils::MM_Unix;
3 require 5.005_03; # Maybe further back, dunno
8 use ExtUtils::MakeMaker::Config;
9 use File::Basename qw(basename dirname);
12 use vars qw($VERSION @ISA
13 $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos
14 $Is_OSF $Is_IRIX $Is_NetBSD $Is_BSD
15 $Is_SunOS4 $Is_Solaris $Is_SunOS $Is_Interix
19 use ExtUtils::MakeMaker qw($Verbose neatvalue);
23 require ExtUtils::MM_Any;
24 @ISA = qw(ExtUtils::MM_Any);
27 $Is_OS2 = $^O eq 'os2';
28 $Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
29 $Is_Dos = $^O eq 'dos';
30 $Is_VMS = $^O eq 'VMS';
31 $Is_OSF = $^O eq 'dec_osf';
32 $Is_IRIX = $^O eq 'irix';
33 $Is_NetBSD = $^O eq 'netbsd';
34 $Is_Interix = $^O eq 'interix';
35 $Is_SunOS4 = $^O eq 'sunos';
36 $Is_Solaris = $^O eq 'solaris';
37 $Is_SunOS = $Is_SunOS4 || $Is_Solaris;
38 $Is_BSD = $^O =~ /^(?:free|net|open)bsd$/ or
39 $^O eq 'bsdos' or $^O eq 'interix';
44 # For things like vmsify()
45 require VMS::Filespec;
46 VMS::Filespec->import;
53 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
57 C<require ExtUtils::MM_Unix;>
61 The methods provided by this package are designed to be used in
62 conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
63 Makefile, it creates one or more objects that inherit their methods
64 from a package C<MM>. MM itself doesn't provide any methods, but it
65 ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
66 specific packages take the responsibility for all the methods provided
67 by MM_Unix. We are trying to reduce the number of the necessary
68 overrides by defining rather primitive operations within
71 If you are going to write a platform specific MM package, please try
72 to limit the necessary overrides to primitive methods, and if it is not
73 possible to do so, let's work out how to achieve that gain.
75 If you are overriding any of these methods in your Makefile.PL (in the
76 MY class), please report that to the makemaker mailing list. We are
77 trying to minimize the necessary method overrides and switch to data
78 driven Makefile.PLs wherever possible. In the long run less methods
79 will be overridable via the MY class.
83 The following description of methods is still under
84 development. Please refer to the code for not suitably documented
85 sections and complain loudly to the makemaker@perl.org mailing list.
86 Better yet, provide a patch.
88 Not all of the methods below are overridable in a
89 Makefile.PL. Overridable methods are marked as (o). All methods are
90 overridable by a platform specific MM_*.pm file.
92 Cross-platform methods are being moved into MM_Any. If you can't find
93 something that used to be in here, look in MM_Any.
97 # So we don't have to keep calling the methods over and over again,
98 # we have these globals to cache the values. Faster and shrtr.
99 my $Curdir = __PACKAGE__->curdir;
100 my $Rootdir = __PACKAGE__->rootdir;
101 my $Updir = __PACKAGE__->updir;
110 Simply says that we're Unix.
121 Defines the suffix rules to compile different flavors of C files to
127 # --- Translation Sections ---
130 return '' unless $self->needs_linking();
132 if (my $cpp = $Config{cpprun}) {
133 my $cpp_cmd = $self->const_cccmd;
134 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/;
137 '. $cpp_cmd . ' $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i
142 $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
146 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
150 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C
151 ' if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific
154 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp
157 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx
160 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc
167 Does very much the same as the cflags script in the perl
168 distribution. It doesn't return the whole compiler command line, but
169 initializes all of its parts. The const_cccmd method then actually
170 returns the definition of the CCCMD macro which uses these parts.
177 my($self,$libperl)=@_;
178 return $self->{CFLAGS} if $self->{CFLAGS};
179 return '' unless $self->needs_linking();
181 my($prog, $uc, $perltype, %cflags);
182 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
183 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
185 @cflags{qw(cc ccflags optimize shellflags)}
186 = @Config{qw(cc ccflags optimize shellflags)};
189 $cflags{shellflags} ||= '';
194 DE => '-DDEBUGGING -DEMBED',
195 M => '-DEMBED -DMULTIPLICITY',
196 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
199 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
202 $uc = ""; # avoid warning
204 $perltype = $map{$uc} ? $map{$uc} : "";
212 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
213 if ($prog = $Config{$name}) {
214 # Expand hints for this extension via the shell
215 print STDOUT "Processing $name hint:\n" if $Verbose;
216 my(@o)=`cc=\"$cflags{cc}\"
217 ccflags=\"$cflags{ccflags}\"
218 optimize=\"$cflags{optimize}\"
219 perltype=\"$cflags{perltype}\"
220 optdebug=\"$cflags{optdebug}\"
223 echo ccflags=\$ccflags
224 echo optimize=\$optimize
225 echo perltype=\$perltype
226 echo optdebug=\$optdebug
231 if ($line =~ /(.*?)=\s*(.*)\s*$/){
233 print STDOUT " $1 = $2\n" if $Verbose;
235 print STDOUT "Unrecognised result from hint: '$line'\n";
241 $cflags{optimize} = $optdebug;
244 for (qw(ccflags optimize perltype)) {
246 $cflags{$_} =~ s/^\s+//;
247 $cflags{$_} =~ s/\s+/ /g;
248 $cflags{$_} =~ s/\s+$//;
249 $self->{uc $_} ||= $cflags{$_};
252 if ($self->{POLLUTE}) {
253 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
257 if ($Config{usemymalloc} and not $Config{bincompat5005}
258 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
259 and $self->{PERL_MALLOC_OK}) {
260 $pollute = '$(PERL_MALLOC_DEF)';
263 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS});
264 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE});
266 return $self->{CFLAGS} = qq{
267 CCFLAGS = $self->{CCFLAGS}
268 OPTIMIZE = $self->{OPTIMIZE}
269 PERLTYPE = $self->{PERLTYPE}
276 =item const_cccmd (o)
278 Returns the full compiler call for C programs and stores the
279 definition in CONST_CCCMD.
284 my($self,$libperl)=@_;
285 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
286 return '' unless $self->needs_linking();
287 return $self->{CONST_CCCMD} =
288 q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
289 $(CCFLAGS) $(OPTIMIZE) \\
290 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
291 $(XS_DEFINE_VERSION)};
294 =item const_config (o)
296 Defines a couple of constants in the Makefile that are imported from
302 # --- Constants Sections ---
306 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
307 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
309 foreach $m (@{$self->{CONFIG}}){
310 # SITE*EXP macros are defined in &constants; avoid duplicates here
311 next if $once_only{$m};
312 $self->{uc $m} = quote_paren($self->{uc $m});
313 push @m, uc($m) , ' = ' , $self->{uc $m}, "\n";
319 =item const_loadlibs (o)
321 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
322 L<ExtUtils::Liblist> for details.
328 return "" unless $self->needs_linking;
331 # $self->{NAME} might depend on some other libraries:
332 # See ExtUtils::Liblist for details
337 EXTRALIBS LDLOADLIBS BSLOADLIBS
339 next unless defined $self->{$tmp};
340 push @m, "$tmp = $self->{$tmp}\n";
342 # don't set LD_RUN_PATH if empty
346 next unless $self->{$tmp};
347 push @m, "$tmp = $self->{$tmp}\n";
354 my $make_frag = $mm->constants;
356 Prints out macros for lots of constants.
364 $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use
368 AR_STATIC_ARGS DIRFILESEP DFSEP
370 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
371 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
372 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
373 INST_MAN1DIR INST_MAN3DIR
375 INSTALLDIRS INSTALL_BASE DESTDIR PREFIX
376 PERLPREFIX SITEPREFIX VENDORPREFIX
378 (map { ("INSTALL".$_,
380 } $self->installvars),
385 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
386 PERLMAINCC PERL_SRC PERL_INC
387 PERL FULLPERL ABSPERL
388 PERLRUN FULLPERLRUN ABSPERLRUN
389 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
395 next unless defined $self->{$macro};
397 # pathnames can have sharp signs in them; escape them so
398 # make doesn't think it is a comment-start character.
399 $self->{$macro} =~ s/#/\\#/g;
400 push @m, "$macro = $self->{$macro}\n";
404 MAKEMAKER = $self->{MAKEMAKER}
405 MM_VERSION = $self->{MM_VERSION}
406 MM_REVISION = $self->{MM_REVISION}
410 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
411 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
412 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
413 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
418 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
419 LDFROM LINKTYPE BOOTDEP
422 next unless defined $self->{$macro};
423 push @m, "$macro = $self->{$macro}\n";
427 # Handy lists of source code files:
428 XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
429 C_FILES = ".$self->wraplist(@{$self->{C}})."
430 O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."
431 H_FILES = ".$self->wraplist(@{$self->{H}})."
432 MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
433 MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
438 # Where is the Config information that we are using/depend on
439 CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
444 # Where to build things
445 INST_LIBDIR = $self->{INST_LIBDIR}
446 INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
448 INST_AUTODIR = $self->{INST_AUTODIR}
449 INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
451 INST_STATIC = $self->{INST_STATIC}
452 INST_DYNAMIC = $self->{INST_DYNAMIC}
453 INST_BOOT = $self->{INST_BOOT}
459 EXPORT_LIST = $self->{EXPORT_LIST}
460 PERL_ARCHIVE = $self->{PERL_ARCHIVE}
461 PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
466 TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."
468 PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}})."
477 Same as macro for the depend attribute.
482 my($self,%attribs) = @_;
484 while (($key,$val) = each %attribs){
485 last unless defined $key;
486 push @m, "$key : $val\n";
496 Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
504 $self->{DESTDIR} ||= '';
506 # Make DEST variables.
507 foreach my $var ($self->installvars) {
508 my $destvar = 'DESTINSTALL'.$var;
509 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
518 Defines a lot of macros for distribution support.
520 macro description default
522 TAR tar command to use tar
523 TARFLAGS flags to pass to TAR cvf
525 ZIP zip command to use zip
526 ZIPFLAGS flags to pass to ZIP -r
528 COMPRESS compression command to gzip --best
530 SUFFIX suffix to put on .gz
533 SHAR shar command to use shar
535 PREOP extra commands to run before
537 POSTOP extra commands to run after
540 TO_UNIX a command to convert linefeeds
541 to Unix style in your archive
543 CI command to checkin your ci -u
544 sources to version control
545 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
548 DIST_CP $how argument to manicopy() best
549 when the distdir is created
551 DIST_DEFAULT default target to use to tardist
552 create a distribution
554 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
562 $self->{TAR} ||= 'tar';
563 $self->{TARFLAGS} ||= 'cvf';
564 $self->{ZIP} ||= 'zip';
565 $self->{ZIPFLAGS} ||= '-r';
566 $self->{COMPRESS} ||= 'gzip --best';
567 $self->{SUFFIX} ||= '.gz';
568 $self->{SHAR} ||= 'shar';
569 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
570 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
571 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
573 $self->{CI} ||= 'ci -u';
574 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
575 $self->{DIST_CP} ||= 'best';
576 $self->{DIST_DEFAULT} ||= 'tardist';
578 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
579 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
585 my $dist_macros = $mm->dist(%overrides);
587 Generates a make fragment defining all the macros initialized in
590 %overrides can be used to override any of the above.
595 my($self, %attribs) = @_;
599 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
601 CI RCS_LABEL DIST_CP DIST_DEFAULT
605 my $value = $attribs{$key} || $self->{$key};
606 $make .= "$key = $value\n";
612 =item dist_basics (o)
614 Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
621 return <<'MAKE_FRAG';
622 distclean :: realclean distcheck
626 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
629 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
632 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
634 veryclean : realclean
635 $(RM_F) *~ *.orig */*~ */*.orig
643 Defines a check in target for RCS.
651 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\
652 -e "@all = keys %{ maniread() };" \\
653 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\
654 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
660 my $dist_make_fragment = $MM->dist_core;
662 Puts the targets necessary for 'make dist' together into one make
671 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
674 my $method = $target.'_target';
676 $make_frag .= $self->$method();
685 my $make_frag = $MM->dist_target;
687 Returns the 'dist' target to make an archive for distribution. This
688 target simply checks to make sure the Makefile is up-to-date and
689 depends on $(DIST_DEFAULT).
696 my $date_check = $self->oneliner(<<'CODE', ['-l']);
697 print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
698 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
701 return sprintf <<'MAKE_FRAG', $date_check;
702 dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
707 =item B<tardist_target>
709 my $make_frag = $MM->tardist_target;
711 Returns the 'tardist' target which is simply so 'make tardist' works.
712 The real work is done by the dynamically named tardistfile_target()
713 method, tardist should have that as a dependency.
720 return <<'MAKE_FRAG';
721 tardist : $(DISTVNAME).tar$(SUFFIX)
726 =item B<zipdist_target>
728 my $make_frag = $MM->zipdist_target;
730 Returns the 'zipdist' target which is simply so 'make zipdist' works.
731 The real work is done by the dynamically named zipdistfile_target()
732 method, zipdist should have that as a dependency.
739 return <<'MAKE_FRAG';
740 zipdist : $(DISTVNAME).zip
745 =item B<tarfile_target>
747 my $make_frag = $MM->tarfile_target;
749 The name of this target is the name of the tarball generated by
750 tardist. This target does the actual work of turning the distdir into
758 return <<'MAKE_FRAG';
759 $(DISTVNAME).tar$(SUFFIX) : distdir
762 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
763 $(RM_RF) $(DISTVNAME)
764 $(COMPRESS) $(DISTVNAME).tar
771 my $make_frag = $MM->zipfile_target;
773 The name of this target is the name of the zip file generated by
774 zipdist. This target does the actual work of turning the distdir into
782 return <<'MAKE_FRAG';
783 $(DISTVNAME).zip : distdir
785 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
786 $(RM_RF) $(DISTVNAME)
791 =item uutardist_target
793 my $make_frag = $MM->uutardist_target;
795 Converts the tarfile into a uuencoded file
799 sub uutardist_target {
802 return <<'MAKE_FRAG';
803 uutardist : $(DISTVNAME).tar$(SUFFIX)
804 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
811 my $make_frag = $MM->shdist_target;
813 Converts the distdir into a shell archive.
820 return <<'MAKE_FRAG';
823 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
824 $(RM_RF) $(DISTVNAME)
832 Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files.
834 Normally just returns an empty string.
845 Defines targets for bootstrap files.
850 my($self, %attribs) = @_;
853 ' unless $self->has_link_code();
855 my $target = $Is_VMS ? '$(MMS$TARGET)' : '$@';
857 return sprintf <<'MAKE_FRAG', ($target) x 5;
858 BOOTSTRAP = $(BASEEXT).bs
860 # As Mkbootstrap might not write a file (if none is required)
861 # we use touch to prevent make continually trying to remake it.
862 # The DynaLoader only reads a non-empty file.
863 $(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
864 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
865 $(NOECHO) $(PERLRUN) \
866 "-MExtUtils::Mkbootstrap" \
867 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
868 $(NOECHO) $(TOUCH) %s
869 $(CHMOD) $(PERM_RW) %s
871 $(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
872 $(NOECHO) $(RM_RF) %s
873 - $(CP) $(BOOTSTRAP) %s
874 $(CHMOD) $(PERM_RW) %s
878 =item dynamic_lib (o)
880 Defines how to produce the *.so (or equivalent) files.
885 my($self, %attribs) = @_;
886 return '' unless $self->needs_linking(); #might be because of a subdir
888 return '' unless $self->has_link_code;
890 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
891 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
892 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
893 my($ldfrom) = '$(LDFROM)';
894 $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':');
896 my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
897 my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : '';
899 # This section creates the dynamically loadable $(INST_DYNAMIC)
900 # from $(OBJECT) and possibly $(MYEXTLIB).
901 ARMAYBE = '.$armaybe.'
902 OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
903 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
904 INST_DYNAMIC_FIX = '.$ld_fix.'
906 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
908 if ($armaybe ne ':'){
909 $ldfrom = 'tmp$(LIB_EXT)';
910 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
911 push(@m,' $(RANLIB) '."$ldfrom\n");
913 $ldfrom = "-all $ldfrom -none" if $Is_OSF;
915 # The IRIX linker doesn't use LD_RUN_PATH
916 my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ?
917 qq{-rpath "$self->{LD_RUN_PATH}"} : '';
919 # For example in AIX the shared objects/libraries from previous builds
920 # linger quite a while in the shared dynalinker cache even when nobody
921 # is using them. This is painful if one for instance tries to restart
922 # a failed build because the link command will fail unnecessarily 'cos
923 # the shared object/library is 'busy'.
927 my $libs = '$(LDLOADLIBS)';
929 if (($Is_NetBSD || $Is_Interix) && $Config{'useshrplib'}) {
930 # Use nothing on static perl platforms, and to the flags needed
931 # to link against the shared libperl library on shared perl
932 # platforms. We peek at lddlflags to see if we need -Wl,-R
933 # or -R to add paths to the run-time library search path.
934 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
935 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
936 } elsif ($Config{'lddlflags'} =~ /-R/) {
937 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
941 my $ld_run_path_shell = "";
942 if ($self->{LD_RUN_PATH} ne "") {
943 $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
946 push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs;
947 %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
948 $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
953 $(CHMOD) $(PERM_RWX) $@
961 Deprecated method. Use libscan instead.
966 my($self,$path) = @_;
972 Called by init_others, and calls ext ExtUtils::Liblist. See
973 L<ExtUtils::Liblist> for details.
978 my($self,$libs) = @_;
979 require ExtUtils::Liblist;
980 $self->ext($libs, $Verbose);
985 Finds the executables PERL and FULLPERL
990 my($self, $ver, $names, $dirs, $trace) = @_;
993 print "Looking for perl $ver by these names:
1000 my $stderr_duped = 0;
1003 if( open(STDERR_COPY, '>&STDERR') ) {
1008 find_perl() can't dup STDERR: $!
1009 You might see some garbage while we search for Perl
1014 foreach $name (@$names){
1015 foreach $dir (@$dirs){
1016 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1018 if ($self->file_name_is_absolute($name)) { # /foo/bar
1020 } elsif ($self->canonpath($name) eq
1021 $self->canonpath(basename($name))) { # foo
1022 $abs = $self->catfile($dir, $name);
1024 $abs = $self->catfile($Curdir, $name);
1026 print "Checking $abs\n" if ($trace >= 2);
1027 next unless $self->maybe_command($abs);
1028 print "Executing $abs\n" if ($trace >= 2);
1030 my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"};
1031 # To avoid using the unportable 2>&1 to suppress STDERR,
1032 # we close it before running the command.
1033 # However, thanks to a thread library bug in many BSDs
1034 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1035 # we cannot use the fancier more portable way in here
1036 # but instead need to use the traditional 2>&1 construct.
1038 $val = `$version_check 2>&1`;
1040 close STDERR if $stderr_duped;
1041 $val = `$version_check`;
1042 open STDERR, '>&STDERR_COPY' if $stderr_duped;
1045 if ($val =~ /^VER_OK/) {
1046 print "Using PERL=$abs\n" if $trace;
1048 } elsif ($trace >= 2) {
1049 print "Result: '$val' ".($? >> 8)."\n";
1053 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1054 0; # false and not empty
1062 Inserts the sharpbang or equivalent magic number to a set of @files.
1066 sub fixin { # stolen from the pink Camel book, more or less
1067 my($self, @files) = @_;
1069 my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1070 for my $file (@files) {
1071 my $file_new = "$file.new";
1072 my $file_bak = "$file.bak";
1076 open(FIXIN, $file) or croak "Can't process '$file': $!";
1078 chomp(my $line = <FIXIN>);
1079 next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
1080 # Now figure out the interpreter name.
1081 my($cmd,$arg) = split ' ', $line, 2;
1084 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
1086 if ($cmd eq "perl") {
1087 if ($Config{startperl} =~ m,^\#!.*/perl,) {
1088 $interpreter = $Config{startperl};
1089 $interpreter =~ s,^\#!,,;
1091 $interpreter = $Config{perlpath};
1094 my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path;
1097 foreach $dir (@absdirs) {
1098 if ($self->maybe_command($cmd)) {
1099 warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter;
1100 $interpreter = $self->catfile($dir,$cmd);
1104 # Figure out how to invoke interpreter on this machine.
1108 print STDOUT "Changing sharpbang in $file to $interpreter" if $Verbose;
1109 # this is probably value-free on DOSISH platforms
1111 $shb .= "$Config{'sharpbang'}$interpreter";
1112 $shb .= ' ' . $arg if defined $arg;
1116 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
1117 if 0; # not running under some shell
1118 } unless $Is_Win32; # this won't work on win32, so don't
1120 warn "Can't find $cmd in PATH, $file unchanged"
1125 unless ( open(FIXOUT,">$file_new") ) {
1126 warn "Can't create new $file: $!\n";
1130 # Print out the new #! line (or equivalent).
1133 print FIXOUT $shb, <FIXIN>;
1137 chmod 0666, $file_bak;
1139 unless ( _rename($file, $file_bak) ) {
1140 warn "Can't rename $file to $file_bak: $!";
1143 unless ( _rename($file_new, $file) ) {
1144 warn "Can't rename $file_new to $file: $!";
1145 unless ( _rename($file_bak, $file) ) {
1146 warn "Can't rename $file_bak back to $file either: $!";
1147 warn "Leaving $file renamed as $file_bak\n";
1153 close(FIXIN) if fileno(FIXIN);
1154 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
1160 my($old, $new) = @_;
1162 foreach my $file ($old, $new) {
1163 if( $Is_VMS and basename($file) !~ /\./ ) {
1164 # rename() in 5.8.0 on VMS will not rename a file if it
1165 # does not contain a dot yet it returns success.
1170 return rename($old, $new);
1176 Writes an empty FORCE: target.
1182 '# Phony target to force checking subdirectories.
1190 Guess the name of this package by examining the working directory's
1191 name. MakeMaker calls this only if the developer has not supplied a
1201 my $name = basename(cwd());
1202 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
1203 # strip minus or underline
1204 # followed by a float or some such
1205 print "Warning: Guessing NAME [$name] from current directory name.\n";
1211 Returns true if C, XS, MYEXTLIB or similar objects exist within this
1212 object that need a compiler. Does not descend into subdirectories as
1213 needs_linking() does.
1219 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1220 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1221 $self->{HAS_LINK_CODE} = 1;
1224 return $self->{HAS_LINK_CODE} = 0;
1230 Scans the directory structure and initializes DIR, XS, XS_FILES,
1231 C, C_FILES, O_FILES, H, H_FILES, PL_FILES, EXE_FILES.
1233 Called by init_main.
1237 sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1239 my($name, %dir, %xs, %c, %h, %pl_files, %pm);
1241 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
1243 # ignore the distdir
1244 $Is_VMS ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1245 : $ignore{$self->{DISTVNAME}} = 1;
1247 @ignore{map lc, keys %ignore} = values %ignore if $Is_VMS;
1249 foreach $name ($self->lsdir($Curdir)){
1250 next if $name =~ /\#/;
1251 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
1252 next unless $self->libscan($name);
1254 next if -l $name; # We do not support symlinks at all
1255 next if $self->{NORECURS};
1256 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1257 } elsif ($name =~ /\.xs\z/){
1258 my($c); ($c = $name) =~ s/\.xs\z/.c/;
1261 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
1263 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1264 } elsif ($name =~ /\.h\z/i){
1266 } elsif ($name =~ /\.PL\z/) {
1267 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
1268 } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
1269 # case-insensitive filesystem, one dot per name, so foo.h.PL
1270 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
1271 local($/); open(PL,$name); my $txt = <PL>; close PL;
1272 if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
1273 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
1276 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1278 } elsif ($name =~ /\.(p[ml]|pod)\z/){
1279 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1283 $self->{PL_FILES} ||= \%pl_files;
1284 $self->{DIR} ||= [sort keys %dir];
1285 $self->{XS} ||= \%xs;
1286 $self->{C} ||= [sort keys %c];
1287 $self->{H} ||= [sort keys %h];
1288 $self->{PM} ||= \%pm;
1290 my @o_files = @{$self->{C}};
1291 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
1297 Determines if man pages should be generated and initializes MAN1PODS
1298 and MAN3PODS as appropriate.
1305 # Set up names of manual pages to generate from pods
1306 foreach my $man (qw(MAN1 MAN3)) {
1307 if ( $self->{"${man}PODS"}
1308 or $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/
1310 $self->{"${man}PODS"} ||= {};
1313 my $init_method = "init_${man}PODS";
1314 $self->$init_method();
1321 my($self, $file) = @_;
1325 if (open(FH,"<$file")) {
1327 if (/^=(?:head\d+|item|pod)\b/) {
1334 # If it doesn't exist yet, we assume, it has pods in it
1344 Initializes MAN1PODS from the list of EXE_FILES.
1351 if ( exists $self->{EXE_FILES} ) {
1352 foreach my $name (@{$self->{EXE_FILES}}) {
1353 next unless $self->_has_pod($name);
1355 $self->{MAN1PODS}->{$name} =
1356 $self->catfile("\$(INST_MAN1DIR)",
1357 basename($name).".\$(MAN1EXT)");
1365 Initializes MAN3PODS from the list of PM files.
1372 my %manifypods = (); # we collect the keys first, i.e. the files
1373 # we have to convert to pod
1375 foreach my $name (keys %{$self->{PM}}) {
1376 if ($name =~ /\.pod\z/ ) {
1377 $manifypods{$name} = $self->{PM}{$name};
1378 } elsif ($name =~ /\.p[ml]\z/ ) {
1379 if( $self->_has_pod($name) ) {
1380 $manifypods{$name} = $self->{PM}{$name};
1385 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1387 # Remove "Configure.pm" and similar, if it's not the only pod listed
1388 # To force inclusion, just name it "Configure.pod", or override
1390 foreach my $name (keys %manifypods) {
1391 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
1392 delete $manifypods{$name};
1395 my($manpagename) = $name;
1396 $manpagename =~ s/\.p(od|m|l)\z//;
1397 # everything below lib is ok
1398 unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1399 $manpagename = $self->catfile(
1400 split(/::/,$self->{PARENT_NAME}),$manpagename
1403 $manpagename = $self->replace_manpage_separator($manpagename);
1404 $self->{MAN3PODS}->{$name} =
1405 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1412 Initializes PMLIBDIRS and PM from PMLIBDIRS.
1419 # Some larger extensions often wish to install a number of *.pm/pl
1420 # files into the library in various locations.
1422 # The attribute PMLIBDIRS holds an array reference which lists
1423 # subdirectories which we should search for library files to
1424 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1425 # recursively search through the named directories (skipping any
1426 # which don't exist or contain Makefile.PL files).
1428 # For each *.pm or *.pl file found $self->libscan() is called with
1429 # the default installation path in $_[1]. The return value of
1430 # libscan defines the actual installation location. The default
1431 # libscan function simply returns the path. The file is skipped
1432 # if libscan returns false.
1434 # The default installation location passed to libscan in $_[1] is:
1436 # ./*.pm => $(INST_LIBDIR)/*.pm
1437 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1438 # ./lib/... => $(INST_LIB)/...
1440 # In this way the 'lib' directory is seen as the root of the actual
1441 # perl library whereas the others are relative to INST_LIBDIR
1442 # (which includes PARENT_NAME). This is a subtle distinction but one
1443 # that's important for nested modules.
1445 unless( $self->{PMLIBDIRS} ) {
1447 # Avoid logical name vs directory collisions
1448 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1451 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1455 #only existing directories that aren't in $dir are allowed
1457 # Avoid $_ wherever possible:
1458 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1459 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1460 @{$self->{PMLIBDIRS}} = ();
1461 my %dir = map { ($_ => $_) } @{$self->{DIR}};
1462 foreach my $pmlibdir (@pmlibdirs) {
1463 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1466 unless( $self->{PMLIBPARENTDIRS} ) {
1467 @{$self->{PMLIBPARENTDIRS}} = ('lib');
1470 return if $self->{PM} and $self->{ARGS}{PM};
1472 if (@{$self->{PMLIBDIRS}}){
1473 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1476 File::Find::find(sub {
1478 unless ($self->libscan($_)){
1479 $File::Find::prune = 1;
1484 return if /~$/; # emacs temp files
1485 return if /,v$/; # RCS files
1487 my $path = $File::Find::name;
1488 my $prefix = $self->{INST_LIBDIR};
1491 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1492 $prefix = $self->{INST_LIB}
1493 if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W}
1496 my($inst) = $self->catfile($prefix,$striplibpath);
1497 local($_) = $inst; # for backwards compatibility
1498 $inst = $self->libscan($inst);
1499 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1500 return unless $inst;
1501 $self->{PM}{$path} = $inst;
1502 }, @{$self->{PMLIBDIRS}});
1507 =item init_DIRFILESEP
1509 Using / for Unix. Called by init_main.
1513 sub init_DIRFILESEP {
1516 $self->{DIRFILESEP} = '/';
1522 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1523 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1524 INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1525 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1526 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1527 VERSION_SYM, XS_VERSION.
1534 # --- Initialize Module Name and Paths
1536 # NAME = Foo::Bar::Oracle
1537 # FULLEXT = Foo/Bar/Oracle
1539 # PARENT_NAME = Foo::Bar
1541 ### ($self->{FULLEXT} =
1542 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1543 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1546 # Copied from DynaLoader:
1548 my(@modparts) = split(/::/,$self->{NAME});
1549 my($modfname) = $modparts[-1];
1551 # Some systems have restrictions on files names for DLL's etc.
1552 # mod2fname returns appropriate file base name (typically truncated)
1553 # It may also edit @modparts if required.
1554 if (defined &DynaLoader::mod2fname) {
1555 $modfname = &DynaLoader::mod2fname(\@modparts);
1558 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1559 $self->{PARENT_NAME} ||= '';
1561 if (defined &DynaLoader::mod2fname) {
1562 # As of 5.001m, dl_os2 appends '_'
1563 $self->{DLBASE} = $modfname;
1565 $self->{DLBASE} = '$(BASEEXT)';
1569 # --- Initialize PERL_LIB, PERL_SRC
1571 # *Real* information: where did we get these two from? ...
1572 my $inc_config_dir = dirname($INC{'Config.pm'});
1573 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1575 unless ($self->{PERL_SRC}){
1577 foreach my $dir_count (1..8) # 8 is the VMS limit for nesting
1579 $dir = $self->catdir(($Updir) x $dir_count);
1581 -f $self->catfile($dir,"config_h.SH")
1583 -f $self->catfile($dir,"perl.h")
1585 -f $self->catfile($dir,"lib","Exporter.pm")
1587 $self->{PERL_SRC}=$dir ;
1593 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1594 $self->{PERL_CORE} and !$self->{PERL_SRC};
1596 if ($self->{PERL_SRC}){
1597 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1599 if (defined $Cross::platform) {
1600 $self->{PERL_ARCHLIB} =
1601 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
1603 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
1604 $Is_Win32?("CORE"):());
1607 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1608 $self->{PERL_INC} = ($Is_Win32) ?
1609 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1612 # catch a situation that has occurred a few times in the past:
1614 -s $self->catfile($self->{PERL_SRC},'cflags')
1618 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1623 You cannot build extensions below the perl source tree after executing
1624 a 'make clean' in the perl source tree.
1626 To rebuild extensions distributed with the perl source you should
1627 simply Configure (to include those extensions) and then build perl as
1628 normal. After installing perl the source tree can be deleted. It is
1629 not needed for building extensions by running 'perl Makefile.PL'
1630 usually without extra arguments.
1632 It is recommended that you unpack and build additional extensions away
1633 from the perl source tree.
1637 # we should also consider $ENV{PERL5LIB} here
1638 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1639 $self->{PERL_LIB} ||= $Config{privlibexp};
1640 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1641 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1644 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1646 # Maybe somebody tries to build an extension with an
1647 # uninstalled Perl outside of Perl build tree
1649 for my $dir (@INC) {
1650 $lib = $dir, last if -e $self->catdir($dir, "Config.pm");
1653 # Win32 puts its header files in /perl/src/lib/CORE.
1654 # Unix leaves them in /perl/src.
1655 my $inc = $Is_Win32 ? $self->catdir($lib, "CORE" )
1657 if (-e $self->catdir($inc, "perl.h")) {
1658 $self->{PERL_LIB} = $lib;
1659 $self->{PERL_ARCHLIB} = $lib;
1660 $self->{PERL_INC} = $inc;
1661 $self->{UNINSTALLED_PERL} = 1;
1663 ... Detected uninstalled Perl. Trying to continue.
1670 # We get SITELIBEXP and SITEARCHEXP directly via
1671 # Get_from_Config. When we are running standard modules, these
1672 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1673 # set it to "site". I prefer that INSTALLDIRS be set from outside
1675 $self->{INSTALLDIRS} ||= "site";
1677 $self->{MAN1EXT} ||= $Config{man1ext};
1678 $self->{MAN3EXT} ||= $Config{man3ext};
1680 # Get some stuff out of %Config if we haven't yet done so
1681 print STDOUT "CONFIG must be an array ref\n"
1682 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1683 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1684 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1685 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1687 foreach my $m (@{$self->{CONFIG}}){
1688 next if $once_only{$m};
1689 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1690 unless exists $Config{$m};
1691 $self->{uc $m} ||= $Config{$m};
1695 # This is too dangerous:
1696 # if ($^O eq "next") {
1697 # $self->{AR} = "libtool";
1698 # $self->{AR_STATIC_ARGS} = "-o";
1700 # But I leave it as a placeholder
1702 $self->{AR_STATIC_ARGS} ||= "cr";
1704 # These should never be needed
1705 $self->{OBJ_EXT} ||= '.o';
1706 $self->{LIB_EXT} ||= '.a';
1708 $self->{MAP_TARGET} ||= "perl";
1710 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1712 # make a simple check if we find Exporter
1713 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1714 (Exporter.pm not found)"
1715 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1716 $self->{NAME} eq "ExtUtils::MakeMaker";
1721 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
1722 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1723 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
1724 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1728 sub init_others { # --- Initialize Other Attributes
1731 $self->{LD} ||= 'ld';
1733 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1734 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1735 # undefined. In any case we turn it into an anon array:
1737 # May check $Config{libs} too, thus not empty.
1738 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
1740 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
1741 $self->{LD_RUN_PATH} = "";
1743 foreach $libs ( @{$self->{LIBS}} ){
1744 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1745 my(@libs) = $self->extliblist($libs);
1746 if ($libs[0] or $libs[1] or $libs[2]){
1747 # LD_RUN_PATH now computed by ExtUtils::Liblist
1748 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1749 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1754 if ( $self->{OBJECT} ) {
1755 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1757 # init_dirscan should have found out, if we have C files
1758 $self->{OBJECT} = "";
1759 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1761 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1762 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1763 $self->{PERLMAINCC} ||= '$(CC)';
1764 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1766 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1767 # the 'dynamic' section of MM. We don't have this problem with
1768 # 'static', since we either must use it (%Config says we can't
1769 # use dynamic loading) or the caller asked for it explicitly.
1770 if (!$self->{LINKTYPE}) {
1771 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1773 : ($Config{usedl} ? 'dynamic' : 'static');
1776 $self->{NOOP} ||= '$(SHELL) -c true';
1777 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1779 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
1780 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1781 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1782 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1784 # Some makes require a wrapper around macros passed in on the command
1786 $self->{MACROSTART} ||= '';
1787 $self->{MACROEND} ||= '';
1789 # Not everybody uses -f to indicate "use this Makefile instead"
1790 $self->{USEMAKEFILE} ||= '-f';
1792 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1794 $self->{ECHO} ||= 'echo';
1795 $self->{ECHO_N} ||= 'echo -n';
1796 $self->{RM_F} ||= "rm -f";
1797 $self->{RM_RF} ||= "rm -rf";
1798 $self->{TOUCH} ||= "touch";
1799 $self->{TEST_F} ||= "test -f";
1800 $self->{CP} ||= "cp";
1801 $self->{MV} ||= "mv";
1802 $self->{CHMOD} ||= "chmod";
1803 $self->{MKPATH} ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
1804 $self->{EQUALIZE_TIMESTAMP} ||=
1805 '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
1807 $self->{UNINST} ||= 0;
1808 $self->{VERBINST} ||= 0;
1809 $self->{MOD_INSTALL} ||=
1810 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1811 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1813 $self->{DOC_INSTALL} ||=
1814 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
1815 $self->{UNINSTALL} ||=
1816 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
1817 $self->{WARN_IF_OLD_PACKLIST} ||=
1818 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
1820 q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
1822 $self->{UMASK_NULL} ||= "umask 0";
1823 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1831 Unix has no need of special linker flags.
1837 $self->{PERL_ARCHIVE} ||= '';
1838 $self->{PERL_ARCHIVE_AFTER} ||= '';
1839 $self->{EXPORT_LIST} ||= '';
1856 # The user who requests an installation directory explicitly
1857 # should not have to tell us an architecture installation directory
1858 # as well. We look if a directory exists that is named after the
1859 # architecture. If not we take it as a sign that it should be the
1860 # same as the requested installation directory. Otherwise we take
1862 for my $libpair ({l=>"privlib", a=>"archlib"},
1863 {l=>"sitelib", a=>"sitearch"},
1864 {l=>"vendorlib", a=>"vendorarch"},
1867 my $lib = "install$libpair->{l}";
1869 my $Arch = uc "install$libpair->{a}";
1870 if( $self->{$Lib} && ! $self->{$Arch} ){
1871 my($ilib) = $Config{$lib};
1873 $self->prefixify($Arch,$ilib,$self->{$Lib});
1875 unless (-d $self->{$Arch}) {
1876 print STDOUT "Directory $self->{$Arch} not found\n"
1878 $self->{$Arch} = $self->{$Lib};
1880 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1890 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1891 *PERLRUN* permutations.
1893 PERL is allowed to be miniperl
1894 FULLPERL must be a complete perl
1896 ABSPERL is PERL converted to an absolute path
1898 *PERLRUN contains everything necessary to run perl, find it's
1901 *PERLRUNINST is *PERLRUN + everything necessary to find the
1902 modules being built.
1910 foreach my $component ($self->{PERL_SRC}, $self->path(),
1913 push @defpath, $component if defined $component;
1916 # Build up a set of file names (not command names).
1917 my $thisperl = $self->canonpath($^X);
1918 $thisperl .= $Config{exe_ext} unless
1919 # VMS might have a file version # at the end
1920 $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
1921 : $thisperl =~ m/$Config{exe_ext}$/i;
1923 # We need a relative path to perl when in the core.
1924 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
1926 my @perls = ($thisperl);
1927 push @perls, map { "$_$Config{exe_ext}" }
1928 ('perl', 'perl5', "perl$Config{version}");
1930 # miniperl has priority over all but the cannonical perl when in the
1931 # core. Otherwise its a last resort.
1932 my $miniperl = "miniperl$Config{exe_ext}";
1933 if( $self->{PERL_CORE} ) {
1934 splice @perls, 1, 0, $miniperl;
1937 push @perls, $miniperl;
1941 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
1942 # don't check if perl is executable, maybe they have decided to
1943 # supply switches with perl
1945 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
1946 my $perl_name = 'perl';
1947 $perl_name = 'ndbgperl' if $Is_VMS &&
1948 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
1950 # XXX This logic is flawed. If "miniperl" is anywhere in the path
1951 # it will get confused. It should be fixed to work only on the filename.
1952 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1953 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
1954 unless $self->{FULLPERL};
1956 # Little hack to get around VMS's find_perl putting "MCR" in front
1958 $self->{ABSPERL} = $self->{PERL};
1959 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
1960 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
1961 $self->{ABSPERL} = '$(PERL)';
1964 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
1965 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
1968 # Are we building the core?
1969 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1970 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
1972 # How do we run perl?
1973 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
1974 my $run = $perl.'RUN';
1976 $self->{$run} = "\$($perl)";
1978 # Make sure perl can find itself before it's installed.
1979 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
1980 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
1982 $self->{$perl.'RUNINST'} =
1983 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
1992 =item platform_constants
1994 Add MM_Unix_VERSION.
2001 $self->{MM_Unix_VERSION} = $VERSION;
2002 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2003 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2004 '-Dcalloc=Perl_calloc';
2008 sub platform_constants {
2012 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2014 next unless defined $self->{$macro};
2015 $make_frag .= "$macro = $self->{$macro}\n";
2026 Called by init_main. Initializes PERL_*
2033 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2034 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2044 Sets up macros having to do with XS code. Currently just INST_STATIC,
2045 INST_DYNAMIC and INST_BOOT.
2052 if ($self->has_link_code()) {
2053 $self->{INST_STATIC} =
2054 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2055 $self->{INST_DYNAMIC} =
2056 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2057 $self->{INST_BOOT} =
2058 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2060 $self->{INST_STATIC} = '';
2061 $self->{INST_DYNAMIC} = '';
2062 $self->{INST_BOOT} = '';
2068 Defines the install target.
2073 my($self, %attribs) = @_;
2077 install :: all pure_install doc_install
2080 install_perl :: all pure_perl_install doc_perl_install
2083 install_site :: all pure_site_install doc_site_install
2086 install_vendor :: all pure_vendor_install doc_vendor_install
2089 pure_install :: pure_$(INSTALLDIRS)_install
2092 doc_install :: doc_$(INSTALLDIRS)_install
2095 pure__install : pure_site_install
2096 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2098 doc__install : doc_site_install
2099 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2101 pure_perl_install ::
2102 $(NOECHO) $(MOD_INSTALL) \
2103 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2104 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2105 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2106 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2107 $(INST_BIN) $(DESTINSTALLBIN) \
2108 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2109 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2110 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2111 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2112 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2115 pure_site_install ::
2116 $(NOECHO) $(MOD_INSTALL) \
2117 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2118 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2119 $(INST_LIB) $(DESTINSTALLSITELIB) \
2120 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2121 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2122 $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
2123 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2124 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2125 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2126 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2128 pure_vendor_install ::
2129 $(NOECHO) $(MOD_INSTALL) \
2130 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2131 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2132 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2133 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2134 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2135 $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
2136 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2137 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2140 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2141 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2142 -$(NOECHO) $(DOC_INSTALL) \
2143 "Module" "$(NAME)" \
2144 "installed into" "$(INSTALLPRIVLIB)" \
2145 LINKTYPE "$(LINKTYPE)" \
2146 VERSION "$(VERSION)" \
2147 EXE_FILES "$(EXE_FILES)" \
2148 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2151 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2152 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2153 -$(NOECHO) $(DOC_INSTALL) \
2154 "Module" "$(NAME)" \
2155 "installed into" "$(INSTALLSITELIB)" \
2156 LINKTYPE "$(LINKTYPE)" \
2157 VERSION "$(VERSION)" \
2158 EXE_FILES "$(EXE_FILES)" \
2159 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2161 doc_vendor_install ::
2162 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2163 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2164 -$(NOECHO) $(DOC_INSTALL) \
2165 "Module" "$(NAME)" \
2166 "installed into" "$(INSTALLVENDORLIB)" \
2167 LINKTYPE "$(LINKTYPE)" \
2168 VERSION "$(VERSION)" \
2169 EXE_FILES "$(EXE_FILES)" \
2170 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2175 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2178 uninstall_from_perldirs ::
2179 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2181 uninstall_from_sitedirs ::
2182 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2184 uninstall_from_vendordirs ::
2185 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2191 =item installbin (o)
2193 Defines targets to make and to install EXE_FILES.
2200 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2201 my @exefiles = @{$self->{EXE_FILES}};
2202 return "" unless @exefiles;
2204 @exefiles = map vmsify($_), @exefiles if $Is_VMS;
2207 for my $from (@exefiles) {
2208 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2210 local($_) = $path; # for backwards compatibility
2211 my $to = $self->libscan($path);
2212 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2214 $to = vmsify($to) if $Is_VMS;
2215 $fromto{$from} = $to;
2217 my @to = values %fromto;
2221 EXE_FILES = @exefiles
2229 # realclean can get rather large.
2230 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2234 # A target for each exe file.
2235 while (my($from,$to) = each %fromto) {
2236 last unless defined $from;
2238 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
2239 %s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2240 $(NOECHO) $(RM_F) %s
2243 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
2255 Defines the linkext target which in turn defines the LINKTYPE.
2260 my($self, %attribs) = @_;
2261 # LINKTYPE => static or dynamic or ''
2262 my($linktype) = defined $attribs{LINKTYPE} ?
2263 $attribs{LINKTYPE} : '$(LINKTYPE)';
2265 linkext :: $linktype
2272 Takes as arguments a directory name and a regular expression. Returns
2273 all entries in the directory that match the regular expression.
2279 my($dir, $regex) = @_;
2281 my $dh = new DirHandle;
2282 $dh->open($dir || ".") or return ();
2285 @ls = grep(/$regex/, @ls) if $regex;
2291 Simple subroutine to insert the macros defined by the macro attribute
2297 my($self,%attribs) = @_;
2299 while (($key,$val) = each %attribs){
2300 last unless defined $key;
2301 push @m, "$key = $val\n";
2308 Called by staticmake. Defines how to write the Makefile to produce a
2311 By default the Makefile produced includes all the static extensions in
2312 the perl library. (Purified versions of library files, e.g.,
2313 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2318 my($self, %attribs) = @_;
2319 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2320 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2323 # --- MakeMaker makeaperl section ---
2324 MAP_TARGET = $target
2325 FULLPERL = $self->{FULLPERL}
2327 return join '', @m if $self->{PARENT};
2329 my($dir) = join ":", @{$self->{DIR}};
2331 unless ($self->{MAKEAPERL}) {
2333 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2334 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
2336 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
2337 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2338 $(NOECHO) $(PERLRUNINST) \
2339 Makefile.PL DIR=}, $dir, q{ \
2340 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2341 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2347 push @m, " \\\n\t\t$_";
2349 # push @m, map( " \\\n\t\t$_", @ARGV );
2357 my($cccmd, $linkcmd, $lperl);
2360 $cccmd = $self->const_cccmd($libperl);
2361 $cccmd =~ s/^CCCMD\s*=\s*//;
2362 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2363 $cccmd .= " $Config{cccdlflags}"
2364 if ($Config{useshrplib} eq 'true');
2365 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2367 # The front matter of the linkcommand...
2368 $linkcmd = join ' ', "\$(CC)",
2369 grep($_, @Config{qw(ldflags ccdlflags)});
2370 $linkcmd =~ s/\s+/ /g;
2371 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2373 # Which *.a files could we make use of...
2376 File::Find::find(sub {
2377 return unless m/\Q$self->{LIB_EXT}\E$/;
2379 # Skip perl's libraries.
2380 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2382 # Skip purified versions of libraries
2383 # (e.g., DynaLoader_pure_p1_c0_032.a)
2384 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2386 if( exists $self->{INCLUDE_EXT} ){
2391 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2395 # Throw away anything not explicitly marked for inclusion.
2396 # DynaLoader is implied.
2397 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2403 return unless $found;
2405 elsif( exists $self->{EXCLUDE_EXT} ){
2409 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2413 # Throw away anything explicitly marked for exclusion
2414 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2415 return if( $xx eq $excl );
2419 # don't include the installed version of this extension. I
2420 # leave this line here, although it is not necessary anymore:
2421 # I patched minimod.PL instead, so that Miniperl.pm won't
2422 # enclude duplicates
2424 # Once the patch to minimod.PL is in the distribution, I can
2426 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2428 $static{cwd() . "/" . $_}++;
2429 }, grep( -d $_, @{$searchdirs || []}) );
2431 # We trust that what has been handed in as argument, will be buildable
2432 $static = [] unless $static;
2433 @static{@{$static}} = (1) x @{$static};
2435 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2436 for (sort keys %static) {
2437 next unless /\Q$self->{LIB_EXT}\E\z/;
2438 $_ = dirname($_) . "/extralibs.ld";
2442 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
2447 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2448 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2449 # extralibs.all are computed correctly
2451 MAP_LINKCMD = $linkcmd
2452 MAP_PERLINC = @{$perlinc || []}
2454 join(" \\\n\t", reverse sort keys %static), "
2456 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2459 if (defined $libperl) {
2460 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2462 unless ($libperl && -f $lperl) { # Ilya's code...
2463 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2464 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2465 $libperl ||= "libperl$self->{LIB_EXT}";
2466 $libperl = "$dir/$libperl";
2467 $lperl ||= "libperl$self->{LIB_EXT}";
2468 $lperl = "$dir/$lperl";
2470 if (! -f $libperl and ! -f $lperl) {
2471 # We did not find a static libperl. Maybe there is a shared one?
2473 $lperl = $libperl = "$dir/$Config{libperl}";
2474 # SUNOS ld does not take the full path to a shared library
2475 $libperl = '' if $Is_SunOS4;
2479 print STDOUT "Warning: $libperl not found
2480 If you're going to build a static perl binary, make sure perl is installed
2481 otherwise ignore this warning\n"
2482 unless (-f $lperl || defined($self->{PERL_SRC}));
2485 # SUNOS ld does not take the full path to a shared library
2486 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2489 MAP_LIBPERL = $libperl
2490 LLIBPERL = $llibperl
2494 $(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
2495 $(NOECHO) $(RM_F) $@
2496 $(NOECHO) $(TOUCH) $@
2500 foreach $catfile (@$extra){
2501 push @m, "\tcat $catfile >> \$\@\n";
2505 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2506 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2507 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2508 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2509 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2510 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
2512 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2514 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
2517 $tmp/perlmain.c: $makefilename}, q{
2518 $(NOECHO) $(ECHO) Writing $@
2519 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2520 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2523 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2524 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2529 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2530 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2531 -$(NOECHO) $(DOC_INSTALL) \
2532 "Perl binary" "$(MAP_TARGET)" \
2533 MAP_STATIC "$(MAP_STATIC)" \
2534 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2535 MAP_LIBPERL "$(MAP_LIBPERL)" \
2536 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2538 } if -f 'Makefile.PL';
2541 inst_perl: pure_inst_perl doc_inst_perl
2543 pure_inst_perl: $(MAP_TARGET)
2544 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2549 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2557 Defines how to rewrite the Makefile.
2564 # We do not know what target was originally specified so we
2565 # must force a manual rerun to be sure. But as it should only
2566 # happen very rarely it is not a significant problem.
2568 $(OBJECT) : $(FIRST_MAKEFILE)
2570 ' if $self->{OBJECT};
2572 my $newer_than_target = $Is_VMS ? '$(MMS$SOURCE_LIST)' : '$?';
2573 my $mpl_args = join " ", map qq["$_"], @ARGV;
2575 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
2576 # We take a very conservative approach here, but it's worth it.
2577 # We move Makefile to Makefile.old here to avoid gnu make looping.
2578 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2579 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
2580 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2581 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2582 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2583 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2584 $(PERLRUN) Makefile.PL %s
2585 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2586 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
2597 Returns true, if the argument is likely to be a command.
2602 my($self,$file) = @_;
2603 return $file if -x $file && ! -d $file;
2608 =item needs_linking (o)
2610 Does this module need linking? Looks into subdirectory objects (see
2611 also has_link_code())
2618 $caller = (caller(0))[3];
2619 confess("needs_linking called too early") if
2620 $caller =~ /^ExtUtils::MakeMaker::/;
2621 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2622 if ($self->has_link_code or $self->{MAKEAPERL}){
2623 $self->{NEEDS_LINKING} = 1;
2626 foreach $child (keys %{$self->{CHILDREN}}) {
2627 if ($self->{CHILDREN}->{$child}->needs_linking) {
2628 $self->{NEEDS_LINKING} = 1;
2632 return $self->{NEEDS_LINKING} = 0;
2637 misnamed method (will have to be changed). The MM_Unix method just
2638 returns the argument without further processing.
2640 On VMS used to insure that colons marking targets are preceded by
2641 space - most Unix Makes don't need this, but it's necessary under VMS
2642 to distinguish the target delimiter from a colon appearing as part of
2648 my($self,$text) = @_;
2652 =item parse_abstract
2654 parse a file and return what you think is the ABSTRACT
2658 sub parse_abstract {
2659 my($self,$parsefile) = @_;
2663 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2665 my $package = $self->{DISTNAME};
2666 $package =~ s/-/::/g;
2668 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2671 next unless /^($package\s-\s)(.*)/;
2681 parse a file and return what you think is $VERSION in this file set to.
2682 It will return the string "undef" if it can't figure out what $VERSION
2683 is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
2684 are okay, but my $VERSION is not.
2689 my($self,$parsefile) = @_;
2694 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2697 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2698 next if $inpod || /^\s*#/;
2700 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
2702 package ExtUtils::MakeMaker::_version;
2711 $result = eval($eval);
2712 warn "Could not eval '$eval' in $parsefile: $@" if $@;
2717 $result = "undef" unless defined $result;
2724 Defines the string that is passed to recursive make calls in
2734 my($sep) = $Is_VMS ? ',' : '';
2737 foreach $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
2738 PREFIX INSTALL_BASE)
2741 next unless defined $self->{$key};
2742 push @pasthru, "$key=\"\$($key)\"";
2745 foreach $key (qw(DEFINE INC)) {
2746 next unless defined $self->{$key};
2747 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
2750 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
2756 Takes one argument, a file name, and returns the file name, if the
2757 argument is likely to be a perl script. On MM_Unix this is true for
2758 any ordinary, readable file.
2763 my($self,$file) = @_;
2764 return $file if -r $file && -f _;
2768 =item perldepend (o)
2770 Defines the dependency from all *.h files that come with the perl
2779 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
2781 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
2782 # Check for unpropogated config.sh changes. Should never happen.
2783 # We do NOT just update config.h because that is not sufficient.
2784 # An out of date config.h is not fatal but complains loudly!
2785 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2786 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2788 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2789 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2793 return join "", @m unless $self->needs_linking;
2797 $(PERL_INC)/EXTERN.h \
2798 $(PERL_INC)/INTERN.h \
2799 $(PERL_INC)/XSUB.h \
2801 $(PERL_INC)/cc_runtime.h \
2802 $(PERL_INC)/config.h \
2805 $(PERL_INC)/dosish.h \
2806 $(PERL_INC)/embed.h \
2807 $(PERL_INC)/embedvar.h \
2808 $(PERL_INC)/fakethr.h \
2809 $(PERL_INC)/form.h \
2811 $(PERL_INC)/handy.h \
2813 $(PERL_INC)/intrpvar.h \
2814 $(PERL_INC)/iperlsys.h \
2815 $(PERL_INC)/keywords.h \
2817 $(PERL_INC)/nostdio.h \
2819 $(PERL_INC)/opcode.h \
2820 $(PERL_INC)/patchlevel.h \
2821 $(PERL_INC)/perl.h \
2822 $(PERL_INC)/perlio.h \
2823 $(PERL_INC)/perlsdio.h \
2824 $(PERL_INC)/perlsfio.h \
2825 $(PERL_INC)/perlvars.h \
2826 $(PERL_INC)/perly.h \
2828 $(PERL_INC)/pp_proto.h \
2829 $(PERL_INC)/proto.h \
2830 $(PERL_INC)/regcomp.h \
2831 $(PERL_INC)/regexp.h \
2832 $(PERL_INC)/regnodes.h \
2833 $(PERL_INC)/scope.h \
2835 $(PERL_INC)/thrdvar.h \
2836 $(PERL_INC)/thread.h \
2837 $(PERL_INC)/unixish.h \
2840 $(OBJECT) : $(PERL_HDRS)
2841 } if $self->{OBJECT};
2843 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2851 Returns the attribute C<PERM_RW> or the string C<644>.
2852 Used as the string that is passed
2853 to the C<chmod> command to set the permissions for read/writeable files.
2854 MakeMaker chooses C<644> because it has turned out in the past that
2855 relying on the umask provokes hard-to-track bug reports.
2856 When the return value is used by the perl function C<chmod>, it is
2857 interpreted as an octal value.
2862 return shift->{PERM_RW};
2867 Returns the attribute C<PERM_RWX> or the string C<755>,
2868 i.e. the string that is passed
2869 to the C<chmod> command to set the permissions for executable files.
2875 return shift->{PERM_RWX};
2880 Defines target that copies all files in the hash PM to their
2881 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
2887 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2889 pm_to_blib : $(TO_INST_PM)
2892 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
2893 pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
2896 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
2898 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
2899 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
2904 =item post_constants (o)
2906 Returns an empty string per default. Dedicated to overrides from
2907 within Makefile.PL after all constants have been defined.
2915 =item post_initialize (o)
2917 Returns an empty string per default. Used in Makefile.PLs to add some
2918 chunk of text to the Makefile after the object is initialized.
2922 sub post_initialize {
2928 Returns an empty string. Can be used in Makefile.PLs to write some
2929 text to the Makefile at the end.
2939 Defines target that creates a PPD (Perl Package Description) file
2940 for a binary distribution.
2947 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
2949 my $abstract = $self->{ABSTRACT} || '';
2950 $abstract =~ s/\n/\\n/sg;
2951 $abstract =~ s/</</g;
2952 $abstract =~ s/>/>/g;
2954 my $author = $self->{AUTHOR} || '';
2955 $author =~ s/</</g;
2956 $author =~ s/>/>/g;
2958 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
2959 <SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
2960 <TITLE>$(DISTNAME)</TITLE>
2961 <ABSTRACT>%s</ABSTRACT>
2965 $ppd_xml .= " <IMPLEMENTATION>\n";
2966 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
2967 my $pre_req = $prereq;
2968 $pre_req =~ s/::/-/g;
2969 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
2971 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
2972 <DEPENDENCY NAME="%s" VERSION="%s" />
2977 my $archname = $Config{archname};
2979 # archname did not change from 5.6 to 5.8, but those versions may
2980 # not be not binary compatible so now we append the part of the
2981 # version that changes when binary compatibility may change
2982 $archname .= "-". substr($Config{version},0,3);
2984 $ppd_xml .= sprintf <<'PPD_OUT', $archname;
2985 <OS NAME="$(OSNAME)" />
2986 <ARCHITECTURE NAME="%s" />
2989 if ($self->{PPM_INSTALL_SCRIPT}) {
2990 if ($self->{PPM_INSTALL_EXEC}) {
2991 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
2992 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
2995 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
2996 $self->{PPM_INSTALL_SCRIPT};
3000 my ($bin_location) = $self->{BINARY_LOCATION} || '';
3001 $bin_location =~ s/\\/\\\\/g;
3003 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
3004 <CODEBASE HREF="%s" />
3009 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
3011 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3012 # Creates a PPD (Perl Package Description) for a binary distribution.
3021 $MM->prefixify($var, $prefix, $new_prefix, $default);
3023 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3024 replace it's $prefix with a $new_prefix.
3026 Should the $prefix fail to match I<AND> a PREFIX was given as an
3027 argument to WriteMakefile() it will set it to the $new_prefix +
3028 $default. This is for systems whose file layouts don't neatly fit into
3029 our ideas of prefixes.
3031 This is for heuristics which attempt to create directory structures
3032 that mirror those of the installed perl.
3036 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3038 this will attempt to remove '/usr' from the front of the
3039 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3040 if necessary) and replace it with '/home/foo'. If this fails it will
3041 simply use '/home/foo/man/man1'.
3046 my($self,$var,$sprefix,$rprefix,$default) = @_;
3048 my $path = $self->{uc $var} ||
3049 $Config_Override{lc $var} || $Config{lc $var} || '';
3051 $rprefix .= '/' if $sprefix =~ m|/$|;
3053 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3054 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
3056 if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) &&
3057 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3060 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3061 print STDERR " no default!\n" if !$default && $Verbose >= 2;
3063 $path = $self->catdir($rprefix, $default) if $default;
3066 print " now $path\n" if $Verbose >= 2;
3067 return $self->{uc $var} = $path;
3073 Defines targets to run *.PL files.
3079 my $pl_files = $self->{PL_FILES};
3081 return "" unless $pl_files;
3084 foreach my $plfile (sort keys %$pl_files) {
3085 my $list = ref($pl_files->{$plfile})
3086 ? $pl_files->{$plfile}
3087 : [$pl_files->{$plfile}];
3089 foreach my $target (@$list) {
3091 $plfile = vmsify($self->eliminate_macros($plfile));
3092 $target = vmsify($self->eliminate_macros($target));
3095 # Normally a .PL file runs AFTER pm_to_blib so it can have
3096 # blib in its @INC and load the just built modules. BUT if
3097 # the generated module is something in $(TO_INST_PM) which
3098 # pm_to_blib depends on then it can't depend on pm_to_blib
3099 # else we have a dependency loop.
3102 if( defined $self->{PM}{$target} ) {
3104 $perlrun = 'PERLRUN';
3107 $pm_dep = 'pm_to_blib';
3108 $perlrun = 'PERLRUNINST';
3116 $target :: $plfile $pm_dep
3117 \$($perlrun) $plfile $target
3128 Backslashes parentheses C<()> in command line arguments.
3129 Doesn't handle recursive Makefile C<$(...)> constructs,
3130 but handles simple ones.
3136 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3137 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3138 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
3142 =item replace_manpage_separator
3144 my $man_name = $MM->replace_manpage_separator($file_path);
3146 Takes the name of a package, which may be a nested package, in the
3147 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3148 safe for a man page file name. Returns the replacement.
3152 sub replace_manpage_separator {
3153 my($self,$man) = @_;
3165 my($self, $dir, @cmds) = @_;
3167 # No leading tab and no trailing newline makes for easier embedding
3168 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3178 my($self, $cmd, $switches) = @_;
3179 $switches = [] unless defined $switches;
3181 # Strip leading and trailing newlines
3185 my @cmds = split /\n/, $cmd;
3186 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
3187 $cmd = $self->escape_newlines($cmd);
3189 $switches = join ' ', @$switches;
3191 return qq{\$(ABSPERLRUN) $switches -e $cmd --};
3200 my($self, $text) = @_;
3202 # I think all we have to quote is single quotes and I think
3203 # this is a safe way to do it.
3204 $text =~ s{'}{'\\''}g;
3210 =item escape_newlines
3214 sub escape_newlines {
3215 my($self, $text) = @_;
3217 $text =~ s{\n}{\\\n}g;
3225 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3232 if (!defined $self->{_MAX_EXEC_LEN}) {
3233 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3234 $self->{_MAX_EXEC_LEN} = $arg_max;
3236 else { # POSIX minimum exec size
3237 $self->{_MAX_EXEC_LEN} = 4096;
3241 return $self->{_MAX_EXEC_LEN};
3247 Defines the static target.
3252 # --- Static Loading Sections ---
3256 ## $(INST_PM) has been moved to the all: target.
3257 ## It remains here for awhile to allow for old usage: "make static"
3258 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3263 =item static_lib (o)
3265 Defines how to produce the *.a (or equivalent) files.
3271 return '' unless $self->has_link_code;
3276 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
3280 # If this extension has its own library (eg SDBM_File)
3281 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3282 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3283 $(CP) $(MYEXTLIB) $@
3287 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3288 # Prefer the absolute pathed ar if available so that PATH
3289 # doesn't confuse us. Perl itself is built with the full_ar.
3294 push @m, sprintf <<'MAKE_FRAG', $ar;
3295 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3296 $(CHMOD) $(PERM_RWX) $@
3297 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3300 # Old mechanism - still available:
3301 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3302 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3308 =item staticmake (o)
3315 my($self, %attribs) = @_;
3318 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3320 # And as it's not yet built, we add the current extension
3321 # but only if it has some C code (or XS code, which implies C code)
3322 if (@{$self->{C}}) {
3323 @static = $self->catfile($self->{INST_ARCHLIB},
3326 "$self->{BASEEXT}$self->{LIB_EXT}"
3330 # Either we determine now, which libraries we will produce in the
3331 # subdirectories or we do it at runtime of the make.
3333 # We could ask all subdir objects, but I cannot imagine, why it
3334 # would be necessary.
3336 # Instead we determine all libraries for the new perl at
3338 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3340 $self->makeaperl(MAKE => $self->{MAKEFILE},
3341 DIRS => \@searchdirs,
3344 TARGET => $self->{MAP_TARGET},
3346 LIBPERL => $self->{LIBPERL_A}
3352 Helper subroutine for subdirs
3357 my($self, $subdir) = @_;
3359 my $subdir_cmd = $self->cd($subdir,
3360 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3362 return sprintf <<'EOT', $subdir_cmd;
3372 Defines targets to process subdirectories.
3377 # --- Sub-directory Sections ---
3380 # This method provides a mechanism to automatically deal with
3381 # subdirectories containing further Makefile.PL scripts.
3382 # It calls the subdir_x() method for each subdirectory.
3383 foreach $dir (@{$self->{DIR}}){
3384 push(@m, $self->subdir_x($dir));
3385 #### print "Including $dir subdirectory\n";
3389 # The default clean, realclean and test targets in this Makefile
3390 # have automatically been given entries for each subdir.
3394 push(@m, "\n# none")
3401 Defines the test targets.
3406 # --- Test and Installation Sections ---
3408 my($self, %attribs) = @_;
3409 my $tests = $attribs{TESTS} || '';
3410 if (!$tests && -d 't') {
3411 $tests = $self->find_tests;
3413 # note: 'test.pl' name is also hardcoded in init_dirscan()
3415 my $subdirs_test = ($self->{DIR} && @{$self->{DIR}} ? 'subdirs-test' : '');
3418 TEST_TYPE=test_\$(LINKTYPE)
3423 testdb :: testdb_\$(LINKTYPE)
3425 test :: \$(TEST_TYPE) $subdirs_test
3428 foreach my $dir (@{ $self->{DIR} }) {
3429 my $test = $self->oneliner(sprintf <<'CODE', $dir);
3431 system '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) test $(PASTHRU)'
3432 if -f '$(FIRST_MAKEFILE)';
3435 push(@m, "\nsubdirs-test ::\n\t\$(NOECHO) $test\n");
3438 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3439 unless $tests or -f "test.pl" or @{$self->{DIR}};
3442 push(@m, "test_dynamic :: pure_all\n");
3443 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3445 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3449 push(@m, "testdb_dynamic :: pure_all\n");
3450 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3454 # Occasionally we may face this degenerate target:
3455 push @m, "test_ : test_dynamic\n\n";
3457 if ($self->needs_linking()) {
3458 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3459 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3460 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3462 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3463 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3466 push @m, "test_static :: test_dynamic\n";
3467 push @m, "testdb_static :: testdb_dynamic\n";
3472 =item test_via_harness (override)
3474 For some reason which I forget, Unix machines like to have
3475 PERL_DL_NONLAZY set for tests.
3479 sub test_via_harness {
3480 my($self, $perl, $tests) = @_;
3481 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3484 =item test_via_script (override)
3486 Again, the PERL_DL_NONLAZY thing.
3490 sub test_via_script {
3491 my($self, $perl, $script) = @_;
3492 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3496 =item tools_other (o)
3498 my $make_frag = $MM->tools_other;
3500 Returns a make fragment containing definitions for the macros init_others()
3509 # We set PM_FILTER as late as possible so it can see all the earlier
3510 # on macro-order sensitive makes such as nmake.
3511 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
3512 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
3515 MOD_INSTALL DOC_INSTALL UNINSTALL
3516 WARN_IF_OLD_PACKLIST
3523 next unless defined $self->{$tool};
3524 push @m, "$tool = $self->{$tool}\n";
3530 =item tool_xsubpp (o)
3532 Determines typemaps, xsubpp version, prototype behaviour.
3538 return "" unless $self->needs_linking;
3541 my @xsubpp_dirs = @INC;
3543 # Make sure we pick up the new xsubpp if we're building perl.
3544 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3546 foreach my $dir (@xsubpp_dirs) {
3547 $xsdir = $self->catdir($dir, 'ExtUtils');
3548 if( -r $self->catfile($xsdir, "xsubpp") ) {
3553 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3554 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3555 if( $self->{TYPEMAPS} ){
3557 foreach $typemap (@{$self->{TYPEMAPS}}){
3558 if( ! -f $typemap ){
3559 warn "Typemap $typemap not found.\n";
3562 push(@tmdeps, $typemap);
3566 push(@tmdeps, "typemap") if -f "typemap";
3567 my(@tmargs) = map("-typemap $_", @tmdeps);
3568 if( exists $self->{XSOPT} ){
3569 unshift( @tmargs, $self->{XSOPT} );
3573 $Config{'ldflags'} &&
3574 $Config{'ldflags'} =~ m!/Debug!i &&
3575 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
3578 unshift(@tmargs,'-nolinenumbers');
3582 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3586 XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp
3587 XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
3588 XSPROTOARG = $self->{XSPROTOARG}
3589 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3590 XSUBPPARGS = @tmargs
3598 Build man pages, too
3605 return <<'MAKE_EXT';
3606 all :: pure_all manifypods
3611 =item top_targets (o)
3613 Defines the targets all, subdirs, config, and O_FILES
3618 # --- Target Sections ---
3623 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3626 pure_all :: config pm_to_blib subdirs linkext
3629 subdirs :: $(MYEXTLIB)
3632 config :: $(FIRST_MAKEFILE) blibdirs
3637 $(O_FILES): $(H_FILES)
3638 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3642 perldoc ExtUtils::MakeMaker
3650 Obsolete, deprecated method. Not used since Version 5.21.
3655 # --- perllocal.pod section ---
3656 my($self,$what,$name,@attribs)=@_;
3657 my $time = localtime;
3658 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3659 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3660 print "\n\n=back\n\n";
3665 Defines the suffix rules to compile XS files to C.
3671 return '' unless $self->needs_linking();
3674 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3680 Defines the suffix rules to compile XS files to C++.
3686 return '' unless $self->needs_linking();
3689 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
3695 Defines suffix rules to go from XS to object files directly. This is
3696 only intended for broken make implementations.
3700 sub xs_o { # many makes are too dumb to use xs_c then c_o
3702 return '' unless $self->needs_linking();
3705 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3706 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
3717 L<ExtUtils::MakeMaker>