Automtically build the Autotools to bootstrap RTEMS.

This changes adds support to build the autotools if the host installed
version is not a suitable version. Autoconf and automake have hard coded
references to the install prefix and host tools and this makes it impossible
to relocate, that is use in any path other than the install prefix. To
bootstrap automake you need to first build a suitable autoconf and with that
you can built automake for the install prefix. The other complication is
not referencing the install prefix in the path when building in the RSB.
Having the install prefix in the path can result in strange issues appearing
such as gcc using a new assembler feature not present in an older assember
installed under the install prefix.

The process is to build the autotools using an install prefix to an
internal path inside the RSB temporary path and to use that autoconf
to build the version for the install prefix. The internal install
prefix version is also used to bootstrap RTEMS.
This commit is contained in:
Chris Johns 2013-07-16 10:02:41 +10:00
parent c2effc143b
commit ebf8a1f0f8
33 changed files with 242 additions and 106 deletions

View File

@ -31,6 +31,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -0,0 +1,23 @@
#
# Tools Set for RTEMS 4.11 Internal Autotools Stable
#
%define release 1
%define rtems_arch none
#
# The RTEMS 4.11 base defines.
#
%include rtems-4.11-base.bset
#
# The autotools package.
#
package: rtems-%{rtems_version}-autotools-%{release}
#
# Tools configuration.
#
tools/rtems-autoconf-2.69-1
tools/rtems-automake-1.12.6-1

View File

@ -0,0 +1,13 @@
#
# Tools Set for RTEMS 4.11 Internal Autotools Stable
#
# Do not use via the command line.
#
%define _internal_autotools yes
%define _disable_collecting yes
%define _disable_packaging yes
%define _disable_reporting yes
%define _disable_installing yes
%include 4.11/rtems-autotools-base.bset

View File

@ -1,23 +1,22 @@
#
# Tools Set for RTEMS 4.11 Autotools Stable
#
%define release 1
%define rtems_arch none
# Autoconf and automake are not relocatable and cannot be cross-compiled.
# RTEMS uses autoconf and automake and building RTEMS in the RSB requires
# bootstrapping and this requires a current autoconf and automake. The RSB
# provides to support by:
#
# 1. Building and installing autoconf and automake with a prefix to a
# temporary internal path.
# 2. Using the temporary internal build, build and install another copy
# using the final prefix location.
#
#
# The RTEMS 4.11 base defines.
# A magic internal path that would break if changes in the defaults.mc
# macro file are made.
#
%include rtems-4.11-base.bset
%define _internal_autotools_path %{_tmppath}/sb-%{_uid}/${SB_PREFIX_CLEAN}
#
# The autotoolspackage.
#
package: rtems-%{rtems_version}-autotools-%{release}
#
# Tools configuration.
#
devel/autoconf-2.69-1
devel/automake-1.12.6-1
4.11/rtems-autotools-internal
4.11/rtems-autotools-base

View File

@ -38,6 +38,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -24,6 +24,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -25,6 +25,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.5.3-newlib-2.0.0-1

View File

@ -34,6 +34,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -21,6 +21,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -25,6 +25,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -26,6 +26,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
devel/dtc-1.2.0
tools/rtems-binutils-2.23.2-1

View File

@ -22,6 +22,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-nios2-binutils-2.20-1
tools/rtems-nios2-gcc-4.1-newlib-1.19.0-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -20,6 +20,7 @@
#
# Tools configuration.
#
4.11/rtems-autotools
devel/expat-2.1.0-1
tools/rtems-binutils-2.23.2-1
tools/rtems-gcc-4.8.1-newlib-cvs-1

View File

@ -0,0 +1,19 @@
#
# Autoconf 2.69.
#
%include %{_configdir}/checks.cfg
%include %{_configdir}/base.cfg
%include %{_configdir}/versions.cfg
%define rtems_autoconf_version 2.69
#
# Check the version of autoconf in the path.
#
%if %{__autoconf_ver} < %{rtems_autoconf_version}
#
# Tools configuration.
#
%include %{_configdir}/devel/autoconf-2.69-1.cfg
%endif

View File

@ -0,0 +1,19 @@
#
# Automake 1.12.6
#
%include %{_configdir}/checks.cfg
%include %{_configdir}/base.cfg
%include %{_configdir}/versions.cfg
%define rtems_automake_version 1.12.6
#
# Check the version of automake in the path.
#
%if %{__automake_ver} < %{rtems_automake_version}
#
# Tools configuration.
#
%include %{_configdir}/devel/automake-1.12.6-1.cfg
%endif

View File

