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 $dir ($Updir,
1578 $self->catdir($Updir,$Updir),
1579 $self->catdir($Updir,$Updir,$Updir),
1580 $self->catdir($Updir,$Updir,$Updir,$Updir),
1581 $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir))
1584 -f $self->catfile($dir,"config_h.SH")
1586 -f $self->catfile($dir,"perl.h")
1588 -f $self->catfile($dir,"lib","Exporter.pm")
1590 $self->{PERL_SRC}=$dir ;
1596 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1597 $self->{PERL_CORE} and !$self->{PERL_SRC};
1599 if ($self->{PERL_SRC}){
1600 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1602 if (defined $Cross::platform) {
1603 $self->{PERL_ARCHLIB} =
1604 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
1606 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
1607 $Is_Win32?("CORE"):());
1610 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1611 $self->{PERL_INC} = ($Is_Win32) ?
1612 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1615 # catch a situation that has occurred a few times in the past:
1617 -s $self->catfile($self->{PERL_SRC},'cflags')
1621 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1626 You cannot build extensions below the perl source tree after executing
1627 a 'make clean' in the perl source tree.
1629 To rebuild extensions distributed with the perl source you should
1630 simply Configure (to include those extensions) and then build perl as
1631 normal. After installing perl the source tree can be deleted. It is
1632 not needed for building extensions by running 'perl Makefile.PL'
1633 usually without extra arguments.
1635 It is recommended that you unpack and build additional extensions away
1636 from the perl source tree.
1640 # we should also consider $ENV{PERL5LIB} here
1641 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1642 $self->{PERL_LIB} ||= $Config{privlibexp};
1643 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1644 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1647 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1649 # Maybe somebody tries to build an extension with an
1650 # uninstalled Perl outside of Perl build tree
1652 for my $dir (@INC) {
1653 $lib = $dir, last if -e $self->catdir($dir, "Config.pm");
1656 # Win32 puts its header files in /perl/src/lib/CORE.
1657 # Unix leaves them in /perl/src.
1658 my $inc = $Is_Win32 ? $self->catdir($lib, "CORE" )
1660 if (-e $self->catdir($inc, "perl.h")) {
1661 $self->{PERL_LIB} = $lib;
1662 $self->{PERL_ARCHLIB} = $lib;
1663 $self->{PERL_INC} = $inc;
1664 $self->{UNINSTALLED_PERL} = 1;
1666 ... Detected uninstalled Perl. Trying to continue.
1673 # We get SITELIBEXP and SITEARCHEXP directly via
1674 # Get_from_Config. When we are running standard modules, these
1675 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1676 # set it to "site". I prefer that INSTALLDIRS be set from outside
1678 $self->{INSTALLDIRS} ||= "site";
1680 $self->{MAN1EXT} ||= $Config{man1ext};
1681 $self->{MAN3EXT} ||= $Config{man3ext};
1683 # Get some stuff out of %Config if we haven't yet done so
1684 print STDOUT "CONFIG must be an array ref\n"
1685 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1686 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1687 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1688 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1690 foreach my $m (@{$self->{CONFIG}}){
1691 next if $once_only{$m};
1692 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1693 unless exists $Config{$m};
1694 $self->{uc $m} ||= $Config{$m};
1698 # This is too dangerous:
1699 # if ($^O eq "next") {
1700 # $self->{AR} = "libtool";
1701 # $self->{AR_STATIC_ARGS} = "-o";
1703 # But I leave it as a placeholder
1705 $self->{AR_STATIC_ARGS} ||= "cr";
1707 # These should never be needed
1708 $self->{OBJ_EXT} ||= '.o';
1709 $self->{LIB_EXT} ||= '.a';
1711 $self->{MAP_TARGET} ||= "perl";
1713 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1715 # make a simple check if we find Exporter
1716 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1717 (Exporter.pm not found)"
1718 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1719 $self->{NAME} eq "ExtUtils::MakeMaker";
1724 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
1725 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1726 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
1727 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1731 sub init_others { # --- Initialize Other Attributes
1734 $self->{LD} ||= 'ld';
1736 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1737 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1738 # undefined. In any case we turn it into an anon array:
1740 # May check $Config{libs} too, thus not empty.
1741 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
1743 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
1744 $self->{LD_RUN_PATH} = "";
1746 foreach $libs ( @{$self->{LIBS}} ){
1747 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1748 my(@libs) = $self->extliblist($libs);
1749 if ($libs[0] or $libs[1] or $libs[2]){
1750 # LD_RUN_PATH now computed by ExtUtils::Liblist
1751 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1752 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1757 if ( $self->{OBJECT} ) {
1758 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1760 # init_dirscan should have found out, if we have C files
1761 $self->{OBJECT} = "";
1762 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1764 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1765 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1766 $self->{PERLMAINCC} ||= '$(CC)';
1767 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1769 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1770 # the 'dynamic' section of MM. We don't have this problem with
1771 # 'static', since we either must use it (%Config says we can't
1772 # use dynamic loading) or the caller asked for it explicitly.
1773 if (!$self->{LINKTYPE}) {
1774 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1776 : ($Config{usedl} ? 'dynamic' : 'static');
1779 $self->{NOOP} ||= '$(SHELL) -c true';
1780 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1782 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
1783 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1784 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1785 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1787 # Some makes require a wrapper around macros passed in on the command
1789 $self->{MACROSTART} ||= '';
1790 $self->{MACROEND} ||= '';
1792 # Not everybody uses -f to indicate "use this Makefile instead"
1793 $self->{USEMAKEFILE} ||= '-f';
1795 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1797 $self->{ECHO} ||= 'echo';
1798 $self->{ECHO_N} ||= 'echo -n';
1799 $self->{RM_F} ||= "rm -f";
1800 $self->{RM_RF} ||= "rm -rf";
1801 $self->{TOUCH} ||= "touch";
1802 $self->{TEST_F} ||= "test -f";
1803 $self->{CP} ||= "cp";
1804 $self->{MV} ||= "mv";
1805 $self->{CHMOD} ||= "chmod";
1806 $self->{MKPATH} ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
1807 $self->{EQUALIZE_TIMESTAMP} ||=
1808 '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
1810 $self->{UNINST} ||= 0;
1811 $self->{VERBINST} ||= 0;
1812 $self->{MOD_INSTALL} ||=
1813 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1814 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1816 $self->{DOC_INSTALL} ||=
1817 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
1818 $self->{UNINSTALL} ||=
1819 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
1820 $self->{WARN_IF_OLD_PACKLIST} ||=
1821 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
1823 q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
1825 $self->{UMASK_NULL} ||= "umask 0";
1826 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1834 Unix has no need of special linker flags.
1840 $self->{PERL_ARCHIVE} ||= '';
1841 $self->{PERL_ARCHIVE_AFTER} ||= '';
1842 $self->{EXPORT_LIST} ||= '';
1859 # The user who requests an installation directory explicitly
1860 # should not have to tell us an architecture installation directory
1861 # as well. We look if a directory exists that is named after the
1862 # architecture. If not we take it as a sign that it should be the
1863 # same as the requested installation directory. Otherwise we take
1865 for my $libpair ({l=>"privlib", a=>"archlib"},
1866 {l=>"sitelib", a=>"sitearch"},
1867 {l=>"vendorlib", a=>"vendorarch"},
1870 my $lib = "install$libpair->{l}";
1872 my $Arch = uc "install$libpair->{a}";
1873 if( $self->{$Lib} && ! $self->{$Arch} ){
1874 my($ilib) = $Config{$lib};
1876 $self->prefixify($Arch,$ilib,$self->{$Lib});
1878 unless (-d $self->{$Arch}) {
1879 print STDOUT "Directory $self->{$Arch} not found\n"
1881 $self->{$Arch} = $self->{$Lib};
1883 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1893 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1894 *PERLRUN* permutations.
1896 PERL is allowed to be miniperl
1897 FULLPERL must be a complete perl
1899 ABSPERL is PERL converted to an absolute path
1901 *PERLRUN contains everything necessary to run perl, find it's
1904 *PERLRUNINST is *PERLRUN + everything necessary to find the
1905 modules being built.
1913 foreach my $component ($self->{PERL_SRC}, $self->path(),
1916 push @defpath, $component if defined $component;
1919 # Build up a set of file names (not command names).
1920 my $thisperl = $self->canonpath($^X);
1921 $thisperl .= $Config{exe_ext} unless
1922 # VMS might have a file version # at the end
1923 $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
1924 : $thisperl =~ m/$Config{exe_ext}$/i;
1926 # We need a relative path to perl when in the core.
1927 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
1929 my @perls = ($thisperl);
1930 push @perls, map { "$_$Config{exe_ext}" }
1931 ('perl', 'perl5', "perl$Config{version}");
1933 # miniperl has priority over all but the cannonical perl when in the
1934 # core. Otherwise its a last resort.
1935 my $miniperl = "miniperl$Config{exe_ext}";
1936 if( $self->{PERL_CORE} ) {
1937 splice @perls, 1, 0, $miniperl;
1940 push @perls, $miniperl;
1944 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
1945 # don't check if perl is executable, maybe they have decided to
1946 # supply switches with perl
1948 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
1949 my $perl_name = 'perl';
1950 $perl_name = 'ndbgperl' if $Is_VMS &&
1951 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
1953 # XXX This logic is flawed. If "miniperl" is anywhere in the path
1954 # it will get confused. It should be fixed to work only on the filename.
1955 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1956 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
1957 unless $self->{FULLPERL};
1959 # Little hack to get around VMS's find_perl putting "MCR" in front
1961 $self->{ABSPERL} = $self->{PERL};
1962 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
1963 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
1964 $self->{ABSPERL} = '$(PERL)';
1967 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
1968 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
1971 # Are we building the core?
1972 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1973 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
1975 # How do we run perl?
1976 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
1977 my $run = $perl.'RUN';
1979 $self->{$run} = "\$($perl)";
1981 # Make sure perl can find itself before it's installed.
1982 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
1983 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
1985 $self->{$perl.'RUNINST'} =
1986 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
1995 =item platform_constants
1997 Add MM_Unix_VERSION.
2004 $self->{MM_Unix_VERSION} = $VERSION;
2005 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2006 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2007 '-Dcalloc=Perl_calloc';
2011 sub platform_constants {
2015 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2017 next unless defined $self->{$macro};
2018 $make_frag .= "$macro = $self->{$macro}\n";
2029 Called by init_main. Initializes PERL_*
2036 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2037 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2047 Sets up macros having to do with XS code. Currently just INST_STATIC,
2048 INST_DYNAMIC and INST_BOOT.
2055 if ($self->has_link_code()) {
2056 $self->{INST_STATIC} =
2057 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2058 $self->{INST_DYNAMIC} =
2059 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2060 $self->{INST_BOOT} =
2061 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2063 $self->{INST_STATIC} = '';
2064 $self->{INST_DYNAMIC} = '';
2065 $self->{INST_BOOT} = '';
2071 Defines the install target.
2076 my($self, %attribs) = @_;
2080 install :: all pure_install doc_install
2083 install_perl :: all pure_perl_install doc_perl_install
2086 install_site :: all pure_site_install doc_site_install
2089 install_vendor :: all pure_vendor_install doc_vendor_install
2092 pure_install :: pure_$(INSTALLDIRS)_install
2095 doc_install :: doc_$(INSTALLDIRS)_install
2098 pure__install : pure_site_install
2099 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2101 doc__install : doc_site_install
2102 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2104 pure_perl_install ::
2105 $(NOECHO) $(MOD_INSTALL) \
2106 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2107 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2108 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2109 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2110 $(INST_BIN) $(DESTINSTALLBIN) \
2111 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2112 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2113 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2114 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2115 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2118 pure_site_install ::
2119 $(NOECHO) $(MOD_INSTALL) \
2120 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2121 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2122 $(INST_LIB) $(DESTINSTALLSITELIB) \
2123 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2124 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2125 $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
2126 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2127 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2128 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2129 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2131 pure_vendor_install ::
2132 $(NOECHO) $(MOD_INSTALL) \
2133 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2134 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2135 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2136 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2137 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2138 $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
2139 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2140 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2143 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2144 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2145 -$(NOECHO) $(DOC_INSTALL) \
2146 "Module" "$(NAME)" \
2147 "installed into" "$(INSTALLPRIVLIB)" \
2148 LINKTYPE "$(LINKTYPE)" \
2149 VERSION "$(VERSION)" \
2150 EXE_FILES "$(EXE_FILES)" \
2151 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2154 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2155 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2156 -$(NOECHO) $(DOC_INSTALL) \
2157 "Module" "$(NAME)" \
2158 "installed into" "$(INSTALLSITELIB)" \
2159 LINKTYPE "$(LINKTYPE)" \
2160 VERSION "$(VERSION)" \
2161 EXE_FILES "$(EXE_FILES)" \
2162 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2164 doc_vendor_install ::
2165 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2166 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2167 -$(NOECHO) $(DOC_INSTALL) \
2168 "Module" "$(NAME)" \
2169 "installed into" "$(INSTALLVENDORLIB)" \
2170 LINKTYPE "$(LINKTYPE)" \
2171 VERSION "$(VERSION)" \
2172 EXE_FILES "$(EXE_FILES)" \
2173 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2178 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2181 uninstall_from_perldirs ::
2182 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2184 uninstall_from_sitedirs ::
2185 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2187 uninstall_from_vendordirs ::
2188 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2194 =item installbin (o)
2196 Defines targets to make and to install EXE_FILES.
2203 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2204 my @exefiles = @{$self->{EXE_FILES}};
2205 return "" unless @exefiles;
2207 @exefiles = map vmsify($_), @exefiles if $Is_VMS;
2210 for my $from (@exefiles) {
2211 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2213 local($_) = $path; # for backwards compatibility
2214 my $to = $self->libscan($path);
2215 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2217 $to = vmsify($to) if $Is_VMS;
2218 $fromto{$from} = $to;
2220 my @to = values %fromto;
2224 EXE_FILES = @exefiles
2232 # realclean can get rather large.
2233 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2237 # A target for each exe file.
2238 while (my($from,$to) = each %fromto) {
2239 last unless defined $from;
2241 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
2242 %s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2243 $(NOECHO) $(RM_F) %s
2246 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
2258 Defines the linkext target which in turn defines the LINKTYPE.
2263 my($self, %attribs) = @_;
2264 # LINKTYPE => static or dynamic or ''
2265 my($linktype) = defined $attribs{LINKTYPE} ?
2266 $attribs{LINKTYPE} : '$(LINKTYPE)';
2268 linkext :: $linktype
2275 Takes as arguments a directory name and a regular expression. Returns
2276 all entries in the directory that match the regular expression.
2282 my($dir, $regex) = @_;
2284 my $dh = new DirHandle;
2285 $dh->open($dir || ".") or return ();
2288 @ls = grep(/$regex/, @ls) if $regex;
2294 Simple subroutine to insert the macros defined by the macro attribute
2300 my($self,%attribs) = @_;
2302 while (($key,$val) = each %attribs){
2303 last unless defined $key;
2304 push @m, "$key = $val\n";
2311 Called by staticmake. Defines how to write the Makefile to produce a
2314 By default the Makefile produced includes all the static extensions in
2315 the perl library. (Purified versions of library files, e.g.,
2316 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2321 my($self, %attribs) = @_;
2322 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2323 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2326 # --- MakeMaker makeaperl section ---
2327 MAP_TARGET = $target
2328 FULLPERL = $self->{FULLPERL}
2330 return join '', @m if $self->{PARENT};
2332 my($dir) = join ":", @{$self->{DIR}};
2334 unless ($self->{MAKEAPERL}) {
2336 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2337 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
2339 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
2340 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2341 $(NOECHO) $(PERLRUNINST) \
2342 Makefile.PL DIR=}, $dir, q{ \
2343 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2344 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2350 push @m, " \\\n\t\t$_";
2352 # push @m, map( " \\\n\t\t$_", @ARGV );
2360 my($cccmd, $linkcmd, $lperl);
2363 $cccmd = $self->const_cccmd($libperl);
2364 $cccmd =~ s/^CCCMD\s*=\s*//;
2365 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2366 $cccmd .= " $Config{cccdlflags}"
2367 if ($Config{useshrplib} eq 'true');
2368 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2370 # The front matter of the linkcommand...
2371 $linkcmd = join ' ', "\$(CC)",
2372 grep($_, @Config{qw(ldflags ccdlflags)});
2373 $linkcmd =~ s/\s+/ /g;
2374 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2376 # Which *.a files could we make use of...
2379 File::Find::find(sub {
2380 return unless m/\Q$self->{LIB_EXT}\E$/;
2382 # Skip perl's libraries.
2383 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2385 # Skip purified versions of libraries
2386 # (e.g., DynaLoader_pure_p1_c0_032.a)
2387 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2389 if( exists $self->{INCLUDE_EXT} ){
2394 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2398 # Throw away anything not explicitly marked for inclusion.
2399 # DynaLoader is implied.
2400 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2406 return unless $found;
2408 elsif( exists $self->{EXCLUDE_EXT} ){
2412 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2416 # Throw away anything explicitly marked for exclusion
2417 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2418 return if( $xx eq $excl );
2422 # don't include the installed version of this extension. I
2423 # leave this line here, although it is not necessary anymore:
2424 # I patched minimod.PL instead, so that Miniperl.pm won't
2425 # enclude duplicates
2427 # Once the patch to minimod.PL is in the distribution, I can
2429 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2431 $static{cwd() . "/" . $_}++;
2432 }, grep( -d $_, @{$searchdirs || []}) );
2434 # We trust that what has been handed in as argument, will be buildable
2435 $static = [] unless $static;
2436 @static{@{$static}} = (1) x @{$static};
2438 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2439 for (sort keys %static) {
2440 next unless /\Q$self->{LIB_EXT}\E\z/;
2441 $_ = dirname($_) . "/extralibs.ld";
2445 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
2450 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2451 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2452 # extralibs.all are computed correctly
2454 MAP_LINKCMD = $linkcmd
2455 MAP_PERLINC = @{$perlinc || []}
2457 join(" \\\n\t", reverse sort keys %static), "
2459 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2462 if (defined $libperl) {
2463 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2465 unless ($libperl && -f $lperl) { # Ilya's code...
2466 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2467 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2468 $libperl ||= "libperl$self->{LIB_EXT}";
2469 $libperl = "$dir/$libperl";
2470 $lperl ||= "libperl$self->{LIB_EXT}";
2471 $lperl = "$dir/$lperl";
2473 if (! -f $libperl and ! -f $lperl) {
2474 # We did not find a static libperl. Maybe there is a shared one?
2476 $lperl = $libperl = "$dir/$Config{libperl}";
2477 # SUNOS ld does not take the full path to a shared library
2478 $libperl = '' if $Is_SunOS4;
2482 print STDOUT "Warning: $libperl not found
2483 If you're going to build a static perl binary, make sure perl is installed
2484 otherwise ignore this warning\n"
2485 unless (-f $lperl || defined($self->{PERL_SRC}));
2488 # SUNOS ld does not take the full path to a shared library
2489 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2492 MAP_LIBPERL = $libperl
2493 LLIBPERL = $llibperl
2497 $(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
2498 $(NOECHO) $(RM_F) $@
2499 $(NOECHO) $(TOUCH) $@
2503 foreach $catfile (@$extra){
2504 push @m, "\tcat $catfile >> \$\@\n";
2508 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2509 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2510 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2511 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2512 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2513 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
2515 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2517 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
2520 $tmp/perlmain.c: $makefilename}, q{
2521 $(NOECHO) $(ECHO) Writing $@
2522 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2523 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2526 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2527 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2532 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2533 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2534 -$(NOECHO) $(DOC_INSTALL) \
2535 "Perl binary" "$(MAP_TARGET)" \
2536 MAP_STATIC "$(MAP_STATIC)" \
2537 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2538 MAP_LIBPERL "$(MAP_LIBPERL)" \
2539 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2541 } if -f 'Makefile.PL';
2544 inst_perl: pure_inst_perl doc_inst_perl
2546 pure_inst_perl: $(MAP_TARGET)
2547 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2552 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2560 Defines how to rewrite the Makefile.
2567 # We do not know what target was originally specified so we
2568 # must force a manual rerun to be sure. But as it should only
2569 # happen very rarely it is not a significant problem.
2571 $(OBJECT) : $(FIRST_MAKEFILE)
2573 ' if $self->{OBJECT};
2575 my $newer_than_target = $Is_VMS ? '$(MMS$SOURCE_LIST)' : '$?';
2576 my $mpl_args = join " ", map qq["$_"], @ARGV;
2578 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
2579 # We take a very conservative approach here, but it's worth it.
2580 # We move Makefile to Makefile.old here to avoid gnu make looping.
2581 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2582 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
2583 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2584 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2585 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2586 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2587 $(PERLRUN) Makefile.PL %s
2588 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2589 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
2600 Returns true, if the argument is likely to be a command.
2605 my($self,$file) = @_;
2606 return $file if -x $file && ! -d $file;
2611 =item needs_linking (o)
2613 Does this module need linking? Looks into subdirectory objects (see
2614 also has_link_code())
2621 $caller = (caller(0))[3];
2622 confess("needs_linking called too early") if
2623 $caller =~ /^ExtUtils::MakeMaker::/;
2624 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2625 if ($self->has_link_code or $self->{MAKEAPERL}){
2626 $self->{NEEDS_LINKING} = 1;
2629 foreach $child (keys %{$self->{CHILDREN}}) {
2630 if ($self->{CHILDREN}->{$child}->needs_linking) {
2631 $self->{NEEDS_LINKING} = 1;
2635 return $self->{NEEDS_LINKING} = 0;
2640 misnamed method (will have to be changed). The MM_Unix method just
2641 returns the argument without further processing.
2643 On VMS used to insure that colons marking targets are preceded by
2644 space - most Unix Makes don't need this, but it's necessary under VMS
2645 to distinguish the target delimiter from a colon appearing as part of
2651 my($self,$text) = @_;
2655 =item parse_abstract
2657 parse a file and return what you think is the ABSTRACT
2661 sub parse_abstract {
2662 my($self,$parsefile) = @_;
2666 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2668 my $package = $self->{DISTNAME};
2669 $package =~ s/-/::/g;
2671 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2674 next unless /^($package\s-\s)(.*)/;
2684 parse a file and return what you think is $VERSION in this file set to.
2685 It will return the string "undef" if it can't figure out what $VERSION
2686 is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
2687 are okay, but my $VERSION is not.
2692 my($self,$parsefile) = @_;
2697 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2700 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2701 next if $inpod || /^\s*#/;
2703 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
2705 package ExtUtils::MakeMaker::_version;
2714 $result = eval($eval);
2715 warn "Could not eval '$eval' in $parsefile: $@" if $@;
2720 $result = "undef" unless defined $result;
2727 Defines the string that is passed to recursive make calls in
2737 my($sep) = $Is_VMS ? ',' : '';
2740 foreach $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
2741 PREFIX INSTALL_BASE)
2744 next unless defined $self->{$key};
2745 push @pasthru, "$key=\"\$($key)\"";
2748 foreach $key (qw(DEFINE INC)) {
2749 next unless defined $self->{$key};
2750 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
2753 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
2759 Takes one argument, a file name, and returns the file name, if the
2760 argument is likely to be a perl script. On MM_Unix this is true for
2761 any ordinary, readable file.
2766 my($self,$file) = @_;
2767 return $file if -r $file && -f _;
2771 =item perldepend (o)
2773 Defines the dependency from all *.h files that come with the perl
2782 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
2784 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
2785 # Check for unpropogated config.sh changes. Should never happen.
2786 # We do NOT just update config.h because that is not sufficient.
2787 # An out of date config.h is not fatal but complains loudly!
2788 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2789 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2791 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2792 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2796 return join "", @m unless $self->needs_linking;
2800 $(PERL_INC)/EXTERN.h \
2801 $(PERL_INC)/INTERN.h \
2802 $(PERL_INC)/XSUB.h \
2804 $(PERL_INC)/cc_runtime.h \
2805 $(PERL_INC)/config.h \
2808 $(PERL_INC)/dosish.h \
2809 $(PERL_INC)/embed.h \
2810 $(PERL_INC)/embedvar.h \
2811 $(PERL_INC)/fakethr.h \
2812 $(PERL_INC)/form.h \
2814 $(PERL_INC)/handy.h \
2816 $(PERL_INC)/intrpvar.h \
2817 $(PERL_INC)/iperlsys.h \
2818 $(PERL_INC)/keywords.h \
2820 $(PERL_INC)/nostdio.h \
2822 $(PERL_INC)/opcode.h \
2823 $(PERL_INC)/patchlevel.h \
2824 $(PERL_INC)/perl.h \
2825 $(PERL_INC)/perlio.h \
2826 $(PERL_INC)/perlsdio.h \
2827 $(PERL_INC)/perlsfio.h \
2828 $(PERL_INC)/perlvars.h \
2829 $(PERL_INC)/perly.h \
2831 $(PERL_INC)/pp_proto.h \
2832 $(PERL_INC)/proto.h \
2833 $(PERL_INC)/regcomp.h \
2834 $(PERL_INC)/regexp.h \
2835 $(PERL_INC)/regnodes.h \
2836 $(PERL_INC)/scope.h \
2838 $(PERL_INC)/thrdvar.h \
2839 $(PERL_INC)/thread.h \
2840 $(PERL_INC)/unixish.h \
2843 $(OBJECT) : $(PERL_HDRS)
2844 } if $self->{OBJECT};
2846 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2854 Returns the attribute C<PERM_RW> or the string C<644>.
2855 Used as the string that is passed
2856 to the C<chmod> command to set the permissions for read/writeable files.
2857 MakeMaker chooses C<644> because it has turned out in the past that
2858 relying on the umask provokes hard-to-track bug reports.
2859 When the return value is used by the perl function C<chmod>, it is
2860 interpreted as an octal value.
2865 return shift->{PERM_RW};
2870 Returns the attribute C<PERM_RWX> or the string C<755>,
2871 i.e. the string that is passed
2872 to the C<chmod> command to set the permissions for executable files.
2878 return shift->{PERM_RWX};
2883 Defines target that copies all files in the hash PM to their
2884 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
2890 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2892 pm_to_blib : $(TO_INST_PM)
2895 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
2896 pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
2899 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
2901 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
2902 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
2907 =item post_constants (o)
2909 Returns an empty string per default. Dedicated to overrides from
2910 within Makefile.PL after all constants have been defined.
2918 =item post_initialize (o)
2920 Returns an empty string per default. Used in Makefile.PLs to add some
2921 chunk of text to the Makefile after the object is initialized.
2925 sub post_initialize {
2931 Returns an empty string. Can be used in Makefile.PLs to write some
2932 text to the Makefile at the end.
2942 Defines target that creates a PPD (Perl Package Description) file
2943 for a binary distribution.
2950 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
2952 my $abstract = $self->{ABSTRACT} || '';
2953 $abstract =~ s/\n/\\n/sg;
2954 $abstract =~ s/</</g;
2955 $abstract =~ s/>/>/g;
2957 my $author = $self->{AUTHOR} || '';
2958 $author =~ s/</</g;
2959 $author =~ s/>/>/g;
2961 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
2962 <SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
2963 <TITLE>$(DISTNAME)</TITLE>
2964 <ABSTRACT>%s</ABSTRACT>
2968 $ppd_xml .= " <IMPLEMENTATION>\n";
2969 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
2970 my $pre_req = $prereq;
2971 $pre_req =~ s/::/-/g;
2972 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
2974 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
2975 <DEPENDENCY NAME="%s" VERSION="%s" />
2980 my $archname = $Config{archname};
2982 # archname did not change from 5.6 to 5.8, but those versions may
2983 # not be not binary compatible so now we append the part of the
2984 # version that changes when binary compatibility may change
2985 $archname .= "-". substr($Config{version},0,3);
2987 $ppd_xml .= sprintf <<'PPD_OUT', $archname;
2988 <OS NAME="$(OSNAME)" />
2989 <ARCHITECTURE NAME="%s" />
2992 if ($self->{PPM_INSTALL_SCRIPT}) {
2993 if ($self->{PPM_INSTALL_EXEC}) {
2994 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
2995 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
2998 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
2999 $self->{PPM_INSTALL_SCRIPT};
3003 my ($bin_location) = $self->{BINARY_LOCATION} || '';
3004 $bin_location =~ s/\\/\\\\/g;
3006 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
3007 <CODEBASE HREF="%s" />
3012 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
3014 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3015 # Creates a PPD (Perl Package Description) for a binary distribution.
3024 $MM->prefixify($var, $prefix, $new_prefix, $default);
3026 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3027 replace it's $prefix with a $new_prefix.
3029 Should the $prefix fail to match I<AND> a PREFIX was given as an
3030 argument to WriteMakefile() it will set it to the $new_prefix +
3031 $default. This is for systems whose file layouts don't neatly fit into
3032 our ideas of prefixes.
3034 This is for heuristics which attempt to create directory structures
3035 that mirror those of the installed perl.
3039 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3041 this will attempt to remove '/usr' from the front of the
3042 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3043 if necessary) and replace it with '/home/foo'. If this fails it will
3044 simply use '/home/foo/man/man1'.
3049 my($self,$var,$sprefix,$rprefix,$default) = @_;
3051 my $path = $self->{uc $var} ||
3052 $Config_Override{lc $var} || $Config{lc $var} || '';
3054 $rprefix .= '/' if $sprefix =~ m|/$|;
3056 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3057 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
3059 if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) &&
3060 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3063 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3064 print STDERR " no default!\n" if !$default && $Verbose >= 2;
3066 $path = $self->catdir($rprefix, $default) if $default;
3069 print " now $path\n" if $Verbose >= 2;
3070 return $self->{uc $var} = $path;
3076 Defines targets to run *.PL files.
3082 my $pl_files = $self->{PL_FILES};
3084 return "" unless $pl_files;
3087 foreach my $plfile (sort keys %$pl_files) {
3088 my $list = ref($pl_files->{$plfile})
3089 ? $pl_files->{$plfile}
3090 : [$pl_files->{$plfile}];
3092 foreach my $target (@$list) {
3094 $plfile = vmsify($self->eliminate_macros($plfile));
3095 $target = vmsify($self->eliminate_macros($target));
3098 # Normally a .PL file runs AFTER pm_to_blib so it can have
3099 # blib in its @INC and load the just built modules. BUT if
3100 # the generated module is something in $(TO_INST_PM) which
3101 # pm_to_blib depends on then it can't depend on pm_to_blib
3102 # else we have a dependency loop.
3105 if( defined $self->{PM}{$target} ) {
3107 $perlrun = 'PERLRUN';
3110 $pm_dep = 'pm_to_blib';
3111 $perlrun = 'PERLRUNINST';
3119 $target :: $plfile $pm_dep
3120 \$($perlrun) $plfile $target
3131 Backslashes parentheses C<()> in command line arguments.
3132 Doesn't handle recursive Makefile C<$(...)> constructs,
3133 but handles simple ones.
3139 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3140 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3141 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
3145 =item replace_manpage_separator
3147 my $man_name = $MM->replace_manpage_separator($file_path);
3149 Takes the name of a package, which may be a nested package, in the
3150 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3151 safe for a man page file name. Returns the replacement.
3155 sub replace_manpage_separator {
3156 my($self,$man) = @_;
3168 my($self, $dir, @cmds) = @_;
3170 # No leading tab and no trailing newline makes for easier embedding
3171 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3181 my($self, $cmd, $switches) = @_;
3182 $switches = [] unless defined $switches;
3184 # Strip leading and trailing newlines
3188 my @cmds = split /\n/, $cmd;
3189 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
3190 $cmd = $self->escape_newlines($cmd);
3192 $switches = join ' ', @$switches;
3194 return qq{\$(ABSPERLRUN) $switches -e $cmd --};
3203 my($self, $text) = @_;
3205 # I think all we have to quote is single quotes and I think
3206 # this is a safe way to do it.
3207 $text =~ s{'}{'\\''}g;
3213 =item escape_newlines
3217 sub escape_newlines {
3218 my($self, $text) = @_;
3220 $text =~ s{\n}{\\\n}g;
3228 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3235 if (!defined $self->{_MAX_EXEC_LEN}) {
3236 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3237 $self->{_MAX_EXEC_LEN} = $arg_max;
3239 else { # POSIX minimum exec size
3240 $self->{_MAX_EXEC_LEN} = 4096;
3244 return $self->{_MAX_EXEC_LEN};
3250 Defines the static target.
3255 # --- Static Loading Sections ---
3259 ## $(INST_PM) has been moved to the all: target.
3260 ## It remains here for awhile to allow for old usage: "make static"
3261 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3266 =item static_lib (o)
3268 Defines how to produce the *.a (or equivalent) files.
3274 return '' unless $self->has_link_code;
3279 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
3283 # If this extension has its own library (eg SDBM_File)
3284 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3285 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3286 $(CP) $(MYEXTLIB) $@
3290 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3291 # Prefer the absolute pathed ar if available so that PATH
3292 # doesn't confuse us. Perl itself is built with the full_ar.
3297 push @m, sprintf <<'MAKE_FRAG', $ar;
3298 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3299 $(CHMOD) $(PERM_RWX) $@
3300 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3303 # Old mechanism - still available:
3304 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3305 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3311 =item staticmake (o)
3318 my($self, %attribs) = @_;
3321 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3323 # And as it's not yet built, we add the current extension
3324 # but only if it has some C code (or XS code, which implies C code)
3325 if (@{$self->{C}}) {
3326 @static = $self->catfile($self->{INST_ARCHLIB},
3329 "$self->{BASEEXT}$self->{LIB_EXT}"
3333 # Either we determine now, which libraries we will produce in the
3334 # subdirectories or we do it at runtime of the make.
3336 # We could ask all subdir objects, but I cannot imagine, why it
3337 # would be necessary.
3339 # Instead we determine all libraries for the new perl at
3341 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3343 $self->makeaperl(MAKE => $self->{MAKEFILE},
3344 DIRS => \@searchdirs,
3347 TARGET => $self->{MAP_TARGET},
3349 LIBPERL => $self->{LIBPERL_A}
3355 Helper subroutine for subdirs
3360 my($self, $subdir) = @_;
3362 my $subdir_cmd = $self->cd($subdir,
3363 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3365 return sprintf <<'EOT', $subdir_cmd;
3375 Defines targets to process subdirectories.
3380 # --- Sub-directory Sections ---
3383 # This method provides a mechanism to automatically deal with
3384 # subdirectories containing further Makefile.PL scripts.
3385 # It calls the subdir_x() method for each subdirectory.
3386 foreach $dir (@{$self->{DIR}}){
3387 push(@m, $self->subdir_x($dir));
3388 #### print "Including $dir subdirectory\n";
3392 # The default clean, realclean and test targets in this Makefile
3393 # have automatically been given entries for each subdir.
3397 push(@m, "\n# none")
3404 Defines the test targets.
3409 # --- Test and Installation Sections ---
3411 my($self, %attribs) = @_;
3412 my $tests = $attribs{TESTS} || '';
3413 if (!$tests && -d 't') {
3414 $tests = $self->find_tests;
3416 # note: 'test.pl' name is also hardcoded in init_dirscan()
3418 my $subdirs_test = ($self->{DIR} && @{$self->{DIR}} ? 'subdirs-test' : '');
3421 TEST_TYPE=test_\$(LINKTYPE)
3426 testdb :: testdb_\$(LINKTYPE)
3428 test :: \$(TEST_TYPE) $subdirs_test
3431 foreach my $dir (@{ $self->{DIR} }) {
3432 my $test = $self->oneliner(sprintf <<'CODE', $dir);
3434 system '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) test $(PASTHRU)'
3435 if -f '$(FIRST_MAKEFILE)';
3438 push(@m, "\nsubdirs-test ::\n\t\$(NOECHO) $test\n");
3441 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3442 unless $tests or -f "test.pl" or @{$self->{DIR}};
3445 push(@m, "test_dynamic :: pure_all\n");
3446 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3448 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3452 push(@m, "testdb_dynamic :: pure_all\n");
3453 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3457 # Occasionally we may face this degenerate target:
3458 push @m, "test_ : test_dynamic\n\n";
3460 if ($self->needs_linking()) {
3461 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3462 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3463 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3465 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3466 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3469 push @m, "test_static :: test_dynamic\n";
3470 push @m, "testdb_static :: testdb_dynamic\n";
3475 =item test_via_harness (override)
3477 For some reason which I forget, Unix machines like to have
3478 PERL_DL_NONLAZY set for tests.
3482 sub test_via_harness {
3483 my($self, $perl, $tests) = @_;
3484 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3487 =item test_via_script (override)
3489 Again, the PERL_DL_NONLAZY thing.
3493 sub test_via_script {
3494 my($self, $perl, $script) = @_;
3495 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3499 =item tools_other (o)
3501 my $make_frag = $MM->tools_other;
3503 Returns a make fragment containing definitions for the macros init_others()
3512 # We set PM_FILTER as late as possible so it can see all the earlier
3513 # on macro-order sensitive makes such as nmake.
3514 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
3515 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
3518 MOD_INSTALL DOC_INSTALL UNINSTALL
3519 WARN_IF_OLD_PACKLIST
3526 next unless defined $self->{$tool};
3527 push @m, "$tool = $self->{$tool}\n";
3533 =item tool_xsubpp (o)
3535 Determines typemaps, xsubpp version, prototype behaviour.
3541 return "" unless $self->needs_linking;
3544 my @xsubpp_dirs = @INC;
3546 # Make sure we pick up the new xsubpp if we're building perl.
3547 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3549 foreach my $dir (@xsubpp_dirs) {
3550 $xsdir = $self->catdir($dir, 'ExtUtils');
3551 if( -r $self->catfile($xsdir, "xsubpp") ) {
3556 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3557 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3558 if( $self->{TYPEMAPS} ){
3560 foreach $typemap (@{$self->{TYPEMAPS}}){
3561 if( ! -f $typemap ){
3562 warn "Typemap $typemap not found.\n";
3565 push(@tmdeps, $typemap);
3569 push(@tmdeps, "typemap") if -f "typemap";
3570 my(@tmargs) = map("-typemap $_", @tmdeps);
3571 if( exists $self->{XSOPT} ){
3572 unshift( @tmargs, $self->{XSOPT} );
3576 $Config{'ldflags'} &&
3577 $Config{'ldflags'} =~ m!/Debug!i &&
3578 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
3581 unshift(@tmargs,'-nolinenumbers');
3585 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3589 XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp
3590 XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
3591 XSPROTOARG = $self->{XSPROTOARG}
3592 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3593 XSUBPPARGS = @tmargs
3601 Build man pages, too
3608 return <<'MAKE_EXT';
3609 all :: pure_all manifypods
3614 =item top_targets (o)
3616 Defines the targets all, subdirs, config, and O_FILES
3621 # --- Target Sections ---
3626 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3629 pure_all :: config pm_to_blib subdirs linkext
3632 subdirs :: $(MYEXTLIB)
3635 config :: $(FIRST_MAKEFILE) blibdirs
3640 $(O_FILES): $(H_FILES)
3641 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3645 perldoc ExtUtils::MakeMaker
3653 Obsolete, deprecated method. Not used since Version 5.21.
3658 # --- perllocal.pod section ---
3659 my($self,$what,$name,@attribs)=@_;
3660 my $time = localtime;
3661 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3662 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3663 print "\n\n=back\n\n";
3668 Defines the suffix rules to compile XS files to C.
3674 return '' unless $self->needs_linking();
3677 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3683 Defines the suffix rules to compile XS files to C++.
3689 return '' unless $self->needs_linking();
3692 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
3698 Defines suffix rules to go from XS to object files directly. This is
3699 only intended for broken make implementations.
3703 sub xs_o { # many makes are too dumb to use xs_c then c_o
3705 return '' unless $self->needs_linking();
3708 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3709 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
3720 L<ExtUtils::MakeMaker>