From: Nicholas Clark Date: Wed, 14 Jan 2009 10:32:44 +0000 (+0000) Subject: Make make_ext.pl write out a shell script of its actions for make distclean etc X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=61edc68382f612a884a3181266d6220ea3a727eb;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/Makefile.SH b/Makefile.SH index 629f51c..6480b94 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -1233,9 +1233,14 @@ _cleaner1: -cd pod; $(LDLIBPTH) $(MAKE) $(CLEAN) -cd utils; $(LDLIBPTH) $(MAKE) $(CLEAN) -cd x2p; $(LDLIBPTH) $(MAKE) $(CLEAN) - -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \ + -@if test -f miniperl$(EXE_EXT) ; then \ + for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \ $(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib ext/util/make_ext.pl $(CLEAN) $$x MAKE=$(MAKE) ; \ - done + done ; \ + else \ + sh $(CLEAN).sh ; \ + fi + rm -f realclean.sh veryclean.sh -@test ! -f ./miniperl$(EXE_EXT) || $(LDLIBPTH) $(RUN) ./miniperl$(EXE_EXT) -Ilib mkppport --clean # Some systems do not support "?", so keep these files separate. diff --git a/ext/util/make_ext.pl b/ext/util/make_ext.pl index f6b7b51..0f35ab4 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) {