Commit | Line | Data |
---|---|---|
5d437a65 JH |
1 | #!/usr/local/bin/perl |
2 | ||
822cd0f2 DM |
3 | # Copy the cpan/Encode/bin/enc2xs script to utils/, while |
4 | # prepending a suitable #! invocation. | |
5 | ||
5d437a65 JH |
6 | use Config; |
7 | use File::Basename qw(&basename &dirname); | |
8 | use 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. | |
19 | my $origdir = cwd; | |
20 | chdir dirname($0); | |
21 | my $file = basename($0, '.PL'); | |
22 | $file .= '.com' if $^O eq 'VMS'; | |
23 | ||
1ae6ead9 | 24 | open OUT, '>', $file or die "Can't create $file: $!"; |
5d437a65 JH |
25 | |
26 | print "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 | ||
31 | print OUT <<"!GROK!THIS!"; | |
32 | $Config{startperl} | |
33 | eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' | |
188e64dd | 34 | if 0; # ^ Run only under a shell |
5d437a65 JH |
35 | !GROK!THIS! |
36 | ||
37 | use File::Spec; | |
38 | ||
fafe5ad5 | 39 | my $enc2xs = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "cpan", "Encode", "bin"), "enc2xs"); |
5d437a65 | 40 | |
1ae6ead9 | 41 | if (open(ENC2XS, '<', $enc2xs)) { |
5d437a65 JH |
42 | print OUT <ENC2XS>; |
43 | close ENC2XS; | |
44 | } else { | |
45 | die "$0: cannot find '$enc2xs'\n"; | |
46 | } | |
47 | ||
48 | close OUT or die "Can't close $file: $!"; | |
49 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; | |
50 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; | |
51 | chdir $origdir; |