Patches rtems-rc-4.5.0-1.diff from Ralf Corsepius <corsepiu@faw.uni-ulm.de>

that addresses the following:

    * Duplicate variables in Makefiles (many Makefile.ams below c/src/test
      are affected systematically)
    * Erroniously using local.am instead of host.am in host-Makefile.am
      (Only host Makefile.ams should be affected; Erroniously using local.am
      in host-Makefiles doesn't desturb much)
    * use '.' instead of '$pwd' in ./bootstrap (using $pwd does not work if
      $pwd is a symlink on linux).
    * Broken CVS Ids somewhere
    * Removing redundant/obsolete make variables from *.cfg files.

  Except of the last item from the list above, most parts of this patch
  are fairly harmless, sometimes even cosmetical.

  As mentioned before, this patch also contains a new ampolish script.

  This script features:
    * Pretty printing of Makefile.ams (eg. removal of trailing spaces,
      removal of duplicate empty lines, pretty printing make variables, etc.).

    * Some syntactical checks on the contents of Makefiles.am
    * Proper handling of Automake conditionals

  FYI:
    * Applying tools/update/rtems-polish.sh -am completely reformats all
      Makefile.am resulting into a very large (~500k) diff.
    * Applying tools/update/rtems-polish.sh -am twice, finally does not
      reformat the Makefile.ams anymore.
    * Many parts of the patch above result from merging back issues which
      have shown when applying this new ampolish (i.e. partially result from
      extracting the essentials of reformating being proposed by applying it
      on Makefile.ams).

    Though this ampolish is a very nice tool, IMHO, I am hestitant if you
    should apply (i.e. run tools/update/rtems-polish.sh -am) it to the
    sources before the release, because
      * the resulting diff is fairly large
      * I am not 100% sure it doesn't break anything.

    However, applying it after the release would result into compatibility
    problems in applying patches ;)

    I would suggest that you might consider trying it locally, then to
    examine the diff and then to decide whether to apply it in general or
    not.

Joel's Comments:

As Ralf points out, this patch is problematic in that applying it before
a release could break things but applying it afterwards will result in
patches being unusable for Makefiles.  My inclination is to forge ahead
and apply it.
This commit is contained in:
Joel Sherrill
2000-03-21 17:11:40 +00:00
parent 15b6e46f70
commit 67077a1b46
43 changed files with 488 additions and 193 deletions

View File

@@ -8,7 +8,6 @@
debug-am:
$(MAKE) $(AM_MAKEFLAGS) "ARCH=o-debug" \
"CFLAGS_DEBUG=$(CFLAGS_DEBUG_V)" \
"CFLAGS_OPTIMIZE=$(CFLAGS_DEBUG_OPTIMIZE_V)" \
"LDFLAGS_DEBUG=$(LDFLAGS_DEBUG_V)" $(TARGET_VA)
debug: debug-am

View File

@@ -61,7 +61,7 @@ pwd=`pwd`;
case $mode in
generate)
confs=`find $pwd -name 'configure.in' -print`
confs=`find . -name 'configure.in' -print`
aclocal_dir=$pwd/aclocal
for i in $confs; do
dir=`dirname $i`;

View File

@@ -4,7 +4,6 @@
AUTOMAKE_OPTIONS = foreign 1.4
BSP_FILES = startup tty
# pieces to pick up out of libcpu/hppa
CPU_FILES = clock milli timer
@@ -16,7 +15,7 @@ GENERIC_FILES = $(GENERIC_MP_REL_FILES)
if HAS_MP
BSP_MP_O_FILES = shmsupp
endif
BSP_FILES = $(BSP_MP_O_FILES)
BSP_FILES = start tty $(BSP_MP_O_FILES)
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../../../../automake/lib.am

View File

@@ -25,4 +25,4 @@ PREINSTALL_FILES = \
## HACK: install into build-tree
all-local: $(PREINSTALL_FILES)
include $(top_srcdir)/../../../../../../../automake/local.am
include $(top_srcdir)/../../../../../../../automake/host.am

View File

@@ -20,4 +20,4 @@ EXTRA_DIST = \
$(noinst_SCRIPTS)
include $(top_srcdir)/../../../../../../../automake/subdirs.am
include $(top_srcdir)/../../../../../../../automake/local.am
include $(top_srcdir)/../../../../../../../automake/host.am

View File

@@ -4,8 +4,6 @@
AUTOMAKE_OPTIONS = foreign 1.4
BSP_FILES = startup clock console timer
if HAS_MP
GENERIC_MP_REL_FILES = shmdr
endif
@@ -14,7 +12,7 @@ GENERIC_FILES += $(GENERIC_MP_REL_FILES)
if HAS_MP
BSP_MP_O_FILES = shmsupp
endif
BSP_FILES += $(BSP_MP_O_FILES)
BSP_FILES = startup clock console timer $(BSP_MP_O_FILES)
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../../../../automake/lib.am

