This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add <stdlib.h> for futimes compilation test
[metaconfig.git] / U / mkglossary
index 1406ffa..2bc8ce3 100755 (executable)
@@ -3,24 +3,33 @@
 use strict;
 use warnings;
 
+use Cwd "abs_path";
 use File::Basename;
+use FindBin;
 
-# WARNING:  This is site-specific.  Change to the location
-# where you have installed dist-3.0PL70.
-my @std_units = glob ("/pro/3gl/CPAN/lib/dist/U/*.U");
-my $PWD       =       "/pro/3gl/CPAN/perl";
-
--d "U" and chdir "U";
-my @perl_units = glob ("$PWD/U/*/*.U");
-push (@perl_units, @std_units);
+my $p5_metaconfig_base = abs_path "$FindBin::Bin/../";
 
+chdir "$p5_metaconfig_base/perl" or
+    die "Cannot use $p5_metaconfig_base/perl to find config.sh\n";
+my @config = sort { -M $a <=> -M $b }
+            grep { -s }
+            qw( config.sh uconfig.sh Porting/config.sh );
+@config or die "Build (and test) perl before generating the Glossary\n";
 # Get the list of config.sh symbols.  Be sure this is up to date!
-# (I run the U/mksample script first to be sure.)
-open my $wanted, "< $PWD/Porting/config.sh" or die "$0: open $PWD/Wanted: $!\n";
+# (I run the Porting/mksample script first to be sure.)
+$config[0] eq "config.sh" or warn "Using $config[0] instead of config.sh - Did you build?\n";
+my $wanted = abs_path $config[0];
+
+chdir "$p5_metaconfig_base/U" or
+    die "Cannot use $p5_metaconfig_base/U to find the units\n";
+my @perl_units = map { abs_path $_ } (sort glob "*/*.U"), sort glob "../dist/U/*.U";
+
+open my $wfh, "<", $wanted or die "$0: open $wanted: $!\n";
 my @WANTED = map  { $_->[0] }
             sort { $a->[1] cmp $b->[1] }
-            map  { [ $_, lc $_ ] } <$wanted>;
-close $wanted;
+            map  { [ $_, lc $_ ] }
+            <$wfh>;
+close $wfh;
 
 print <<'EOM';
 
@@ -37,7 +46,7 @@ EOM
 
 my ($Loc, %expl, %file, %predef);
 foreach my $file (@perl_units) {
-    open my $fh, "< $file" or die "$0: open $file: $!";
+    open my $fh, "<", $file or die "$0: open $file: $!";
     my $base = basename ($file);
     $Loc = $file, next if $base eq "Loc.U" and not defined $Loc;
     my @var;
@@ -64,7 +73,7 @@ foreach my $file (@perl_units) {
 
 defined $Loc or die "$0: Couldn't locate Loc.U: $!";
 
-open my $fh, "< $Loc" or die "$0: open $Loc: $!";
+open my $fh, "<", $Loc or die "$0: open $Loc: $!";
 while (<$fh>) {
     m/^\?(\w+):\1$/ and ($expl{$1}, $file{$1}) = (1, "Loc.U");
     }
@@ -196,6 +205,6 @@ config_arg0 (Options.U):
 config_argc (Options.U):
        This variable contains the number of command-line arguments
        passed to Configure, as reported by the shell in the $# variable.
-       The individual arguments are stored as variables config_argc1,
-       config_argc2, etc.
+       The individual arguments are stored as variables config_arg1,
+       config_arg2, etc.