summaryrefslogtreecommitdiff
path: root/make_ext.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-02-12 20:43:49 +0000
committerNicholas Clark <nick@ccl4.org>2009-02-12 21:05:20 +0000
commite74f76b27bd4a9c64ec8f4f10c74bbd59db04e7d (patch)
treebb1024d6d860c7e4734f23271995306043f11a18 /make_ext.pl
parent619cec6d4589de2be1141fac9adde5c7d9c84167 (diff)
downloadperl-e74f76b27bd4a9c64ec8f4f10c74bbd59db04e7d.tar.gz
make_ext.pl now generates a Makefile.PL if needed.
Remove ext/Safe/Makefile.PL as a proof of concept.
Diffstat (limited to 'make_ext.pl')
-rw-r--r--make_ext.pl46
1 files changed, 44 insertions, 2 deletions
diff --git a/make_ext.pl b/make_ext.pl
index e9d318d802..f74124ca42 100644
--- a/make_ext.pl
+++ b/make_ext.pl
@@ -206,12 +206,13 @@ foreach my $spec (@extspec) {
print "\tMaking $mname ($target)\n";
build_extension('ext', $ext_pathname, $up, $perl || "$up/miniperl",
- "$up/lib",
+ "$up/lib", $mname,
[@pass_through, @{$extra_passthrough{$spec} || []}]);
}
sub build_extension {
- my ($ext, $ext_dir, $return_dir, $perl, $lib_dir, $pass_through) = @_;
+ my ($ext, $ext_dir, $return_dir, $perl, $lib_dir, $mname, $pass_through)
+ = @_;
unless (chdir "$ext_dir") {
warn "Cannot cd to $ext_dir: $!";
return;
@@ -229,6 +230,47 @@ sub build_extension {
}
if (!-f $makefile) {
+ if (!-f 'Makefile.PL') {
+ print "\nCreating Makefile.PL in $ext_dir for $mname\n";
+ # We need to cope well with various possible layouts
+ my @dirs = split /::/, $mname;
+ my $leaf = pop @dirs;
+ my $leafname = "$leaf.pm";
+ my $pathname = join '/', @dirs, $leafname;
+ my @locations = ($leafname, $pathname, "lib/$pathname");
+ my $fromname;
+ foreach (@locations) {
+ if (-f $_) {
+ $fromname = $_;
+ last;
+ }
+ }
+
+ unless ($fromname) {
+ die "For $mname tried @locations in in $ext_dir but can't find source";
+ }
+ open my $fh, '>', 'Makefile.PL'
+ or die "Can't open Makefile.PL for writing: $!";
+ print $fh <<"EOM";
+#-*- buffer-read-only: t -*-
+
+# This Makefile.PL was written by $0.
+# It will be deleted automatically by make realclean
+
+use strict;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => '$mname',
+ VERSION_FROM => '$fromname',
+ ABSTRACT_FROM => '$fromname',
+ realclean => {FILES => 'Makefile.PL'},
+);
+
+# ex: set ro:
+EOM
+ close $fh or die "Can't close Makefile.PL: $!";
+ }
print "\nRunning Makefile.PL in $ext_dir\n";
# Presumably this can be simplified