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