summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-01-14 10:32:44 +0000
committerNicholas Clark <nick@ccl4.org>2009-01-14 10:32:44 +0000
commit61edc68382f612a884a3181266d6220ea3a727eb (patch)
tree6f11064ee8b84f3dc23302ab9584ccae02a19a0b /ext
parent29638d28d4592a1802e976efd732f501c8ff0af8 (diff)
downloadperl-61edc68382f612a884a3181266d6220ea3a727eb.tar.gz
Make make_ext.pl write out a shell script of its actions for make distclean etc
(In case the user runs make clean; make distclean; as clean removes miniperl) Change the #! line to ./miniperl
Diffstat (limited to 'ext')
-rw-r--r--ext/util/make_ext.pl41
1 files changed, 40 insertions, 1 deletions
diff --git a/ext/util/make_ext.pl b/ext/util/make_ext.pl
index f6b7b51376..0f35ab4226 100644
--- a/ext/util/make_ext.pl
+++ b/ext/util/make_ext.pl
@@ -1,4 +1,4 @@
-#!/bin/perl
+#!./miniperl
use strict;
use warnings;
@@ -151,6 +151,45 @@ if (not -f $makefile) {
if (-f "Makefile.PL") {
system("${run}../$depth/miniperl -I../$depth/lib Makefile.PL INSTALLDIRS=perl INSTALLMAN3DIR=none PERL_CORE=1 $passthru");
}
+ # Right. The reason for this little hack is that we're sitting inside
+ # a program run by ./miniperl, but there are tasks we need to perform
+ # when the 'realclean', 'distclean' or 'veryclean' targets are run.
+ # Unfortunately, they can be run *after* 'clean', which deletes
+ # ./miniperl
+ # So we do our best to leave a set of instructions identical to what
+ # we would do if we are run directly as 'realclean' etc
+ # Whilst we're perfect, unfortunately the targets we call are not, as
+ # some of them rely on a $(PERL) for their own distclean targets.
+ # But this always used to be a problem with the old /bin/sh version of
+ # this.
+ my $suffix = '.sh';
+ foreach my $clean_target ('realclean', 'veryclean') {
+ my $file = "../$depth/$clean_target$suffix";
+ open my $fh, '>>', $file or die "open $file: $!";
+ # Quite possible that we're being run in parallel here.
+ # Can't use Fcntl this early to get the LOCK_EX
+ flock $fh, 2 or warn "flock $file: $!";
+ if ($^O eq 'VMS') {
+ # Write out DCL here
+ } elsif ($^O eq 'MSWin32') {
+ # Might not need anything here.
+ } else {
+ print $fh <<"EOS";
+chdir ext/$pname
+if test ! -f $makefile -a -f Makefile.old; then
+ echo "Note: Using Makefile.old"
+ make -f Makefile.old $clean_target MAKE=$make $passthru
+else
+ if test ! -f $makefile ; then
+ echo "Warning: No Makefile!"
+ fi
+ make $clean_target MAKE=$make $passthru
+fi
+chdir ../$depth
+EOS
+ }
+ close $fh or die "close $file: $!";
+ }
}
if (not -f $makefile) {