source: rtems/tools/update/ampolish @ 9f4868c

4.104.114.84.95
Last change on this file since 9f4868c was 9f4868c, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/99 at 13:57:02

Miscellaneous patches from Ralf Corsepius <corsepiu@…>
that are part of the Makefile.am conversion effort but were missed
in the previous commits.

  • Property mode set to 100755
File size: 2.3 KB
Line 
1#!/usr/bin/perl
2
3#
4# Perl script to beautify and enhance RTEMS automake Makefile.ams
5#
6# Reads from stdin and writes to stdout
7#
8# usage:
9# <path-to>/ampolish <Makefile.am >Makefile.am~
10# mv Makefile.am~ Makefile.am
11#
12# ATTENTION: This file contains embedded tabs
13
14my $subdirs_seen = "" ;
15
16# find a relative up-path to a file $file, starting at directory $pre
17sub find_file
18{
19  my $pre = $_[0] ;
20  my $file= $_[1] ;
21
22  my $top = "." ;
23  if (not "$pre") { $pre = "." ; }
24
25  for ( $str = "$pre" . "/" . "$top" ;
26    ( -d "$str" ) ;
27    $str = "$pre" . "/" . "$top" )
28  {
29    if ( -f "${str}/${file}" ) 
30    {
31      return $top ;
32    }
33    if ( "$top" eq "." )
34    {
35      $top = ".." ;
36    }
37    else
38    {
39      $top .= "/.." ;
40    }
41  } ;
42  die "Can't find file ${file}\n" ;
43}
44
45# find relative up-path to configure.in
46my $rtems_cfg = find_file(".","configure.in");
47
48# find relative up-path from configure.in to VERSION
49my $rtems_top = find_file("$rtems_cfg","VERSION");
50
51if ( "$rtems_top" eq "." )
52{ $rtems_top = "" ; }
53else { $rtems_top .= "/" ; } 
54
55my $nl_seen = 0 ;
56
57while( <> )
58{ # consume header
59  last if ( /^[^#].*$/ ) ;
60  print "$_" ;
61}
62
63print "\nAUTOMAKE_OPTIONS = foreign 1.4\n";
64if ( "$rtems_cfg" eq "." )
65{
66  print "ACLOCAL_AMFLAGS = -I \$(RTEMS_TOPdir)/aclocal\n"
67}
68
69while( <> )
70{
71  if ( /^[\s\t]*$/o )
72  {
73    $nl_seen = $nl_seen+1;
74  }
75
76  if ( /^[\s\t]*AUTOMAKE_OPTIONS.*$/o )
77  { # remove the line
78  }
79  elsif ( /^[\s\t]*ACLOCAL[\s\t]*=[\s\t]*\@ACLOCAL\@.*$/o )
80  { # remove the line
81  }
82  elsif ( /^[\s\t]*ACLOCAL_AMFLAGS[\s\t]*=[\s\t]*.*$/o )
83  { # remove the line
84  }
85  elsif ( /^[\s\t]*include[\s\t]*\$\(top_srcdir\)[\.\/]*automake\/(.*)\.am$/o )
86  {
87    if ( "$1" eq "lib" )
88    {
89      print "include \$(top_srcdir)/${rtems_top}automake/$1.am\n" ;
90    }
91  }
92  elsif ( /^[\s\t]*include[\s\t]*\$\(RTEMS_ROOT\)\/make\/lib.cfg$/o )
93  {
94    print "include \$(top_srcdir)/${rtems_top}automake/lib.am\n" ;
95  }
96  elsif ( /^[\s\t]*SUBDIRS.*$/o )
97  {
98    $subdirs_seen = "yes" ;
99    print "$_" ;
100    $nl_seen = 0 ;
101  }
102  elsif ( /^[   ]*$/o )
103  {
104    print "$_" if $nl_seen < 2 ;
105  }
106  else
107  {
108    print "$_" ;
109    $nl_seen = 0;
110  }
111} # while
112
113if ( "$subdirs_seen" )
114{
115  print "include \$(top_srcdir)/${rtems_top}automake/subdirs.am\n" ;
116}
117print "include \$(top_srcdir)/${rtems_top}automake/local.am\n" ;
118
119;1
Note: See TracBrowser for help on using the repository browser.