diff options
author | Chris Johns <chrisj@rtems.org> | 2012-10-31 12:09:38 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-10-31 12:09:38 +1100 |
commit | 52604491d35d6d6df76f0cec5607455abf2b39b8 (patch) | |
tree | 04590d7d213db26aa24e83623e6789c935355c61 | |
parent | Create the sources path if not present and the user has forced. (diff) | |
download | rtems-source-builder-52604491d35d6d6df76f0cec5607455abf2b39b8.tar.bz2 |
Support modules other than bintuls and gcc.
Added support to build autoconf and automake plus other packages
such as libusb and the stlink project. This includes support to
build a specific github version downloaded from github.
-rw-r--r-- | config/autoconf-2-1.cfg | 56 | ||||
-rw-r--r-- | config/autoconf-2.69-1.cfg | 21 | ||||
-rw-r--r-- | config/automake-1-1.cfg | 57 | ||||
-rw-r--r-- | config/automake-1.12-1.cfg | 21 | ||||
-rw-r--r-- | config/libusb-1-1.cfg | 60 | ||||
-rw-r--r-- | config/libusb-1.0.9-1.cfg | 21 | ||||
-rw-r--r-- | config/texane-stlink-1.cfg | 70 | ||||
-rw-r--r-- | patches/texane-stlink-3494c11-1.diff | 13 | ||||
-rw-r--r-- | tb/build.py | 41 | ||||
-rw-r--r-- | tb/config.py | 21 | ||||
-rw-r--r-- | tb/crossgcc.py | 46 | ||||
-rw-r--r-- | tb/defaults.py | 2 |
12 files changed, 394 insertions, 35 deletions
diff --git a/config/autoconf-2-1.cfg b/config/autoconf-2-1.cfg new file mode 100644 index 0000000..8cf36d1 --- /dev/null +++ b/config/autoconf-2-1.cfg @@ -0,0 +1,56 @@ +# +# Autoconf 2.xx Version 1. +# +# This configuration file configure's, make's and install's autoconf +# +# Warning: this package is only for bootstrapping within a build. +# + +%warning This autoconf build is for internal bootstraps, no package created + +Summary: Autoconf v%{autoconf_version} for host %{_host} +Version: %{autoconf_version} +Release: %{release} +URL: http://www.gnu.org/software/autoconf/ +BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n) + +# +# Source +# +Source0: ftp://ftp.gnu.org/gnu/autoconf/autoconf-%{autoconf_version}.tar.gz + +# +# Prepare the source code. +# +%prep +%setup -q -c -T -n %{name}-%{version} +cd autoconf-%{autoconf_version} +%{?patch0:%patch0 -p1} +cd .. + +%build + export PATH="%{_bindir}:${PATH}" + cd autoconf-%{autoconf_version} + +%if "%{_build}" != "%{_host}" + CFLAGS_FOR_BUILD="-g -O2 -Wall" \ +%endif + CFLAGS="$TB_OPT_FLAGS" \ + ./configure \ + --build=%{_build} --host=%{_host} \ + --verbose --disable-nls \ + --without-included-gettext \ + --prefix=$TB_TMPPREFIX + + %{__make} %{?_smp_mflags} all + + cd .. + +%install + export PATH="%{_bindir}:${PATH}" + rm -rf $TB_BUILD_ROOT + + cd autoconf-%{autoconf_version} + %{__make} install + + cd .. diff --git a/config/autoconf-2.69-1.cfg b/config/autoconf-2.69-1.cfg new file mode 100644 index 0000000..5d7a890 --- /dev/null +++ b/config/autoconf-2.69-1.cfg @@ -0,0 +1,21 @@ +# +# Autoconf 2.22. +# + +%ifn %{defined release} +%error No 'release' defined +%endif + +%include %{_configdir}/base.cfg + +%define autoconf_version 2.69 + +Name: autoconf-%{autoconf_version}-%{_host}-%{release} + +%description +Autoconf for host %{_host}. + +# +# The autoconf build instructions. We use 2.xx Release 1. +# +%include %{_configdir}/autoconf-2-1.cfg diff --git a/config/automake-1-1.cfg b/config/automake-1-1.cfg new file mode 100644 index 0000000..a53ff9a --- /dev/null +++ b/config/automake-1-1.cfg @@ -0,0 +1,57 @@ +# +# Automake 1.xx Version 1. +# +# This configuration file configure's, make's and install's automake +# +# Warning: this package is only for bootstrapping within a build. +# + +%warning This automake build is for internal bootstraps, no package created + +Summary: Automake v%{automake_version} for host %{_host} +Version: %{automake_version} +Release: %{release} +URL: http://www.gnu.org/software/automake/ +BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n) + +# +# Source +# +Source0: ftp://ftp.gnu.org/gnu/automake/automake-%{automake_version}.tar.gz + +# +# Prepare the source code. +# +%prep +%setup -q -c -T -n %{name}-%{version} +cd automake-%{automake_version} +%{?patch0:%patch0 -p1} +cd .. + +%build + export PATH="%{_bindir}:${PATH}" + + cd automake-%{automake_version} + +%if "%{_build}" != "%{_host}" + CFLAGS_FOR_BUILD="-g -O2 -Wall" \ +%endif + CFLAGS="$TB_OPT_FLAGS" \ + ./configure \ + --build=%{_build} --host=%{_host} \ + --verbose --disable-nls \ + --without-included-gettext \ + --prefix=$TB_TMPPREFIX + + %{__make} %{?_smp_mflags} all + + cd .. + +%install + export PATH="%{_bindir}:${PATH}" + rm -rf $TB_BUILD_ROOT + + cd automake-%{automake_version} + %{__make} install + + cd .. diff --git a/config/automake-1.12-1.cfg b/config/automake-1.12-1.cfg new file mode 100644 index 0000000..32ff39f --- /dev/null +++ b/config/automake-1.12-1.cfg @@ -0,0 +1,21 @@ +# +# Automake 1.12 +# + +%ifn %{defined release} +%error No 'release' defined +%endif + +%include %{_configdir}/base.cfg + +%define automake_version 1.12 + +Name: automake-%{automake_version}-%{_host}-%{release} + +%description +Automake for host %{_host}. + +# +# The automake build instructions. We use 1.xx Release 1. +# +%include %{_configdir}/automake-1-1.cfg diff --git a/config/libusb-1-1.cfg b/config/libusb-1-1.cfg new file mode 100644 index 0000000..cf61b0c --- /dev/null +++ b/config/libusb-1-1.cfg @@ -0,0 +1,60 @@ +# +# LibUSB 1.xx Version 1. +# +# This configuration file configure's, make's and install's libusb. +# + +%ifn %{defined release} +%error No 'release' defined +%endif + +Summary: LibUSB v%{libusb_version} for target %{_target} on host %{_host} +Version: %{libusb_version} +Release: %{release} +URL: http://libusb.org/ +BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n) + +# +# Source +# +Source0: http://downloads.sourceforge.net/project/libusb/libusb-1.0/libusb-%{libusb_version}/libusb-%{libusb_version}.tar.bz2 + +# +# Prepare the source code. +# +%prep +%setup -q -c -T -n %{name}-%{version} +%setup -q -D -T -n %{name}-%{version} -a0 +cd libusb-%{libusb_version} +%{?patch0:%patch0 -p1} +cd .. + +%build + export PATH="%{_bindir}:${PATH}" + cd libusb-%{libusb_version} + +%if "%{_build}" != "%{_host}" + CFLAGS_FOR_BUILD="-g -O2 -Wall" \ +%endif + CFLAGS="$TB_OPT_FLAGS" \ + ./configure \ + --build=%{_build} --host=%{_host} \ + --verbose --disable-nls \ + --without-included-gettext \ + --prefix=%{_prefix} --bindir=%{_bindir} \ + --exec-prefix=%{_exec_prefix} \ + --includedir=%{_includedir} --libdir=%{_libdir} \ + --mandir=%{_mandir} --infodir=%{_infodir} + + %{__make} %{?_smp_mflags} all + + cd .. + +%install + export PATH="%{_bindir}:${PATH}" + rm -rf $TB_BUILD_ROOT + + cd libusb-%{libusb_version} + %{__make} DESTDIR=$TB_BUILD_ROOT install + + cd .. diff --git a/config/libusb-1.0.9-1.cfg b/config/libusb-1.0.9-1.cfg new file mode 100644 index 0000000..728a626 --- /dev/null +++ b/config/libusb-1.0.9-1.cfg @@ -0,0 +1,21 @@ +# +# LibUSB 1.0.9 +# + +%ifn %{defined release} +%error No 'release' defined +%endif + +%include %{_configdir}/base.cfg + +%define libusb_version 1.0.9 + +Name: libusb-%{libusb_version}-%{_host}-%{release} + +%description +LibUSB for host %{_host}. + +# +# The Libuxb build instructions. We use 1.xx Release 1. +# +%include %{_configdir}/libusb-1-1.cfg diff --git a/config/texane-stlink-1.cfg b/config/texane-stlink-1.cfg new file mode 100644 index 0000000..89ca2c3 --- /dev/null +++ b/config/texane-stlink-1.cfg @@ -0,0 +1,70 @@ +# +# ST-Link Version 1. +# +# This configuration file configure's, make's and install's SL-Link. +# + +%ifn %{defined release} +%error No 'release' defined +%endif + +%include %{_configdir}/base.cfg + +%define stlink_version 3494c11 + +Name: texane-stlink-%{stlink_version}-%{release} +Summary: ST-Link v%{stlink_version} for host %{_host} +Version: %{stlink_version} +Release: %{release} +URL: https://github.com/texane/stlink/ +BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n) + +# +# Source +# +Source0: https://api.github.com/repos/texane/stlink/texane-stlink-%{stlink_version}.tar.gz +Patch0: texane-stlink-3494c11-1.diff + +# +# Prepare the source code. +# +%prep +%setup -q -c -T -n %{name}-%{version} +%setup -q -D -T -n %{name}-%{version} -a0 +cd texane-stlink-%{stlink_version} +%{?patch0:%patch0 -p1} +cd .. + +%build + export PATH="%{_bindir}:${PATH}" + + cd texane-stlink-%{stlink_version} + + ./autogen.sh + +%if "%{_build}" != "%{_host}" + CFLAGS_FOR_BUILD="-g -O2 -Wall" \ +%endif + CPPFLAGS="-I $TB_TMPPREFIX/include/libusb-1.0" \ + CFLAGS="$TB_OPT_FLAGS" \ + LDFLAGS="-L $TB_TMPPREFIX/lib" \ + ./configure \ + --build=%{_build} --host=%{_host} \ + --verbose \ + --prefix=%{_prefix} --bindir=%{_bindir} \ + --exec-prefix=%{_exec_prefix} \ + --includedir=%{_includedir} --libdir=%{_libdir} \ + --mandir=%{_mandir} --infodir=%{_infodir} + + %{__make} %{?_smp_mflags} all + + cd .. + +%install + export PATH="%{_bindir}:${PATH}" + rm -rf $TB_BUILD_ROOT + + cd texane-stlink-%{stlink_version} + %{__make} DESTDIR=$TB_BUILD_ROOT install + + cd .. diff --git a/patches/texane-stlink-3494c11-1.diff b/patches/texane-stlink-3494c11-1.diff new file mode 100644 index 0000000..e1d30f9 --- /dev/null +++ b/patches/texane-stlink-3494c11-1.diff @@ -0,0 +1,13 @@ +--- texane-stlink-3494c11.orig/configure.ac 2012-10-31 11:40:49.000000000 +1100 ++++ texane-stlink-3494c11/configure.ac 2012-10-31 10:34:57.000000000 +1100 +@@ -21,9 +21,7 @@ + AC_REPLACE_FUNCS(mmap) + + # Checks for libraries. +-PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.0,, +- AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***])) +-AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb) ++AC_CHECK_HEADER([libusb.h], [USB_LIBS="-lusb-1.0"]) + + LIBS="$LIBS $USB_LIBS" + CFLAGS="$CFLAGS $USB_CFLAGS" diff --git a/tb/build.py b/tb/build.py index 7328cc2..5effbc3 100644 --- a/tb/build.py +++ b/tb/build.py @@ -142,7 +142,14 @@ class build: url_file = url_path[slash + 1:] urls.append(urlparse.urljoin(base, url_file)) urls.append(url) + if self.opts.trace(): + print '_url:', ','.join(urls), '->', local for url in urls: + # + # Hack for GitHub. + # + if url.startswith('https://api.github.com'): + url = urlparse.urljoin(url, self.config.expand('tarball/%{version}')) _notice(self.opts, 'download: ' + url + ' -> ' + local) if not self.opts.dry_run(): failed = False @@ -153,11 +160,13 @@ class build: _out = open(local, 'wb') _out.write(_in.read()) except IOError, err: - _notice(self.opts, 'download: ' + url + ': failed: ' + str(err)) + msg = 'download: %s: error: %s' % (url, str(err)) + _notice(self.opts, msg) if os.path.exists(local): os.remove(local) failed = True except: + print >> sys.stderr, msg if _out is not None: _out.close() raise @@ -169,9 +178,9 @@ class build: if not os.path.isfile(local): raise error.general('source is not a file: ' + local) return - raise error.general('downloading ' + url + ': all paths have failed, giving up') + raise error.general('downloading %s: all paths have failed, giving up', url) - def parse_url(self, url): + def parse_url(self, url, pathkey): # # Split the source up into the parts we need. # @@ -183,7 +192,7 @@ class build: # # Get the file. Checks the local source directory first. # - source['local'] = os.path.join(self.config.abspath('_sourcedir'), + source['local'] = os.path.join(self.config.abspath(pathkey), source['file']) # # Is the file compressed ? @@ -215,7 +224,7 @@ class build: break if url is None: raise error.general('source tag not found: source' + str(source_tag)) - source = self.parse_url(url) + source = self.parse_url(url, '_sourcedir') self.get_file(source['url'], source['local']) if 'compressed' in source: source['script'] = source['compressed'] + ' ' + \ @@ -237,7 +246,15 @@ class build: break if url is None: raise error.general('patch tag not found: ' + args[0]) - patch = self.parse_url(url) + # + # Parse the URL first in the source builder's patch directory. + # + patch = self.parse_url(url, '_patchdir') + # + # If not in the source builder package check the source directory. + # + if not os.path.isfile(patch['local']): + patch = self.parse_url(url, '_sourcedir') self.get_file(patch['url'], patch['local']) if 'compressed' in patch: patch['script'] = patch['compressed'] + ' ' + patch['local'] @@ -354,12 +371,14 @@ class build: prefixbase = '' inpath = os.path.join('%{buildroot}', prefixbase) tardir = os.path.abspath(self.config.expand('%{_tardir}')) - self.script.append('mkdir -p %s' % tardir) - self.script.append(self.config.expand('cd ' + inpath)) + self.script.append(self.config.expand('if test -d %s; then' % (inpath))) + self.script.append(' mkdir -p %s' % tardir) + self.script.append(self.config.expand(' cd ' + inpath)) tar = os.path.join(tardir, package.long_name() + '.tar.bz2') - cmd = self.config.expand('%{__tar} -cf - . ' + '| %{__bzip2} > ' + tar) + cmd = self.config.expand(' %{__tar} -cf - . ' + '| %{__bzip2} > ' + tar) self.script.append(cmd) - self.script.append(self.config.expand('cd %{_builddir}')) + self.script.append(self.config.expand(' cd %{_builddir}')) + self.script.append('fi') def clean(self, package): self.script.append('echo "==> %clean:"') @@ -378,7 +397,7 @@ class build: _notice(self.opts, 'cleanup: %s' % (builddir)) self.rmdir(builddir) - def make(self): + def make(self, path): packages = self.config.packages() package = packages['main'] name = package.name() diff --git a/tb/config.py b/tb/config.py index 75a91aa..05da300 100644 --- a/tb/config.py +++ b/tb/config.py @@ -213,16 +213,20 @@ class file: s += str(self._packages[_package]) return s + def _name_line_msg(self, msg): + return '%s:%d: %s' % (os.path.basename(self.name), self.lc, msg) + def _output(self, text): if not self.opts.quiet(): log.output(text) def _warning(self, msg): - self._output('warning: ' + self.name + ':' + str(self.lc) + ': ' + msg) + self._output('warning: %s' % (self._name_line_msg(msg))) def _error(self, msg): - print >> sys.stderr, \ - 'error: ' + self.name + ':' + str(self.lc) + ': ' + msg + err = 'error: %s' % (self._name_line_msg(msg)) + print >> sys.stderr, err + self._output(err) self.in_error = True if not self.opts.dry_run(): print >> sys.stderr, 'warning: switched to dry run due to errors' @@ -597,7 +601,10 @@ class file: return ('package', name) elif ls[0] == '%error': if isvalid: - return ('data', ['%%error %s:%d: %s' % (self.name, self.lc, l[7:])]) + return ('data', ['%%error %s' % (self._name_line_msg(l[7:]))]) + elif ls[0] == '%warning': + if isvalid: + return ('data', ['%%warning %s' % (self._name_line_msg(l[9:]))]) elif ls[0] == '%define' or ls[0] == '%global': if isvalid: self._define(config, ls) @@ -773,6 +780,9 @@ class file: l = self._expand(l) if l.startswith('%error'): raise error.general('config error: %s' % (l[7:])) + elif l.startswith('%warning'): + print >> sys.stderr, 'warning: %s' % (l[9:]) + self._warning(l[9:]) if not dir: ls = self.tags.split(l, 1) if self.opts.trace(): @@ -816,6 +826,9 @@ class file: raise error.general('macro "' + name + '" not found') return self._expand(d) + def set_define(self, name, value): + self.defines[name.lower()] = value + def expand(self, line): return self._expand(line) diff --git a/tb/crossgcc.py b/tb/crossgcc.py index 5e40ac3..e48e93d 100644 --- a/tb/crossgcc.py +++ b/tb/crossgcc.py @@ -66,30 +66,34 @@ class crossgcc: log.output(text) def copy(self, src, dst): - what = '%s -> %s' % (src, dst) - _notice(self.opts, 'coping: %s' % (what)) - if not self.opts.dry_run(): - try: - files = distutils.dir_util.copy_tree(src, dst) - for f in files: - self._output(f) - except IOError, err: - raise error.general('coping tree: %s: %s' % (what, str(err))) - except distutils.errors.DistutilsFileError, err: - raise error.general('coping tree: %s' % (str(err))) + if os.path.isdir(src): + topdir = self.opts.expand('%{_topdir}', self.defaults) + what = '%s -> %s' % (src[len(topdir) + 1:], dst[len(topdir) + 1:]) + _notice(self.opts, 'installing: %s' % (what)) + if not self.opts.dry_run(): + try: + files = distutils.dir_util.copy_tree(src, dst) + for f in files: + self._output(f) + except IOError, err: + raise error.general('installing tree: %s: %s' % (what, str(err))) + except distutils.errors.DistutilsFileError, err: + raise error.general('installing tree: %s' % (str(err))) def first_package(self, _build): - what = _build.config.expand('crossgcc-%(%{__id_u} -n)-' + _build.name()) - path = os.path.join(_build.config.abspath('%{_tmppath}'), what) - _build.rmdir(path) - _build.mkdir(path) - prefix = os.path.join(_build.config.expand('%{_prefix}'), 'bin') + tmproot = os.path.abspath(_build.config.expand('%{_tmproot}')) + _build.rmdir(tmproot) + _build.mkdir(tmproot) + prefix = _build.config.expand('%{_prefix}') if prefix[0] == os.sep: prefix = prefix[1:] - binpath = os.path.join(path, prefix) - os.environ['PATH'] = binpath + os.pathsep + os.environ['PATH'] + tmpprefix = os.path.join(tmproot, prefix) + tmpbindir = os.path.join(tmpprefix, 'bin') + os.environ['TB_TMPPREFIX'] = tmpprefix + os.environ['TB_TMPBINDIR'] = tmpbindir + os.environ['PATH'] = tmpbindir + os.pathsep + os.environ['PATH'] self._output('path: ' + os.environ['PATH']) - return path + return tmproot def every_package(self, _build, path): self.copy(_build.config.abspath('%{buildroot}'), path) @@ -117,6 +121,8 @@ class crossgcc: extoolset = self.opts.expand(self.toolset, self.defaults) + self.defaults['_toolset'] = extoolset + root, ext = os.path.splitext(extoolset) if extoolset.endswith('.cfg'): @@ -202,7 +208,7 @@ class crossgcc: b = build.build(configs[s], _defaults = self.defaults, opts = self.opts) if s == 0: path = self.first_package(b) - b.make() + b.make(path) self.every_package(b, path) if s == len(configs) - 1: self.last_package(b, path) diff --git a/tb/defaults.py b/tb/defaults.py index a4c4940..9868011 100644 --- a/tb/defaults.py +++ b/tb/defaults.py @@ -49,9 +49,11 @@ defaults = { '_configdir': '%{_topdir}/config:%{_tbdir}/config', '_tardir': '%{_topdir}/tar', '_sourcedir': '%{_topdir}/sources', +'_patchdir': '%{_tbdir}/patches', '_builddir': '%{_topdir}/build/%{name}-%{version}-%{release}', '_docdir': '%{_defaultdocdir}', '_tmppath': '%{_topdir}/build/tmp', +'_tmproot': '%{_tmppath}/source-build-%(%{__id_u} -n)/%{_toolset}', 'buildroot:': '%{_tmppath}/%{name}-root-%(%{__id_u} -n)', # Defaults, override in platform specific modules. |