source: rtems/tools/update/cipolish @ edb9d70

4.104.114.84.95
Last change on this file since edb9d70 was edb9d70, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/00 at 20:10:00

Patch rtems-rc-20000705-1.diff from Ralf Corsepius <corsepiu@…>.
CVS: ----------------------------------------------------------------------
CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: c/src/tests/libtests/termios/init.c
CVS: ----------------------------------------------------------------------

  • Property mode set to 100755
File size: 4.8 KB
Line 
1#!/usr/bin/perl
2
3#
4# Perl script to beautify and enhance RTEMS configure.in
5#
6# Reads from stdin and writes to stdout
7#
8# usage:
9# acpolish <configure.in >configure.in~
10# mv configure.in~ configure.in
11#
12
13# $Id$
14
15use strict ;
16
17my @vars = () ;
18my @buffer = () ;
19my %var_ ;
20
21# find relative up-path to VERSION
22my $rtems_cfg = &find_file(".","VERSION");
23my $rtems_root = &find_root() ;
24$rtems_root =~ tr/\//\-/ ;
25my $rtems_name = "rtems" ;
26$rtems_name .=  "-" . "$rtems_root" if (length($rtems_root) > 0 ) ;
27
28while ( <> )
29{
30  push @buffer, "$_" ;
31}
32
33{
34  my @tbuf = () ;
35
36  foreach ( @buffer )
37  {
38    if ( /^#.*list.*Makefile.*$/o ) {}
39    elsif ( /^dnl[\s]+check.*target.*cc.*$/o ) {}
40    elsif ( /^[\s]*AC_CONFIG_AUX_DIR\(.*\)[\s]*$/o )
41    {
42      push @tbuf, "AC_CONFIG_AUX_DIR($rtems_cfg)\n" ;
43    }
44    elsif ( /^[\s]*RTEMS_TOP\(.*\)[\s]*$/o )
45    {
46      push @tbuf, "RTEMS_TOP($rtems_cfg)\n" ;
47    }
48    elsif ( /^[\s]*AM_INIT_AUTOMAKE\(.*\)[\s]*$/o )
49    {
50      push @tbuf, "AM_INIT_AUTOMAKE($rtems_name,\$RTEMS_VERSION,no)\n" ;
51    }
52    elsif ( /^[\s]*AC_SUBST\(RTEMS_HAS_POSIX_API\)[\s]*$/o )
53    {
54      #remove the line
55    }
56    elsif ( /^[\s]*AC_SUBST\(RTEMS_HAS_ITRON_API\)[\s]*$/o )
57    {
58      #remove the line
59    }
60    elsif ( /^[\s]*AC_SUBST\(RTEMS_HAS_HWAPI\)[\s]*$/o )
61    {
62      #remove the line
63    }
64    elsif ( /^[\s]*AC_SUBST\(RTEMS_USE_MACROS\)[\s]*$/o )
65    {
66      #remove the line
67    }
68    elsif ( /^[\s]*AC_SUBST\(RTEMS_HAS_MULTIPROCESSING\)[\s]*$/o )
69    {
70      #remove the line
71    }
72    elsif ( /^[\s]*AC_SUBST\(RTEMS_HAS_RDBG\)[\s]*$/o )
73    {
74      #remove the line
75    }
76    elsif ( /^[\s\t]*AC_SUBST\(RTEMS_USE_OWN_PDIR\)[\s]*$/o )
77    { # obsolete option
78      #remove the line
79    }
80    elsif ( /^[\s\t]*RTEMS_ENABLE_GMAKE_PRINT[     ]*$/o )
81    { # obsolete macro
82      #remove the line
83    }
84    elsif ( /^[\s]*AC_SUBST\(RTEMS_HAS_NETWORKING\)[\s]*$/o )
85    {
86      #remove the line
87    }
88    elsif ( /^[\s]*AC_SUBST\(RTEMS_LIBC_DIR\)[\s]*$/o )
89    {
90      #remove the line
91    }
92    elsif ( /^[\s]*AC_SUBST\(PROJECT_ROOT\)[\s]*$/o )
93    {
94      #remove the line
95    }
96    elsif ( /^[\s]*AC_SUBST\(RTEMS_GAS_CODE16\)[\s]*$/o )
97    {
98      #remove the line
99    }
100    elsif ( /^[\s]*PROJECT_ROOT[\s]*=.*$/o )
101    {
102      #remove the line
103    }
104    elsif ( /^[\s]*(RTEMS_ENABLE_LIBCDIR).*$/o )
105    { #remove the line
106      &define_variable("$1","");
107      push @tbuf, "$_" ;
108    }
109    elsif ( /^[\s]*(RTEMS_PROG_CC_FOR_TARGET).*$/o )
110    {
111      &define_variable("$1","");
112      push @tbuf, "$_" ;
113    }
114    elsif ( /^[\s]*(RTEMS_PROG_CXX_FOR_TARGET).*$/o )
115    {
116      &define_variable("$1","");
117      push @tbuf, "$_" ;
118    }
119    else
120    {
121      push @tbuf, "$_" ;
122    }
123  } # foreach
124  @buffer = @tbuf ;
125}
126
127{
128  my @tbuf = () ;
129  foreach ( @buffer )
130  {
131    if ( /^[\s]*(RTEMS_ENABLE_LIBCDIR).*$/o )
132    {
133      if (  ( not variable_seen( "RTEMS_PROG_CC_FOR_TARGET" ) )
134        and ( not variable_seen( "RTEMS_PROG_CXX_FOR_TARGET" ) )
135      )
136      {
137        push @tbuf, "$_" ;
138      }
139    }
140    elsif ( /^AC_OUTPUT.*$/o )
141    {
142      push @tbuf, "# Explicitly list all Makefiles here\n" ;
143      push @tbuf, "$_" ;
144    }
145    else
146    {
147      push @tbuf, "$_" ;
148    }
149  }
150  @buffer = @tbuf ;
151}
152
153{ ## pretty print
154  my $out = join ('',@buffer) ;
155  $out =~ s/\s\#\n(\#\n)+/\n/g ;
156  $out =~ s/\n\n\#\n\n/\n/g ;
157  $out =~ s/\n\n[\n]*/\n\n/g ;
158  print $out ;
159}
160
161exit 1 ;
162
163# find a relative up-path to a file $file, starting at directory $pre
164sub find_file($$)
165{
166  my $pre = $_[0] ;
167  my $file= $_[1] ;
168
169  my $top = "." ;
170  if (not "$pre") { $pre = "." ; }
171
172  for ( my $str = "$pre" . "/" . "$top" ;
173    ( -d "$str" ) ;
174    $str = "$pre" . "/" . "$top" )
175  {
176    if ( -f "${str}/${file}" ) 
177    {
178      return $top ;
179    }
180    if ( "$top" eq "." )
181    {
182      $top = ".." ;
183    }
184    else
185    {
186      $top .= "/.." ;
187    }
188  } ;
189  die "Can't find file ${file}\n" ;
190}
191
192sub find_root()
193{
194  my $top_builddir = "." ;
195  my $subdir="";
196  my $pwd = `pwd`; chomp $pwd;
197  $pwd .= "/" ;
198  my $len ;
199
200  if ( -f "VERSION" )  { return $subdir ; }
201  my $i = rindex($pwd,'/');
202
203  $len = $i;
204  $pwd = substr($pwd,0,$len);
205  $i = rindex($pwd,'/');
206  $subdir = substr($pwd,$i+1,$len - 1);
207  $top_builddir = ".." ; 
208
209  while( -d "$top_builddir" )
210  {
211    if ( -f "${top_builddir}/VERSION" ) 
212    {
213      return $subdir ;
214    }
215    $len=$i;
216    $pwd = substr($pwd,0,$len);
217    $i = rindex($pwd,'/');
218    $subdir = substr($pwd,$i+1,$len - 1) . "/$subdir";
219    $top_builddir .= "/.." ; 
220  } ;
221  die "Can't find VERSION\n" ;
222}
223
224sub variable_seen($)
225{
226  my $label = "$_[0]" ;
227  my $res = defined $var_{"$label"};
228#print STDERR "SEEN: $label ->$res<\n" ;
229  return $res ;
230}
231
232sub define_variable($$)
233{
234  my ($label,@value) = @_ ;
235
236  if ( not variable_seen("$label") )
237  {
238# print STDERR "DEFINING $label\n" ;
239    push @vars, "$label" ;
240  }
241
242  foreach my $i ( @{value} )
243  {
244    push @{$var_{"$label"}}, $i ;
245  }
246}
247
Note: See TracBrowser for help on using the repository browser.