crosstool-ng/scripts/build/libc/moxiebox.sh
Alexey Neyman 40d5bf6440 Add moxiebox as a choice for libc
This required some rework of the libc selection, as moxiebox is a layer on
top of another libc - newlib.

Also, moxiebox'es host VM (`sandbox`) needs a libcrypto on the host. We will
not have it if we're cross-compiling a canadian cross. Fortunately, all moxiebox
needs from libcrypto is SHA256, and it already includes a standalone implementation
of SHA256 in its runtime. Provide a little wrapper that allows moxiebox use
that implementation for the host binary, too.

Also, automate collecting/printing the list of all packages in a given category
(e.g. LIBC or COMP_TOOLS), generate a list of all Kconfig symbols for a given
category.

Signed-off-by: Alexey Neyman <stilor@att.net>
2018-12-01 10:10:51 -08:00

85 lines
3.2 KiB
Bash

# Functions to build the moxiebox runtime.
. "${CT_LIB_DIR}/scripts/build/libc/newlib.sh"
moxiebox_get()
{
CT_Fetch NEWLIB
CT_Fetch MOXIEBOX
}
moxiebox_extract()
{
CT_ExtractPatch NEWLIB
CT_ExtractPatch MOXIEBOX
}
moxiebox_start_files()
{
newlib_start_files
}
moxiebox_main()
{
newlib_main
# newlib installs the linker script, moxiebox.ld, to the
# PREFIX/moxie-unknown-moxiebox/lib, but ld searches PREFIX/lib when
# configured for that target. ld does find scripts in PREFIX/TARGET/lib
# for other targets, so this seems to be moxie architecture's quirk.
# Move it to PREFIX/lib.
# TBD CT_DoExecLog ALL mv -v "${CT_SYSROOT_DIR}/lib/"*.ld "${CT_PREFIX_DIR}/lib"
# TBD what about moxie-*-elf? Does it need the same?
CT_DoStep INFO "Installing moxiebox runtime and VM"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-moxiebox"
CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/moxiebox/." .
CT_DoLog EXTRA "Building SHA256-only libcrypto"
# Moxiebox needs libcrypto on the host, but it only uses SHA256 digest functions
# from it. We don't want to pull the whole OpenSSL for the host; fortunately,
# moxiebox comes with a standalone SHA256 implementation - which it only uses
# for the target library. Help it use the same implementation for the host.
CT_mkdir_pushd openssl
CT_DoExecLog ALL cp -v "${CT_LIB_DIR}/packages/moxiebox/"sha*.[ch] ./
CT_DoExecLog ALL "${CT_HOST}-gcc" -c sha256_wrap.c -O2 -Wall
CT_DoExecLog ALL "${CT_HOST}-ar" cru libcrypto.a sha256_wrap.o
CT_Popd
# Moxiebox includes a VM which we're building for the
# host machine.
CT_DoLog EXTRA "Configuring moxiebox"
CT_DoExecLog CFG ./autogen.sh
# moxiebox build script create symlinks from the installation location to the build
# directory for the moxiebox library. This seems backwards. Instead, pass the search
# as part of the MOX_GCC definition.
# moxiebox also depends on the tools being named moxiebox-{gcc,as,ar}. However, failure
# to detect such tools is non-fatal in the configure and we need to override it in
# make's command line anyway.
CT_DoExecLog CFG \
LDFLAGS="${CT_LDFLAGS_FOR_HOST} -L${CT_BUILD_DIR}/build-libc-moxiebox/openssl" \
CFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \
CXXFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \
./configure \
--host="${CT_HOST}"
CT_DoLog EXTRA "Building moxiebox"
CT_DoExecLog CFG make all \
MOX_GCC="${CT_TARGET}-gcc -B ${CT_BUILD_DIR}/build-libc-moxiebox/runtime -B ${CT_SYSROOT_DIR}/lib" \
MOX_AS="${CT_TARGET}-as" \
MOX_AR="${CT_TARGET}-ar"
CT_DoLog EXTRA "Installing moxiebox"
# moxiebox does not have install target. Copy the interesting stuff manually.
CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/runtime/libsandboxrt.a" \
"${CT_BUILD_DIR}/build-libc-moxiebox/runtime/crt0.o" \
"${CT_SYSROOT_DIR}/lib/"
CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/src/sandbox" \
"${CT_PREFIX_DIR}/bin"
CT_Popd
CT_EndStep
}