home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / perl / Perl / makeaperl.SH < prev    next >
Text File  |  1995-12-03  |  4KB  |  129 lines

  1. case $CONFIG in
  2. '')
  3.     if test -f config.sh; then TOP=.;
  4.     elif test -f ../config.sh; then TOP=..;
  5.     elif test -f ../../config.sh; then TOP=../..;
  6.     elif test -f ../../../config.sh; then TOP=../../..;
  7.     elif test -f ../../../../config.sh; then TOP=../../../..;
  8.     else
  9.         echo "Can't find config.sh."; exit 1
  10.     fi
  11.     . $TOP/config.sh
  12.     ;;
  13. esac
  14. : This forces SH files to create target in same directory as SH file.
  15. : This is so that make depend always knows where to find SH derivatives.
  16. case "$0" in
  17. */*) cd `expr X$0 : 'X\(.*\)/'` ;;
  18. esac
  19. echo "Extracting makeaperl (with variable substitutions)"
  20. rm -f makeaperl
  21. $spitshell >makeaperl <<!GROK!THIS!
  22. #!$binexp/perl
  23. !GROK!THIS!
  24.  
  25. $spitshell >>makeaperl <<'!NO!SUBS!'
  26.  
  27. =head1 NAME
  28.  
  29. makeaperl - create a new perl binary from static extensions
  30.  
  31. =head1 SYNOPSIS
  32.  
  33. C<makeaperl -l library -m makefile -o target -t tempdir [object_files] [static_extensions] [search_directories]>
  34.  
  35. =head1 DESCRIPTION
  36.  
  37. This utility is designed to build new perl binaries from existing
  38. extensions on the fly. Called without any arguments it produces a new
  39. binary with the name C<perl> in the current directory. Intermediate
  40. files are produced in C</tmp>, if that is writeable, else in the
  41. current directory. The most important intermediate file is a Makefile,
  42. that is used internally to call C<make>. The new perl binary will consist
  43.  
  44. The C<-l> switch lets you specify the name of a perl library to be
  45. linked into the new binary. If you do not specify a library, makeaperl
  46. writes targets for any C<libperl*.a> it finds in the search path. The
  47. topmost target will be the one related to C<libperl.a>.
  48.  
  49. With the C<-m> switch you can provide a name for the Makefile that
  50. will be written (default C</tmp/Makefile.$$>). Likewise specifies the
  51. C<-o> switch a name for the perl binary (default C<perl>). The C<-t>
  52. switch lets you determine, in which directory the intermediate files
  53. should be stored.
  54.  
  55. All object files and static extensions following on the command line
  56. will be linked into the target file. If there are any directories
  57. specified on the command line, these directories are searched for
  58. C<*.a> files, and all of the found ones will be linked in, too. If
  59. there is no directory named, then the contents of $INC[0] are
  60. searched.
  61.  
  62. If the command fails, there is currently no other mechanism to adjust
  63. the behaviour of the program than to alter the generated Makefile and
  64. run C<make> by hand.
  65.  
  66. =head1 AUTHORS
  67. Tim Bunce <Tim.Bunce@ig.co.uk>, Andreas Koenig
  68. <koenig@franz.ww.TU-Berlin.DE>; 
  69.  
  70. =head2 STATUS
  71. First version, written 5 Feb 1995, is considered alpha.
  72.  
  73. =cut
  74.  
  75. use ExtUtils::MakeMaker;
  76. use Getopt::Long;
  77. use strict qw(subs refs);
  78.  
  79. $Version = 1.0;
  80. $Verbose = 0;
  81.  
  82. sub usage{
  83.     warn <<END;
  84. $0 version $Version
  85.  
  86. $0: [options] [object_files] [static_extensions ...] [directories to search through]
  87.  -l perllibrary     perl library to link from (the first libperl.a found)
  88.  -m makefilename    name of the makefile to be written (/tmp/Makefile.\$\$)
  89.  -o name            name for perl executable (perl)
  90.  -t directory       directory where intermediate files reside (/tmp)
  91. END
  92.     exit 1;
  93. }
  94.  
  95. if (-w "/tmp") {
  96.     $opt_t = "/tmp";
  97. } else {
  98.     $opt_t = ".";
  99. }
  100. $opt_l = '';
  101. $opt_m = "$opt_t/Makefile.$$";
  102. $opt_o = 'perl';
  103.  
  104. $Getopt::Long::ignorecase=0;
  105.  
  106. GetOptions('t=s', 'l=s', 'm=s', 'o=s') || die &usage;
  107.  
  108. @dirs = grep -d $_, @ARGV;
  109. @fils = grep -f $_, @ARGV;
  110.  
  111. @dirs = $INC[0] unless @dirs;
  112.  
  113. open MAKE, ">$opt_m";
  114. MM->init_main();
  115. MM->init_others();
  116. print MAKE MM->makeaperl('MAKE'    => $opt_m,
  117.              'TARGET'  => $opt_o,
  118.              'TMP'     => $opt_t,
  119.              'LIBPERL' => $opt_l,
  120.              'DIRS'    => [@dirs], 
  121.              'STAT'    => [@fils], 
  122.              'INCL'    => [@dirs]
  123. );
  124. close MAKE;
  125. (system "make -f $opt_m") == 0 or die "$0 failed: Please check file $opt_m and run make -f $opt_m\n";
  126. !NO!SUBS!
  127. chmod 755 makeaperl
  128. $eunicefix makeaperl
  129.