View File

@@ -7,8 +7,6 @@ AUTOMAKE_OPTIONS = foreign 1.4
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../../../../automake/lib.am
BSP_PIECES = startup clock console timer
if HAS_MP
GENERIC_MP_REL_PIECES = shmdr
endif
@@ -17,7 +15,7 @@ GENERIC_PIECES += $(GENERIC_MP_REL_PIECES)
if HAS_MP
BSP_MP_O_PIECES = shmsupp
endif
BSP_PIECES += $(BSP_MP_O_PIECES)
BSP_PIECES = startup clock console timer $(BSP_MP_O_PIECES)
# bummer; have to use $foreach since % pattern subst rules only replace 1x
OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \

View File

@@ -7,8 +7,6 @@ AUTOMAKE_OPTIONS = foreign 1.4
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../../../../automake/lib.am
BSP_PIECES = startup clock console timer
if HAS_MP
GENERIC_MP_REL_PIECES = shmdr
endif
@@ -17,7 +15,7 @@ GENERIC_PIECES += $(GENERIC_MP_REL_PIECES)
if HAS_MP
BSP_MP_O_PIECES = shmsupp
endif
BSP_PIECES += $(BSP_MP_O_PIECES)
BSP_PIECES = startup clock console timer $(BSP_MP_O_PIECES)
# bummer; have to use $foreach since % pattern subst rules only replace 1x
OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \

View File

@@ -7,8 +7,6 @@ AUTOMAKE_OPTIONS = foreign 1.4
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../../../../automake/lib.am
BSP_PIECES = startup clock console timer
if HAS_MP
GENERIC_MP_REL_PIECES = shmdr
endif
@@ -17,7 +15,7 @@ GENERIC_PIECES += $(GENERIC_MP_REL_PIECES)
if HAS_MP
BSP_MP_O_PIECES = shmsupp
endif
BSP_PIECES += $(BSP_MP_O_PIECES)
BSP_PIECES = startup clock console timer $(BSP_MP_O_PIECES)
# bummer; have to use $foreach since % pattern subst rules only replace 1x
OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \

View File

@@ -14,4 +14,4 @@ install-exec-local: $(PROGRAMS)
$(mkinstalldirs) $(PROJECT_ROOT)/mvme162/bin
$(INSTALL_PROGRAM) $(PROGRAMS) $(PROJECT_ROOT)/mvme162/bin
include $(top_srcdir)/../../../../../../../automake/local.am
include $(top_srcdir)/../../../../../../../automake/host.am

View File

