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.
This commit is contained in:
Chris Johns 2013-05-15 12:15:14 +10:00
parent 8a1e7a0ab0
commit db65c6aaf1
12 changed files with 126 additions and 72 deletions

View File

@ -54,15 +54,13 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
cd .. cd ..
%build %build
%{?host_force_32bit:HOST_FORCE_32BIT="-m32"} %{build_directory}
if test "%{_build}" != "%{_host}" ; then
build_dir="build-cxc"
else
build_dir="build"
fi
mkdir -p ${build_dir} mkdir -p ${build_dir}
cd ${build_dir} cd ${build_dir}
CFLAGS="$SB_OPT_FLAGS" \
%{host_build_flags}
../${source_dir_0}/configure \ ../${source_dir_0}/configure \
--build=%{_build} --host=%{_host} \ --build=%{_build} --host=%{_host} \
--target=%{_target} \ --target=%{_target} \

View File

@ -39,6 +39,8 @@ Source0: http://www.jdl.com/software/dtc-v%{dtc_version}.tgz
%build %build
cd dtc-v%{dtc_version} cd dtc-v%{dtc_version}
%{host_build_flags}
%{__make} PREFIX=%{_prefix} %{__make} PREFIX=%{_prefix}
cd .. cd ..

View File

@ -32,12 +32,8 @@ Source0: http://downloads.sourceforge.net/project/expat/expat/%{expat_version}/e
%build %build
cd expat-%{expat_version} cd expat-%{expat_version}
if test "%{_build}" != "%{_host}" ; then %{host_build_flags}
CFLAGS_FOR_BUILD="-g -O2 -Wall"
fi
export CFLAGS_FOR_BUILD
CFLAGS="$SB_OPT_FLAGS" \
./configure \ ./configure \
--build=%{_build} --host=%{_host} \ --build=%{_build} --host=%{_host} \
--verbose \ --verbose \
@ -48,8 +44,6 @@ Source0: http://downloads.sourceforge.net/project/expat/expat/%{expat_version}/e
%{__make} %{?_smp_mflags} all %{__make} %{?_smp_mflags} all
unset CFLAGS_FOR_BUILD
cd .. cd ..
%install %install

View File

@ -110,12 +110,8 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
cd .. cd ..
%build %build
# Build directory support. %{build_directory}
if test "%{_build}" != "%{_host}" ; then
build_dir="build-cxc"
else
build_dir="build"
fi
mkdir -p ${build_dir} mkdir -p ${build_dir}
cd ${build_dir} cd ${build_dir}
@ -140,18 +136,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
languages="$languages,objc" languages="$languages,objc"
%endif %endif
# Host flags %{host_build_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
../${source_dir_0}/configure \ ../${source_dir_0}/configure \
--prefix=%{_prefix} \ --prefix=%{_prefix} \
@ -190,8 +175,6 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
%{__make} %{?_smp_mflags} all %{__make} %{?_smp_mflags} all
cd .. cd ..
unset CFLAGS CFLAGS_FOR_BUILD CC CXXFLAGS_FOR_BUILD CXX
%install %install
%{__rmdir} $SB_BUILD_ROOT %{__rmdir} $SB_BUILD_ROOT

View File

@ -58,19 +58,22 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
cd .. cd ..
%build %build
if test "%{_build}" != "%{_host}" ; then %{build_directory}
build_dir="build-cxc"
else
build_dir="build"
fi
mkdir -p ${build_dir} mkdir -p ${build_dir}
cd ${build_dir} cd ${build_dir}
%{host_build_flags}
if test "%{_build}" != "%{_host}" ; then 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 fi
LIBS_STATIC="-lexpat"
CFLAGS="$SB_OPT_FLAGS" \ LIBS_STATIC=${GDB_LIBS_STATIC} \
LIBS="%{_forced_static}" \ LIBS=${GDB_LIBS} \
../${source_dir_0}/configure \ ../${source_dir_0}/configure \
--build=%{_build} --host=%{_host} \ --build=%{_build} --host=%{_host} \
--target=%{_target} \ --target=%{_target} \

View File

