home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / SLAKWARE / D12 / PERL1.TGZ / perl1.tar / usr / lib / perl5 / ExtUtils / MakeMaker.pm < prev    next >
Text File  |  1996-06-28  |  55KB  |  1,809 lines

  1. BEGIN {require 5.002;} # MakeMaker 5.17 was the last MakeMaker that was compatible with perl5.001m
  2.  
  3. package ExtUtils::MakeMaker;
  4.  
  5. $Version = $VERSION = "5.34";
  6. $Version_OK = "5.17";    # Makefiles older than $Version_OK will die
  7.             # (Will be checked from MakeMaker version 4.13 onwards)
  8. ($Revision = substr(q$Revision: 1.202 $, 10)) =~ s/\s+$//;
  9.  
  10.  
  11.  
  12. require Exporter;
  13. use Config;
  14. use Carp ();
  15. #use FileHandle ();
  16.  
  17. use vars qw(
  18.  
  19.         @ISA @EXPORT @EXPORT_OK $AUTOLOAD
  20.         $ISA_TTY $Is_Mac $Is_OS2 $Is_VMS $Revision $Setup_done
  21.         $VERSION $Verbose $Version_OK %Config %Keep_after_flush
  22.         %MM_Sections %Prepend_dot_dot %Recognized_Att_Keys
  23.         @Get_from_Config @MM_Sections @Overridable @Parent
  24.  
  25.        );
  26. # use strict;
  27.  
  28. eval {require DynaLoader;};    # Get mod2fname, if defined. Will fail
  29.                                 # with miniperl.
  30.  
  31. #
  32. # Set up the inheritance before we pull in the MM_* packages, because they
  33. # import variables and functions from here
  34. #
  35. @ISA = qw(Exporter);
  36. @EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
  37. @EXPORT_OK = qw($VERSION &Version_check &neatvalue &mkbootstrap &mksymlists
  38.         $Version);
  39.         # $Version in mixed case will go away!
  40.  
  41. #
  42. # Dummy package MM inherits actual methods from OS-specific
  43. # default packages.  We use this intermediate package so
  44. # MY::XYZ->func() can call MM->func() and get the proper
  45. # default routine without having to know under what OS
  46. # it's running.
  47. #
  48. @MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::Liblist ExtUtils::MakeMaker];
  49.  
  50. #
  51. # Setup dummy package:
  52. # MY exists for overriding methods to be defined within
  53. #
  54. {
  55.     package MY;
  56.     @MY::ISA = qw(MM);
  57. ###    sub AUTOLOAD { use Devel::Symdump; print Devel::Symdump->rnew->as_string; Carp::confess "hey why? $AUTOLOAD" }
  58.     package MM;
  59.     sub DESTROY {}
  60. }
  61.  
  62. # "predeclare the package: we only load it via AUTOLOAD
  63. # but we have already mentioned it in @ISA
  64. package ExtUtils::Liblist;
  65.  
  66. package ExtUtils::MakeMaker;
  67. #
  68. # Now we can can pull in the friends
  69. #
  70. $Is_VMS = $^O eq 'VMS';
  71. $Is_OS2 = $^O =~ m|^os/?2$|i;
  72. $Is_Mac = $^O eq 'MacOS';
  73.  
  74. require ExtUtils::MM_Unix;
  75.  
  76. if ($Is_VMS) {
  77.     require ExtUtils::MM_VMS;
  78.     require VMS::Filespec; # is a noop as long as we require it within MM_VMS
  79. }
  80. if ($Is_OS2) {
  81.     require ExtUtils::MM_OS2;
  82. }
  83. if ($Is_Mac) {
  84.     require ExtUtils::MM_Mac;
  85. }
  86.  
  87. # The SelfLoader would bring a lot of overhead for MakeMaker, because
  88. # we know for sure we will use most of the autoloaded functions once
  89. # we have to use one of them. So we write our own loader
  90.  
  91. sub AUTOLOAD {
  92.     my $code;
  93.     if (defined fileno(DATA)) {
  94.     my $fh = select DATA;
  95.     my $o = $/;            # For future reads from the file.
  96.     $/ = "\n__END__\n";
  97.     $code = <DATA>;
  98.     $/ = $o;
  99.     select $fh;
  100.     close DATA;
  101.     eval $code;
  102.     if ($@) {
  103.         $@ =~ s/ at .*\n//;
  104.         Carp::croak $@;
  105.     }
  106.     } else {
  107.     warn "AUTOLOAD called unexpectedly for $AUTOLOAD"; 
  108.     }
  109.     defined(&$AUTOLOAD) or die "Myloader inconsistency error";
  110.     goto &$AUTOLOAD;
  111. }
  112.  
  113. # The only subroutine we do not SelfLoad is Version_Check because it's
  114. # called so often. Loading this minimum still requires 1.2 secs on my
  115. # Indy :-(
  116.  
  117. sub Version_check {
  118.     my($checkversion) = @_;
  119.     die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
  120. Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
  121. changes in the meantime.
  122. Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
  123.     if $checkversion < $Version_OK;
  124.     printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
  125.     $checkversion, "Current Version is", $VERSION
  126.     unless $checkversion == $VERSION;
  127. }
  128.  
  129. sub warnhandler {
  130.     $_[0] =~ /^Use of uninitialized value/ && return;
  131.     $_[0] =~ /used only once/ && return;
  132.     $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
  133.     warn @_;
  134. }
  135.  
  136. sub ExtUtils::MakeMaker::eval_in_subdirs ;
  137. sub ExtUtils::MakeMaker::eval_in_x ;
  138. sub ExtUtils::MakeMaker::full_setup ;
  139. sub ExtUtils::MakeMaker::writeMakefile ;
  140. sub ExtUtils::MakeMaker::new ;
  141. sub ExtUtils::MakeMaker::check_manifest ;
  142. sub ExtUtils::MakeMaker::parse_args ;
  143. sub ExtUtils::MakeMaker::check_hints ;
  144. sub ExtUtils::MakeMaker::mv_all_methods ;
  145. sub ExtUtils::MakeMaker::skipcheck ;
  146. sub ExtUtils::MakeMaker::flush ;
  147. sub ExtUtils::MakeMaker::mkbootstrap ;
  148. sub ExtUtils::MakeMaker::mksymlists ;
  149. sub ExtUtils::MakeMaker::neatvalue ;
  150. sub ExtUtils::MakeMaker::selfdocument ;
  151. sub ExtUtils::MakeMaker::WriteMakefile ;
  152. sub ExtUtils::MakeMaker::prompt ;
  153.  
  154. 1;
  155. #__DATA__
  156. package ExtUtils::MakeMaker;
  157.  
  158. sub WriteMakefile {
  159.     Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
  160.     local $SIG{__WARN__} = \&warnhandler;
  161.  
  162.     unless ($Setup_done++){
  163.     full_setup();
  164.     undef &ExtUtils::MakeMaker::full_setup; #safe memory
  165.     }
  166.     my %att = @_;
  167.     MM->new(\%att)->flush;
  168. }
  169.  
  170. sub prompt ($;$) {
  171.     my($mess,$def)=@_;
  172.     $ISA_TTY = -t STDIN && -t STDOUT ;
  173.     Carp::confess("prompt function called without an argument") unless defined $mess;
  174.     my $dispdef = defined $def ? "[$def] " : " ";
  175.     $def = defined $def ? $def : "";
  176.     my $ans;
  177.     if ($ISA_TTY) {
  178.     local $|=1;
  179.     print "$mess $dispdef";
  180.     chomp($ans = <STDIN>);
  181.     }
  182.     return $ans || $def;
  183. }
  184.  
  185. sub eval_in_subdirs {
  186.     my($self) = @_;
  187.     my($dir);
  188.     use Cwd 'cwd';
  189.     my $pwd = cwd();
  190.  
  191.     foreach $dir (@{$self->{DIR}}){
  192.     my($abs) = $self->catdir($pwd,$dir);
  193.     $self->eval_in_x($abs);
  194.     }
  195.     chdir $pwd;
  196. }
  197.  
  198. sub eval_in_x {
  199.     my($self,$dir) = @_;
  200.     package main;
  201.     chdir $dir or Carp::carp("Couldn't change to directory $dir: $!");
  202. #    use FileHandle ();
  203. #    my $fh = new FileHandle;
  204. #    $fh->open("Makefile.PL") or Carp::carp("Couldn't open Makefile.PL in $dir");
  205.     local *FH;
  206.     open(FH,"Makefile.PL") or Carp::carp("Couldn't open Makefile.PL in $dir");
  207. #    my $eval = join "", <$fh>;
  208.     my $eval = join "", <FH>;
  209. #    $fh->close;
  210.     close FH;
  211.     eval $eval;
  212.     if ($@) {
  213. #       if ($@ =~ /prerequisites/) {
  214. #           die "MakeMaker WARNING: $@";
  215. #       } else {
  216. #           warn "WARNING from evaluation of $dir/Makefile.PL: $@";
  217. #       }
  218.     warn "WARNING from evaluation of $dir/Makefile.PL: $@";
  219.     }
  220. }
  221.  
  222. sub full_setup {
  223.     $Verbose ||= 0;
  224.     $^W=1;
  225.  
  226.     # package name for the classes into which the first object will be blessed
  227.     $PACKNAME = "PACK000";
  228.  
  229.     @Attrib_help = qw/
  230.  
  231.     C CONFIG CONFIGURE DEFINE DIR DISTNAME DL_FUNCS DL_VARS EXE_FILES
  232.     EXCLUDE_EXT INCLUDE_EXT NO_VC FIRST_MAKEFILE FULLPERL H INC
  233.     INSTALLARCHLIB INSTALLBIN INSTALLDIRS INSTALLMAN1DIR
  234.     INSTALLMAN3DIR INSTALLPRIVLIB INSTALLSCRIPT INSTALLSITEARCH
  235.     INSTALLSITELIB INST_ARCHLIB INST_BIN INST_EXE INST_LIB
  236.     INST_MAN1DIR INST_MAN3DIR INST_SCRIPT LDFROM LIBPERL_A LIBS
  237.     LINKTYPE MAKEAPERL MAKEFILE MAN1PODS MAN3PODS MAP_TARGET MYEXTLIB
  238.     NAME NEEDS_LINKING NOECHO NORECURS OBJECT OPTIMIZE PERL PERLMAINCC
  239.     PERL_ARCHLIB PERL_LIB PERL_SRC PL_FILES PM PMLIBDIRS PREFIX
  240.     PREREQ_PM SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG
  241.     XS_VERSION clean depend dist dynamic_lib linkext macro realclean
  242.     tool_autosplit
  243.  
  244.     installpm
  245.  
  246.     /;
  247.  
  248.     # ^^^ installpm is deprecated, will go about Summer 96
  249.  
  250.     # @Overridable is close to @MM_Sections but not identical.  The
  251.     # order is important. Many subroutines declare macros. These
  252.     # depend on each other. Let's try to collect the macros up front,
  253.     # then pasthru, then the rules.
  254.  
  255.     # MM_Sections are the sections we have to call explicitly
  256.     # in Overridable we have subroutines that are used indirectly
  257.  
  258.  
  259.     @MM_Sections = 
  260.     qw(
  261.  
  262.  post_initialize const_config constants tool_autosplit tool_xsubpp
  263.  tools_other dist macro depend cflags const_loadlibs const_cccmd
  264.  post_constants
  265.  
  266.  pasthru
  267.  
  268.  c_o xs_c xs_o top_targets linkext dlsyms dynamic dynamic_bs
  269.  dynamic_lib static static_lib manifypods processPL installbin subdirs
  270.  clean realclean dist_basics dist_core dist_dir dist_test dist_ci
  271.  install force perldepend makefile staticmake test
  272.  
  273.       ); # loses section ordering
  274.  
  275.     @Overridable = @MM_Sections;
  276.     push @Overridable, qw[
  277.  
  278.  dir_target libscan makeaperl needs_linking subdir_x test_via_harness
  279.  test_via_script
  280.  
  281.              ];
  282.  
  283.     push @MM_Sections, qw[
  284.  
  285.  pm_to_blib selfdocument
  286.  
  287.              ];
  288.  
  289.     # Postamble needs to be the last that was always the case
  290.     push @MM