From: Nicholas Clark Date: Thu, 12 Feb 2009 20:43:49 +0000 (+0000) Subject: make_ext.pl now generates a Makefile.PL if needed. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e74f76b27bd4a9c64ec8f4f10c74bbd59db04e7d;p=p5sagit%2Fp5-mst-13.2.git make_ext.pl now generates a Makefile.PL if needed. Remove ext/Safe/Makefile.PL as a proof of concept. --- diff --git a/MANIFEST b/MANIFEST index 67fddb6..6c51220 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1018,7 +1018,6 @@ ext/re/t/re_funcs.t See if exportable 're' funcs in re.xs work ext/re/t/regop.pl generate debug output for various patterns ext/re/t/regop.t test RE optimizations by scraping debug output ext/re/t/re.t see if re pragma works -ext/Safe/Makefile.PL Safe extension Perl module ext/Safe/Safe.pm Safe extension Perl module ext/Safe/t/safe1.t See if Safe works ext/Safe/t/safe2.t See if Safe works diff --git a/ext/Safe/Makefile.PL b/ext/Safe/Makefile.PL deleted file mode 100644 index b4aa932..0000000 --- a/ext/Safe/Makefile.PL +++ /dev/null @@ -1,8 +0,0 @@ -# Yes, this is boilerplate and will be abolished "real soon now". -use strict; -use ExtUtils::MakeMaker; - -WriteMakefile( - NAME => 'Safe', - VERSION_FROM => 'Safe.pm', -); diff --git a/make_ext.pl b/make_ext.pl index e9d318d..f74124c 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