@ -53,6 +53,10 @@ _target: none, optional, ''
# The user # The user
_uid: none, convert, '%(%{__id_u} -n)' _uid: none, convert, '%(%{__id_u} -n)'
# Default flags
optflags: none, convert, '-O2 -pipe'
optincludes: none, convert, ''
# Paths # Paths
_host_platform: none, none, '%{_host_cpu}-%{_host_vendor}-%{_host_os}%{?_gnu}' _host_platform: none, none, '%{_host_cpu}-%{_host_vendor}-%{_host_os}%{?_gnu}'
_arch: none, none, '%{_host_arch}' _arch: none, none, '%{_host_arch}'
@ -170,10 +174,12 @@ export SB_ORIG_PATH=${PATH}
%{?_prefix:SB_PREFIX_CLEAN=$(echo "%{_prefix}" | %{__sed} -e 's/^\///')} %{?_prefix:SB_PREFIX_CLEAN=$(echo "%{_prefix}" | %{__sed} -e 's/^\///')}
SB_SOURCE_DIR="%{_sourcedir}" SB_SOURCE_DIR="%{_sourcedir}"
SB_BUILD_DIR="%{_builddir}" 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_ARCH="%{_arch}"
SB_OS="%{_os}" 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 # Documentation
SB_DOC_DIR="%{_docdir}" SB_DOC_DIR="%{_docdir}"
export SB_DOC_DIR export SB_DOC_DIR
@ -229,9 +235,9 @@ ___build_template: none, none, '''#!%{___build_shell}
# Configure command # Configure command
configure: none, none, ''' configure: none, none, '''
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; CFLAGS="${CFLAGS:-${SB_OPT_FLAGS}" ; export CFLAGS ;
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; CXXFLAGS="${CXXFLAGS:-${SB_OPT_FLAGS}}" ; export CXXFLAGS ;
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; FFLAGS="${FFLAGS:-${SB_OPT_FLAGS}}" ; export FFLAGS ;
./configure --build=%{_build} --host=%{_host} \ ./configure --build=%{_build} --host=%{_host} \
--target=%{_target_platform} \ --target=%{_target_platform} \
--program-prefix=%{?_program_prefix} \ --program-prefix=%{?_program_prefix} \
@ -249,6 +255,32 @@ FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ;
--mandir=%{_mandir} \ --mandir=%{_mandir} \
--infodir=%{_infodir}''' --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 # Default package settings
_forced_static: none, none, '-Xlinker -Bstatic ${LIBS_STATIC} -Xlinker -Bdynamic' _forced_static: none, none, '-Xlinker -Bstatic ${LIBS_STATIC} -Xlinker -Bdynamic'
__xz: exe, required, '/usr/bin/xz' __xz: exe, required, '/usr/bin/xz'

View File

@ -291,8 +291,7 @@ class build:
self.script.append('echo "==> %build:"') self.script.append('echo "==> %build:"')
_build = package.build() _build = package.build()
for l in _build: for l in _build:
args = l.split() self.script.append(l)
self.script.append(' '.join(args))
def install(self, package): def install(self, package):
self.script.append('echo "==> %install:"') self.script.append('echo "==> %install:"')

View File

@ -91,6 +91,7 @@ def _check_paths(name, paths):
return True return True
return False return False
def host_setup(opts): def host_setup(opts):
""" Basic sanity check. All executables and directories must exist.""" """ Basic sanity check. All executables and directories must exist."""
@ -125,6 +126,10 @@ def host_setup(opts):
return sane return sane
def check_exe(label, exe):
return _check_exe(None, label, exe, None)
def run(): def run():
import sys import sys
try: try:

View File

