3 # This script reorders config_h.SH after metaconfig
4 # Changing metaconfig is too complicated
6 # Copyright (C) 2005-2005 by H.Merijn Brand (m)'05 [25-05-2005]
8 # You may distribute under the terms of either the GNU General Public
9 # License or the Artistic License, as specified in the README file.
14 my ($cSH, $ch, @ch, %ch) = ("config_h.SH");
15 open $ch, "<$cSH" or die "Cannot open $cSH: $!\n";
25 foreach my $ch (0 .. $#ch) {
26 while ($ch[$ch] =~ m{^/\* ([A-Z]\w+)}gm) {
28 push @{$ref[$ch]}, $1;
36 foreach my $ch (0 .. $#CH) {
37 $CH[$ch] =~ s{/\*.*?\*/\s*}{}gis;
38 while ($CH[$ch] =~ m{\b([A-Z]\w+)}g) {
39 exists $ch{$1} or next;
40 $ch{$1} == $ch and next;
41 #print STDERR "$ref[$ch][0] ($ch) ref to $1 ($ch{$1})\n";
42 $RF{$1}{$ref[$ch][0]}++;
45 foreach my $r (sort keys %RF) {
46 my $R = sprintf "%-20s", $r;
47 print " $r => [ qw ( @{[sort keys %{$RF{$r}}]}\t) ],\n";
51 # This symbol must be defined BEFORE ...
52 BYTEORDER => [ qw( UVSIZE ) ],
53 LONGSIZE => [ qw( BYTEORDER ) ],
54 MULTIARCH => [ qw( BYTEORDER MEM_ALIGNBYTES ) ],
55 USE_CROSS_COMPILE => [ qw( BYTEORDER MEM_ALIGNBYTES ) ],
56 HAS_QUAD => [ qw( I64TYPE ) ],
57 HAS_GETGROUPS => [ qw( Groups_t ) ],
58 HAS_SETGROUPS => [ qw( Groups_t ) ],
65 foreach my $sym (keys %dep) {
67 foreach my $dep (@{$dep{$sym}}) {
68 print STDERR "Check if $sym\t($ch{$sym}) precedes $dep\t($ch{$dep})\n";
69 $ch{$sym} < $ch{$dep} and next;
70 my $ch = splice @ch, $ch{$sym}, 1;
71 splice @ch, $ch{$dep}, 0, $ch;