use Pod::Usage;
use Getopt::Std;
+use Config;
$Getopt::Std::STANDARD_HELP_VERSION = 1;
my $trysource = "try.c";
}
die "$macro not found\n" unless defined $header;
+if ($^O =~ /MSWin(32|64)/) {
+ # The Win32 (and Win64) build process expects to be run from
+ # bleadperl/Win32
+ chdir "Win32"
+ or die "Couldn't chdir to win32: $!";
+};
+
open my $out, '>', $trysource or die "Can't open $trysource: $!";
my $sentinel = "$macro expands to";
-my %done_header;
+# These two are included from perl.h, and perl.h sometimes redefines their
+# macros. So no need to include them.
+my %done_header = ('embed.h' => 1, 'embedvar.h' => 1);
sub do_header {
my $header = shift;
close $out or die "Can't close $trysource: $!";
-print "doing: make $tryout\n" if $opt{v};
-system "make $tryout" and die;
+print "doing: $Config{make} $tryout\n" if $opt{v};
+my $cmd = "$Config{make} $tryout";
+system( $cmd ) == 0
+ or die "Couldn't launch [$cmd]: $! / $?";
# if user wants 'indent' formatting ..
my $out_fh;
$out_fh = \*STDOUT;
}
-open my $fh, '<', $tryout or die "Can't open $tryout: $!";
+{
+ open my $fh, '<', $tryout or die "Can't open $tryout: $!";
-while (<$fh>) {
- print $out_fh $_ if /$sentinel/o .. 1;
-}
+ while (<$fh>) {
+ print $out_fh $_ if /$sentinel/o .. 1;
+ }
+};
unless ($opt{k}) {
foreach($trysource, $tryout) {
- die "Can't unlink $_" unless unlink $_;
+ die "Can't unlink $_: $!" unless unlink $_;
}
}