@ -47,12 +47,19 @@ def load():
'_usr': ('dir', 'optional', '/usr/local'), '_usr': ('dir', 'optional', '/usr/local'),
'_var': ('dir', 'optional', '/usr/local/var'), '_var': ('dir', 'optional', '/usr/local/var'),
'_prefix': ('dir', 'optional', '%{_usr}'), '_prefix': ('dir', 'optional', '%{_usr}'),
'optflags': ('none', 'none', '-O2'),
'__ldconfig': ('exe', 'none', ''), '__ldconfig': ('exe', 'none', ''),
'__xz': ('exe', 'required', '%{_usr}/bin/xz'), '__xz': ('exe', 'required', '%{_usr}/bin/xz'),
'with_zlib': ('none', 'none', '--with-zlib=no'), 'with_zlib': ('none', 'none', '--with-zlib=no'),
'_forced_static': ('none', 'none', '') '_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 return defines
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -27,6 +27,7 @@
import pprint import pprint
import os import os
import check
import execute import execute
def load(): def load():
@ -46,25 +47,44 @@ def load():
if version.find('-') > 0: if version.find('-') > 0:
version = version.split('-')[0] version = version.split('-')[0]
defines = { defines = {
'_ncpus': ('none', 'none', ncpus), '_ncpus': ('none', 'none', ncpus),
'_os': ('none', 'none', 'freebsd'), '_os': ('none', 'none', 'freebsd'),
'_host': ('triplet', 'required', cpu + '-freebsd' + version), '_host': ('triplet', 'required', cpu + '-freebsd' + version),
'_host_vendor': ('none', 'none', 'pc'), '_host_vendor': ('none', 'none', 'pc'),
'_host_os': ('none', 'none', 'freebsd'), '_host_os': ('none', 'none', 'freebsd'),
'_host_cpu': ('none', 'none', cpu), '_host_cpu': ('none', 'none', cpu),
'_host_alias': ('none', 'none', '%{nil}'), '_host_alias': ('none', 'none', '%{nil}'),
'_host_arch': ('none', 'none', cpu), '_host_arch': ('none', 'none', cpu),
'_usr': ('dir', 'required', '/usr/local'), '_usr': ('dir', 'required', '/usr/local'),
'_var': ('dir', 'optional', '/usr/local/var'), '_var': ('dir', 'optional', '/usr/local/var'),
'optflags': ('none', 'none', '-O2 -I/usr/local/include -L/usr/local/lib'), 'optincludes': ('none', 'none', '-I/usr/local/include -L/usr/local/lib'),
'__bash': ('exe', 'optional', '/usr/local/bin/bash'), '__bash': ('exe', 'optional', '/usr/local/bin/bash'),
'__bison': ('exe', 'required', '/usr/local/bin/bison'), '__bison': ('exe', 'required', '/usr/local/bin/bison'),
'__git': ('exe', 'required', '/usr/local/bin/git'), '__git': ('exe', 'required', '/usr/local/bin/git'),
'__svn': ('exe', 'required', '/usr/local/bin/svn'), '__svn': ('exe', 'required', '/usr/local/bin/svn'),
'__xz': ('exe', 'optional', '/usr/bin/xz'), '__xz': ('exe', 'optional', '/usr/bin/xz'),
'__make': ('exe', 'required', 'gmake'), '__make': ('exe', 'required', 'gmake'),
'__patch_opts': ('none', 'none', '-E') '__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 return defines
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -61,7 +61,6 @@ def load():
'_host_arch': ('none', 'none', cpu), '_host_arch': ('none', 'none', cpu),
'_usr': ('dir', 'required', '/usr'), '_usr': ('dir', 'required', '/usr'),
'_var': ('dir', 'required', '/var'), '_var': ('dir', 'required', '/var'),
'optflags': ('none', 'none', '-O2 -pipe'),
'__bzip2': ('exe', 'required', '/usr/bin/bzip2'), '__bzip2': ('exe', 'required', '/usr/bin/bzip2'),
'__gzip': ('exe', 'required', '/bin/gzip'), '__gzip': ('exe', 'required', '/bin/gzip'),
'__tar': ('exe', 'required', '/bin/tar') '__tar': ('exe', 'required', '/bin/tar')
@ -120,6 +119,14 @@ def load():
for v in variations[distro]: for v in variations[distro]:
if path.exists(variations[distro][v][2]): if path.exists(variations[distro][v][2]):
defines[v] = variations[distro][v] 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 return defines
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -66,6 +66,11 @@ def load():
'_ncpus': ('none', 'none', ncpus), '_ncpus': ('none', 'none', ncpus),
'_os': ('none', 'none', 'win32'), '_os': ('none', 'none', 'win32'),
'_build': ('triplet', 'required', build_triple), '_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': ('triplet', 'required', host_triple),
'_host_vendor': ('none', 'none', 'microsoft'), '_host_vendor': ('none', 'none', 'microsoft'),
'_host_os': ('none', 'none', 'win32'), '_host_os': ('none', 'none', 'win32'),
@ -111,8 +116,7 @@ def load():
'__unzip': ('exe', 'required', 'unzip'), '__unzip': ('exe', 'required', 'unzip'),
'__xz': ('exe', 'required', 'xz'), '__xz': ('exe', 'required', 'xz'),
'_buildshell': ('exe', 'required', '%{__sh}'), '_buildshell': ('exe', 'required', '%{__sh}'),
'___setup_shell': ('exe', 'required', '%{__sh}'), '___setup_shell': ('exe', 'required', '%{__sh}')
'optflags': ('none', 'none', '-O2 -pipe'),
} }
return defines return defines