This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor File::DosGlob to avoid an unescaped { in a regex.
[perl5.git] / utils / xsubpp.PL
CommitLineData
a55f9fbc
RGS
1#!/usr/local/bin/perl
2
3use Config;
4use File::Basename qw(&basename &dirname);
5use Cwd;
6
7# List explicitly here the variables you want Configure to
8# generate. Metaconfig only looks for shell variables, so you
9# have to mention them as if they were shell variables, not
10# %Config entries. Thus you write
11# $startperl
12# to ensure Configure will look for $Config{startperl}.
13
14# This forces PL files to create target in same directory as PL file.
15# This is so that make depend always knows where to find PL derivatives.
16my $origdir = cwd;
17chdir dirname($0);
18my $file = basename($0, '.PL');
19$file .= '.com' if $^O eq 'VMS';
20
21open OUT,">$file" or die "Can't create $file: $!";
22
23print "Extracting $file (with variable substitutions)\n";
24
25# In this section, perl variables will be expanded during extraction.
26# You can use $Config{...} to use Configure variables.
27
28print OUT <<"!GROK!THIS!";
29$Config{startperl}
30 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
31 if \$running_under_some_shell;
32!GROK!THIS!
33
34use File::Spec;
35
4822030c 36my $xsubpp = File::Spec->catfile(File::Spec->catdir(File::Spec->updir,
cc79184a 37 qw(dist ExtUtils-ParseXS
d27deb09
CB
38 lib ExtUtils)),
39 'xsubpp');
a55f9fbc
RGS
40
41if (open(XSUBPP, $xsubpp)) {
42 print OUT <XSUBPP>;
43 close XSUBPP;
44} else {
45 die "$0: cannot find '$xsubpp'\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;