diff options
Diffstat (limited to 'scripts/build/companion_libs')
-rw-r--r-- | scripts/build/companion_libs/050-zlib.sh | 55 | ||||
-rw-r--r-- | scripts/build/companion_libs/100-gmp.sh | 59 | ||||
-rw-r--r-- | scripts/build/companion_libs/110-mpfr.sh | 14 | ||||
-rw-r--r-- | scripts/build/companion_libs/121-isl.sh | 21 | ||||
-rw-r--r-- | scripts/build/companion_libs/130-cloog.sh | 24 | ||||
-rw-r--r-- | scripts/build/companion_libs/140-mpc.sh | 13 | ||||
-rw-r--r-- | scripts/build/companion_libs/200-libelf.sh | 11 | ||||
-rw-r--r--[-rwxr-xr-x] | scripts/build/companion_libs/210-expat.sh | 14 | ||||
-rw-r--r-- | scripts/build/companion_libs/220-ncurses.sh | 52 | ||||
-rw-r--r-- | scripts/build/companion_libs/320-libiconv.sh | 10 | ||||
-rw-r--r-- | scripts/build/companion_libs/330-gettext.sh | 32 | ||||
-rw-r--r-- | scripts/build/companion_libs/340-picolibc.sh | 171 | ||||
-rw-r--r-- | scripts/build/companion_libs/350-newlib_nano.sh | 276 | ||||
-rw-r--r-- | scripts/build/companion_libs/400-gnuprumcu.sh | 88 |
14 files changed, 700 insertions, 140 deletions
diff --git a/scripts/build/companion_libs/050-zlib.sh b/scripts/build/companion_libs/050-zlib.sh index 6e17819..8c6a0f6 100644 --- a/scripts/build/companion_libs/050-zlib.sh +++ b/scripts/build/companion_libs/050-zlib.sh @@ -13,14 +13,12 @@ if [ "${CT_ZLIB}" = "y" ]; then # Download zlib do_zlib_get() { - CT_GetFile "zlib-${CT_ZLIB_VERSION}" \ - "http://downloads.sourceforge.net/project/libpng/zlib/${CT_ZLIB_VERSION}" + CT_Fetch ZLIB } # Extract zlib do_zlib_extract() { - CT_Extract "zlib-${CT_ZLIB_VERSION}" - CT_Patch "zlib" "${CT_ZLIB_VERSION}" + CT_ExtractPatch ZLIB } # Build zlib for running on build @@ -76,30 +74,51 @@ do_zlib_backend() { local ldflags local arg local -a extra_config + local -a extra_make for arg in "$@"; do eval "${arg// /\\ }" done - CT_DoLog EXTRA "Configuring zlib" - - CT_DoExecLog CFG \ - CFLAGS="${cflags}" \ - LDFLAGS="${ldflags}" \ - CROSS_PREFIX="${host}-" \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/zlib-${CT_ZLIB_VERSION}/configure" \ - --prefix="${prefix}" \ - --static \ - "${extra_config[@]}" + case "${host}" in + *-mingw32) + # zlib treats mingw host differently and requires using a different + # makefile rather than configure+make. It also does not support + # out-of-tree building. + cp -av "${CT_SRC_DIR}/zlib/." . + extra_make=( -f win32/Makefile.gcc \ + PREFIX="${host}-" \ + SHAREDLIB= \ + IMPLIB= \ + LIBRARY_PATH="${prefix}/lib" \ + INCLUDE_PATH="${prefix}/include" \ + BINARY_PATH="${prefix}/bin" \ + prefix="${prefix}" \ + ) + ;; + + *) + CT_DoLog EXTRA "Configuring zlib" + + CT_DoExecLog CFG \ + CFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + CHOST="${host}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/zlib/configure" \ + --prefix="${prefix}" \ + --static \ + "${extra_config[@]}" + ;; + esac CT_DoLog EXTRA "Building zlib" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make "${extra_make[@]}" ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking zlib" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make "${extra_make[@]}" -s test else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for zlib on the host" @@ -107,7 +126,7 @@ do_zlib_backend() { fi CT_DoLog EXTRA "Installing zlib" - CT_DoExecLog ALL make install + CT_DoExecLog ALL make "${extra_make[@]}" install } fi # CT_ZLIB diff --git a/scripts/build/companion_libs/100-gmp.sh b/scripts/build/companion_libs/100-gmp.sh index c81874a..a17eda9 100644 --- a/scripts/build/companion_libs/100-gmp.sh +++ b/scripts/build/companion_libs/100-gmp.sh @@ -9,19 +9,16 @@ do_gmp_for_host() { :; } do_gmp_for_target() { :; } # Overide functions depending on configuration -if [ "${CT_GMP}" = "y" ]; then +if [ "${CT_GMP_TARGET}" = "y" -o "${CT_GMP}" = "y" ]; then # Download GMP do_gmp_get() { - CT_GetFile "gmp-${CT_GMP_VERSION}" \ - https://gmplib.org/download/gmp \ - {http,ftp,https}://ftp.gnu.org/gnu/gmp + CT_Fetch GMP } # Extract GMP do_gmp_extract() { - CT_Extract "gmp-${CT_GMP_VERSION}" - CT_Patch "gmp" "${CT_GMP_VERSION}" + CT_ExtractPatch GMP } # Build GMP for running on build @@ -64,12 +61,40 @@ do_gmp_for_host() { CT_EndStep } +if [ "${CT_GMP_TARGET}" = "y" ]; then +do_gmp_for_target() { + local -a gmp_opts + + CT_DoStep INFO "Installing GMP for target" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-target-${CT_HOST}" + + gmp_opts+=( "host=${CT_TARGET}" ) + case "${CT_TARGET}" in + *-*-mingw*) + prefix="/mingw" + ;; + *) + prefix="/usr" + ;; + esac + gmp_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) + gmp_opts+=( "prefix=${prefix}" ) + gmp_opts+=( "destdir=${CT_SYSROOT_DIR}" ) + gmp_opts+=( "shared=${CT_SHARED_LIBS}" ) + do_gmp_backend "${gmp_opts[@]}" + + CT_Popd + CT_EndStep +} +fi + # Build GMP # Parameter : description : type : default # host : machine to run on : tuple : (none) # prefix : prefix to install into : dir : (none) # cflags : cflags to use : string : (empty) # ldflags : ldflags to use : string : (empty) +# destdir : install destination : dir : (none) do_gmp_backend() { local host local prefix @@ -84,15 +109,23 @@ do_gmp_backend() { CT_DoLog EXTRA "Configuring GMP" - if [ ! "${CT_GMP_5_0_2_or_later}" = "y" ]; then - extra_config+=("--enable-mpbsd") - fi + # To avoind “illegal text-relocation” linking error against + # the static library, see: + # https://github.com/Homebrew/homebrew-core/pull/25470 + case "${host}" in + *darwin*) + extra_config+=("--with-pic") + ;; + esac + # FIXME: GMP's configure script doesn't respect the host parameter + # when not cross-compiling, ie when build == host. CT_DoExecLog CFG \ + CC="${host}-gcc" \ CFLAGS="${cflags} -fexceptions" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \ + "${CT_SRC_DIR}/gmp/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -103,12 +136,12 @@ do_gmp_backend() { "${extra_config[@]}" CT_DoLog EXTRA "Building GMP" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking GMP" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for GMP on the host" @@ -116,7 +149,7 @@ do_gmp_backend() { fi CT_DoLog EXTRA "Installing GMP" - CT_DoExecLog ALL make install + CT_DoExecLog ALL make install DESTDIR="${destdir}" } fi # CT_GMP diff --git a/scripts/build/companion_libs/110-mpfr.sh b/scripts/build/companion_libs/110-mpfr.sh index 5a89077..d2cb9f6 100644 --- a/scripts/build/companion_libs/110-mpfr.sh +++ b/scripts/build/companion_libs/110-mpfr.sh @@ -13,16 +13,14 @@ if [ "${CT_MPFR}" = "y" ]; then # Download MPFR do_mpfr_get() { - CT_GetFile "mpfr-${CT_MPFR_VERSION}" \ - {https,http,ftp}://ftp.gnu.org/gnu/mpfr \ - http://www.mpfr.org/mpfr-${CT_MPFR_VERSION} + CT_Fetch MPFR } # Extract MPFR do_mpfr_extract() { - CT_Extract "mpfr-${CT_MPFR_VERSION}" - CT_Patch "mpfr" "${CT_MPFR_VERSION}" + CT_ExtractPatch MPFR + # TBD is it a problem with 2.4.x? The comment says it is not, yet the code is run # OK, Gentoo have a sanity check that libtool.m4 and ltmain.sh have the # same version number. Unfortunately, some tarballs of MPFR are not # built sanely, and thus ./configure fails on Gentoo. @@ -115,7 +113,7 @@ do_mpfr_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure" \ + "${CT_SRC_DIR}/mpfr/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -124,12 +122,12 @@ do_mpfr_backend() { --enable-static CT_DoLog EXTRA "Building MPFR" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking MPFR" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for MPFR on the host" diff --git a/scripts/build/companion_libs/121-isl.sh b/scripts/build/companion_libs/121-isl.sh index ef93bbd..3577b75 100644 --- a/scripts/build/companion_libs/121-isl.sh +++ b/scripts/build/companion_libs/121-isl.sh @@ -13,14 +13,12 @@ if [ "${CT_ISL}" = "y" ]; then # Download ISL do_isl_get() { - CT_GetFile "isl-${CT_ISL_VERSION}" \ - http://isl.gforge.inria.fr + CT_Fetch ISL } # Extract ISL do_isl_extract() { - CT_Extract "isl-${CT_ISL_VERSION}" - CT_Patch "isl" "${CT_ISL_VERSION}" + CT_ExtractPatch ISL } # Build ISL for running on build @@ -86,21 +84,12 @@ do_isl_backend() { CT_DoLog EXTRA "Configuring ISL" - if [ "${CT_ISL_V_0_12_or_later}" != "y" ]; then - extra_config+=("--with-libgmp-prefix=${prefix}") - extra_config+=("--with-libgmpxx-prefix=${prefix}") - fi - - if [ "${CT_ISL_V_0_14_or_later}" != "y" ]; then - extra_config+=("--with-piplib=no") - fi - CT_DoExecLog CFG \ CFLAGS="${cflags}" \ CXXFLAGS="${cxxflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/isl-${CT_ISL_VERSION}/configure" \ + "${CT_SRC_DIR}/isl/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -112,12 +101,12 @@ do_isl_backend() { --with-clang=no CT_DoLog EXTRA "Building ISL" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking ISL" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for ISL on the host" diff --git a/scripts/build/companion_libs/130-cloog.sh b/scripts/build/companion_libs/130-cloog.sh index b21b028..9ee897a 100644 --- a/scripts/build/companion_libs/130-cloog.sh +++ b/scripts/build/companion_libs/130-cloog.sh @@ -13,18 +13,12 @@ if [ "${CT_CLOOG}" = "y" ]; then # Download CLooG do_cloog_get() { - CT_GetFile "cloog-${CT_CLOOG_VERSION}" \ - http://www.bastoul.net/cloog/pages/download \ - ftp://gcc.gnu.org/pub/gcc/infrastructure + CT_Fetch CLOOG } # Extract CLooG do_cloog_extract() { - CT_Extract "cloog-${CT_CLOOG_VERSION}" - CT_Patch "cloog" "${CT_CLOOG_VERSION}" - - # Help the autostuff in case it thinks there are things to regenerate... - CT_DoExecLog DEBUG mkdir -p "${CT_SRC_DIR}/cloog-${CT_CLOOG_VERSION}/m4" + CT_ExtractPatch CLOOG } # Build CLooG for running on build @@ -85,11 +79,9 @@ do_cloog_backend() { eval "${arg// /\\ }" done - if [ "${CT_CLOOG_0_18_or_later}" = y ]; then - cloog_opts+=( --with-gmp=system --with-gmp-prefix="${prefix}" ) - cloog_opts+=( --with-isl=system --with-isl-prefix="${prefix}" ) - cloog_opts+=( --without-osl ) - fi + cloog_opts+=( --with-gmp=system --with-gmp-prefix="${prefix}" ) + cloog_opts+=( --with-isl=system --with-isl-prefix="${prefix}" ) + cloog_opts+=( --without-osl ) CT_DoLog EXTRA "Configuring CLooG" @@ -98,7 +90,7 @@ do_cloog_backend() { LDFLAGS="${ldflags}" \ LIBS="-lm" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/cloog-${CT_CLOOG_VERSION}/configure" \ + "${CT_SRC_DIR}/cloog/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -109,12 +101,12 @@ do_cloog_backend() { "${cloog_opts[@]}" CT_DoLog EXTRA "Building CLooG" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking CLooG" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for CLooG on the host" diff --git a/scripts/build/companion_libs/140-mpc.sh b/scripts/build/companion_libs/140-mpc.sh index e6efb4f..2166ef1 100644 --- a/scripts/build/companion_libs/140-mpc.sh +++ b/scripts/build/companion_libs/140-mpc.sh @@ -13,15 +13,12 @@ if [ "${CT_MPC}" = "y" ]; then # Download MPC do_mpc_get() { - CT_GetFile "mpc-${CT_MPC_VERSION}" .tar.gz \ - {http,ftp,https}://ftp.gnu.org/gnu/mpc \ - http://www.multiprecision.org/mpc/download + CT_Fetch MPC } # Extract MPC do_mpc_extract() { - CT_Extract "mpc-${CT_MPC_VERSION}" - CT_Patch "mpc" "${CT_MPC_VERSION}" + CT_ExtractPatch MPC } # Build MPC for running on build @@ -87,7 +84,7 @@ do_mpc_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \ + "${CT_SRC_DIR}/mpc/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -97,12 +94,12 @@ do_mpc_backend() { --enable-static CT_DoLog EXTRA "Building MPC" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking MPC" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for MPC on the host" diff --git a/scripts/build/companion_libs/200-libelf.sh b/scripts/build/companion_libs/200-libelf.sh index 807ce7e..f0d8be4 100644 --- a/scripts/build/companion_libs/200-libelf.sh +++ b/scripts/build/companion_libs/200-libelf.sh @@ -9,15 +9,11 @@ do_libelf_for_target() { :; } if [ "${CT_LIBELF}" = "y" -o "${CT_LIBELF_TARGET}" = "y" ]; then do_libelf_get() { - # The server hosting libelf will return an "HTTP 300 : Multiple Choices" - # error code if we try to download a file that does not exists there. - # So we have to request the file with an explicit extension. - CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/ + CT_Fetch LIBELF } do_libelf_extract() { - CT_Extract "libelf-${CT_LIBELF_VERSION}" - CT_Patch "libelf" "${CT_LIBELF_VERSION}" + CT_ExtractPatch LIBELF } if [ "${CT_LIBELF}" = "y" ]; then @@ -85,6 +81,7 @@ do_libelf_for_target() { libelf_opts+=( "destdir=${CT_SYSROOT_DIR}" ) libelf_opts+=( "host=${CT_TARGET}" ) + libelf_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) libelf_opts+=( "prefix=${prefix}" ) libelf_opts+=( "shared=${CT_SHARED_LIBS}" ) do_libelf_backend "${libelf_opts[@]}" @@ -131,7 +128,7 @@ do_libelf_backend() { CFLAGS="${cflags} -fPIC" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure" \ + "${CT_SRC_DIR}/libelf/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ diff --git a/scripts/build/companion_libs/210-expat.sh b/scripts/build/companion_libs/210-expat.sh index 5aa8e31..68667f6 100755..100644 --- a/scripts/build/companion_libs/210-expat.sh +++ b/scripts/build/companion_libs/210-expat.sh @@ -9,13 +9,11 @@ do_expat_for_target() { :; } if [ "${CT_EXPAT_TARGET}" = "y" -o "${CT_EXPAT}" = "y" ]; then do_expat_get() { - CT_GetFile "expat-${CT_EXPAT_VERSION}" .tar.gz \ - http://downloads.sourceforge.net/project/expat/expat/${CT_EXPAT_VERSION} + CT_Fetch EXPAT } do_expat_extract() { - CT_Extract "expat-${CT_EXPAT_VERSION}" - CT_Patch "expat" "${CT_EXPAT_VERSION}" + CT_ExtractPatch EXPAT } if [ "${CT_EXPAT}" = "y" ]; then @@ -56,6 +54,7 @@ do_expat_for_target() { prefix="/usr" ;; esac + expat_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) expat_opts+=( "prefix=${prefix}" ) expat_opts+=( "destdir=${CT_SYSROOT_DIR}" ) expat_opts+=( "shared=${CT_SHARED_LIBS}" ) @@ -95,17 +94,18 @@ do_expat_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/expat-${CT_EXPAT_VERSION}/configure" \ + "${CT_SRC_DIR}/expat/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ --enable-static \ + --without-docbook \ "${extra_config[@]}" CT_DoLog EXTRA "Building expat" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing expat" - CT_DoExecLog ALL make install INSTALL_ROOT="${destdir}" + CT_DoExecLog ALL make install DESTDIR="${destdir}" } fi diff --git a/scripts/build/companion_libs/220-ncurses.sh b/scripts/build/companion_libs/220-ncurses.sh index 573523b..f1fcd1a 100644 --- a/scripts/build/companion_libs/220-ncurses.sh +++ b/scripts/build/companion_libs/220-ncurses.sh @@ -9,15 +9,11 @@ do_ncurses_for_target() { :; } if [ "${CT_NCURSES_TARGET}" = "y" -o "${CT_NCURSES}" = "y" ]; then do_ncurses_get() { - CT_GetFile "ncurses-${CT_NCURSES_VERSION}" .tar.gz \ - {http,ftp,https}://ftp.gnu.org/pub/gnu/ncurses \ - ftp://invisible-island.net/ncurses + CT_Fetch NCURSES } do_ncurses_extract() { - CT_Extract "ncurses-${CT_NCURSES_VERSION}" - CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}" - CT_Patch "ncurses" "${CT_NCURSES_VERSION}" + CT_ExtractPatch NCURSES } # We need tic that runs on the build when building ncurses for host/target @@ -31,26 +27,13 @@ do_ncurses_for_build() { "--without-tests" \ "--without-cxx" \ "--without-cxx-binding" \ - "--without-ada") - # If we are not canadian, this is also our host curses - # Unlike other companion libs, we skip host build if build==host - # (i.e. in simple cross or native): ncurses may not be needed for - # host, but we still need them on build to produce 'tic'. - case "${CT_TOOLCHAIN_TYPE}" in - native|cross) - if [ "${CT_NCURSES_HOST_DISABLE_DB}" = "y" ]; then - opts+=( "--disable-database" ) - fi - if [ -n "${CT_NCURSES_HOST_FALLBACKS}" ]; then - opts+=( "--with-fallbacks=${CT_NCURSES_HOST_FALLBACKS}" ) - fi - opts+=( "${CT_NCURSES_HOST_CONFIG_ARGS[@]}" ) - ;; - esac + "--without-ada" \ + "--without-fallbacks" ) do_ncurses_backend host="${CT_BUILD}" \ destdir="${CT_BUILDTOOLS_PREFIX_DIR}" \ cflags="${CT_CFLAGS_FOR_BUILD}" \ ldflags="${CT_LDFLAGS_FOR_BUILD}" \ + install_target=install.progs \ "${opts[@]}" CT_Popd CT_EndStep @@ -60,13 +43,6 @@ if [ "${CT_NCURSES}" = "y" ]; then do_ncurses_for_host() { local -a opts - # Unlike other companion libs, we skip host build if build==host - # (i.e. in simple cross or native): ncurses may not be needed for - # host, but we still need them on build to produce 'tic'. - case "${CT_TOOLCHAIN_TYPE}" in - native|cross) return 0;; - esac - CT_DoStep INFO "Installing ncurses for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-ncurses-host-${CT_HOST}" opts=("--enable-symlinks" \ @@ -76,7 +52,8 @@ do_ncurses_for_host() { "--without-cxx-binding" \ "--without-ada" ) if [ "${CT_NCURSES_HOST_DISABLE_DB}" = "y" ]; then - opts+=( "--disable-database" ) + opts+=( "--disable-database" \ + "--disable-db-install" ) fi if [ -n "${CT_NCURSES_HOST_FALLBACKS}" ]; then opts+=( "--with-fallbacks=${CT_NCURSES_HOST_FALLBACKS}" ) @@ -120,6 +97,7 @@ do_ncurses_for_target() { prefix="${prefix}" \ destdir="${CT_SYSROOT_DIR}" \ shared="${CT_SHARED_LIBS}" \ + cflags="${CT_ALL_TARGET_CFLAGS}" \ "${opts[@]}" CT_Popd CT_EndStep @@ -142,12 +120,12 @@ do_ncurses_backend() { local ldflags local shared local arg - local for_target + local install_target=install for arg in "$@"; do case "$arg" in --*) - ncurses_opts+=("$arg") + ncurses_opts+=("${arg}") ;; *) eval "${arg// /\\ }" @@ -177,7 +155,7 @@ do_ncurses_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \ + "${CT_SRC_DIR}/ncurses/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -196,9 +174,13 @@ do_ncurses_backend() { # it also builds ncurses anyway, and dedicated targets (install.includes and # install.progs) do not do well with parallel make (-jX). CT_DoLog EXTRA "Building ncurses" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + # STRIPPROG is handled by our wrapper around install. CT_DoLog EXTRA "Installing ncurses" - CT_DoExecLog ALL make install + CT_DoExecLog ALL \ + STRIPPROG="${host}-strip" \ + make "${install_target}" } fi diff --git a/scripts/build/companion_libs/320-libiconv.sh b/scripts/build/companion_libs/320-libiconv.sh index f2f0bef..9748ba2 100644 --- a/scripts/build/companion_libs/320-libiconv.sh +++ b/scripts/build/companion_libs/320-libiconv.sh @@ -9,13 +9,11 @@ do_libiconv_for_target() { :; } if [ "${CT_LIBICONV}" = "y" ]; then do_libiconv_get() { - CT_GetFile "libiconv-${CT_LIBICONV_VERSION}" \ - http://ftp.gnu.org/pub/gnu/libiconv/ + CT_Fetch LIBICONV } do_libiconv_extract() { - CT_Extract "libiconv-${CT_LIBICONV_VERSION}" - CT_Patch "libiconv" "${CT_LIBICONV_VERSION}" + CT_ExtractPatch LIBICONV } # Build libiconv for running on build @@ -93,7 +91,7 @@ do_libiconv_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/libiconv-${CT_LIBICONV_VERSION}/configure" \ + "${CT_SRC_DIR}/libiconv/configure" \ --build=${CT_BUILD} \ --host="${host}" \ --prefix="${prefix}" \ @@ -102,7 +100,7 @@ do_libiconv_backend() { "${extra_config[@]}" \ CT_DoLog EXTRA "Building libiconv" - CT_DoExecLog ALL make CC="${host}-gcc ${cflags}" ${JOBSFLAGS} + CT_DoExecLog ALL make CC="${host}-gcc ${cflags}" ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing libiconv" CT_DoExecLog ALL make install CC="${host}-gcc ${cflags}" diff --git a/scripts/build/companion_libs/330-gettext.sh b/scripts/build/companion_libs/330-gettext.sh index 8828e5d..9fa3bdc 100644 --- a/scripts/build/companion_libs/330-gettext.sh +++ b/scripts/build/companion_libs/330-gettext.sh @@ -9,13 +9,11 @@ do_gettext_for_target() { :; } if [ "${CT_GETTEXT}" = "y" ]; then do_gettext_get() { - CT_GetFile "gettext-${CT_GETTEXT_VERSION}" \ - http://ftp.gnu.org/pub/gnu/gettext/ + CT_Fetch GETTEXT } do_gettext_extract() { - CT_Extract "gettext-${CT_GETTEXT_VERSION}" - CT_Patch "gettext" "${CT_GETTEXT_VERSION}" + CT_ExtractPatch GETTEXT } # Build gettext for running on build @@ -82,6 +80,28 @@ do_gettext_backend() { return ;; + # Starting with 0.21, gettext cannot build against uClibc-NG: gettext + # checks if it needs to use fopen wrapper (using gnulib) and newer versions + # of gnulib also check if fopen provided by the system supports 'e' and 'x' + # modes. In cross-compile environment, gnulib falls back to assuming fopen + # does not support these modes unless the target tuple is glibc or musl + # (rightly so, since these fopen modes are optional in uClibc-NG). + # Unfortunately, the fopen() wrapper does not compile against uClibc-NG's + # stdio.h then because it includes <stdio.h> after defining __need_FILE macro. + # It looks like two bugs, one in each of uClibc-ng and gnulib: + # - uClibc-ng does not include its internal headers with the definitions for the + # __BEGIN_NAMESPACE_STD/__END_NAMESPACE_STD macros, which therefore escape + # unsubstituted into the including code. + # - gnulib shouldn't expect the fopen() prototype if it only asked for FILE + # structure definition by defining the __need_FILE macro. + # Until the maintainers sort this out, disallow newer gettext versions if + # linking against uClibc-NG. + *-uclibc*) + if [ "${CT_GETTEXT_INCOMPATIBLE_WITH_UCLIBC_NG}" = "y" ]; then + CT_Abort "This version of gettext is incompatible with uClibc-NG" + fi + ;; + # A bit ugly. D__USE_MINGW_ANSI_STDIO=1 has its own {v}asprintf functions # but gettext configure doesn't see this flag when it checks for that. An # alternative may be to use CC="${host}-gcc ${cflags}" but that didn't @@ -112,7 +132,7 @@ do_gettext_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gettext-${CT_GETTEXT_VERSION}/configure" \ + "${CT_SRC_DIR}/gettext/configure" \ --build=${CT_BUILD} \ --host="${host}" \ --prefix="${prefix}" \ @@ -133,7 +153,7 @@ do_gettext_backend() { "${extra_config[@]}" CT_DoLog EXTRA "Building gettext" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing gettext" CT_DoExecLog ALL make install diff --git a/scripts/build/companion_libs/340-picolibc.sh b/scripts/build/companion_libs/340-picolibc.sh new file mode 100644 index 0000000..e879005 --- /dev/null +++ b/scripts/build/companion_libs/340-picolibc.sh @@ -0,0 +1,171 @@ +# This file adds functions to build the Picolibc library +# Copyright © 2020 Keith Packard +# Licensed under the GPL v2 or later. See COPYING in the root of this package +# +# Edited by Keith Packard <keithp@keithp.com> +# + +do_picolibc_get() { :; } +do_picolibc_extract() { :; } +do_picolibc_for_build() { :; } +do_picolibc_for_host() { :; } +do_picolibc_for_target() { :; } + +if [ "${CT_COMP_LIBS_PICOLIBC}" = "y" ]; then + +# Download picolibc +do_picolibc_get() { + CT_Fetch PICOLIBC +} + +do_picolibc_extract() { + CT_ExtractPatch PICOLIBC +} + +#------------------------------------------------------------------------------ +# Build an additional target libstdc++ with "-Os" (optimise for speed) option +# flag for libstdc++ "picolibc" variant. +do_cc_libstdcxx_picolibc() +{ + local -a final_opts + local final_backend + + if [ "${CT_LIBC_PICOLIBC_GCC_LIBSTDCXX}" = "y" ]; then + final_opts+=( "host=${CT_HOST}" ) + final_opts+=( "libstdcxx_name=picolibc" ) + final_opts+=( "prefix=${CT_PREFIX_DIR}" ) + final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" ) + final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) + final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) + final_opts+=( "lang_list=c,c++" ) + final_opts+=( "build_step=libstdcxx" ) + final_opts+=( "extra_config+=('--enable-stdio=stdio_pure')" ) + final_opts+=( "extra_config+=('--disable-wchar_t')" ) + if [ "${CT_LIBC_PICOLIBC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + final_opts+=( "enable_optspace=yes" ) + fi + + if [ "${CT_BARE_METAL}" = "y" ]; then + final_opts+=( "mode=baremetal" ) + final_opts+=( "build_libgcc=yes" ) + final_opts+=( "build_libstdcxx=yes" ) + final_opts+=( "build_libgfortran=yes" ) + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then + final_opts+=( "build_staticlinked=yes" ) + fi + final_backend=do_gcc_core_backend + else + final_backend=do_gcc_backend + fi + + CT_DoStep INFO "Installing libstdc++ picolibc" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-libstdcxx-picolibc" + "${final_backend}" "${final_opts[@]}" + CT_Popd + + CT_EndStep + fi +} + +do_picolibc_for_target() { + local -a picolibc_opts + local cflags_for_target + + CT_DoStep INFO "Installing Picolibc library" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-picolibc-build-${CT_BUILD}" + + CT_DoLog EXTRA "Configuring Picolibc library" + + # Multilib is the default, so if it is not enabled, disable it. + if [ "${CT_MULTILIB}" != "y" ]; then + picolibc_opts+=("-Dmultilib=false") + fi + + yn_args="IO_C99FMT:io-c99-formats +IO_LL:io-long-long +REGISTER_FINI:newlib-register-fini +NANO_MALLOC:newlib-nano-malloc +ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc +GLOBAL_ATEXIT:newlib-global-atexit +LITE_EXIT:lite-exit +MULTITHREAD:newlib-multithread +RETARGETABLE_LOCKING:newlib-retargetable-locking + " + + for ynarg in $yn_args; do + var="CT_LIBC_PICOLIBC_${ynarg%:*}" + eval var=\$${var} + argument=${ynarg#*:} + + + if [ "${var}" = "y" ]; then + picolibc_opts+=( "-D$argument=true" ) + else + picolibc_opts+=( "-D$argument=false" ) + fi + done + + [ "${CT_USE_SYSROOT}" = "y" ] && \ + picolibc_opts+=( "-Dsysroot-install=true" ) + + [ "${CT_LIBC_PICOLIBC_EXTRA_SECTIONS}" = "y" ] && \ + CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -ffunction-sections -fdata-sections" + + [ "${CT_LIBC_PICOLIBC_LTO}" = "y" ] && \ + CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -flto" + + cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_PICOLIBC_TARGET_CFLAGS}" + + # Note: picolibc handles the build/host/target a little bit differently + # than one would expect: + # build : not used + # host : the machine building picolibc + # target : the machine picolibc runs on + meson_cflags="" + for cflag in ${cflags_for_target}; do + meson_cflags="${meson_cflags} '${cflag}'," + done + cat << EOF > picolibc-cross.txt +[binaries] +c = '${CT_TARGET}-gcc' +ar = '${CT_TARGET}-ar' +as = '${CT_TARGET}-as' +strip = '${CT_TARGET}-strip' + +[host_machine] +system = '${CT_TARGET_VENDOR}' +cpu_family = '${CT_TARGET_ARCH}' +cpu = '${CT_TARGET_ARCH}' +endian = '${CT_ARCH_ENDIAN}' + +[properties] +c_args = [ ${meson_cflags} '-nostdlib', '-fno-common', '-ftls-model=local-exec' ] +needs_exe_wrapper = true +skip_sanity_check = true +EOF + + CT_DoExecLog CFG \ + meson \ + --cross-file picolibc-cross.txt \ + --prefix="${CT_PREFIX_DIR}" \ + -Dincludedir=picolibc/include \ + -Dlibdir=picolibc/${CT_TARGET}/lib \ + -Dspecsdir="${CT_SYSROOT_DIR}"/lib \ + "${CT_SRC_DIR}/picolibc" \ + "${picolibc_opts[@]}" \ + "${CT_LIBC_PICOLIBC_EXTRA_CONFIG_ARRAY[@]}" + + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL ninja + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL ninja install + + CT_Popd + CT_EndStep + + do_cc_libstdcxx_picolibc +} + +fi diff --git a/scripts/build/companion_libs/350-newlib_nano.sh b/scripts/build/companion_libs/350-newlib_nano.sh new file mode 100644 index 0000000..ad6ea9a --- /dev/null +++ b/scripts/build/companion_libs/350-newlib_nano.sh @@ -0,0 +1,276 @@ +# This file adds functions to build the Newlib library using the 'nano' configuration +# Copyright © 2021 Keith Packard +# Licensed under the GPL v2 or later. See COPYING in the root of this package +# +# Edited by Keith Packard <keithp@keithp.com> +# + +do_newlib_nano_get() { :; } +do_newlib_nano_extract() { :; } +do_newlib_nano_for_build() { :; } +do_newlib_nano_for_host() { :; } +do_newlib_nano_for_target() { :; } + +if [ "${CT_COMP_LIBS_NEWLIB_NANO}" = "y" ]; then + +# Download newlib_nano +do_newlib_nano_get() { + CT_Fetch NEWLIB_NANO +} + +do_newlib_nano_extract() { + CT_ExtractPatch NEWLIB_NANO +} + +# Some architectures assume "nano" libs co-exist with normal ones +# in the same folder, though being suffixed with "_nano". +do_nano_libc_symlinks() { + CT_Pushd "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib/${multi_dir}" + + CT_DoLog DEBUG "Installing nano libc symlinks in $PWD" + + ln -s libc.a libc_nano.a + ln -s libm.a libm_nano.a + ln -s libg.a libg_nano.a + + CT_Popd +} + +do_nano_libstdcxx_symlinks() { + CT_Pushd "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib/${multi_dir}" + + CT_DoLog DEBUG "Installing nano libstdc++ symlinks in $PWD" + + ln -s libstdc++.a libstdc++_nano.a + ln -s libsupc++.a libsupc++_nano.a + + CT_Popd +} + +#------------------------------------------------------------------------------ +# Build an additional target libstdc++ with "-Os" (optimise for speed) option +# flag for libstdc++ "newlib_nano" variant. +do_cc_libstdcxx_newlib_nano() +{ + local -a final_opts + local final_backend + + if [ "${CT_NEWLIB_NANO_GCC_LIBSTDCXX}" = "y" ]; then + final_opts+=( "host=${CT_HOST}" ) + final_opts+=( "libstdcxx_name=newlib-nano" ) + final_opts+=( "prefix=${CT_PREFIX_DIR}" ) + final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" ) + final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) + final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) + final_opts+=( "lang_list=c,c++" ) + final_opts+=( "build_step=libstdcxx" ) + if [ "${CT_LIBC_NEWLIB_NANO_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + final_opts+=( "enable_optspace=yes" ) + fi + if [ -n "${CT_NEWLIB_NANO_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ]; then + final_opts+=( "extra_cxxflags_for_target=${CT_NEWLIB_NANO_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ) + fi + + if [ "${CT_BARE_METAL}" = "y" ]; then + final_opts+=( "mode=baremetal" ) + final_opts+=( "build_libgcc=yes" ) + final_opts+=( "build_libstdcxx=yes" ) + final_opts+=( "build_libgfortran=yes" ) + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then + final_opts+=( "build_staticlinked=yes" ) + fi + final_backend=do_gcc_core_backend + else + final_backend=do_gcc_backend + fi + + CT_DoStep INFO "Installing libstdc++ newlib-nano" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-libstdcxx-newlib-nano" + "${final_backend}" "${final_opts[@]}" + + # Create "nano" symlinks for libstdc++.a & libsup++.a + CT_IterateMultilibs do_nano_libstdcxx_symlinks libstdcxx_symlinks + + CT_Popd + + CT_EndStep + fi +} + +do_newlib_nano_for_target() { + local -a newlib_nano_opts + local cflags_for_target + + CT_DoStep INFO "Installing Newlib Nano library" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-newlib_nano-build-${CT_BUILD}" + + CT_DoLog EXTRA "Configuring Newlib Nano library" + + # Multilib is the default, so if it is not enabled, disable it. + if [ "${CT_MULTILIB}" != "y" ]; then + newlib_nano_opts+=("-Dmultilib=false") + fi + + if [ "${CT_LIBC_NEWLIB_NANO_IO_FLOAT}" = "y" ]; then + newlib_opts+=( "--enable-newlib-io-float" ) + if [ "${CT_LIBC_NEWLIB_NANO_IO_LDBL}" = "y" ]; then + newlib_opts+=( "--enable-newlib-io-long-double" ) + else + newlib_opts+=( "--disable-newlib-io-long-double" ) + fi + else + newlib_opts+=( "--disable-newlib-io-float" ) + newlib_opts+=( "--disable-newlib-io-long-double" ) + fi + + if [ "${CT_LIBC_NEWLIB_NANO_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then + newlib_opts+=( "--disable-newlib-supplied-syscalls" ) + else + newlib_opts+=( "--enable-newlib-supplied-syscalls" ) + fi + + yn_args="IO_POS_ARGS:newlib-io-pos-args +IO_C99FMT:newlib-io-c99-formats +IO_LL:newlib-io-long-long +REGISTER_FINI:newlib-register-fini +NANO_MALLOC:newlib-nano-malloc +NANO_FORMATTED_IO:newlib-nano-formatted-io +ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc +GLOBAL_ATEXIT:newlib-global-atexit +LITE_EXIT:lite-exit +REENT_SMALL:newlib-reent-small +MULTITHREAD:newlib-multithread +RETARGETABLE_LOCKING:newlib-retargetable-locking +WIDE_ORIENT:newlib-wide-orient +FSEEK_OPTIMIZATION:newlib-fseek-optimization +FVWRITE_IN_STREAMIO:newlib-fvwrite-in-streamio +UNBUF_STREAM_OPT:newlib-unbuf-stream-opt +ENABLE_TARGET_OPTSPACE:target-optspace + " + + for ynarg in $yn_args; do + var="CT_LIBC_NEWLIB_NANO_${ynarg%:*}" + eval var=\$${var} + argument=${ynarg#*:} + + + if [ "${var}" = "y" ]; then + newlib_opts+=( "--enable-$argument" ) + else + newlib_opts+=( "--disable-$argument" ) + fi + done + + [ "${CT_LIBC_NEWLIB_NANO_EXTRA_SECTIONS}" = "y" ] && \ + CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS="${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS} -ffunction-sections -fdata-sections" + + [ "${CT_LIBC_NEWLIB_NANO_LTO}" = "y" ] && \ + CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS="${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS} -flto" + + cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS}" + + # Note: newlib handles the build/host/target a little bit differently + # than one would expect: + # build : not used + # host : the machine building newlib + # target : the machine newlib runs on + CT_DoExecLog CFG \ + CC_FOR_BUILD="${CT_BUILD}-gcc" \ + CFLAGS_FOR_TARGET="${cflags_for_target}" \ + AR_FOR_TARGET="`which ${CT_TARGET}-gcc-ar`" \ + RANLIB_FOR_TARGET="`which ${CT_TARGET}-gcc-ranlib`" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/newlib-nano/configure" \ + --host=${CT_BUILD} \ + --target=${CT_TARGET} \ + --prefix=${CT_PREFIX_DIR} \ + --exec-prefix=${CT_PREFIX_DIR}/newlib-nano \ + --libdir=${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib \ + "${newlib_opts[@]}" \ + "${CT_LIBC_NEWLIB_NANO_EXTRA_CONFIG_ARRAY[@]}" + + CT_DoLog EXTRA "Building Newlib Nano C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + CT_DoLog EXTRA "Installing Newlib Nano C library" + CT_DoExecLog ALL make install + + if [ "${CT_NEWLIB_NANO_INSTALL_IN_TARGET}" = "y" ]; then + cat > "${CT_SYSROOT_DIR}/lib/nano.specs" <<EOF +%rename link nano_link +%rename link_gcc_c_sequence nano_link_gcc_c_sequence +%rename cpp_unique_options nano_cpp_unique_options + +*cpp_unique_options: +-isystem =/include/newlib-nano %(nano_cpp_unique_options) + +*nano_libc: +-lc_nano + +*nano_libgloss: +%{specs=rdimon.specs:-lrdimon_nano} %{specs=nosys.specs:-lnosys} + +*link_gcc_c_sequence: +%(nano_link_gcc_c_sequence) --start-group %G %(nano_libc) %(nano_libgloss) --end-group + +*link: +%(nano_link) %:replace-outfile(-lc -lc_nano) %:replace-outfile(-lg -lg_nano) %:replace-outfile(-lm -lm_nano) %:replace-outfile(-lstdc++ -lstdc++_nano) %:replace-outfile(-lsupc++ -lsupc++_nano) %:replace-outfile(-lrdimon -lrdimon_nano) + +*lib: +%{!shared:%{g*:-lg_nano} %{!p:%{!pg:-lc_nano}}%{p:-lc_p}%{pg:-lc_p}} + +EOF + else + cat > "${CT_SYSROOT_DIR}/lib/nano.specs" <<EOF +%rename link newlib_nano_link +%rename cpp newlib_nano_cpp +%rename cc1plus newlib_nano_cc1plus + +*cpp: +-isystem %:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/include) %(newlib_nano_cpp) + +*cc1plus: +-idirafter %:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/include) %(newlib_nano_cc1plus) + +*link: +-L%:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/lib/%M) -L%:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/lib) + +EOF + fi + + # Create "nano" symlinks for libc.a, libg.a & libm.a + CT_IterateMultilibs do_nano_libc_symlinks libc_symlinks + + CT_Popd + CT_EndStep + + do_cc_libstdcxx_newlib_nano + + if [ "${CT_NEWLIB_NANO_INSTALL_IN_TARGET}" = "y" ]; then + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano" + CT_DoExecLog ALL cp -f "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/include/newlib.h" \ + "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano/newlib.h" + CT_IterateMultilibs newlib_nano_copy_multilibs copylibs + fi +} + +newlib_nano_copy_multilibs() +{ + local nano_lib_dir="${CT_PREFIX_DIR}/newlib-nano" + local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + for lib_a in "${nano_lib_dir}/${CT_TARGET}/lib/${multi_dir}/"*.a; do + if [ -f ${lib_a} ] && [ ! -L ${lib_a} ]; then + _f=$(basename "${lib_a}") + CT_DoExecLog ALL cp -f "${lib_a}" \ + "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/${_f%.*}_nano.a" + fi + done +} + +fi diff --git a/scripts/build/companion_libs/400-gnuprumcu.sh b/scripts/build/companion_libs/400-gnuprumcu.sh new file mode 100644 index 0000000..bba8574 --- /dev/null +++ b/scripts/build/companion_libs/400-gnuprumcu.sh @@ -0,0 +1,88 @@ +# Build script for gnuprumcu + +do_gnuprumcu_get() { :; } +do_gnuprumcu_extract() { :; } +do_gnuprumcu_for_build() { :; } +do_gnuprumcu_for_host() { :; } +do_gnuprumcu_for_target() { :; } + +if [ "${CT_COMP_LIBS_GNUPRUMCU}" = "y" ]; then + +do_gnuprumcu_get() { + CT_Fetch GNUPRUMCU +} + +do_gnuprumcu_extract() { + CT_ExtractPatch GNUPRUMCU +} + + +do_gnuprumcu_for_target() { + local -a gnuprumcu_opts + + CT_DoStep INFO "Installing gnuprumcu for the target" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gnuprumcu-target-${CT_TARGET}" + + gnuprumcu_opts+=( "destdir=${CT_SYSROOT_DIR}" ) + gnuprumcu_opts+=( "host=${CT_TARGET}" ) + + gnuprumcu_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) + gnuprumcu_opts+=( "prefix=${CT_PREFIX_DIR}" ) + do_gnuprumcu_backend "${gnuprumcu_opts[@]}" + + CT_Popd + CT_EndStep +} + + +# Build gnuprumcu +# Parameter : description : type : default +# destdir : out-of-tree install dir : string : / +# host : machine to run on : tuple : (none) +# prefix : prefix to install into : dir : (none) +# cflags : cflags to use : string : (empty) +# ldflags : ldflags to use : string : (empty) +# shared : also buils shared lib : bool : n +do_gnuprumcu_backend() { + local destdir="/" + local host + local prefix + local cflags + local ldflags + local shared + local -a extra_config + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Configuring gnuprumcu" + + CT_DoExecLog CFG \ + CC="${CT_TARGET}-${CT_CC}" \ + RANLIB="${CT_TARGET}-ranlib" \ + CFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/gnuprumcu/configure" \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --prefix="${prefix}" \ + "${extra_config[@]}" + + CT_DoLog EXTRA "Building gnuprumcu" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing gnuprumcu" + + # Guard against $destdir$prefix == // + # which is a UNC path on Cygwin/MSYS2 + if [[ ${destdir} == / ]] && [[ ${prefix} == /* ]]; then + destdir= + fi + + CT_DoExecLog ALL make instroot="${destdir}" install +} + +fi # CT_COMP_LIBS_GNUPRUMCU |