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 $self->{"BUILD${man}PODS"} = 1;
1310 unless ($self->{"${man}PODS"}) {
1311 $self->{"${man}PODS"} = {};
1312 $self->{"BUILD${man}PODS"} = 0 if
1313 $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/;
1317 $self->init_MAN1PODS() if $self->{BUILDMAN1PODS};
1318 $self->init_MAN3PODS() if $self->{BUILDMAN3PODS};
1323 my($self, $file) = @_;
1327 if (open(FH,"<$file")) {
1329 if (/^=(?:head\d+|item|pod)\b/) {
1336 # If it doesn't exist yet, we assume, it has pods in it
1346 Initializes MAN1PODS from the list of EXE_FILES.
1353 if ( exists $self->{EXE_FILES} ) {
1354 foreach my $name (@{$self->{EXE_FILES}}) {
1355 next unless $self->_has_pod($name);
1357 $self->{MAN1PODS}->{$name} =
1358 $self->catfile("\$(INST_MAN1DIR)",
1359 basename($name).".\$(MAN1EXT)");
1367 Initializes MAN3PODS from the list of PM files.
1374 my %manifypods = (); # we collect the keys first, i.e. the files
1375 # we have to convert to pod
1377 foreach my $name (keys %{$self->{PM}}) {
1378 if ($name =~ /\.pod\z/ ) {
1379 $manifypods{$name} = $self->{PM}{$name};
1380 } elsif ($name =~ /\.p[ml]\z/ ) {
1381 if( $self->_has_pod($name) ) {
1382 $manifypods{$name} = $self->{PM}{$name};
1387 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1389 # Remove "Configure.pm" and similar, if it's not the only pod listed
1390 # To force inclusion, just name it "Configure.pod", or override
1392 foreach my $name (keys %manifypods) {
1393 if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
1394 delete $manifypods{$name};
1397 my($manpagename) = $name;
1398 $manpagename =~ s/\.p(od|m|l)\z//;
1399 # everything below lib is ok
1400 unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
1401 $manpagename = $self->catfile(
1402 split(/::/,$self->{PARENT_NAME}),$manpagename
1405 $manpagename = $self->replace_manpage_separator($manpagename);
1406 $self->{MAN3PODS}->{$name} =
1407 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
1414 Initializes PMLIBDIRS and PM from PMLIBDIRS.
1421 my $pm = $self->{PM};
1423 # Some larger extensions often wish to install a number of *.pm/pl
1424 # files into the library in various locations.
1426 # The attribute PMLIBDIRS holds an array reference which lists
1427 # subdirectories which we should search for library files to
1428 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1429 # recursively search through the named directories (skipping any
1430 # which don't exist or contain Makefile.PL files).
1432 # For each *.pm or *.pl file found $self->libscan() is called with
1433 # the default installation path in $_[1]. The return value of
1434 # libscan defines the actual installation location. The default
1435 # libscan function simply returns the path. The file is skipped
1436 # if libscan returns false.
1438 # The default installation location passed to libscan in $_[1] is:
1440 # ./*.pm => $(INST_LIBDIR)/*.pm
1441 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1442 # ./lib/... => $(INST_LIB)/...
1444 # In this way the 'lib' directory is seen as the root of the actual
1445 # perl library whereas the others are relative to INST_LIBDIR
1446 # (which includes PARENT_NAME). This is a subtle distinction but one
1447 # that's important for nested modules.
1449 unless( $self->{PMLIBDIRS} ) {
1451 # Avoid logical name vs directory collisions
1452 $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
1455 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}];
1459 #only existing directories that aren't in $dir are allowed
1461 # Avoid $_ wherever possible:
1462 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1463 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1464 @{$self->{PMLIBDIRS}} = ();
1465 my %dir = map { ($_ => $_) } @{$self->{DIR}};
1466 foreach my $pmlibdir (@pmlibdirs) {
1467 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1470 unless( $self->{PMLIBPARENTDIRS} ) {
1471 @{$self->{PMLIBPARENTDIRS}} = ('lib');
1474 if (@{$self->{PMLIBDIRS}}){
1475 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1478 File::Find::find(sub {
1480 unless ($self->libscan($_)){
1481 $File::Find::prune = 1;
1486 return if /~$/; # emacs temp files
1487 return if /,v$/; # RCS files
1489 my $path = $File::Find::name;
1490 my $prefix = $self->{INST_LIBDIR};
1493 my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
1494 $prefix = $self->{INST_LIB}
1495 if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W}
1498 my($inst) = $self->catfile($prefix,$striplibpath);
1499 local($_) = $inst; # for backwards compatibility
1500 $inst = $self->libscan($inst);
1501 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1502 return unless $inst;
1503 $pm->{$path} = $inst;
1504 }, @{$self->{PMLIBDIRS}});
1509 =item init_DIRFILESEP
1511 Using / for Unix. Called by init_main.
1515 sub init_DIRFILESEP {
1518 $self->{DIRFILESEP} = '/';
1524 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
1525 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
1526 INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
1527 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
1528 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
1529 VERSION_SYM, XS_VERSION.
1536 # --- Initialize Module Name and Paths
1538 # NAME = Foo::Bar::Oracle
1539 # FULLEXT = Foo/Bar/Oracle
1541 # PARENT_NAME = Foo::Bar
1543 ### ($self->{FULLEXT} =
1544 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1545 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1548 # Copied from DynaLoader:
1550 my(@modparts) = split(/::/,$self->{NAME});
1551 my($modfname) = $modparts[-1];
1553 # Some systems have restrictions on files names for DLL's etc.
1554 # mod2fname returns appropriate file base name (typically truncated)
1555 # It may also edit @modparts if required.
1556 if (defined &DynaLoader::mod2fname) {
1557 $modfname = &DynaLoader::mod2fname(\@modparts);
1560 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
1561 $self->{PARENT_NAME} ||= '';
1563 if (defined &DynaLoader::mod2fname) {
1564 # As of 5.001m, dl_os2 appends '_'
1565 $self->{DLBASE} = $modfname;
1567 $self->{DLBASE} = '$(BASEEXT)';
1571 # --- Initialize PERL_LIB, PERL_SRC
1573 # *Real* information: where did we get these two from? ...
1574 my $inc_config_dir = dirname($INC{'Config.pm'});
1575 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1577 unless ($self->{PERL_SRC}){
1579 foreach $dir ($Updir,
1580 $self->catdir($Updir,$Updir),
1581 $self->catdir($Updir,$Updir,$Updir),
1582 $self->catdir($Updir,$Updir,$Updir,$Updir),
1583 $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir))
1586 -f $self->catfile($dir,"config_h.SH")
1588 -f $self->catfile($dir,"perl.h")
1590 -f $self->catfile($dir,"lib","Exporter.pm")
1592 $self->{PERL_SRC}=$dir ;
1598 warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
1599 $self->{PERL_CORE} and !$self->{PERL_SRC};
1601 if ($self->{PERL_SRC}){
1602 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1604 if (defined $Cross::platform) {
1605 $self->{PERL_ARCHLIB} =
1606 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
1608 $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform,
1609 $Is_Win32?("CORE"):());
1612 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1613 $self->{PERL_INC} = ($Is_Win32) ?
1614 $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1617 # catch a situation that has occurred a few times in the past:
1619 -s $self->catfile($self->{PERL_SRC},'cflags')
1623 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1628 You cannot build extensions below the perl source tree after executing
1629 a 'make clean' in the perl source tree.
1631 To rebuild extensions distributed with the perl source you should
1632 simply Configure (to include those extensions) and then build perl as
1633 normal. After installing perl the source tree can be deleted. It is
1634 not needed for building extensions by running 'perl Makefile.PL'
1635 usually without extra arguments.
1637 It is recommended that you unpack and build additional extensions away
1638 from the perl source tree.
1642 # we should also consider $ENV{PERL5LIB} here
1643 my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
1644 $self->{PERL_LIB} ||= $Config{privlibexp};
1645 $self->{PERL_ARCHLIB} ||= $Config{archlibexp};
1646 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1649 if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
1651 # Maybe somebody tries to build an extension with an
1652 # uninstalled Perl outside of Perl build tree
1654 for my $dir (@INC) {
1655 $lib = $dir, last if -e $self->catdir($dir, "Config.pm");
1658 # Win32 puts its header files in /perl/src/lib/CORE.
1659 # Unix leaves them in /perl/src.
1660 my $inc = $Is_Win32 ? $self->catdir($lib, "CORE" )
1662 if (-e $self->catdir($inc, "perl.h")) {
1663 $self->{PERL_LIB} = $lib;
1664 $self->{PERL_ARCHLIB} = $lib;
1665 $self->{PERL_INC} = $inc;
1666 $self->{UNINSTALLED_PERL} = 1;
1668 ... Detected uninstalled Perl. Trying to continue.
1675 # We get SITELIBEXP and SITEARCHEXP directly via
1676 # Get_from_Config. When we are running standard modules, these
1677 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1678 # set it to "site". I prefer that INSTALLDIRS be set from outside
1680 $self->{INSTALLDIRS} ||= "site";
1682 $self->{MAN1EXT} ||= $Config{man1ext};
1683 $self->{MAN3EXT} ||= $Config{man3ext};
1685 # Get some stuff out of %Config if we haven't yet done so
1686 print STDOUT "CONFIG must be an array ref\n"
1687 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1688 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1689 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1690 push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
1692 foreach my $m (@{$self->{CONFIG}}){
1693 next if $once_only{$m};
1694 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1695 unless exists $Config{$m};
1696 $self->{uc $m} ||= $Config{$m};
1700 # This is too dangerous:
1701 # if ($^O eq "next") {
1702 # $self->{AR} = "libtool";
1703 # $self->{AR_STATIC_ARGS} = "-o";
1705 # But I leave it as a placeholder
1707 $self->{AR_STATIC_ARGS} ||= "cr";
1709 # These should never be needed
1710 $self->{OBJ_EXT} ||= '.o';
1711 $self->{LIB_EXT} ||= '.a';
1713 $self->{MAP_TARGET} ||= "perl";
1715 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1717 # make a simple check if we find Exporter
1718 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1719 (Exporter.pm not found)"
1720 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1721 $self->{NAME} eq "ExtUtils::MakeMaker";
1726 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
1727 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
1728 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
1729 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
1733 sub init_others { # --- Initialize Other Attributes
1736 $self->{LD} ||= 'ld';
1738 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1739 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1740 # undefined. In any case we turn it into an anon array:
1742 # May check $Config{libs} too, thus not empty.
1743 $self->{LIBS} = [$self->{LIBS}] unless ref $self->{LIBS};
1745 $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
1746 $self->{LD_RUN_PATH} = "";
1748 foreach $libs ( @{$self->{LIBS}} ){
1749 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1750 my(@libs) = $self->extliblist($libs);
1751 if ($libs[0] or $libs[1] or $libs[2]){
1752 # LD_RUN_PATH now computed by ExtUtils::Liblist
1753 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
1754 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1759 if ( $self->{OBJECT} ) {
1760 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1762 # init_dirscan should have found out, if we have C files
1763 $self->{OBJECT} = "";
1764 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1766 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1767 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1768 $self->{PERLMAINCC} ||= '$(CC)';
1769 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1771 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1772 # the 'dynamic' section of MM. We don't have this problem with
1773 # 'static', since we either must use it (%Config says we can't
1774 # use dynamic loading) or the caller asked for it explicitly.
1775 if (!$self->{LINKTYPE}) {
1776 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1778 : ($Config{usedl} ? 'dynamic' : 'static');
1781 $self->{NOOP} ||= '$(SHELL) -c true';
1782 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1784 $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
1785 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1786 $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
1787 $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
1789 # Some makes require a wrapper around macros passed in on the command
1791 $self->{MACROSTART} ||= '';
1792 $self->{MACROEND} ||= '';
1794 # Not everybody uses -f to indicate "use this Makefile instead"
1795 $self->{USEMAKEFILE} ||= '-f';
1797 $self->{SHELL} ||= $Config{sh} || '/bin/sh';
1799 $self->{ECHO} ||= 'echo';
1800 $self->{ECHO_N} ||= 'echo -n';
1801 $self->{RM_F} ||= "rm -f";
1802 $self->{RM_RF} ||= "rm -rf";
1803 $self->{TOUCH} ||= "touch";
1804 $self->{TEST_F} ||= "test -f";
1805 $self->{CP} ||= "cp";
1806 $self->{MV} ||= "mv";
1807 $self->{CHMOD} ||= "chmod";
1808 $self->{MKPATH} ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
1809 $self->{EQUALIZE_TIMESTAMP} ||=
1810 '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
1812 $self->{UNINST} ||= 0;
1813 $self->{VERBINST} ||= 0;
1814 $self->{MOD_INSTALL} ||=
1815 $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
1816 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
1818 $self->{DOC_INSTALL} ||=
1819 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
1820 $self->{UNINSTALL} ||=
1821 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
1822 $self->{WARN_IF_OLD_PACKLIST} ||=
1823 '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
1825 q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
1827 $self->{UMASK_NULL} ||= "umask 0";
1828 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1836 Unix has no need of special linker flags.
1842 $self->{PERL_ARCHIVE} ||= '';
1843 $self->{PERL_ARCHIVE_AFTER} ||= '';
1844 $self->{EXPORT_LIST} ||= '';
1861 # The user who requests an installation directory explicitly
1862 # should not have to tell us an architecture installation directory
1863 # as well. We look if a directory exists that is named after the
1864 # architecture. If not we take it as a sign that it should be the
1865 # same as the requested installation directory. Otherwise we take
1867 for my $libpair ({l=>"privlib", a=>"archlib"},
1868 {l=>"sitelib", a=>"sitearch"},
1869 {l=>"vendorlib", a=>"vendorarch"},
1872 my $lib = "install$libpair->{l}";
1874 my $Arch = uc "install$libpair->{a}";
1875 if( $self->{$Lib} && ! $self->{$Arch} ){
1876 my($ilib) = $Config{$lib};
1878 $self->prefixify($Arch,$ilib,$self->{$Lib});
1880 unless (-d $self->{$Arch}) {
1881 print STDOUT "Directory $self->{$Arch} not found\n"
1883 $self->{$Arch} = $self->{$Lib};
1885 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1895 Called by init_main. Sets up ABSPERL, PERL, FULLPERL and all the
1896 *PERLRUN* permutations.
1898 PERL is allowed to be miniperl
1899 FULLPERL must be a complete perl
1901 ABSPERL is PERL converted to an absolute path
1903 *PERLRUN contains everything necessary to run perl, find it's
1906 *PERLRUNINST is *PERLRUN + everything necessary to find the
1907 modules being built.
1915 foreach my $component ($self->{PERL_SRC}, $self->path(),
1918 push @defpath, $component if defined $component;
1921 # Build up a set of file names (not command names).
1922 my $thisperl = $self->canonpath($^X);
1923 $thisperl .= $Config{exe_ext} unless
1924 # VMS might have a file version # at the end
1925 $Is_VMS ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
1926 : $thisperl =~ m/$Config{exe_ext}$/i;
1928 # We need a relative path to perl when in the core.
1929 $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
1931 my @perls = ($thisperl);
1932 push @perls, map { "$_$Config{exe_ext}" }
1933 ('perl', 'perl5', "perl$Config{version}");
1935 # miniperl has priority over all but the cannonical perl when in the
1936 # core. Otherwise its a last resort.
1937 my $miniperl = "miniperl$Config{exe_ext}";
1938 if( $self->{PERL_CORE} ) {
1939 splice @perls, 1, 0, $miniperl;
1942 push @perls, $miniperl;
1946 $self->find_perl(5.0, \@perls, \@defpath, $Verbose );
1947 # don't check if perl is executable, maybe they have decided to
1948 # supply switches with perl
1950 # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
1951 my $perl_name = 'perl';
1952 $perl_name = 'ndbgperl' if $Is_VMS &&
1953 defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
1955 # XXX This logic is flawed. If "miniperl" is anywhere in the path
1956 # it will get confused. It should be fixed to work only on the filename.
1957 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1958 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
1959 unless $self->{FULLPERL};
1961 # Little hack to get around VMS's find_perl putting "MCR" in front
1963 $self->{ABSPERL} = $self->{PERL};
1964 my $has_mcr = $self->{ABSPERL} =~ s/^MCR\s*//;
1965 if( $self->file_name_is_absolute($self->{ABSPERL}) ) {
1966 $self->{ABSPERL} = '$(PERL)';
1969 $self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
1970 $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
1973 # Are we building the core?
1974 $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
1975 $self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
1977 # How do we run perl?
1978 foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
1979 my $run = $perl.'RUN';
1981 $self->{$run} = "\$($perl)";
1983 # Make sure perl can find itself before it's installed.
1984 $self->{$run} .= q{ "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)"}
1985 if $self->{UNINSTALLED_PERL} || $self->{PERL_CORE};
1987 $self->{$perl.'RUNINST'} =
1988 sprintf q{$(%sRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"}, $perl;
1997 =item platform_constants
1999 Add MM_Unix_VERSION.
2006 $self->{MM_Unix_VERSION} = $VERSION;
2007 $self->{PERL_MALLOC_DEF} = '-DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc '.
2008 '-Dfree=Perl_mfree -Drealloc=Perl_realloc '.
2009 '-Dcalloc=Perl_calloc';
2013 sub platform_constants {
2017 foreach my $macro (qw(MM_Unix_VERSION PERL_MALLOC_DEF))
2019 next unless defined $self->{$macro};
2020 $make_frag .= "$macro = $self->{$macro}\n";
2031 Called by init_main. Initializes PERL_*
2038 $self->{PERM_RW} = 644 unless defined $self->{PERM_RW};
2039 $self->{PERM_RWX} = 755 unless defined $self->{PERM_RWX};
2049 Sets up macros having to do with XS code. Currently just INST_STATIC,
2050 INST_DYNAMIC and INST_BOOT.
2057 if ($self->has_link_code()) {
2058 $self->{INST_STATIC} =
2059 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT)$(LIB_EXT)');
2060 $self->{INST_DYNAMIC} =
2061 $self->catfile('$(INST_ARCHAUTODIR)', '$(DLBASE).$(DLEXT)');
2062 $self->{INST_BOOT} =
2063 $self->catfile('$(INST_ARCHAUTODIR)', '$(BASEEXT).bs');
2065 $self->{INST_STATIC} = '';
2066 $self->{INST_DYNAMIC} = '';
2067 $self->{INST_BOOT} = '';
2073 Defines the install target.
2078 my($self, %attribs) = @_;
2082 install :: all pure_install doc_install
2085 install_perl :: all pure_perl_install doc_perl_install
2088 install_site :: all pure_site_install doc_site_install
2091 install_vendor :: all pure_vendor_install doc_vendor_install
2094 pure_install :: pure_$(INSTALLDIRS)_install
2097 doc_install :: doc_$(INSTALLDIRS)_install
2100 pure__install : pure_site_install
2101 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2103 doc__install : doc_site_install
2104 $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
2106 pure_perl_install ::
2107 $(NOECHO) $(MOD_INSTALL) \
2108 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2109 write }.$self->catfile('$(DESTINSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
2110 $(INST_LIB) $(DESTINSTALLPRIVLIB) \
2111 $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
2112 $(INST_BIN) $(DESTINSTALLBIN) \
2113 $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
2114 $(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
2115 $(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
2116 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2117 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
2120 pure_site_install ::
2121 $(NOECHO) $(MOD_INSTALL) \
2122 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2123 write }.$self->catfile('$(DESTINSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
2124 $(INST_LIB) $(DESTINSTALLSITELIB) \
2125 $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
2126 $(INST_BIN) $(DESTINSTALLSITEBIN) \
2127 $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
2128 $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
2129 $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
2130 $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
2131 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
2133 pure_vendor_install ::
2134 $(NOECHO) $(MOD_INSTALL) \
2135 read }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
2136 write }.$self->catfile('$(DESTINSTALLVENDORARCH)','auto','$(FULLEXT)','.packlist').q{ \
2137 $(INST_LIB) $(DESTINSTALLVENDORLIB) \
2138 $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
2139 $(INST_BIN) $(DESTINSTALLVENDORBIN) \
2140 $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
2141 $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
2142 $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
2145 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2146 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2147 -$(NOECHO) $(DOC_INSTALL) \
2148 "Module" "$(NAME)" \
2149 "installed into" "$(INSTALLPRIVLIB)" \
2150 LINKTYPE "$(LINKTYPE)" \
2151 VERSION "$(VERSION)" \
2152 EXE_FILES "$(EXE_FILES)" \
2153 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2156 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2157 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2158 -$(NOECHO) $(DOC_INSTALL) \
2159 "Module" "$(NAME)" \
2160 "installed into" "$(INSTALLSITELIB)" \
2161 LINKTYPE "$(LINKTYPE)" \
2162 VERSION "$(VERSION)" \
2163 EXE_FILES "$(EXE_FILES)" \
2164 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2166 doc_vendor_install ::
2167 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2168 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2169 -$(NOECHO) $(DOC_INSTALL) \
2170 "Module" "$(NAME)" \
2171 "installed into" "$(INSTALLVENDORLIB)" \
2172 LINKTYPE "$(LINKTYPE)" \
2173 VERSION "$(VERSION)" \
2174 EXE_FILES "$(EXE_FILES)" \
2175 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2180 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
2183 uninstall_from_perldirs ::
2184 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
2186 uninstall_from_sitedirs ::
2187 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2189 uninstall_from_vendordirs ::
2190 $(NOECHO) $(UNINSTALL) }.$self->catfile('$(VENDORARCHEXP)','auto','$(FULLEXT)','.packlist').q{
2196 =item installbin (o)
2198 Defines targets to make and to install EXE_FILES.
2205 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
2206 my @exefiles = @{$self->{EXE_FILES}};
2207 return "" unless @exefiles;
2209 @exefiles = map vmsify($_), @exefiles if $Is_VMS;
2212 for my $from (@exefiles) {
2213 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
2215 local($_) = $path; # for backwards compatibility
2216 my $to = $self->libscan($path);
2217 print "libscan($from) => '$to'\n" if ($Verbose >=2);
2219 $to = vmsify($to) if $Is_VMS;
2220 $fromto{$from} = $to;
2222 my @to = values %fromto;
2226 EXE_FILES = @exefiles
2234 # realclean can get rather large.
2235 push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
2239 # A target for each exe file.
2240 while (my($from,$to) = each %fromto) {
2241 last unless defined $from;
2243 push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
2244 %s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
2245 $(NOECHO) $(RM_F) %s
2248 -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
2260 Defines the linkext target which in turn defines the LINKTYPE.
2265 my($self, %attribs) = @_;
2266 # LINKTYPE => static or dynamic or ''
2267 my($linktype) = defined $attribs{LINKTYPE} ?
2268 $attribs{LINKTYPE} : '$(LINKTYPE)';
2270 linkext :: $linktype
2277 Takes as arguments a directory name and a regular expression. Returns
2278 all entries in the directory that match the regular expression.
2284 my($dir, $regex) = @_;
2286 my $dh = new DirHandle;
2287 $dh->open($dir || ".") or return ();
2290 @ls = grep(/$regex/, @ls) if $regex;
2296 Simple subroutine to insert the macros defined by the macro attribute
2302 my($self,%attribs) = @_;
2304 while (($key,$val) = each %attribs){
2305 last unless defined $key;
2306 push @m, "$key = $val\n";
2313 Called by staticmake. Defines how to write the Makefile to produce a
2316 By default the Makefile produced includes all the static extensions in
2317 the perl library. (Purified versions of library files, e.g.,
2318 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2323 my($self, %attribs) = @_;
2324 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2325 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2328 # --- MakeMaker makeaperl section ---
2329 MAP_TARGET = $target
2330 FULLPERL = $self->{FULLPERL}
2332 return join '', @m if $self->{PARENT};
2334 my($dir) = join ":", @{$self->{DIR}};
2336 unless ($self->{MAKEAPERL}) {
2338 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2339 $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
2341 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
2342 $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2343 $(NOECHO) $(PERLRUNINST) \
2344 Makefile.PL DIR=}, $dir, q{ \
2345 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2346 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2352 push @m, " \\\n\t\t$_";
2354 # push @m, map( " \\\n\t\t$_", @ARGV );
2362 my($cccmd, $linkcmd, $lperl);
2365 $cccmd = $self->const_cccmd($libperl);
2366 $cccmd =~ s/^CCCMD\s*=\s*//;
2367 $cccmd =~ s/\$\(INC\)/ "-I$self->{PERL_INC}" /;
2368 $cccmd .= " $Config{cccdlflags}"
2369 if ($Config{useshrplib} eq 'true');
2370 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2372 # The front matter of the linkcommand...
2373 $linkcmd = join ' ', "\$(CC)",
2374 grep($_, @Config{qw(ldflags ccdlflags)});
2375 $linkcmd =~ s/\s+/ /g;
2376 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2378 # Which *.a files could we make use of...
2381 File::Find::find(sub {
2382 return unless m/\Q$self->{LIB_EXT}\E$/;
2384 # Skip perl's libraries.
2385 return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
2387 # Skip purified versions of libraries
2388 # (e.g., DynaLoader_pure_p1_c0_032.a)
2389 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2391 if( exists $self->{INCLUDE_EXT} ){
2396 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2400 # Throw away anything not explicitly marked for inclusion.
2401 # DynaLoader is implied.
2402 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2408 return unless $found;
2410 elsif( exists $self->{EXCLUDE_EXT} ){
2414 ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
2418 # Throw away anything explicitly marked for exclusion
2419 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2420 return if( $xx eq $excl );
2424 # don't include the installed version of this extension. I
2425 # leave this line here, although it is not necessary anymore:
2426 # I patched minimod.PL instead, so that Miniperl.pm won't
2427 # enclude duplicates
2429 # Once the patch to minimod.PL is in the distribution, I can
2431 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
2433 $static{cwd() . "/" . $_}++;
2434 }, grep( -d $_, @{$searchdirs || []}) );
2436 # We trust that what has been handed in as argument, will be buildable
2437 $static = [] unless $static;
2438 @static{@{$static}} = (1) x @{$static};
2440 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2441 for (sort keys %static) {
2442 next unless /\Q$self->{LIB_EXT}\E\z/;
2443 $_ = dirname($_) . "/extralibs.ld";
2447 grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
2452 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2453 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2454 # extralibs.all are computed correctly
2456 MAP_LINKCMD = $linkcmd
2457 MAP_PERLINC = @{$perlinc || []}
2459 join(" \\\n\t", reverse sort keys %static), "
2461 MAP_PRELIBS = $Config{perllibs} $Config{cryptlib}
2464 if (defined $libperl) {
2465 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2467 unless ($libperl && -f $lperl) { # Ilya's code...
2468 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2469 $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
2470 $libperl ||= "libperl$self->{LIB_EXT}";
2471 $libperl = "$dir/$libperl";
2472 $lperl ||= "libperl$self->{LIB_EXT}";
2473 $lperl = "$dir/$lperl";
2475 if (! -f $libperl and ! -f $lperl) {
2476 # We did not find a static libperl. Maybe there is a shared one?
2478 $lperl = $libperl = "$dir/$Config{libperl}";
2479 # SUNOS ld does not take the full path to a shared library
2480 $libperl = '' if $Is_SunOS4;
2484 print STDOUT "Warning: $libperl not found
2485 If you're going to build a static perl binary, make sure perl is installed
2486 otherwise ignore this warning\n"
2487 unless (-f $lperl || defined($self->{PERL_SRC}));
2490 # SUNOS ld does not take the full path to a shared library
2491 my $llibperl = $libperl ? '$(MAP_LIBPERL)' : '-lperl';
2494 MAP_LIBPERL = $libperl
2495 LLIBPERL = $llibperl
2499 $(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
2500 $(NOECHO) $(RM_F) $@
2501 $(NOECHO) $(TOUCH) $@
2505 foreach $catfile (@$extra){
2506 push @m, "\tcat $catfile >> \$\@\n";
2510 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2511 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2512 \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
2513 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2514 \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
2515 \$(NOECHO) \$(ECHO) ' \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
2517 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2519 push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
2522 $tmp/perlmain.c: $makefilename}, q{
2523 $(NOECHO) $(ECHO) Writing $@
2524 $(NOECHO) $(PERL) $(MAP_PERLINC) "-MExtUtils::Miniperl" \\
2525 -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
2528 push @m, "\t", q{$(NOECHO) $(PERL) $(INSTALLSCRIPT)/fixpmain
2529 } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
2534 $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
2535 -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
2536 -$(NOECHO) $(DOC_INSTALL) \
2537 "Perl binary" "$(MAP_TARGET)" \
2538 MAP_STATIC "$(MAP_STATIC)" \
2539 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2540 MAP_LIBPERL "$(MAP_LIBPERL)" \
2541 >> }.$self->catfile('$(DESTINSTALLARCHLIB)','perllocal.pod').q{
2546 inst_perl: pure_inst_perl doc_inst_perl
2548 pure_inst_perl: $(MAP_TARGET)
2549 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
2554 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2562 Defines how to rewrite the Makefile.
2569 # We do not know what target was originally specified so we
2570 # must force a manual rerun to be sure. But as it should only
2571 # happen very rarely it is not a significant problem.
2573 $(OBJECT) : $(FIRST_MAKEFILE)
2575 ' if $self->{OBJECT};
2577 my $newer_than_target = $Is_VMS ? '$(MMS$SOURCE_LIST)' : '$?';
2578 my $mpl_args = join " ", map qq["$_"], @ARGV;
2580 $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
2581 # We take a very conservative approach here, but it's worth it.
2582 # We move Makefile to Makefile.old here to avoid gnu make looping.
2583 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
2584 $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
2585 $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
2586 -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
2587 -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
2588 - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
2589 $(PERLRUN) Makefile.PL %s
2590 $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
2591 $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
2602 Returns true, if the argument is likely to be a command.
2607 my($self,$file) = @_;
2608 return $file if -x $file && ! -d $file;
2613 =item needs_linking (o)
2615 Does this module need linking? Looks into subdirectory objects (see
2616 also has_link_code())
2623 $caller = (caller(0))[3];
2624 confess("needs_linking called too early") if
2625 $caller =~ /^ExtUtils::MakeMaker::/;
2626 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2627 if ($self->has_link_code or $self->{MAKEAPERL}){
2628 $self->{NEEDS_LINKING} = 1;
2631 foreach $child (keys %{$self->{CHILDREN}}) {
2632 if ($self->{CHILDREN}->{$child}->needs_linking) {
2633 $self->{NEEDS_LINKING} = 1;
2637 return $self->{NEEDS_LINKING} = 0;
2642 misnamed method (will have to be changed). The MM_Unix method just
2643 returns the argument without further processing.
2645 On VMS used to insure that colons marking targets are preceded by
2646 space - most Unix Makes don't need this, but it's necessary under VMS
2647 to distinguish the target delimiter from a colon appearing as part of
2653 my($self,$text) = @_;
2657 =item parse_abstract
2659 parse a file and return what you think is the ABSTRACT
2663 sub parse_abstract {
2664 my($self,$parsefile) = @_;
2668 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2670 my $package = $self->{DISTNAME};
2671 $package =~ s/-/::/g;
2673 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2676 next unless /^($package\s-\s)(.*)/;
2686 parse a file and return what you think is $VERSION in this file set to.
2687 It will return the string "undef" if it can't figure out what $VERSION
2688 is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
2689 are okay, but my $VERSION is not.
2694 my($self,$parsefile) = @_;
2699 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2702 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2703 next if $inpod || /^\s*#/;
2705 next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
2707 package ExtUtils::MakeMaker::_version;
2716 $result = eval($eval);
2717 warn "Could not eval '$eval' in $parsefile: $@" if $@;
2722 $result = "undef" unless defined $result;
2729 Defines the string that is passed to recursive make calls in
2739 my($sep) = $Is_VMS ? ',' : '';
2742 foreach $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
2743 PREFIX INSTALL_BASE)
2746 next unless defined $self->{$key};
2747 push @pasthru, "$key=\"\$($key)\"";
2750 foreach $key (qw(DEFINE INC)) {
2751 next unless defined $self->{$key};
2752 push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
2755 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
2761 Takes one argument, a file name, and returns the file name, if the
2762 argument is likely to be a perl script. On MM_Unix this is true for
2763 any ordinary, readable file.
2768 my($self,$file) = @_;
2769 return $file if -r $file && -f _;
2773 =item perldepend (o)
2775 Defines the dependency from all *.h files that come with the perl
2784 my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
2786 push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
2787 # Check for unpropogated config.sh changes. Should never happen.
2788 # We do NOT just update config.h because that is not sufficient.
2789 # An out of date config.h is not fatal but complains loudly!
2790 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2791 -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2793 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2794 $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2798 return join "", @m unless $self->needs_linking;
2802 $(PERL_INC)/EXTERN.h \
2803 $(PERL_INC)/INTERN.h \
2804 $(PERL_INC)/XSUB.h \
2806 $(PERL_INC)/cc_runtime.h \
2807 $(PERL_INC)/config.h \
2810 $(PERL_INC)/dosish.h \
2811 $(PERL_INC)/embed.h \
2812 $(PERL_INC)/embedvar.h \
2813 $(PERL_INC)/fakethr.h \
2814 $(PERL_INC)/form.h \
2816 $(PERL_INC)/handy.h \
2818 $(PERL_INC)/intrpvar.h \
2819 $(PERL_INC)/iperlsys.h \
2820 $(PERL_INC)/keywords.h \
2822 $(PERL_INC)/nostdio.h \
2824 $(PERL_INC)/opcode.h \
2825 $(PERL_INC)/patchlevel.h \
2826 $(PERL_INC)/perl.h \
2827 $(PERL_INC)/perlio.h \
2828 $(PERL_INC)/perlsdio.h \
2829 $(PERL_INC)/perlsfio.h \
2830 $(PERL_INC)/perlvars.h \
2831 $(PERL_INC)/perly.h \
2833 $(PERL_INC)/pp_proto.h \
2834 $(PERL_INC)/proto.h \
2835 $(PERL_INC)/regcomp.h \
2836 $(PERL_INC)/regexp.h \
2837 $(PERL_INC)/regnodes.h \
2838 $(PERL_INC)/scope.h \
2840 $(PERL_INC)/thrdvar.h \
2841 $(PERL_INC)/thread.h \
2842 $(PERL_INC)/unixish.h \
2845 $(OBJECT) : $(PERL_HDRS)
2846 } if $self->{OBJECT};
2848 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2856 Returns the attribute C<PERM_RW> or the string C<644>.
2857 Used as the string that is passed
2858 to the C<chmod> command to set the permissions for read/writeable files.
2859 MakeMaker chooses C<644> because it has turned out in the past that
2860 relying on the umask provokes hard-to-track bug reports.
2861 When the return value is used by the perl function C<chmod>, it is
2862 interpreted as an octal value.
2867 return shift->{PERM_RW};
2872 Returns the attribute C<PERM_RWX> or the string C<755>,
2873 i.e. the string that is passed
2874 to the C<chmod> command to set the permissions for executable files.
2880 return shift->{PERM_RWX};
2885 Defines target that copies all files in the hash PM to their
2886 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
2892 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2894 pm_to_blib : $(TO_INST_PM)
2897 my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
2898 pm_to_blib({\@ARGV}, '$autodir', '\$(PM_FILTER)')
2901 my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
2903 $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
2904 $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
2909 =item post_constants (o)
2911 Returns an empty string per default. Dedicated to overrides from
2912 within Makefile.PL after all constants have been defined.
2920 =item post_initialize (o)
2922 Returns an empty string per default. Used in Makefile.PLs to add some
2923 chunk of text to the Makefile after the object is initialized.
2927 sub post_initialize {
2933 Returns an empty string. Can be used in Makefile.PLs to write some
2934 text to the Makefile at the end.
2944 Defines target that creates a PPD (Perl Package Description) file
2945 for a binary distribution.
2952 my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
2954 my $abstract = $self->{ABSTRACT} || '';
2955 $abstract =~ s/\n/\\n/sg;
2956 $abstract =~ s/</</g;
2957 $abstract =~ s/>/>/g;
2959 my $author = $self->{AUTHOR} || '';
2960 $author =~ s/</</g;
2961 $author =~ s/>/>/g;
2963 my $ppd_xml = sprintf <<'PPD_HTML', $pack_ver, $abstract, $author;
2964 <SOFTPKG NAME="$(DISTNAME)" VERSION="%s">
2965 <TITLE>$(DISTNAME)</TITLE>
2966 <ABSTRACT>%s</ABSTRACT>
2970 $ppd_xml .= " <IMPLEMENTATION>\n";
2971 foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
2972 my $pre_req = $prereq;
2973 $pre_req =~ s/::/-/g;
2974 my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
2976 $ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
2977 <DEPENDENCY NAME="%s" VERSION="%s" />
2982 $ppd_xml .= sprintf <<'PPD_OUT', $Config{archname};
2983 <OS NAME="$(OSNAME)" />
2984 <ARCHITECTURE NAME="%s" />
2987 if ($self->{PPM_INSTALL_SCRIPT}) {
2988 if ($self->{PPM_INSTALL_EXEC}) {
2989 $ppd_xml .= sprintf qq{ <INSTALL EXEC="%s">%s</INSTALL>\n},
2990 $self->{PPM_INSTALL_EXEC}, $self->{PPM_INSTALL_SCRIPT};
2993 $ppd_xml .= sprintf qq{ <INSTALL>%s</INSTALL>\n},
2994 $self->{PPM_INSTALL_SCRIPT};
2998 my ($bin_location) = $self->{BINARY_LOCATION} || '';
2999 $bin_location =~ s/\\/\\\\/g;
3001 $ppd_xml .= sprintf <<'PPD_XML', $bin_location;
3002 <CODEBASE HREF="%s" />
3007 my @ppd_cmds = $self->echo($ppd_xml, '$(DISTNAME).ppd');
3009 return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
3010 # Creates a PPD (Perl Package Description) for a binary distribution.
3019 $MM->prefixify($var, $prefix, $new_prefix, $default);
3021 Using either $MM->{uc $var} || $Config{lc $var}, it will attempt to
3022 replace it's $prefix with a $new_prefix.
3024 Should the $prefix fail to match I<AND> a PREFIX was given as an
3025 argument to WriteMakefile() it will set it to the $new_prefix +
3026 $default. This is for systems whose file layouts don't neatly fit into
3027 our ideas of prefixes.
3029 This is for heuristics which attempt to create directory structures
3030 that mirror those of the installed perl.
3034 $MM->prefixify('installman1dir', '/usr', '/home/foo', 'man/man1');
3036 this will attempt to remove '/usr' from the front of the
3037 $MM->{INSTALLMAN1DIR} path (initializing it to $Config{installman1dir}
3038 if necessary) and replace it with '/home/foo'. If this fails it will
3039 simply use '/home/foo/man/man1'.
3044 my($self,$var,$sprefix,$rprefix,$default) = @_;
3046 my $path = $self->{uc $var} ||
3047 $Config_Override{lc $var} || $Config{lc $var} || '';
3049 $rprefix .= '/' if $sprefix =~ m|/$|;
3051 print STDERR " prefixify $var => $path\n" if $Verbose >= 2;
3052 print STDERR " from $sprefix to $rprefix\n" if $Verbose >= 2;
3054 if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) &&
3055 $path !~ s{^\Q$sprefix\E\b}{$rprefix}s )
3058 print STDERR " cannot prefix, using default.\n" if $Verbose >= 2;
3059 print STDERR " no default!\n" if !$default && $Verbose >= 2;
3061 $path = $self->catdir($rprefix, $default) if $default;
3064 print " now $path\n" if $Verbose >= 2;
3065 return $self->{uc $var} = $path;
3071 Defines targets to run *.PL files.
3077 my $pl_files = $self->{PL_FILES};
3079 return "" unless $pl_files;
3082 foreach my $plfile (sort keys %$pl_files) {
3083 my $list = ref($pl_files->{$plfile})
3084 ? $pl_files->{$plfile}
3085 : [$pl_files->{$plfile}];
3087 foreach my $target (@$list) {
3089 $plfile = vmsify($self->eliminate_macros($plfile));
3090 $target = vmsify($self->eliminate_macros($target));
3093 # Normally a .PL file runs AFTER pm_to_blib so it can have
3094 # blib in its @INC and load the just built modules. BUT if
3095 # the generated module is something in $(TO_INST_PM) which
3096 # pm_to_blib depends on then it can't depend on pm_to_blib
3097 # else we have a dependency loop.
3100 if( defined $self->{PM}{$target} ) {
3102 $perlrun = 'PERLRUN';
3105 $pm_dep = 'pm_to_blib';
3106 $perlrun = 'PERLRUNINST';
3114 $target :: $plfile $pm_dep
3115 \$($perlrun) $plfile $target
3126 Backslashes parentheses C<()> in command line arguments.
3127 Doesn't handle recursive Makefile C<$(...)> constructs,
3128 but handles simple ones.
3134 $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g; # protect $(...)
3135 $arg =~ s{(?<!\\)([()])}{\\$1}g; # quote unprotected
3136 $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g; # unprotect $(...)
3140 =item replace_manpage_separator
3142 my $man_name = $MM->replace_manpage_separator($file_path);
3144 Takes the name of a package, which may be a nested package, in the
3145 form 'Foo/Bar.pm' and replaces the slash with C<::> or something else
3146 safe for a man page file name. Returns the replacement.
3150 sub replace_manpage_separator {
3151 my($self,$man) = @_;
3163 my($self, $dir, @cmds) = @_;
3165 # No leading tab and no trailing newline makes for easier embedding
3166 my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
3176 my($self, $cmd, $switches) = @_;
3177 $switches = [] unless defined $switches;
3179 # Strip leading and trailing newlines
3183 my @cmds = split /\n/, $cmd;
3184 $cmd = join " \n\t -e ", map $self->quote_literal($_), @cmds;
3185 $cmd = $self->escape_newlines($cmd);
3187 $switches = join ' ', @$switches;
3189 return qq{\$(ABSPERLRUN) $switches -e $cmd --};
3198 my($self, $text) = @_;
3200 # I think all we have to quote is single quotes and I think
3201 # this is a safe way to do it.
3202 $text =~ s{'}{'\\''}g;
3208 =item escape_newlines
3212 sub escape_newlines {
3213 my($self, $text) = @_;
3215 $text =~ s{\n}{\\\n}g;
3223 Using POSIX::ARG_MAX. Otherwise falling back to 4096.
3230 if (!defined $self->{_MAX_EXEC_LEN}) {
3231 if (my $arg_max = eval { require POSIX; &POSIX::ARG_MAX }) {
3232 $self->{_MAX_EXEC_LEN} = $arg_max;
3234 else { # POSIX minimum exec size
3235 $self->{_MAX_EXEC_LEN} = 4096;
3239 return $self->{_MAX_EXEC_LEN};
3245 Defines the static target.
3250 # --- Static Loading Sections ---
3254 ## $(INST_PM) has been moved to the all: target.
3255 ## It remains here for awhile to allow for old usage: "make static"
3256 static :: $(FIRST_MAKEFILE) $(INST_STATIC)
3261 =item static_lib (o)
3263 Defines how to produce the *.a (or equivalent) files.
3269 return '' unless $self->has_link_code;
3274 $(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
3278 # If this extension has its own library (eg SDBM_File)
3279 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
3280 push(@m, <<'MAKE_FRAG') if $self->{MYEXTLIB};
3281 $(CP) $(MYEXTLIB) $@
3285 if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
3286 # Prefer the absolute pathed ar if available so that PATH
3287 # doesn't confuse us. Perl itself is built with the full_ar.
3292 push @m, sprintf <<'MAKE_FRAG', $ar;
3293 $(%s) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
3294 $(CHMOD) $(PERM_RWX) $@
3295 $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
3298 # Old mechanism - still available:
3299 push @m, <<'MAKE_FRAG' if $self->{PERL_SRC} && $self->{EXTRALIBS};
3300 $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
3306 =item staticmake (o)
3313 my($self, %attribs) = @_;
3316 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
3318 # And as it's not yet built, we add the current extension
3319 # but only if it has some C code (or XS code, which implies C code)
3320 if (@{$self->{C}}) {
3321 @static = $self->catfile($self->{INST_ARCHLIB},
3324 "$self->{BASEEXT}$self->{LIB_EXT}"
3328 # Either we determine now, which libraries we will produce in the
3329 # subdirectories or we do it at runtime of the make.
3331 # We could ask all subdir objects, but I cannot imagine, why it
3332 # would be necessary.
3334 # Instead we determine all libraries for the new perl at
3336 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
3338 $self->makeaperl(MAKE => $self->{MAKEFILE},
3339 DIRS => \@searchdirs,
3342 TARGET => $self->{MAP_TARGET},
3344 LIBPERL => $self->{LIBPERL_A}
3350 Helper subroutine for subdirs
3355 my($self, $subdir) = @_;
3357 my $subdir_cmd = $self->cd($subdir,
3358 '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
3360 return sprintf <<'EOT', $subdir_cmd;
3370 Defines targets to process subdirectories.
3375 # --- Sub-directory Sections ---
3378 # This method provides a mechanism to automatically deal with
3379 # subdirectories containing further Makefile.PL scripts.
3380 # It calls the subdir_x() method for each subdirectory.
3381 foreach $dir (@{$self->{DIR}}){
3382 push(@m, $self->subdir_x($dir));
3383 #### print "Including $dir subdirectory\n";
3387 # The default clean, realclean and test targets in this Makefile
3388 # have automatically been given entries for each subdir.
3392 push(@m, "\n# none")
3399 Defines the test targets.
3404 # --- Test and Installation Sections ---
3406 my($self, %attribs) = @_;
3407 my $tests = $attribs{TESTS} || '';
3408 if (!$tests && -d 't') {
3409 $tests = $self->find_tests;
3411 # note: 'test.pl' name is also hardcoded in init_dirscan()
3415 TEST_TYPE=test_\$(LINKTYPE)
3420 testdb :: testdb_\$(LINKTYPE)
3422 test :: \$(TEST_TYPE)
3425 foreach my $dir (@{ $self->{DIR} }) {
3426 my $test = $self->oneliner(sprintf <<'CODE', $dir);
3428 system '$(MAKE) test $(PASTHRU)'
3429 if -f '$(FIRST_MAKEFILE)';
3432 push(@m, "\t\$(NOECHO) $test\n");
3435 push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
3436 unless $tests or -f "test.pl" or @{$self->{DIR}};
3439 push(@m, "test_dynamic :: pure_all\n");
3440 push(@m, $self->test_via_harness('$(FULLPERLRUN)', '$(TEST_FILES)'))
3442 push(@m, $self->test_via_script('$(FULLPERLRUN)', '$(TEST_FILE)'))
3446 push(@m, "testdb_dynamic :: pure_all\n");
3447 push(@m, $self->test_via_script('$(FULLPERLRUN) $(TESTDB_SW)',
3451 # Occasionally we may face this degenerate target:
3452 push @m, "test_ : test_dynamic\n\n";
3454 if ($self->needs_linking()) {
3455 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
3456 push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
3457 push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
3459 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
3460 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
3463 push @m, "test_static :: test_dynamic\n";
3464 push @m, "testdb_static :: testdb_dynamic\n";
3469 =item test_via_harness (override)
3471 For some reason which I forget, Unix machines like to have
3472 PERL_DL_NONLAZY set for tests.
3476 sub test_via_harness {
3477 my($self, $perl, $tests) = @_;
3478 return $self->SUPER::test_via_harness("PERL_DL_NONLAZY=1 $perl", $tests);
3481 =item test_via_script (override)
3483 Again, the PERL_DL_NONLAZY thing.
3487 sub test_via_script {
3488 my($self, $perl, $script) = @_;
3489 return $self->SUPER::test_via_script("PERL_DL_NONLAZY=1 $perl", $script);
3493 =item tools_other (o)
3495 my $make_frag = $MM->tools_other;
3497 Returns a make fragment containing definitions for the macros init_others()
3506 # We set PM_FILTER as late as possible so it can see all the earlier
3507 # on macro-order sensitive makes such as nmake.
3508 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
3509 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
3512 MOD_INSTALL DOC_INSTALL UNINSTALL
3513 WARN_IF_OLD_PACKLIST
3520 next unless defined $self->{$tool};
3521 push @m, "$tool = $self->{$tool}\n";
3527 =item tool_xsubpp (o)
3529 Determines typemaps, xsubpp version, prototype behaviour.
3535 return "" unless $self->needs_linking;
3538 my @xsubpp_dirs = @INC;
3540 # Make sure we pick up the new xsubpp if we're building perl.
3541 unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
3543 foreach my $dir (@xsubpp_dirs) {
3544 $xsdir = $self->catdir($dir, 'ExtUtils');
3545 if( -r $self->catfile($xsdir, "xsubpp") ) {
3550 my $tmdir = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
3551 my(@tmdeps) = $self->catfile($tmdir,'typemap');
3552 if( $self->{TYPEMAPS} ){
3554 foreach $typemap (@{$self->{TYPEMAPS}}){
3555 if( ! -f $typemap ){
3556 warn "Typemap $typemap not found.\n";
3559 push(@tmdeps, $typemap);
3563 push(@tmdeps, "typemap") if -f "typemap";
3564 my(@tmargs) = map("-typemap $_", @tmdeps);
3565 if( exists $self->{XSOPT} ){
3566 unshift( @tmargs, $self->{XSOPT} );
3570 $Config{'ldflags'} &&
3571 $Config{'ldflags'} =~ m!/Debug!i &&
3572 (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
3575 unshift(@tmargs,'-nolinenumbers');
3579 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3583 XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp
3584 XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
3585 XSPROTOARG = $self->{XSPROTOARG}
3586 XSUBPPDEPS = @tmdeps \$(XSUBPP)
3587 XSUBPPARGS = @tmargs
3595 Build man pages, too
3602 return <<'MAKE_EXT';
3603 all :: pure_all manifypods
3608 =item top_targets (o)
3610 Defines the targets all, subdirs, config, and O_FILES
3615 # --- Target Sections ---
3620 push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
3623 pure_all :: config pm_to_blib subdirs linkext
3626 subdirs :: $(MYEXTLIB)
3629 config :: $(FIRST_MAKEFILE) blibdirs
3634 $(O_FILES): $(H_FILES)
3635 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3639 perldoc ExtUtils::MakeMaker
3647 Obsolete, deprecated method. Not used since Version 5.21.
3652 # --- perllocal.pod section ---
3653 my($self,$what,$name,@attribs)=@_;
3654 my $time = localtime;
3655 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3656 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3657 print "\n\n=back\n\n";
3662 Defines the suffix rules to compile XS files to C.
3668 return '' unless $self->needs_linking();
3671 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3677 Defines the suffix rules to compile XS files to C++.
3683 return '' unless $self->needs_linking();
3686 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
3692 Defines suffix rules to go from XS to object files directly. This is
3693 only intended for broken make implementations.
3697 sub xs_o { # many makes are too dumb to use xs_c then c_o
3699 return '' unless $self->needs_linking();
3702 $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
3703 $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
3714 L<ExtUtils::MakeMaker>