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