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|bsdos|interix|dragonfly)$/;
43 # For things like vmsify()
44 require VMS::Filespec;
45 VMS::Filespec->import;
52 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
56 C<require ExtUtils::MM_Unix;>
60 The methods provided by this package are designed to be used in
61 conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
62 Makefile, it creates one or more objects that inherit their methods
63 from a package C<MM>. MM itself doesn't provide any methods, but it
64 ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
65 specific packages take the responsibility for all the methods provided
66 by MM_Unix. We are trying to reduce the number of the necessary
67 overrides by defining rather primitive operations within
70 If you are going to write a platform specific MM package, please try
71 to limit the necessary overrides to primitive methods, and if it is not
72 possible to do so, let's work out how to achieve that gain.
74 If you are overriding any of these methods in your Makefile.PL (in the
75 MY class), please report that to the makemaker mailing list. We are
76 trying to minimize the necessary method overrides and switch to data
77 driven Makefile.PLs wherever possible. In the long run less methods
78 will be overridable via the MY class.
82 The following description of methods is still under
83 development. Please refer to the code for not suitably documented
84 sections and complain loudly to the makemaker@perl.org mailing list.
85 Better yet, provide a patch.
87 Not all of the methods below are overridable in a
88 Makefile.PL. Overridable methods are marked as (o). All methods are
89 overridable by a platform specific MM_*.pm file.
91 Cross-platform methods are being moved into MM_Any. If you can't find
92 something that used to be in here, look in MM_Any.
96 # So we don't have to keep calling the methods over and over again,
97 # we have these globals to cache the values. Faster and shrtr.
98 my $Curdir = __PACKAGE__->curdir;
99 my $Rootdir = __PACKAGE__->rootdir;
100 my $Updir = __PACKAGE__->updir;
109 Simply says that we're Unix.
120 Defines the suffix rules to compile different flavors of C files to
126 # --- Translation Sections ---
129 return '' unless $self->needs_linking();
131 if (my $cpp = $Config{cpprun}) {
132 my $cpp_cmd = $self->const_cccmd;
133 $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/;
136 '. $cpp_cmd . ' $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i
141 $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
145 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
149 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C
150 ' if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific
153 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp
156 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx
159 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc
166 Does very much the same as the cflags script in the perl
167 distribution. It doesn't return the whole compiler command line, but
168 initializes all of its parts. The const_cccmd method then actually
169 returns the definition of the CCCMD macro which uses these parts.
176 my($self,$libperl)=@_;
177 return $self->{CFLAGS} if $self->{CFLAGS};
178 return '' unless $self->needs_linking();
180 my($prog, $uc, $perltype, %cflags);
181 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
182 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
184 @cflags{qw(cc ccflags optimize shellflags)}
185 = @Config{qw(cc ccflags optimize shellflags)};
188 $cflags{shellflags} ||= '';
193 DE => '-DDEBUGGING -DEMBED',
194 M => '-DEMBED -DMULTIPLICITY',
195 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
198 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
201 $uc = ""; # avoid warning
203 $perltype = $map{$uc} ? $map{$uc} : "";
211 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
212 if ($prog = $Config{$name}) {
213 # Expand hints for this extension via the shell
214 print STDOUT "Processing $name hint:\n" if $Verbose;
215 my(@o)=`cc=\"$cflags{cc}\"
216 ccflags=\"$cflags{ccflags}\"
217 optimize=\"$cflags{optimize}\"
218 perltype=\"$cflags{perltype}\"
219 optdebug=\"$cflags{optdebug}\"
222 echo ccflags=\$ccflags
223 echo optimize=\$optimize
224 echo perltype=\$perltype
225 echo optdebug=\$optdebug
230 if ($line =~ /(.*?)=\s*(.*)\s*$/){
232 print STDOUT " $1 = $2\n" if $Verbose;
234 print STDOUT "Unrecognised result from hint: '$line'\n";
240 $cflags{optimize} = $optdebug;
243 for (qw(ccflags optimize perltype)) {
245 $cflags{$_} =~ s/^\s+//;
246 $cflags{$_} =~ s/\s+/ /g;
247 $cflags{$_} =~ s/\s+$//;
248 $self->{uc $_} ||= $cflags{$_};
251 if ($self->{POLLUTE}) {
252 $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
256 if ($Config{usemymalloc} and not $Config{bincompat5005}
257 and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
258 and $self->{PERL_MALLOC_OK}) {
259 $pollute = '$(PERL_MALLOC_DEF)';
262 $self->{CCFLAGS} = quote_paren($self->{CCFLAGS});
263 $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE});
265 return $self->{CFLAGS} = qq{
266 CCFLAGS = $self->{CCFLAGS}
267 OPTIMIZE = $self->{OPTIMIZE}
268 PERLTYPE = $self->{PERLTYPE}
275 =item const_cccmd (o)
277 Returns the full compiler call for C programs and stores the
278 definition in CONST_CCCMD.
283 my($self,$libperl)=@_;
284 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
285 return '' unless $self->needs_linking();
286 return $self->{CONST_CCCMD} =
287 q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
288 $(CCFLAGS) $(OPTIMIZE) \\
289 $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
290 $(XS_DEFINE_VERSION)};
293 =item const_config (o)
295 Defines a couple of constants in the Makefile that are imported from
301 # --- Constants Sections ---
305 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
306 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
308 foreach $m (@{$self->{CONFIG}}){
309 # SITE*EXP macros are defined in &constants; avoid duplicates here
310 next if $once_only{$m};
311 $self->{uc $m} = quote_paren($self->{uc $m});
312 push @m, uc($m) , ' = ' , $self->{uc $m}, "\n";
318 =item const_loadlibs (o)
320 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
321 L<ExtUtils::Liblist> for details.
327 return "" unless $self->needs_linking;
330 # $self->{NAME} might depend on some other libraries:
331 # See ExtUtils::Liblist for details
336 EXTRALIBS LDLOADLIBS BSLOADLIBS
338 next unless defined $self->{$tmp};
339 push @m, "$tmp = $self->{$tmp}\n";
341 # don't set LD_RUN_PATH if empty
345 next unless $self->{$tmp};
346 push @m, "$tmp = $self->{$tmp}\n";
353 my $make_frag = $mm->constants;
355 Prints out macros for lots of constants.
363 $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use
367 AR_STATIC_ARGS DIRFILESEP DFSEP
369 VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION
370 XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION
371 INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB
372 INST_MAN1DIR INST_MAN3DIR
374 INSTALLDIRS INSTALL_BASE DESTDIR PREFIX
375 PERLPREFIX SITEPREFIX VENDORPREFIX
377 (map { ("INSTALL".$_,
379 } $self->installvars),
384 FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
385 PERLMAINCC PERL_SRC PERL_INC
386 PERL FULLPERL ABSPERL
387 PERLRUN FULLPERLRUN ABSPERLRUN
388 PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
394 next unless defined $self->{$macro};
396 # pathnames can have sharp signs in them; escape them so
397 # make doesn't think it is a comment-start character.
398 $self->{$macro} =~ s/#/\\#/g;
399 push @m, "$macro = $self->{$macro}\n";
403 MAKEMAKER = $self->{MAKEMAKER}
404 MM_VERSION = $self->{MM_VERSION}
405 MM_REVISION = $self->{MM_REVISION}
409 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
410 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
411 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
412 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
417 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
418 LDFROM LINKTYPE BOOTDEP
421 next unless defined $self->{$macro};
422 push @m, "$macro = $self->{$macro}\n";
426 # Handy lists of source code files:
427 XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."
428 C_FILES = ".$self->wraplist(@{$self->{C}})."
429 O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."
430 H_FILES = ".$self->wraplist(@{$self->{H}})."
431 MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."
432 MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
437 # Where is the Config information that we are using/depend on
438 CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
443 # Where to build things
444 INST_LIBDIR = $self->{INST_LIBDIR}
445 INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
447 INST_AUTODIR = $self->{INST_AUTODIR}
448 INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
450 INST_STATIC = $self->{INST_STATIC}
451 INST_DYNAMIC = $self->{INST_DYNAMIC}
452 INST_BOOT = $self->{INST_BOOT}
458 EXPORT_LIST = $self->{EXPORT_LIST}
459 PERL_ARCHIVE = $self->{PERL_ARCHIVE}
460 PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
465 TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."
467 PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}})."
476 Same as macro for the depend attribute.
481 my($self,%attribs) = @_;
483 while (($key,$val) = each %attribs){
484 last unless defined $key;
485 push @m, "$key : $val\n";
495 Defines the DESTDIR and DEST* variables paralleling the INSTALL*.
503 $self->{DESTDIR} ||= '';
505 # Make DEST variables.
506 foreach my $var ($self->installvars) {
507 my $destvar = 'DESTINSTALL'.$var;
508 $self->{$destvar} ||= '$(DESTDIR)$(INSTALL'.$var.')';
517 Defines a lot of macros for distribution support.
519 macro description default
521 TAR tar command to use tar
522 TARFLAGS flags to pass to TAR cvf
524 ZIP zip command to use zip
525 ZIPFLAGS flags to pass to ZIP -r
527 COMPRESS compression command to gzip --best
529 SUFFIX suffix to put on .gz
532 SHAR shar command to use shar
534 PREOP extra commands to run before
536 POSTOP extra commands to run after
539 TO_UNIX a command to convert linefeeds
540 to Unix style in your archive
542 CI command to checkin your ci -u
543 sources to version control
544 RCS_LABEL command to label your sources rcs -Nv$(VERSION_SYM): -q
547 DIST_CP $how argument to manicopy() best
548 when the distdir is created
550 DIST_DEFAULT default target to use to tardist
551 create a distribution
553 DISTVNAME name of the resulting archive $(DISTNAME)-$(VERSION)
561 $self->{TAR} ||= 'tar';
562 $self->{TARFLAGS} ||= 'cvf';
563 $self->{ZIP} ||= 'zip';
564 $self->{ZIPFLAGS} ||= '-r';
565 $self->{COMPRESS} ||= 'gzip --best';
566 $self->{SUFFIX} ||= '.gz';
567 $self->{SHAR} ||= 'shar';
568 $self->{PREOP} ||= '$(NOECHO) $(NOOP)'; # eg update MANIFEST
569 $self->{POSTOP} ||= '$(NOECHO) $(NOOP)'; # eg remove the distdir
570 $self->{TO_UNIX} ||= '$(NOECHO) $(NOOP)';
572 $self->{CI} ||= 'ci -u';
573 $self->{RCS_LABEL}||= 'rcs -Nv$(VERSION_SYM): -q';
574 $self->{DIST_CP} ||= 'best';
575 $self->{DIST_DEFAULT} ||= 'tardist';
577 ($self->{DISTNAME} = $self->{NAME}) =~ s{::}{-}g unless $self->{DISTNAME};
578 $self->{DISTVNAME} ||= $self->{DISTNAME}.'-'.$self->{VERSION};
584 my $dist_macros = $mm->dist(%overrides);
586 Generates a make fragment defining all the macros initialized in
589 %overrides can be used to override any of the above.
594 my($self, %attribs) = @_;
598 TAR TARFLAGS ZIP ZIPFLAGS COMPRESS SUFFIX SHAR
600 CI RCS_LABEL DIST_CP DIST_DEFAULT
604 my $value = $attribs{$key} || $self->{$key};
605 $make .= "$key = $value\n";
611 =item dist_basics (o)
613 Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
620 return <<'MAKE_FRAG';
621 distclean :: realclean distcheck
625 $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
628 $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
631 $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
633 veryclean : realclean
634 $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old
642 Defines a check in target for RCS.
650 $(PERLRUN) "-MExtUtils::Manifest=maniread" \\
651 -e "@all = keys %{ maniread() };" \\
652 -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \\
653 -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
659 my $dist_make_fragment = $MM->dist_core;
661 Puts the targets necessary for 'make dist' together into one make
670 foreach my $target (qw(dist tardist uutardist tarfile zipdist zipfile
673 my $method = $target.'_target';
675 $make_frag .= $self->$method();
684 my $make_frag = $MM->dist_target;
686 Returns the 'dist' target to make an archive for distribution. This
687 target simply checks to make sure the Makefile is up-to-date and
688 depends on $(DIST_DEFAULT).
695 my $date_check = $self->oneliner(<<'CODE', ['-l']);
696 print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
697 if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(FIRST_MAKEFILE)';
700 return sprintf <<'MAKE_FRAG', $date_check;
701 dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
706 =item B<tardist_target>
708 my $make_frag = $MM->tardist_target;
710 Returns the 'tardist' target which is simply so 'make tardist' works.
711 The real work is done by the dynamically named tardistfile_target()
712 method, tardist should have that as a dependency.
719 return <<'MAKE_FRAG';
720 tardist : $(DISTVNAME).tar$(SUFFIX)
725 =item B<zipdist_target>
727 my $make_frag = $MM->zipdist_target;
729 Returns the 'zipdist' target which is simply so 'make zipdist' works.
730 The real work is done by the dynamically named zipdistfile_target()
731 method, zipdist should have that as a dependency.
738 return <<'MAKE_FRAG';
739 zipdist : $(DISTVNAME).zip
744 =item B<tarfile_target>
746 my $make_frag = $MM->tarfile_target;
748 The name of this target is the name of the tarball generated by
749 tardist. This target does the actual work of turning the distdir into
757 return <<'MAKE_FRAG';
758 $(DISTVNAME).tar$(SUFFIX) : distdir
761 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
762 $(RM_RF) $(DISTVNAME)
763 $(COMPRESS) $(DISTVNAME).tar
770 my $make_frag = $MM->zipfile_target;
772 The name of this target is the name of the zip file generated by
773 zipdist. This target does the actual work of turning the distdir into
781 return <<'MAKE_FRAG';
782 $(DISTVNAME).zip : distdir
784 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
785 $(RM_RF) $(DISTVNAME)
790 =item uutardist_target
792 my $make_frag = $MM->uutardist_target;
794 Converts the tarfile into a uuencoded file
798 sub uutardist_target {
801 return <<'MAKE_FRAG';
802 uutardist : $(DISTVNAME).tar$(SUFFIX)
803 uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
810 my $make_frag = $MM->shdist_target;
812 Converts the distdir into a shell archive.
819 return <<'MAKE_FRAG';
822 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
823 $(RM_RF) $(DISTVNAME)
831 Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files.
833 Normally just returns an empty string.
844 Defines targets for bootstrap files.
849 my($self, %attribs) = @_;
852 ' unless $self->has_link_code();
854 my $target = $Is_VMS ? '$(MMS$TARGET)' : '$@';
856 return sprintf <<'MAKE_FRAG', ($target) x 5;
857 BOOTSTRAP = $(BASEEXT).bs
859 # As Mkbootstrap might not write a file (if none is required)
860 # we use touch to prevent make continually trying to remake it.
861 # The DynaLoader only reads a non-empty file.
862 $(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
863 $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
864 $(NOECHO) $(PERLRUN) \
865 "-MExtUtils::Mkbootstrap" \
866 -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
867 $(NOECHO) $(TOUCH) %s
868 $(CHMOD) $(PERM_RW) %s
870 $(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
871 $(NOECHO) $(RM_RF) %s
872 - $(CP) $(BOOTSTRAP) %s
873 $(CHMOD) $(PERM_RW) %s
877 =item dynamic_lib (o)
879 Defines how to produce the *.so (or equivalent) files.
884 my($self, %attribs) = @_;
885 return '' unless $self->needs_linking(); #might be because of a subdir
887 return '' unless $self->has_link_code;
889 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
890 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
891 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
892 my($ldfrom) = '$(LDFROM)';
893 $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':');
895 my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
896 my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : '';
898 # This section creates the dynamically loadable $(INST_DYNAMIC)
899 # from $(OBJECT) and possibly $(MYEXTLIB).
900 ARMAYBE = '.$armaybe.'
901 OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
902 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
903 INST_DYNAMIC_FIX = '.$ld_fix.'
905 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
907 if ($armaybe ne ':'){
908 $ldfrom = 'tmp$(LIB_EXT)';
909 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
910 push(@m,' $(RANLIB) '."$ldfrom\n");
912 $ldfrom = "-all $ldfrom -none" if $Is_OSF;
914 # The IRIX linker doesn't use LD_RUN_PATH
915 my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ?
916 qq{-rpath "$self->{LD_RUN_PATH}"} : '';
918 # For example in AIX the shared objects/libraries from previous builds
919 # linger quite a while in the shared dynalinker cache even when nobody
920 # is using them. This is painful if one for instance tries to restart
921 # a failed build because the link command will fail unnecessarily 'cos
922 # the shared object/library is 'busy'.
926 my $libs = '$(LDLOADLIBS)';
928 if (($Is_NetBSD || $Is_Interix) && $Config{'useshrplib'} eq 'true') {
929 # Use nothing on static perl platforms, and to the flags needed
930 # to link against the shared libperl library on shared perl
931 # platforms. We peek at lddlflags to see if we need -Wl,-R
932 # or -R to add paths to the run-time library search path.
933 if ($Config{'lddlflags'} =~ /-Wl,-R/) {
934 $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
935 } elsif ($Config{'lddlflags'} =~ /-R/) {
936 $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
940 my $ld_run_path_shell = "";
941 if ($self->{LD_RUN_PATH} ne "") {
942 $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
945 push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs;
946 %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
947 $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
952 $(CHMOD) $(PERM_RWX) $@
960 Deprecated method. Use libscan instead.
965 my($self,$path) = @_;
971 Called by init_others, and calls ext ExtUtils::Liblist. See
972 L<ExtUtils::Liblist> for details.
977 my($self,$libs) = @_;
978 require ExtUtils::Liblist;
979 $self->ext($libs, $Verbose);
984 Finds the executables PERL and FULLPERL
989 my($self, $ver, $names, $dirs, $trace) = @_;
992 print "Looking for perl $ver by these names:
999 my $stderr_duped = 0;
1002 if( open(STDERR_COPY, '>&STDERR') ) {
1007 find_perl() can't dup STDERR: $!
1008 You might see some garbage while we search for Perl
1013 foreach $name (@$names){
1014 foreach $dir (@$dirs){
1015 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1017 if ($self->file_name_is_absolute($name)) { # /foo/bar
1019 } elsif ($self->canonpath($name) eq
1020 $self->canonpath(basename($name))) { # foo
1021 $abs = $self->catfile($dir, $name);
1023 $abs = $self->catfile($Curdir, $name);
1025 print "Checking $abs\n" if ($trace >= 2);
1026 next unless $self->maybe_command($abs);
1027 print "Executing $abs\n" if ($trace >= 2);
1029 my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"};
1030 $version_check = "$Config{run} $version_check"
1031 if defined $Config{run} and length $Config{run};
1033 # To avoid using the unportable 2>&1 to suppress STDERR,
1034 # we close it before running the command.
1035 # However, thanks to a thread library bug in many BSDs
1036 # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
1037 # we cannot use the fancier more portable way in here
1038 # but instead need to use the traditional 2>&1 construct.
1040 $val = `$version_check 2>&1`;
1042 close STDERR if $stderr_duped;
1043 $val = `$version_check`;
1044 open STDERR, '>&STDERR_COPY' if $stderr_duped;
1047 if ($val =~ /^VER_OK/m) {
1048 print "Using PERL=$abs\n" if $trace;
1050 } elsif ($trace >= 2) {
1051 print "Result: '$val' ".($? >> 8)."\n";
1055 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1056 0; # false and not empty
1064 Inserts the sharpbang or equivalent magic number to a set of @files.
1068 sub fixin { # stolen from the pink Camel book, more or less
1069 my ( $self, @files ) = @_;
1071 my ($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
1072 for my $file (@files) {
1073 my $file_new = "$file.new";
1074 my $file_bak = "$file.bak";
1078 open( FIXIN, $file ) or croak "Can't process '$file': $!";
1080 chomp( my $line = <FIXIN> );
1081 next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
1082 # Now figure out the interpreter name.
1083 my ( $cmd, $arg ) = split ' ', $line, 2;
1086 # Now look (in reverse) for interpreter in absolute PATH (unless perl).
1088 if ( $cmd eq "perl" ) {
1089 if ( $Config{startperl} =~ m,^\#!.*/perl, ) {
1090 $interpreter = $Config{startperl};
1091 $interpreter =~ s,^\#!,,;
1094 $interpreter = $Config{perlpath};
1099 = reverse grep { $self->file_name_is_absolute } $self->path;
1102 foreach $dir (@absdirs) {
1103 if ( $self->maybe_command($cmd) ) {
1104 warn "Ignoring $interpreter in $file\n"
1105 if $Verbose && $interpreter;
1106 $interpreter = $self->catfile( $dir, $cmd );
1111 # Figure out how to invoke interpreter on this machine.
1115 print STDOUT "Changing sharpbang in $file to $interpreter"
1118 # this is probably value-free on DOSISH platforms
1120 $shb .= "$Config{'sharpbang'}$interpreter";
1121 $shb .= ' ' . $arg if defined $arg;
1125 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
1126 if 0; # not running under some shell
1127 } unless $Is_Win32; # this won't work on win32, so don't
1130 warn "Can't find $cmd in PATH, $file unchanged"
1135 unless ( open( FIXOUT, ">$file_new" ) ) {
1136 warn "Can't create new $file: $!\n";
1140 # Print out the new #! line (or equivalent).
1143 print FIXOUT $shb, <FIXIN>;
1147 chmod 0666, $file_bak;
1149 unless ( _rename( $file, $file_bak ) ) {
1150 warn "Can't rename $file to $file_bak: $!";
1153 unless ( _rename( $file_new, $file ) ) {
1154 warn "Can't rename $file_new to $file: $!";
1155 unless ( _rename( $file_bak, $file ) ) {
1156 warn "Can't rename $file_bak back to $file either: $!";
1157 warn "Leaving $file renamed as $file_bak\n";
1164 close(FIXIN) if fileno(FIXIN);
1165 system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
1171 my($old, $new) = @_;
1173 foreach my $file ($old, $new) {
1174 if( $Is_VMS and basename($file) !~ /\./ ) {
1175 # rename() in 5.8.0 on VMS will not rename a file if it
1176 # does not contain a dot yet it returns success.
1181 return rename($old, $new);
1187 Writes an empty FORCE: target.
1193 '# Phony target to force checking subdirectories.
1201 Guess the name of this package by examining the working directory's
1202 name. MakeMaker calls this only if the developer has not supplied a
1212 my $name = basename(cwd());
1213 $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
1214 # strip minus or underline
1215 # followed by a float or some such
1216 print "Warning: Guessing NAME [$name] from current directory name.\n";
1222 Returns true if C, XS, MYEXTLIB or similar objects exist within this
1223 object that need a compiler. Does not descend into subdirectories as
1224 needs_linking() does.
1230 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1231 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1232 $self->{HAS_LINK_CODE} = 1;
1235 return $self->{HAS_LINK_CODE} = 0;
1241 Scans the directory structure and initializes DIR, XS, XS_FILES,
1242 C, C_FILES, O_FILES, H, H_FILES, PL_FILES, EXE_FILES.
1244 Called by init_main.
1248 sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1250 my($name, %dir, %xs, %c, %h, %pl_files, %pm);
1252 my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
1254 # ignore the distdir
1255 $Is_VMS ? $ignore{"$self->{DISTVNAME}.dir"} = 1
1256 : $ignore{$self->{DISTVNAME}} = 1;
1258 @ignore{map lc, keys %ignore} = values %ignore if $Is_VMS;
1260 foreach $name ($self->lsdir($Curdir)){
1261 next if $name =~ /\#/;
1262 next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
1263 next unless $self->libscan($name);
1265 next if -l $name; # We do not support symlinks at all
1266 next if $self->{NORECURS};
1267 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1268 } elsif ($name =~ /\.xs\z/){
1269 my($c); ($c = $name) =~ s/\.xs\z/.c/;
1272 } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
1274 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1275 } elsif ($name =~ /\.h\z/i){
1277 } elsif ($name =~ /\.PL\z/) {
1278 ($pl_files{$name} = $name) =~ s/\.PL\z// ;
1279 } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
1280 # case-insensitive filesystem, one dot per name, so foo.h.PL
1281 # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
1282 local($/); open(PL,$name); my $txt = <PL>; close PL;
1283 if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
1284 ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
1287 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1289 } elsif ($name =~ /\.(p[ml]|pod)\z/){
1290 $pm{$name} = $self->catfile($self->{INST_LIBDIR},$name);
1294 $self->{PL_FILES} ||= \%pl_files;
1295 $self->{DIR} ||= [sort keys %dir];
1296 $self->{XS} ||= \%xs;
1297 $self->{C} ||= [sort keys %c];
1298 $self->{H} ||= [sort keys %h];
1299 $self->{PM} ||= \%pm;
1301 my @o_files = @{$self->{C}};
1302 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
1308 Determines if man pages should be generated and initializes MAN1PODS
1309 and MAN3PODS as appropriate.
1316 # Set up names of manual pages to generate from pods
1317 foreach my $man (qw(MAN1 MAN3)) {
1318 if ( $self->{"${man}PODS"}
1319 or $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/
1321 $self->{"${man}PODS"} ||= {};
1324 my $init_method = "init_${man}PODS";
1325 $self->$init_method();
1332 my($self, $file) = @_;
1336 if (open(FH,"<$file")) {
1338 if (/^=(?:head\d+|item|pod)\b/) {
1345 # If it doesn't exist yet, we assume, it has pods in it
1355 Initializes MAN1PODS from the list of EXE_FILES.
1362 if ( exists $self->{EXE_FILES} ) {
1363 foreach my $name (@{$self->{EXE_FILES}}) {
1364 next unless $self->_has_pod($name);
1366 $self->{MAN1PODS}->{$name} =
1367 $self->catfile("\$(INST_MAN1DIR)",
1368 basename($name).".\$(MAN1EXT)");
1376 Initializes MAN3PODS from the list of PM files.
1383 my %manifypods = (); # we collect the keys first, i.e. the files
1384 # we have to convert to pod
1386 foreach my $name (keys %{$self->{PM}}) {
1387 if ($name =~ /\.pod\z/ ) {
1388 $manifypods{$name} = $self->{PM}{$name};
1389 } elsif ($name =~ /\.p[ml]\z/ ) {
1390 if( $self->_has_pod($name) ) {
1391 $manifypods{$name} = $self->{PM}{$name};
1396 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1398 # Remove "Configure.pm" and similar, if it's not the only pod listed
1399 # To force inclusion, just name it "Configure.pod", or override
1401 foreach my $name (keys %manifypods) {
1402 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
1403 delete $manifypods{$name};
1406 my($manpagename) = $name;
1407 $manpagename =~ s/\.p(od|m|l)\z//;
1408 # everything below lib is ok
1409 unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1410 $manpagename = $self->catfile(
1411 split(/::/,$self->{PARENT_NAME}),$manpagename
1414 $manpagename = $self->replace_manpage_separator($manpagename);
1415 $self->{MAN3PODS}->{$name} =
1416 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1423 Initializes PMLIBDIRS and PM from PMLIBDIRS.
1430 # Some larger extensions often wish to install a number of *.pm/pl
1431 # files into the library in various locations.
1433 # The attribute PMLIBDIRS holds an array reference which lists
1434 # subdirectories which we should search for library files to
1435 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1436 # recursively search through the named directories (skipping any
1437 # which don't exist or contain Makefile.PL files).
1439 # For each *.pm or *.pl file found $self->libscan() is called with
1440 # the default installation path in $_[1]. The return value of
1441 # libscan defines the actual installation location. The default
1442 # libscan function simply returns the path. The file is skipped
1443 # if libscan returns false.
1445 # The default installation location passed to libscan in $_[1] is:
1447 # ./*.pm => $(INST_LIBDIR)/*.pm
1448 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1449 # ./lib/... => $(INST_LIB)/...
1451 # In this way the 'lib' directory is seen as the root of the actual
1452 # perl library whereas the others are relative to INST_LIBDIR
1453 # (which includes PARENT_NAME). This is a subtle distinction but one
1454 # that's important for nested modules.
1456 unless( $self->{PMLIBDIRS} ) {
1458 # Avoid logical name vs directory collisions
1459 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1462 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1466 #only existing directories that aren't in $dir are allowed
1468 # Avoid $_ wherever possible:
1469 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1470 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1471 @{$self->{PMLIBDIRS}} = ();
1472 my %dir = map { ($_ => $_) } @{$self->{DIR}};
1473 foreach my $pmlibdir (@pmlibdirs) {
1474 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1477 unless( $self->{PMLIBPARENTDIRS} ) {
1478 @{$self->{PMLIBPARENTDIRS}} = ('lib');
1481 return if $self->{PM} and $self->{ARGS}{PM};
1483 if (@{$self->{PMLIBDIRS}}){
1484 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1487 File::Find::find(sub {
1489 unless ($self->libscan($_)){
1490 $File::Find::prune = 1;
1495 return if /~$/; # emacs temp files
1496 return if /,v$/; # RCS files
1498 my $path = $File::Find::name;
1499 my $prefix = $self->{INST_LIBDIR};
1502 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1503 $prefix = $self->{INST_LIB}
1504 if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W}
1507 my($inst) = $self->catfile($prefix,$striplibpath);
1508 local($_) = $inst; # for backwards compatibility
1509 $inst = $self->libscan($inst);
1510 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1511 return unless $inst;
1512 $self->{PM}{$path} = $inst;
1513 }, @{$self->{PMLIBDIRS}});
1518 =item init_DIRFILESEP
1520 Using / for Unix. Called by init_main.
1524 sub init_DIRFILESEP {
1527 $self->{DIRFILESEP} = '/';
1533 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1534 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1535 INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1536 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1537 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1538 VERSION_SYM, XS_VERSION.
1545 # --- Initialize Module Name and Paths
1547 # NAME = Foo::Bar::Oracle
1548 # FULLEXT = Foo/Bar/Oracle
1550 # PARENT_NAME = Foo::Bar
1552 ### ($self->{FULLEXT} =
1553 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1554 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1557 # Copied from DynaLoader:
1559 my(@modparts) = split(/::/,$self->{NAME});
1560 my($modfname) = $modparts[-1];
1562 # Some systems have restrictions on files names for DLL's etc.
1563 # mod2fname returns appropriate file base name (typically truncated)
1564 # It may also edit @modparts if required.
1565 if (defined &DynaLoader::mod2fname) {
1566 $modfname = &DynaLoader::mod2fname(\@modparts);
1569 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1570 $self->{PARENT_NAME} ||= '';
1572 if (defined &DynaLoader::mod2fname) {
1573 # As of 5.001m, dl_os2 appends '_'
1574 $self->{DLBASE} = $modfname;
1576 $self->{DLBASE} = '$(BASEEXT)';
1580 # --- Initialize PERL_LIB, PERL_SRC
1582 # *Real* information: where did we get these two from? ...
1583 my $inc_config_dir = dirname($INC{'Config.pm'});
1584 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1586 unless ($self->{PERL_SRC}){
1587 foreach my $dir_count (1..8) { # 8 is the VMS limit for nesting
1588 my $dir = $self->catdir(($Updir) x $dir_count);
1590 if (-f $self->catfile($dir,"config_h.SH") &&
1591 -f $self->catfile($dir,"perl.h") &&
1592 -f $self->catfile($dir,"lib","Exporter.pm")
1594 $self->{PERL_SRC}=$dir ;
1600 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1601 $self->{PERL_CORE} and !$self->{PERL_SRC};
1603 if ($self->{PERL_SRC}){
1604 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1606 if (defined $Cross::platform) {
1607 $self->{PERL_ARCHLIB} =
1608 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
1610 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
1611 $Is_Win32?("CORE"):());
1614 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1615 $self->{PERL_INC} = ($Is_Win32) ?
1616 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1619 # catch a situation that has occurred a few times in the past:
1621 -s $self->catfile($self->{PERL_SRC},'cflags')
1625 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1630 You cannot build extensions below the perl source tree after executing
1631 a 'make clean' in the perl source tree.
1633 To rebuild extensions distributed with the perl source you should
1634 simply Configure (to include those extensions) and then build perl as
1635 normal. After installing perl the source tree can be deleted. It is
1636 not needed for building extensions by running 'perl Makefile.PL'
1637 usually without extra arguments.
1639 It is recommended that you unpack and build additional extensions away
1640 from the perl source tree.
1644 # we should also consider $ENV{PERL5LIB} here
1645 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1646 $self->{PERL_LIB} ||= $Config{privlibexp};
1647 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1648 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1651 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1653 # Maybe somebody tries to build an extension with an
1654 # uninstalled Perl outside of Perl build tree
1656 for my $dir (@INC) {
1657 $lib = $dir, last if -e $self->catdir($dir, "Config.pm");
1660 # Win32 puts its header files in /perl/src/lib/CORE.
1661 # Unix leaves them in /perl/src.
1662 my $inc = $Is_Win32 ? $self->catdir($lib, "CORE" )
1664 if (-e $self->catdir($inc, "perl.h")) {
1665 $self->{PERL_LIB} = $lib;
1666 $self->{PERL_ARCHLIB} = $lib;
1667 $self->{PERL_INC} = $inc;
1668 $self->{UNINSTALLED_PERL} = 1;
1670 ... Detected uninstalled Perl. Trying to continue.
1677 # We get SITELIBEXP and SITEARCHEXP directly via
1678 # Get_from_Config. When we are running standard modules, these
1679 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1680 # set it to "site". I prefer that INSTALLDIRS be set from outside
1682 $self->{INSTALLDIRS} ||= "site";
1684 $self->{MAN1EXT} ||= $Config{man1ext};
1685 $self->{MAN3EXT} ||= $Config{man3ext};
1687 # Get some stuff out of %Config if we haven't yet done so
1688 print STDOUT "CONFIG must be an array ref\n"
1689 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1690 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1691 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1692 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1694 foreach my $m (@{$self->{CONFIG}}){
1695 next if $once_only{$m};
1696 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1697 unless exists $Config{$m};
1698 $self->{uc $m} ||= $Config{$m};
1702 # This is too dangerous:
1703 # if ($^O eq "next") {
1704 # $self->{AR} = "libtool";
1705 # $self->{AR_STATIC_ARGS} = "-o";
1707 # But I leave it as a placeholder
1709 $self->{AR_STATIC_ARGS} ||= "cr";
1711 # These should never be needed
1712 $self->{OBJ_EXT} ||= '.o';
1713 $self->{LIB_EXT} ||= '.a';
1715 $self->{MAP_TARGET} ||= "perl";
1717 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1719 # make a simple check if we find Exporter
1720 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1721 (Exporter.pm not found)"
1722 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1723 $self->{NAME} eq "ExtUtils::MakeMaker";
1728 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
1729 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1730 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
1731 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1735 sub init_others { # --- Initialize Other Attributes
1738 $self->{LD} ||= 'ld';
1740 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1741 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1742 # undefined. In any case we turn it into an anon array:
1744 # May check $Config{libs} too, thus not empty.
1745 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
1747 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
1748 $self->{LD_RUN_PATH} = "";
1750 foreach $libs ( @{$self->{LIBS}} ){
1751 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1752 my(@libs) = $self->extliblist($libs);
1753 if ($libs[0] or $libs[1] or $libs[2]){
1754 # LD_RUN_PATH now computed by ExtUtils::Liblist
1755 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1756 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1761 if ( $self->{OBJECT} ) {
1762 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1764 # init_dirscan should have found out, if we have C files
1765 $self->{OBJECT} = "";
1766 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1768 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1769 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1770 $self->{PERLMAINCC} ||= '$(CC)';
1771 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1773 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1774 # the 'dynamic' section of MM. We don't have this problem with
1775 # 'static', since we either must use it (%Config says we can't
1776 # use dynamic loading) or the caller asked for it explicitly.
1777 if (!$self->{LINKTYPE}) {
1778 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1780 : ($Config{usedl} ? 'dynamic' : 'static');
1783 $self->{NOOP} ||= '$(SHELL) -c true';
1784 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1786 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
1787 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1788 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1789 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1791 # Some makes require a wrapper around macros passed in on the command
1793 $self->{MACROSTART} ||= '';
1794 $self->{MACROEND} ||= '';
1796 # Not everybody uses -f to indicate "use this Makefile instead"
1797 $self->{USEMAKEFILE} ||= '-f';
1799 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1801 $self->{ECHO} ||= 'echo';
1802 $self->{ECHO_N} ||= 'echo -n';
1803 $self->{RM_F} ||= "rm -f";
1804 $self->{RM_RF} ||= "rm -rf";
1805 $self->{TOUCH} ||= "touch";
1806 $self->{TEST_F} ||= "test -f";
1807 $self->{CP} ||= "cp";
1808 $self->{MV} ||= "mv";
1809 $self->{CHMOD} ||= "chmod";
1810 $self->{MKPATH} ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
1811 $self->{EQUALIZE_TIMESTAMP} ||=
1812 '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
1814 $self->{UNINST} ||= 0;
1815 $self->{VERBINST} ||= 0;
1816 $self->{MOD_INSTALL} ||=
1817 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1818 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1820 $self->{DOC_INSTALL} ||=
1821 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
1822 $self->{UNINSTALL} ||=
1823 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
1824 $self->{WARN_IF_OLD_PACKLIST} ||=
1825 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
1827 q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
1829 $self->{UMASK_NULL} ||= "umask 0";
1830 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1838 Unix has no need of special linker flags.
1844 $self->{PERL_ARCHIVE} ||= '';
1845 $self->{PERL_ARCHIVE_AFTER} ||= '';
1846 $self->{EXPORT_LIST} ||= '';
1863 # The user who requests an installation directory explicitly
1864 # should not have to tell us an architecture installation directory
1865 # as well. We look if a directory exists that is named after the
1866 # architecture. If not we take it as a sign that it should be the
1867 # same as the requested installation directory. Otherwise we take
1869 for my $libpair ({l=>"privlib", a=>"archlib"},
1870 {l=>"sitelib", a=>"sitearch"},
1871 {l=>"vendorlib", a=>"vendorarch"},
1874 my $lib = "install$libpair->{l}";
1876 my $Arch = uc "install$libpair->{a}";
1877 if( $self->{$Lib} && ! $self->{$Arch} ){
1878 my($ilib) = $Config{$lib};
1880 $self->prefixify($Arch,$ilib,$self->{$Lib});
1882 unless (-d $self->{$Arch}) {
1883 print STDOUT "Directory $self->{$Arch} not found\n"
1885 $self->{$Arch} = $self->{$Lib};
1887 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1897 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1898 *PERLRUN* permutations.
1900 PERL is allowed to be miniperl
1901 FULLPERL must be a complete perl
1903 ABSPERL is PERL converted to an absolute path
1905 *PERLRUN contains everything necessary to run perl, find it's
1908 *PERLRUNINST is *PERLRUN + everything necessary to find the
1909 modules being built.
1917 foreach my $component ($self->{PERL_SRC}, $self->path(),
1920 push @defpath, $component if defined $component;
1923 # Build up a set of file names (not command names).
1924 my $thisperl = $self->canonpath($^X);
1925 $thisperl .= $Config{exe_ext} unless
1926 # VMS might have a file version # at the end
1927 $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
1928 : $thisperl =~ m/$Config{exe_ext}$/i;
1930 # We need a relative path to perl when in the core.
1931 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
1933 my @perls = ($thisperl);
1934 push @perls, map { "$_$Config{exe_ext}" }
1935 ('perl', 'perl5', "perl$Config{version}");
1937 # miniperl has priority over all but the cannonical perl when in the
1938 # core. Otherwise its a last resort.
1939 my $miniperl = "miniperl$Config{exe_ext}";
1940 if( $self->{PERL_CORE} ) {
1941 splice @perls, 1, 0, $miniperl;
1944 push @perls, $miniperl;
1948 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
1949 # don't check if perl is executable, maybe they have decided to
1950 # supply switches with perl
1952 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
1953 my $perl_name = 'perl';
1954 $perl_name = 'ndbgperl' if $Is_VMS &&
1955 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
1957 # XXX This logic is flawed. If "miniperl" is anywhere in the path
1958 # it will get confused. It should be fixed to work only on the filename.
1959 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1960 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
1961 unless $self->{FULLPERL};
1963 # Little hack to get around VMS's find_perl putting "MCR" in front
1965 $self->{ABSPERL} = $self->{PERL};
1966 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
1967 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
1968 $self->{ABSPERL} = '$(PERL)';
1971 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
1972 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
1975 # Are we building the core?
1976 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1977 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
1979 # How do we run perl?
1980 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
1981 my $run = $perl.'RUN';
1983 $self->{$run} = "\$($perl)";
1985 # Make sure perl can find itself before it's installed.
1986 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
1987 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
1989 $self->{$perl.'RUNINST'} =
1990 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
1999 =item platform_constants
2001 Add MM_Unix_VERSION.
2008 $self->{MM_Unix_VERSION} = $VERSION;
2009 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2010 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2011 '-Dcalloc=Perl_calloc';
2015 sub platform_constants {
2019 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2021 next unless defined $self->{$macro};
2022 $make_frag .= "$macro = $self->{$macro}\n";
2033 Called by init_main. Initializes PERL_*
2040 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2041 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2051 Sets up macros having to do with XS code. Currently just INST_STATIC,
2052 INST_DYNAMIC and INST_BOOT.
2059 if ($self->has_link_code()) {
2060 $self->{INST_STATIC} =
2061 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2062 $self->{INST_DYNAMIC} =
2063 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2064 $self->{INST_BOOT} =
2065 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2067 $self->{INST_STATIC} = '';
2068 $self->{INST_DYNAMIC} = '';
2069 $self->{INST_BOOT} = '';
2075 Defines the install target.
2080 my($self, %attribs) = @_;
2084 install :: all pure_install doc_install
2087 install_perl :: all pure_perl_install doc_perl_install
2090 install_site :: all pure_site_install doc_site_install
2093 install_vendor :: all pure_vendor_install doc_vendor_install
2096 pure_install :: pure_$(INSTALLDIRS)_install
2099 doc_install :: doc_$(INSTALLDIRS)_install
2102 pure__install : pure_site_install
2103 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2105 doc__install : doc_site_install
2106 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2108 pure_perl_install ::
2109 $(NOECHO) $(MOD_INSTALL) \
2110 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2111 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2112 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2113 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2114 $(INST_BIN) $(DESTINSTALLBIN) \
2115 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2116 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2117 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2118 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2119 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2122 pure_site_install ::
2123 $(NOECHO) $(MOD_INSTALL) \
2124 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2125 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2126 $(INST_LIB) $(DESTINSTALLSITELIB) \
2127 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2128 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2129 $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
2130 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2131 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2132 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2133 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2135 pure_vendor_install ::
2136 $(NOECHO) $(MOD_INSTALL) \
2137 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2138 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2139 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2140 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2141 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2142 $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
2143 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2144 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2147 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2148 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2149 -$(NOECHO) $(DOC_INSTALL) \
2150 "Module" "$(NAME)" \
2151 "installed into" "$(INSTALLPRIVLIB)" \
2152 LINKTYPE "$(LINKTYPE)" \
2153 VERSION "$(VERSION)" \
2154 EXE_FILES "$(EXE_FILES)" \
2155 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2158 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2159 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2160 -$(NOECHO) $(DOC_INSTALL) \
2161 "Module" "$(NAME)" \
2162 "installed into" "$(INSTALLSITELIB)" \
2163 LINKTYPE "$(LINKTYPE)" \
2164 VERSION "$(VERSION)" \
2165 EXE_FILES "$(EXE_FILES)" \
2166 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2168 doc_vendor_install ::
2169 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2170 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2171 -$(NOECHO) $(DOC_INSTALL) \
2172 "Module" "$(NAME)" \
2173 "installed into" "$(INSTALLVENDORLIB)" \
2174 LINKTYPE "$(LINKTYPE)" \
2175 VERSION "$(VERSION)" \
2176 EXE_FILES "$(EXE_FILES)" \
2177 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2182 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2185 uninstall_from_perldirs ::
2186 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2188 uninstall_from_sitedirs ::
2189 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2191 uninstall_from_vendordirs ::
2192 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2198 =item installbin (o)
2200 Defines targets to make and to install EXE_FILES.
2207 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2208 my @exefiles = @{$self->{EXE_FILES}};
2209 return "" unless @exefiles;
2211 @exefiles = map vmsify($_), @exefiles if $Is_VMS;
2214 for my $from (@exefiles) {
2215 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2217 local($_) = $path; # for backwards compatibility
2218 my $to = $self->libscan($path);
2219 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2221 $to = vmsify($to) if $Is_VMS;
2222 $fromto{$from} = $to;
2224 my @to = values %fromto;
2228 EXE_FILES = @exefiles
2236 # realclean can get rather large.
2237 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2241 # A target for each exe file.
2242 while (my($from,$to) = each %fromto) {
2243 last unless defined $from;
2245 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
2246 %s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2247 $(NOECHO) $(RM_F) %s
2250 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
2262 Defines the linkext target which in turn defines the LINKTYPE.
2267 my($self, %attribs) = @_;
2268 # LINKTYPE => static or dynamic or ''
2269 my($linktype) = defined $attribs{LINKTYPE} ?
2270 $attribs{LINKTYPE} : '$(LINKTYPE)';
2272 linkext :: $linktype
2279 Takes as arguments a directory name and a regular expression. Returns
2280 all entries in the directory that match the regular expression.
2286 my($dir, $regex) = @_;
2288 my $dh = new DirHandle;
2289 $dh->open($dir || ".") or return ();
2292 @ls = grep(/$regex/, @ls) if $regex;
2298 Simple subroutine to insert the macros defined by the macro attribute
2304 my($self,%attribs) = @_;
2306 while (($key,$val) = each %attribs){
2307 last unless defined $key;
2308 push @m, "$key = $val\n";
2315 Called by staticmake. Defines how to write the Makefile to produce a
2318 By default the Makefile produced includes all the static extensions in
2319 the perl library. (Purified versions of library files, e.g.,
2320 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2325 my($self, %attribs) = @_;
2326 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2327 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2330 # --- MakeMaker makeaperl section ---
2331 MAP_TARGET = $target
2332 FULLPERL = $self->{FULLPERL}
2334 return join '', @m if $self->{PARENT};
2336 my($dir) = join ":", @{$self->{DIR}};
2338 unless ($self->{MAKEAPERL}) {
2340 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2341 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
2343 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
2344 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2345 $(NOECHO) $(PERLRUNINST) \
2346 Makefile.PL DIR=}, $dir, q{ \
2347 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2348 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2354 push @m, " \\\n\t\t$_";
2356 # push @m, map( " \\\n\t\t$_", @ARGV );
2364 my($cccmd, $linkcmd, $lperl);
2367 $cccmd = $self->const_cccmd($libperl);
2368 $cccmd =~ s/^CCCMD\s*=\s*//;
2369 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2370 $cccmd .= " $Config{cccdlflags}"
2371 if ($Config{useshrplib} eq 'true');
2372 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2374 # The front matter of the linkcommand...
2375 $linkcmd = join ' ', "\$(CC)",
2376 grep($_, @Config{qw(ldflags ccdlflags)});
2377 $linkcmd =~ s/\s+/ /g;
2378 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2380 # Which *.a files could we make use of...
2383 File::Find::find(sub {
2384 return unless m/\Q$self->{LIB_EXT}\E$/;
2386 # Skip perl's libraries.
2387 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2389 # Skip purified versions of libraries
2390 # (e.g., DynaLoader_pure_p1_c0_032.a)
2391 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2393 if( exists $self->{INCLUDE_EXT} ){
2398 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2402 # Throw away anything not explicitly marked for inclusion.
2403 # DynaLoader is implied.
2404 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2410 return unless $found;
2412 elsif( exists $self->{EXCLUDE_EXT} ){
2416 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2420 # Throw away anything explicitly marked for exclusion
2421 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2422 return if( $xx eq $excl );
2426 # don't include the installed version of this extension. I
2427 # leave this line here, although it is not necessary anymore:
2428 # I patched minimod.PL instead, so that Miniperl.pm won't
2429 # enclude duplicates
2431 # Once the patch to minimod.PL is in the distribution, I can
2433 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2435 $static{cwd() . "/" . $_}++;
2436 }, grep( -d $_, @{$searchdirs || []}) );
2438 # We trust that what has been handed in as argument, will be buildable
2439 $static = [] unless $static;
2440 @static{@{$static}} = (1) x @{$static};
2442 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2443 for (sort keys %static) {
2444 next unless /\Q$self->{LIB_EXT}\E\z/;
2445 $_ = dirname($_) . "/extralibs.ld";
2449 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
2454 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2455 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2456 # extralibs.all are computed correctly
2458 MAP_LINKCMD = $linkcmd
2459 MAP_PERLINC = @{$perlinc || []}
2461 join(" \\\n\t", reverse sort keys %static), "
2463 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2466 if (defined $libperl) {
2467 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2469 unless ($libperl && -f $lperl) { # Ilya's code...
2470 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2471 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2472 $libperl ||= "libperl$self->{LIB_EXT}";
2473 $libperl = "$dir/$libperl";
2474 $lperl ||= "libperl$self->{LIB_EXT}";
2475 $lperl = "$dir/$lperl";
2477 if (! -f $libperl and ! -f $lperl) {
2478 # We did not find a static libperl. Maybe there is a shared one?
2480 $lperl = $libperl = "$dir/$Config{libperl}";
2481 # SUNOS ld does not take the full path to a shared library
2482 $libperl = '' if $Is_SunOS4;
2486 print STDOUT "Warning: $libperl not found
2487 If you're going to build a static perl binary, make sure perl is installed
2488 otherwise ignore this warning\n"
2489 unless (-f $lperl || defined($self->{PERL_SRC}));
2492 # SUNOS ld does not take the full path to a shared library
2493 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2496 MAP_LIBPERL = $libperl
2497 LLIBPERL = $llibperl
2501 $(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
2502 $(NOECHO) $(RM_F) $@
2503 $(NOECHO) $(TOUCH) $@
2507 foreach $catfile (@$extra){
2508 push @m, "\tcat $catfile >> \$\@\n";
2512 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2513 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2514 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2515 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2516 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2517 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
2519 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2521 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
2524 $tmp/perlmain.c: $makefilename}, q{
2525 $(NOECHO) $(ECHO) Writing $@
2526 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2527 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2530 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2531 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2536 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2537 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2538 -$(NOECHO) $(DOC_INSTALL) \
2539 "Perl binary" "$(MAP_TARGET)" \
2540 MAP_STATIC "$(MAP_STATIC)" \
2541 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2542 MAP_LIBPERL "$(MAP_LIBPERL)" \
2543 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2548 inst_perl: pure_inst_perl doc_inst_perl
2550 pure_inst_perl: $(MAP_TARGET)
2551 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2556 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2564 Defines how to rewrite the Makefile.
2571 # We do not know what target was originally specified so we
2572 # must force a manual rerun to be sure. But as it should only
2573 # happen very rarely it is not a significant problem.
2575 $(OBJECT) : $(FIRST_MAKEFILE)
2577 ' if $self->{OBJECT};
2579 my $newer_than_target = $Is_VMS ? '$(MMS$SOURCE_LIST)' : '$?';
2580 my $mpl_args = join " ", map qq["$_"], @ARGV;
2582 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
2583 # We take a very conservative approach here, but it's worth it.
2584 # We move Makefile to Makefile.old here to avoid gnu make looping.
2585 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2586 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
2587 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2588 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2589 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2590 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2591 $(PERLRUN) Makefile.PL %s
2592 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2593 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
2604 Returns true, if the argument is likely to be a command.
2609 my($self,$file) = @_;
2610 return $file if -x $file && ! -d $file;
2615 =item needs_linking (o)
2617 Does this module need linking? Looks into subdirectory objects (see
2618 also has_link_code())
2625 $caller = (caller(0))[3];
2626 confess("needs_linking called too early") if
2627 $caller =~ /^ExtUtils::MakeMaker::/;
2628 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2629 if ($self->has_link_code or $self->{MAKEAPERL}){
2630 $self->{NEEDS_LINKING} = 1;
2633 foreach $child (keys %{$self->{CHILDREN}}) {
2634 if ($self->{CHILDREN}->{$child}->needs_linking) {
2635 $self->{NEEDS_LINKING} = 1;
2639 return $self->{NEEDS_LINKING} = 0;
2644 misnamed method (will have to be changed). The MM_Unix method just
2645 returns the argument without further processing.
2647 On VMS used to insure that colons marking targets are preceded by
2648 space - most Unix Makes don't need this, but it's necessary under VMS
2649 to distinguish the target delimiter from a colon appearing as part of
2655 my($self,$text) = @_;
2659 =item parse_abstract
2661 parse a file and return what you think is the ABSTRACT
2665 sub parse_abstract {
2666 my($self,$parsefile) = @_;
2670 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2672 my $package = $self->{DISTNAME};
2673 $package =~ s/-/::/g;
2675 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2678 next unless /^($package\s-\s)(.*)/;
2688 my $version = MM->parse_version($file);
2690 Parse a $file and return what $VERSION is set to by the first assignment.
2691 It will return the string "undef" if it can't figure out what $VERSION
2692 is. $VERSION should be for all to see, so C<our $VERSION> or plain $VERSION
2693 are okay, but C<my $VERSION> is not.
2695 parse_version() will try to C<use version> before checking for C<$VERSION> so the following will work.
2697 $VERSION = qv(1.2.3);
2702 my($self,$parsefile) = @_;
2707 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2710 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2711 next if $inpod || /^\s*#/;
2713 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
2715 package ExtUtils::MakeMaker::_version;
2728 $result = eval($eval);
2729 warn "Could not eval '$eval' in $parsefile: $@" if $@;
2734 $result = "undef" unless defined $result;
2741 Defines the string that is passed to recursive make calls in
2751 my($sep) = $Is_VMS ? ',' : '';
2754 foreach $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
2755 PREFIX INSTALL_BASE)
2758 next unless defined $self->{$key};
2759 push @pasthru, "$key=\"\$($key)\"";
2762 foreach $key (qw(DEFINE INC)) {
2763 next unless defined $self->{$key};
2764 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
2767 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
2773 Takes one argument, a file name, and returns the file name, if the
2774 argument is likely to be a perl script. On MM_Unix this is true for
2775 any ordinary, readable file.
2780 my($self,$file) = @_;
2781 return $file if -r $file && -f _;
2785 =item perldepend (o)
2787 Defines the dependency from all *.h files that come with the perl
2796 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
2798 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
2799 # Check for unpropogated config.sh changes. Should never happen.
2800 # We do NOT just update config.h because that is not sufficient.
2801 # An out of date config.h is not fatal but complains loudly!
2802 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2803 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2805 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2806 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2810 return join "", @m unless $self->needs_linking;
2814 $(PERL_INC)/EXTERN.h \
2815 $(PERL_INC)/INTERN.h \
2816 $(PERL_INC)/XSUB.h \
2818 $(PERL_INC)/cc_runtime.h \
2819 $(PERL_INC)/config.h \
2822 $(PERL_INC)/dosish.h \
2823 $(PERL_INC)/embed.h \
2824 $(PERL_INC)/embedvar.h \
2825 $(PERL_INC)/fakethr.h \
2826 $(PERL_INC)/form.h \
2828 $(PERL_INC)/handy.h \
2830 $(PERL_INC)/intrpvar.h \
2831 $(PERL_INC)/iperlsys.h \
2832 $(PERL_INC)/keywords.h \
2834 $(PERL_INC)/nostdio.h \
2836 $(PERL_INC)/opcode.h \
2837 $(PERL_INC)/patchlevel.h \
2838 $(PERL_INC)/perl.h \
2839 $(PERL_INC)/perlio.h \
2840 $(PERL_INC)/perlsdio.h \
2841 $(PERL_INC)/perlsfio.h \
2842 $(PERL_INC)/perlvars.h \
2843 $(PERL_INC)/perly.h \
2845 $(PERL_INC)/pp_proto.h \
2846 $(PERL_INC)/proto.h \
2847 $(PERL_INC)/regcomp.h \
2848 $(PERL_INC)/regexp.h \
2849 $(PERL_INC)/regnodes.h \
2850 $(PERL_INC)/scope.h \
2852 $(PERL_INC)/thread.h \
2853 $(PERL_INC)/unixish.h \
2856 $(OBJECT) : $(PERL_HDRS)
2857 } if $self->{OBJECT};
2859 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2867 Returns the attribute C<PERM_RW> or the string C<644>.
2868 Used as the string that is passed
2869 to the C<chmod> command to set the permissions for read/writeable files.
2870 MakeMaker chooses C<644> because it has turned out in the past that
2871 relying on the umask provokes hard-to-track bug reports.
2872 When the return value is used by the perl function C<chmod>, it is
2873 interpreted as an octal value.
2878 return shift->{PERM_RW};
2883 Returns the attribute C<PERM_RWX> or the string C<755>,
2884 i.e. the string that is passed
2885 to the C<chmod> command to set the permissions for executable files.
2891 return shift->{PERM_RWX};
2896 Defines target that copies all files in the hash PM to their
2897 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
2903 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2905 pm_to_blib : $(TO_INST_PM)
2908 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
2909 pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
2912 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
2914 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
2915 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
2920 =item post_constants (o)
2922 Returns an empty string per default. Dedicated to overrides from
2923 within Makefile.PL after all constants have been defined.
2931 =item post_initialize (o)
2933 Returns an empty string per default. Used in Makefile.PLs to add some
2934 chunk of text to the Makefile after the object is initialized.
2938 sub post_initialize {
2944 Returns an empty string. Can be used in Makefile.PLs to write some
2945 text to the Makefile at the end.
2955 Defines target that creates a PPD (Perl Package Description) file
2956 for a binary distribution.
2963 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
2965 my $abstract = $self->{ABSTRACT} || '';
2966 $abstract =~ s/\n/\\n/sg;
2967 $abstract =~ s/</</g;
2968 $abstract =~ s/>/>/g;
2970 my $author = $self->{AUTHOR} || '';
2971 $author =~ s/</</g;
2972 $author =~ s/>/>/g;
2974 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
2975 <SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
2976 <TITLE>$(DISTNAME)</TITLE>
2977 <ABSTRACT>%s</ABSTRACT>
2981 $ppd_xml .= " <IMPLEMENTATION>\n";
2982 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
2983 my $pre_req = $prereq;
2984 $pre_req =~ s/::/-/g;
2985 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
2987 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
2988 <DEPENDENCY NAME="%s" VERSION="%s" />
2993 my $archname = $Config{archname};
2995 # archname did not change from 5.6 to 5.8, but those versions may
2996 # not be not binary compatible so now we append the part of the
2997 # version that changes when binary compatibility may change
2998 $archname .= "-". substr($Config{version},0,3);
3000 $ppd_xml .= sprintf <<'PPD_OUT', $archname;
3001 <OS NAME="$(OSNAME)" />
3002 <ARCHITECTURE NAME="%s" />
3005 if ($self->{PPM_INSTALL_SCRIPT}) {
3006 if ($self->{PPM_INSTALL_EXEC}) {
3007 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
3008 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
3011 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
3012 $self->{PPM_INSTALL_SCRIPT};
3016 my ($bin_location) = $self->{BINARY_LOCATION} || '';
3017 $bin_location =~ s/\\/\\\\/g;
3019 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
3020 <CODEBASE HREF="%s" />
3025 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
3027 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3028 # Creates a PPD (Perl Package Description) for a binary distribution.
3037 $MM->prefixify($var, $prefix, $new_prefix, $default);
3039 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3040 replace it's $prefix with a $new_prefix.
3042 Should the $prefix fail to match I<AND> a PREFIX was given as an
3043 argument to WriteMakefile() it will set it to the $new_prefix +
3044 $default. This is for systems whose file layouts don't neatly fit into
3045 our ideas of prefixes.
3047 This is for heuristics which attempt to create directory structures
3048 that mirror those of the installed perl.
3052 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3054 this will attempt to remove '/usr' from the front of the
3055 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3056 if necessary) and replace it with '/home/foo'. If this fails it will
3057 simply use '/home/foo/man/man1'.
3062 my($self,$var,$sprefix,$rprefix,$default) = @_;
3064 my $path = $self->{uc $var} ||
3065 $Config_Override{lc $var} || $Config{lc $var} || '';
3067 $rprefix .= '/' if $sprefix =~ m|/$|;
3069 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3070 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
3072 if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) &&
3073 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3076 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3077 print STDERR " no default!\n" if !$default && $Verbose >= 2;
3079 $path = $self->catdir($rprefix, $default) if $default;
3082 print " now $path\n" if $Verbose >= 2;
3083 return $self->{uc $var} = $path;
3089 Defines targets to run *.PL files.
3095 my $pl_files = $self->{PL_FILES};
3097 return "" unless $pl_files;
3100 foreach my $plfile (sort keys %$pl_files) {
3101 my $list = ref($pl_files->{$plfile})
3102 ? $pl_files->{$plfile}
3103 : [$pl_files->{$plfile}];
3105 foreach my $target (@$list) {
3107 $plfile = vmsify($self->eliminate_macros($plfile));
3108 $target = vmsify($self->eliminate_macros($target));
3111 # Normally a .PL file runs AFTER pm_to_blib so it can have
3112 # blib in its @INC and load the just built modules. BUT if
3113 # the generated module is something in $(TO_INST_PM) which
3114 # pm_to_blib depends on then it can't depend on pm_to_blib
3115 # else we have a dependency loop.
3118 if( defined $self->{PM}{$target} ) {
3120 $perlrun = 'PERLRUN';
3123 $pm_dep = 'pm_to_blib';
3124 $perlrun = 'PERLRUNINST';
3132 $target :: $plfile $pm_dep
3133 \$($perlrun) $plfile $target
3144 Backslashes parentheses C<()> in command line arguments.
3145 Doesn't handle recursive Makefile C<$(...)> constructs,
3146 but handles simple ones.
3152 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3153 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3154 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
3158 =item replace_manpage_separator
3160 my $man_name = $MM->replace_manpage_separator($file_path);
3162 Takes the name of a package, which may be a nested package, in the
3163 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3164 safe for a man page file name. Returns the replacement.
3168 sub replace_manpage_separator {
3169 my($self,$man) = @_;
3181 my($self, $dir, @cmds) = @_;
3183 # No leading tab and no trailing newline makes for easier embedding
3184 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3194 my($self, $cmd, $switches) = @_;
3195 $switches = [] unless defined $switches;
3197 # Strip leading and trailing newlines
3201 my @cmds = split /\n/, $cmd;
3202 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
3203 $cmd = $self->escape_newlines($cmd);
3205 $switches = join ' ', @$switches;
3207 return qq{\$(ABSPERLRUN) $switches -e $cmd --};
3216 my($self, $text) = @_;
3218 # I think all we have to quote is single quotes and I think
3219 # this is a safe way to do it.
3220 $text =~ s{'}{'\\''}g;
3226 =item escape_newlines
3230 sub escape_newlines {
3231 my($self, $text) = @_;
3233 $text =~ s{\n}{\\\n}g;
3241 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3248 if (!defined $self->{_MAX_EXEC_LEN}) {
3249 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3250 $self->{_MAX_EXEC_LEN} = $arg_max;
3252 else { # POSIX minimum exec size
3253 $self->{_MAX_EXEC_LEN} = 4096;
3257 return $self->{_MAX_EXEC_LEN};
3263 Defines the static target.
3268 # --- Static Loading Sections ---
3272 ## $(INST_PM) has been moved to the all: target.
3273 ## It remains here for awhile to allow for old usage: "make static"
3274 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3279 =item static_lib (o)
3281 Defines how to produce the *.a (or equivalent) files.
3287 return '' unless $self->has_link_code;
3292 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
3296 # If this extension has its own library (eg SDBM_File)
3297 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3298 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3299 $(CP) $(MYEXTLIB) $@
3303 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3304 # Prefer the absolute pathed ar if available so that PATH
3305 # doesn't confuse us. Perl itself is built with the full_ar.
3310 push @m, sprintf <<'MAKE_FRAG', $ar;
3311 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3312 $(CHMOD) $(PERM_RWX) $@
3313 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3316 # Old mechanism - still available:
3317 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3318 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3324 =item staticmake (o)
3331 my($self, %attribs) = @_;
3334 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3336 # And as it's not yet built, we add the current extension
3337 # but only if it has some C code (or XS code, which implies C code)
3338 if (@{$self->{C}}) {
3339 @static = $self->catfile($self->{INST_ARCHLIB},
3342 "$self->{BASEEXT}$self->{LIB_EXT}"
3346 # Either we determine now, which libraries we will produce in the
3347 # subdirectories or we do it at runtime of the make.
3349 # We could ask all subdir objects, but I cannot imagine, why it
3350 # would be necessary.
3352 # Instead we determine all libraries for the new perl at
3354 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3356 $self->makeaperl(MAKE => $self->{MAKEFILE},
3357 DIRS => \@searchdirs,
3360 TARGET => $self->{MAP_TARGET},
3362 LIBPERL => $self->{LIBPERL_A}
3368 Helper subroutine for subdirs
3373 my($self, $subdir) = @_;
3375 my $subdir_cmd = $self->cd($subdir,
3376 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3378 return sprintf <<'EOT', $subdir_cmd;
3388 Defines targets to process subdirectories.
3393 # --- Sub-directory Sections ---
3396 # This method provides a mechanism to automatically deal with
3397 # subdirectories containing further Makefile.PL scripts.
3398 # It calls the subdir_x() method for each subdirectory.
3399 foreach $dir (@{$self->{DIR}}){
3400 push(@m, $self->subdir_x($dir));
3401 #### print "Including $dir subdirectory\n";
3405 # The default clean, realclean and test targets in this Makefile
3406 # have automatically been given entries for each subdir.
3410 push(@m, "\n# none")
3417 Defines the test targets.
3422 # --- Test and Installation Sections ---
3424 my($self, %attribs) = @_;
3425 my $tests = $attribs{TESTS} || '';
3426 if (!$tests && -d 't') {
3427 $tests = $self->find_tests;
3429 # note: 'test.pl' name is also hardcoded in init_dirscan()
3433 TEST_TYPE=test_\$(LINKTYPE)
3438 testdb :: testdb_\$(LINKTYPE)
3440 test :: \$(TEST_TYPE) subdirs-test
3447 foreach my $dir (@{ $self->{DIR} }) {
3448 my $test = $self->cd($dir, '$(MAKE) test $(PASTHRU)');
3457 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3458 unless $tests or -f "test.pl" or @{$self->{DIR}};
3461 push(@m, "test_dynamic :: pure_all\n");
3462 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3464 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3468 push(@m, "testdb_dynamic :: pure_all\n");
3469 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3473 # Occasionally we may face this degenerate target:
3474 push @m, "test_ : test_dynamic\n\n";
3476 if ($self->needs_linking()) {
3477 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3478 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3479 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3481 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3482 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3485 push @m, "test_static :: test_dynamic\n";
3486 push @m, "testdb_static :: testdb_dynamic\n";
3491 =item test_via_harness (override)
3493 For some reason which I forget, Unix machines like to have
3494 PERL_DL_NONLAZY set for tests.
3498 sub test_via_harness {
3499 my($self, $perl, $tests) = @_;
3500 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3503 =item test_via_script (override)
3505 Again, the PERL_DL_NONLAZY thing.
3509 sub test_via_script {
3510 my($self, $perl, $script) = @_;
3511 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3515 =item tools_other (o)
3517 my $make_frag = $MM->tools_other;
3519 Returns a make fragment containing definitions for the macros init_others()
3528 # We set PM_FILTER as late as possible so it can see all the earlier
3529 # on macro-order sensitive makes such as nmake.
3530 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
3531 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
3534 MOD_INSTALL DOC_INSTALL UNINSTALL
3535 WARN_IF_OLD_PACKLIST
3542 next unless defined $self->{$tool};
3543 push @m, "$tool = $self->{$tool}\n";
3549 =item tool_xsubpp (o)
3551 Determines typemaps, xsubpp version, prototype behaviour.
3557 return "" unless $self->needs_linking;
3560 my @xsubpp_dirs = @INC;
3562 # Make sure we pick up the new xsubpp if we're building perl.
3563 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3565 foreach my $dir (@xsubpp_dirs) {
3566 $xsdir = $self->catdir($dir, 'ExtUtils');
3567 if( -r $self->catfile($xsdir, "xsubpp") ) {
3572 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3573 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3574 if( $self->{TYPEMAPS} ){
3576 foreach $typemap (@{$self->{TYPEMAPS}}){
3577 if( ! -f $typemap ){
3578 warn "Typemap $typemap not found.\n";
3581 push(@tmdeps, $typemap);
3585 push(@tmdeps, "typemap") if -f "typemap";
3586 my(@tmargs) = map("-typemap $_", @tmdeps);
3587 if( exists $self->{XSOPT} ){
3588 unshift( @tmargs, $self->{XSOPT} );
3592 $Config{'ldflags'} &&
3593 $Config{'ldflags'} =~ m!/Debug!i &&
3594 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
3597 unshift(@tmargs,'-nolinenumbers');
3601 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3605 XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp
3606 XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
3607 XSPROTOARG = $self->{XSPROTOARG}
3608 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3609 XSUBPPARGS = @tmargs
3617 Build man pages, too
3624 return <<'MAKE_EXT';
3625 all :: pure_all manifypods
3630 =item top_targets (o)
3632 Defines the targets all, subdirs, config, and O_FILES
3637 # --- Target Sections ---
3642 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3645 pure_all :: config pm_to_blib subdirs linkext
3648 subdirs :: $(MYEXTLIB)
3651 config :: $(FIRST_MAKEFILE) blibdirs
3656 $(O_FILES): $(H_FILES)
3657 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3661 perldoc ExtUtils::MakeMaker
3669 Obsolete, deprecated method. Not used since Version 5.21.
3674 # --- perllocal.pod section ---
3675 my($self,$what,$name,@attribs)=@_;
3676 my $time = localtime;
3677 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3678 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3679 print "\n\n=back\n\n";
3684 Defines the suffix rules to compile XS files to C.
3690 return '' unless $self->needs_linking();
3693 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3699 Defines the suffix rules to compile XS files to C++.
3705 return '' unless $self->needs_linking();
3708 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
3714 Defines suffix rules to go from XS to object files directly. This is
3715 only intended for broken make implementations.
3719 sub xs_o { # many makes are too dumb to use xs_c then c_o
3721 return '' unless $self->needs_linking();
3724 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3725 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
3736 L<ExtUtils::MakeMaker>