summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2013-05-15 12:15:14 +1000
committerChris Johns <chrisj@rtems.org>2013-05-15 12:15:14 +1000
commitdb65c6aaf1e73722cfa1327d77419ecc402f096a (patch)
tree282a2cccf62ad776a0f50beaec02ee936c7ed2d5
parentAdd better error messages. (diff)
downloadrtems-source-builder-db65c6aaf1e73722cfa1327d77419ecc402f096a.tar.bz2
Support Canadian cross builds on FreeBSD (and other hosts).
Set up the rules to manage the separate host and build setting to allow a Canadian cross to complete. Update the scripts to move the build directory and host/build flags into the defaults so they are common for all build configurations.
-rw-r--r--source-builder/config/binutils-2-1.cfg12
-rw-r--r--source-builder/config/dtc-1-1.cfg2
-rw-r--r--source-builder/config/expat-2-1.cfg8
-rw-r--r--source-builder/config/gcc-common-1.cfg23
-rw-r--r--source-builder/config/gdb-7-1.cfg21
-rw-r--r--source-builder/defaults.mc42
-rw-r--r--source-builder/sb/build.py3
-rw-r--r--source-builder/sb/check.py5
-rw-r--r--source-builder/sb/darwin.py9
-rw-r--r--source-builder/sb/freebsd.py56
-rw-r--r--source-builder/sb/linux.py9
-rw-r--r--source-builder/sb/windows.py8
12 files changed, 126 insertions, 72 deletions
diff --git a/source-builder/config/binutils-2-1.cfg b/source-builder/config/binutils-2-1.cfg
index 8c563eb..460536e 100644
--- a/source-builder/config/binutils-2-1.cfg
+++ b/source-builder/config/binutils-2-1.cfg
@@ -54,15 +54,13 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
cd ..
%build
- %{?host_force_32bit:HOST_FORCE_32BIT="-m32"}
- if test "%{_build}" != "%{_host}" ; then
- build_dir="build-cxc"
- else
- build_dir="build"
- fi
+ %{build_directory}
+
mkdir -p ${build_dir}
cd ${build_dir}
- CFLAGS="$SB_OPT_FLAGS" \
+
+ %{host_build_flags}
+
../${source_dir_0}/configure \
--build=%{_build} --host=%{_host} \
--target=%{_target} \
diff --git a/source-builder/config/dtc-1-1.cfg b/source-builder/config/dtc-1-1.cfg
index ff51e67..060c0b7 100644
--- a/source-builder/config/dtc-1-1.cfg
+++ b/source-builder/config/dtc-1-1.cfg
@@ -39,6 +39,8 @@ Source0: http://www.jdl.com/software/dtc-v%{dtc_version}.tgz
%build
cd dtc-v%{dtc_version}
+ %{host_build_flags}
+
%{__make} PREFIX=%{_prefix}
cd ..
diff --git a/source-builder/config/expat-2-1.cfg b/source-builder/config/expat-2-1.cfg
index ff7f4d4..91dc245 100644
--- a/source-builder/config/expat-2-1.cfg
+++ b/source-builder/config/expat-2-1.cfg
@@ -32,12 +32,8 @@ Source0: http://downloads.sourceforge.net/project/expat/expat/%{expat_version}/e
%build
cd expat-%{expat_version}
- if test "%{_build}" != "%{_host}" ; then
- CFLAGS_FOR_BUILD="-g -O2 -Wall"
- fi
- export CFLAGS_FOR_BUILD
+ %{host_build_flags}
- CFLAGS="$SB_OPT_FLAGS" \
./configure \
--build=%{_build} --host=%{_host} \
--verbose \
@@ -48,8 +44,6 @@ Source0: http://downloads.sourceforge.net/project/expat/expat/%{expat_version}/e
%{__make} %{?_smp_mflags} all
- unset CFLAGS_FOR_BUILD
-
cd ..
%install
diff --git a/source-builder/config/gcc-common-1.cfg b/source-builder/config/gcc-common-1.cfg
index 52320a4..c63b9ca 100644
--- a/source-builder/config/gcc-common-1.cfg
+++ b/source-builder/config/gcc-common-1.cfg
@@ -110,12 +110,8 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
cd ..
%build
- # Build directory support.
- if test "%{_build}" != "%{_host}" ; then
- build_dir="build-cxc"
- else
- build_dir="build"
- fi
+ %{build_directory}
+
mkdir -p ${build_dir}
cd ${build_dir}
@@ -140,18 +136,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
languages="$languages,objc"
%endif
- # Host flags
- if test "%{_build}" != "%{_host}" ; then
- CFLAGS_FOR_BUILD="-g -O2 -Wall"
- CC="%{_host}-gcc ${SB_OPT_FLAGS}"
- CXXFLAGS_FOR_BUILD="-g -O2 -Wall"
- CXX="%{_host}-g++ ${SB_OPT_FLAGS}"
- else
- # gcc is not ready to be compiled with -std=gnu99
- CC=$(echo "%{__cc} ${SB_OPT_FLAGS}" | sed -e 's,-std=gnu99 ,,')
- CXX=$(echo "%{__cxx} ${SB_OPT_FLAGS}" | sed -e 's,-std=gnu99 ,,')
- fi
- export CFLAGS CFLAGS_FOR_BUILD CC CXXFLAGS_FOR_BUILD CXX
+ %{host_build_flags}
../${source_dir_0}/configure \
--prefix=%{_prefix} \
@@ -190,8 +175,6 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
%{__make} %{?_smp_mflags} all
cd ..
- unset CFLAGS CFLAGS_FOR_BUILD CC CXXFLAGS_FOR_BUILD CXX
-
%install
%{__rmdir} $SB_BUILD_ROOT
diff --git a/source-builder/config/gdb-7-1.cfg b/source-builder/config/gdb-7-1.cfg
index 21dec87..2e41ab4 100644
--- a/source-builder/config/gdb-7-1.cfg
+++ b/source-builder/config/gdb-7-1.cfg
@@ -58,19 +58,22 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
cd ..
%build
- if test "%{_build}" != "%{_host}" ; then
- build_dir="build-cxc"
- else
- build_dir="build"
- fi
+ %{build_directory}
+
mkdir -p ${build_dir}
cd ${build_dir}
+
+ %{host_build_flags}
+
if test "%{_build}" != "%{_host}" ; then
- CFLAGS_FOR_BUILD="-g -O2 -Wall"
+ GDB_LIBS_STATIC="-lexpat"
+ else
+ GDB_LIBS_STATIC="-lexpat"
+ GDB_LIBS="%{_forced_static}"
fi
- LIBS_STATIC="-lexpat"
- CFLAGS="$SB_OPT_FLAGS" \
- LIBS="%{_forced_static}" \
+
+ LIBS_STATIC=${GDB_LIBS_STATIC} \
+ LIBS=${GDB_LIBS} \
../${source_dir_0}/configure \
--build=%{_build} --host=%{_host} \
--target=%{_target} \
diff --git a/source-builder/defaults.mc b/source-builder/defaults.mc
index ee9bc01..a2ed569 100644
--- a/source-builder/defaults.mc
+++ b/source-builder/defaults.mc
@@ -53,6 +53,10 @@ _target: none, optional, ''
# The user
_uid: none, convert, '%(%{__id_u} -n)'
+# Default flags
+optflags: none, convert, '-O2 -pipe'
+optincludes: none, convert, ''
+
# Paths
_host_platform: none, none, '%{_host_cpu}-%{_host_vendor}-%{_host_os}%{?_gnu}'
_arch: none, none, '%{_host_arch}'
@@ -170,10 +174,12 @@ export SB_ORIG_PATH=${PATH}
%{?_prefix:SB_PREFIX_CLEAN=$(echo "%{_prefix}" | %{__sed} -e 's/^\///')}
SB_SOURCE_DIR="%{_sourcedir}"
SB_BUILD_DIR="%{_builddir}"
-SB_OPT_FLAGS="%{?_tmproot:-I%{_tmproot}/${SB_PREFIX_CLEAN}/include -L%{_tmproot}/${SB_PREFIX_CLEAN}/lib} %{optflags}"
+SB_OPT_HOST_FLAGS="%{optflags} %{?_tmproot:-I%{_tmproot}/${SB_PREFIX_CLEAN}/include -L%{_tmproot}/${SB_PREFIX_CLEAN}/lib}"
+SB_OPT_BUILD_FLAGS="%{optflags} %{optincludes}"
+SB_OPT_FLAGS="${SB_OPT_HOST_FLAGS} %{optincludes}"
SB_ARCH="%{_arch}"
SB_OS="%{_os}"
-export SB_SOURCE_DIR SB_BUILD_DIR SB_OPT_FLAGS SB_ARCH SB_OS
+export SB_SOURCE_DIR SB_BUILD_DIR SB_OPT_HOST_FLAGS SB_OPT_BUILD_FLAGS SB_OPT_FLAGS SB_ARCH SB_OS
# Documentation
SB_DOC_DIR="%{_docdir}"
export SB_DOC_DIR
@@ -229,9 +235,9 @@ ___build_template: none, none, '''#!%{___build_shell}
# Configure command
configure: none, none, '''
-CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ;
-CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ;
-FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ;
+CFLAGS="${CFLAGS:-${SB_OPT_FLAGS}" ; export CFLAGS ;
+CXXFLAGS="${CXXFLAGS:-${SB_OPT_FLAGS}}" ; export CXXFLAGS ;
+FFLAGS="${FFLAGS:-${SB_OPT_FLAGS}}" ; export FFLAGS ;
./configure --build=%{_build} --host=%{_host} \
--target=%{_target_platform} \
--program-prefix=%{?_program_prefix} \
@@ -249,6 +255,32 @@ FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ;
--mandir=%{_mandir} \
--infodir=%{_infodir}'''
+# Build script support.
+build_directory: none, none, '''
+if test "%{_build}" != "%{_host}" ; then
+ build_dir="build-cxc"
+else
+ build_dir="build"
+fi'''
+
+host_build_flags: none, none, '''
+# Host and build flags
+if test "%{_build}" != "%{_host}" ; then
+ CFLAGS_FOR_BUILD="${SB_OPT_HOST_FLAGS}"
+ CC=$(echo "%{_host}-gcc ${SB_OPT_HOST_FLAGS}" | sed -e 's,-std=gnu99 ,,')
+ CXXFLAGS_FOR_BUILD="${SB_OPT_HOST_FLAGS}"
+ CXX=$(echo "%{_host}-g++ ${SB_OPT_HOST_FLAGS}" | sed -e 's,-std=gnu99 ,,')
+ CC_FOR_BUILD=$(echo "%{__cc} ${SB_OPT_FLAGS}" | sed -e 's,-std=gnu99 ,,')
+ CXX_FOR_BUILD=$(echo "%{__cxx} ${SB_OPT_FLAGS}" | sed -e 's,-std=gnu99 ,,')
+else
+ # gcc is not ready to be compiled with -std=gnu99
+ CC=$(echo "%{__cc} ${SB_OPT_FLAGS}" | sed -e 's,-std=gnu99 ,,')
+ CXX=$(echo "%{__cxx} ${SB_OPT_FLAGS}" | sed -e 's,-std=gnu99 ,,')
+ CC_FOR_BUILD=${CC}
+ CXX_FOR_BUILD=${CXX}
+fi
+export CC CXX CC_FOR_BUILD CXX_FOR_BUILD CFLAGS CFLAGS_FOR_BUILD CXXFLAGS_FOR_BUILD'''
+
# Default package settings
_forced_static: none, none, '-Xlinker -Bstatic ${LIBS_STATIC} -Xlinker -Bdynamic'
__xz: exe, required, '/usr/bin/xz'
diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py
index a2570e6..8b6ae35 100644
--- a/source-builder/sb/build.py
+++ b/source-builder/sb/build.py
@@ -291,8 +291,7 @@ class build:
self.script.append('echo "==> %build:"')
_build = package.build()
for l in _build:
- args = l.split()
- self.script.append(' '.join(args))
+ self.script.append(l)
def install(self, package):
self.script.append('echo "==> %install:"')
diff --git a/source-builder/sb/check.py b/source-builder/sb/check.py
index 56d5b6d..f28f791 100644
--- a/source-builder/sb/check.py
+++ b/source-builder/sb/check.py
@@ -91,6 +91,7 @@ def _check_paths(name, paths):
return True
return False
+
def host_setup(opts):
""" Basic sanity check. All executables and directories must exist."""
@@ -125,6 +126,10 @@ def host_setup(opts):
return sane
+def check_exe(label, exe):
+ return _check_exe(None, label, exe, None)
+
+
def run():
import sys
try:
diff --git a/source-builder/sb/darwin.py b/source-builder/sb/darwin.py
index b924a0f..498ac48 100644
--- a/source-builder/sb/darwin.py
+++ b/source-builder/sb/darwin.py
@@ -47,12 +47,19 @@ def load():
'_usr': ('dir', 'optional', '/usr/local'),
'_var': ('dir', 'optional', '/usr/local/var'),
'_prefix': ('dir', 'optional', '%{_usr}'),
- 'optflags': ('none', 'none', '-O2'),
'__ldconfig': ('exe', 'none', ''),
'__xz': ('exe', 'required', '%{_usr}/bin/xz'),
'with_zlib': ('none', 'none', '--with-zlib=no'),
'_forced_static': ('none', 'none', '')
}
+
+ defines['_build'] = defines['_host']
+ defines['_build_vendor'] = defines['_host_vendor']
+ defines['_build_os'] = defines['_host_os']
+ defines['_build_cpu'] = defines['_host_cpu']
+ defines['_build_alias'] = defines['_host_alias']
+ defines['_build_arch'] = defines['_host_arch']
+
return defines
if __name__ == '__main__':
diff --git a/source-builder/sb/freebsd.py b/source-builder/sb/freebsd.py
index 76c79e4..afbabf8 100644
--- a/source-builder/sb/freebsd.py
+++ b/source-builder/sb/freebsd.py
@@ -27,6 +27,7 @@
import pprint
import os
+import check
import execute
def load():
@@ -46,25 +47,44 @@ def load():
if version.find('-') > 0:
version = version.split('-')[0]
defines = {
- '_ncpus': ('none', 'none', ncpus),
- '_os': ('none', 'none', 'freebsd'),
- '_host': ('triplet', 'required', cpu + '-freebsd' + version),
- '_host_vendor': ('none', 'none', 'pc'),
- '_host_os': ('none', 'none', 'freebsd'),
- '_host_cpu': ('none', 'none', cpu),
- '_host_alias': ('none', 'none', '%{nil}'),
- '_host_arch': ('none', 'none', cpu),
- '_usr': ('dir', 'required', '/usr/local'),
- '_var': ('dir', 'optional', '/usr/local/var'),
- 'optflags': ('none', 'none', '-O2 -I/usr/local/include -L/usr/local/lib'),
- '__bash': ('exe', 'optional', '/usr/local/bin/bash'),
- '__bison': ('exe', 'required', '/usr/local/bin/bison'),
- '__git': ('exe', 'required', '/usr/local/bin/git'),
- '__svn': ('exe', 'required', '/usr/local/bin/svn'),
- '__xz': ('exe', 'optional', '/usr/bin/xz'),
- '__make': ('exe', 'required', 'gmake'),
- '__patch_opts': ('none', 'none', '-E')
+ '_ncpus': ('none', 'none', ncpus),
+ '_os': ('none', 'none', 'freebsd'),
+ '_host': ('triplet', 'required', cpu + '-freebsd' + version),
+ '_host_vendor': ('none', 'none', 'pc'),
+ '_host_os': ('none', 'none', 'freebsd'),
+ '_host_cpu': ('none', 'none', cpu),
+ '_host_alias': ('none', 'none', '%{nil}'),
+ '_host_arch': ('none', 'none', cpu),
+ '_usr': ('dir', 'required', '/usr/local'),
+ '_var': ('dir', 'optional', '/usr/local/var'),
+ 'optincludes': ('none', 'none', '-I/usr/local/include -L/usr/local/lib'),
+ '__bash': ('exe', 'optional', '/usr/local/bin/bash'),
+ '__bison': ('exe', 'required', '/usr/local/bin/bison'),
+ '__git': ('exe', 'required', '/usr/local/bin/git'),
+ '__svn': ('exe', 'required', '/usr/local/bin/svn'),
+ '__xz': ('exe', 'optional', '/usr/bin/xz'),
+ '__make': ('exe', 'required', 'gmake'),
+ '__patch_opts': ('none', 'none', '-E')
}
+
+ defines['_build'] = defines['_host']
+ defines['_build_vendor'] = defines['_host_vendor']
+ defines['_build_os'] = defines['_host_os']
+ defines['_build_cpu'] = defines['_host_cpu']
+ defines['_build_alias'] = defines['_host_alias']
+ defines['_build_arch'] = defines['_host_arch']
+
+ for gv in ['47', '48', '49']:
+ gcc = '%s-portbld-freebsd%s-gcc%s' % (cpu, version, gv)
+ if check.check_exe(gcc, gcc):
+ defines['__cc'] = gcc
+ break
+ for gv in ['47', '48', '49']:
+ gxx = '%s-portbld-freebsd%s-g++%s' % (cpu, version, gv)
+ if check.check_exe(gxx, gxx):
+ defines['__cxx'] = gxx
+ break
+
return defines
if __name__ == '__main__':
diff --git a/source-builder/sb/linux.py b/source-builder/sb/linux.py
index 94fbf1e..6c4cf52 100644
--- a/source-builder/sb/linux.py
+++ b/source-builder/sb/linux.py
@@ -61,7 +61,6 @@ def load():
'_host_arch': ('none', 'none', cpu),
'_usr': ('dir', 'required', '/usr'),
'_var': ('dir', 'required', '/var'),
- 'optflags': ('none', 'none', '-O2 -pipe'),
'__bzip2': ('exe', 'required', '/usr/bin/bzip2'),
'__gzip': ('exe', 'required', '/bin/gzip'),
'__tar': ('exe', 'required', '/bin/tar')
@@ -120,6 +119,14 @@ def load():
for v in variations[distro]:
if path.exists(variations[distro][v][2]):
defines[v] = variations[distro][v]
+
+ defines['_build'] = defines['_host']
+ defines['_build_vendor'] = defines['_host_vendor']
+ defines['_build_os'] = defines['_host_os']
+ defines['_build_cpu'] = defines['_host_cpu']
+ defines['_build_alias'] = defines['_host_alias']
+ defines['_build_arch'] = defines['_host_arch']
+
return defines
if __name__ == '__main__':
diff --git a/source-builder/sb/windows.py b/source-builder/sb/windows.py
index 1b636d6..c9fd111 100644
--- a/source-builder/sb/windows.py
+++ b/source-builder/sb/windows.py
@@ -66,6 +66,11 @@ def load():
'_ncpus': ('none', 'none', ncpus),
'_os': ('none', 'none', 'win32'),
'_build': ('triplet', 'required', build_triple),
+ '_build_vendor': ('none', 'none', 'microsoft'),
+ '_build_os': ('none', 'none', 'win32'),
+ '_build_cpu': ('none', 'none', hosttype),
+ '_build_alias': ('none', 'none', '%{nil}'),
+ '_build_arch': ('none', 'none', hosttype),
'_host': ('triplet', 'required', host_triple),
'_host_vendor': ('none', 'none', 'microsoft'),
'_host_os': ('none', 'none', 'win32'),
@@ -111,8 +116,7 @@ def load():
'__unzip': ('exe', 'required', 'unzip'),
'__xz': ('exe', 'required', 'xz'),
'_buildshell': ('exe', 'required', '%{__sh}'),
- '___setup_shell': ('exe', 'required', '%{__sh}'),
- 'optflags': ('none', 'none', '-O2 -pipe'),
+ '___setup_shell': ('exe', 'required', '%{__sh}')
}
return defines