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