#!/usr/bin/perl use IO::File; use File::Spec 'catfile'; use warnings; use strict; # Alternative: Use Config's idea of the path to perl. # IMHO, it's entirely too easy to move the perl executable without updating # Config.pm. We assume the user knew what they were doing when they specified what # perl to run to the shell, and simply attempt to interpret it the same way as the # shell did, when it's not absolute. my ($myperl)=(scalar(()=File::Spec->splitdir($^X)) > 1 # If the path has any "slash"es... # Assume it's rel to the current directory, or absolute ? File::Spec->rel2abs($^X) # Otherwise, we have very little to go on. Get the # first executable file Of this name in the path. : ( grep { -x $_ } # On unix, empty=. let this go for other OSes too, as # there's no other useful meaning. map { File::Spec->catfile($_, $^X) } (File::Spec->rel2abs($^X)), File::Spec->path ) ); print "Running with perl $myperl\n"; my $returnval=0; my @dirs = grep {-d $_} glob('*'); foreach (@dirs) { print "$_\n"; chdir $_ or do {print "Couldn't change directory to $_: $!"; next}; system($^X, 'Makefile.PL', @ARGV); if ($?==-1) { print "Error running Makefile.PL: $!\n"; } elsif ($?) { print "While running Makefile.PL in subdir $_, it failed with \$?=$?. Continuing anyway.\n"; print "(Signal ", $?>>8, ")\n" if $?>>8 ; print "(Return ", $?&127, ")\n" if $?&127; print "(Core dumped)\n" if $?&128; if ($?>>8 > $returnval) { $returnval = $?>>8; } } chdir '..' or die "Couldn't chdir back to main directory: $!"; } print "Writing Makefile in this directory.\n"; my @targets = qw(FORCE all ci clean config dist distcheck distclean distdir disttest dynamic help install linkext makemakerdflt manifest manifypods metafile ppd realclean shdist skipcheck static subdirs tardist test testdb uninstall uutardist veryclean zipdist); my $makefile = IO::File->new('>Makefile') or die "Cannot open Makefile: $!"; print $makefile <<"END_OF_MAKEFILE"; # This makefile generated by Build::Bundle::Really @targets: END_OF_MAKEFILE foreach (@dirs) { print $makefile "\tcd $_; make $@"; print $makefile "\n"; } exit $returnval;