@@ -4,8 +4,6 @@
AUTOMAKE_OPTIONS = foreign 1.4
BSP_FILES = startup clock console timer
if HAS_MP
GENERIC_MP_REL_FILES = shmdr
endif
@@ -14,7 +12,7 @@ GENERIC_FILES = $(GENERIC_MP_REL_FILES)
if HAS_MP
BSP_MP_O_FILES = shmsupp
endif
BSP_FILES = $(BSP_MP_O_FILES)
BSP_FILES = startup clock console timer $(BSP_MP_O_FILES)
# bummer; have to use $foreach since % pattern subst rules only replace 1x
OBJS = $(foreach piece, $(BSP_FILES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \

View File

@@ -1,5 +1,5 @@
##
## $Id:
## $Id$
##
AUTOMAKE_OPTIONS = foreign 1.4

View File

@@ -7,8 +7,6 @@ AUTOMAKE_OPTIONS = foreign 1.4
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../../../../../../automake/lib.am
BSP_PIECES = startup clock console timer vectors
if HAS_MP
GENERIC_MP_REL_PIECES = shmdr
endif
@@ -17,7 +15,7 @@ GENERIC_PIECES += $(GENERIC_MP_REL_PIECES)
if HAS_MP
BSP_MP_O_PIECES = shmsupp
endif
BSP_PIECES += $(BSP_MP_O_PIECES)
BSP_PIECES = startup clock console timer vectors $(BSP_MP_O_PIECES)
# bummer; have to use $foreach since % pattern subst rules only replace 1x
OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \

View File

@@ -31,9 +31,6 @@ rtems_bsp_make_DATA = \
bsp.cfg
if MAINTAINER_MODE
$(srcdir)/main.cfg.in: $(top_srcdir)/@RTEMS_TOPdir@/make/main.cfg
sed -e 's%\$$(RTEMS_BSP)%\@RTEMS_BSP\@%g' < $< >$@
$(srcdir)/host.cfg.in: $(top_srcdir)/@RTEMS_TOPdir@/make/host.cfg.in
cp $< $@

View File

@@ -4,15 +4,14 @@
#
# Make(1) configuration file include'd by all Makefile's
#
# NOTE: This file does not get exported from the source tree
#
#
# where things are relative to PROJECT_ROOT; shouldn't need to change,
# but could be overridden in custom files.
#
PROJECT_RELEASE=$(PROJECT_ROOT)/@RTEMS_BSP@
PROJECT_BIN=$(PROJECT_RELEASE)/bin
PROJECT_INCLUDE=$(PROJECT_RELEASE)/lib/include
PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools
#
@@ -24,21 +23,6 @@ ARCH=o-optimize
VARIANT=
#
# Initial target for make(1)
# Once this is established we can safely include other targets
# within this make-include file.
#
default_target: all
#
# Default makefile name
# May be overridden by command line macro assignment
#
MAKEFILE=Makefile
#
# Target variant names
#
@@ -49,27 +33,5 @@ TARGET_VARIANTS = optimize debug profile
#
VARIANTS=${TARGET_VARIANTS:%=o-%}
#
# List of "recursion-able" targets for directory Makefiles
#
RECURSE_TARGETS=all depend install \
preinstall-recursive \
$(TARGET_VARIANTS)
${ARCH}:
test -d ${ARCH} || mkdir ${ARCH}
ifndef AUTOMAKE
distclean-generic:
-$(RM) .#* $(CONFIG_CLEAN_FILES)
-$(RM) -r $(CLOBBER_ADDITIONS)
clean-generic:
-$(RM) a.out core mon.out gmon.out
-$(RM) -r $(CLEAN_ADDITIONS)
endif
.PHONY: $(RECURSE_TARGETS)
.PHONY: clean-generic
.PHONY: distclean-generic

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -22,8 +22,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(TEST).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/itrontests.am

View File

@@ -6,7 +6,8 @@ AUTOMAKE_OPTIONS = foreign 1.4
SUBDIRS = node1 node2
EXTRA_DIST = system.h delay.c evtask1.c evtmtask.c exit.c init.c msgtask1.c pttask1.c smtask1.c
EXTRA_DIST = system.h delay.c evtask1.c evtmtask.c exit.c init.c msgtask1.c \
pttask1.c smtask1.c
include $(top_srcdir)/../../../../automake/subdirs.am
include $(top_srcdir)/../../../../automake/local.am

View File

@@ -4,8 +4,6 @@
AUTOMAKE_OPTIONS = foreign 1.4
VPATH = @srcdir@
TEST = psxfile01
MANAGERS = all

View File

@@ -26,8 +26,6 @@ OBJS = $(C_O_FILES) $(CC_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(SAMPLE).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/sample.am

View File

@@ -23,8 +23,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(SAMPLE).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/sample.am

View File

@@ -20,8 +20,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(SAMPLE).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/sample.am

View File

@@ -23,8 +23,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(SAMPLE).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/sample.am

View File

@@ -23,8 +23,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(SAMPLE).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/sample.am

View File

@@ -23,8 +23,6 @@ OBJS = $(C_O_FILES)
PRINT_SRCS = $(DOCS)
PGM = ${ARCH}/$(SAMPLE).exe
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
include $(top_srcdir)/sample.am

View File

@@ -18,9 +18,7 @@ OBJS = $(C_O_FILES)
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(RTEMS_ROOT)/make/leaf.cfg
TMPINSTALL_FILES = \
$(PROJECT_INCLUDE) \
$(H_FILES:%=$(PROJECT_INCLUDE)/%)
TMPINSTALL_FILES += $(PROJECT_INCLUDE) $(H_FILES:%=$(PROJECT_INCLUDE)/%)
$(PROJECT_INCLUDE):
@$(mkinstalldirs) $@

View File

@@ -19,8 +19,7 @@ include $(top_srcdir)/../../../../automake/lib.am
# (OPTIONAL) Add local stuff here using +=
#
TMPINSTALL_FILES += \
$(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a
TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/$(LIBNAME)$(LIB_VARIANT).a
$(LIB): ${OBJS}
$(make-library)

View File

@@ -8,4 +8,4 @@ ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal
SUBDIRS = @subdirs@
include $(top_srcdir)/../../../../automake/subdirs.am
include $(top_srcdir)/../../../../automake/local.am
include $(top_srcdir)/../../../../automake/host.am

View File

@@ -9,10 +9,8 @@ noinst_SCRIPTS = difftest sorttimes
project_bspdir = $(PROJECT_ROOT)/@RTEMS_BSP@
PREINSTALL_FILES = \
$(project_bspdir)/tests \
$(project_bspdir)/tests/difftest \
$(project_bspdir)/tests/sorttimes
PREINSTALL_FILES += $(project_bspdir)/tests $(project_bspdir)/tests/difftest \
$(project_bspdir)/tests/sorttimes
$(project_bspdir)/tests:
@$(mkinstalldirs) $@

View File

@@ -78,10 +78,6 @@ CFLAGS_OPTIMIZE_V=-O4 -fomit-frame-pointer
# debug flag; typically -g
CFLAGS_DEBUG_V=-g -Wno-unused
# when debugging, optimize flag: typically empty
# some compilers do allow optimization with their "-g"
CFLAGS_DEBUG_OPTIMIZE_V=
# profile flag; use gprof(1)
CFLAGS_PROFILE_V=-pg

View File

@@ -59,10 +59,6 @@ CFLAGS_OPTIMIZE_V=-Os
# debug flag; typically -g
CFLAGS_DEBUG_V=-g -O0 -DRTEMS_DEBUG -DSTACK_CHECKER_ON
# when debugging, optimize flag: typically empty
# some compilers do allow optimization with their "-g"
CFLAGS_DEBUG_OPTIMIZE_V=
# profile flag; use gprof(1)
CFLAGS_PROFILE_V=

View File

@@ -93,10 +93,6 @@ ifeq ($(RTEMS_USE_GCC272),no)
CFLAGS_DEBUG_V+=-qrtems_debug
endif
# when debugging, optimize flag: typically empty
# some compilers do allow optimization with their "-g"
CFLAGS_DEBUG_OPTIMIZE_V=-g
# profile flag; use gprof(1)
CFLAGS_PROFILE_V=-pg

View File

@@ -84,7 +84,6 @@ endef
# and (hopefully) optimize for it.
#
CPU_CFLAGS = -mcpu=603
#CFLAGS_DEBUG_OPTIMIZE_V=
# optimize flag: typically -0, could use -O4 or -fast
# -O4 is ok for RTEMS

View File

@@ -125,10 +125,6 @@ define make-exe
endef
endif
define make-rel
$(LDARGS) $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $(OBJS)
endef
# Miscellaneous additions go here
# BSP-specific tools

View File

@@ -49,7 +49,7 @@ ifndef AUTOMAKE
debug:
$(MAKE) -f $(MAKEFILE) MAKEFILE=$(MAKEFILE) "ARCH=o-debug" \
"CFLAGS_DEBUG=$(CFLAGS_DEBUG_V)" \
"CFLAGS_OPTIMIZE=$(CFLAGS_DEBUG_OPTIMIZE_V)" \
"CFLAGS_OPTIMIZE=$(CFLAGS_OPTIMIZE_V)" \
"LDFLAGS_DEBUG=$(LDFLAGS_DEBUG_V)" $(TARGET_VA)
profile:

View File

@@ -1,5 +1,7 @@
#!/usr/bin/perl
package main ;
use strict ;
#
@@ -11,9 +13,334 @@ use strict ;
# <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, "<22>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]*debug-am:.*$/o )
{ # remove the line
}
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 ( /^<5E>.*$/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, "<22>$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( /^<5E>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 ( /^<5E>(\+|)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
@@ -44,78 +371,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 "$_" ;
}
print "\nAUTOMAKE_OPTIONS = foreign 1.4\n";
if ( "$rtems_cfg" eq "." )
sub variable_seen($)
{
print "ACLOCAL_AMFLAGS = -I \$(RTEMS_TOPdir)/aclocal\n"
my $label = "$_[0]" ;
my $res = defined $var_{"$label"};
#print STDERR "SEEN: $label ->$res<\n" ;
return $res ;
}
while( <> )
{
if ( /^[\s\t]*$/o )
sub define_variable($$)
{
my ($label,@value) = @_ ;
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
foreach my $i ( @{value} )
{
push @{$var_{"$label"}}, $i ;
}
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
}
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) ;
}
@{$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++ )
{
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 ( /^[\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 )
{
$subdirs_seen = "yes" ;
print "$_" ;
$nl_seen = 0 ;
}
elsif ( /^[ ]*$/o )
{
print "$_" if $nl_seen < 2 ;
}
else
{
print "$_" ;
$nl_seen = 0;
}
} # while
if ( "$subdirs_seen" )
{
print "include \$(top_srcdir)/${rtems_top}automake/subdirs.am\n" ;
if ( $state > 0 )
{
push @res, substr($line,$begin,$len-$begin);
$state = 0
}
return @res ;
}
print "include \$(top_srcdir)/${rtems_top}automake/local.am\n" ;
;1
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 = " $_" ;
}
}
push @{$ibuf}, "$line\n" ;
}
sub print_line($$)
{
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" ;
}
sub print_script($$)
{
my ($ibuf,$input) = @_ ;
$input =~ s%<25>%\\\n%g ;
push @{$ibuf}, $input ;
}