summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Bunce <Tim.Bunce@ig.co.uk>1995-01-17 04:09:00 +0000
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1995-01-17 04:09:00 +0000
commit3edbfbe5ecbb7e6fb99acc874379580a458f3cff (patch)
tree0fef803084e171ed4d85c12a817e59d493f77612
parente1666bf5602ae794563d8669f6ff15c398321bac (diff)
downloadperl-3edbfbe5ecbb7e6fb99acc874379580a458f3cff.tar.gz
MakeMaker 3.8
-rw-r--r--Changes2
-rwxr-xr-xConfigure4
-rw-r--r--MANIFEST7
-rw-r--r--Makefile.SH6
-rwxr-xr-xembed_h.sh (renamed from embed_h.SH)0
-rw-r--r--ext/DB_File/DB_File.pm2
-rw-r--r--ext/Fcntl/Fcntl.pm2
-rw-r--r--ext/GDBM_File/GDBM_File.pm2
-rw-r--r--ext/POSIX/POSIX.pm2
-rw-r--r--ext/Socket/Socket.pm2
-rwxr-xr-xh2xs228
-rwxr-xr-xinstallperl27
-rw-r--r--lib/AutoSplit.pm33
-rw-r--r--lib/Cwd.pm8
-rw-r--r--lib/ExtUtils/MakeMaker.pm426
-rw-r--r--lib/ExtUtils/typemap (renamed from ext/typemap)0
-rwxr-xr-xlib/ExtUtils/xsubpp (renamed from ext/xsubpp)0
-rwxr-xr-xx2p/Makefile.SH2
-rw-r--r--x2p/malloc.c466
19 files changed, 435 insertions, 784 deletions
diff --git a/Changes b/Changes
index ac5349f2ec..466332e0fd 100644
--- a/Changes
+++ b/Changes
@@ -15,7 +15,7 @@ New things
meaning the parens are optional. Even subroutines may be called as
list operators if they've already been declared.
- More embeddible. See main.c and embed_h.SH. Multiple interpreters
+ More embeddible. See main.c and embed_h.sh. Multiple interpreters
in the same process are supported (though not with interleaved
execution yet).
diff --git a/Configure b/Configure
index 10dd65db12..3d3b38da5c 100755
--- a/Configure
+++ b/Configure
@@ -6320,7 +6320,9 @@ $cc $ccflags -c bar1.c >/dev/null 2>&1
$cc $ccflags -c bar2.c >/dev/null 2>&1
$cc $ccflags -c foo.c >/dev/null 2>&1
ar rc bar.a bar2.o bar1.o >/dev/null 2>&1
-if $cc $ccflags $ldflags -o foobar foo.o bar.a $libs > /dev/null 2>&1 &&
+if test -n "$ranlib" ; then
+ orderlib=false
+elif $cc $ccflags $ldflags -o foobar foo.o bar.a $libs > /dev/null 2>&1 &&
./foobar >/dev/null 2>&1; then
echo "ar appears to generate random libraries itself."
orderlib=false
diff --git a/MANIFEST b/MANIFEST
index f42df72a40..735fb41fb5 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -79,7 +79,7 @@ emacs/perldb.el Emacs debugging
emacs/perldb.pl Emacs debugging
emacs/tedstuff Some optional patches
embed.h Maps symbols to safer names
-embed_h.SH Produces embed.h
+embed_h.sh Produces embed.h
ext/DB_File/DB_File.pm Berkeley DB extension Perl module
ext/DB_File/DB_File.xs Berkeley DB extension external subroutines
ext/DB_File/DB_File_BS Berkeley DB extension mkbootstrap fodder
@@ -150,11 +150,9 @@ ext/SDBM_File/typemap SDBM extension interface types
ext/Socket/Makefile.PL Socket extension makefile writer
ext/Socket/Socket.pm Socket extension Perl module
ext/Socket/Socket.xs Socket extension external subroutines
-ext/typemap Extension interface types
ext/util/extliblist Used by extension Makefile.PL to make lib lists
ext/util/make_ext Used by Makefile to execute extension Makefiles
ext/util/mkbootstrap Turns ext/*/*_BS into bootstrap info
-ext/xsubpp External subroutine preprocessor
form.h Public declarations for the above
global.sym Symbols that need hiding when embedded
gv.c Glob value code
@@ -239,6 +237,8 @@ lib/English.pm Readable aliases for short variables
lib/Env.pm Map environment into ordinary variables
lib/Exporter.pm Exporter base class
lib/ExtUtils/MakeMaker.pm Write Makefiles for extensions
+lib/ExtUtils/typemap Extension interface types
+lib/ExtUtils/xsubpp External subroutine preprocessor
lib/File/Basename.pm A module to emulate the basename program
lib/File/CheckTree.pm Perl module supporting wholesale file mode validation
lib/File/Find.pm Routines to do a find
@@ -533,7 +533,6 @@ x2p/find2perl.SH A find to perl translator
x2p/handy.h Handy definitions
x2p/hash.c Associative arrays again
x2p/hash.h Public declarations for the above
-x2p/malloc.c Malloc code
x2p/s2p.SH Sed to perl translator
x2p/s2p.man Manual page for sed to perl translator
x2p/str.c String handling package
diff --git a/Makefile.SH b/Makefile.SH
index 4608ab2396..1144176ec8 100644
--- a/Makefile.SH
+++ b/Makefile.SH
@@ -115,7 +115,7 @@ manpages = perl.man
util =
-sh = Makefile.SH cflags.SH embed_h.SH makedepend.SH makedir.SH writemain.SH
+sh = Makefile.SH cflags.SH makedepend.SH makedir.SH writemain.SH
h1 = EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h dosish.h
h2 = embed.h form.h gv.h handy.h hv.h keywords.h mg.h op.h
@@ -215,8 +215,8 @@ sperl.o: perl.c perly.h patchlevel.h $(h)
opcode.h: opcode.pl
- perl opcode.pl
-embed.h: embed_h.SH global.sym interp.sym
- sh embed_h.SH
+embed.h: embed_h.sh global.sym interp.sym
+ sh embed_h.sh
preplibrary: miniperl lib/Config.pm
@test -d lib/auto || mkdir lib/auto
diff --git a/embed_h.SH b/embed_h.sh
index 159ab0ed81..159ab0ed81 100755
--- a/embed_h.SH
+++ b/embed_h.sh
diff --git a/ext/DB_File/DB_File.pm b/ext/DB_File/DB_File.pm
index d66ab2cabe..af56cc0548 100644
--- a/ext/DB_File/DB_File.pm
+++ b/ext/DB_File/DB_File.pm
@@ -179,7 +179,7 @@ require TieHash;
require Exporter;
require AutoLoader;
require DynaLoader;
-@ISA = (TieHash, Exporter, AutoLoader, DynaLoader);
+@ISA = (TieHash, Exporter, DynaLoader);
@EXPORT = qw(
$DB_BTREE $DB_HASH $DB_RECNO
BTREEMAGIC
diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm
index c4fd2ff550..d55d4e30bd 100644
--- a/ext/Fcntl/Fcntl.pm
+++ b/ext/Fcntl/Fcntl.pm
@@ -3,7 +3,7 @@ package Fcntl;
require Exporter;
require AutoLoader;
require DynaLoader;
-@ISA = (Exporter, AutoLoader, DynaLoader);
+@ISA = (Exporter, DynaLoader);
# Items to export into callers namespace by default
# (move infrequently used names to @EXPORT_OK below)
@EXPORT =
diff --git a/ext/GDBM_File/GDBM_File.pm b/ext/GDBM_File/GDBM_File.pm
index 23422f7a2e..99b6390e80 100644
--- a/ext/GDBM_File/GDBM_File.pm
+++ b/ext/GDBM_File/GDBM_File.pm
@@ -5,7 +5,7 @@ require TieHash;
require Exporter;
require AutoLoader;
require DynaLoader;
-@ISA = (TieHash, Exporter, AutoLoader, DynaLoader);
+@ISA = (TieHash, Exporter, DynaLoader);
@EXPORT = qw(
GDBM_CACHESIZE
GDBM_FAST
diff --git a/ext/POSIX/POSIX.pm b/ext/POSIX/POSIX.pm
index 3fa292df6a..4ccc5ce520 100644
--- a/ext/POSIX/POSIX.pm
+++ b/ext/POSIX/POSIX.pm
@@ -5,7 +5,7 @@ require Exporter;
require AutoLoader;
require DynaLoader;
require Config;
-@ISA = (Exporter, AutoLoader, DynaLoader);
+@ISA = (Exporter, DynaLoader);
$H{assert_h} = [qw(assert NDEBUG)];
diff --git a/ext/Socket/Socket.pm b/ext/Socket/Socket.pm
index a05c0a0a0c..a129ec694e 100644
--- a/ext/Socket/Socket.pm
+++ b/ext/Socket/Socket.pm
@@ -4,7 +4,7 @@ use Carp;
require Exporter;
require AutoLoader;
require DynaLoader;
-@ISA = (Exporter, AutoLoader, DynaLoader);
+@ISA = (Exporter, DynaLoader);
@EXPORT = qw(
AF_802
AF_APPLETALK
diff --git a/h2xs b/h2xs
index b4d8da94e0..401600a8a1 100755
--- a/h2xs
+++ b/h2xs
@@ -1,16 +1,114 @@
#!/usr/bin/perl
-'di ';
-'ds 00 \"';
-'ig 00 ';
+
+=head1 NAME
+
+h2xs - convert .h C header files to Perl extensions
+
+=head1 SYNOPSIS
+
+B<h2xs> [B<-Acfh>] [B<-n> module_name] [headerfile [extra_libraries]]
+
+=head1 DESCRIPTION
+
+I<h2xs> builds a Perl extension from any C header file. The extension will
+include functions which can be used to retrieve the value of any #define
+statement which was in the C header.
+
+The I<module_name> will be used for the name of the extension. If
+module_name is not supplied then the name of the header file will be used,
+with the first character capitalized.
+
+If the extension might need extra libraries, they should be included
+here. The extension Makefile.PL will take care of checking whether
+the libraries actually exist and how they should be loaded.
+The extra libraries should be specified in the form -lm -lposix, etc,
+just as on the cc command line. By default, the Makefile.PL will
+search through the library path determined by Configure. That path
+can be augmented by including arguments of the form B<-L/another/library/path>
+in the extra-libraries argument.
+
+=head1 OPTIONS
+
+=over 5
+
+=item B<-n> I<module_name>
+
+Specifies a name to be used for the extension, e.g., S<-n RPC::DCE>
+
+=item B<-f>
+
+Allows an extension to be created for a header even if that header is
+not found in /usr/include.
+
+=item B<-c>
+
+Omit C<constant()> from the .xs file and corresponding specialised
+C<AUTOLOAD> from the .pm file.
+
+=item B<-A>
+
+Omit all autoload facilities. This is the same as B<-c> but also removes the
+S<C<require AutoLoader>> statement from the .pm file.
+
+=back
+
+=head1 EXAMPLES
+
+
+ # Default behavior, extension is Rusers
+ h2xs rpcsvc/rusers
+
+ # Same, but extension is RUSERS
+ h2xs -n RUSERS rpcsvc/rusers
+
+ # Extension is rpcsvc::rusers. Still finds <rpcsvc/rusers.h>
+ h2xs rpcsvc::rusers
+
+ # Extension is ONC::RPC. Still finds <rpcsvc/rusers.h>
+ h2xs -n ONC::RPC rpcsvc/rusers
+
+ # Without constant() or AUTOLOAD
+ h2xs -c rpcsvc/rusers
+
+ # Creates templates for an extension named RPC
+ h2xs -cfn RPC
+
+ # Extension is ONC::RPC.
+ h2xs -cfn ONC::RPC
+
+ # Makefile.PL will look for library -lrpc in
+ # additional directory /opt/net/lib
+ h2xs rpcsvc/rusers -L/opt/net/lib -lrpc
+
+
+=head1 ENVIRONMENT
+
+No environment variables are used.
+
+=head1 AUTHOR
+
+Larry Wall and others
+
+=head1 SEE ALSO
+
+L<perl>, L<ExtUtils::MakeMaker>, L<AutoLoader>
+
+=head1 DIAGNOSTICS
+
+The usual warnings if it can't read or write the files involved.
+
+=cut
+
use Getopt::Std;
sub usage{
warn "@_\n" if @_;
- die 'h2xs [-fnch] [-n module_name] [headerfile [extra_libraries]]
+ die 'h2xs [-Acfh] [-n module_name] [headerfile [extra_libraries]]
-f Force creation of the extension even if the C header does not exist.
-n Specify a name to use for the extension (recommended).
-c Omit the constant() function and specialised AUTOLOAD from the XS file.
+ -A Omit all autoloading facilities (implies -c).
-h Display this help message
extra_libraries
are any libraries that might be needed for loading the
@@ -19,7 +117,7 @@ extra_libraries
}
-getopts("fhcAn:") || usage;
+getopts("Acfhn:") || usage;
usage if $opt_h;
$opt_c = 1 if $opt_A;
@@ -96,11 +194,33 @@ print PM <<"END";
package $module;
require Exporter;
-require AutoLoader;
require DynaLoader;
+END
+
+if( ! $opt_A ){
+ print PM <<"END";
+require AutoLoader;
+END
+}
+
+if( $opt_c && ! $opt_A ){
+ # we won't have our own AUTOLOAD(), so we'll inherit it.
+ print PM <<"END";
\@ISA = qw(Exporter AutoLoader DynaLoader);
+END
+}
+else{
+ # 1) we have our own AUTOLOAD(), so don't need to inherit it.
+ # or
+ # 2) we don't want autoloading mentioned.
+ print PM <<"END";
+
+\@ISA = qw(Exporter DynaLoader);
+END
+}
+print PM<<"END";
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@@ -115,8 +235,9 @@ END
print PM <<"END" unless $opt_c;
sub AUTOLOAD {
- # This AUTOLOAD function overrides the one inherited from AutoLoader.
- # It is used to 'autoload' constants from the constant() XS function.
+ # This AUTOLOAD is used to 'autoload' constants from the constant()
+ # XS function. If a constant is not found then control is passed
+ # to the AUTOLOAD in AutoLoader.
# NOTE: THIS AUTOLOAD FUNCTION IS FLAWED (but is the best we can do for now).
# Avoid old-style ``&CONST'' usage. Either remove the ``&'' or add ``()''.
@@ -274,94 +395,3 @@ print PL ");\n";
system '/bin/ls > MANIFEST';
-
-
-##############################################################################
-
- # These next few lines are legal in both Perl and nroff.
-
-.00 ; # finish .ig
-
-'di \" finish diversion--previous line must be blank
-.nr nl 0-1 \" fake up transition to first page again
-.nr % 0 \" start at page 1
-'; __END__ ############# From here on it's a standard manual page ############
-.TH H2XS 1 "August 9, 1994"
-.AT 3
-.SH NAME
-h2xs \- convert .h C header files to Perl extensions
-.SH SYNOPSIS
-.B h2xs [-Aachfm] [-n module_name] [headerfile [extra_libraries]]
-.SH DESCRIPTION
-.I h2xs
-builds a Perl extension from any C header file. The extension will include
-functions which can be used to retrieve the value of any #define statement
-which was in the C header.
-.PP
-The
-.I module_name
-will be used for the name of the extension. If module_name is not supplied
-then the name of the header file will be used, with the first character
-capitalized.
-.PP
-If the extension might need extra libraries, they should be included
-here. The extension Makefile.PL will take care of checking whether
-the libraries actually exist and how they should be loaded.
-The extra libraries should be specified in the form -lm -lposix, etc,
-just as on the cc command line. By default, the Makefile.PL will
-search through the library path determined by Configure. That path
-can be augmented by including arguments of the form -L/another/library/path
-in the extra-libraries argument.
-.SH OPTIONS
-.TP
-.B \-n module_name
-Specifies a name to be used for the extension, e.g., -n RPC::DCE
-.TP
-.B \-f
-Allows an extension to be created for a header even if that header is
-not found in /usr/include.
-.TP
-.B \-c
-Omit constant() from the .xs file and corresponding specialised AUTOLOAD from
-the .pm file.
-.TP
-.B \-A
-Deprecated synonym for -c.
-.SH EXAMPLES
-.nf
-
- # Default behavior, extension is Rusers
- h2xs rpcsvc/rusers
-
- # Same, but extension is RUSERS
- h2xs -n RUSERS rpcsvc/rusers
-
- # Extension is rpcsvc::rusers. Still finds <rpcsvc/rusers.h>
- h2xs rpcsvc::rusers
-
- # Extension is ONC::RPC. Still finds <rpcsvc/rusers.h>
- h2xs -n ONC::RPC rpcsvc/rusers
-
- # Without constant() or AUTOLOAD
- h2xs -c rpcsvc/rusers
-
- # Creates templates for an extension named RPC
- h2xs -cfn RPC
-
- # Extension is ONC::RPC.
- h2xs -cfn ONC::RPC
-
- # Makefile.PL will look for library -lrpc in
- # additional directory /opt/net/lib
- h2xs rpcsvc/rusers -L/opt/net/lib -lrpc
-
-.fi
-.SH ENVIRONMENT
-No environment variables are used.
-.SH AUTHOR
-Larry Wall and others
-.SH "SEE ALSO"
-perl(1) ExtUtils::MakeMaker
-.SH DIAGNOSTICS
-The usual warnings if it can't read or write the files involved.
-.ex
diff --git a/installperl b/installperl
index 4fc145206c..fb4bb05242 100755
--- a/installperl
+++ b/installperl
@@ -48,7 +48,7 @@ if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
$installbin || die "No installbin directory in config.sh\n";
-d $installbin || die "$installbin is not a directory\n";
-w $installbin || die "$installbin is not writable by you\n"
- unless $installbin =~ m#^/afs/#;
+ unless $installbin =~ m#^/afs/# || $nonono;
-x 'perl' || die "perl isn't executable!\n";
-x 'suidperl' || die "suidperl isn't executable!\n" if $d_dosuid;
@@ -148,6 +148,12 @@ else {
warn "Can't cd to lib to install lib files: $!\n";
}
+# Install header files
+makedir("$installarchlib/CORE");
+foreach $file (<*.h libperl*.a>) {
+ cp_if_diff($file,"$installarchlib/CORE/$file");
+}
+
# Offer to install perl in a "standard" location
($udev,$uino) = stat($mainperldir);
@@ -300,12 +306,18 @@ sub installlib {
return unless $do_installprivlib;
}
- &makedir("$installlib/$dir");
-
if (-f $_) {
+ if (/\.al$/ || /\.ix$/) {
+ $installlib = $installprivlib;
+ #We're installing *.al and *.ix files into $installprivlib,
+ #but we have to delete old *.al and *.ix files from the 5.000
+ #distribution:
+ &unlink("$installarchlib/$name");
+ }
system "cmp", "-s", $_, "$installlib/$name";
if ($?) {
&unlink("$installlib/$name");
+ &makedir("$installlib/$dir");
&cmd("cp $_ $installlib/$dir");
&chmod(0644, "$installlib/$name");
}
@@ -313,3 +325,12 @@ sub installlib {
&makedir("$installlib/$name");
}
}
+
+sub cp_if_diff {
+ my($from,$to)=@_;
+ -f $from || die "$0: $from not found";
+ system "cmp", "-s", $from, $to;
+ if ($?) {
+ cmd("cp $from $to");
+ }
+}
diff --git a/lib/AutoSplit.pm b/lib/AutoSplit.pm
index 9867cffab7..71115c6c8c 100644
--- a/lib/AutoSplit.pm
+++ b/lib/AutoSplit.pm
@@ -8,25 +8,27 @@ use Carp;
@ISA = qw(Exporter);
@EXPORT = qw(&autosplit &autosplit_lib_modules);
-@EXPORT_OK = qw($Verbose $Keep);
+@EXPORT_OK = qw($Verbose $Keep $Maxlen $CheckForAutoloader $CheckModTime);
# for portability warn about names longer than $maxlen
$Maxlen = 8; # 8 for dos, 11 (14-".al") for SYSVR3
$Verbose = 1; # 0=none, 1=minimal, 2=list .al files
$Keep = 0;
-$IndexFile = "autosplit.ix"; # file also serves as timestamp
+$CheckForAutoloader = 1;
+$CheckModTime = 1;
+$IndexFile = "autosplit.ix"; # file also serves as timestamp
$maxflen = 255;
$maxflen = 14 if $Config{'d_flexfnam'} ne 'define';
$vms = ($Config{'osname'} eq 'VMS');
+
sub autosplit{
my($file, $autodir) = @_;
- autosplit_file($file, $autodir, $Keep, 1, 0);
+ autosplit_file($file, $autodir, $Keep, $CheckForAutoloader, $CheckModTime);
}
-
# This function is used during perl building/installation
# ./miniperl -e 'use AutoSplit; autosplit_modules(@ARGV)' ...
@@ -42,7 +44,7 @@ sub autosplit_lib_modules{
$dir =~ s#[\.\]]#/#g;
$_ = $dir . $name;
}
- autosplit_file("lib/$_", "lib/auto", $Keep, 1, 1);
+ autosplit_file("lib/$_", "lib/auto", $Keep, $CheckForAutoloader, $CheckModTime);
}
0;
}
@@ -56,7 +58,18 @@ sub autosplit_file{
# where to write output files
$autodir = "lib/auto" unless $autodir;
- die "autosplit directory $autodir does not exist" unless -d $autodir;
+ unless (-d $autodir){
+ local($", @p)="/";
+ foreach(split(/\//,$autodir)){
+ push(@p, $_);
+ next if -d "@p/";
+ mkdir("@p",0755) or die "AutoSplit unable to mkdir @p: $!";
+ }
+ # We should never need to create the auto dir here. installperl
+ # (or similar) should have done it. Expecting it to exist is a valuable
+ # sanity check against autosplitting into some random directory by mistake.
+ print "Warning: AutoSplit had to create top-level $autodir unexpectedly.\n";
+ }
# allow just a package name to be used
$filename .= ".pm" unless ($filename =~ m/\.pm$/);
@@ -67,11 +80,15 @@ sub autosplit_file{
while (<IN>) {
# record last package name seen
$package = $1 if (m/^\s*package\s+([\w:]+)\s*;/);
- ++$autoloader_seen if m/^\s*use\s+AutoLoader\b/;
+ ++$autoloader_seen if m/^\s*(use|require)\s+AutoLoader\b/;
++$autoloader_seen if m/\bISA\s*=.*\bAutoLoader\b/;
+ ++$autoloader_seen if m/^\s*sub\s+AUTOLOAD\b/;
last if /^__END__/;
}
- return 0 if ($check_for_autoloader && !$autoloader_seen);
+ if ($check_for_autoloader && !$autoloader_seen){
+ print "AutoSplit skipped $filename: no AutoLoader used\n" if ($Verbose>=2);
+ return 0
+ }
$_ or die "Can't find __END__ in $filename\n";
$package or die "Can't find 'package Name;' in $filename\n";
diff --git a/lib/Cwd.pm b/lib/Cwd.pm
index 12c2e16368..9aa57ecad4 100644
--- a/lib/Cwd.pm
+++ b/lib/Cwd.pm
@@ -46,8 +46,8 @@ sub getcwd
{
do
{
- unless ($dir = readdir(PARENT))
- {
+ unless (defined ($dir = readdir(PARENT)))
+ {
warn "readdir($dotdots): $!";
closedir(PARENT);
return '';
@@ -65,7 +65,7 @@ sub getcwd
$cwd = "$dir/$cwd";
closedir(PARENT);
} while ($dir);
- chop($cwd);
+ chop($cwd); # drop the trailing /
$cwd;
}
@@ -95,7 +95,7 @@ sub fastcwd {
next if $_ eq '.';
next if $_ eq '..';
- last unless $_;
+ last unless defined;
($tdev, $tino) = lstat($_);
last unless $tdev != $odev || $tino != $oino;
}
diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm
index 7172dbdf2a..1631477ec5 100644
--- a/lib/ExtUtils/MakeMaker.pm
+++ b/lib/ExtUtils/MakeMaker.pm
@@ -1,6 +1,6 @@
package ExtUtils::MakeMaker;
-$Version = 3.7; # Last edited 19th Dec 1994 by Tim Bunce
+$Version = 3.8; # Last edited 17th Jan 1995 by Andreas Koenig
use Config;
use Carp;
@@ -8,8 +8,10 @@ use Cwd;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(&WriteMakefile &mkbootstrap $Verbose &writeMakefile);
-@EXPORT_OK = qw($Version %att %skip %Recognized_Att_Keys @MM_Sections %MM_Sections);
+@EXPORT = qw(&WriteMakefile &mkbootstrap $Verbose);
+@EXPORT_OK = qw($Version %att %skip %Recognized_Att_Keys
+ @MM_Sections %MM_Sections
+ &help &lsdir);
$Is_VMS = $Config{'osname'} eq 'VMS';
require ExtUtils::MM_VMS if $Is_VMS;
@@ -28,6 +30,7 @@ ExtUtils::MakeMaker - create an extension Makefile
=head1 SYNOPSIS
use ExtUtils::MakeMaker;
+
WriteMakefile( ATTRIBUTE => VALUE [, ...] );
=head1 DESCRIPTION
@@ -42,23 +45,37 @@ it wishes to have written to the Makefile.
=head2 Default Makefile Behaviour
-This section (not yet written) will describe how a default Makefile will behave.
+The automatically generated Makefile enables the user of the extension
+to invoke
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+(This section is yet to be completed ...)
=head2 Determination of Perl Library and Installation Locations
MakeMaker needs to know, or to guess, where certain things are located.
Especially INST_LIB, INST_ARCHLIB, PERL_LIB, PERL_ARCHLIB and PERL_SRC.
-Because installperl does not currently install header files (etc) into
-the library the Perl source code must be available when building
-extensions. Currently MakeMaker will default PERL_LIB and PERL_ARCHLIB
-to PERL_SRC/lib. Later, once installperl does install header files
-(etc) into the library, PERL_*LIB will only default to PERL_SRC/lib if
-the extension is in PERL_SRC/ext/* (e.g., a standard extension).
-Otherwise PERL_*LIB and PERL_SRC will default to the public library
-locations.
+Extensions may be built anywhere within the file system after perl has
+been installed correctly. Before perl is installed extensions have to
+be built below the C<ext/> directory within the tree of the perl
+source, i.e. where all the standard extensions are being built. The
+generated Makefile will recognize, which of the two is the current
+configuration and will set some variables accordingly.
+
+Only if the extension is being built in PERL_SRC/ext, the variable
+PERL_SRC is defined, otherwise it is undefined. Consequently
+MakeMaker will default PERL_LIB and PERL_ARCHLIB to PERL_SRC/lib only
+if PERL_SRC is defined, otherwise PERL_*LIB will default to the public
+library locations.
-INST_LIB and INST_ARCHLIB default to PERL_LIB and PERL_ARCHLIB.
+INST_LIB and INST_ARCHLIB default to PERL_LIB and PERL_ARCHLIB if we
+are building below the PERL_SRC/ext directory. Else they default to
+./blib.
=head2 Useful Default Makefile Macros
@@ -68,17 +85,21 @@ BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD)
-PERL_LIB
+PERL_LIB = Directory where we read the perl library files
-PERL_ARCHLIB
+PERL_ARCHLIB = Same as above for architecture dependent files
-INST_LIB
+INST_LIB = Directory where we put library files of this extension
+ while building it. If we are building below PERL_SRC/ext
+ we default to PERL_SRC/lib, else we default to ./blib.
-INST_ARCHLIB
+INST_ARCHLIB = Same as above for architecture dependent files
-INST_LIBDIR = $(INST_LIB)$(ROOTEXT) (and INST_ARCHLIBDIR)
+INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
-INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) (and INST_ARCHAUTODIR)
+INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
+
+INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
=head2 Customizing The Generated Makefile
@@ -90,7 +111,9 @@ using the mechanisms described below.
The following attributes can be specified as arguments to WriteMakefile()
or as NAME=VALUE pairs on the command line:
-(not yet complete)
+This description is not yet documented; you can get at the description
+with the command
+ perl -e 'use ExtUtils::MakeMaker qw(&help); &help;'
=head2 Overriding MakeMaker Methods
@@ -108,7 +131,7 @@ or you can edit the default by saying something like:
If you still need a different solution, try to develop another
subroutine, that fits your needs and submit the diffs to
-perl5-porters@isu.edu or comp.lang.perl as appropriate.
+perl5-porters@nicoh.com or comp.lang.perl as appropriate.
=head1 AUTHORS
@@ -118,106 +141,15 @@ Andy Dougherty <doughera@lafcol.lafayette.edu>, Andreas Koenig
=head1 MODIFICATION HISTORY
-v1, August 1994; by Andreas Koenig.
-
-Initial version. Based on Andy Dougherty's Makefile.SH work.
-
-v2, September 1994; by Tim Bunce.
-
-Use inheritance to implement overriding. Methods return text so
-derived methods can edit it before it's output. mkbootstrap() now
-executes the *_BS file in the DynaLoader package and automatically adds
-dl_findfile() if required. More support for nested modules.
-
-v3.0, October/November 1994; by Tim Bunce.
-
-Major reorganisation. Fixed perl binary locating code. Replaced single
-$(TOP) with $(PERL_SRC), $(PERL_LIB) and $(INST_LIB). Restructured
-code. Consolidated and/or eliminated several attributes and added
-argument name checking. Added initial pod documentation. Made generated
-Makefile easier to read. Added generic mechanism for passing parameters
-to specific sections of the Makefile. Merged in Andreas's perl version
-of Andy's extliblist.
-
-v3.1 November 11th 1994 by Tim Bunce
-
-Fixed AIX dynamic loading problem for nested modules. Fixed perl
-extliblist to give paths not names for libs so that cross-check works.
-Converted the .xs to .c translation to a suffix rule. Added a .xs.o
-rule for dumb makes. Added very useful PM, XS and DIR attributes. Used
-new attributes to make other sections smarter (especially clean and
-realclean). Make clean no longer deletes Makefile so that a later make
-realclean can still work. Fixed all known problems. Write temporary
-Makefile as Makefile.new and rename once complete.
-
-v3.2 November 18th 1994 By Tim Bunce
-
-Fixed typos, added makefile section (split out of a flattened
-perldepend section). Added subdirectories to test section. Added -lm
-fix for NeXT in extliblist. Added clean of *~ files. Tidied up clean
-and realclean sections to produce fewer lines. Major revision to the
-const_loadlibs comments for EXTRALIBS, LDLOADLIBS and BSLOADLIBS.
-Added LINKTYPE=\$(LINKTYPE) to subdirectory make invocations.
-Write temporary Makefile as MakeMaker.tmp. Write temporary xsubpp
-output files as xstmp.c instead of tmp. Now installs multiple PM files.
-Improved parsing of NAME=VALUE args. $(BOOTSTRAP) is now a dependency
-of $(INST_DYNAMIC). Improved init of PERL_LIB, INST_LIB and PERL_SRC.
-Reinstated $(TOP) for transition period. Removed CONFIG_SH attribute
-(no longer used). Put INST_PM back and include .pm and .pl files in
-current and lib directory. Allow OBJECT to contain newlines. ROOTEXT
-now has leading slash. Added INST_LIBDIR (containing ROOTEXT) and
-renamed AUTOEXT to INST_AUTO. Assorted other cosmetic changes.
-All known problems fixed.
-
-v3.3 November 27th 1994 By Andreas Koenig
-
-Bug fixes submitted by Michael Peppler and Wayne Scott. Changed the
-order how @libpath is constructed in C<new_extliblist()>. Improved
-pod-structure. Relative paths in C<-L> switches to LIBS are turned into
-absolute ones now. Included VMS support thanks to submissions by
-Charles Bailey. Added warnings for switches other than C<-L> or C<-l>
-in new_extliblist() and if a library is not found at all. Changed
-dependency distclean:clean to distclean:realclean. Added dependency
-all->config. ext.libs is now written without duplicates and empty
-lines. As old_extliblist() and new_extliblist() do not produce the
-same anymore, the default becomes new_extliblist(), though the warning
-remains, whenever they differ. The use of cflags is accompanied by a
-replacement: there will be a warning when the two routines lead to
-different results, but still the output of cflags will be used.
-Cosmetic changes (Capitalize globals, uncapitalize others, insert a
-C<:> as default for $postop). Added some verbosity.
-
-v3.4 December 7th 1994 By Andreas Koenig and Tim Bunce
-
-Introduced ARCH_LIB and required other perl files to be patched.
-
-v3.5 December 15th 1994 By Tim Bunce
-
-Based primarily on v3.3. Replaced ARCH_LIB with INST_ARCHLIB, which
-defaults to INST_LIB, because the rest of perl assumes that ./lib
-includes architecture dependent files. Ideally an ./archlib should
-exist, that would be more consistent and simplify installperl.
-Added linkext and $(INST_PM) dependencies to all: target. The linkext
-target (and subroutine) exists solely to depend on $(LINKTYPE). Any
-Makefile.PLs using LINKTYPE => '...' where '...' is not 'static' or
-'dynamic' should be changed to use 'linkext' => { LINKTYPE => '...' }.
-
-Automatic determination of PERL_* and INST_* has been revised. The
-INST_* macros have INST_ARCH* and INST_*DIR variants. The ARCH variants
-point to the architecture specific directory and the *DIR variants
-include the module specific subdirectory path. So INST_AUTO is now
-INST_AUTODIR and an INST_ARCHAUTODIR has also been defined.
-
-An AUTOSPLITFILE tool macro has been defined which will AutoSplit any
-named file into any named auto directory. This replaces AUTOSPLITLIB.
-MKPATH now accepts multiple paths. The paths INST_LIBDIR,
-INST_ARCHLIBDIR, INST_AUTODIR and INST_ARCHAUTODIR are made by the
-config: target. A new ext.libs mechanism has been added. installpm has
-been split and now calls installpm_x per file. A section attribute
-mechanism has been added and skip cross-checking has been moved into a
-skipcheck function. MakeMaker now uses Cwd and File::Basename modules.
-
-v3.6 December 15th 1994 By Tim Bunce
+v1, August 1994; by Andreas Koenig. Based on Andy Dougherty's Makefile.SH.
+v2, September 1994 by Tim Bunce.
+v3.0 October 1994 by Tim Bunce.
+v3.1 November 11th 1994 by Tim Bunce.
+v3.2 November 18th 1994 by Tim Bunce.
+v3.3 November 27th 1994 by Andreas Koenig.
+v3.4 December 7th 1994 by Andreas Koenig and Tim Bunce.
+v3.5 December 15th 1994 by Tim Bunce.
+v3.6 December 15th 1994 by Tim Bunce.
Added C and H attributes and corresponding macros. These default to the
list of *.c and *.h files in the directory. C also includes *.c file
@@ -232,6 +164,75 @@ only read a non-empty bootstrap file. Subdirectory dependencies have
been improved. The .c files produced from .xs files now depend on
XSUBPPDEPS (the typemaps).
+v3.7 December 30th By Tim Bunce
+
+Most, if not all, the MakeMaker support for no perl source is now
+included. Recent ld and mkbootstrap patches applied. -lX11_s suffix
+fix applied.
+
+Also contained patches to Makefile.SH, ext/DynaLoader/DynaLoader.pm,
+ext/util/make_ext, and h2xs
+
+v3.8 January 9th By Andreas Koenig and Tim Bunce
+
+- Introduces ./blib as the directory, where the ready-to-use module
+will live for the time of the building process if PERL_SRC/lib is not
+available. ./blib is turned into an absolute pathname and gets passed
+to subdirectories when writing the Makefile.
+
+- INST_ARCHLIB will now be set equal to INST_LIB if we cannot
+determine it with the methods near line 620 (in the intialize
+subroutine).
+
+- Introduced the install subroutine, that calls another make
+recursively with INST_LIB, and INST_ARCHLIB set according to the local
+conventions.
+
+- Since version 3.6 all *.al and *.ix files are installed into
+$installprivlib. In perl5.000 they were installed into
+$installarchlib. Version 3.8 takes precautions to delete old *.{al,ix}
+files that are left over in $installarchlib. Installperl is also
+patched to both delete old *.al and *.ix files, that were put into
+$installarchlib, and to install them properly from now on.
+
+- h2xs is patched by Dean Roehrich to reintroduce the C<-A> option and
+reconsiders the use of the AutoLoader. Also podifies h2xs.
+
+- Patches to {DB_File,Fcntl,GDBM_File,POSIX,Socket}.pm, eliminating
+AutoLoader from @ISA (by Dean Roehrich).
+
+- A patch to AutoSplit.pm makes sure, the target directory of the
+split exists.
+
+- installperl now installs all *.h files into $installarchlib/CORE.
+
+- added a simple help function
+
+- AutoSplit:
+
+ Turned two constants into package variables.
+ Modified the default for &autosplit to be $CheckModTime=1.
+ Added warning and comment if auto dir does not exist.
+ Enhanced AutoLoader check (POSIX.pm was not getting AutoSplit!)
+ Improved logging if $Verbose>=2.
+
+- MakeMaker:
+
+ EXPORT_OK lsdir(), it's very handy.
+ Deleted much of the early revision history.
+ Changed LDTARGET (bad name) to LDFROM (better, but not great :)
+ INST_ARCHLIB for ./blib found via mapping from INST_LIB ./blib
+ (this allows error message if INST_ARCHLIB still undefined)
+ Added optional regex filter to &lsdir.
+ Added cute auto handling of a ./$(BASEEXT)/*.pm directory as
+ per recent messages with Nick re ext/nTk/nTk/Text.pm
+ Added NOOP, RM_F, RM_RF, TOUCH, CP to %att.
+ NOOP is now "" on Unix, "<tab>" caused problems (see makefile section)
+ RM_F etc now expanded when Makefile written.
+ Old AUTOSPLITLIB definition deleted.
+ See new dynamic_lib section for new ARMAYBE handling.
+ install section now uses $(INSTALLPRIVLIB) because on some
+ systems INSTALLPRIVLIB != PRIVLIB (ditto for archlib)
=head1 NOTES
@@ -239,17 +240,9 @@ MakeMaker development work still to be done:
Needs more complete documentation.
-Replace use of cflags with %Config (taking note of hints etc)
-
-Move xsubpp and typemap into lib/ExtUtils/...
-
The ext.libs file mechanism will need to be revised to allow a
make-a-perl [list-of-static-extensions] script to work.
-Eventually eliminate use of $(PERL_SRC). This must wait until
-MakeMaker is the standard and Larry makes the required changes
-elsewhere.
-
Add method to take a list of files and wrap it in a Makefile
compatible way (<space><backslash><newline><tab>).
@@ -305,8 +298,9 @@ $Attrib_Help = <<'END';
'LIBS' => "-ltcl -ltk -lX11"
MakeMaker will turn it into an array with one element.
- LDTARGET: defaults to "$(OBJECT)" and is used in the ld command
- (some machines need additional switches for bigger projects)
+ LDFROM: defaults to "$(OBJECT)" and is used in the ld command
+ to specify what files to link/load from
+ (also see dynamic_lib below for how to specify ld flags)
DIR: Ref to array of subdirectories containing Makefile.PLs
e.g. [ 'sdbm' ] in ext/SDBM_File
@@ -345,11 +339,13 @@ normally required:
linkext: {LINKTYPE => 'static', 'dynamic' or ''}
dynamic_lib {ARMAYBE => 'ar', OTHERLDFLAGS => '...'}
clean: {FILES => "*.xyz foo"}
- realclean: {FILES => '$(INST_AUTODIR)/*.xyz'}
+ realclean: {FILES => '$(INST_ARCHAUTODIR)/*.xyz'}
distclean: {TARNAME=>'MyTarFile', TARFLAGS=>'cvfF', COMPRESS=>'gzip'}
tool_autosplit: {MAXLEN => 8}
END
+sub help {print $Attrib_Help;}
+
@MM_Sections_spec = (
'post_initialize' => {},
'constants' => {},
@@ -560,11 +556,8 @@ sub initialize {
# PERL_SRC ../.. (undefined)
# INST Macro: Locally Publically
- # INST_LIB ../../lib /usr/local/lib/perl5
- # INST_ARCHLIB ../../lib /usr/local/lib/perl5/sun4-sunos
-
- # This code will need to be reworked to deal with having no perl
- # source. PERL_LIB should become the primary focus.
+ # INST_LIB ../../lib ./blib
+ # INST_ARCHLIB ../../lib ./blib
unless ($att{PERL_SRC}){
foreach(qw(../.. ../../.. ../../../..)){
@@ -587,12 +580,18 @@ sub initialize {
# INST_LIB typically pre-set if building an extension after
# perl has been built and installed. Setting INST_LIB allows
- # You to build directly into privlib and avoid installperl.
- $att{INST_LIB} = $att{PERL_LIB} unless $att{INST_LIB};
-
+ # you to build directly into privlib and avoid installperl.
+ unless ($att{INST_LIB}){
+ if (defined $att{PERL_SRC}) {
+ $att{INST_LIB} = $att{PERL_LIB};
+ } else {
+ $att{INST_LIB} = "$pwd/blib";
+ }
+ }
# Try to work out what INST_ARCHLIB should be if not set:
unless ($att{INST_ARCHLIB}){
my(%archmap) = (
+ "$pwd/blib" => "$pwd/blib", # our private build lib
$att{PERL_LIB} => $att{PERL_ARCHLIB},
$Config{'privlib'} => $Config{'archlib'},
$Config{'installprivlib'} => $Config{'installarchlib'},
@@ -677,12 +676,22 @@ sub initialize {
# then add in any .pm and .pl files in that directory.
# This makes it easy and tidy to ship a number of perl files.
if (-d "lib" and !$dir{'lib'}){
- foreach $name (lsdir("lib")){
- next unless ($name =~ /\.p[ml]$/);
+ foreach $name (lsdir("lib", '\.p[ml]$')){
+ # next unless ($name =~ /\.p[ml]$/);
$pm{"lib/$name"} = "\$(INST_LIBDIR)/$name";
}
}
+ # Similarly, if we have a ./$(BASEEXT) dir without a Makefile.PL
+ # we treat it as a directory containing *.pm files for modules
+ # which are nested below this one. E.g., ./Tk.pm & ./Tk/Text.pm
+ if (-d $att{BASEEXT} and !$dir{$att{BASEEXT}}){
+ foreach $name (lsdir($att{BASEEXT}, '\.p[ml]$')){
+ # next unless ($name =~ /\.p[ml]$/);
+ $pm{"$att{BASEEXT}/$name"} = "\$(INST_LIBDIR)/$att{BASEEXT}/$name";
+ }
+ }
+
$att{DIR} = [sort keys %dir] unless $att{DIRS};
$att{XS} = \%xs unless $att{XS};
$att{PM} = \%pm unless $att{PM};
@@ -734,18 +743,26 @@ sub initialize {
}
$att{BOOTDEP} = (-f "$att{BASEEXT}_BS") ? "$att{BASEEXT}_BS" : "";
$att{LD} = ($Config{'ld'} || 'ld') unless $att{LD};
- $att{LDTARGET} = '$(OBJECT)' unless $att{LDTARGET};
+ $att{LDFROM} = '$(OBJECT)' unless $att{LDFROM};
$att{LINKTYPE} = ($Config{'usedl'}) ? 'dynamic' : 'static'
unless $att{LINKTYPE};
+ # These get overridden for VMS and maybe some other systems
+ $att{NOOP} = "";
+ $att{RM_F} = "rm -f";
+ $att{RM_RF} = "rm -rf";
+ $att{TOUCH} = "touch";
+ $att{CP} = "cp";
}
sub lsdir{
+ my($dir, $regex) = @_;
local(*DIR, @ls);
opendir(DIR, $_[0] || ".") or die "opendir: $!";
@ls = readdir(DIR);
closedir(DIR);
+ @ls = grep(/$regex/, @ls) if $regex;
@ls;
}
@@ -756,6 +773,7 @@ sub find_perl{
print "Looking for perl $ver by these names: @$names, in these dirs: @$dirs\n"
if ($trace);
foreach $dir (@$dirs){
+ next unless defined $dir; # $att{PERL_SRC} may be undefined
foreach $name (@$names){
print "checking $dir/$name\n" if ($trace >= 2);
if ($Is_VMS) {
@@ -825,7 +843,7 @@ EXT = CHANGE_EXT_TO_BASEEXT
INC = $att{INC}
DEFINE = $att{DEFINE}
OBJECT = $att{OBJECT}
-LDTARGET = $att{LDTARGET}
+LDFROM = $att{LDFROM}
LINKTYPE = $att{LINKTYPE}
# Source code:
@@ -851,9 +869,14 @@ CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm
INST_LIBDIR = $(INST_LIB)$(ROOTEXT)
INST_ARCHLIBDIR = $(INST_ARCHLIB)$(ROOTEXT)
-INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
-INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
+';
+
+ push @m, '
+INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
+INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
+';
+ push @m, '
INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(BASEEXT).$(DLEXT)
INST_STATIC = $(BASEEXT).a
@@ -906,7 +929,7 @@ sub const_cccmd{
." old: $old\n"
." new: $new\n"
." Using 'old' set.\n"
- ."Please notify perl5-porters\@isu.edu\n";
+ ."Please notify perl5-porters\@nicoh.com\n";
}
my($cccmd)=($old) ? $old : $new;
"CCCMD = $cccmd\n";
@@ -976,10 +999,9 @@ sub tool_autosplit{
my($asl) = "";
$asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
q{
-AUTOSPLITLIB = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use AutoSplit; chdir("$(INST_LIB)/..") or die $$!; $$AutoSplit::Maxlen=}.$asl.q{; autosplit_lib_modules(@ARGV) ;'
-
# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
-AUTOSPLITFILE = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use AutoSplit;}.$asl.q{ AutoSplit::autosplit_file($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
+# Remark: the "" around the -I switches are helpful for the VMS support
+AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{ AutoSplit::autosplit_file($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
};
}
@@ -1004,6 +1026,10 @@ sub tools_other{
"
SHELL = /bin/sh
LD = $att{LD}
+TOUCH = $att{TOUCH}
+CP = $att{CP}
+RM_F = $att{RM_F}
+RM_RF = $att{RM_RF}
".q{
# The following is a portable way to say mkdir -p
MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){ my(@p); foreach(split(/\//,$$p)){ push(@p,$$_); next if -d "@p/"; print "mkdir @p"; mkdir("@p",0777)||die $$! }} exit 0;'
@@ -1046,12 +1072,11 @@ sub xs_o { # many makes are too dumb to use xs_c then c_o
sub top_targets{
'
all :: config linkext $(INST_PM)
+'.$att{NOOP}.'
config :: Makefile
- @$(MKPATH) $(INST_LIBDIR) $(INST_ARCHLIBDIR)
- @$(MKPATH) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
-
-install :: all
+ @$(MKPATH) $(INST_LIBDIR)
+ @$(MKPATH) $(INST_ARCHAUTODIR)
';
}
@@ -1061,6 +1086,7 @@ sub linkext {
my($linktype) = $attribs{LINKTYPE} || '$(LINKTYPE)';
"
linkext :: $linktype
+$att{NOOP}
";
}
@@ -1072,6 +1098,7 @@ sub dynamic {
# $(INST_PM) has been moved to the all: target.
# It remains here for awhile to allow for old usage: "make dynamic"
dynamic :: $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
+'.$att{NOOP}.'
';
}
@@ -1083,14 +1110,15 @@ BOOTSTRAP = '."$att{BASEEXT}.bs".'
# As MakeMaker mkbootstrap might not write a file (if none is required)
# we use touch to prevent make continually trying to remake it.
# The DynaLoader only reads a non-empty file.
-$(BOOTSTRAP): '.$att{BOOTDEP}.' $(CONFIGDEP)
- $(PERL) -I$(PERL_LIB) -e \'use ExtUtils::MakeMaker; &mkbootstrap("$(BSLOADLIBS)");\' \
+$(BOOTSTRAP): '.$att{BOOTDEP}.' $(CONFIGDEP) Makefile.PL
+ $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
+ -e \'use ExtUtils::MakeMaker; &mkbootstrap("$(BSLOADLIBS)");\' \
INST_LIB=$(INST_LIB) INST_ARCHLIB=$(INST_ARCHLIB) PERL_SRC=$(PERL_SRC) NAME=$(NAME)
- @touch $(BOOTSTRAP)
+ @$(TOUCH) $(BOOTSTRAP)
$(INST_BOOT): $(BOOTSTRAP)
- @rm -f $(INST_BOOT)
- cp $(BOOTSTRAP) $(INST_BOOT)
+ @'.$att{RM_RF}.' $(INST_BOOT)
+ '.$att{CP}.' $(BOOTSTRAP) $(INST_BOOT)
';
}
@@ -1098,15 +1126,23 @@ sub dynamic_lib {
my($self, %attribs) = @_;
my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
my($armaybe) = $attribs{ARMAYBE} || $att{ARMAYBE} || ":";
- '
+ my($ldfrom) = '$(LDFROM)';
+ my(@m);
+ push(@m,'
ARMAYBE = '.$armaybe.'
OTHERLDFLAGS = '.$otherldflags.'
$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP)
- @$(MKPATH) $(INST_AUTODIR)
- $(ARMAYBE) cr $(BASEEXT).a $(OBJECT)
- $(LD) $(LDDLFLAGS) -o $@ $(LDTARGET) $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS)
-';
+ @$(MKPATH) $(INST_ARCHAUTODIR)
+');
+ if ($armaybe ne ':'){
+ $ldfrom = "tmp.a";
+ push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
+ push(@m,' $(RANLIB) '."$ldfrom\n");
+ }
+ push(@m,' $(LD) $(LDDLFLAGS) -o $@ '.$ldfrom.
+ ' $(OTHERLDFLAGS) $(MYEXTLIB) $(LDLOADLIBS)'."\n");
+ join('',@m);
}
@@ -1117,6 +1153,7 @@ sub static {
# $(INST_PM) has been moved to the all: target.
# It remains here for awhile to allow for old usage: "make static"
static :: $(INST_STATIC) $(INST_PM)
+'.$att{NOOP}.'
';
}
@@ -1127,13 +1164,13 @@ $(INST_STATIC): $(OBJECT) $(MYEXTLIB)
END
# If this extension has it's own library (eg SDBM_File)
# then copy that to $(INST_STATIC) and add $(OBJECT) into it.
- push(@m, ' cp $(MYEXTLIB) $@'."\n") if $att{MYEXTLIB};
+ push(@m, " $att{CP} \$(MYEXTLIB) \$\@\n") if $att{MYEXTLIB};
push(@m, <<'END');
ar cr $@ $(OBJECT) && $(RANLIB) $@
@: New mechanism - not yet used:
@echo $(EXTRALIBS) > $(INST_ARCHAUTODIR)/extralibs.ld
- cp $@ $(INST_ARCHAUTODIR)/
+ $(CP) $@ $(INST_ARCHAUTODIR)/
END
push(@m, <<'END') if $att{PERL_SRC};
@: Old mechanism - still needed:
@@ -1169,9 +1206,9 @@ sub installpm_x { # called by installpm per file
my(@m);
push(@m,"
$inst: $dist
-".' @rm -f $@
+".' @'.$att{RM_F}.' $@
@$(MKPATH) '.$instdir.'
- cp $? $@
+ '.$att{CP}.' $? $@
');
push(@m, "\t\$(AUTOSPLITFILE) \$@ $splitlib/auto\n")
if ($splitlib and $inst =~ m/\.pm$/);
@@ -1220,12 +1257,13 @@ sub subdir_x {
# MY::subdir_x() method to override this one.
qq{
config :: $subdir/Makefile
- cd $subdir ; \$(MAKE) config LINKTYPE=\$(LINKTYPE)
+ cd $subdir ; \$(MAKE) config INST_LIB=\$(INST_LIB) INST_ARCHLIB=\$(INST_ARCHLIB) LINKTYPE=\$(LINKTYPE)
$subdir/Makefile: $subdir/Makefile.PL \$(CONFIGDEP)
}.' @echo "Rebuilding $@ ..."
$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \\
-e "use ExtUtils::MakeMaker; MM->runsubdirpl(qw('.$subdir.'))" \\
+ INST_LIB=$(INST_LIB) INST_ARCHLIB=$(INST_ARCHLIB) \\
$(SUBDIR_MAKEFILE_PL_ARGS)
@echo "Rebuild of $@ complete."
'.qq{
@@ -1250,12 +1288,12 @@ clean ::
');
# clean subdirectories first
push(@m, map("\t-cd $_ && test -f Makefile && \$(MAKE) clean\n",@{$att{DIR}}));
- push(@m, " rm -f *~ t/*~ *.o *.a mon.out core so_locations \$(BOOTSTRAP) \$(BASEEXT).bso\n");
+ push(@m, " $att{RM_F} *~ t/*~ *.o *.a mon.out core so_locations \$(BOOTSTRAP) \$(BASEEXT).bso\n");
my(@otherfiles);
# Automatically delete the .c files generated from *.xs files:
push(@otherfiles, values %{$att{XS}});
push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
- push(@m, " rm -rf @otherfiles\n") if @otherfiles;
+ push(@m, " $att{RM_RF} @otherfiles\n") if @otherfiles;
push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
join("", @m);
}
@@ -1269,11 +1307,13 @@ realclean purge :: clean
');
# clean subdirectories first
push(@m, map("\t-cd $_ && test -f Makefile && \$(MAKE) realclean\n",@{$att{DIR}}));
- push(@m, ' rm -f Makefile $(INST_DYNAMIC) $(INST_STATIC) $(INST_BOOT) $(INST_PM)'."\n");
- push(@m, ' rm -rf $(INST_AUTODIR) $(INST_ARCHAUTODIR)'."\n");
+ # try to clean those files first, where we might have no permissions, so Makefile won't be lost
+ push(@m, " $att{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
+ push(@m, " $att{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT) \$(INST_PM)\n");
+ push(@m, " $att{RM_F} Makefile \$(INST_STATIC)\n");
my(@otherfiles);
push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
- push(@m, " rm -rf @otherfiles\n") if @otherfiles;
+ push(@m, " $att{RM_RF} @otherfiles\n") if @otherfiles;
push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
join("", @m);
}
@@ -1291,7 +1331,7 @@ sub distclean {
"
distclean: clean
$preop
- rm -f $mkfiles
+ $att{RM_F} $mkfiles
cd ..; tar $tarflags $tarname.tar \$(BASEEXT)
cd ..; $compress $tarname.tar
$postop
@@ -1309,10 +1349,10 @@ sub test {
test :: all
");
push(@m, <<"END") if $tests;
- \$(FULLPERL) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) -e 'use Test::Harness; runtests \@ARGV;' $tests
+ \$(FULLPERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) -e 'use Test::Harness; runtests \@ARGV;' $tests
END
push(@m, <<'END') if -f "test.pl";
- $(FULLPERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
+ $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) test.pl
END
push(@m, map("\tcd $_ && test -f Makefile && \$(MAKE) test LINKTYPE=\$(LINKTYPE)\n",@{$att{DIR}}));
push(@m, "\t\@echo 'No tests defined for \$(NAME) extension.'\n") unless @m > 1;
@@ -1321,15 +1361,21 @@ END
sub install {
- '
+ my($self, %attribs) = @_;
+ my(@m);
+ push(@m, "
install :: all
- # install is not defined. Makefile, by default, builds the extension
- # directly into $(INST_LIB) so "installing" does not make much sense.
- # If INST_LIB is in the perl source tree then installperl will install
- # the extension when it installs perl.
-';
-}
+");
+ # install subdirectories first
+ push(@m, map("\tcd $_ && test -f Makefile && \$(MAKE) install\n",@{$att{DIR}}));
+
+ push(@m, "\t: perl5.000 used to autosplit into INST_ARCHLIB, we delete these old files here
+ $att{RM_F} \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.al \$(INSTALLARCHLIB)/auto/\$(FULLEXT)/*.ix
+ make INST_LIB=\$(INSTALLPRIVLIB) INST_ARCHLIB=\$(INSTALLARCHLIB)
+");
+ join("",@m);
+}
sub force {
'# Phony target to force checking subdirectories.
@@ -1357,7 +1403,6 @@ $(OBJECT) : $(PERL_HDRS)
push(@m,'
$(PERL_INC)/config.h: $(PERL_SRC)/config.sh; cd $(PERL_SRC); /bin/sh config_h.SH
-$(PERL_INC)/embed.h: $(PERL_SRC)/config.sh; cd $(PERL_SRC); /bin/sh embed_h.SH
') if $att{PERL_SRC};
# This needs a better home:
@@ -1371,9 +1416,13 @@ sub makefile {
# We do not know what target was originally specified so we
# must force a manual rerun to be sure. But as it would only
# happen very rarely it is not a significant problem.
- '
-$(OBJECT) : Makefile
+# This dependency, with no_op, causes problems. Make tries to build OBJECT via no_op!
+# So we'll just drop it for now.
+#$(OBJECT) : Makefile
+#'.$att{NOOP}.'
+
+ '
Makefile: Makefile.PL $(CONFIGDEP)
$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
@echo "Now you must rerun make."; false
@@ -1401,7 +1450,7 @@ sub extliblist{
warn "Warning (non-fatal): $att{NAME} extliblist consistency check failed:\n".
" old: $oldlibs\n".
" new: $newlibs\n".
- "Using 'new' set. Please notify perl5-porters\@isu.edu.\n"
+ "Using 'new' set. Please notify perl5-porters\@nicoh.com.\n"
if ("$newlibs" ne "$oldlibs");
}
@new;
@@ -1664,4 +1713,3 @@ package ExtUtils::MakeMaker;
1;
__END__
-
diff --git a/ext/typemap b/lib/ExtUtils/typemap
index 98493e7c04..98493e7c04 100644
--- a/ext/typemap
+++ b/lib/ExtUtils/typemap
diff --git a/ext/xsubpp b/lib/ExtUtils/xsubpp
index 1e13118ad5..1e13118ad5 100755
--- a/ext/xsubpp
+++ b/lib/ExtUtils/xsubpp
diff --git a/x2p/Makefile.SH b/x2p/Makefile.SH
index e24a9beb6d..5b8041c78b 100755
--- a/x2p/Makefile.SH
+++ b/x2p/Makefile.SH
@@ -84,7 +84,7 @@ clean:
rm -f a2p *.o a2p.c
realclean: clean
- rm -f *.orig */*.orig core $(addedbyconf) a2p.c all
+ rm -f *.orig */*.orig core $(addedbyconf) a2p.c all malloc.c
rm -f Makefile cflags find2perl s2p makefile makefile.old
# The following lint has practically everything turned on. Unfortunately,
diff --git a/x2p/malloc.c b/x2p/malloc.c
deleted file mode 100644
index 87c5068e99..0000000000
--- a/x2p/malloc.c
+++ /dev/null
@@ -1,466 +0,0 @@
-/* $RCSfile: malloc.c,v $$Revision: 4.1 $$Date: 92/08/07 18:24:25 $
- *
- * $Log: malloc.c,v $
- */
-
-#ifndef lint
-#ifdef DEBUGGING
-#define RCHECK
-#endif
-/*
- * malloc.c (Caltech) 2/21/82
- * Chris Kingsley, kingsley@cit-20.
- *
- * This is a very fast storage allocator. It allocates blocks of a small
- * number of different sizes, and keeps free lists of each size. Blocks that
- * don't exactly fit are passed up to the next larger size. In this
- * implementation, the available sizes are 2^n-4 (or 2^n-12) bytes long.
- * This is designed for use in a program that uses vast quantities of memory,
- * but bombs when it runs out.
- */
-
-#include "EXTERN.h"
-#include "../perl.h"
-
-/* I don't much care whether these are defined in sys/types.h--LAW */
-
-#define u_char unsigned char
-#define u_int unsigned int
-#define u_short unsigned short
-
-/*
- * The overhead on a block is at least 4 bytes. When free, this space
- * contains a pointer to the next free block, and the bottom two bits must
- * be zero. When in use, the first byte is set to MAGIC, and the second
- * byte is the size index. The remaining bytes are for alignment.
- * If range checking is enabled and the size of the block fits
- * in two bytes, then the top two bytes hold the size of the requested block
- * plus the range checking words, and the header word MINUS ONE.
- */
-union overhead {
- union overhead *ov_next; /* when free */
-#if MEM_ALIGNBYTES > 4
- double strut; /* alignment problems */
-#endif
- struct {
- u_char ovu_magic; /* magic number */
- u_char ovu_index; /* bucket # */
-#ifdef RCHECK
- u_short ovu_size; /* actual block size */
- u_int ovu_rmagic; /* range magic number */
-#endif
- } ovu;
-#define ov_magic ovu.ovu_magic
-#define ov_index ovu.ovu_index
-#define ov_size ovu.ovu_size
-#define ov_rmagic ovu.ovu_rmagic
-};
-
-#ifdef debug
-static void botch _((char *s));
-#endif
-static void morecore _((int bucket));
-static int findbucket _((union overhead *freep, int srchlen));
-
-#define MAGIC 0xff /* magic # on accounting info */
-#define RMAGIC 0x55555555 /* magic # on range info */
-#ifdef RCHECK
-#define RSLOP sizeof (u_int)
-#else
-#define RSLOP 0
-#endif
-
-/*
- * nextf[i] is the pointer to the next free block of size 2^(i+3). The
- * smallest allocatable block is 8 bytes. The overhead information
- * precedes the data area returned to the user.
- */
-#define NBUCKETS 30
-static union overhead *nextf[NBUCKETS];
-extern char *sbrk();
-
-#ifdef MSTATS
-/*
- * nmalloc[i] is the difference between the number of mallocs and frees
- * for a given block size.
- */
-static u_int nmalloc[NBUCKETS];
-#include <stdio.h>
-#endif
-
-#ifdef debug
-#define ASSERT(p) if (!(p)) botch("p"); else
-static void
-botch(s)
- char *s;
-{
-
- printf("assertion botched: %s\n", s);
- abort();
-}
-#else
-#define ASSERT(p)
-#endif
-
-Malloc_t
-malloc(nbytes)
- register MEM_SIZE nbytes;
-{
- register union overhead *p;
- register int bucket = 0;
- register MEM_SIZE shiftr;
-
-#ifdef safemalloc
-#ifdef DEBUGGING
- MEM_SIZE size = nbytes;
-#endif
-
-#ifdef MSDOS
- if (nbytes > 0xffff) {
- fprintf(stderr, "Allocation too large: %lx\n", (long)nbytes);
- exit(1);
- }
-#endif /* MSDOS */
-#ifdef DEBUGGING
- if ((long)nbytes < 0)
- croak("panic: malloc");
-#endif
-#endif /* safemalloc */
-
- /*
- * Convert amount of memory requested into
- * closest block size stored in hash buckets
- * which satisfies request. Account for
- * space used per block for accounting.
- */
- nbytes += sizeof (union overhead) + RSLOP;
- nbytes = (nbytes + 3) &~ 3;
- shiftr = (nbytes - 1) >> 2;
- /* apart from this loop, this is O(1) */
- while (shiftr >>= 1)
- bucket++;
- /*
- * If nothing in hash bucket right now,
- * request more memory from the system.
- */
- if (nextf[bucket] == NULL)
- morecore(bucket);
- if ((p = (union overhead *)nextf[bucket]) == NULL) {
-#ifdef safemalloc
- if (!nomemok) {
- fputs("Out of memory!\n", stderr);
- exit(1);
- }
-#else
- return (NULL);
-#endif
- }
-
-#ifdef safemalloc
- DEBUG_m(fprintf(stderr,"0x%lx: (%05d) malloc %ld bytes\n",
- (unsigned long)(p+1),an++,(long)size));
-#endif /* safemalloc */
-
- /* remove from linked list */
-#ifdef RCHECK
- if (*((int*)p) & (sizeof(union overhead) - 1))
- fprintf(stderr,"Corrupt malloc ptr 0x%lx at 0x%lx\n",
- (unsigned long)*((int*)p),(unsigned long)p);
-#endif
- nextf[bucket] = p->ov_next;
- p->ov_magic = MAGIC;
- p->ov_index= bucket;
-#ifdef MSTATS
- nmalloc[bucket]++;
-#endif
-#ifdef RCHECK
- /*
- * Record allocated size of block and
- * bound space with magic numbers.
- */
- if (nbytes <= 0x10000)
- p->ov_size = nbytes - 1;
- p->ov_rmagic = RMAGIC;
- *((u_int *)((caddr_t)p + nbytes - RSLOP)) = RMAGIC;
-#endif
- return ((Malloc_t)(p + 1));
-}
-
-/*
- * Allocate more memory to the indicated bucket.
- */
-static void
-morecore(bucket)
- register int bucket;
-{
- register union overhead *op;
- register int rnu; /* 2^rnu bytes will be requested */
- register int nblks; /* become nblks blocks of the desired size */
- register MEM_SIZE siz;
-
- if (nextf[bucket])
- return;
- /*
- * Insure memory is allocated
- * on a page boundary. Should
- * make getpageize call?
- */
-#ifndef atarist /* on the atari we dont have to worry about this */
- op = (union overhead *)sbrk(0);
-#ifndef I286
- if ((int)op & 0x3ff)
- (void)sbrk(1024 - ((int)op & 0x3ff));
-#else
- /* The sbrk(0) call on the I286 always returns the next segment */
-#endif
-#endif /* atarist */
-
-#if !(defined(I286) || defined(atarist))
- /* take 2k unless the block is bigger than that */
- rnu = (bucket <= 8) ? 11 : bucket + 3;
-#else
- /* take 16k unless the block is bigger than that
- (80286s like large segments!), probably good on the atari too */
- rnu = (bucket <= 11) ? 14 : bucket + 3;
-#endif
- nblks = 1 << (rnu - (bucket + 3)); /* how many blocks to get */
- if (rnu < bucket)
- rnu = bucket;
- op = (union overhead *)sbrk(1L << rnu);
- /* no more room! */
- if ((int)op == -1)
- return;
- /*
- * Round up to minimum allocation size boundary
- * and deduct from block count to reflect.
- */
-#ifndef I286
- if ((int)op & 7) {
- op = (union overhead *)(((MEM_SIZE)op + 8) &~ 7);
- nblks--;
- }
-#else
- /* Again, this should always be ok on an 80286 */
-#endif
- /*
- * Add new memory allocated to that on
- * free list for this hash bucket.
- */
- nextf[bucket] = op;
- siz = 1 << (bucket + 3);
- while (--nblks > 0) {
- op->ov_next = (union overhead *)((caddr_t)op + siz);
- op = (union overhead *)((caddr_t)op + siz);
- }
-}
-
-void
-free(mp)
- Malloc_t mp;
-{
- register MEM_SIZE size;
- register union overhead *op;
- char *cp = (char*)mp;
-
-#ifdef safemalloc
- DEBUG_m(fprintf(stderr,"0x%lx: (%05d) free\n",(unsigned long)cp,an++));
-#endif /* safemalloc */
-
- if (cp == NULL)
- return;
- op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
-#ifdef debug
- ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */
-#else
- if (op->ov_magic != MAGIC) {
-#ifdef RCHECK
- warn("%s free() ignored",
- op->ov_rmagic == RMAGIC - 1 ? "Duplicate" : "Bad");
-#else
- warn("Bad free() ignored");
-#endif
- return; /* sanity */
- }
-#endif
-#ifdef RCHECK
- ASSERT(op->ov_rmagic == RMAGIC);
- if (op->ov_index <= 13)
- ASSERT(*(u_int *)((caddr_t)op + op->ov_size + 1 - RSLOP) == RMAGIC);
- op->ov_rmagic = RMAGIC - 1;
-#endif
- ASSERT(op->ov_index < NBUCKETS);
- size = op->ov_index;
- op->ov_next = nextf[size];
- nextf[size] = op;
-#ifdef MSTATS
- nmalloc[size]--;
-#endif
-}
-
-/*
- * When a program attempts "storage compaction" as mentioned in the
- * old malloc man page, it realloc's an already freed block. Usually
- * this is the last block it freed; occasionally it might be farther
- * back. We have to search all the free lists for the block in order
- * to determine its bucket: 1st we make one pass thru the lists
- * checking only the first block in each; if that fails we search
- * ``reall_srchlen'' blocks in each list for a match (the variable
- * is extern so the caller can modify it). If that fails we just copy
- * however many bytes was given to realloc() and hope it's not huge.
- */
-int reall_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
-
-Malloc_t
-realloc(mp, nbytes)
- Malloc_t mp;
- MEM_SIZE nbytes;
-{
- register MEM_SIZE onb;
- union overhead *op;
- char *res;
- register int i;
- int was_alloced = 0;
- char *cp = (char*)mp;
-
-#ifdef safemalloc
-#ifdef DEBUGGING
- MEM_SIZE size = nbytes;
-#endif
-
-#ifdef MSDOS
- if (nbytes > 0xffff) {
- fprintf(stderr, "Reallocation too large: %lx\n", size);
- exit(1);
- }
-#endif /* MSDOS */
- if (!cp)
- return malloc(nbytes);
-#ifdef DEBUGGING
- if ((long)nbytes < 0)
- croak("panic: realloc");
-#endif
-#endif /* safemalloc */
-
- op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
- if (op->ov_magic == MAGIC) {
- was_alloced++;
- i = op->ov_index;
- } else {
- /*
- * Already free, doing "compaction".
- *
- * Search for the old block of memory on the
- * free list. First, check the most common
- * case (last element free'd), then (this failing)
- * the last ``reall_srchlen'' items free'd.
- * If all lookups fail, then assume the size of
- * the memory block being realloc'd is the
- * smallest possible.
- */
- if ((i = findbucket(op, 1)) < 0 &&
- (i = findbucket(op, reall_srchlen)) < 0)
- i = 0;
- }
- onb = (1L << (i + 3)) - sizeof (*op) - RSLOP;
- /* avoid the copy if same size block */
- if (was_alloced &&
- nbytes <= onb && nbytes > (onb >> 1) - sizeof(*op) - RSLOP) {
-#ifdef RCHECK
- /*
- * Record new allocated size of block and
- * bound space with magic numbers.
- */
- if (op->ov_index <= 13) {
- /*
- * Convert amount of memory requested into
- * closest block size stored in hash buckets
- * which satisfies request. Account for
- * space used per block for accounting.
- */
- nbytes += sizeof (union overhead) + RSLOP;
- nbytes = (nbytes + 3) &~ 3;
- op->ov_size = nbytes - 1;
- *((u_int *)((caddr_t)op + nbytes - RSLOP)) = RMAGIC;
- }
-#endif
- res = cp;
- }
- else {
- if ((res = (char*)malloc(nbytes)) == NULL)
- return (NULL);
- if (cp != res) /* common optimization */
- Copy(cp, res, (MEM_SIZE)(nbytes<onb?nbytes:onb), char);
- if (was_alloced)
- free(cp);
- }
-
-#ifdef safemalloc
-#ifdef DEBUGGING
- if (debug & 128) {
- fprintf(stderr,"0x%lx: (%05d) rfree\n",(unsigned long)res,an++);
- fprintf(stderr,"0x%lx: (%05d) realloc %ld bytes\n",
- (unsigned long)res,an++,(long)size);
- }
-#endif
-#endif /* safemalloc */
- return ((Malloc_t)res);
-}
-
-/*
- * Search ``srchlen'' elements of each free list for a block whose
- * header starts at ``freep''. If srchlen is -1 search the whole list.
- * Return bucket number, or -1 if not found.
- */
-static int
-findbucket(freep, srchlen)
- union overhead *freep;
- int srchlen;
-{
- register union overhead *p;
- register int i, j;
-
- for (i = 0; i < NBUCKETS; i++) {
- j = 0;
- for (p = nextf[i]; p && j != srchlen; p = p->ov_next) {
- if (p == freep)
- return (i);
- j++;
- }
- }
- return (-1);
-}
-
-#ifdef MSTATS
-/*
- * mstats - print out statistics about malloc
- *
- * Prints two lines of numbers, one showing the length of the free list
- * for each size category, the second showing the number of mallocs -
- * frees for each size category.
- */
-void
-mstats(s)
- char *s;
-{
- register int i, j;
- register union overhead *p;
- int totfree = 0,
- totused = 0;
-
- fprintf(stderr, "Memory allocation statistics %s\nfree:\t", s);
- for (i = 0; i < NBUCKETS; i++) {
- for (j = 0, p = nextf[i]; p; p = p->ov_next, j++)
- ;
- fprintf(stderr, " %d", j);
- totfree += j * (1 << (i + 3));
- }
- fprintf(stderr, "\nused:\t");
- for (i = 0; i < NBUCKETS; i++) {
- fprintf(stderr, " %d", nmalloc[i]);
- totused += nmalloc[i] * (1 << (i + 3));
- }
- fprintf(stderr, "\n\tTotal in use: %d, total free: %d\n",
- totused, totfree);
-}
-#endif
-#endif /* lint */