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);
21 # $VERSION needs to stay numeric to avoid test warnings
24 require ExtUtils::MM_Any;
25 @ISA = qw(ExtUtils::MM_Any);
28 $Is_OS2 = $^O eq 'os2';
29 $Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
30 $Is_Dos = $^O eq 'dos';
31 $Is_VMS = $^O eq 'VMS';
32 $Is_OSF = $^O eq 'dec_osf';
33 $Is_IRIX = $^O eq 'irix';
34 $Is_NetBSD = $^O eq 'netbsd';
35 $Is_Interix = $^O eq 'interix';
36 $Is_SunOS4 = $^O eq 'sunos';
37 $Is_Solaris = $^O eq 'solaris';
38 $Is_SunOS = $Is_SunOS4 || $Is_Solaris;
39 $Is_BSD = $^O =~ /^(?:free|net|open)bsd$/ or
40 $^O eq 'bsdos' or $^O eq 'interix';
45 # For things like vmsify()
46 require VMS::Filespec;
47 VMS::Filespec->import;
54 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
58 C<require ExtUtils::MM_Unix;>
62 The methods provided by this package are designed to be used in
63 conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
64 Makefile, it creates one or more objects that inherit their methods
65 from a package C<MM>. MM itself doesn't provide any methods, but it
66 ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
67 specific packages take the responsibility for all the methods provided
68 by MM_Unix. We are trying to reduce the number of the necessary
69 overrides by defining rather primitive operations within
72 If you are going to write a platform specific MM package, please try
73 to limit the necessary overrides to primitive methods, and if it is not
74 possible to do so, let's work out how to achieve that gain.
76 If you are overriding any of these methods in your Makefile.PL (in the
77 MY class), please report that to the makemaker mailing list. We are
78 trying to minimize the necessary method overrides and switch to data
79 driven Makefile.PLs wherever possible. In the long run less methods
80 will be overridable via the MY class.
84 The following description of methods is still under
85 development. Please refer to the code for not suitably documented
86 sections and complain loudly to the makemaker@perl.org mailing list.
87 Better yet, provide a patch.
89 Not all of the methods below are overridable in a
90 Makefile.PL. Overridable methods are marked as (o). All methods are
91 overridable by a platform specific MM_*.pm file.
93 Cross-platform methods are being moved into MM_Any. If you can't find
94 something that used to be in here, look in MM_Any.
98 # So we don't have to keep calling the methods over and over again,
99 # we have these globals to cache the values. Faster and shrtr.
100 my $Curdir = __PACKAGE__->curdir;
101 my $Rootdir = __PACKAGE__->rootdir;
102 my $Updir = __PACKAGE__->updir;
111 Simply says that we're Unix.
122 Defines the suffix rules to compile different flavors of C files to
128 # --- Translation Sections ---
131 return '' unless $self->needs_linking();
133 if (my $cpp = $Config{cpprun}) {
134 my $cpp_cmd = $self->const_cccmd;
135 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/;
138 '. $cpp_cmd . ' $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i
143 $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
147 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
151 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C
152 ' if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific
155 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp
158 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx
161 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc
168 Does very much the same as the cflags script in the perl
169 distribution. It doesn't return the whole compiler command line, but
170 initializes all of its parts. The const_cccmd method then actually
171 returns the definition of the CCCMD macro which uses these parts.
178 my($self,$libperl)=@_;
179 return $self->{CFLAGS} if $self->{CFLAGS};
180 return '' unless $self->needs_linking();
182 my($prog, $uc, $perltype, %cflags);
183 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
184 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
186 @cflags{qw(cc ccflags optimize shellflags)}
187 = @Config{qw(cc ccflags optimize shellflags)};
190 $cflags{shellflags} ||= '';
195 DE => '-DDEBUGGING -DEMBED',
196 M => '-DEMBED -DMULTIPLICITY',
197 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
200 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
203 $uc = ""; # avoid warning
205 $perltype = $map{$uc} ? $map{$uc} : "";
213 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
214 if ($prog = $Config{$name}) {
215 # Expand hints for this extension via the shell
216 print STDOUT "Processing $name hint:\n" if $Verbose;
217 my(@o)=`cc=\"$cflags{cc}\"
218 ccflags=\"$cflags{ccflags}\"
219 optimize=\"$cflags{optimize}\"
220 perltype=\"$cflags{perltype}\"
221 optdebug=\"$cflags{optdebug}\"
224 echo ccflags=\$ccflags
225 echo optimize=\$optimize
226 echo perltype=\$perltype
227 echo optdebug=\$optdebug
232 if ($line =~ /(.*?)=\s*(.*)\s*$/){
234 print STDOUT " $1 = $2\n" if $Verbose;
236 print STDOUT "Unrecognised result from hint: '$line'\n";
242 $cflags{optimize} = $optdebug;
245 for (qw(ccflags optimize perltype)) {
247 $cflags{$_} =~ s/^\s+//;
248 $cflags{$_} =~ s/\s+/ /g;
249 $cflags{$_} =~ s/\s+$//;
250 $self->{uc $_} ||= $cflags{$_};
253 if ($self->{POLLUTE}) {
254 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
258 if ($Config{usemymalloc} and not $Config{bincompat5005}
259 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
260 and $self->{PERL_MALLOC_OK}) {
261 $pollute = '$(PERL_MALLOC_DEF)';
264 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS});
265 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE});
267 return $self->{CFLAGS} = qq{
268 CCFLAGS = $self->{CCFLAGS}
269 OPTIMIZE = $self->{OPTIMIZE}
270 PERLTYPE = $self->{PERLTYPE}
277 =item const_cccmd (o)
279 Returns the full compiler call for C programs and stores the
280 definition in CONST_CCCMD.
285 my($self,$libperl)=@_;
286 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
287 return '' unless $self->needs_linking();
288 return $self->{CONST_CCCMD} =
289 q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
290 $(CCFLAGS) $(OPTIMIZE) \\
291 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
292 $(XS_DEFINE_VERSION)};
295 =item const_config (o)
297 Defines a couple of constants in the Makefile that are imported from
303 # --- Constants Sections ---
307 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
308 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
310 foreach $m (@{$self->{CONFIG}}){
311 # SITE*EXP macros are defined in &constants; avoid duplicates here
312 next if $once_only{$m};
313 $self->{uc $m} = quote_paren($self->{uc $m});
314 push @m, uc($m) , ' = ' , $self->{uc $m}, "\n";
320 =item const_loadlibs (o)
322 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
323 L<ExtUtils::Liblist> for details.
329 return "" unless $self->needs_linking;
332 # $self->{NAME} might depend on some other libraries:
333 # See ExtUtils::Liblist for details
338 EXTRALIBS LDLOADLIBS BSLOADLIBS
340 next unless defined $self->{$tmp};
341 push @m, "$tmp = $self->{$tmp}\n";
343 # don't set LD_RUN_PATH if empty
347 next unless $self->{$tmp};
348 push @m, "$tmp = $self->{$tmp}\n";
355 my $make_frag = $mm->constants;
357 Prints out macros for lots of constants.
365 $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use
369 AR_STATIC_ARGS DIRFILESEP DFSEP
371 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
372 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
373 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
374 INST_MAN1DIR INST_MAN3DIR
376 INSTALLDIRS INSTALL_BASE DESTDIR PREFIX
377 PERLPREFIX SITEPREFIX VENDORPREFIX
379 (map { ("INSTALL".$_,
381 } $self->installvars),
386 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
387 PERLMAINCC PERL_SRC PERL_INC
388 PERL FULLPERL ABSPERL
389 PERLRUN FULLPERLRUN ABSPERLRUN
390 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
396 next unless defined $self->{$macro};
398 # pathnames can have sharp signs in them; escape them so
399 # make doesn't think it is a comment-start character.
400 $self->{$macro} =~ s/#/\\#/g;
401 push @m, "$macro = $self->{$macro}\n";
405 MAKEMAKER = $self->{MAKEMAKER}
406 MM_VERSION = $self->{MM_VERSION}
407 MM_REVISION = $self->{MM_REVISION}
411 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
412 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
413 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
414 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
419 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
420 LDFROM LINKTYPE BOOTDEP
423 next unless defined $self->{$macro};
424 push @m, "$macro = $self->{$macro}\n";
428 # Handy lists of source code files:
429 XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
430 C_FILES = ".$self->wraplist(@{$self->{C}})."
431 O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."
432 H_FILES = ".$self->wraplist(@{$self->{H}})."
433 MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
434 MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
439 # Where is the Config information that we are using/depend on
440 CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
445 # Where to build things
446 INST_LIBDIR = $self->{INST_LIBDIR}
447 INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
449 INST_AUTODIR = $self->{INST_AUTODIR}
450 INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
452 INST_STATIC = $self->{INST_STATIC}
453 INST_DYNAMIC = $self->{INST_DYNAMIC}
454 INST_BOOT = $self->{INST_BOOT}
460 EXPORT_LIST = $self->{EXPORT_LIST}
461 PERL_ARCHIVE = $self->{PERL_ARCHIVE}
462 PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
467 TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."
469 PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}})."
478 Same as macro for the depend attribute.
483 my($self,%attribs) = @_;
485 while (($key,$val) = each %attribs){
486 last unless defined $key;
487 push @m, "$key : $val\n";
497 Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
505 $self->{DESTDIR} ||= '';
507 # Make DEST variables.
508 foreach my $var ($self->installvars) {
509 my $destvar = 'DESTINSTALL'.$var;
510 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
519 Defines a lot of macros for distribution support.
521 macro description default
523 TAR tar command to use tar
524 TARFLAGS flags to pass to TAR cvf
526 ZIP zip command to use zip
527 ZIPFLAGS flags to pass to ZIP -r
529 COMPRESS compression command to gzip --best
531 SUFFIX suffix to put on .gz
534 SHAR shar command to use shar
536 PREOP extra commands to run before
538 POSTOP extra commands to run after
541 TO_UNIX a command to convert linefeeds
542 to Unix style in your archive
544 CI command to checkin your ci -u
545 sources to version control
546 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
549 DIST_CP $how argument to manicopy() best
550 when the distdir is created
552 DIST_DEFAULT default target to use to tardist
553 create a distribution
555 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
563 $self->{TAR} ||= 'tar';
564 $self->{TARFLAGS} ||= 'cvf';
565 $self->{ZIP} ||= 'zip';
566 $self->{ZIPFLAGS} ||= '-r';
567 $self->{COMPRESS} ||= 'gzip --best';
568 $self->{SUFFIX} ||= '.gz';
569 $self->{SHAR} ||= 'shar';
570 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
571 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
572 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
574 $self->{CI} ||= 'ci -u';
575 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
576 $self->{DIST_CP} ||= 'best';
577 $self->{DIST_DEFAULT} ||= 'tardist';
579 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
580 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
586 my $dist_macros = $mm->dist(%overrides);
588 Generates a make fragment defining all the macros initialized in
591 %overrides can be used to override any of the above.
596 my($self, %attribs) = @_;
600 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
602 CI RCS_LABEL DIST_CP DIST_DEFAULT
606 my $value = $attribs{$key} || $self->{$key};
607 $make .= "$key = $value\n";
613 =item dist_basics (o)
615 Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
622 return <<'MAKE_FRAG';
623 distclean :: realclean distcheck
627 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
630 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
633 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
635 veryclean : realclean
636 $(RM_F) *~ *.orig */*~ */*.orig
644 Defines a check in target for RCS.
652 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\
653 -e "@all = keys %{ maniread() };" \\
654 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\
655 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
661 my $dist_make_fragment = $MM->dist_core;
663 Puts the targets necessary for 'make dist' together into one make
672 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
675 my $method = $target.'_target';
677 $make_frag .= $self->$method();
686 my $make_frag = $MM->dist_target;
688 Returns the 'dist' target to make an archive for distribution. This
689 target simply checks to make sure the Makefile is up-to-date and
690 depends on $(DIST_DEFAULT).
697 my $date_check = $self->oneliner(<<'CODE', ['-l']);
698 print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
699 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
702 return sprintf <<'MAKE_FRAG', $date_check;
703 dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
708 =item B<tardist_target>
710 my $make_frag = $MM->tardist_target;
712 Returns the 'tardist' target which is simply so 'make tardist' works.
713 The real work is done by the dynamically named tardistfile_target()
714 method, tardist should have that as a dependency.
721 return <<'MAKE_FRAG';
722 tardist : $(DISTVNAME).tar$(SUFFIX)
727 =item B<zipdist_target>
729 my $make_frag = $MM->zipdist_target;
731 Returns the 'zipdist' target which is simply so 'make zipdist' works.
732 The real work is done by the dynamically named zipdistfile_target()
733 method, zipdist should have that as a dependency.
740 return <<'MAKE_FRAG';
741 zipdist : $(DISTVNAME).zip
746 =item B<tarfile_target>
748 my $make_frag = $MM->tarfile_target;
750 The name of this target is the name of the tarball generated by
751 tardist. This target does the actual work of turning the distdir into
759 return <<'MAKE_FRAG';
760 $(DISTVNAME).tar$(SUFFIX) : distdir
763 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
764 $(RM_RF) $(DISTVNAME)
765 $(COMPRESS) $(DISTVNAME).tar
772 my $make_frag = $MM->zipfile_target;
774 The name of this target is the name of the zip file generated by
775 zipdist. This target does the actual work of turning the distdir into
783 return <<'MAKE_FRAG';
784 $(DISTVNAME).zip : distdir
786 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
787 $(RM_RF) $(DISTVNAME)
792 =item uutardist_target
794 my $make_frag = $MM->uutardist_target;
796 Converts the tarfile into a uuencoded file
800 sub uutardist_target {
803 return <<'MAKE_FRAG';
804 uutardist : $(DISTVNAME).tar$(SUFFIX)
805 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
812 my $make_frag = $MM->shdist_target;
814 Converts the distdir into a shell archive.
821 return <<'MAKE_FRAG';
824 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
825 $(RM_RF) $(DISTVNAME)
833 Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files.
835 Normally just returns an empty string.
846 Defines targets for bootstrap files.
851 my($self, %attribs) = @_;
854 ' unless $self->has_link_code();
856 my $target = $Is_VMS ? '$(MMS$TARGET)' : '$@';
858 return sprintf <<'MAKE_FRAG', ($target) x 5;
859 BOOTSTRAP = $(BASEEXT).bs
861 # As Mkbootstrap might not write a file (if none is required)
862 # we use touch to prevent make continually trying to remake it.
863 # The DynaLoader only reads a non-empty file.
864 $(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
865 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
866 $(NOECHO) $(PERLRUN) \
867 "-MExtUtils::Mkbootstrap" \
868 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
869 $(NOECHO) $(TOUCH) %s
870 $(CHMOD) $(PERM_RW) %s
872 $(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
873 $(NOECHO) $(RM_RF) %s
874 - $(CP) $(BOOTSTRAP) %s
875 $(CHMOD) $(PERM_RW) %s
879 =item dynamic_lib (o)
881 Defines how to produce the *.so (or equivalent) files.
886 my($self, %attribs) = @_;
887 return '' unless $self->needs_linking(); #might be because of a subdir
889 return '' unless $self->has_link_code;
891 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
892 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
893 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
894 my($ldfrom) = '$(LDFROM)';
895 $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':');
897 my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
898 my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : '';
900 # This section creates the dynamically loadable $(INST_DYNAMIC)
901 # from $(OBJECT) and possibly $(MYEXTLIB).
902 ARMAYBE = '.$armaybe.'
903 OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
904 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
905 INST_DYNAMIC_FIX = '.$ld_fix.'
907 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
909 if ($armaybe ne ':'){
910 $ldfrom = 'tmp$(LIB_EXT)';
911 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
912 push(@m,' $(RANLIB) '."$ldfrom\n");
914 $ldfrom = "-all $ldfrom -none" if $Is_OSF;
916 # The IRIX linker doesn't use LD_RUN_PATH
917 my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ?
918 qq{-rpath "$self->{LD_RUN_PATH}"} : '';
920 # For example in AIX the shared objects/libraries from previous builds
921 # linger quite a while in the shared dynalinker cache even when nobody
922 # is using them. This is painful if one for instance tries to restart
923 # a failed build because the link command will fail unnecessarily 'cos
924 # the shared object/library is 'busy'.
928 my $libs = '$(LDLOADLIBS)';
930 if (($Is_NetBSD || $Is_Interix) && $Config{'useshrplib'}) {
931 # Use nothing on static perl platforms, and to the flags needed
932 # to link against the shared libperl library on shared perl
933 # platforms. We peek at lddlflags to see if we need -Wl,-R
934 # or -R to add paths to the run-time library search path.
935 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
936 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
937 } elsif ($Config{'lddlflags'} =~ /-R/) {
938 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
942 my $ld_run_path_shell = "";
943 if ($self->{LD_RUN_PATH} ne "") {
944 $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
947 push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs;
948 %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
949 $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
954 $(CHMOD) $(PERM_RWX) $@
962 Deprecated method. Use libscan instead.
967 my($self,$path) = @_;
973 Called by init_others, and calls ext ExtUtils::Liblist. See
974 L<ExtUtils::Liblist> for details.
979 my($self,$libs) = @_;
980 require ExtUtils::Liblist;
981 $self->ext($libs, $Verbose);
986 Finds the executables PERL and FULLPERL
991 my($self, $ver, $names, $dirs, $trace) = @_;
994 print "Looking for perl $ver by these names:
1001 my $stderr_duped = 0;
1004 if( open(STDERR_COPY, '>&STDERR') ) {
1009 find_perl() can't dup STDERR: $!
1010 You might see some garbage while we search for Perl
1015 foreach $name (@$names){
1016 foreach $dir (@$dirs){
1017 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1019 if ($self->file_name_is_absolute($name)) { # /foo/bar
1021 } elsif ($self->canonpath($name) eq
1022 $self->canonpath(basename($name))) { # foo
1023 $abs = $self->catfile($dir, $name);
1025 $abs = $self->catfile($Curdir, $name);
1027 print "Checking $abs\n" if ($trace >= 2);
1028 next unless $self->maybe_command($abs);
1029 print "Executing $abs\n" if ($trace >= 2);
1031 my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"};
1032 # To avoid using the unportable 2>&1 to suppress STDERR,
1033 # we close it before running the command.
1034 # However, thanks to a thread library bug in many BSDs
1035 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1036 # we cannot use the fancier more portable way in here
1037 # but instead need to use the traditional 2>&1 construct.
1039 $val = `$version_check 2>&1`;
1041 close STDERR if $stderr_duped;
1042 $val = `$version_check`;
1043 open STDERR, '>&STDERR_COPY' if $stderr_duped;
1046 if ($val =~ /^VER_OK/) {
1047 print "Using PERL=$abs\n" if $trace;
1049 } elsif ($trace >= 2) {
1050 print "Result: '$val' ".($? >> 8)."\n";
1054 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1055 0; # false and not empty
1063 Inserts the sharpbang or equivalent magic number to a set of @files.
1067 sub fixin { # stolen from the pink Camel book, more or less
1068 my($self, @files) = @_;
1070 my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1071 for my $file (@files) {
1072 my $file_new = "$file.new";
1073 my $file_bak = "$file.bak";
1077 open(FIXIN, $file) or croak "Can't process '$file': $!";
1079 chomp(my $line = <FIXIN>);
1080 next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
1081 # Now figure out the interpreter name.
1082 my($cmd,$arg) = split ' ', $line, 2;
1085 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
1087 if ($cmd eq "perl") {
1088 if ($Config{startperl} =~ m,^\#!.*/perl,) {
1089 $interpreter = $Config{startperl};
1090 $interpreter =~ s,^\#!,,;
1092 $interpreter = $Config{perlpath};
1095 my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path;
1098 foreach $dir (@absdirs) {
1099 if ($self->maybe_command($cmd)) {
1100 warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter;
1101 $interpreter = $self->catfile($dir,$cmd);
1105 # Figure out how to invoke interpreter on this machine.
1109 print STDOUT "Changing sharpbang in $file to $interpreter" if $Verbose;
1110 # this is probably value-free on DOSISH platforms
1112 $shb .= "$Config{'sharpbang'}$interpreter";
1113 $shb .= ' ' . $arg if defined $arg;
1117 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
1118 if 0; # not running under some shell
1119 } unless $Is_Win32; # this won't work on win32, so don't
1121 warn "Can't find $cmd in PATH, $file unchanged"
1126 unless ( open(FIXOUT,">$file_new") ) {
1127 warn "Can't create new $file: $!\n";
1131 # Print out the new #! line (or equivalent).
1134 print FIXOUT $shb, <FIXIN>;
1138 chmod 0666, $file_bak;
1140 unless ( _rename($file, $file_bak) ) {
1141 warn "Can't rename $file to $file_bak: $!";
1144 unless ( _rename($file_new, $file) ) {
1145 warn "Can't rename $file_new to $file: $!";
1146 unless ( _rename($file_bak, $file) ) {
1147 warn "Can't rename $file_bak back to $file either: $!";
1148 warn "Leaving $file renamed as $file_bak\n";
1154 close(FIXIN) if fileno(FIXIN);
1155 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
1161 my($old, $new) = @_;
1163 foreach my $file ($old, $new) {
1164 if( $Is_VMS and basename($file) !~ /\./ ) {
1165 # rename() in 5.8.0 on VMS will not rename a file if it
1166 # does not contain a dot yet it returns success.
1171 return rename($old, $new);
1177 Writes an empty FORCE: target.
1183 '# Phony target to force checking subdirectories.
1191 Guess the name of this package by examining the working directory's
1192 name. MakeMaker calls this only if the developer has not supplied a
1202 my $name = basename(cwd());
1203 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
1204 # strip minus or underline
1205 # followed by a float or some such
1206 print "Warning: Guessing NAME [$name] from current directory name.\n";
1212 Returns true if C, XS, MYEXTLIB or similar objects exist within this
1213 object that need a compiler. Does not descend into subdirectories as
1214 needs_linking() does.
1220 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1221 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1222 $self->{HAS_LINK_CODE} = 1;
1225 return $self->{HAS_LINK_CODE} = 0;
1231 Scans the directory structure and initializes DIR, XS, XS_FILES,
1232 C, C_FILES, O_FILES, H, H_FILES, PL_FILES, EXE_FILES.
1234 Called by init_main.
1238 sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1240 my($name, %dir, %xs, %c, %h, %pl_files, %pm);
1242 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
1244 # ignore the distdir
1245 $Is_VMS ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1246 : $ignore{$self->{DISTVNAME}} = 1;
1248 @ignore{map lc, keys %ignore} = values %ignore if $Is_VMS;
1250 foreach $name ($self->lsdir($Curdir)){
1251 next if $name =~ /\#/;
1252 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
1253 next unless $self->libscan($name);
1255 next if -l $name; # We do not support symlinks at all
1256 next if $self->{NORECURS};
1257 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1258 } elsif ($name =~ /\.xs\z/){
1259 my($c); ($c = $name) =~ s/\.xs\z/.c/;
1262 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
1264 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1265 } elsif ($name =~ /\.h\z/i){
1267 } elsif ($name =~ /\.PL\z/) {
1268 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
1269 } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
1270 # case-insensitive filesystem, one dot per name, so foo.h.PL
1271 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
1272 local($/); open(PL,$name); my $txt = <PL>; close PL;
1273 if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
1274 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
1277 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1279 } elsif ($name =~ /\.(p[ml]|pod)\z/){
1280 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1284 $self->{PL_FILES} ||= \%pl_files;
1285 $self->{DIR} ||= [sort keys %dir];
1286 $self->{XS} ||= \%xs;
1287 $self->{C} ||= [sort keys %c];
1288 $self->{H} ||= [sort keys %h];
1289 $self->{PM} ||= \%pm;
1291 my @o_files = @{$self->{C}};
1292 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
1298 Determines if man pages should be generated and initializes MAN1PODS
1299 and MAN3PODS as appropriate.
1306 # Set up names of manual pages to generate from pods
1307 foreach my $man (qw(MAN1 MAN3)) {
1308 unless ($self->{"${man}PODS"}) {
1309 $self->{"${man}PODS"} = {};
1310 unless ($self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/) {
1311 my $init = "init_${man}PODS";
1320 my($self, $file) = @_;
1324 if (open(FH,"<$file")) {
1326 if (/^=(?:head\d+|item|pod)\b/) {
1333 # If it doesn't exist yet, we assume, it has pods in it
1343 Initializes MAN1PODS from the list of EXE_FILES.
1350 if ( exists $self->{EXE_FILES} ) {
1351 foreach my $name (@{$self->{EXE_FILES}}) {
1352 next unless $self->_has_pod($name);
1354 $self->{MAN1PODS}->{$name} =
1355 $self->catfile("\$(INST_MAN1DIR)",
1356 basename($name).".\$(MAN1EXT)");
1364 Initializes MAN3PODS from the list of PM files.
1371 my %manifypods = (); # we collect the keys first, i.e. the files
1372 # we have to convert to pod
1374 foreach my $name (keys %{$self->{PM}}) {
1375 if ($name =~ /\.pod\z/ ) {
1376 $manifypods{$name} = $self->{PM}{$name};
1377 } elsif ($name =~ /\.p[ml]\z/ ) {
1378 if( $self->_has_pod($name) ) {
1379 $manifypods{$name} = $self->{PM}{$name};
1384 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1386 # Remove "Configure.pm" and similar, if it's not the only pod listed
1387 # To force inclusion, just name it "Configure.pod", or override
1389 foreach my $name (keys %manifypods) {
1390 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
1391 delete $manifypods{$name};
1394 my($manpagename) = $name;
1395 $manpagename =~ s/\.p(od|m|l)\z//;
1396 # everything below lib is ok
1397 unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1398 $manpagename = $self->catfile(
1399 split(/::/,$self->{PARENT_NAME}),$manpagename
1402 $manpagename = $self->replace_manpage_separator($manpagename);
1403 $self->{MAN3PODS}->{$name} =
1404 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1411 Initializes PMLIBDIRS and PM from PMLIBDIRS.
1418 my $pm = $self->{PM};
1420 # Some larger extensions often wish to install a number of *.pm/pl
1421 # files into the library in various locations.
1423 # The attribute PMLIBDIRS holds an array reference which lists
1424 # subdirectories which we should search for library files to
1425 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1426 # recursively search through the named directories (skipping any
1427 # which don't exist or contain Makefile.PL files).
1429 # For each *.pm or *.pl file found $self->libscan() is called with
1430 # the default installation path in $_[1]. The return value of
1431 # libscan defines the actual installation location. The default
1432 # libscan function simply returns the path. The file is skipped
1433 # if libscan returns false.
1435 # The default installation location passed to libscan in $_[1] is:
1437 # ./*.pm => $(INST_LIBDIR)/*.pm
1438 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1439 # ./lib/... => $(INST_LIB)/...
1441 # In this way the 'lib' directory is seen as the root of the actual
1442 # perl library whereas the others are relative to INST_LIBDIR
1443 # (which includes PARENT_NAME). This is a subtle distinction but one
1444 # that's important for nested modules.
1446 unless( $self->{PMLIBDIRS} ) {
1448 # Avoid logical name vs directory collisions
1449 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1452 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1456 #only existing directories that aren't in $dir are allowed
1458 # Avoid $_ wherever possible:
1459 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1460 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1461 @{$self->{PMLIBDIRS}} = ();
1462 my %dir = map { ($_ => $_) } @{$self->{DIR}};
1463 foreach my $pmlibdir (@pmlibdirs) {
1464 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1467 unless( $self->{PMLIBPARENTDIRS} ) {
1468 @{$self->{PMLIBPARENTDIRS}} = ('lib');
1471 if (@{$self->{PMLIBDIRS}}){
1472 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1475 File::Find::find(sub {
1477 unless ($self->libscan($_)){
1478 $File::Find::prune = 1;
1483 return if /~$/; # emacs temp files
1484 return if /,v$/; # RCS files
1486 my $path = $File::Find::name;
1487 my $prefix = $self->{INST_LIBDIR};
1490 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1491 $prefix = $self->{INST_LIB}
1492 if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W}
1495 my($inst) = $self->catfile($prefix,$striplibpath);
1496 local($_) = $inst; # for backwards compatibility
1497 $inst = $self->libscan($inst);
1498 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1499 return unless $inst;
1500 $pm->{$path} = $inst;
1501 }, @{$self->{PMLIBDIRS}});
1506 =item init_DIRFILESEP
1508 Using / for Unix. Called by init_main.
1512 sub init_DIRFILESEP {
1515 $self->{DIRFILESEP} = '/';
1521 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1522 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1523 INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1524 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1525 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1526 VERSION_SYM, XS_VERSION.
1533 # --- Initialize Module Name and Paths
1535 # NAME = Foo::Bar::Oracle
1536 # FULLEXT = Foo/Bar/Oracle
1538 # PARENT_NAME = Foo::Bar
1540 ### ($self->{FULLEXT} =
1541 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1542 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1545 # Copied from DynaLoader:
1547 my(@modparts) = split(/::/,$self->{NAME});
1548 my($modfname) = $modparts[-1];
1550 # Some systems have restrictions on files names for DLL's etc.
1551 # mod2fname returns appropriate file base name (typically truncated)
1552 # It may also edit @modparts if required.
1553 if (defined &DynaLoader::mod2fname) {
1554 $modfname = &DynaLoader::mod2fname(\@modparts);
1557 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1558 $self->{PARENT_NAME} ||= '';
1560 if (defined &DynaLoader::mod2fname) {
1561 # As of 5.001m, dl_os2 appends '_'
1562 $self->{DLBASE} = $modfname;
1564 $self->{DLBASE} = '$(BASEEXT)';
1568 # --- Initialize PERL_LIB, PERL_SRC
1570 # *Real* information: where did we get these two from? ...
1571 my $inc_config_dir = dirname($INC{'Config.pm'});
1572 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1574 unless ($self->{PERL_SRC}){
1576 foreach $dir ($Updir,
1577 $self->catdir($Updir,$Updir),
1578 $self->catdir($Updir,$Updir,$Updir),
1579 $self->catdir($Updir,$Updir,$Updir,$Updir),
1580 $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir))
1583 -f $self->catfile($dir,"config_h.SH")
1585 -f $self->catfile($dir,"perl.h")
1587 -f $self->catfile($dir,"lib","Exporter.pm")
1589 $self->{PERL_SRC}=$dir ;
1595 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1596 $self->{PERL_CORE} and !$self->{PERL_SRC};
1598 if ($self->{PERL_SRC}){
1599 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1601 if (defined $Cross::platform) {
1602 $self->{PERL_ARCHLIB} =
1603 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
1605 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
1606 $Is_Win32?("CORE"):());
1609 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1610 $self->{PERL_INC} = ($Is_Win32) ?
1611 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1614 # catch a situation that has occurred a few times in the past:
1616 -s $self->catfile($self->{PERL_SRC},'cflags')
1620 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1625 You cannot build extensions below the perl source tree after executing
1626 a 'make clean' in the perl source tree.
1628 To rebuild extensions distributed with the perl source you should
1629 simply Configure (to include those extensions) and then build perl as
1630 normal. After installing perl the source tree can be deleted. It is
1631 not needed for building extensions by running 'perl Makefile.PL'
1632 usually without extra arguments.
1634 It is recommended that you unpack and build additional extensions away
1635 from the perl source tree.
1639 # we should also consider $ENV{PERL5LIB} here
1640 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1641 $self->{PERL_LIB} ||= $Config{privlibexp};
1642 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1643 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1646 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1648 # Maybe somebody tries to build an extension with an
1649 # uninstalled Perl outside of Perl build tree
1651 for my $dir (@INC) {
1652 $lib = $dir, last if -e $self->catdir($dir, "Config.pm");
1655 # Win32 puts its header files in /perl/src/lib/CORE.
1656 # Unix leaves them in /perl/src.
1657 my $inc = $Is_Win32 ? $self->catdir($lib, "CORE" )
1659 if (-e $self->catdir($inc, "perl.h")) {
1660 $self->{PERL_LIB} = $lib;
1661 $self->{PERL_ARCHLIB} = $lib;
1662 $self->{PERL_INC} = $inc;
1663 $self->{UNINSTALLED_PERL} = 1;
1665 ... Detected uninstalled Perl. Trying to continue.
1672 # We get SITELIBEXP and SITEARCHEXP directly via
1673 # Get_from_Config. When we are running standard modules, these
1674 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1675 # set it to "site". I prefer that INSTALLDIRS be set from outside
1677 $self->{INSTALLDIRS} ||= "site";
1679 $self->{MAN1EXT} ||= $Config{man1ext};
1680 $self->{MAN3EXT} ||= $Config{man3ext};
1682 # Get some stuff out of %Config if we haven't yet done so
1683 print STDOUT "CONFIG must be an array ref\n"
1684 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1685 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1686 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1687 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1689 foreach my $m (@{$self->{CONFIG}}){
1690 next if $once_only{$m};
1691 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1692 unless exists $Config{$m};
1693 $self->{uc $m} ||= $Config{$m};
1697 # This is too dangerous:
1698 # if ($^O eq "next") {
1699 # $self->{AR} = "libtool";
1700 # $self->{AR_STATIC_ARGS} = "-o";
1702 # But I leave it as a placeholder
1704 $self->{AR_STATIC_ARGS} ||= "cr";
1706 # These should never be needed
1707 $self->{OBJ_EXT} ||= '.o';
1708 $self->{LIB_EXT} ||= '.a';
1710 $self->{MAP_TARGET} ||= "perl";
1712 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1714 # make a simple check if we find Exporter
1715 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1716 (Exporter.pm not found)"
1717 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1718 $self->{NAME} eq "ExtUtils::MakeMaker";
1723 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
1724 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1725 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
1726 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1730 sub init_others { # --- Initialize Other Attributes
1733 $self->{LD} ||= 'ld';
1735 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1736 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1737 # undefined. In any case we turn it into an anon array:
1739 # May check $Config{libs} too, thus not empty.
1740 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
1742 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
1743 $self->{LD_RUN_PATH} = "";
1745 foreach $libs ( @{$self->{LIBS}} ){
1746 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1747 my(@libs) = $self->extliblist($libs);
1748 if ($libs[0] or $libs[1] or $libs[2]){
1749 # LD_RUN_PATH now computed by ExtUtils::Liblist
1750 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1751 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1756 if ( $self->{OBJECT} ) {
1757 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1759 # init_dirscan should have found out, if we have C files
1760 $self->{OBJECT} = "";
1761 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1763 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1764 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1765 $self->{PERLMAINCC} ||= '$(CC)';
1766 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1768 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1769 # the 'dynamic' section of MM. We don't have this problem with
1770 # 'static', since we either must use it (%Config says we can't
1771 # use dynamic loading) or the caller asked for it explicitly.
1772 if (!$self->{LINKTYPE}) {
1773 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1775 : ($Config{usedl} ? 'dynamic' : 'static');
1778 $self->{NOOP} ||= '$(SHELL) -c true';
1779 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1781 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
1782 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1783 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1784 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1786 # Some makes require a wrapper around macros passed in on the command
1788 $self->{MACROSTART} ||= '';
1789 $self->{MACROEND} ||= '';
1791 # Not everybody uses -f to indicate "use this Makefile instead"
1792 $self->{USEMAKEFILE} ||= '-f';
1794 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1796 $self->{ECHO} ||= 'echo';
1797 $self->{ECHO_N} ||= 'echo -n';
1798 $self->{RM_F} ||= "rm -f";
1799 $self->{RM_RF} ||= "rm -rf";
1800 $self->{TOUCH} ||= "touch";
1801 $self->{TEST_F} ||= "test -f";
1802 $self->{CP} ||= "cp";
1803 $self->{MV} ||= "mv";
1804 $self->{CHMOD} ||= "chmod";
1805 $self->{MKPATH} ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
1806 $self->{EQUALIZE_TIMESTAMP} ||=
1807 '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
1809 $self->{UNINST} ||= 0;
1810 $self->{VERBINST} ||= 0;
1811 $self->{MOD_INSTALL} ||=
1812 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1813 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1815 $self->{DOC_INSTALL} ||=
1816 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
1817 $self->{UNINSTALL} ||=
1818 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
1819 $self->{WARN_IF_OLD_PACKLIST} ||=
1820 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
1822 q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
1824 $self->{UMASK_NULL} ||= "umask 0";
1825 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1833 Unix has no need of special linker flags.
1839 $self->{PERL_ARCHIVE} ||= '';
1840 $self->{PERL_ARCHIVE_AFTER} ||= '';
1841 $self->{EXPORT_LIST} ||= '';
1858 # The user who requests an installation directory explicitly
1859 # should not have to tell us an architecture installation directory
1860 # as well. We look if a directory exists that is named after the
1861 # architecture. If not we take it as a sign that it should be the
1862 # same as the requested installation directory. Otherwise we take
1864 for my $libpair ({l=>"privlib", a=>"archlib"},
1865 {l=>"sitelib", a=>"sitearch"},
1866 {l=>"vendorlib", a=>"vendorarch"},
1869 my $lib = "install$libpair->{l}";
1871 my $Arch = uc "install$libpair->{a}";
1872 if( $self->{$Lib} && ! $self->{$Arch} ){
1873 my($ilib) = $Config{$lib};
1875 $self->prefixify($Arch,$ilib,$self->{$Lib});
1877 unless (-d $self->{$Arch}) {
1878 print STDOUT "Directory $self->{$Arch} not found\n"
1880 $self->{$Arch} = $self->{$Lib};
1882 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1892 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1893 *PERLRUN* permutations.
1895 PERL is allowed to be miniperl
1896 FULLPERL must be a complete perl
1898 ABSPERL is PERL converted to an absolute path
1900 *PERLRUN contains everything necessary to run perl, find it's
1903 *PERLRUNINST is *PERLRUN + everything necessary to find the
1904 modules being built.
1912 foreach my $component ($self->{PERL_SRC}, $self->path(),
1915 push @defpath, $component if defined $component;
1918 # Build up a set of file names (not command names).
1919 my $thisperl = $self->canonpath($^X);
1920 $thisperl .= $Config{exe_ext} unless
1921 # VMS might have a file version # at the end
1922 $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
1923 : $thisperl =~ m/$Config{exe_ext}$/i;
1925 # We need a relative path to perl when in the core.
1926 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
1928 my @perls = ($thisperl);
1929 push @perls, map { "$_$Config{exe_ext}" }
1930 ('perl', 'perl5', "perl$Config{version}");
1932 # miniperl has priority over all but the cannonical perl when in the
1933 # core. Otherwise its a last resort.
1934 my $miniperl = "miniperl$Config{exe_ext}";
1935 if( $self->{PERL_CORE} ) {
1936 splice @perls, 1, 0, $miniperl;
1939 push @perls, $miniperl;
1943 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
1944 # don't check if perl is executable, maybe they have decided to
1945 # supply switches with perl
1947 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
1948 my $perl_name = 'perl';
1949 $perl_name = 'ndbgperl' if $Is_VMS &&
1950 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
1952 # XXX This logic is flawed. If "miniperl" is anywhere in the path
1953 # it will get confused. It should be fixed to work only on the filename.
1954 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1955 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
1956 unless $self->{FULLPERL};
1958 # Little hack to get around VMS's find_perl putting "MCR" in front
1960 $self->{ABSPERL} = $self->{PERL};
1961 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
1962 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
1963 $self->{ABSPERL} = '$(PERL)';
1966 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
1967 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
1970 # Are we building the core?
1971 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1972 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
1974 # How do we run perl?
1975 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
1976 my $run = $perl.'RUN';
1978 $self->{$run} = "\$($perl)";
1980 # Make sure perl can find itself before it's installed.
1981 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
1982 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
1984 $self->{$perl.'RUNINST'} =
1985 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
1994 =item platform_constants
1996 Add MM_Unix_VERSION.
2003 $self->{MM_Unix_VERSION} = $VERSION;
2004 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2005 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2006 '-Dcalloc=Perl_calloc';
2010 sub platform_constants {
2014 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2016 next unless defined $self->{$macro};
2017 $make_frag .= "$macro = $self->{$macro}\n";
2028 Called by init_main. Initializes PERL_*
2035 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2036 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2046 Sets up macros having to do with XS code. Currently just INST_STATIC,
2047 INST_DYNAMIC and INST_BOOT.
2054 if ($self->has_link_code()) {
2055 $self->{INST_STATIC} =
2056 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2057 $self->{INST_DYNAMIC} =
2058 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2059 $self->{INST_BOOT} =
2060 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2062 $self->{INST_STATIC} = '';
2063 $self->{INST_DYNAMIC} = '';
2064 $self->{INST_BOOT} = '';
2070 Defines the install target.
2075 my($self, %attribs) = @_;
2079 install :: all pure_install doc_install
2082 install_perl :: all pure_perl_install doc_perl_install
2085 install_site :: all pure_site_install doc_site_install
2088 install_vendor :: all pure_vendor_install doc_vendor_install
2091 pure_install :: pure_$(INSTALLDIRS)_install
2094 doc_install :: doc_$(INSTALLDIRS)_install
2097 pure__install : pure_site_install
2098 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2100 doc__install : doc_site_install
2101 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2103 pure_perl_install ::
2104 $(NOECHO) $(MOD_INSTALL) \
2105 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2106 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2107 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2108 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2109 $(INST_BIN) $(DESTINSTALLBIN) \
2110 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2111 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2112 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2113 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2114 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2117 pure_site_install ::
2118 $(NOECHO) $(MOD_INSTALL) \
2119 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2120 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2121 $(INST_LIB) $(DESTINSTALLSITELIB) \
2122 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2123 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2124 $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
2125 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2126 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2127 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2128 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2130 pure_vendor_install ::
2131 $(NOECHO) $(MOD_INSTALL) \
2132 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2133 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2134 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2135 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2136 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2137 $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
2138 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2139 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2142 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2143 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2144 -$(NOECHO) $(DOC_INSTALL) \
2145 "Module" "$(NAME)" \
2146 "installed into" "$(INSTALLPRIVLIB)" \
2147 LINKTYPE "$(LINKTYPE)" \
2148 VERSION "$(VERSION)" \
2149 EXE_FILES "$(EXE_FILES)" \
2150 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2153 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2154 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2155 -$(NOECHO) $(DOC_INSTALL) \
2156 "Module" "$(NAME)" \
2157 "installed into" "$(INSTALLSITELIB)" \
2158 LINKTYPE "$(LINKTYPE)" \
2159 VERSION "$(VERSION)" \
2160 EXE_FILES "$(EXE_FILES)" \
2161 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2163 doc_vendor_install ::
2164 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2165 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2166 -$(NOECHO) $(DOC_INSTALL) \
2167 "Module" "$(NAME)" \
2168 "installed into" "$(INSTALLVENDORLIB)" \
2169 LINKTYPE "$(LINKTYPE)" \
2170 VERSION "$(VERSION)" \
2171 EXE_FILES "$(EXE_FILES)" \
2172 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2177 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2180 uninstall_from_perldirs ::
2181 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2183 uninstall_from_sitedirs ::
2184 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2186 uninstall_from_vendordirs ::
2187 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2193 =item installbin (o)
2195 Defines targets to make and to install EXE_FILES.
2202 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2203 my @exefiles = @{$self->{EXE_FILES}};
2204 return "" unless @exefiles;
2206 @exefiles = map vmsify($_), @exefiles if $Is_VMS;
2209 for my $from (@exefiles) {
2210 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2212 local($_) = $path; # for backwards compatibility
2213 my $to = $self->libscan($path);
2214 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2216 $to = vmsify($to) if $Is_VMS;
2217 $fromto{$from} = $to;
2219 my @to = values %fromto;
2223 EXE_FILES = @exefiles
2231 # realclean can get rather large.
2232 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2236 # A target for each exe file.
2237 while (my($from,$to) = each %fromto) {
2238 last unless defined $from;
2240 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
2241 %s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2242 $(NOECHO) $(RM_F) %s
2245 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
2257 Defines the linkext target which in turn defines the LINKTYPE.
2262 my($self, %attribs) = @_;
2263 # LINKTYPE => static or dynamic or ''
2264 my($linktype) = defined $attribs{LINKTYPE} ?
2265 $attribs{LINKTYPE} : '$(LINKTYPE)';
2267 linkext :: $linktype
2274 Takes as arguments a directory name and a regular expression. Returns
2275 all entries in the directory that match the regular expression.
2281 my($dir, $regex) = @_;
2283 my $dh = new DirHandle;
2284 $dh->open($dir || ".") or return ();
2287 @ls = grep(/$regex/, @ls) if $regex;
2293 Simple subroutine to insert the macros defined by the macro attribute
2299 my($self,%attribs) = @_;
2301 while (($key,$val) = each %attribs){
2302 last unless defined $key;
2303 push @m, "$key = $val\n";
2310 Called by staticmake. Defines how to write the Makefile to produce a
2313 By default the Makefile produced includes all the static extensions in
2314 the perl library. (Purified versions of library files, e.g.,
2315 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2320 my($self, %attribs) = @_;
2321 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2322 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2325 # --- MakeMaker makeaperl section ---
2326 MAP_TARGET = $target
2327 FULLPERL = $self->{FULLPERL}
2329 return join '', @m if $self->{PARENT};
2331 my($dir) = join ":", @{$self->{DIR}};
2333 unless ($self->{MAKEAPERL}) {
2335 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2336 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
2338 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
2339 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2340 $(NOECHO) $(PERLRUNINST) \
2341 Makefile.PL DIR=}, $dir, q{ \
2342 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2343 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2349 push @m, " \\\n\t\t$_";
2351 # push @m, map( " \\\n\t\t$_", @ARGV );
2359 my($cccmd, $linkcmd, $lperl);
2362 $cccmd = $self->const_cccmd($libperl);
2363 $cccmd =~ s/^CCCMD\s*=\s*//;
2364 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2365 $cccmd .= " $Config{cccdlflags}"
2366 if ($Config{useshrplib} eq 'true');
2367 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2369 # The front matter of the linkcommand...
2370 $linkcmd = join ' ', "\$(CC)",
2371 grep($_, @Config{qw(ldflags ccdlflags)});
2372 $linkcmd =~ s/\s+/ /g;
2373 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2375 # Which *.a files could we make use of...
2378 File::Find::find(sub {
2379 return unless m/\Q$self->{LIB_EXT}\E$/;
2381 # Skip perl's libraries.
2382 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2384 # Skip purified versions of libraries
2385 # (e.g., DynaLoader_pure_p1_c0_032.a)
2386 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2388 if( exists $self->{INCLUDE_EXT} ){
2393 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2397 # Throw away anything not explicitly marked for inclusion.
2398 # DynaLoader is implied.
2399 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2405 return unless $found;
2407 elsif( exists $self->{EXCLUDE_EXT} ){
2411 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2415 # Throw away anything explicitly marked for exclusion
2416 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2417 return if( $xx eq $excl );
2421 # don't include the installed version of this extension. I
2422 # leave this line here, although it is not necessary anymore:
2423 # I patched minimod.PL instead, so that Miniperl.pm won't
2424 # enclude duplicates
2426 # Once the patch to minimod.PL is in the distribution, I can
2428 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2430 $static{cwd() . "/" . $_}++;
2431 }, grep( -d $_, @{$searchdirs || []}) );
2433 # We trust that what has been handed in as argument, will be buildable
2434 $static = [] unless $static;
2435 @static{@{$static}} = (1) x @{$static};
2437 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2438 for (sort keys %static) {
2439 next unless /\Q$self->{LIB_EXT}\E\z/;
2440 $_ = dirname($_) . "/extralibs.ld";
2444 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
2449 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2450 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2451 # extralibs.all are computed correctly
2453 MAP_LINKCMD = $linkcmd
2454 MAP_PERLINC = @{$perlinc || []}
2456 join(" \\\n\t", reverse sort keys %static), "
2458 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2461 if (defined $libperl) {
2462 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2464 unless ($libperl && -f $lperl) { # Ilya's code...
2465 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2466 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2467 $libperl ||= "libperl$self->{LIB_EXT}";
2468 $libperl = "$dir/$libperl";
2469 $lperl ||= "libperl$self->{LIB_EXT}";
2470 $lperl = "$dir/$lperl";
2472 if (! -f $libperl and ! -f $lperl) {
2473 # We did not find a static libperl. Maybe there is a shared one?
2475 $lperl = $libperl = "$dir/$Config{libperl}";
2476 # SUNOS ld does not take the full path to a shared library
2477 $libperl = '' if $Is_SunOS4;
2481 print STDOUT "Warning: $libperl not found
2482 If you're going to build a static perl binary, make sure perl is installed
2483 otherwise ignore this warning\n"
2484 unless (-f $lperl || defined($self->{PERL_SRC}));
2487 # SUNOS ld does not take the full path to a shared library
2488 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2491 MAP_LIBPERL = $libperl
2492 LLIBPERL = $llibperl
2496 $(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
2497 $(NOECHO) $(RM_F) $@
2498 $(NOECHO) $(TOUCH) $@
2502 foreach $catfile (@$extra){
2503 push @m, "\tcat $catfile >> \$\@\n";
2507 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2508 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2509 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2510 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2511 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2512 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
2514 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2516 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
2519 $tmp/perlmain.c: $makefilename}, q{
2520 $(NOECHO) $(ECHO) Writing $@
2521 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2522 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2525 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2526 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2531 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2532 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2533 -$(NOECHO) $(DOC_INSTALL) \
2534 "Perl binary" "$(MAP_TARGET)" \
2535 MAP_STATIC "$(MAP_STATIC)" \
2536 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2537 MAP_LIBPERL "$(MAP_LIBPERL)" \
2538 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2543 inst_perl: pure_inst_perl doc_inst_perl
2545 pure_inst_perl: $(MAP_TARGET)
2546 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2551 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2559 Defines how to rewrite the Makefile.
2566 # We do not know what target was originally specified so we
2567 # must force a manual rerun to be sure. But as it should only
2568 # happen very rarely it is not a significant problem.
2570 $(OBJECT) : $(FIRST_MAKEFILE)
2572 ' if $self->{OBJECT};
2574 my $newer_than_target = $Is_VMS ? '$(MMS$SOURCE_LIST)' : '$?';
2575 my $mpl_args = join " ", map qq["$_"], @ARGV;
2577 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
2578 # We take a very conservative approach here, but it's worth it.
2579 # We move Makefile to Makefile.old here to avoid gnu make looping.
2580 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2581 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
2582 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2583 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2584 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2585 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2586 $(PERLRUN) Makefile.PL %s
2587 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2588 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
2599 Returns true, if the argument is likely to be a command.
2604 my($self,$file) = @_;
2605 return $file if -x $file && ! -d $file;
2610 =item needs_linking (o)
2612 Does this module need linking? Looks into subdirectory objects (see
2613 also has_link_code())
2620 $caller = (caller(0))[3];
2621 confess("needs_linking called too early") if
2622 $caller =~ /^ExtUtils::MakeMaker::/;
2623 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2624 if ($self->has_link_code or $self->{MAKEAPERL}){
2625 $self->{NEEDS_LINKING} = 1;
2628 foreach $child (keys %{$self->{CHILDREN}}) {
2629 if ($self->{CHILDREN}->{$child}->needs_linking) {
2630 $self->{NEEDS_LINKING} = 1;
2634 return $self->{NEEDS_LINKING} = 0;
2639 misnamed method (will have to be changed). The MM_Unix method just
2640 returns the argument without further processing.
2642 On VMS used to insure that colons marking targets are preceded by
2643 space - most Unix Makes don't need this, but it's necessary under VMS
2644 to distinguish the target delimiter from a colon appearing as part of
2650 my($self,$text) = @_;
2654 =item parse_abstract
2656 parse a file and return what you think is the ABSTRACT
2660 sub parse_abstract {
2661 my($self,$parsefile) = @_;
2665 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2667 my $package = $self->{DISTNAME};
2668 $package =~ s/-/::/g;
2670 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2673 next unless /^($package\s-\s)(.*)/;
2683 parse a file and return what you think is $VERSION in this file set to.
2684 It will return the string "undef" if it can't figure out what $VERSION
2685 is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
2686 are okay, but my $VERSION is not.
2691 my($self,$parsefile) = @_;
2696 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2699 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2700 next if $inpod || /^\s*#/;
2702 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
2704 package ExtUtils::MakeMaker::_version;
2713 $result = eval($eval);
2714 warn "Could not eval '$eval' in $parsefile: $@" if $@;
2719 $result = "undef" unless defined $result;
2726 Defines the string that is passed to recursive make calls in
2736 my($sep) = $Is_VMS ? ',' : '';
2739 foreach $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
2740 PREFIX INSTALL_BASE)
2743 next unless defined $self->{$key};
2744 push @pasthru, "$key=\"\$($key)\"";
2747 foreach $key (qw(DEFINE INC)) {
2748 next unless defined $self->{$key};
2749 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
2752 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
2758 Takes one argument, a file name, and returns the file name, if the
2759 argument is likely to be a perl script. On MM_Unix this is true for
2760 any ordinary, readable file.
2765 my($self,$file) = @_;
2766 return $file if -r $file && -f _;
2770 =item perldepend (o)
2772 Defines the dependency from all *.h files that come with the perl
2781 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
2783 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
2784 # Check for unpropogated config.sh changes. Should never happen.
2785 # We do NOT just update config.h because that is not sufficient.
2786 # An out of date config.h is not fatal but complains loudly!
2787 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2788 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2790 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2791 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2795 return join "", @m unless $self->needs_linking;
2799 $(PERL_INC)/EXTERN.h \
2800 $(PERL_INC)/INTERN.h \
2801 $(PERL_INC)/XSUB.h \
2803 $(PERL_INC)/cc_runtime.h \
2804 $(PERL_INC)/config.h \
2807 $(PERL_INC)/dosish.h \
2808 $(PERL_INC)/embed.h \
2809 $(PERL_INC)/embedvar.h \
2810 $(PERL_INC)/fakethr.h \
2811 $(PERL_INC)/form.h \
2813 $(PERL_INC)/handy.h \
2815 $(PERL_INC)/intrpvar.h \
2816 $(PERL_INC)/iperlsys.h \
2817 $(PERL_INC)/keywords.h \
2819 $(PERL_INC)/nostdio.h \
2821 $(PERL_INC)/opcode.h \
2822 $(PERL_INC)/patchlevel.h \
2823 $(PERL_INC)/perl.h \
2824 $(PERL_INC)/perlio.h \
2825 $(PERL_INC)/perlsdio.h \
2826 $(PERL_INC)/perlsfio.h \
2827 $(PERL_INC)/perlvars.h \
2828 $(PERL_INC)/perly.h \
2830 $(PERL_INC)/pp_proto.h \
2831 $(PERL_INC)/proto.h \
2832 $(PERL_INC)/regcomp.h \
2833 $(PERL_INC)/regexp.h \
2834 $(PERL_INC)/regnodes.h \
2835 $(PERL_INC)/scope.h \
2837 $(PERL_INC)/thrdvar.h \
2838 $(PERL_INC)/thread.h \
2839 $(PERL_INC)/unixish.h \
2842 $(OBJECT) : $(PERL_HDRS)
2843 } if $self->{OBJECT};
2845 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2853 Returns the attribute C<PERM_RW> or the string C<644>.
2854 Used as the string that is passed
2855 to the C<chmod> command to set the permissions for read/writeable files.
2856 MakeMaker chooses C<644> because it has turned out in the past that
2857 relying on the umask provokes hard-to-track bug reports.
2858 When the return value is used by the perl function C<chmod>, it is
2859 interpreted as an octal value.
2864 return shift->{PERM_RW};
2869 Returns the attribute C<PERM_RWX> or the string C<755>,
2870 i.e. the string that is passed
2871 to the C<chmod> command to set the permissions for executable files.
2877 return shift->{PERM_RWX};
2882 Defines target that copies all files in the hash PM to their
2883 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
2889 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2891 pm_to_blib : $(TO_INST_PM)
2894 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
2895 pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
2898 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
2900 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
2901 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
2906 =item post_constants (o)
2908 Returns an empty string per default. Dedicated to overrides from
2909 within Makefile.PL after all constants have been defined.
2917 =item post_initialize (o)
2919 Returns an empty string per default. Used in Makefile.PLs to add some
2920 chunk of text to the Makefile after the object is initialized.
2924 sub post_initialize {
2930 Returns an empty string. Can be used in Makefile.PLs to write some
2931 text to the Makefile at the end.
2941 Defines target that creates a PPD (Perl Package Description) file
2942 for a binary distribution.
2949 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
2951 my $abstract = $self->{ABSTRACT} || '';
2952 $abstract =~ s/\n/\\n/sg;
2953 $abstract =~ s/</</g;
2954 $abstract =~ s/>/>/g;
2956 my $author = $self->{AUTHOR} || '';
2957 $author =~ s/</</g;
2958 $author =~ s/>/>/g;
2960 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
2961 <SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
2962 <TITLE>$(DISTNAME)</TITLE>
2963 <ABSTRACT>%s</ABSTRACT>
2967 $ppd_xml .= " <IMPLEMENTATION>\n";
2968 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
2969 my $pre_req = $prereq;
2970 $pre_req =~ s/::/-/g;
2971 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
2973 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
2974 <DEPENDENCY NAME="%s" VERSION="%s" />
2979 $ppd_xml .= sprintf <<'PPD_OUT', $Config{archname};
2980 <OS NAME="$(OSNAME)" />
2981 <ARCHITECTURE NAME="%s" />
2984 if ($self->{PPM_INSTALL_SCRIPT}) {
2985 if ($self->{PPM_INSTALL_EXEC}) {
2986 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
2987 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
2990 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
2991 $self->{PPM_INSTALL_SCRIPT};
2995 my ($bin_location) = $self->{BINARY_LOCATION} || '';
2996 $bin_location =~ s/\\/\\\\/g;
2998 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
2999 <CODEBASE HREF="%s" />
3004 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
3006 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3007 # Creates a PPD (Perl Package Description) for a binary distribution.
3016 $MM->prefixify($var, $prefix, $new_prefix, $default);
3018 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3019 replace it's $prefix with a $new_prefix.
3021 Should the $prefix fail to match I<AND> a PREFIX was given as an
3022 argument to WriteMakefile() it will set it to the $new_prefix +
3023 $default. This is for systems whose file layouts don't neatly fit into
3024 our ideas of prefixes.
3026 This is for heuristics which attempt to create directory structures
3027 that mirror those of the installed perl.
3031 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3033 this will attempt to remove '/usr' from the front of the
3034 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3035 if necessary) and replace it with '/home/foo'. If this fails it will
3036 simply use '/home/foo/man/man1'.
3041 my($self,$var,$sprefix,$rprefix,$default) = @_;
3043 my $path = $self->{uc $var} ||
3044 $Config_Override{lc $var} || $Config{lc $var} || '';
3046 $rprefix .= '/' if $sprefix =~ m|/$|;
3048 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3049 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
3051 if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) &&
3052 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3055 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3056 print STDERR " no default!\n" if !$default && $Verbose >= 2;
3058 $path = $self->catdir($rprefix, $default) if $default;
3061 print " now $path\n" if $Verbose >= 2;
3062 return $self->{uc $var} = $path;
3068 Defines targets to run *.PL files.
3074 my $pl_files = $self->{PL_FILES};
3076 return "" unless $pl_files;
3079 foreach my $plfile (sort keys %$pl_files) {
3080 my $list = ref($pl_files->{$plfile})
3081 ? $pl_files->{$plfile}
3082 : [$pl_files->{$plfile}];
3084 foreach my $target (@$list) {
3086 $plfile = vmsify($self->eliminate_macros($plfile));
3087 $target = vmsify($self->eliminate_macros($target));
3090 # Normally a .PL file runs AFTER pm_to_blib so it can have
3091 # blib in its @INC and load the just built modules. BUT if
3092 # the generated module is something in $(TO_INST_PM) which
3093 # pm_to_blib depends on then it can't depend on pm_to_blib
3094 # else we have a dependency loop.
3097 if( defined $self->{PM}{$target} ) {
3099 $perlrun = 'PERLRUN';
3102 $pm_dep = 'pm_to_blib';
3103 $perlrun = 'PERLRUNINST';
3111 $target :: $plfile $pm_dep
3112 \$($perlrun) $plfile $target
3123 Backslashes parentheses C<()> in command line arguments.
3124 Doesn't handle recursive Makefile C<$(...)> constructs,
3125 but handles simple ones.
3131 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3132 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3133 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
3137 =item replace_manpage_separator
3139 my $man_name = $MM->replace_manpage_separator($file_path);
3141 Takes the name of a package, which may be a nested package, in the
3142 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3143 safe for a man page file name. Returns the replacement.
3147 sub replace_manpage_separator {
3148 my($self,$man) = @_;
3160 my($self, $dir, @cmds) = @_;
3162 # No leading tab and no trailing newline makes for easier embedding
3163 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3173 my($self, $cmd, $switches) = @_;
3174 $switches = [] unless defined $switches;
3176 # Strip leading and trailing newlines
3180 my @cmds = split /\n/, $cmd;
3181 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
3182 $cmd = $self->escape_newlines($cmd);
3184 $switches = join ' ', @$switches;
3186 return qq{\$(ABSPERLRUN) $switches -e $cmd --};
3195 my($self, $text) = @_;
3197 # I think all we have to quote is single quotes and I think
3198 # this is a safe way to do it.
3199 $text =~ s{'}{'\\''}g;
3205 =item escape_newlines
3209 sub escape_newlines {
3210 my($self, $text) = @_;
3212 $text =~ s{\n}{\\\n}g;
3220 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3227 if (!defined $self->{_MAX_EXEC_LEN}) {
3228 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3229 $self->{_MAX_EXEC_LEN} = $arg_max;
3231 else { # POSIX minimum exec size
3232 $self->{_MAX_EXEC_LEN} = 4096;
3236 return $self->{_MAX_EXEC_LEN};
3242 Defines the static target.
3247 # --- Static Loading Sections ---
3251 ## $(INST_PM) has been moved to the all: target.
3252 ## It remains here for awhile to allow for old usage: "make static"
3253 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3258 =item static_lib (o)
3260 Defines how to produce the *.a (or equivalent) files.
3266 return '' unless $self->has_link_code;
3271 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
3275 # If this extension has its own library (eg SDBM_File)
3276 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3277 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3278 $(CP) $(MYEXTLIB) $@
3282 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3283 # Prefer the absolute pathed ar if available so that PATH
3284 # doesn't confuse us. Perl itself is built with the full_ar.
3289 push @m, sprintf <<'MAKE_FRAG', $ar;
3290 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3291 $(CHMOD) $(PERM_RWX) $@
3292 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3295 # Old mechanism - still available:
3296 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3297 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3303 =item staticmake (o)
3310 my($self, %attribs) = @_;
3313 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3315 # And as it's not yet built, we add the current extension
3316 # but only if it has some C code (or XS code, which implies C code)
3317 if (@{$self->{C}}) {
3318 @static = $self->catfile($self->{INST_ARCHLIB},
3321 "$self->{BASEEXT}$self->{LIB_EXT}"
3325 # Either we determine now, which libraries we will produce in the
3326 # subdirectories or we do it at runtime of the make.
3328 # We could ask all subdir objects, but I cannot imagine, why it
3329 # would be necessary.
3331 # Instead we determine all libraries for the new perl at
3333 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3335 $self->makeaperl(MAKE => $self->{MAKEFILE},
3336 DIRS => \@searchdirs,
3339 TARGET => $self->{MAP_TARGET},
3341 LIBPERL => $self->{LIBPERL_A}
3347 Helper subroutine for subdirs
3352 my($self, $subdir) = @_;
3354 my $subdir_cmd = $self->cd($subdir,
3355 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3357 return sprintf <<'EOT', $subdir_cmd;
3367 Defines targets to process subdirectories.
3372 # --- Sub-directory Sections ---
3375 # This method provides a mechanism to automatically deal with
3376 # subdirectories containing further Makefile.PL scripts.
3377 # It calls the subdir_x() method for each subdirectory.
3378 foreach $dir (@{$self->{DIR}}){
3379 push(@m, $self->subdir_x($dir));
3380 #### print "Including $dir subdirectory\n";
3384 # The default clean, realclean and test targets in this Makefile
3385 # have automatically been given entries for each subdir.
3389 push(@m, "\n# none")
3396 Defines the test targets.
3401 # --- Test and Installation Sections ---
3403 my($self, %attribs) = @_;
3404 my $tests = $attribs{TESTS} || '';
3405 if (!$tests && -d 't') {
3406 $tests = $self->find_tests;
3408 # note: 'test.pl' name is also hardcoded in init_dirscan()
3412 TEST_TYPE=test_\$(LINKTYPE)
3417 testdb :: testdb_\$(LINKTYPE)
3419 test :: \$(TEST_TYPE)
3422 foreach my $dir (@{ $self->{DIR} }) {
3423 my $test = $self->oneliner(sprintf <<'CODE', $dir);
3425 system '$(MAKE) test $(PASTHRU)'
3426 if -f '$(FIRST_MAKEFILE)';
3429 push(@m, "\t\$(NOECHO) $test\n");
3432 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3433 unless $tests or -f "test.pl" or @{$self->{DIR}};
3436 push(@m, "test_dynamic :: pure_all\n");
3437 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3439 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3443 push(@m, "testdb_dynamic :: pure_all\n");
3444 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3448 # Occasionally we may face this degenerate target:
3449 push @m, "test_ : test_dynamic\n\n";
3451 if ($self->needs_linking()) {
3452 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3453 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3454 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3456 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3457 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3460 push @m, "test_static :: test_dynamic\n";
3461 push @m, "testdb_static :: testdb_dynamic\n";
3466 =item test_via_harness (override)
3468 For some reason which I forget, Unix machines like to have
3469 PERL_DL_NONLAZY set for tests.
3473 sub test_via_harness {
3474 my($self, $perl, $tests) = @_;
3475 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3478 =item test_via_script (override)
3480 Again, the PERL_DL_NONLAZY thing.
3484 sub test_via_script {
3485 my($self, $perl, $script) = @_;
3486 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3490 =item tools_other (o)
3492 my $make_frag = $MM->tools_other;
3494 Returns a make fragment containing definitions for the macros init_others()
3503 # We set PM_FILTER as late as possible so it can see all the earlier
3504 # on macro-order sensitive makes such as nmake.
3505 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
3506 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
3509 MOD_INSTALL DOC_INSTALL UNINSTALL
3510 WARN_IF_OLD_PACKLIST
3517 next unless defined $self->{$tool};
3518 push @m, "$tool = $self->{$tool}\n";
3524 =item tool_xsubpp (o)
3526 Determines typemaps, xsubpp version, prototype behaviour.
3532 return "" unless $self->needs_linking;
3535 my @xsubpp_dirs = @INC;
3537 # Make sure we pick up the new xsubpp if we're building perl.
3538 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3540 foreach my $dir (@xsubpp_dirs) {
3541 $xsdir = $self->catdir($dir, 'ExtUtils');
3542 if( -r $self->catfile($xsdir, "xsubpp") ) {
3547 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3548 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3549 if( $self->{TYPEMAPS} ){
3551 foreach $typemap (@{$self->{TYPEMAPS}}){
3552 if( ! -f $typemap ){
3553 warn "Typemap $typemap not found.\n";
3556 push(@tmdeps, $typemap);
3560 push(@tmdeps, "typemap") if -f "typemap";
3561 my(@tmargs) = map("-typemap $_", @tmdeps);
3562 if( exists $self->{XSOPT} ){
3563 unshift( @tmargs, $self->{XSOPT} );
3567 $Config{'ldflags'} &&
3568 $Config{'ldflags'} =~ m!/Debug!i &&
3569 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
3572 unshift(@tmargs,'-nolinenumbers');
3576 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3580 XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp
3581 XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
3582 XSPROTOARG = $self->{XSPROTOARG}
3583 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3584 XSUBPPARGS = @tmargs
3592 Build man pages, too
3599 return <<'MAKE_EXT';
3600 all :: pure_all manifypods
3605 =item top_targets (o)
3607 Defines the targets all, subdirs, config, and O_FILES
3612 # --- Target Sections ---
3617 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3620 pure_all :: config pm_to_blib subdirs linkext
3623 subdirs :: $(MYEXTLIB)
3626 config :: $(FIRST_MAKEFILE) blibdirs
3631 $(O_FILES): $(H_FILES)
3632 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3636 perldoc ExtUtils::MakeMaker
3644 Obsolete, deprecated method. Not used since Version 5.21.
3649 # --- perllocal.pod section ---
3650 my($self,$what,$name,@attribs)=@_;
3651 my $time = localtime;
3652 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3653 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3654 print "\n\n=back\n\n";
3659 Defines the suffix rules to compile XS files to C.
3665 return '' unless $self->needs_linking();
3668 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3674 Defines the suffix rules to compile XS files to C++.
3680 return '' unless $self->needs_linking();
3683 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
3689 Defines suffix rules to go from XS to object files directly. This is
3690 only intended for broken make implementations.
3694 sub xs_o { # many makes are too dumb to use xs_c then c_o
3696 return '' unless $self->needs_linking();
3699 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3700 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
3711 L<ExtUtils::MakeMaker>