@ -74,6 +74,9 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
%{?patch8:%patch8 %{?patch8_opts:%{patch8_opts}}%{!?patch8_opts:-p1}}
%{?patch9:%patch9 %{?patch9_opts:%{patch9_opts}}%{!?patch9_opts:-p1}}
%if %{rtems_bootstrap}
%if %{defined _internal_autotools_path}
export PATH="%{_internal_autotools_path}/bin:${PATH}"
%endif
./bootstrap -c
%{_sbdir}/sb-bootstrap --preinstall
%{_sbdir}/sb-bootstrap

View File

@ -9,12 +9,19 @@
%define rtems_kernel_version 4.11
#
# Check the version of autoconf.
# Check the version of autoconf. Check autoreconf as it is used.
#
%if %{__autoconf_ver} <= 2.68
%error Autoconf version 2.69 or higher is needed.
%if %{__autoreconf_ver} <= 2.68
%if %{__autoreconf_bindir_ver} <= 2.68
%error Autoconf (autoreconf) version 2.69 or higher is needed.
%endif
%endif
#
# A magic internal path that would break if changes in the defaults.mc
# macro file are made.
#
%define _internal_autotools_path %{_tmppath}/sb-%{_uid}/${SB_PREFIX_CLEAN}
#
# Pull the latest changes from git each build. Override if this is not what you
# want.

View File

@ -31,16 +31,14 @@ VersionControl0: git clone git://git.sv.gnu.org/autoconf
cd ..
%build
if test "%{_internal_autotools}" == "yes"; then
export PATH="%{_bindir}:${PATH}"
else
export PATH=$SB_ORIG_PATH
fi
%if %{defined _internal_autotools_path}
export PATH="%{_internal_autotools_path}/bin:${PATH}"
%endif
cd autoconf-%{autoconf_version}
if test "%{_internal_autotools}" == "yes"; then
ac_prefix=$SB_TMPPREFIX
ac_prefix=%{_internal_autotools_path}
else
ac_prefix=%{_prefix}
fi
@ -65,11 +63,11 @@ VersionControl0: git clone git://git.sv.gnu.org/autoconf
%install
export PATH="%{_bindir}:${PATH}"
rm -rf $SB_BUILD_ROOT
%{__rmdir} $SB_BUILD_ROOT
cd autoconf-%{autoconf_version}
if "%{_internal_autotools}" == "yes"; then
if test "%{_internal_autotools}" == "yes"; then
%{__make} install
else
%{__make} DESTDIR=$SB_BUILD_ROOT install

View File

@ -31,22 +31,20 @@ VersionControl0: git clone git://git.savannah.gnu.org/automake.git
cd ..
%build
if test "%{_internal_autotools}" == "yes"; then
export PATH="%{_bindir}:${PATH}"
else
export PATH=$SB_ORIG_PATH
fi
%if %{defined _internal_autotools_path}
export PATH="%{_internal_autotools_path}/bin:${PATH}"
%endif
cd automake-%{automake_version}
if test "%{_internal_autotools}" == "yes"; then
am_prefix=$SB_TMPPREFIX
am_prefix=%{_internal_autotools_path}
else
am_prefix=%{_prefix}
fi
if test "%{_build}" != "%{_host}" ; then
CFLAGS_FOR_BUILD="-g -O2 -Wall"
CFLAGS_FOR_BUILD="-g -O2 -Wall"
fi
export CFLAGS CFLAGS_FOR_BUILD CC
@ -64,11 +62,11 @@ VersionControl0: git clone git://git.savannah.gnu.org/automake.git
%install
export PATH="%{_bindir}:${PATH}"
rm -rf $SB_BUILD_ROOT
%{__rmdir} $SB_BUILD_ROOT
cd automake-%{automake_version}
if "%{_internal_autotools}" == "yes"; then
if test "%{_internal_autotools}" == "yes"; then
%{__make} install
else
%{__make} DESTDIR=$SB_BUILD_ROOT install

View File

@ -1,7 +1,9 @@
# Generate version strings.
%define __makeinfo_ver %(%{__makeinfo} --version | %{__awk} 'NR==1 {print $NF}')
%define __autoconf_ver %(%{__autoconf} --version | %{__awk} 'NR==1 {print $NF}')
%define __automake_ver %(%{__automake} --version | %{__awk} 'NR==1 {print $NF}')
%define __makeinfo_ver %(test -x %{__makeinfo} && %{__makeinfo} --version | %{__awk} 'NR==1 {print $NF}' || echo "0")
%define __autoconf_ver %(test -x %{__autoconf} && %{__autoconf} --version | %{__awk} 'NR==1 {print $NF}' || echo "0")
%define __autoconf_bindir_ver %(test -x %{_bindir}/autoconf && %{_bindir}/autoconf --version | %{__awk} 'NR==1 {print $NF}' || echo "0")
%define __autoreconf_ver %(test -x %{__autoreconf} && %{__autoreconf} --version | %{__awk} 'NR==1 {print $NF}' || echo "0")
%define __autoreconf_bindir_ver %(test -x %{_bindir}/autoreconf && %{_bindir}/autoreconf --version | %{__awk} 'NR==1 {print $NF}' || echo "0")
%define __automake_ver %(test -x %{__automake} && %{__automake} --version | %{__awk} 'NR==1 {print $NF}' || echo "0")
%define __automake_bindir_ver %(test -x %{_bindir}/automake && %{_bindir}/automake --version | %{__awk} 'NR==1 {print $NF}' || echo "0")

