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