summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/Makefile.am2
-rw-r--r--tools/build/Makefile.am13
-rw-r--r--tools/cpu/Makefile.am2
-rw-r--r--tools/cpu/generic/Makefile.am4
-rw-r--r--tools/cpu/generic/size_rtems.in4
-rw-r--r--tools/cpu/hppa1.1/Makefile.am13
-rw-r--r--tools/cpu/sh/Makefile.am18
-rw-r--r--tools/cpu/sh/configure.in5
-rw-r--r--tools/cpu/sh/shgen.c78
-rw-r--r--tools/cpu/unix/Makefile.am6
-rw-r--r--tools/cpu/unix/gensize.c1
-rw-r--r--tools/update/Makefile.am25
-rwxr-xr-xtools/update/acpolish62
-rwxr-xr-xtools/update/ampolish526
-rwxr-xr-xtools/update/cipolish15
-rwxr-xr-xtools/update/rtems-polish.sh2
16 files changed, 609 insertions, 167 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index baddc06279..7d5befb104 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -5,4 +5,4 @@ AUTOMAKE_OPTIONS = foreign 1.4
SUBDIRS = build cpu update
include $(top_srcdir)/automake/subdirs.am
-include $(top_srcdir)/automake/local.am
+include $(top_srcdir)/automake/host.am
diff --git a/tools/build/Makefile.am b/tools/build/Makefile.am
index 55012a65ce..81ba93bece 100644
--- a/tools/build/Makefile.am
+++ b/tools/build/Makefile.am
@@ -5,21 +5,18 @@
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
-bin_PROGRAMS = cklength eolstrip packhex unhex
+bin_PROGRAMS = cklength eolstrip packhex unhex
noinst_PROGRAMS = binpatch
cklength_SOURCES = cklength.c
eolstrip_SOURCES = eolstrip.c
-packhex_SOURCES = packhex.c
-unhex_SOURCES = unhex.c
+packhex_SOURCES = packhex.c
+unhex_SOURCES = unhex.c
binpatch_SOURCES = binpatch.c
-bin_SCRIPTS=\
-install-if-change \
-lock-directory \
-unlock-directory
+bin_SCRIPTS = install-if-change lock-directory unlock-directory
noinst_SCRIPTS = search-id.sh
-include $(top_srcdir)/../../automake/local.am
+include $(top_srcdir)/../../automake/host.am
diff --git a/tools/cpu/Makefile.am b/tools/cpu/Makefile.am
index cf41512cdb..e1dc9607a4 100644
--- a/tools/cpu/Makefile.am
+++ b/tools/cpu/Makefile.am
@@ -10,4 +10,4 @@ SUBDIRS = @subdirs@
DIST_SUBDIRS = generic hppa1.1 sh unix
include $(top_srcdir)/../../automake/subdirs.am
-include $(top_srcdir)/../../automake/local.am
+include $(top_srcdir)/../../automake/host.am
diff --git a/tools/cpu/generic/Makefile.am b/tools/cpu/generic/Makefile.am
index 0cd7a9ebd7..0d6f395093 100644
--- a/tools/cpu/generic/Makefile.am
+++ b/tools/cpu/generic/Makefile.am
@@ -5,5 +5,5 @@
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
-noinst_SCRIPTS=size_rtems
-include $(top_srcdir)/../../../automake/local.am
+noinst_SCRIPTS = size_rtems
+include $(top_srcdir)/../../../automake/host.am
diff --git a/tools/cpu/generic/size_rtems.in b/tools/cpu/generic/size_rtems.in
index b913e4575a..14c91917d8 100644
--- a/tools/cpu/generic/size_rtems.in
+++ b/tools/cpu/generic/size_rtems.in
@@ -46,14 +46,14 @@ case $target in
echo Not supported on unix port.
exit 0
;;
- i[3456]86-pc-linux-gnu)
+ i[34567]86-pc-linux-gnu)
echo linux
rtems_cpu=unix
bsp=linux1
echo Not supported on unix port.
exit 0
;;
- i[3456]86-unknown-freebsd2.[12]*)
+ i[34567]86-unknown-freebsd2.[12]*)
echo freebsd
rtems_cpu=unix
bsp=freebsd2
diff --git a/tools/cpu/hppa1.1/Makefile.am b/tools/cpu/hppa1.1/Makefile.am
index 2b64579122..ebbd28bc02 100644
--- a/tools/cpu/hppa1.1/Makefile.am
+++ b/tools/cpu/hppa1.1/Makefile.am
@@ -5,17 +5,14 @@
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
-noinst_PROGRAMS=genoffsets
+noinst_PROGRAMS = genoffsets
-genoffsets_SOURCES = \
-genoffsets.c
+genoffsets_SOURCES = genoffsets.c
## We use files that have not been installed yet.
-CPU_DIR=../../cpu/$(RTEMS_CPU)
+CPU_DIR = ../../cpu/$(RTEMS_CPU)
-INCLUDES = \
--I$(PROJECT_INCLUDE) \
--I$(CPU_DIR)
+AM_CPPFLAGS = -I$(PROJECT_INCLUDE) -I$(CPU_DIR)
-include $(top_srcdir)/../../../automake/local.am
+include $(top_srcdir)/../../../automake/host.am
diff --git a/tools/cpu/sh/Makefile.am b/tools/cpu/sh/Makefile.am
index 2eb28edb70..541f1758b5 100644
--- a/tools/cpu/sh/Makefile.am
+++ b/tools/cpu/sh/Makefile.am
@@ -2,14 +2,18 @@
## $Id$
##
-AUTOMAKE_OPTIONS = foreign 1.4
+AUTOMAKE_OPTIONS = foreign 1.4 no-installman
ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
-noinst_PROGRAMS=shgen
+noinst_PROGRAMS = shgen
-shgen_SOURCES = \
-sci.h \
-sci.c \
-shgen.c
+shgen_SOURCES = sci.h sci.c shgen.c
-include $(top_srcdir)/../../../automake/local.am
+if HELP2MAN
+man_MANS = shgen.1
+
+shgen.1: $(srcdir)/shgen.c
+ $(HELP2MAN) -N shgen >$@
+endif
+
+include $(top_srcdir)/../../../automake/host.am
diff --git a/tools/cpu/sh/configure.in b/tools/cpu/sh/configure.in
index 0b718ef87e..368e95b79b 100644
--- a/tools/cpu/sh/configure.in
+++ b/tools/cpu/sh/configure.in
@@ -8,12 +8,15 @@ AC_CONFIG_AUX_DIR(../../..)
RTEMS_CANONICAL_TARGET_CPU
-AM_INIT_AUTOMAKE(rtems-tools-cpu-sh,$RTEMS_VERSION,no)
+AM_INIT_AUTOMAKE(rtems-tools-cpu-sh,0.4)
AM_MAINTAINER_MODE
AC_EXEEXT
AC_PROG_CC
AC_CHECK_LIB(m,fabs)
+AC_CHECK_FUNCS(getopt_long)
+AC_CHECK_PROGS(HELP2MAN,help2man)
+AM_CONDITIONAL(HELP2MAN,test -n "$HELP2MAN" )
RTEMS_TOOLPATHS
diff --git a/tools/cpu/sh/shgen.c b/tools/cpu/sh/shgen.c
index c101388ad8..6fc262d694 100644
--- a/tools/cpu/sh/shgen.c
+++ b/tools/cpu/sh/shgen.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-1999 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
+ * Copyright (c) 1998,1999,2000 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
*
* See the file COPYING for copyright notice.
*/
@@ -11,25 +11,44 @@
#include "sci.h"
-static void usage( char *prog )
+static void usage( FILE* ofile, char *prog )
{
- fprintf( stderr, "usage: %s [options] driver\n", prog );
- fprintf( stderr, "options:\n" );
- fprintf( stderr, "\t-M Phi .. processor frequency [MHz]\n" );
- fprintf( stderr, "\t-K Phi .. processor frequency [KHz]\n" );
- fprintf( stderr, "\t-H Phi .. processor frequency [Hz]\n" );
- fprintf( stderr, "\t\t..default 20MHz" );
- fprintf( stderr, "driver:\n" );
- fprintf( stderr, "\tsci .. bitrate table for sci\n" );
- exit ( 1 );
+ fprintf( ofile, "Usage: %s [options] driver\n", prog );
+ fprintf( ofile, "\nOptions:\n" );
+ fprintf( ofile, "Processor frequency (default 20MHz):\n") ;
+ fprintf( ofile, "\t-M Phi .. processor frequency [MHz]\n" );
+ fprintf( ofile, "\t-K Phi .. processor frequency [KHz]\n" );
+ fprintf( ofile, "\t-H Phi .. processor frequency [Hz]\n" );
+ fprintf( ofile, "Driver:\n" );
+ fprintf( ofile, "\tsci .. bitrate table for sci\n" );
+
+ fprintf( ofile, "\nWritten by Ralf Corsepius <corsepiu@faw.uni-ulm.de>\n" );
+ fprintf( ofile, "\nCopyright (c) 1998,1999,2000\tRalf Corsepius\n" );
}
+#if HAVE_GETOPT_LONG
+#define NOARG 0
+#define HASARG 1
+#define OPTARG 2
+
+static struct option long_options[] =
+{
+ { "version", NOARG, NULL, 'v' },
+ { "help", NOARG, NULL, 'h' },
+ { "mega-hertz", HASARG, NULL, 'M' },
+ { "kilo-hertz", HASARG, NULL, 'K' },
+ { "hertz", HASARG, NULL, 'H' },
+ { 0, 0, 0, 0 }
+};
+#endif
+
static void shgen_header( FILE *file )
{
fprintf( file,
- "/*\n * DO NOT EDIT - this file is automatically generated by shgen 0.3\n" );
+ "/*\n * DO NOT EDIT - this file is automatically generated by shgen %s\n",
+ VERSION );
fprintf( file,
- " * Copyright (c) 1998-1999, Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
+ " * Copyright (c) 1998,1999,2000 Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
fprintf( file,
"\n/* This file is not copyrighted */\n\n" );
}
@@ -37,8 +56,14 @@ static void shgen_header( FILE *file )
int main( int argc, char *argv[] )
{
double Phi = 20.0 ;
-
- while ( ( optopt = getopt( argc, argv, "M:K:H:" ) ) > 0 )
+
+#if HAVE_GETOPT_LONG
+ int option_index = 0 ;
+ while( ( optopt = getopt_long( argc, argv, "M:K:H:hv",
+ long_options, &option_index ) ) > 0 )
+#else
+ while ( ( optopt = getopt( argc, argv, "M:K:H:hv" ) ) > 0 )
+#endif
{
switch ( optopt )
{
@@ -51,17 +76,27 @@ int main( int argc, char *argv[] )
Phi = Phi * 1000.0;
break ;
case 'H' :
- sscanf( optarg, "%lf", &Phi );
+ sscanf( optarg, "%lf", &Phi );
break ;
+ case 'h' :
+ usage( stdout, argv[0] );
+ exit(0);
+ case 'v' :
+ fprintf( stdout, "%s version %s\n", argv[0], VERSION );
+ exit(0);
default :
- usage( argv[0] );
+ usage( stderr, argv[0] );
+ exit(1);
break ;
}
}
if ( argc - optind != 1 )
- usage( argv[0] );
-
+ {
+ fprintf( stderr, "%s: Missing argument: driver\n", argv[0] );
+ exit(1);
+ }
+
shgen_header( stdout );
if ( strcmp( argv[optind], "sci" ) == 0 )
@@ -69,7 +104,10 @@ int main( int argc, char *argv[] )
shgen_gensci( stdout, Phi );
}
else
- usage( argv[0] );
+ {
+ fprintf( stderr, "%s: Invalid argument: driver\n", argv[0] );
+ exit(1);
+ }
return 0 ;
}
diff --git a/tools/cpu/unix/Makefile.am b/tools/cpu/unix/Makefile.am
index 8104ed7c87..1ade15085d 100644
--- a/tools/cpu/unix/Makefile.am
+++ b/tools/cpu/unix/Makefile.am
@@ -5,8 +5,8 @@
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
-noinst_PROGRAMS=gensize
+noinst_PROGRAMS = gensize
-gensize_SOURCES=gensize.c
+gensize_SOURCES = gensize.c
-include $(top_srcdir)/../../../automake/local.am
+include $(top_srcdir)/../../../automake/host.am
diff --git a/tools/cpu/unix/gensize.c b/tools/cpu/unix/gensize.c
index 41c28bbf52..2d848e0a94 100644
--- a/tools/cpu/unix/gensize.c
+++ b/tools/cpu/unix/gensize.c
@@ -36,6 +36,7 @@
typedef struct {
jmp_buf regs;
int isr_level;
+ int pad[4]; /* just in case */
} Context_Control;
int main(
diff --git a/tools/update/Makefile.am b/tools/update/Makefile.am
index 05a1bf959e..6277439559 100644
--- a/tools/update/Makefile.am
+++ b/tools/update/Makefile.am
@@ -4,6 +4,7 @@
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
+
## NOTE: It doesn't make much sense to install these files
CLEANFILES = update word-replace
@@ -12,16 +13,10 @@ if PERL
# All files in this directory depend on having perl.
# Do not handle them if perl is missing.
-noinst_SCRIPTS = \
-acpolish \
-ampolish \
-cipolish \
-rtems-polish.sh \
-word-replace \
-update
+noinst_SCRIPTS = acpolish ampolish cipolish rtems-polish.sh word-replace \
+ update
-noinst_DATA = \
-310_to_320_list
+noinst_DATA = 310_to_320_list
update: $(srcdir)/update.in $(top_builddir)/config.status
@cd $(top_builddir) \
@@ -35,13 +30,7 @@ word-replace: $(srcdir)/word-replace.in $(top_builddir)/config.status
endif
-EXTRA_DIST = \
-310_to_320_list \
-update.in \
-word-replace.in \
-acpolish \
-ampolish \
-cipolish \
-rtems-polish.sh
+EXTRA_DIST = 310_to_320_list update.in word-replace.in acpolish ampolish \
+ cipolish rtems-polish.sh
-include $(top_srcdir)/../../automake/local.am
+include $(top_srcdir)/../../automake/host.am
diff --git a/tools/update/acpolish b/tools/update/acpolish
index 5de711f60c..0a739fd9cf 100755
--- a/tools/update/acpolish
+++ b/tools/update/acpolish
@@ -1,10 +1,8 @@
#!/usr/bin/perl
-# use strict 'subs' ;
-# use strict 'vars' ;
-# use strict 'refs' ;
+use strict ;
-# use strict ;
+sub print_macro($$);
#
# Perl script to beautify and enhance RTEMS autoconf Makefile.ins
@@ -40,27 +38,6 @@ my @files = () ;
my @variants = () ;
my @vars = () ;
-sub print_macro($$)
-{
- my $line = $_[0] ;
- my $input = $_[1] ;
- $input =~ s/\\\\/ /g;
- my @l = split(' ',$input);
-
- foreach (@l) {
- if ( ( length($line) + length($_) ) < 76 )
- {
- $line .= " $_";
- }
- else
- {
- print "$line \\\n";
- $line = " $_" ;
- }
- }
- print "$line\n" ;
-}
-
# Strip off duplicate entries from a list
sub purge($)
{
@@ -180,8 +157,8 @@ sub subst_line
{
my $files =`ls *.h 2>/dev/null`;
print STDERR "WARNING: Replacing \"\(wildcard... in $_\n" ;
- $line = "H_FILES =";
- @l = split(' ',$files) ;
+ my $line = "H_FILES =";
+ my @l = split(' ',$files) ;
foreach(@l) { $line .= " \$\(srcdir\)/$_"; }
$line .= "\n" ;
$_ = "$line" ;
@@ -214,7 +191,7 @@ sub subst_line
my @ibuf = () ;
my $line = "" ;
- while ( <> )
+ while ( <STDIN> )
{
&subst_line ;
if ( /^(#.*)$/o )
@@ -618,7 +595,7 @@ if ( $experimental > 1 )
{
print "mkinstalldirs = \$(SHELL) \$(top_srcdir)/\@RTEMS_TOPdir\@/mkinstalldirs\n\n" ;
my $line = join( ' ',@installdirs );
- print_macro "INSTALLDIRS =", $line ;
+ &print_macro( "INSTALLDIRS =", $line );
print "\n\$(INSTALLDIRS):\n\t\@\$(mkinstalldirs) \$(INSTALLDIRS)\n\n" ;
$nl_seen = 1 ;
}
@@ -633,12 +610,12 @@ if ( $experimental > 1 )
}
elsif ( /^\§4(.*)$/o )
{ # pretty print a make variable
- print_macro "$1 =", ${"var_$1"} ;
+ &print_macro( "$1 =", ${"var_$1"} );
$nl_seen = 0 ;
}
elsif ( /^\§5(.*)$/o )
{ # pretty print an addition to a make variable
- print_macro "$1 +=", ${"var_$1+"} ;
+ &print_macro( "$1 +=", ${"var_$1+"}) ;
$nl_seen = 0 ;
}
else
@@ -678,4 +655,25 @@ print " \$(ACLOCAL_M4)\n" ;
print "\tcd \$(srcdir) && \$(AUTOCONF)\n"
}
-;1
+exit 0 ;
+
+sub print_macro($$)
+{
+ my ($line,$input) = @_ ;
+ $input =~ s/\\\\/ /g;
+ my @l = split(' ',$input);
+
+ foreach (@l) {
+ if ( ( length($line) + length($_) ) < 76 )
+ {
+ $line .= " $_";
+ }
+ else
+ {
+ print "$line \\\n";
+ $line = " $_" ;
+ }
+ }
+ print "$line\n" ;
+}
+
diff --git a/tools/update/ampolish b/tools/update/ampolish
index 265a3bc76c..0856798ce6 100755
--- a/tools/update/ampolish
+++ b/tools/update/ampolish
@@ -1,5 +1,9 @@
#!/usr/bin/perl
+package main ;
+
+use strict ;
+
#
# Perl script to beautify and enhance RTEMS automake Makefile.ams
#
@@ -9,9 +13,341 @@
# <path-to>/ampolish <Makefile.am >Makefile.am~
# mv Makefile.am~ Makefile.am
#
-# ATTENTION: This file contains embedded tabs
-my $subdirs_seen = "" ;
+my @vars ;
+my @conditions = ( "" ) ;
+my @buffer = ();
+my %var_ ;
+
+define_variable( "\$(AUTOMAKE_OPTIONS)", ( "foreign", "1.4" ) );
+define_variable( "\$(VPATH)", ( "\@srcdir\@" ) );
+
+# find relative up-path to configure.in
+my $rtems_cfg = find_file(".","configure.in");
+
+# find relative up-path from configure.in to VERSION
+my $rtems_top = find_file("$rtems_cfg","VERSION");
+
+if ( "$rtems_top" eq "." ) { $rtems_top = "" ; }
+else { $rtems_top .= "/" ; }
+
+{
+# PASS1:
+# read input file and concatenate multiple lines into single lines.
+
+ my @ibuf = () ;
+
+ while( <STDIN> )
+ { # consume header
+ last if ( /^[^#].*$/ ) ;
+ push @ibuf, "$_" ;
+ }
+
+ push @ibuf, "§header\n" ;
+
+ do
+ {
+ if ( /^(#.*)$/o )
+ { # preserve comments
+ push @ibuf, "$_" ;
+ }
+ elsif ( /^(\t.*)\\[\s]*$/o )
+ { # multilines for scripts
+ my $line = "$1§" ;
+ while( <STDIN> )
+ {
+ if ( /^(.*)\\[\s]*$/o )
+ {
+ $line .= "$1§" ;
+ }
+ else
+ {
+ $line .= "$_" ;
+ push @ibuf, $line ;
+ last ;
+ }
+ }
+ }
+ elsif ( /^(.*)\\[\s]*$/o )
+ { # multilines
+ my $line = "$1" ;
+ while( <STDIN> )
+ {
+ if ( /^(.*)\\[\s]*$/o )
+ {
+ $line .= "$1" ;
+ }
+ else
+ {
+ $line .= "$_" ;
+ $line =~ s%[\s]+% %g ;
+ push @ibuf, "$line\n" ;
+ last ;
+ }
+ }
+ }
+ else
+ {
+ push @ibuf, "$_" ;
+ }
+ } while ( <STDIN> ) ;
+ @buffer = @ibuf ;
+}
+
+{
+# PASS2:
+# fix obsolete constructs
+ my @ibuf = () ;
+
+ foreach ( @buffer )
+ {
+# tr /\{\}/\(\)/ ;
+
+ if ( /^(TMP|PRE)INSTALL_FILES[\s]*=(.*)$/o )
+ { # force "+="
+ push @ibuf, "$1INSTALL_FILES +=$2\n" ;
+ }
+ elsif ( /^(VPATH|EXTRA_DIST)[\s]*\+=(.*)$/o )
+ { # force "="
+ push @ibuf, "$1 = $2\n" ;
+ }
+ elsif ( /^[\s]*ACLOCAL[\s]*=[\s]*\@ACLOCAL\@.*$/o )
+ { # remove the line
+ }
+ elsif ( /^[\s]*(ACLOCAL_AMFLAGS)[\s\t]*[\+]*=[\s]*(.*)[\s]*$/o )
+ { # remove the line
+ }
+ elsif ( /^[\s]*(AM_CFLAGS)[\s\t]*[\+]*=[\s]*\$\(CFLAGS_OS_V\)[\s]*$/o )
+ { # remove the line
+ }
+ elsif ( /^[\s]*debug-am:.*$/o )
+ { # remove the line
+ }
+ elsif ( /^[\s]*all(\-am):(.*)$/o )
+ { # replace the line
+ push @ibuf, "all-local:$2\n" ;
+ }
+ elsif ( /^[\s]*profile-am:.*$/o )
+ { # remove the line
+ }
+ elsif ( /^[\s]*include[\s\t]*\$\(RTEMS_ROOT\)\/make\/lib.cfg[\s]*$/o )
+ {
+ push @ibuf, "include \$(top_srcdir)/${rtems_top}automake/lib.am\n" ;
+ }
+ elsif ( /^(.*[^\s])[\s]*$/o )
+ { # remove trailing spaces
+ push @ibuf, "$1\n" ;
+ }
+ else
+ {
+ push @ibuf, "$_" ;
+ }
+ }
+ @buffer = @ibuf ;
+}
+
+# print STDERR "<tmp>\n", @buffer, "</tmp>\n" ;
+
+{
+ my @ibuf = () ;
+ foreach ( @buffer )
+ {
+ if ( /^#(.*)$/o )
+ {
+ push @ibuf, "#$1\n" ;
+ }
+ elsif ( /^[\s]*if[\s\t]+([a-zA-Z0-9_]+)[\s\t]*$/o )
+ {
+ push @conditions, "\@" . $1 . "_TRUE\@" ;
+ push @ibuf, "if $1\n" ;
+ }
+ elsif ( /^[\s]*else[\s\t]*$/o )
+ {
+ @conditions[$#conditions] =~ s/_TRUE\@$/_FALSE\@/;
+ push @ibuf, "else\n" ;
+ }
+ elsif ( /^[\s]*endif[\s\t]*$/o )
+ {
+ pop @conditions ;
+ push @ibuf, "endif\n" ;
+ }
+ elsif ( /^§.*$/o )
+ {
+ push @ibuf, "$_" ;
+ }
+ elsif ( /^[\s]*(VPATH)[\s\t]*([\+]*)=[\s]*(.*)[\s]*$/o )
+ {
+ my $lh = "\$($1)" ;
+ my @rh = split( /:/,"$3");
+ if ( $#conditions > 0 )
+ {
+ print STDERR "WARNING: $1 must not be set inside of conditionals!\n"
+ }
+ define_variable( "$lh", @rh );
+
+ }
+ elsif ( /^[\s]*(AUTOMAKE_OPTIONS)[\s\t]*([\+]*)=[\s]*(.*)$/o )
+ {
+ my $lh = "\$($1)" ;
+ my @rh = &split_vars("$3");
+
+ if ( $#conditions > 0 )
+ {
+ print STDERR "WARNING: $1 must not be set inside of conditionals!\n"
+ }
+
+ define_variable( "$lh", @rh );
+ }
+ elsif ( /^[\s]*([a-zA-Z0-9_]+)[\s\t]*([\+]*)=[\s]*(.*)$/o )
+ {
+ my $lh = join ('',@conditions) . "\$($1)" ;
+ my @rh = &split_vars("$3");
+ my $seen = variable_seen( "$lh" ) ;
+
+ if ( $#conditions > 0 )
+ {
+ define_variable( "\$($1)", () );
+ }
+
+ define_variable( "$lh", @rh );
+
+ if ( not $seen )
+ {
+ push @ibuf, "§$2var_$lh\n" ;
+ }
+ }
+ elsif ( /^[\s]*include[\s\t]*\$\(top_srcdir\)[\.\/]*automake\/(.*)\.am$/o )
+ {
+ if ( "$1" eq "lib" )
+ {
+ push @ibuf, "include \$(top_srcdir)/${rtems_top}automake/$1.am\n" ;
+ }
+ elsif ( "$1" eq "local" )
+ {
+ $main::seen_local = 1 ;
+ }
+ elsif ( "$1" eq "host" )
+ {
+ $main::seen_host = 1 ;
+ }
+ }
+ elsif ( /^[\s]*include[\s\t]*(.*)$/o )
+ {
+ push @ibuf, "include $1\n" ;
+ }
+ elsif ( /^\t(.*)$/o )
+ {
+ push @ibuf, "\t$1\n" ;
+ }
+ elsif ( /^(.*)\:(.*)$/o )
+ {
+ push @ibuf, "$1:$2\n" ;
+ }
+ elsif ( /^[\s]*$/o )
+ {
+ push @ibuf, "\n" ;
+ }
+ else
+ {
+ die "ERROR: Don't know how to handle <$_>" ;
+ }
+ } # for
+ @buffer = @ibuf ;
+} # while
+
+die "Conditional stack corrupted" if ( $#conditions != 0 );
+
+foreach( @vars )
+{
+ purge( \@{$var_{"$_"}} );
+}
+
+# print STDERR "<tmp>\n", @buffer, "</tmp>\n" ;
+
+
+{
+ my @ibuf = () ;
+ foreach( @buffer )
+ {
+ if ( /^#.*$/o )
+ {
+ push @ibuf, "$_" ;
+ }
+ elsif( /^§header$/o )
+ {
+ my $l = $var_{"\$(AUTOMAKE_OPTIONS)"} ;
+ push @ibuf, "\nAUTOMAKE_OPTIONS = @{$l}\n" ;
+ if ( "$rtems_cfg" eq "." )
+ {
+ push @ibuf, "ACLOCAL_AMFLAGS = -I \$(RTEMS_TOPdir)/aclocal\n" ;
+ }
+ if ( defined( @{$var_{"\$(VPATH)"}} ) )
+ {
+ if ( $#{$var_{"\$(VPATH)"}} > 0 )
+ {
+ my $l = join (':',@{$var_{"\$(VPATH)"}}) ;
+ push @ibuf, "\nVPATH = $l\n" ;
+ }
+ }
+ push @ibuf, "\n" ;
+ }
+ elsif ( /^§(\+|)var_(.*)\$\((.*)\)$/o )
+ {
+ print_var(\@ibuf, "$3 $1=", $var_{"$2\$($3)"}) ;
+ }
+ elsif ( /^\t.*$/o )
+ {
+ &print_script(\@ibuf, "$_");
+ }
+ elsif ( /^[\s]*if[\s]+([a-zA-Z0-9_]+)[\s\t]*$/o )
+ {
+ push @conditions, "\@$1_TRUE\@" ;
+ push @ibuf, "if $1\n" ;
+ }
+ elsif ( /^[\s]*else[\s]*$/o )
+ {
+ @conditions[$#conditions] =~ s/_TRUE\@$/_FALSE\@/;
+ push @ibuf, "else\n" ;
+ }
+ elsif ( /^[\s]*endif[\s]*$/o )
+ {
+ pop @conditions ;
+ push @ibuf, "endif\n" ;
+ }
+ else
+ {
+ print_line(\@ibuf,$_);
+ }
+ }
+
+ if ( variable_seen("\$(SUBDIRS)") )
+ {
+ push @ibuf, "include \$(top_srcdir)/${rtems_top}automake/subdirs.am\n" ;
+ }
+
+ if ( defined( $main::seen_host ) )
+ {
+ push @ibuf, "include \$(top_srcdir)/${rtems_top}automake/host.am\n" ;
+ }
+ else
+ {
+ push @ibuf, "include \$(top_srcdir)/${rtems_top}automake/local.am\n" ;
+ }
+
+ @buffer = @ibuf ;
+}
+
+#print STDERR "<tmp>\n", @buffer, "</tmp>\n" ;
+
+{ ## pretty print
+ my $out = join ('',@buffer) ;
+ $out =~ s/\s\#\n(\#\n)+/\n/g ;
+ $out =~ s/\n\n\#\n\n/\n/g ;
+ $out =~ s/\n\n[\n]*/\n\n/g ;
+ print $out ;
+}
+
+exit 0;
# find a relative up-path to a file $file, starting at directory $pre
sub find_file
@@ -22,7 +358,7 @@ sub find_file
my $top = "." ;
if (not "$pre") { $pre = "." ; }
- for ( $str = "$pre" . "/" . "$top" ;
+ for ( my $str = "$pre" . "/" . "$top" ;
( -d "$str" ) ;
$str = "$pre" . "/" . "$top" )
{
@@ -42,78 +378,154 @@ sub find_file
die "Can't find file ${file}\n" ;
}
-# find relative up-path to configure.in
-my $rtems_cfg = find_file(".","configure.in");
-
-# find relative up-path from configure.in to VERSION
-my $rtems_top = find_file("$rtems_cfg","VERSION");
-
-if ( "$rtems_top" eq "." )
-{ $rtems_top = "" ; }
-else { $rtems_top .= "/" ; }
-
-my $nl_seen = 0 ;
-
-while( <> )
-{ # consume header
- last if ( /^[^#].*$/ ) ;
- print "$_" ;
+sub variable_seen($)
+{
+ my $label = "$_[0]" ;
+ my $res = defined $var_{"$label"};
+#print STDERR "SEEN: $label ->$res<\n" ;
+ return $res ;
}
-print "\nAUTOMAKE_OPTIONS = foreign 1.4\n";
-if ( "$rtems_cfg" eq "." )
+sub define_variable($$)
{
- print "ACLOCAL_AMFLAGS = -I \$(RTEMS_TOPdir)/aclocal\n"
-}
+ my ($label,@value) = @_ ;
-while( <> )
-{
- if ( /^[\s\t]*$/o )
+ if ( not variable_seen("$label") )
{
- $nl_seen = $nl_seen+1;
+#print STDERR "DEFINING: $label\n" ;
+ push @vars, "$label" ;
}
- if ( /^[\s\t]*AUTOMAKE_OPTIONS.*$/o )
- { # remove the line
- }
- elsif ( /^[\s\t]*ACLOCAL[\s\t]*=[\s\t]*\@ACLOCAL\@.*$/o )
- { # remove the line
- }
- elsif ( /^[\s\t]*ACLOCAL_AMFLAGS[\s\t]*=[\s\t]*.*$/o )
- { # remove the line
+ foreach my $i ( @{value} )
+ {
+ push @{$var_{"$label"}}, $i ;
}
- elsif ( /^[\s\t]*include[\s\t]*\$\(top_srcdir\)[\.\/]*automake\/(.*)\.am$/o )
+}
+
+# Strip off duplicate entries from a list
+sub purge($)
+{
+ my $list = $_[0] ; # Reference to list !
+ my (@tmp) = () ;
+
+ foreach my $l ( @{$list} )
{
- if ( "$1" eq "lib" )
+ my $i = 1 ;
+ foreach my $t (@tmp)
{
- print "include \$(top_srcdir)/${rtems_top}automake/$1.am\n" ;
+ if ( $t eq $l )
+ {
+ $i = 0 ;
+ last ;
+ }
}
+ push @tmp,$l if ($i) ;
}
- elsif ( /^[\s\t]*include[\s\t]*\$\(RTEMS_ROOT\)\/make\/lib.cfg$/o )
- {
- print "include \$(top_srcdir)/${rtems_top}automake/lib.am\n" ;
- }
- elsif ( /^[\s\t]*SUBDIRS.*$/o )
+
+ @{$list} = @tmp ;
+}
+
+#
+# Break the right hand side of a variable assignment into separate chunks
+#
+sub split_vars($)
+{
+ my $line = $_[0] ;
+ my (@buf) = split(//,"$line") ;
+
+ my $begin = 0 ;
+ my @res = () ;
+
+ my $depth = 0 ;
+ my $state = 0 ;
+
+ my $len = $#buf + 1 ;
+ for ( my $i = 0 ; $i < $len ; $i++ )
{
- $subdirs_seen = "yes" ;
- print "$_" ;
- $nl_seen = 0 ;
+ my $c = @buf[$i] ;
+ if ( $state == 0 )
+ {
+ if ( "$c" ne " " )
+ { # token
+ $begin = $i ;
+ $state++ ;
+ }
+ if ( "$c" eq "\$" )
+ { # variable
+ $depth++ ;
+ }
+ }
+ elsif ( $state == 1 )
+ {
+ if ( ( "$c" eq "\)" ) or ( "$c" eq "\}" ) )
+ { # variable
+ $depth-- ;
+ }
+ elsif ( ("$c" eq " " ) and ( $depth == 0 ) )
+ {
+ push @res, substr($line,$begin,$i-$begin);
+ $state-- ;
+ }
+ elsif ( "$c" eq "\$" )
+ { # variable
+ $depth++ ;
+ }
+ }
+ else
+ {
+ die "split_vars: unknown mode\n" ;
+ }
}
- elsif ( /^[ ]*$/o )
+
+ if ( $state > 0 )
{
- print "$_" if $nl_seen < 2 ;
+ push @res, substr($line,$begin,$len-$begin);
+ $state = 0
}
- else
- {
- print "$_" ;
- $nl_seen = 0;
+ return @res ;
+}
+
+sub print_var($$$)
+{
+ my ($ibuf,$line,$l) = @_ ; # $l .. reference to list
+
+ foreach (@{$l}) {
+ if ( ( length($line) + length($_) ) < 76 )
+ {
+ $line .= " $_";
+ }
+ else
+ {
+ push @{$ibuf}, "$line \\\n";
+ $line = " $_" ;
+ }
}
-} # while
+ push @{$ibuf}, "$line\n" ;
+}
-if ( "$subdirs_seen" )
+sub print_line($$)
{
- print "include \$(top_srcdir)/${rtems_top}automake/subdirs.am\n" ;
+ my ($ibuf,$input) = @_ ;
+ my @l = split( / /, $input );
+ my $line = shift @l ;
+
+ foreach my $i (@l) {
+ if ( ( length($line) + length($i) ) < 76 )
+ {
+ $line .= " $i";
+ }
+ else
+ {
+ push @{$ibuf}, "$line \\\n";
+ $line = " $i" ;
+ }
+ }
+ push @{$ibuf}, "$line" ;
}
-print "include \$(top_srcdir)/${rtems_top}automake/local.am\n" ;
-;1
+sub print_script($$)
+{
+ my ($ibuf,$input) = @_ ;
+ $input =~ s%§%\\\n%g ;
+ push @{$ibuf}, $input ;
+}
diff --git a/tools/update/cipolish b/tools/update/cipolish
index c04e0c52c6..dd3bb8084f 100755
--- a/tools/update/cipolish
+++ b/tools/update/cipolish
@@ -12,15 +12,18 @@
# $Id$
-# find relative up-path to configure.in
+use strict ;
+
+my @vars = () ;
+my @buffer = () ;
+
+# find relative up-path to VERSION
my $rtems_cfg = &find_file(".","VERSION");
my $rtems_root = &find_root() ;
$rtems_root =~ tr/\//\-/ ;
my $rtems_name = "rtems" ;
$rtems_name .= "-" . "$rtems_root" if (length($rtems_root) > 0 ) ;
-my @buffer = () ;
-
while ( <> )
{
push @buffer, "$_" ;
@@ -126,8 +129,8 @@ while ( <> )
{
if ( /^[\s]*(RTEMS_ENABLE_LIBCDIR).*$/o )
{
- if ( ( not defined $var_RTEMS_PROG_CC_FOR_TARGET )
- and ( not defined $var_RTEMS_PROG_CXX_FOR_TARGET )
+ if ( ( not defined $main::var_RTEMS_PROG_CC_FOR_TARGET )
+ and ( not defined $main::var_RTEMS_PROG_CXX_FOR_TARGET )
)
{
push @tbuf, "$_" ;
@@ -165,7 +168,7 @@ sub find_file($$)
my $top = "." ;
if (not "$pre") { $pre = "." ; }
- for ( $str = "$pre" . "/" . "$top" ;
+ for ( my $str = "$pre" . "/" . "$top" ;
( -d "$str" ) ;
$str = "$pre" . "/" . "$top" )
{
diff --git a/tools/update/rtems-polish.sh b/tools/update/rtems-polish.sh
index 83e3d0e390..df0cc8a0e7 100755
--- a/tools/update/rtems-polish.sh
+++ b/tools/update/rtems-polish.sh
@@ -37,7 +37,7 @@ usage()
exit 1;
}
-# Check for auxillary files
+# Check for auxiliary files
aux_files="../../VERSION ampolish acpolish cipolish"
for i in ${aux_files}; do
if test ! -f ${perltools}/$i; then