View File

@ -106,9 +106,10 @@ __aclocal: exe, optional, 'aclocal'
__ar: exe, required, 'ar'
__arch_install_post: exe, none, '%{nil}'
__as: exe, required, 'as'
__autoconf: exe, required, 'autoconf'
__autoheader: exe, required, 'autoheader'
__automake: exe, required, 'automake'
__autoconf: exe, optional, 'autoconf'
__autoheader: exe, optional, 'autoheader'
__automake: exe, optional, 'automake'
__autoreconf: exe, optional, 'autoreconf'
__awk: exe, required, 'awk'
__bash: exe, optional, '/bin/bash'
__bison: exe, required, '/usr/bin/bison'

View File

@ -273,14 +273,15 @@ class build:
def prep(self, package):
self.script.append('echo "==> %prep:"')
_prep = package.prep()
for l in _prep:
args = l.split()
if args[0] == '%setup':
self.setup(package, args)
elif args[0].startswith('%patch'):
self.patch(package, args)
else:
self.script.append(' '.join(args))
if _prep:
for l in _prep:
args = l.split()
if args[0] == '%setup':
self.setup(package, args)
elif args[0].startswith('%patch'):
self.patch(package, args)
else:
self.script.append(' '.join(args))
def build(self, package):
self.script.append('echo "==> clean %{buildroot}: ${SB_BUILD_ROOT}"')
@ -290,18 +291,21 @@ class build:
(self.config.expand('%{__mkdir_p}')))
self.script.append('echo "==> %build:"')
_build = package.build()
for l in _build:
self.script.append(l)
if _build:
for l in _build:
self.script.append(l)
def install(self, package):
self.script.append('echo "==> %install:"')
_install = package.install()
for l in _install:
args = l.split()
self.script.append(' '.join(args))
if _install:
for l in _install:
args = l.split()
self.script.append(' '.join(args))
def files(self, package):
if self.create_tar_files:
if self.create_tar_files \
and not self.macros.get('%{_disable_packaging'):
self.script.append('echo "==> %files:"')
inpath = path.abspath(self.config.expand('%{buildroot}'))
tardir = path.abspath(self.config.expand('%{_tardir}'))
@ -335,7 +339,8 @@ class build:
self.clean(package)
def cleanup(self):
if not self.opts.no_clean():
package = self.main_package()
if not package.disabled() and not self.opts.no_clean():
buildroot = self.config.abspath('buildroot')
builddir = self.config.abspath('_builddir')
buildcxcdir = self.config.abspath('_buildcxcdir')
@ -356,35 +361,43 @@ class build:
def make(self):
package = self.main_package()
name = package.name()
if self.canadian_cross():
log.notice('package: (Cxc) %s' % (name))
if package.disabled():
log.notice('package: nothing to build')
else:
log.notice('package: %s' % (name))
log.trace('---- macro maps %s' % ('-' * 55))
log.trace('%s' % (str(self.config.macros)))
log.trace('-' * 70)
self.script.reset()
self.script.append(self.config.expand('%{___build_template}'))
self.script.append('echo "=> ' + name + ':"')
self.prep(package)
self.build_package(package)
if not self.opts.dry_run():
self.builddir()
sn = path.join(self.config.expand('%{_builddir}'), 'doit')
log.output('write script: ' + sn)
self.script.write(sn)
name = package.name()
if self.canadian_cross():
log.notice('building: (Cxc) %s' % (name))
log.notice('package: (Cxc) %s' % (name))
else:
log.notice('building: %s' % (name))
self.run(sn)
log.notice('package: %s' % (name))
log.trace('---- macro maps %s' % ('-' * 55))
log.trace('%s' % (str(self.config.macros)))
log.trace('-' * 70)
self.script.reset()
self.script.append(self.config.expand('%{___build_template}'))
self.script.append('echo "=> ' + name + ':"')
self.prep(package)
self.build_package(package)
if not self.opts.dry_run():
self.builddir()
sn = path.join(self.config.expand('%{_builddir}'), 'doit')
log.output('write script: ' + sn)
self.script.write(sn)
if self.canadian_cross():
log.notice('building: (Cxc) %s' % (name))
else:
log.notice('building: %s' % (name))
self.run(sn)
def name(self):
packages = self.config.packages()
package = packages['main']
return package.name()
def disabled(self):
packages = self.config.packages()
package = packages['main']
return package.disabled()
def get_configs(opts):
def _scan(_path, ext):

