1 package ExtUtils::MM_Unix;
5 use File::Basename qw(basename dirname fileparse);
8 use vars qw($VERSION $Is_Mac $Is_OS2 $Is_VMS $Is_Win32
9 $Verbose %pm %static $Xsubpp_Version);
11 $VERSION = substr q$Revision: 1.114 $, 10;
12 # $Id: MM_Unix.pm,v 1.113 1997/02/11 21:54:09 k Exp $
14 Exporter::import('ExtUtils::MakeMaker',
15 qw( $Verbose &neatvalue));
17 $Is_OS2 = $^O eq 'os2';
18 $Is_Mac = $^O eq 'MacOS';
19 $Is_Win32 = $^O eq 'MSWin32';
21 if ($Is_VMS = $^O eq 'VMS') {
22 require VMS::Filespec;
23 import VMS::Filespec qw( &vmsify );
28 ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
32 C<require ExtUtils::MM_Unix;>
36 The methods provided by this package are designed to be used in
37 conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
38 Makefile, it creates one or more objects that inherit their methods
39 from a package C<MM>. MM itself doesn't provide any methods, but it
40 ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
41 specific packages take the responsibility for all the methods provided
42 by MM_Unix. We are trying to reduce the number of the necessary
43 overrides by defining rather primitive operations within
46 If you are going to write a platform specific MM package, please try
47 to limit the necessary overrides to primitive methods, and if it is not
48 possible to do so, let's work out how to achieve that gain.
50 If you are overriding any of these methods in your Makefile.PL (in the
51 MY class), please report that to the makemaker mailing list. We are
52 trying to minimize the necessary method overrides and switch to data
53 driven Makefile.PLs wherever possible. In the long run less methods
54 will be overridable via the MY class.
58 The following description of methods is still under
59 development. Please refer to the code for not suitably documented
60 sections and complain loudly to the makemaker mailing list.
62 Not all of the methods below are overridable in a
63 Makefile.PL. Overridable methods are marked as (o). All methods are
64 overridable by a platform specific MM_*.pm file (See
65 L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>).
67 =head2 Preloaded methods
73 No physical check on the filesystem, but a logical cleanup of a
74 path. On UNIX eliminated successive slashes and successive "/.".
80 $path =~ s|/+|/|g ; # xx////xx -> xx/xx
81 $path =~ s|(/\.)+/|/|g ; # xx/././xx -> xx/xx
82 $path =~ s|^(\./)+|| unless $path eq "./"; # ./xx -> xx
83 $path =~ s|/$|| unless $path eq "/"; # xx/ -> xx
89 Concatenate two or more directory names to form a complete path ending
90 with a directory. But remove the trailing slash from the resulting
91 string, because it doesn't look good, isn't necessary and confuses
92 OS2. Of course, if this is the root directory, don't cut off the
103 # append a slash to each argument unless it has one there
104 $_ .= "/" if $_ eq '' or substr($_,-1) ne "/";
106 my $result = join('', @args);
107 # remove a trailing slash unless we are root
108 substr($result,-1) = ""
109 if length($result) > 1 && substr($result,-1) eq "/";
115 Concatenate one or more directory names and a filename to form a
116 complete path ending with a filename
123 return $file unless @_;
124 my $dir = $self->catdir(@_);
126 $_ .= "/" unless substr($_,length($_)-1,1) eq "/";
133 Returns a string representing of the current directory. "." on UNIX.
143 Returns a string representing of the root directory. "/" on UNIX.
153 Returns a string representing of the parent directory. ".." on UNIX.
161 sub ExtUtils::MM_Unix::c_o ;
162 sub ExtUtils::MM_Unix::clean ;
163 sub ExtUtils::MM_Unix::const_cccmd ;
164 sub ExtUtils::MM_Unix::const_config ;
165 sub ExtUtils::MM_Unix::const_loadlibs ;
166 sub ExtUtils::MM_Unix::constants ;
167 sub ExtUtils::MM_Unix::depend ;
168 sub ExtUtils::MM_Unix::dir_target ;
169 sub ExtUtils::MM_Unix::dist ;
170 sub ExtUtils::MM_Unix::dist_basics ;
171 sub ExtUtils::MM_Unix::dist_ci ;
172 sub ExtUtils::MM_Unix::dist_core ;
173 sub ExtUtils::MM_Unix::dist_dir ;
174 sub ExtUtils::MM_Unix::dist_test ;
175 sub ExtUtils::MM_Unix::dlsyms ;
176 sub ExtUtils::MM_Unix::dynamic ;
177 sub ExtUtils::MM_Unix::dynamic_bs ;
178 sub ExtUtils::MM_Unix::dynamic_lib ;
179 sub ExtUtils::MM_Unix::exescan ;
180 sub ExtUtils::MM_Unix::export_list ;
181 sub ExtUtils::MM_Unix::extliblist ;
182 sub ExtUtils::MM_Unix::file_name_is_absolute ;
183 sub ExtUtils::MM_Unix::find_perl ;
184 sub ExtUtils::MM_Unix::force ;
185 sub ExtUtils::MM_Unix::guess_name ;
186 sub ExtUtils::MM_Unix::has_link_code ;
187 sub ExtUtils::MM_Unix::init_dirscan ;
188 sub ExtUtils::MM_Unix::init_main ;
189 sub ExtUtils::MM_Unix::init_others ;
190 sub ExtUtils::MM_Unix::install ;
191 sub ExtUtils::MM_Unix::installbin ;
192 sub ExtUtils::MM_Unix::libscan ;
193 sub ExtUtils::MM_Unix::linkext ;
194 sub ExtUtils::MM_Unix::lsdir ;
195 sub ExtUtils::MM_Unix::macro ;
196 sub ExtUtils::MM_Unix::makeaperl ;
197 sub ExtUtils::MM_Unix::makefile ;
198 sub ExtUtils::MM_Unix::manifypods ;
199 sub ExtUtils::MM_Unix::maybe_command ;
200 sub ExtUtils::MM_Unix::maybe_command_in_dirs ;
201 sub ExtUtils::MM_Unix::needs_linking ;
202 sub ExtUtils::MM_Unix::nicetext ;
203 sub ExtUtils::MM_Unix::parse_version ;
204 sub ExtUtils::MM_Unix::pasthru ;
205 sub ExtUtils::MM_Unix::path ;
206 sub ExtUtils::MM_Unix::perl_archive;
207 sub ExtUtils::MM_Unix::perl_script ;
208 sub ExtUtils::MM_Unix::perldepend ;
209 sub ExtUtils::MM_Unix::pm_to_blib ;
210 sub ExtUtils::MM_Unix::post_constants ;
211 sub ExtUtils::MM_Unix::post_initialize ;
212 sub ExtUtils::MM_Unix::postamble ;
213 sub ExtUtils::MM_Unix::prefixify ;
214 sub ExtUtils::MM_Unix::processPL ;
215 sub ExtUtils::MM_Unix::realclean ;
216 sub ExtUtils::MM_Unix::replace_manpage_separator ;
217 sub ExtUtils::MM_Unix::static ;
218 sub ExtUtils::MM_Unix::static_lib ;
219 sub ExtUtils::MM_Unix::staticmake ;
220 sub ExtUtils::MM_Unix::subdir_x ;
221 sub ExtUtils::MM_Unix::subdirs ;
222 sub ExtUtils::MM_Unix::test ;
223 sub ExtUtils::MM_Unix::test_via_harness ;
224 sub ExtUtils::MM_Unix::test_via_script ;
225 sub ExtUtils::MM_Unix::tool_autosplit ;
226 sub ExtUtils::MM_Unix::tool_xsubpp ;
227 sub ExtUtils::MM_Unix::tools_other ;
228 sub ExtUtils::MM_Unix::top_targets ;
229 sub ExtUtils::MM_Unix::writedoc ;
230 sub ExtUtils::MM_Unix::xs_c ;
231 sub ExtUtils::MM_Unix::xs_o ;
232 sub ExtUtils::MM_Unix::xsubpp_version ;
234 package ExtUtils::MM_Unix;
244 =head2 SelfLoaded methods
250 Defines the suffix rules to compile different flavors of C files to
256 # --- Translation Sections ---
259 return '' unless $self->needs_linking();
263 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
267 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
268 ' if $^O ne 'os2' and $^O ne 'MSWin32'; # Case-specific
271 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cpp
274 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cxx
277 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cc
284 Does very much the same as the cflags script in the perl
285 distribution. It doesn't return the whole compiler command line, but
286 initializes all of its parts. The const_cccmd method then actually
287 returns the definition of the CCCMD macro which uses these parts.
294 my($self,$libperl)=@_;
295 return $self->{CFLAGS} if $self->{CFLAGS};
296 return '' unless $self->needs_linking();
298 my($prog, $uc, $perltype, %cflags);
299 $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
300 $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
302 @cflags{qw(cc ccflags optimize large split shellflags)}
303 = @Config{qw(cc ccflags optimize large split shellflags)};
306 $cflags{shellflags} ||= '';
311 DE => '-DDEBUGGING -DEMBED',
312 M => '-DEMBED -DMULTIPLICITY',
313 DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
316 if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
319 $uc = ""; # avoid warning
321 $perltype = $map{$uc} ? $map{$uc} : "";
329 ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
330 if ($prog = $Config::Config{$name}) {
331 # Expand hints for this extension via the shell
332 print STDOUT "Processing $name hint:\n" if $Verbose;
333 my(@o)=`cc=\"$cflags{cc}\"
334 ccflags=\"$cflags{ccflags}\"
335 optimize=\"$cflags{optimize}\"
336 perltype=\"$cflags{perltype}\"
337 optdebug=\"$cflags{optdebug}\"
338 large=\"$cflags{large}\"
339 split=\"$cflags{'split'}\"
342 echo ccflags=\$ccflags
343 echo optimize=\$optimize
344 echo perltype=\$perltype
345 echo optdebug=\$optdebug
352 if ($line =~ /(.*?)=\s*(.*)\s*$/){
354 print STDOUT " $1 = $2\n" if $Verbose;
356 print STDOUT "Unrecognised result from hint: '$line'\n";
362 $cflags{optimize} = $optdebug;
365 for (qw(ccflags optimize perltype large split)) {
366 $cflags{$_} =~ s/^\s+//;
367 $cflags{$_} =~ s/\s+/ /g;
368 $cflags{$_} =~ s/\s+$//;
369 $self->{uc $_} ||= $cflags{$_}
372 return $self->{CFLAGS} = qq{
373 CCFLAGS = $self->{CCFLAGS}
374 OPTIMIZE = $self->{OPTIMIZE}
375 PERLTYPE = $self->{PERLTYPE}
376 LARGE = $self->{LARGE}
377 SPLIT = $self->{SPLIT}
384 Defines the clean target.
389 # --- Cleanup and Distribution Sections ---
391 my($self, %attribs) = @_;
394 # Delete temporary files but do not touch installed files. We don\'t delete
395 # the Makefile here so a later make realclean still has a makefile to use.
399 # clean subdirectories first
400 for $dir (@{$self->{DIR}}) {
401 push @m, "\t-cd $dir && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) clean\n";
404 my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
405 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
406 push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all
407 perlmain.c mon.out core so_locations pm_to_blib
408 *~ */*~ */*/*~ *$(OBJ_EXT) *$(LIB_EXT) perl.exe
409 $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def
412 push @m, "\t-$self->{RM_RF} @otherfiles\n";
413 # See realclean and ext/utils/make_ext for usage of Makefile.old
415 "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old \$(DEV_NULL)\n");
417 "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
421 =item const_cccmd (o)
423 Returns the full compiler call for C programs and stores the
424 definition in CONST_CCCMD.
429 my($self,$libperl)=@_;
430 return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
431 return '' unless $self->needs_linking();
432 return $self->{CONST_CCCMD} =
433 q{CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \\
434 $(PERLTYPE) $(LARGE) $(SPLIT) $(DEFINE_VERSION) \\
435 $(XS_DEFINE_VERSION)};
438 =item const_config (o)
440 Defines a couple of constants in the Makefile that are imported from
446 # --- Constants Sections ---
450 push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
451 push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
453 foreach $m (@{$self->{CONFIG}}){
454 # SITE*EXP macros are defined in &constants; avoid duplicates here
455 next if $once_only{$m} or $m eq 'sitelibexp' or $m eq 'sitearchexp';
456 push @m, "\U$m\E = ".$self->{uc $m}."\n";
462 =item const_loadlibs (o)
464 Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
465 L<ExtUtils::Liblist> for details.
471 return "" unless $self->needs_linking;
474 # $self->{NAME} might depend on some other libraries:
475 # See ExtUtils::Liblist for details
480 EXTRALIBS LDLOADLIBS BSLOADLIBS LD_RUN_PATH
482 next unless defined $self->{$tmp};
483 push @m, "$tmp = $self->{$tmp}\n";
490 Initializes lots of constants and .SUFFIXES and .PHONY
500 AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
501 VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB
502 INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
503 INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
504 INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
505 PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
506 FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
507 PERL_INC PERL FULLPERL
510 next unless defined $self->{$tmp};
511 push @m, "$tmp = $self->{$tmp}\n";
515 VERSION_MACRO = VERSION
516 DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
517 XS_VERSION_MACRO = XS_VERSION
518 XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
522 MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
523 MM_VERSION = $ExtUtils::MakeMaker::VERSION
527 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
528 # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
529 # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!!
530 # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
531 # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
535 FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
538 next unless defined $self->{$tmp};
539 push @m, "$tmp = $self->{$tmp}\n";
543 # Handy lists of source code files:
544 XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
545 C_FILES = ".join(" \\\n\t", @{$self->{C}})."
546 O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
547 H_FILES = ".join(" \\\n\t", @{$self->{H}})."
548 MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
549 MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
553 INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
555 next unless defined $self->{$tmp};
556 push @m, "$tmp = $self->{$tmp}\n";
560 .NO_CONFIG_REC: Makefile
561 } if $ENV{CLEARCASE_ROOT};
563 # why not q{} ? -- emacs
565 # work around a famous dec-osf make(1) feature(?):
568 .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
570 # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
571 # some make implementations will delete the Makefile when we rebuild it. Because
572 # we call false(1) when we rebuild it. So make(1) is not completely wrong when it
573 # does so. Our milage may vary.
574 # .PRECIOUS: Makefile # seems to be not necessary anymore
576 .PHONY: all config static dynamic test linkext manifest
578 # Where is the Config information that we are using/depend on
579 CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h
582 my @parentdir = split(/::/, $self->{PARENT_NAME});
584 # Where to put things:
585 INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{
586 INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{
588 INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
589 INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
592 if ($self->has_link_code()) {
594 INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
595 INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
596 INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
606 $tmp = $self->export_list;
610 $tmp = $self->perl_archive;
616 #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
618 #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
622 TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
624 PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
632 Same as macro for the depend attribute.
637 my($self,%attribs) = @_;
639 while (($key,$val) = each %attribs){
640 last unless defined $key;
641 push @m, "$key: $val\n";
648 Takes an array of directories that need to exist and returns a
649 Makefile entry for a .exists file in these directories. Returns
650 nothing, if the entry has already been processed. We're helpless
651 though, if the same directory comes as $(FOO) _and_ as "bar". Both of
652 them get an entry, that's why we use "::".
657 # --- Make-Directories section (internal method) ---
658 # dir_target(@array) returns a Makefile entry for the file .exists in each
659 # named directory. Returns nothing, if the entry has already been processed.
660 # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
661 # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
662 # prerequisite, because there has to be one, something that doesn't change
665 my($self,@dirs) = @_;
666 my(@m,$dir,$targdir);
667 foreach $dir (@dirs) {
668 my($src) = $self->catfile($self->{PERL_INC},'perl.h');
669 my($targ) = $self->catfile($dir,'.exists');
670 # catfile may have adapted syntax of $dir to target OS, so...
671 if ($Is_VMS) { # Just remove file name; dirspec is often in macro
672 ($targdir = $targ) =~ s:/?\.exists$::;
674 else { # while elsewhere we expect to see the dir separator in $targ
675 $targdir = dirname($targ);
677 next if $self->{DIR_TARGET}{$self}{$targdir}++;
680 $self->{NOECHO}\$(MKPATH) $targdir
681 $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) $src $targ
684 -$self->{NOECHO}\$(CHMOD) 755 $targdir
692 Defines a lot of macros for distribution support.
697 my($self, %attribs) = @_;
700 # VERSION should be sanitised before use as a file name
701 my($version) = $attribs{VERSION} || '$(VERSION)';
702 my($name) = $attribs{NAME} || '$(DISTNAME)';
703 my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar
704 my($tarflags) = $attribs{TARFLAGS} || 'cvf';
705 my($zip) = $attribs{ZIP} || 'zip'; # eg pkzip Yuck!
706 my($zipflags) = $attribs{ZIPFLAGS} || '-r';
707 my($compress) = $attribs{COMPRESS} || 'compress'; # eg gzip
708 my($suffix) = $attribs{SUFFIX} || '.Z'; # eg .gz
709 my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip"
710 my($preop) = $attribs{PREOP} || "$self->{NOECHO}\$(NOOP)"; # eg update MANIFEST
711 my($postop) = $attribs{POSTOP} || "$self->{NOECHO}\$(NOOP)"; # eg remove the distdir
713 my($to_unix) = $attribs{TO_UNIX} || ($Is_OS2
715 . '$(TEST_F) tmp.zip && $(RM) tmp.zip;'
716 . ' $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM) tmp.zip'
717 : "$self->{NOECHO}\$(NOOP)");
719 my($ci) = $attribs{CI} || 'ci -u';
720 my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q';
721 my($dist_cp) = $attribs{DIST_CP} || 'best';
722 my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
725 DISTVNAME = ${name}-$version
737 RCS_LABEL = $rcs_label
739 DIST_DEFAULT = $dist_default
744 =item dist_basics (o)
746 Defines the targets distclean, distcheck, skipcheck, manifest.
754 distclean :: realclean distcheck
759 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=fullcheck \\
765 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=skipcheck \\
771 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=mkmanifest \\
779 Defines a check in target for RCS.
788 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
789 -e "@all = keys %{ maniread() };" \\
790 -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
791 -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
798 Defeines the targets dist, tardist, zipdist, uutardist, shdist
806 dist : $(DIST_DEFAULT)
807 }.$self->{NOECHO}.q{$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \
808 -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "}.$self->{MAKEFILE}.q{";'
810 tardist : $(DISTVNAME).tar$(SUFFIX)
812 zipdist : $(DISTVNAME).zip
814 $(DISTVNAME).tar$(SUFFIX) : distdir
817 $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
818 $(RM_RF) $(DISTVNAME)
819 $(COMPRESS) $(DISTVNAME).tar
822 $(DISTVNAME).zip : distdir
824 $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
825 $(RM_RF) $(DISTVNAME)
828 uutardist : $(DISTVNAME).tar$(SUFFIX)
829 uuencode $(DISTVNAME).tar$(SUFFIX) \\
830 $(DISTVNAME).tar$(SUFFIX) > \\
831 $(DISTVNAME).tar$(SUFFIX)_uu
835 $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
836 $(RM_RF) $(DISTVNAME)
844 Defines the scratch directory target that will hold the distribution
845 before tar-ing (or shar-ing).
854 $(RM_RF) $(DISTVNAME)
855 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \\
856 -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
863 Defines a target that produces the distribution in the
864 scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
874 cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
875 cd $(DISTVNAME) && $(MAKE)
876 cd $(DISTVNAME) && $(MAKE) test
883 Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp
889 my($self,%attribs) = @_;
891 return '' unless ($^O eq 'aix' && $self->needs_linking() );
893 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
894 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
898 dynamic :: $self->{BASEEXT}.exp
900 ") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
903 static :: $self->{BASEEXT}.exp
905 ") unless $self->{SKIPHASH}{'static'}; # we avoid a warning if we tick them
908 $self->{BASEEXT}.exp: Makefile.PL
909 ",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
910 Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
911 neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
919 Defines the dynamic target.
924 # --- Dynamic Loading Sections ---
928 ## $(INST_PM) has been moved to the all: target.
929 ## It remains here for awhile to allow for old usage: "make dynamic"
930 #dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
931 dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT)
932 '.$self->{NOECHO}.'$(NOOP)
938 Defines targets for bootstrap files.
943 my($self, %attribs) = @_;
946 ' unless $self->has_link_code();
949 BOOTSTRAP = '."$self->{BASEEXT}.bs".'
951 # As Mkbootstrap might not write a file (if none is required)
952 # we use touch to prevent make continually trying to remake it.
953 # The DynaLoader only reads a non-empty file.
954 $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists
955 '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
956 '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
957 -MExtUtils::Mkbootstrap \
958 -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
959 '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
962 $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
963 '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
964 -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
969 =item dynamic_lib (o)
971 Defines how to produce the *.so (or equivalent) files.
976 my($self, %attribs) = @_;
977 return '' unless $self->needs_linking(); #might be because of a subdir
979 return '' unless $self->has_link_code;
981 my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
982 my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
983 my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
984 my($ldfrom) = '$(LDFROM)';
985 $armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':');
988 # This section creates the dynamically loadable $(INST_DYNAMIC)
989 # from $(OBJECT) and possibly $(MYEXTLIB).
990 ARMAYBE = '.$armaybe.'
991 OTHERLDFLAGS = '.$otherldflags.'
992 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
994 $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
996 if ($armaybe ne ':'){
997 $ldfrom = 'tmp$(LIB_EXT)';
998 push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
999 push(@m,' $(RANLIB) '."$ldfrom\n");
1001 $ldfrom = "-all $ldfrom -none" if ($^O eq 'dec_osf');
1003 # Brain dead solaris linker does not use LD_RUN_PATH?
1004 # This fixes dynamic extensions which need shared libs
1006 $ldrun = join ' ', map "-R$_", split /:/, $self->{LD_RUN_PATH}
1007 if ($^O eq 'solaris');
1009 push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
1010 ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST)');
1015 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
1021 Deprecated method. Use libscan instead.
1026 my($self,$path) = @_;
1032 Called by init_others, and calls ext ExtUtils::Liblist. See
1033 L<ExtUtils::Liblist> for details.
1038 my($self,$libs) = @_;
1039 require ExtUtils::Liblist;
1040 $self->ext($libs, $Verbose);
1043 =item file_name_is_absolute
1045 Takes as argument a path and returns true, if it is an absolute path.
1049 sub file_name_is_absolute {
1050 my($self,$file) = @_;
1056 Finds the executables PERL and FULLPERL
1061 my($self, $ver, $names, $dirs, $trace) = @_;
1064 print "Looking for perl $ver by these names:
1070 foreach $dir (@$dirs){
1071 next unless defined $dir; # $self->{PERL_SRC} may be undefined
1072 foreach $name (@$names){
1074 if ($self->file_name_is_absolute($name)) { # /foo/bar
1076 } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
1077 $abs = $self->catfile($dir, $name);
1079 $abs = $self->canonpath($self->catfile($self->curdir, $name));
1081 print "Checking $abs\n" if ($trace >= 2);
1082 next unless $self->maybe_command($abs);
1083 print "Executing $abs\n" if ($trace >= 2);
1084 $val = `$abs -e 'require $ver; print "VER_OK\n" ' 2>&1`;
1085 if ($val =~ /VER_OK/) {
1086 print "Using PERL=$abs\n" if $trace;
1088 } elsif ($trace >= 2) {
1089 print "Result: `$val'\n";
1093 print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
1094 0; # false and not empty
1099 =head2 Methods to actually produce chunks of text for the Makefile
1101 The methods here are called for each MakeMaker object in the order
1102 specified by @ExtUtils::MakeMaker::MM_Sections.
1114 '# Phony target to force checking subdirectories.
1116 '.$self->{NOECHO}.'$(NOOP)
1122 Guess the name of this package by examining the working directory's
1123 name. MakeMaker calls this only if the developer has not supplied a
1133 my $name = basename(cwd());
1134 $name =~ s|[\-_][\d\.\-]+$||; # this is new with MM 5.00, we
1135 # strip minus or underline
1136 # followed by a float or some such
1137 print "Warning: Guessing NAME [$name] from current directory name.\n";
1143 Returns true if C, XS, MYEXTLIB or similar objects exist within this
1144 object that need a compiler. Does not descend into subdirectories as
1145 needs_linking() does.
1151 return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
1152 if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
1153 $self->{HAS_LINK_CODE} = 1;
1156 return $self->{HAS_LINK_CODE} = 0;
1161 Initializes DIR, XS, PM, C, O_FILES, H, PL_FILES, MAN*PODS, EXE_FILES.
1165 sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
1167 my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
1168 local(%pm); #the sub in find() has to see this hash
1169 $ignore{'test.pl'} = 1;
1170 $ignore{'makefile.pl'} = 1 if $Is_VMS;
1171 foreach $name ($self->lsdir($self->curdir)){
1172 next if $name =~ /\#/;
1173 next if $name eq $self->curdir or $name eq $self->updir or $ignore{$name};
1174 next unless $self->libscan($name);
1176 next if -l $name; # We do not support symlinks at all
1177 $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
1178 } elsif ($name =~ /\.xs$/){
1179 my($c); ($c = $name) =~ s/\.xs$/.c/;
1182 } elsif ($name =~ /\.c(pp|xx|c)?$/i){ # .c .C .cpp .cxx .cc
1184 unless $name =~ m/perlmain\.c/; # See MAP_TARGET
1185 } elsif ($name =~ /\.h$/i){
1187 } elsif ($name =~ /\.(p[ml]|pod)$/){
1188 $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);
1189 } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
1190 ($pl_files{$name} = $name) =~ s/\.PL$// ;
1191 } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' &&
1192 $name ne 'test.pl') { # case-insensitive filesystem
1193 ($pl_files{$name} = $name) =~ s/\.pl$// ;
1197 # Some larger extensions often wish to install a number of *.pm/pl
1198 # files into the library in various locations.
1200 # The attribute PMLIBDIRS holds an array reference which lists
1201 # subdirectories which we should search for library files to
1202 # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
1203 # recursively search through the named directories (skipping any
1204 # which don't exist or contain Makefile.PL files).
1206 # For each *.pm or *.pl file found $self->libscan() is called with
1207 # the default installation path in $_[1]. The return value of
1208 # libscan defines the actual installation location. The default
1209 # libscan function simply returns the path. The file is skipped
1210 # if libscan returns false.
1212 # The default installation location passed to libscan in $_[1] is:
1214 # ./*.pm => $(INST_LIBDIR)/*.pm
1215 # ./xyz/... => $(INST_LIBDIR)/xyz/...
1216 # ./lib/... => $(INST_LIB)/...
1218 # In this way the 'lib' directory is seen as the root of the actual
1219 # perl library whereas the others are relative to INST_LIBDIR
1220 # (which includes PARENT_NAME). This is a subtle distinction but one
1221 # that's important for nested modules.
1223 $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]
1224 unless $self->{PMLIBDIRS};
1226 #only existing directories that aren't in $dir are allowed
1228 # Avoid $_ wherever possible:
1229 # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
1230 my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
1232 @{$self->{PMLIBDIRS}} = ();
1233 foreach $pmlibdir (@pmlibdirs) {
1234 -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
1237 if (@{$self->{PMLIBDIRS}}){
1238 print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
1241 File::Find::find(sub {
1243 if ($_ eq "CVS" || $_ eq "RCS"){
1244 $File::Find::prune = 1;
1249 my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
1250 my($striplibpath,$striplibname);
1251 $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i);
1252 ($striplibname,$striplibpath) = fileparse($striplibpath);
1253 my($inst) = $self->catfile($prefix,$striplibpath,$striplibname);
1254 local($_) = $inst; # for backwards compatibility
1255 $inst = $self->libscan($inst);
1256 print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
1257 return unless $inst;
1259 }, @{$self->{PMLIBDIRS}});
1262 $self->{DIR} = [sort keys %dir] unless $self->{DIR};
1263 $self->{XS} = \%xs unless $self->{XS};
1264 $self->{PM} = \%pm unless $self->{PM};
1265 $self->{C} = [sort keys %c] unless $self->{C};
1266 my(@o_files) = @{$self->{C}};
1267 $self->{O_FILES} = [grep s/\.c(pp|xx|c)?$/$self->{OBJ_EXT}/i, @o_files] ;
1268 $self->{H} = [sort keys %h] unless $self->{H};
1269 $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
1271 # Set up names of manual pages to generate from pods
1272 if ($self->{MAN1PODS}) {
1273 } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) {
1274 $self->{MAN1PODS} = {};
1276 my %manifypods = ();
1277 if ( exists $self->{EXE_FILES} ) {
1278 foreach $name (@{$self->{EXE_FILES}}) {
1279 # use FileHandle ();
1280 # my $fh = new FileHandle;
1283 # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?)
1284 # if ($fh->open("<$name")) {
1285 if (open(FH,"<$name")) {
1288 if (/^=head1\s+\w+/) {
1296 # If it doesn't exist yet, we assume, it has pods in it
1300 $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)');
1304 $self->{MAN1PODS} = \%manifypods;
1306 if ($self->{MAN3PODS}) {
1307 } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) {
1308 $self->{MAN3PODS} = {};
1310 my %manifypods = (); # we collect the keys first, i.e. the files
1311 # we have to convert to pod
1312 foreach $name (keys %{$self->{PM}}) {
1313 if ($name =~ /\.pod$/ ) {
1314 $manifypods{$name} = $self->{PM}{$name};
1315 } elsif ($name =~ /\.p[ml]$/ ) {
1316 # use FileHandle ();
1317 # my $fh = new FileHandle;
1320 # $fh->open("<$name");
1321 if (open(FH,"<$name")) {
1324 if (/^=head1\s+\w+/) {
1335 $manifypods{$name} = $self->{PM}{$name};
1340 # Remove "Configure.pm" and similar, if it's not the only pod listed
1341 # To force inclusion, just name it "Configure.pod", or override MAN3PODS
1342 foreach $name (keys %manifypods) {
1343 if ($name =~ /(config|setup).*\.pm/i) {
1344 delete $manifypods{$name};
1347 my($manpagename) = $name;
1348 unless ($manpagename =~ s!^\W*lib\W+!!) { # everything below lib is ok
1349 $manpagename = $self->catfile(split(/::/,$self->{PARENT_NAME}),$manpagename);
1351 $manpagename =~ s/\.p(od|m|l)$//;
1352 $manpagename = $self->replace_manpage_separator($manpagename);
1353 $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)");
1355 $self->{MAN3PODS} = \%manifypods;
1361 Initializes NAME, FULLEXT, BASEEXT, PARENT_NAME, DLBASE, PERL_SRC,
1362 PERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*,
1363 PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, EXE_EXT, MAP_TARGET,
1364 LIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM.
1371 # --- Initialize Module Name and Paths
1373 # NAME = Foo::Bar::Oracle
1374 # FULLEXT = Foo/Bar/Oracle
1376 # ROOTEXT = Directory part of FULLEXT with leading /. !!! Deprecated from MM 5.32 !!!
1377 # PARENT_NAME = Foo::Bar
1379 ### ($self->{FULLEXT} =
1380 ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
1381 $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
1384 # Copied from DynaLoader:
1386 my(@modparts) = split(/::/,$self->{NAME});
1387 my($modfname) = $modparts[-1];
1389 # Some systems have restrictions on files names for DLL's etc.
1390 # mod2fname returns appropriate file base name (typically truncated)
1391 # It may also edit @modparts if required.
1392 if (defined &DynaLoader::mod2fname) {
1393 $modfname = &DynaLoader::mod2fname(\@modparts);
1396 ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!([\w:]+::)?(\w+)$! ;
1398 if (defined &DynaLoader::mod2fname) {
1399 # As of 5.001m, dl_os2 appends '_'
1400 $self->{DLBASE} = $modfname;
1402 $self->{DLBASE} = '$(BASEEXT)';
1406 ### ROOTEXT deprecated from MM 5.32
1407 ### ($self->{ROOTEXT} =
1408 ### $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ; #eg. /BSD/Foo
1409 ### $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};
1412 # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
1414 # *Real* information: where did we get these two from? ...
1415 my $inc_config_dir = dirname($INC{'Config.pm'});
1416 my $inc_carp_dir = dirname($INC{'Carp.pm'});
1418 unless ($self->{PERL_SRC}){
1420 foreach $dir ($self->updir(),$self->catdir($self->updir(),$self->updir()),$self->catdir($self->updir(),$self->updir(),$self->updir())){
1422 -f $self->catfile($dir,"config.sh")
1424 -f $self->catfile($dir,"perl.h")
1426 -f $self->catfile($dir,"lib","Exporter.pm")
1428 $self->{PERL_SRC}=$dir ;
1433 if ($self->{PERL_SRC}){
1434 $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
1435 $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
1436 $self->{PERL_INC} = ($Is_Win32) ? $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
1438 # catch a situation that has occurred a few times in the past:
1440 -s $self->catfile($self->{PERL_SRC},'cflags')
1444 -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
1451 You cannot build extensions below the perl source tree after executing
1452 a 'make clean' in the perl source tree.
1454 To rebuild extensions distributed with the perl source you should
1455 simply Configure (to include those extensions) and then build perl as
1456 normal. After installing perl the source tree can be deleted. It is
1457 not needed for building extensions by running 'perl Makefile.PL'
1458 usually without extra arguments.
1460 It is recommended that you unpack and build additional extensions away
1461 from the perl source tree.
1465 # we should also consider $ENV{PERL5LIB} here
1466 $self->{PERL_LIB} ||= $Config::Config{privlibexp};
1467 $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};
1468 $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
1470 unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))){
1472 Error: Unable to locate installed Perl libraries or Perl source code.
1474 It is recommended that you install perl in a standard location before
1475 building extensions. Some precompiled versions of perl do not contain
1476 these header files, so you cannot build extensions. In such a case,
1477 please build and install your perl from a fresh perl distribution. It
1478 usually solves this kind of problem.
1480 \(You get this message, because MakeMaker could not find "$perl_h"\)
1483 # print STDOUT "Using header files found in $self->{PERL_INC}\n"
1484 # if $Verbose && $self->needs_linking();
1488 # We get SITELIBEXP and SITEARCHEXP directly via
1489 # Get_from_Config. When we are running standard modules, these
1490 # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
1491 # set it to "site". I prefer that INSTALLDIRS be set from outside
1493 $self->{INSTALLDIRS} ||= "site";
1495 # INST_LIB typically pre-set if building an extension after
1496 # perl has been built and installed. Setting INST_LIB allows
1497 # you to build directly into, say $Config::Config{privlibexp}.
1498 unless ($self->{INST_LIB}){
1501 ##### XXXXX We have to change this nonsense
1503 if (defined $self->{PERL_SRC} and $self->{INSTALLDIRS} eq "perl") {
1504 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
1506 $self->{INST_LIB} = $self->catdir($self->curdir,"blib","lib");
1509 $self->{INST_ARCHLIB} ||= $self->catdir($self->curdir,"blib","arch");
1510 $self->{INST_BIN} ||= $self->catdir($self->curdir,'blib','bin');
1512 # We need to set up INST_LIBDIR before init_libscan() for VMS
1513 my @parentdir = split(/::/, $self->{PARENT_NAME});
1514 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)',@parentdir);
1515 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)',@parentdir);
1516 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)','auto','$(FULLEXT)');
1517 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)');
1519 # INST_EXE is deprecated, should go away March '97
1520 $self->{INST_EXE} ||= $self->catdir($self->curdir,'blib','script');
1521 $self->{INST_SCRIPT} ||= $self->catdir($self->curdir,'blib','script');
1523 # The user who requests an installation directory explicitly
1524 # should not have to tell us a architecture installation directory
1525 # as well. We look if a directory exists that is named after the
1526 # architecture. If not we take it as a sign that it should be the
1527 # same as the requested installation directory. Otherwise we take
1529 # We do the same thing twice: for privlib/archlib and for sitelib/sitearch
1531 for $libpair ({l=>"privlib", a=>"archlib"}, {l=>"sitelib", a=>"sitearch"}) {
1532 my $lib = "install$libpair->{l}";
1534 my $Arch = uc "install$libpair->{a}";
1535 if( $self->{$Lib} && ! $self->{$Arch} ){
1536 my($ilib) = $Config{$lib};
1537 $ilib = VMS::Filespec::unixify($ilib) if $Is_VMS;
1539 $self->prefixify($Arch,$ilib,$self->{$Lib});
1541 unless (-d $self->{$Arch}) {
1542 print STDOUT "Directory $self->{$Arch} not found, thusly\n" if $Verbose;
1543 $self->{$Arch} = $self->{$Lib};
1545 print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
1549 # we have to look at the relation between $Config{prefix} and the
1550 # requested values. We're going to set the $Config{prefix} part of
1551 # all the installation path variables to literally $(PREFIX), so
1552 # the user can still say make PREFIX=foo
1553 my($configure_prefix) = $Config{'prefix'};
1554 $configure_prefix = VMS::Filespec::unixify($configure_prefix) if $Is_VMS;
1555 $self->{PREFIX} ||= $configure_prefix;
1558 my($install_variable,$search_prefix,$replace_prefix);
1560 # The rule, taken from Configure, is that if prefix contains perl,
1562 # perlprefix/lib/ INSTALLPRIVLIB
1563 # perlprefix/lib/pod/
1564 # perlprefix/lib/site_perl/ INSTALLSITELIB
1565 # perlprefix/bin/ INSTALLBIN
1566 # perlprefix/man/ INSTALLMAN1DIR
1568 # prefix/lib/perl5/ INSTALLPRIVLIB
1569 # prefix/lib/perl5/pod/
1570 # prefix/lib/perl5/site_perl/ INSTALLSITELIB
1571 # prefix/bin/ INSTALLBIN
1572 # prefix/lib/perl5/man/ INSTALLMAN1DIR
1574 $replace_prefix = qq[\$\(PREFIX\)];
1575 for $install_variable (qw/
1579 $self->prefixify($install_variable,$configure_prefix,$replace_prefix);
1581 $search_prefix = $configure_prefix =~ /perl/ ?
1582 $self->catdir($configure_prefix,"lib") :
1583 $self->catdir($configure_prefix,"lib","perl5");
1585 $self->{INSTALLPRIVLIB} = $self->{INSTALLSITELIB} = $self->{LIB};
1586 $self->{INSTALLARCHLIB} = $self->{INSTALLSITEARCH} =
1587 $self->catdir($self->{LIB},$Config{'archname'});
1589 $replace_prefix = $self->{PREFIX} =~ /perl/ ?
1590 $self->catdir(qq[\$\(PREFIX\)],"lib") :
1591 $self->catdir(qq[\$\(PREFIX\)],"lib","perl5");
1592 for $install_variable (qw/
1598 $self->prefixify($install_variable,$search_prefix,$replace_prefix);
1601 $search_prefix = $configure_prefix =~ /perl/ ?
1602 $self->catdir($configure_prefix,"man") :
1603 $self->catdir($configure_prefix,"lib","perl5","man");
1604 $replace_prefix = $self->{PREFIX} =~ /perl/ ?
1605 $self->catdir(qq[\$\(PREFIX\)],"man") :
1606 $self->catdir(qq[\$\(PREFIX\)],"lib","perl5","man");
1607 for $install_variable (qw/
1611 $self->prefixify($install_variable,$search_prefix,$replace_prefix);
1614 # Now we head at the manpages. Maybe they DO NOT want manpages
1616 $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir}
1617 unless defined $self->{INSTALLMAN1DIR};
1618 unless (defined $self->{INST_MAN1DIR}){
1619 if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){
1620 $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR};
1622 $self->{INST_MAN1DIR} = $self->catdir($self->curdir,'blib','man1');
1625 $self->{MAN1EXT} ||= $Config::Config{man1ext};
1627 $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir}
1628 unless defined $self->{INSTALLMAN3DIR};
1629 unless (defined $self->{INST_MAN3DIR}){
1630 if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){
1631 $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR};
1633 $self->{INST_MAN3DIR} = $self->catdir($self->curdir,'blib','man3');
1636 $self->{MAN3EXT} ||= $Config::Config{man3ext};
1639 # Get some stuff out of %Config if we haven't yet done so
1640 print STDOUT "CONFIG must be an array ref\n"
1641 if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
1642 $self->{CONFIG} = [] unless (ref $self->{CONFIG});
1643 push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
1644 push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags};
1646 foreach $m (@{$self->{CONFIG}}){
1647 next if $once_only{$m};
1648 print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
1649 unless exists $Config::Config{$m};
1650 $self->{uc $m} ||= $Config::Config{$m};
1654 # This is too dangerous:
1655 # if ($^O eq "next") {
1656 # $self->{AR} = "libtool";
1657 # $self->{AR_STATIC_ARGS} = "-o";
1659 # But I leave it as a placeholder
1661 $self->{AR_STATIC_ARGS} ||= "cr";
1663 # These should never be needed
1664 $self->{LD} ||= 'ld';
1665 $self->{OBJ_EXT} ||= '.o';
1666 $self->{LIB_EXT} ||= '.a';
1668 $self->{MAP_TARGET} ||= "perl";
1670 $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
1672 # make a simple check if we find Exporter
1673 warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
1674 (Exporter.pm not found)"
1675 unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
1676 $self->{NAME} eq "ExtUtils::MakeMaker";
1678 # Determine VERSION and VERSION_FROM
1679 ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME};
1680 if ($self->{VERSION_FROM}){
1681 $self->{VERSION} = $self->parse_version($self->{VERSION_FROM}) or
1682 Carp::carp "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n"
1686 if ($self->{VERSION}) {
1687 $self->{VERSION} =~ s/^\s+//;
1688 $self->{VERSION} =~ s/\s+$//;
1691 $self->{VERSION} ||= "0.10";
1692 ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
1695 # Graham Barr and Paul Marquess had some ideas how to ensure
1696 # version compatibility between the *.pm file and the
1697 # corresponding *.xs file. The bottomline was, that we need an
1698 # XS_VERSION macro that defaults to VERSION:
1699 $self->{XS_VERSION} ||= $self->{VERSION};
1701 # --- Initialize Perl Binary Locations
1703 # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
1704 # will be working versions of perl 5. miniperl has priority over perl
1705 # for PERL to ensure that $(PERL) is usable while building ./ext/*
1706 my ($component,@defpath);
1707 foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
1708 push @defpath, $component if defined $component;
1711 $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ],
1712 \@defpath, $Verbose );
1713 # don't check if perl is executable, maybe they have decided to
1714 # supply switches with perl
1716 # Define 'FULLPERL' to be a non-miniperl (used in test: target)
1717 ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
1718 unless ($self->{FULLPERL});
1723 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH,
1724 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, NOOP, FIRST_MAKEFILE,
1725 MAKEFILE, NOECHO, RM_F, RM_RF, TEST_F, TOUCH, CP, MV, CHMOD, UMASK_NULL
1729 sub init_others { # --- Initialize Other Attributes
1732 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
1733 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
1734 # undefined. In any case we turn it into an anon array:
1736 # May check $Config{libs} too, thus not empty.
1737 $self->{LIBS}=[''] unless $self->{LIBS};
1739 $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq 'SCALAR';
1740 $self->{LD_RUN_PATH} = "";
1742 foreach $libs ( @{$self->{LIBS}} ){
1743 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
1744 my(@libs) = $self->extliblist($libs);
1745 if ($libs[0] or $libs[1] or $libs[2]){
1746 # LD_RUN_PATH now computed by ExtUtils::Liblist
1747 ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
1752 if ( $self->{OBJECT} ) {
1753 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
1755 # init_dirscan should have found out, if we have C files
1756 $self->{OBJECT} = "";
1757 $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
1759 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
1760 $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
1761 $self->{PERLMAINCC} ||= '$(CC)';
1762 $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
1764 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
1765 # the 'dynamic' section of MM. We don't have this problem with
1766 # 'static', since we either must use it (%Config says we can't
1767 # use dynamic loading) or the caller asked for it explicitly.
1768 if (!$self->{LINKTYPE}) {
1769 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
1771 : ($Config::Config{usedl} ? 'dynamic' : 'static');
1774 # These get overridden for VMS and maybe some other systems
1775 $self->{NOOP} ||= '$(SHELL) -c true';
1776 $self->{FIRST_MAKEFILE} ||= "Makefile";
1777 $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
1778 $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
1779 $self->{NOECHO} = '@' unless defined $self->{NOECHO};
1780 $self->{RM_F} ||= "rm -f";
1781 $self->{RM_RF} ||= "rm -rf";
1782 $self->{TOUCH} ||= "touch";
1783 $self->{TEST_F} ||= "test -f";
1784 $self->{CP} ||= "cp";
1785 $self->{MV} ||= "mv";
1786 $self->{CHMOD} ||= "chmod";
1787 $self->{UMASK_NULL} ||= "umask 0";
1788 $self->{DEV_NULL} ||= "> /dev/null 2>&1";
1793 Defines the install target.
1798 my($self, %attribs) = @_;
1802 install :: all pure_install doc_install
1804 install_perl :: all pure_perl_install doc_perl_install
1806 install_site :: all pure_site_install doc_site_install
1808 install_ :: install_site
1809 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1811 pure_install :: pure_$(INSTALLDIRS)_install
1813 doc_install :: doc_$(INSTALLDIRS)_install
1814 }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
1816 pure__install : pure_site_install
1817 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1819 doc__install : doc_site_install
1820 @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
1822 pure_perl_install ::
1823 }.$self->{NOECHO}.q{$(MOD_INSTALL) \
1824 read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
1825 write }.$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
1826 $(INST_LIB) $(INSTALLPRIVLIB) \
1827 $(INST_ARCHLIB) $(INSTALLARCHLIB) \
1828 $(INST_BIN) $(INSTALLBIN) \
1829 $(INST_SCRIPT) $(INSTALLSCRIPT) \
1830 $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
1831 $(INST_MAN3DIR) $(INSTALLMAN3DIR)
1832 }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
1833 }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
1836 pure_site_install ::
1837 }.$self->{NOECHO}.q{$(MOD_INSTALL) \
1838 read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
1839 write }.$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
1840 $(INST_LIB) $(INSTALLSITELIB) \
1841 $(INST_ARCHLIB) $(INSTALLSITEARCH) \
1842 $(INST_BIN) $(INSTALLBIN) \
1843 $(INST_SCRIPT) $(INSTALLSCRIPT) \
1844 $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
1845 $(INST_MAN3DIR) $(INSTALLMAN3DIR)
1846 }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
1847 }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
1850 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
1851 "Module" "$(NAME)" \
1852 "installed into" "$(INSTALLPRIVLIB)" \
1853 LINKTYPE "$(LINKTYPE)" \
1854 VERSION "$(VERSION)" \
1855 EXE_FILES "$(EXE_FILES)" \
1856 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
1859 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
1860 "Module" "$(NAME)" \
1861 "installed into" "$(INSTALLSITELIB)" \
1862 LINKTYPE "$(LINKTYPE)" \
1863 VERSION "$(VERSION)" \
1864 EXE_FILES "$(EXE_FILES)" \
1865 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
1870 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
1872 uninstall_from_perldirs ::
1874 q{$(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
1876 uninstall_from_sitedirs ::
1878 q{$(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
1884 =item installbin (o)
1886 Defines targets to install EXE_FILES.
1892 return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
1893 return "" unless @{$self->{EXE_FILES}};
1894 my(@m, $from, $to, %fromto, @to);
1895 push @m, $self->dir_target(qw[$(INST_SCRIPT)]);
1896 for $from (@{$self->{EXE_FILES}}) {
1897 my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
1898 local($_) = $path; # for backwards compatibility
1899 $to = $self->libscan($path);
1900 print "libscan($from) => '$to'\n" if ($Verbose >=2);
1903 @to = values %fromto;
1905 EXE_FILES = @{$self->{EXE_FILES}}
1913 while (($from,$to) = each %fromto) {
1914 last unless defined $from;
1915 my $todir = dirname($to);
1917 $to: $from $self->{MAKEFILE} ".$self->catfile($todir,'.exists')."
1918 $self->{NOECHO}$self->{RM_F} $to
1919 $self->{CP} $from $to
1927 Takes a path to a file that is found by init_dirscan and returns false
1928 if we don't want to include this file in the library. Mainly used to
1929 exclude RCS, CVS, and SCCS directories from installation.
1936 my($self,$path) = @_;
1937 return '' if $path =~ m:\b(RCS|CVS|SCCS)\b: ;
1943 Defines the linkext target which in turn defines the LINKTYPE.
1948 my($self, %attribs) = @_;
1949 # LINKTYPE => static or dynamic or ''
1950 my($linktype) = defined $attribs{LINKTYPE} ?
1951 $attribs{LINKTYPE} : '$(LINKTYPE)';
1953 linkext :: $linktype
1954 $self->{NOECHO}\$(NOOP)
1960 Takes as arguments a directory name and a regular expression. Returns
1961 all entries in the directory that match the regular expression.
1967 my($dir, $regex) = @_;
1969 my $dh = new DirHandle;
1970 $dh->open($dir || ".") or return ();
1973 @ls = grep(/$regex/, @ls) if $regex;
1979 Simple subroutine to insert the macros defined by the macro attribute
1985 my($self,%attribs) = @_;
1987 while (($key,$val) = each %attribs){
1988 last unless defined $key;
1989 push @m, "$key = $val\n";
1996 Called by staticmake. Defines how to write the Makefile to produce a
1999 By default the Makefile produced includes all the static extensions in
2000 the perl library. (Purified versions of library files, e.g.,
2001 DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
2006 my($self, %attribs) = @_;
2007 my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
2008 @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
2011 # --- MakeMaker makeaperl section ---
2012 MAP_TARGET = $target
2013 FULLPERL = $self->{FULLPERL}
2015 return join '', @m if $self->{PARENT};
2017 my($dir) = join ":", @{$self->{DIR}};
2019 unless ($self->{MAKEAPERL}) {
2021 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
2022 $(MAKE) -f $(MAKE_APERL_FILE) $@
2024 $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
2025 }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
2026 }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
2027 Makefile.PL DIR=}, $dir, q{ \
2028 MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
2029 MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
2035 push @m, " \\\n\t\t$_";
2037 # push @m, map( " \\\n\t\t$_", @ARGV );
2045 my($cccmd, $linkcmd, $lperl);
2048 $cccmd = $self->const_cccmd($libperl);
2049 $cccmd =~ s/^CCCMD\s*=\s*//;
2050 $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /;
2051 $cccmd .= " $Config::Config{cccdlflags}"
2052 if ($Config::Config{useshrplib} eq 'true');
2053 $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
2055 # The front matter of the linkcommand...
2056 $linkcmd = join ' ', "\$(CC)",
2057 grep($_, @Config{qw(large split ldflags ccdlflags)});
2058 $linkcmd =~ s/\s+/ /g;
2059 $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
2061 # Which *.a files could we make use of...
2064 File::Find::find(sub {
2065 return unless m/\Q$self->{LIB_EXT}\E$/;
2066 return if m/^libperl/;
2067 # Skip purified versions of libraries (e.g., DynaLoader_pure_p1_c0_032.a)
2068 return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
2070 if( exists $self->{INCLUDE_EXT} ){
2075 ($xx = $File::Find::name) =~ s,.*?/auto/,,;
2079 # Throw away anything not explicitly marked for inclusion.
2080 # DynaLoader is implied.
2081 foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
2087 return unless $found;
2089 elsif( exists $self->{EXCLUDE_EXT} ){
2093 ($xx = $File::Find::name) =~ s,.*?/auto/,,;
2097 # Throw away anything explicitly marked for exclusion
2098 foreach $excl (@{$self->{EXCLUDE_EXT}}){
2099 return if( $xx eq $excl );
2103 # don't include the installed version of this extension. I
2104 # leave this line here, although it is not necessary anymore:
2105 # I patched minimod.PL instead, so that Miniperl.pm won't
2106 # enclude duplicates
2108 # Once the patch to minimod.PL is in the distribution, I can
2110 return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}$:;
2112 $static{cwd() . "/" . $_}++;
2113 }, grep( -d $_, @{$searchdirs || []}) );
2115 # We trust that what has been handed in as argument, will be buildable
2116 $static = [] unless $static;
2117 @static{@{$static}} = (1) x @{$static};
2119 $extra = [] unless $extra && ref $extra eq 'ARRAY';
2120 for (sort keys %static) {
2121 next unless /\Q$self->{LIB_EXT}\E$/;
2122 $_ = dirname($_) . "/extralibs.ld";
2126 grep(s/^/-I/, @{$perlinc || []});
2128 $target = "perl" unless $target;
2129 $tmp = "." unless $tmp;
2131 # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
2132 # regenerate the Makefiles, MAP_STATIC and the dependencies for
2133 # extralibs.all are computed correctly
2135 MAP_LINKCMD = $linkcmd
2136 MAP_PERLINC = @{$perlinc || []}
2138 join(" \\\n\t", reverse sort keys %static), "
2140 MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
2143 if (defined $libperl) {
2144 ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
2146 unless ($libperl && -f $lperl) { # Ilya's code...
2147 my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
2148 $libperl ||= "libperl$self->{LIB_EXT}";
2149 $libperl = "$dir/$libperl";
2150 $lperl ||= "libperl$self->{LIB_EXT}";
2151 $lperl = "$dir/$lperl";
2153 if (! -f $libperl and ! -f $lperl) {
2154 # We did not find a static libperl. Maybe there is a shared one?
2155 if ($^O eq 'solaris' or $^O eq 'sunos') {
2156 $lperl = $libperl = "$dir/$Config::Config{libperl}";
2157 # SUNOS ld does not take the full path to a shared library
2158 $libperl = '' if $^O eq 'sunos';
2162 print STDOUT "Warning: $libperl not found
2163 If you're going to build a static perl binary, make sure perl is installed
2164 otherwise ignore this warning\n"
2165 unless (-f $lperl || defined($self->{PERL_SRC}));
2169 MAP_LIBPERL = $libperl
2173 \$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)."
2174 $self->{NOECHO}$self->{RM_F} \$\@
2175 $self->{NOECHO}\$(TOUCH) \$\@
2179 foreach $catfile (@$extra){
2180 push @m, "\tcat $catfile >> \$\@\n";
2182 # SUNOS ld does not take the full path to a shared library
2183 my $llibperl = ($libperl)?'$(MAP_LIBPERL)':'-lperl';
2185 # Brain dead solaris linker does not use LD_RUN_PATH?
2186 # This fixes dynamic extensions which need shared libs
2187 my $ldfrom = ($^O eq 'solaris')?
2188 join(' ', map "-R$_", split /:/, $self->{LD_RUN_PATH}):'';
2191 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
2192 \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) $ldfrom $llibperl \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
2193 $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
2194 $self->{NOECHO}echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
2195 $self->{NOECHO}echo 'To remove the intermediate files say'
2196 $self->{NOECHO}echo ' make -f $makefilename map_clean'
2198 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
2200 push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n";
2203 $tmp/perlmain.c: $makefilename}, q{
2204 }.$self->{NOECHO}.q{echo Writing $@
2205 }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -MExtUtils::Miniperl \\
2206 -e "writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)" > $@t && $(MV) $@t $@
2212 }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
2213 }.$self->{NOECHO}.q{$(DOC_INSTALL) \
2214 "Perl binary" "$(MAP_TARGET)" \
2215 MAP_STATIC "$(MAP_STATIC)" \
2216 MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
2217 MAP_LIBPERL "$(MAP_LIBPERL)" \
2218 >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
2223 inst_perl: pure_inst_perl doc_inst_perl
2225 pure_inst_perl: $(MAP_TARGET)
2226 }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(INSTALLBIN)','$(MAP_TARGET)').q{
2231 }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
2239 Defines how to rewrite the Makefile.
2246 # We do not know what target was originally specified so we
2247 # must force a manual rerun to be sure. But as it should only
2248 # happen very rarely it is not a significant problem.
2250 $(OBJECT) : $(FIRST_MAKEFILE)
2251 ' if $self->{OBJECT};
2254 # We take a very conservative approach here, but it\'s worth it.
2255 # We move Makefile to Makefile.old here to avoid gnu make looping.
2256 }.$self->{MAKEFILE}.q{ : Makefile.PL $(CONFIGDEP)
2257 }.$self->{NOECHO}.q{echo "Makefile out-of-date with respect to $?"
2258 }.$self->{NOECHO}.q{echo "Cleaning current config before rebuilding Makefile..."
2259 -}.$self->{NOECHO}.q{$(MV) }."$self->{MAKEFILE} $self->{MAKEFILE}.old".q{
2260 -$(MAKE) -f }.$self->{MAKEFILE}.q{.old clean $(DEV_NULL) || $(NOOP)
2261 $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{
2262 }.$self->{NOECHO}.q{echo "==> Your Makefile has been rebuilt. <=="
2263 }.$self->{NOECHO}.q{echo "==> Please rerun the make command. <=="
2266 # To change behavior to :: would be nice, but would break Tk b9.02
2267 # so you find such a warning below the dist target.
2268 #}.$self->{MAKEFILE}.q{ :: $(VERSION_FROM)
2269 # }.$self->{NOECHO}.q{echo "Warning: Makefile possibly out of date with $(VERSION_FROM)"
2275 =item manifypods (o)
2277 Defines targets and routines to translate the pods into manpages and
2278 put them into the INST_* directories.
2283 my($self, %attribs) = @_;
2284 return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n" unless %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
2287 if (defined $self->{PERL_SRC}) {
2288 $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
2290 $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
2292 unless ($self->perl_script($pod2man_exe)) {
2293 # No pod2man but some MAN3PODS to be installed
2296 Warning: I could not locate your pod2man program. Please make sure,
2297 your pod2man program is in your PATH before you execute 'make'
2300 $pod2man_exe = "-S pod2man";
2304 qq[POD2MAN_EXE = $pod2man_exe\n],
2305 q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\
2306 -e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\
2307 -e 'print "Manifying $$m{$$_}\n";' \\
2308 -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
2309 -e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}'
2311 push @m, "\nmanifypods : ";
2312 push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
2315 if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
2316 push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
2317 push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
2324 Returns true, if the argument is likely to be a command.
2329 my($self,$file) = @_;
2330 return $file if -x $file && ! -d $file;
2334 =item maybe_command_in_dirs
2336 method under development. Not yet used. Ask Ilya :-)
2340 sub maybe_command_in_dirs { # $ver is optional argument if looking for perl
2341 # Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here
2342 my($self, $names, $dirs, $trace, $ver) = @_;
2344 foreach $dir (@$dirs){
2345 next unless defined $dir; # $self->{PERL_SRC} may be undefined
2346 foreach $name (@$names){
2348 if ($self->file_name_is_absolute($name)) { # /foo/bar
2350 } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # bar
2351 $abs = $self->catfile($dir, $name);
2353 $abs = $self->catfile($self->curdir, $name);
2355 print "Checking $abs for $name\n" if ($trace >= 2);
2356 next unless $tryabs = $self->maybe_command($abs);
2357 print "Substituting $tryabs instead of $abs\n"
2358 if ($trace >= 2 and $tryabs ne $abs);
2361 print "Executing $abs\n" if ($trace >= 2);
2362 if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
2363 print "Using PERL=$abs\n" if $trace;
2366 } else { # Do not look for perl
2373 =item needs_linking (o)
2375 Does this module need linking? Looks into subdirectory objects (see
2376 also has_link_code())
2383 $caller = (caller(0))[3];
2384 Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/;
2385 return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
2386 if ($self->has_link_code or $self->{MAKEAPERL}){
2387 $self->{NEEDS_LINKING} = 1;
2390 foreach $child (keys %{$self->{CHILDREN}}) {
2391 if ($self->{CHILDREN}->{$child}->needs_linking) {
2392 $self->{NEEDS_LINKING} = 1;
2396 return $self->{NEEDS_LINKING} = 0;
2401 misnamed method (will have to be changed). The MM_Unix method just
2402 returns the argument without further processing.
2404 On VMS used to insure that colons marking targets are preceded by
2405 space - most Unix Makes don't need this, but it's necessary under VMS
2406 to distinguish the target delimiter from a colon appearing as part of
2412 my($self,$text) = @_;
2418 parse a file and return what you think is $VERSION in this file set to
2423 my($self,$parsefile) = @_;
2427 open(FH,$parsefile) or die "Could not open '$parsefile': $!";
2430 $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
2433 next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/;
2435 package ExtUtils::MakeMaker::_version;
2443 $result = eval($eval) || 0;
2444 die "Could not eval '$eval' in $parsefile: $@" if $@;
2454 Defines the string that is passed to recursive make calls in
2464 my($sep) = $Is_VMS ? ',' : '';
2467 foreach $key (qw(LIB LIBPERL_A LINKTYPE PREFIX OPTIMIZE)){
2468 push @pasthru, "$key=\"\$($key)\"";
2471 push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
2477 Takes no argument, returns the environment variable PATH as an array.
2483 my $path_sep = $Is_OS2 ? ";" : ":";
2484 my $path = $ENV{PATH};
2485 $path =~ s:\\:/:g if $Is_OS2;
2486 my @path = split $path_sep, $path;
2487 foreach(@path) { $_ = '.' if $_ eq '' }
2493 Takes one argument, a file name, and returns the file name, if the
2494 argument is likely to be a perl script. On MM_Unix this is true for
2495 any ordinary, readable file.
2500 my($self,$file) = @_;
2501 return $file if -r $file && -f _;
2505 =item perldepend (o)
2507 Defines the dependency from all *.h files that come with the perl
2516 # Check for unpropogated config.sh changes. Should never happen.
2517 # We do NOT just update config.h because that is not sufficient.
2518 # An out of date config.h is not fatal but complains loudly!
2519 $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
2520 -}.$self->{NOECHO}.q{echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
2522 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
2523 }.$self->{NOECHO}.q{echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
2524 cd $(PERL_SRC) && $(MAKE) lib/Config.pm
2525 } if $self->{PERL_SRC};
2527 return join "", @m unless $self->needs_linking;
2531 $(PERL_INC)/EXTERN.h $(PERL_INC)/gv.h $(PERL_INC)/pp.h \
2532 $(PERL_INC)/INTERN.h $(PERL_INC)/handy.h $(PERL_INC)/proto.h \
2533 $(PERL_INC)/XSUB.h $(PERL_INC)/hv.h $(PERL_INC)/regcomp.h \
2534 $(PERL_INC)/av.h $(PERL_INC)/keywords.h $(PERL_INC)/regexp.h \
2535 $(PERL_INC)/config.h $(PERL_INC)/mg.h $(PERL_INC)/scope.h \
2536 $(PERL_INC)/cop.h $(PERL_INC)/op.h $(PERL_INC)/sv.h \
2537 $(PERL_INC)/cv.h $(PERL_INC)/opcode.h $(PERL_INC)/unixish.h \
2538 $(PERL_INC)/dosish.h $(PERL_INC)/patchlevel.h $(PERL_INC)/util.h \
2539 $(PERL_INC)/embed.h $(PERL_INC)/perl.h \
2540 $(PERL_INC)/form.h $(PERL_INC)/perly.h
2542 $(OBJECT) : $(PERL_HDRS)
2543 } if $self->{OBJECT};
2545 push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
2552 Defines target that copies all files in the hash PM to their
2553 destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
2559 my($autodir) = $self->catdir('$(INST_LIB)','auto');
2561 pm_to_blib: $(TO_INST_PM)
2562 }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
2563 "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
2564 -e "pm_to_blib({qw{$(PM_TO_BLIB)}},'}.$autodir.q{')"
2565 }.$self->{NOECHO}.q{$(TOUCH) $@
2569 =item post_constants (o)
2571 Returns an empty string per default. Dedicated to overrides from
2572 within Makefile.PL after all constants have been defined.
2581 =item post_initialize (o)
2583 Returns an empty string per default. Used in Makefile.PLs to add some
2584 chunk of text to the Makefile after the object is initialized.
2588 sub post_initialize {
2595 Returns an empty string. Can be used in Makefile.PLs to write some
2596 text to the Makefile at the end.
2607 Check a path variable in $self from %Config, if it contains a prefix,
2608 and replace it with another one.
2610 Takes as arguments an attribute name, a search prefix and a
2611 replacement prefix. Changes the attribute in the object.
2616 my($self,$var,$sprefix,$rprefix) = @_;
2617 $self->{uc $var} ||= $Config{lc $var};
2618 $self->{uc $var} = VMS::Filespec::unixpath($self->{uc $var}) if $Is_VMS;
2619 $self->{uc $var} =~ s/\Q$sprefix\E/$rprefix/;
2624 Defines targets to run *.PL files.
2630 return "" unless $self->{PL_FILES};
2632 foreach $plfile (sort keys %{$self->{PL_FILES}}) {
2634 all :: $self->{PL_FILES}->{$plfile}
2636 $self->{PL_FILES}->{$plfile} :: $plfile
2637 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
2645 Defines the realclean target.
2650 my($self, %attribs) = @_;
2653 # Delete temporary files (via clean) and also delete installed files
2654 realclean purge :: clean
2656 # realclean subdirectories first (already cleaned)
2657 my $sub = "\t-cd %s && \$(TEST_F) %s && \$(MAKE) %s realclean\n";
2658 foreach(@{$self->{DIR}}){
2659 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
2660 push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
2662 push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
2663 if( $self->has_link_code ){
2664 push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
2665 push(@m, " $self->{RM_F} \$(INST_STATIC)\n");
2667 push(@m, " $self->{RM_F} " . join(" ", values %{$self->{PM}}) . "\n");
2668 my(@otherfiles) = ($self->{MAKEFILE},
2669 "$self->{MAKEFILE}.old"); # Makefiles last
2670 push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
2671 push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles;
2672 push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
2676 =item replace_manpage_separator
2678 Takes the name of a package, which may be a nested package, in the
2679 form Foo/Bar and replaces the slash with C<::>. Returns the replacement.
2683 sub replace_manpage_separator {
2684 my($self,$man) = @_;
2691 Defines the static target.
2696 # --- Static Loading Sections ---
2700 ## $(INST_PM) has been moved to the all: target.
2701 ## It remains here for awhile to allow for old usage: "make static"
2702 #static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
2703 static :: '.$self->{MAKEFILE}.' $(INST_STATIC)
2704 '.$self->{NOECHO}.'$(NOOP)
2708 =item static_lib (o)
2710 Defines how to produce the *.a (or equivalent) files.
2716 # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
2717 # return '' unless $self->needs_linking(); #might be because of a subdir
2719 return '' unless $self->has_link_code;
2723 $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
2726 # If this extension has it's own library (eg SDBM_File)
2727 # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
2728 push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
2731 q{ $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
2733 }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
2735 # Old mechanism - still available:
2737 "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
2738 } if $self->{PERL_SRC} && $self->{EXTRALIBS};
2741 push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
2745 =item staticmake (o)
2752 my($self, %attribs) = @_;
2755 my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
2757 # And as it's not yet built, we add the current extension
2758 # but only if it has some C code (or XS code, which implies C code)
2759 if (@{$self->{C}}) {
2760 @static = $self->catfile($self->{INST_ARCHLIB},
2763 "$self->{BASEEXT}$self->{LIB_EXT}"
2767 # Either we determine now, which libraries we will produce in the
2768 # subdirectories or we do it at runtime of the make.
2770 # We could ask all subdir objects, but I cannot imagine, why it
2771 # would be necessary.
2773 # Instead we determine all libraries for the new perl at
2775 my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
2777 $self->makeaperl(MAKE => $self->{MAKEFILE},
2778 DIRS => \@searchdirs,
2781 TARGET => $self->{MAP_TARGET},
2783 LIBPERL => $self->{LIBPERL_A}
2789 Helper subroutine for subdirs
2794 my($self, $subdir) = @_;
2799 $self->{NOECHO}cd $subdir && \$(MAKE) all \$(PASTHRU)
2806 Defines targets to process subdirectories.
2811 # --- Sub-directory Sections ---
2814 # This method provides a mechanism to automatically deal with
2815 # subdirectories containing further Makefile.PL scripts.
2816 # It calls the subdir_x() method for each subdirectory.
2817 foreach $dir (@{$self->{DIR}}){
2818 push(@m, $self->subdir_x($dir));
2819 #### print "Including $dir subdirectory\n";
2823 # The default clean, realclean and test targets in this Makefile
2824 # have automatically been given entries for each subdir.
2828 push(@m, "\n# none")
2835 Defines the test targets.
2840 # --- Test and Installation Sections ---
2842 my($self, %attribs) = @_;
2843 my $tests = $attribs{TESTS};
2844 if (!$tests && -d 't') {
2845 $tests = $Is_Win32 ? join(' ', <t\\*.t>) : 't/*.t';
2850 TEST_TYPE=test_\$(LINKTYPE)
2854 testdb :: testdb_\$(LINKTYPE)
2856 test :: \$(TEST_TYPE)
2858 push(@m, map("\t$self->{NOECHO}cd $_ && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
2860 push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n")
2861 unless $tests or -f "test.pl" or @{$self->{DIR}};
2864 push(@m, "test_dynamic :: pure_all\n");
2865 push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
2866 push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
2869 push(@m, "testdb_dynamic :: pure_all\n");
2870 push(@m, $self->test_via_script('$(FULLPERL) $(TESTDB_SW)', '$(TEST_FILE)'));
2873 # Occasionally we may face this degenerate target:
2874 push @m, "test_ : test_dynamic\n\n";
2876 if ($self->needs_linking()) {
2877 push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
2878 push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
2879 push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
2881 push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
2882 push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
2885 push @m, "test_static :: test_dynamic\n";
2886 push @m, "testdb_static :: testdb_dynamic\n";
2891 =item test_via_harness (o)
2893 Helper method to write the test targets
2897 sub test_via_harness {
2898 my($self, $perl, $tests) = @_;
2899 $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
2900 "\t$perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
2903 =item test_via_script (o)
2905 Other helper method for test.
2909 sub test_via_script {
2910 my($self, $perl, $script) = @_;
2911 $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
2912 qq{\t$perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script
2916 =item tool_autosplit (o)
2918 Defines a simple perl call that runs autosplit. May be deprecated by
2923 sub tool_autosplit {
2924 # --- Tool Sections ---
2926 my($self, %attribs) = @_;
2928 $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
2930 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
2931 AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
2935 =item tools_other (o)
2937 Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
2938 the Makefile. Also defines the perl programs MKPATH,
2939 WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
2946 my $bin_sh = $Config{sh} || '/bin/sh';
2951 for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
2952 push @m, "$_ = $self->{$_}\n";
2956 # The following is a portable way to say mkdir -p
2957 # To see which directories are created, change the if 0 to if 1
2958 MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
2960 # This helps us to minimize the effect of the .exists files A yet
2961 # better solution would be to have a stable file in the perl
2962 # distribution with a timestamp of zero. But this solution doesn't
2963 # need any changes to the core distribution and works with older perls
2964 EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
2968 return join "", @m if $self->{PARENT};
2971 # Here we warn users that an old packlist file was found somewhere,
2972 # and that they should call some uninstall routine
2973 WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \\
2974 -e 'print "WARNING: I have found an old package in\n";' \\
2975 -e 'print "\t$$ARGV[0].\n";' \\
2976 -e 'print "Please make sure the two installations are not conflicting\n";'
2981 MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
2982 -e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');"
2984 DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \
2985 -e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", shift, ">";' \
2986 -e 'print "=over 4";' \
2987 -e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \
2990 UNINSTALL = $(PERL) -MExtUtils::Install \
2991 -e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \
2992 -e 'print " packlist above carefully.\n There may be errors. Remove the";' \
2993 -e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"'
2999 =item tool_xsubpp (o)
3001 Determines typemaps, xsubpp version, prototype behaviour.
3007 return "" unless $self->needs_linking;
3008 my($xsdir) = $self->catdir($self->{PERL_LIB},"ExtUtils");
3009 my(@tmdeps) = $self->catdir('$(XSUBPPDIR)','typemap');
3010 if( $self->{TYPEMAPS} ){
3012 foreach $typemap (@{$self->{TYPEMAPS}}){
3013 if( ! -f $typemap ){
3014 warn "Typemap $typemap not found.\n";
3017 push(@tmdeps, $typemap);
3021 push(@tmdeps, "typemap") if -f "typemap";
3022 my(@tmargs) = map("-typemap $_", @tmdeps);
3023 if( exists $self->{XSOPT} ){
3024 unshift( @tmargs, $self->{XSOPT} );
3028 my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,"xsubpp"));
3030 # What are the correct thresholds for version 1 && 2 Paul?
3031 if ( $xsubpp_version > 1.923 ){
3032 $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3034 if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
3035 print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
3036 Your version of xsubpp is $xsubpp_version and cannot handle this.
3037 Please upgrade to a more recent version of xsubpp.
3040 $self->{XSPROTOARG} = "";
3046 XSUBPP = \$(XSUBPPDIR)/xsubpp
3047 XSPROTOARG = $self->{XSPROTOARG}
3048 XSUBPPDEPS = @tmdeps
3049 XSUBPPARGS = @tmargs
3055 my($self,$xsubpp) = @_;
3056 return $Xsubpp_Version if defined $Xsubpp_Version; # global variable
3060 # try to figure out the version number of the xsubpp on the system
3062 # first try the -v flag, introduced in 1.921 & 2.000a2
3064 return "" unless $self->needs_linking;
3066 my $command = "$self->{PERL} -I$self->{PERL_LIB} $xsubpp -v 2>&1";
3067 print "Running $command\n" if $Verbose >= 2;
3068 $version = `$command` ;
3069 warn "Running '$command' exits with status " . ($?>>8) if $?;
3072 return $Xsubpp_Version = $1 if $version =~ /^xsubpp version (.*)/ ;
3074 # nope, then try something else
3076 my $counter = '000';
3077 my ($file) = 'temp' ;
3078 $counter++ while -e "$file$counter"; # don't overwrite anything
3081 open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
3083 MODULE = fred PACKAGE = fred
3092 $command = "$self->{PERL} $xsubpp $file 2>&1";
3093 print "Running $command\n" if $Verbose >= 2;
3094 my $text = `$command` ;
3095 warn "Running '$command' exits with status " . ($?>>8) if $?;
3098 # gets 1.2 -> 1.92 and 2.000a1
3099 return $Xsubpp_Version = $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ;
3101 # it is either 1.0 or 1.1
3102 return $Xsubpp_Version = 1.1 if $text =~ /^Warning: ignored semicolon/ ;
3104 # none of the above, so 1.0
3105 return $Xsubpp_Version = "1.0" ;
3108 =item top_targets (o)
3110 Defines the targets all, subdirs, config, and O_FILES
3115 # --- Target Sections ---
3120 #all :: config $(INST_PM) subdirs linkext manifypods
3124 all :: pure_all manifypods
3125 '.$self->{NOECHO}.'$(NOOP)
3127 unless $self->{SKIPHASH}{'all'};
3130 pure_all :: config pm_to_blib subdirs linkext
3131 '.$self->{NOECHO}.'$(NOOP)
3133 subdirs :: $(MYEXTLIB)
3134 '.$self->{NOECHO}.'$(NOOP)
3136 config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists
3137 '.$self->{NOECHO}.'$(NOOP)
3139 config :: $(INST_ARCHAUTODIR)/.exists
3140 '.$self->{NOECHO}.'$(NOOP)
3142 config :: $(INST_AUTODIR)/.exists
3143 '.$self->{NOECHO}.'$(NOOP)
3147 config :: Version_check
3148 $self->{NOECHO}\$(NOOP)
3150 } unless $self->{PARENT} or ($self->{PERL_SRC} && $self->{INSTALLDIRS} eq "perl") or $self->{NO_VC};
3152 push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
3154 if (%{$self->{MAN1PODS}}) {
3156 config :: \$(INST_MAN1DIR)/.exists
3157 $self->{NOECHO}\$(NOOP)
3160 push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
3162 if (%{$self->{MAN3PODS}}) {
3164 config :: \$(INST_MAN3DIR)/.exists
3165 $self->{NOECHO}\$(NOOP)
3168 push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
3172 $(O_FILES): $(H_FILES)
3173 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
3177 perldoc ExtUtils::MakeMaker
3182 }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
3183 -MExtUtils::MakeMaker=Version_check \
3184 -e "Version_check('$(MM_VERSION)')"
3192 Obsolete, depecated method. Not used since Version 5.21.
3197 # --- perllocal.pod section ---
3198 my($self,$what,$name,@attribs)=@_;
3199 my $time = localtime;
3200 print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
3201 print join "\n\n=item *\n\n", map("C<$_>",@attribs);
3202 print "\n\n=back\n\n";
3207 Defines the suffix rules to compile XS files to C.
3213 return '' unless $self->needs_linking();
3216 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && $(MV) $*.tc $@
3222 Defines suffix rules to go from XS to object files directly. This is
3223 only intended for broken make implementations.
3227 sub xs_o { # many makes are too dumb to use xs_c then c_o
3229 return '' unless $self->needs_linking();
3232 $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && $(MV) xstmp.c $*.c
3233 $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
3239 This is internal method that returns path to libperl.a equivalent
3240 to be linked to dynamic extensions. UNIX does not have one but OS2
3252 This is internal method that returns name of a file that is
3253 passed to linker to define symbols to be exported.
3254 UNIX does not have one but OS2 and Win32 do.
3270 L<ExtUtils::MakeMaker>