2007-02-24 11:00:05 +00:00
|
|
|
# This file declares functions to install the uClibc C library
|
|
|
|
# Copyright 2007 Yann E. MORIN
|
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
|
2010-07-27 23:38:15 +00:00
|
|
|
# This is a constant because it does not change very often.
|
|
|
|
# We're in 2010, and are still using data from 7 years ago.
|
|
|
|
uclibc_locales_version=030818
|
2016-04-02 01:24:27 +00:00
|
|
|
uclibc_locale_tarball="uClibc-locale-${uclibc_locales_version}"
|
2010-07-27 23:38:15 +00:00
|
|
|
|
2015-11-10 22:41:33 +00:00
|
|
|
if [ "${CT_LIBC_UCLIBC_NG}" = "y" ]; then
|
|
|
|
uclibc_name="uClibc-ng"
|
|
|
|
libc_src="http://downloads.uclibc-ng.org/releases/${CT_LIBC_VERSION}"
|
|
|
|
else
|
|
|
|
uclibc_name="uClibc"
|
2008-05-03 17:51:16 +00:00
|
|
|
libc_src="http://www.uclibc.org/downloads
|
2007-05-07 09:04:02 +00:00
|
|
|
http://www.uclibc.org/downloads/old-releases"
|
2015-11-10 22:41:33 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Download uClibc
|
|
|
|
do_libc_get() {
|
2012-10-11 04:39:44 +00:00
|
|
|
if [ "${CT_LIBC_UCLIBC_CUSTOM}" = "y" ]; then
|
2015-11-26 13:06:21 +00:00
|
|
|
CT_GetCustom "${uclibc_name}" "${CT_LIBC_UCLIBC_CUSTOM_VERSION}" \
|
|
|
|
"${CT_LIBC_UCLIBC_CUSTOM_LOCATION}"
|
2012-10-11 04:39:44 +00:00
|
|
|
else
|
2015-11-10 22:41:33 +00:00
|
|
|
CT_GetFile "${uclibc_name}-${CT_LIBC_VERSION}" ${libc_src}
|
2012-10-11 04:39:44 +00:00
|
|
|
fi
|
2007-05-07 09:04:02 +00:00
|
|
|
# uClibc locales
|
2010-07-27 23:03:07 +00:00
|
|
|
if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" ]; then
|
2016-04-02 01:24:27 +00:00
|
|
|
CT_GetFile "${uclibc_locale_tarball}" ${libc_src}
|
2009-01-05 23:02:43 +00:00
|
|
|
fi
|
2007-05-07 15:57:02 +00:00
|
|
|
|
|
|
|
return 0
|
2007-05-07 09:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Extract uClibc
|
|
|
|
do_libc_extract() {
|
2015-11-26 13:06:21 +00:00
|
|
|
CT_Extract "${uclibc_name}-${CT_LIBC_VERSION}"
|
|
|
|
CT_Patch "${uclibc_name}" "${CT_LIBC_VERSION}"
|
2009-01-05 23:02:43 +00:00
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# uClibc locales
|
2010-07-27 23:03:07 +00:00
|
|
|
# Extracting pregen locales ourselves is kinda
|
|
|
|
# broken, so just link it in place...
|
|
|
|
if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" \
|
2016-04-02 01:24:27 +00:00
|
|
|
-a ! -f "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted" ]; then
|
2015-11-10 22:41:33 +00:00
|
|
|
CT_Pushd "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}/extra/locale"
|
2016-04-02 01:24:27 +00:00
|
|
|
CT_DoExecLog ALL ln -s "${CT_TARBALLS_DIR}/${uclibc_locale_tarball}.tgz" .
|
2009-01-04 22:17:53 +00:00
|
|
|
CT_Popd
|
2016-04-02 01:24:27 +00:00
|
|
|
touch "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted"
|
2009-01-04 22:17:53 +00:00
|
|
|
fi
|
2007-05-07 15:57:02 +00:00
|
|
|
|
|
|
|
return 0
|
2007-05-07 09:04:02 +00:00
|
|
|
}
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2011-01-22 21:32:25 +00:00
|
|
|
# Build and install headers and start files
|
|
|
|
do_libc_start_files() {
|
2016-04-02 06:28:43 +00:00
|
|
|
# Start files and Headers should be configured the same way as the
|
|
|
|
# final libc, but built and installed differently.
|
|
|
|
do_libc_backend libc_mode=startfiles
|
2007-02-24 11:00:05 +00:00
|
|
|
}
|
|
|
|
|
2016-04-02 06:28:43 +00:00
|
|
|
# This function builds and install the full C library
|
2007-02-24 11:00:05 +00:00
|
|
|
do_libc() {
|
2016-04-02 06:28:43 +00:00
|
|
|
do_libc_backend libc_mode=final
|
|
|
|
}
|
|
|
|
|
2016-04-05 21:47:20 +00:00
|
|
|
# Common backend for 1st and 2nd passes.
|
2016-04-02 06:28:43 +00:00
|
|
|
do_libc_backend() {
|
|
|
|
local libc_mode
|
2016-04-11 20:59:16 +00:00
|
|
|
local arg
|
2016-03-21 18:18:53 +00:00
|
|
|
|
2016-04-02 06:28:43 +00:00
|
|
|
for arg in "$@"; do
|
|
|
|
eval "${arg// /\\ }"
|
|
|
|
done
|
|
|
|
|
|
|
|
case "${libc_mode}" in
|
|
|
|
startfiles) CT_DoStep INFO "Installing C library headers & start files";;
|
|
|
|
final) CT_DoStep INFO "Installing C library";;
|
|
|
|
*) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";;
|
|
|
|
esac
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2016-04-12 06:11:22 +00:00
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
|
2016-04-11 20:59:16 +00:00
|
|
|
CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}"
|
2016-04-05 21:47:20 +00:00
|
|
|
|
|
|
|
|
2016-04-12 06:11:22 +00:00
|
|
|
CT_Popd
|
2016-04-05 21:47:20 +00:00
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
|
|
|
# Common backend for 1st and 2nd passes, once per multilib.
|
|
|
|
do_libc_backend_once() {
|
|
|
|
local libc_mode
|
2016-04-11 20:59:16 +00:00
|
|
|
local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
|
|
|
|
local multilib_dir startfiles_dir
|
2016-04-05 21:47:20 +00:00
|
|
|
local jflag=${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}}
|
|
|
|
local -a make_args
|
|
|
|
local extra_cflags f cfg_cflags cf
|
|
|
|
local hdr_install_subdir
|
|
|
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
eval "${arg// /\\ }"
|
|
|
|
done
|
|
|
|
|
2016-04-11 20:59:16 +00:00
|
|
|
CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'"
|
|
|
|
|
2010-01-02 17:00:54 +00:00
|
|
|
# Simply copy files until uClibc has the ability to build out-of-tree
|
2007-02-24 11:00:05 +00:00
|
|
|
CT_DoLog EXTRA "Copying sources to build dir"
|
2016-12-02 22:50:58 +00:00
|
|
|
CT_DoExecLog ALL cp -aT "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}/." .
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2016-04-02 06:28:43 +00:00
|
|
|
multilib_dir="lib/${multi_os_dir}"
|
|
|
|
startfiles_dir="${multi_root}/usr/${multilib_dir}"
|
|
|
|
CT_SanitizeVarDir multilib_dir startfiles_dir
|
|
|
|
|
|
|
|
# Construct make arguments:
|
|
|
|
# - uClibc uses the CROSS environment variable as a prefix to the compiler
|
|
|
|
# tools to use. Since it requires core pass-1, thusly named compiler is
|
|
|
|
# already available.
|
|
|
|
# - Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
|
|
|
|
# depending on the configuration of the library. That is, they are tailored
|
|
|
|
# to best fit the target. So it is useless and seems to be a bad thing to
|
|
|
|
# use LIBC_EXTRA_CFLAGS here.
|
|
|
|
# - We do _not_ want to strip anything for now, in case we specifically
|
|
|
|
# asked for a debug toolchain, thus the STRIPTOOL= assignment.
|
|
|
|
make_args=( CROSS_COMPILE="${CT_TARGET}-" \
|
|
|
|
PREFIX="${multi_root}/" \
|
|
|
|
MULTILIB_DIR="${multilib_dir}" \
|
|
|
|
LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \
|
|
|
|
STRIPTOOL=true \
|
|
|
|
${CT_LIBC_UCLIBC_VERBOSITY} \
|
|
|
|
)
|
2016-03-21 18:18:53 +00:00
|
|
|
|
2016-04-02 06:28:43 +00:00
|
|
|
# Force the date of the pregen locale data, as the
|
|
|
|
# newer ones that are referenced are not available
|
2007-02-24 11:00:05 +00:00
|
|
|
CT_DoLog EXTRA "Applying configuration"
|
2016-04-02 07:12:41 +00:00
|
|
|
|
|
|
|
# Use the default config if the user did not provide one.
|
|
|
|
if [ -z "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
|
|
|
|
CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/contrib/uClibc-defconfigs/${uclibc_name}.config"
|
|
|
|
fi
|
|
|
|
|
2016-04-05 21:47:20 +00:00
|
|
|
manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config "${multi_flags}"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoYes | CT_DoExecLog ALL make "${make_args[@]}" oldconfig
|
2016-04-02 06:28:43 +00:00
|
|
|
|
2016-04-05 21:47:20 +00:00
|
|
|
# Now filter the multilib flags. manage_uClibc_config did the opposite of
|
|
|
|
# what Rules.mak in uClibc would do: by the multilib's CFLAGS, it determined
|
|
|
|
# the applicable configuration options. We don't want to pass the same options
|
|
|
|
# in the UCLIBC_EXTRA_CFLAGS again (on some targets, the options do not correctly
|
|
|
|
# override each other). On the other hand, we do not want to lose the options
|
|
|
|
# that are not reflected in the .config.
|
|
|
|
extra_cflags="-pipe"
|
|
|
|
{ echo "include Rules.mak"; echo "show-cpu-flags:"; printf '\t@echo $(CPU_CFLAGS)\n'; } \
|
|
|
|
> .show-cpu-cflags.mk
|
2016-11-21 07:50:17 +00:00
|
|
|
cfg_cflags=$( make "${make_args[@]}" \
|
2016-04-05 21:47:20 +00:00
|
|
|
--no-print-directory -f .show-cpu-cflags.mk show-cpu-flags )
|
|
|
|
CT_DoExecLog ALL rm -f .show-cpu-cflags.mk
|
|
|
|
CT_DoLog DEBUG "CPU_CFLAGS detected by uClibc: ${cfg_cflags[@]}"
|
|
|
|
for f in ${multi_flags}; do
|
|
|
|
for cf in ${cfg_cflags}; do
|
|
|
|
if [ "${f}" = "${cf}" ]; then
|
|
|
|
f=
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "${f}" ]; then
|
|
|
|
extra_cflags+=" ${f}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
CT_DoLog DEBUG "Filtered multilib CFLAGS: ${extra_cflags}"
|
|
|
|
make_args+=( UCLIBC_EXTRA_CFLAGS="${extra_cflags}" )
|
|
|
|
|
|
|
|
# uClibc does not have a way to select the installation subdirectory for headers,
|
|
|
|
# it is always $(DEVEL_PREFIX)/include. Also, we're reinstalling the headers
|
|
|
|
# at the final stage (see the note below), we may already have the subdirectory
|
|
|
|
# in /usr/include.
|
|
|
|
CT_DoArchUClibcHeaderDir hdr_install_subdir "${multi_flags}"
|
2016-04-14 07:30:34 +00:00
|
|
|
if [ -n "${hdr_install_subdir}" ]; then
|
2016-04-05 21:47:20 +00:00
|
|
|
CT_DoExecLog ALL cp -a "${multi_root}/usr/include" "${multi_root}/usr/include.saved"
|
|
|
|
fi
|
|
|
|
|
2016-04-02 06:28:43 +00:00
|
|
|
if [ "${libc_mode}" = "startfiles" ]; then
|
|
|
|
CT_DoLog EXTRA "Building headers"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make "${make_args[@]}" headers
|
2016-04-02 06:28:43 +00:00
|
|
|
|
|
|
|
# Ensure the directory for installing multilib-specific binaries exists.
|
|
|
|
CT_DoExecLog ALL mkdir -p "${startfiles_dir}"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing headers"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make "${make_args[@]}" install_headers
|
2016-04-02 06:28:43 +00:00
|
|
|
|
|
|
|
# The check might look bogus, but it is the same condition as is used
|
|
|
|
# by GCC build script to enable/disable shared library support.
|
|
|
|
if [ "${CT_THREADS}" = "nptl" ]; then
|
|
|
|
CT_DoLog EXTRA "Building start files"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make ${jflag} "${make_args[@]}" \
|
2016-04-02 06:28:43 +00:00
|
|
|
lib/crt1.o lib/crti.o lib/crtn.o
|
|
|
|
|
|
|
|
# From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b
|
|
|
|
# libm.so is needed for ppc, as libgcc is linked against libm.so
|
|
|
|
# No problem to create it for other archs.
|
|
|
|
CT_DoLog EXTRA "Building dummy shared libs"
|
2017-01-14 05:24:16 +00:00
|
|
|
CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -nostdlib -nostartfiles \
|
2016-04-05 21:47:20 +00:00
|
|
|
-shared ${multi_flags} -x c /dev/null -o libdummy.so
|
2016-04-02 06:28:43 +00:00
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing start files"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL install -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \
|
2016-04-02 06:28:43 +00:00
|
|
|
"${startfiles_dir}"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing dummy shared libs"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL install -m 0755 libdummy.so "${startfiles_dir}/libc.so"
|
|
|
|
CT_DoExecLog ALL install -m 0755 libdummy.so "${startfiles_dir}/libm.so"
|
2016-04-02 06:28:43 +00:00
|
|
|
fi # CT_THREADS == nptl
|
|
|
|
fi # libc_mode == startfiles
|
|
|
|
|
|
|
|
if [ "${libc_mode}" = "final" ]; then
|
|
|
|
CT_DoLog EXTRA "Cleaning up startfiles"
|
|
|
|
CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \
|
|
|
|
"${startfiles_dir}/crti.o" \
|
|
|
|
"${startfiles_dir}/crtn.o" \
|
|
|
|
"${startfiles_dir}/libc.so" \
|
|
|
|
"${startfiles_dir}/libm.so"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Building C library"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make "${make_args[@]}" pregen
|
|
|
|
CT_DoExecLog ALL make ${jflag} "${make_args[@]}" all
|
2016-04-02 06:28:43 +00:00
|
|
|
|
|
|
|
# YEM-FIXME:
|
|
|
|
# - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and
|
|
|
|
# such files, except the headers as they already are installed
|
|
|
|
# - "make install_dev" installs the headers, the crti.o... and the
|
|
|
|
# static libs, but not the dynamic libs
|
|
|
|
# - "make install_runtime" installs the dynamic libs only
|
|
|
|
# - "make install" calls install_runtime and install_dev
|
|
|
|
# - so we're left with re-installing the headers... Sigh...
|
|
|
|
CT_DoLog EXTRA "Installing C library"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make "${make_args[@]}" install install_utils
|
2016-04-02 06:28:43 +00:00
|
|
|
fi # libc_mode == final
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2016-04-05 21:47:20 +00:00
|
|
|
# Now, if installing headers into a subdirectory, put everything in its place.
|
|
|
|
# Remove the header subdirectory if it existed already.
|
2016-04-14 07:30:34 +00:00
|
|
|
if [ -n "${hdr_install_subdir}" ]; then
|
2016-04-05 21:47:20 +00:00
|
|
|
CT_DoExecLog ALL mv "${multi_root}/usr/include" "${multi_root}/usr/include.new"
|
|
|
|
CT_DoExecLog ALL mv "${multi_root}/usr/include.saved" "${multi_root}/usr/include"
|
|
|
|
CT_DoExecLog ALL rm -rf "${multi_root}/usr/include/${hdr_install_subdir}"
|
|
|
|
CT_DoExecLog ALL mv "${multi_root}/usr/include.new" "${multi_root}/usr/include/${hdr_install_subdir}"
|
|
|
|
fi
|
2016-04-12 06:11:22 +00:00
|
|
|
|
2016-04-11 20:59:16 +00:00
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
# Initialises the .config file to sensible values
|
2007-07-28 11:59:37 +00:00
|
|
|
# $1: original file
|
2015-11-10 07:50:13 +00:00
|
|
|
# $2: modified file
|
|
|
|
manage_uClibc_config() {
|
|
|
|
src="$1"
|
|
|
|
dst="$2"
|
2016-04-05 21:47:20 +00:00
|
|
|
flags="$3"
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2015-11-10 07:50:13 +00:00
|
|
|
# Start with fresh files
|
|
|
|
CT_DoExecLog ALL cp "${src}" "${dst}"
|
2010-01-01 17:47:20 +00:00
|
|
|
|
2011-11-20 20:08:27 +00:00
|
|
|
case "${CT_ARCH_ENDIAN}" in
|
|
|
|
big)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}"
|
|
|
|
CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}"
|
|
|
|
CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${dst}"
|
|
|
|
CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}"
|
|
|
|
;;
|
2011-11-20 20:08:27 +00:00
|
|
|
little)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${dst}"
|
|
|
|
CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}"
|
|
|
|
CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${dst}"
|
|
|
|
CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}"
|
|
|
|
;;
|
2007-02-24 11:00:05 +00:00
|
|
|
esac
|
|
|
|
|
2011-04-24 16:57:01 +00:00
|
|
|
if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "ARCH_USE_MMU" "${dst}"
|
2011-04-24 16:57:01 +00:00
|
|
|
else
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigDisableOption "ARCH_USE_MMU" "${dst}"
|
2011-04-24 16:57:01 +00:00
|
|
|
fi
|
|
|
|
|
2016-08-29 17:46:02 +00:00
|
|
|
if [ "${CT_SHARED_LIBS}" = "y" ]; then
|
|
|
|
CT_KconfigEnableOption "HAVE_SHARED" "${dst}"
|
|
|
|
else
|
|
|
|
CT_KconfigDisableOption "HAVE_SHARED" "${dst}"
|
|
|
|
fi
|
|
|
|
|
2007-05-19 22:52:47 +00:00
|
|
|
# Accomodate for old and new uClibc version, where the
|
|
|
|
# way to select between hard/soft float has changed
|
2011-11-14 17:54:37 +00:00
|
|
|
case "${CT_ARCH_FLOAT}" in
|
|
|
|
hard|softfp)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_FLOATS" "${dst}"
|
2007-02-24 11:00:05 +00:00
|
|
|
;;
|
2011-11-14 17:54:37 +00:00
|
|
|
soft)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_FLOATS" "${dst}"
|
|
|
|
CT_KconfigEnableOption "DO_C99_MATH" "${dst}"
|
2007-02-24 11:00:05 +00:00
|
|
|
;;
|
|
|
|
esac
|
2014-01-04 15:19:18 +00:00
|
|
|
if [ "${CT_LIBC_UCLIBC_FENV}" = "y" ]; then
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_FENV" "${dst}"
|
2014-01-04 15:19:18 +00:00
|
|
|
fi
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2011-08-12 22:05:51 +00:00
|
|
|
# We always want ctor/dtor
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_CTOR_DTOR" "${dst}"
|
2011-08-12 22:05:51 +00:00
|
|
|
|
2007-09-16 17:59:18 +00:00
|
|
|
# Change paths to work with crosstool-NG
|
2015-11-10 07:50:13 +00:00
|
|
|
#
|
|
|
|
# DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX,
|
|
|
|
# which is the correct value of ${PREFIX}/${TARGET}.
|
|
|
|
CT_KconfigSetOption "DEVEL_PREFIX" "\"/usr/\"" "${dst}"
|
|
|
|
CT_KconfigSetOption "RUNTIME_PREFIX" "\"/\"" "${dst}"
|
|
|
|
CT_KconfigSetOption "KERNEL_HEADERS" "\"${CT_HEADERS_DIR}\"" "${dst}"
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2008-11-01 17:13:54 +00:00
|
|
|
# Locales support
|
2007-02-24 11:00:05 +00:00
|
|
|
# Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing
|
|
|
|
# entirely if LOCALE is not set. If LOCALE was already set, we'll
|
|
|
|
# assume the user has already made all the appropriate generation
|
|
|
|
# arrangements. Note that having the uClibc Makefile download the
|
|
|
|
# pregenerated locales is not compatible with crosstool; besides,
|
|
|
|
# crosstool downloads them as part of getandpatch.sh.
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE" "${dst}"
|
2010-07-27 23:03:07 +00:00
|
|
|
case "${CT_LIBC_UCLIBC_LOCALES}:${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" in
|
|
|
|
:*)
|
|
|
|
;;
|
|
|
|
y:)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}"
|
|
|
|
CT_KconfigDeleteOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}"
|
|
|
|
CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" \
|
|
|
|
"${dst}"
|
|
|
|
CT_KconfigDeleteOption "UCLIBC_HAS_XLOCALE" "${dst}"
|
2010-07-27 23:03:07 +00:00
|
|
|
;;
|
|
|
|
y:y)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}"
|
|
|
|
CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" \
|
|
|
|
"${dst}"
|
|
|
|
CT_KconfigDeleteOption "UCLIBC_HAS_XLOCALE" "${dst}"
|
2010-07-27 23:03:07 +00:00
|
|
|
;;
|
|
|
|
esac
|
2008-11-01 17:13:54 +00:00
|
|
|
|
2009-11-06 19:17:30 +00:00
|
|
|
# WCHAR support
|
2015-11-10 07:50:13 +00:00
|
|
|
if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ]; then
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_WCHAR" "${dst}"
|
2009-11-06 19:17:30 +00:00
|
|
|
else
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigDisableOption "UCLIBC_HAS_WCHAR" "${dst}"
|
2009-11-06 19:17:30 +00:00
|
|
|
fi
|
|
|
|
|
2015-11-23 06:18:08 +00:00
|
|
|
# IPv6 support
|
|
|
|
if [ "${CT_LIBC_UCLIBC_IPV6}" = "y" ]; then
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_IPV6" "${dst}"
|
|
|
|
else
|
|
|
|
CT_KconfigDisableOption "UCLIBC_HAS_IPV6" "${dst}"
|
|
|
|
fi
|
|
|
|
|
2008-11-01 17:13:54 +00:00
|
|
|
# Force on options needed for C++ if we'll be making a C++ compiler.
|
|
|
|
# I'm not sure locales are a requirement for doing C++... Are they?
|
2007-02-24 11:00:05 +00:00
|
|
|
if [ "${CT_CC_LANG_CXX}" = "y" ]; then
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "DO_C99_MATH" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_GNU_GETOPT" "${dst}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Stack Smash Protection (SSP)
|
|
|
|
if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_SSP" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_BUILD_SSP" "${dst}"
|
|
|
|
else
|
|
|
|
CT_KconfigDisableOption "UCLIBC_HAS_SSP" "${dst}"
|
|
|
|
CT_KconfigDisableOption "UCLIBC_BUILD_SSP" "${dst}"
|
2007-02-24 11:00:05 +00:00
|
|
|
fi
|
|
|
|
|
2010-06-08 22:41:25 +00:00
|
|
|
# Push the threading model
|
2016-04-04 15:25:07 +00:00
|
|
|
CT_KconfigDisableOption "UCLIBC_HAS_THREADS" "${dst}"
|
|
|
|
CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}"
|
|
|
|
CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}"
|
|
|
|
CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
|
2010-06-08 22:41:25 +00:00
|
|
|
case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in
|
2010-07-02 23:15:28 +00:00
|
|
|
none:)
|
2010-06-08 22:41:25 +00:00
|
|
|
;;
|
2016-09-20 01:50:08 +00:00
|
|
|
linuxthreads:)
|
|
|
|
# Newer version of uClibc-ng, no old/new dichotomy
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_LINUXTHREADS" "${dst}"
|
|
|
|
;;
|
2010-07-02 20:11:45 +00:00
|
|
|
linuxthreads:old)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
|
|
|
|
CT_KconfigEnableOption "LINUXTHREADS_OLD" "${dst}"
|
2010-06-08 22:41:25 +00:00
|
|
|
;;
|
2010-07-02 20:11:45 +00:00
|
|
|
linuxthreads:new)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
|
|
|
|
CT_KconfigEnableOption "LINUXTHREADS_NEW" "${dst}"
|
2010-07-02 23:15:28 +00:00
|
|
|
;;
|
|
|
|
nptl:)
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
|
2010-06-08 22:41:25 +00:00
|
|
|
;;
|
2010-07-02 23:15:28 +00:00
|
|
|
*)
|
|
|
|
CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREAD}' CT_LIBC_UCLIBC_LNXTHRD='${CT_LIBC_UCLIBC_LNXTHRD}'"
|
|
|
|
;;
|
2010-06-08 22:41:25 +00:00
|
|
|
esac
|
|
|
|
|
2008-06-19 08:14:52 +00:00
|
|
|
# Always build the libpthread_db
|
2015-11-10 07:50:13 +00:00
|
|
|
CT_KconfigEnableOption "PTHREADS_DEBUG_SUPPORT" "${dst}"
|
2008-06-19 08:14:52 +00:00
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
# Force on debug options if asked for
|
2016-04-04 15:25:07 +00:00
|
|
|
CT_KconfigDisableOption "DODEBUG" "${dst}"
|
|
|
|
CT_KconfigDisableOption "DODEBUG_PT" "${dst}"
|
|
|
|
CT_KconfigDisableOption "DOASSERTS" "${dst}"
|
|
|
|
CT_KconfigDisableOption "SUPPORT_LD_DEBUG" "${dst}"
|
|
|
|
CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}"
|
|
|
|
CT_KconfigDisableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}"
|
2007-02-24 11:00:05 +00:00
|
|
|
case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
|
2015-11-10 07:50:13 +00:00
|
|
|
0)
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
CT_KconfigEnableOption "DODEBUG" "${dst}"
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
CT_KconfigEnableOption "DODEBUG" "${dst}"
|
|
|
|
CT_KconfigEnableOption "DOASSERTS" "${dst}"
|
|
|
|
CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}"
|
|
|
|
;;
|
|
|
|
3)
|
|
|
|
CT_KconfigEnableOption "DODEBUG" "${dst}"
|
|
|
|
CT_KconfigEnableOption "DODEBUG_PT" "${dst}"
|
|
|
|
CT_KconfigEnableOption "DOASSERTS" "${dst}"
|
|
|
|
CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}"
|
|
|
|
CT_KconfigEnableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}"
|
|
|
|
CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}"
|
|
|
|
;;
|
2007-02-24 11:00:05 +00:00
|
|
|
esac
|
2016-04-04 15:25:07 +00:00
|
|
|
|
|
|
|
# Remove stripping: its the responsibility of the
|
|
|
|
# firmware builder to strip or not.
|
|
|
|
CT_KconfigDisableOption "DOSTRIP" "${dst}"
|
|
|
|
|
|
|
|
# Now allow architecture to tweak as it wants
|
|
|
|
CT_DoArchUClibcConfig "${dst}"
|
2016-04-05 21:47:20 +00:00
|
|
|
CT_DoArchUClibcCflags "${dst}" "${flags}"
|
2007-02-24 11:00:05 +00:00
|
|
|
}
|
2015-06-21 23:53:06 +00:00
|
|
|
|
|
|
|
do_libc_post_cc() {
|
2016-04-17 07:11:03 +00:00
|
|
|
# uClibc and GCC disagree where the dynamic linker lives. uClibc always
|
|
|
|
# places it in the MULTILIB_DIR, while gcc does that for *some* variants
|
|
|
|
# and expects it in /lib for the other. So, create a symlink from lib
|
|
|
|
# to the actual location, but only if that will not override the actual
|
|
|
|
# file in /lib. Thus, need to do this after all the variants are built.
|
|
|
|
# Moreover, need to do this after the final compiler is built: on targets
|
|
|
|
# that use elf2flt, the core compilers cannot find ld when running elf2flt.
|
|
|
|
CT_DoStep INFO "Checking dynamic linker symlinks"
|
|
|
|
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-post_cc"
|
|
|
|
echo "int main(void) { return 0; }" > test-ldso.c
|
|
|
|
CT_IterateMultilibs do_libc_ldso_fixup ldso_fixup
|
|
|
|
CT_Popd
|
|
|
|
CT_EndStep
|
|
|
|
}
|
|
|
|
|
|
|
|
do_libc_ldso_fixup() {
|
|
|
|
local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
|
|
|
|
local binary
|
|
|
|
local ldso ldso_f ldso_d multilib_dir
|
|
|
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
eval "${arg// /\\ }"
|
|
|
|
done
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'"
|
|
|
|
|
|
|
|
multilib_dir="/lib/${multi_os_dir}"
|
|
|
|
CT_SanitizeVarDir multilib_dir
|
|
|
|
|
2017-01-14 05:24:16 +00:00
|
|
|
CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags}
|
2016-04-17 07:11:03 +00:00
|
|
|
if [ -r "test-ldso.gdb" ]; then
|
|
|
|
binary="test-ldso.gdb"
|
|
|
|
else
|
|
|
|
binary="test-ldso"
|
|
|
|
fi
|
|
|
|
if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then
|
|
|
|
ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \
|
|
|
|
grep 'Requesting program interpreter: ' | \
|
|
|
|
sed -e 's,.*: ,,' -e 's,\].*,,' )
|
|
|
|
fi
|
|
|
|
CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'"
|
|
|
|
|
|
|
|
ldso_d="${ldso%/ld*.so.*}"
|
|
|
|
ldso_f="${ldso##*/}"
|
|
|
|
# Create symlink if GCC produced an executable, dynamically linked, it was requesting
|
|
|
|
# a linker not in the current directory, and there is no such file in the expected
|
|
|
|
# ldso dir.
|
|
|
|
if [ -n "${ldso}" -a "${ldso_d}" != "${multilib_dir}" -a ! -r "${multi_root}${ldso}" ]; then
|
|
|
|
# Convert ldso_d to "how many levels we need to go up" and remove
|
|
|
|
# leading slash.
|
|
|
|
ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' )
|
|
|
|
CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \
|
|
|
|
"${multi_root}${ldso}"
|
|
|
|
fi
|
2015-06-21 23:53:06 +00:00
|
|
|
}
|