View File

@ -203,6 +203,9 @@ class package:
def long_name(self):
return self.name()
def disabled(self):
return len(self.name()) == 0
class file:
"""Parse a config file."""
@ -540,6 +543,11 @@ class file:
return text
if r[1] == '%else':
in_iftrue = False
elif r[0] == 'directive':
if r[1] == '%include':
self.load(r[2][0])
else:
log.warning("directive not supported in if: '%s'" % (' '.join(r[2])))
elif r[0] == 'data':
if this_isvalid:
text.extend(r[1])

View File

@ -523,6 +523,8 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc'):
o.process()
o.post_process()
log.notice(' '.join(args))
return o
def run(args):

View File

@ -99,7 +99,9 @@ class buildset:
raise error.general('copying tree: %s' % (str(err)))
def report(self, _config, _build):
if not _build.opts.get_arg('--no-report') and _build.opts.get_arg('--mail'):
if not _build.opts.get_arg('--no-report') \
and not _build.macros.get('%{_disable_reporting}') \
and _build.opts.get_arg('--mail'):
format = _build.opts.get_arg('--report-format')
if format is None:
format = 'html'
@ -172,20 +174,24 @@ class buildset:
_build.make()
for m in macros_to_save:
_build.config.set_define(m, orig_macros[m])
self.root_copy(_build.config.expand('%{buildcxcroot}'),
_build.config.expand('%{_tmpcxcroot}'))
if not _build.macros.get('%{_disable_collecting}'):
self.root_copy(_build.config.expand('%{buildcxcroot}'),
_build.config.expand('%{_tmpcxcroot}'))
def build_package(self, _config, _build):
if _build.canadian_cross():
self.canadian_cross(_build)
_build.make()
self.report(_config, _build)
self.root_copy(_build.config.expand('%{buildroot}'),
_build.config.expand('%{_tmproot}'))
if not _build.disabled():
if _build.canadian_cross():
self.canadian_cross(_build)
_build.make()
self.report(_config, _build)
if not _build.macros.get('%{_disable_collecting}'):
self.root_copy(_build.config.expand('%{buildroot}'),
_build.config.expand('%{_tmproot}'))
def bset_tar(self, _build):
tardir = _build.config.expand('%{_tardir}')
if self.opts.get_arg('--bset-tar-file'):
if self.opts.get_arg('--bset-tar-file') \
and not _build.macros.get('%{_disable_packaging}'):
path.mkdir(tardir)
tar = path.join(tardir, _build.config.expand('%s.tar.bz2' % (self.bset_pkg)))
log.notice('tarball: %s' % (os.path.relpath(path.host(tar))))
@ -306,6 +312,7 @@ class buildset:
try:
builds = []
for s in range(0, len(configs)):
b = None
try:
#
# Each section of the build set gets a separate set of
@ -334,30 +341,36 @@ class buildset:
else:
raise error.general('invalid config type: %s' % (configs[s]))
except error.general, gerr:
if self.build_failure is None:
self.build_failure = b.name()
self.write_mail_header('')
self.write_mail_header('= ' * 40)
self.write_mail_header('Build FAILED: %s' % (b.name()))
self.write_mail_header('- ' * 40)
self.write_mail_header(str(log.default))
self.write_mail_header('- ' * 40)
if self.opts.keep_going():
print gerr
if self.opts.always_clean():
builds += [b]
if b is not None:
if self.build_failure is None:
self.build_failure = b.name()
self.write_mail_header('')
self.write_mail_header('= ' * 40)
self.write_mail_header('Build FAILED: %s' % (b.name()))
self.write_mail_header('- ' * 40)
self.write_mail_header(str(log.default))
self.write_mail_header('- ' * 40)
if self.opts.keep_going():
print gerr
if self.opts.always_clean():
builds += [b]
else:
raise
else:
raise
if deps is None and not self.opts.no_install():
for b in builds:
self.install(b.name(),
b.config.expand('%{buildroot}'),
b.config.expand('%{_prefix}'))
if not b.disabled() \
and not b.macros.get('%{_disable_installing}'):
self.install(b.name(),
b.config.expand('%{buildroot}'),
b.config.expand('%{_prefix}'))
if deps is None and \
(not self.opts.no_clean() or self.opts.always_clean()):
for b in builds:
log.notice('cleaning: %s' % (b.name()))
b.cleanup()
if not b.disabled():
log.notice('cleaning: %s' % (b.name()))
b.cleanup()
for b in builds:
del b
except error.general, gerr: