1#!/usr/local/bin/perl 2# 3# xsubpp.PL: this script's normal purpose is to copy 4# 5# dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp 6# to 7# utils/xsubpp 8# 9# while prepending the standard "eval 'exec ...'" interpreter invocation 10# boilerplate. 11# This script belongs to the perl distribution, rather than belonging to 12# ExtUtils-ParseXS. 13 14use Config; 15use File::Basename qw(&basename &dirname); 16use Cwd; 17 18# List explicitly here the variables you want Configure to 19# generate. Metaconfig only looks for shell variables, so you 20# have to mention them as if they were shell variables, not 21# %Config entries. Thus you write 22# $startperl 23# to ensure Configure will look for $Config{startperl}. 24 25# This forces PL files to create target in same directory as PL file. 26# This is so that make depend always knows where to find PL derivatives. 27my $origdir = cwd; 28chdir dirname($0); 29my $file = basename($0, '.PL'); 30$file .= '.com' if $^O eq 'VMS'; 31 32open OUT, ">", $file or die "Can't create $file: $!"; 33 34print "Extracting $file (with variable substitutions)\n"; 35 36# In this section, perl variables will be expanded during extraction. 37# You can use $Config{...} to use Configure variables. 38 39print OUT <<"!GROK!THIS!"; 40$Config{startperl} 41 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' 42 if 0; # ^ Run only under a shell 43!GROK!THIS! 44 45use File::Spec; 46 47my $xsubpp = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, 48 qw(dist ExtUtils-ParseXS 49 lib ExtUtils)), 50 'xsubpp'); 51 52if (open(XSUBPP, '<', $xsubpp)) { 53 print OUT <XSUBPP>; 54 close XSUBPP; 55} else { 56 die "$0: cannot find '$xsubpp'\n"; 57} 58 59close OUT or die "Can't close $file: $!"; 60chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 61exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 62chdir $origdir; 63