Updated.
[p5sagit/p5-mst-13.2.git] / configpm
index acce1e0..c5a4f63 100755 (executable)
--- a/configpm
+++ b/configpm
@@ -9,6 +9,9 @@ $config_pm = $ARGV[0] || 'lib/Config.pm';
        dynamic_ext static_ext extensions dl_src
        sig_name ccflags cppflags intsize);
 
+# names of things which may need to have slashes changed to double-colons
+@extensions = qw(dynamic_ext static_ext extensions known_extensions);
+
 
 open CONFIG, ">$config_pm" or die "Can't open $config_pm: $!\n";
 $myver = sprintf("%.3f", $]);
@@ -26,7 +29,54 @@ require Exporter;
 
 ENDOFBEG
 
+print CONFIG <<'EndOfPod';
+=head1 NAME
+
+Config - access Perl configuration option
+
+=head1 SYNOPSIS
+
+    use Config;
+    if ($Config{'cc'} =~ /gcc/) {
+       print "built by gcc\n";
+    } 
+
+=head1 DESCRIPTION
+
+The Config module contains everything that was available to the
+C<Configure> program at Perl build time.  Shell variables from
+F<config.sh> are stored in the readonly-variable C<%Config>, indexed by
+their names.
+
+=head1 EXAMPLE
+
+Here's a more sophisticated example of using %Config:
+
+    use Config;
+
+    defined $Config{sig_name} || die "No sigs?";
+    foreach $name (split(' ', $Config{sig_name})) {
+       $signo{$name} = $i;
+       $signame[$i] = $name;
+       $i++;
+    }   
+
+    print "signal #17 = $signame[17]\n";
+    if ($signo{ALRM}) { 
+       print "SIGALRM is $signo{ALRM}\n";
+    }   
+
+=head1 NOTE
+
+This module contains a good example of how to make a variable
+readonly to those outside of it.  
+
+=cut
+
+EndOfPod
+
 @fast{@fast} = @fast;
+@extensions{@extensions} = @extensions;
 @non_v=();
 @v_fast=();
 @v_others=();
@@ -39,7 +89,9 @@ while (<>) {
        push(@non_v, "#$_"); # not a name='value' line
        next;
     }
-    if (!$fast{$1}){ push(@v_others, $_); next; }
+    $name = $1;
+    if ($extensions{$name}) { s,/,::,g }
+    if (!$fast{$name}){ push(@v_others, $_); next; }
     push(@v_fast,$_);
 }
 
@@ -89,10 +141,42 @@ sub EXISTS{
 
 sub readonly { die "\%Config::Config is read-only\n" }
 
+sub myconfig {
+       my($output);
+       
+       $output = <<'END';
+Summary of my $package (patchlevel $PATCHLEVEL) configuration:
+  Platform:
+    osname=$osname, osver=$osvers, archname=$archname
+    uname='$myuname'
+    hint=$hint
+  Compiler:
+    cc='$cc', optimize='$optimize'
+    cppflags='$cppflags'
+    ccflags ='$ccflags'
+    ldflags ='$ldflags'
+    stdchar='$stdchar', d_stdstdio=$d_stdstdio, usevfork=$usevfork
+    voidflags=$voidflags, castflags=$castflags, d_casti32=$d_casti32, d_castneg=$d_castneg
+    intsize=$intsize, alignbytes=$alignbytes, usemymalloc=$usemymalloc, randbits=$randbits
+  Libraries:
+    so=$so
+    libpth=$libpth
+    libs=$libs
+    libc=$libc
+  Dynamic Linking:
+    dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun
+    cccdlflags='$cccdlflags', ccdlflags='$ccdlflags', lddlflags='$lddlflags'
+
+END
+       $output =~ s/\$(\w+)/$Config{$1}/ge;
+       $output;
+}
+
 sub STORE { &readonly }
 sub DELETE{ &readonly }
 sub CLEAR { &readonly }
 
+sub config_sh { $config_sh }
 
 1;
 ENDOFEND