|
|
e5fd9a |
|
|
|
ce6529 |
# ccenv.sh: sofort's tool-finding bits,
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
dff3c5 |
# this file is covered by COPYING.SOFORT.
|
|
|
dff3c5 |
|
|
|
ce6529 |
# invocation and names of binary tools:
|
|
|
ce6529 |
# agnostic names (ar, nm, objdump, ...);
|
|
|
ce6529 |
# target-prefixed agnostic names (x86_64-nt64-midipix-ar, ...);
|
|
|
ce6529 |
# branded names (llvm-ar, llvm-nm, llvm-objdump, ...);
|
|
|
ce6529 |
# target-prefixed branded names (x86_64-linux-gnu-gcc-ar, ...);
|
|
|
ce6529 |
# target-specifying branded tools (llvm-ar --target=x86_64-linux, ...).
|
|
|
ce6529 |
|
|
|
ce6529 |
# cross-compilation: default search order:
|
|
|
ce6529 |
# target-prefixed agnostic tools;
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
# ``gcc'' when using gcc, and ``llvm'' when using clang);
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
# internal variables of interest:
|
|
|
ce6529 |
# ccenv_cfgtype: the type of host being tested (host/native)
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
e5fd9a |
# variables available to cfgdefs.sh and cfgfini.sh:
|
|
|
e5fd9a |
# ccenv_host_cflags: expanded cflags, valid for the host compiler
|
|
|
e5fd9a |
# ccenv_host_ldflags: expanded ldflags, valid for the host compiler
|
|
|
8917cb |
|
|
|
e5fd9a |
# ccenv_native_cflags: expanded cflags, valid for the native compiler
|
|
|
e5fd9a |
# ccenv_native_ldflags: expanded ldflags, valid for the native compiler
|
|
|
8917cb |
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_usage()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
cat "$mb_project_dir"/sofort/ccenv/ccenv.usage
|
|
|
ce6529 |
exit 0
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_newline()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
printf '\n' >> "$ccenv_cfgfile"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_comment()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_internal_str='#'
|
|
|
ce6529 |
|
|
|
ce6529 |
for ccenv_internal_arg ; do
|
|
|
ce6529 |
ccenv_internal_str="$ccenv_internal_str $ccenv_internal_arg"
|
|
|
ce6529 |
done
|
|
|
ce6529 |
|
|
|
ce6529 |
printf '%s\n' "$ccenv_internal_str" >> "$ccenv_cfgfile"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
fad405 |
ccenv_tool_prolog()
|
|
|
fad405 |
{
|
|
|
88afb3 |
ccenv_line_dots='.....................................'
|
|
|
e4a871 |
ccenv_tool_desc=" == checking for ${1}"
|
|
|
fad405 |
ccenv_tool_dlen="${#ccenv_line_dots}"
|
|
|
fad405 |
|
|
|
2e6edf |
printf '\n%s\n' '________________________' >&3
|
|
|
2e6edf |
printf "ccenv: checking for ${1}\n\n" >&3
|
|
|
fad405 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s" \
|
|
|
88afb3 |
"${ccenv_tool_desc} ${mb_line_dots}"
|
|
|
fad405 |
}
|
|
|
fad405 |
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_tool_epilog()
|
|
|
fad405 |
{
|
|
|
fad405 |
ccenv_line_dots='................................'
|
|
|
fad405 |
ccenv_tool_dlen="$((${#ccenv_line_dots} - ${#1}))"
|
|
|
fad405 |
|
|
|
69f390 |
case ${ccenv_tool_dlen} in
|
|
|
69f390 |
0 | -* )
|
|
|
69f390 |
ccenv_tool_dlen='3' ;;
|
|
|
69f390 |
esac
|
|
|
69f390 |
|
|
|
88afb3 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \
|
|
|
fad405 |
"${ccenv_line_dots}" "${1}"
|
|
|
2e6edf |
|
|
|
2e6edf |
if [ "${1}" = 'false' ]; then
|
|
|
2e6edf |
printf '\n\nccenv: not (yet) found.\n' >&3
|
|
|
2e6edf |
else
|
|
|
2e6edf |
printf "\n\nccenv : found $(command -v ${1}).\n" >&3
|
|
|
2e6edf |
fi
|
|
|
2e6edf |
|
|
|
2e6edf |
printf '%s\n' '------------------------' >&3
|
|
|
fad405 |
}
|
|
|
fad405 |
|
|
|
fad405 |
|
|
|
45979f |
ccenv_tool_variant_epilog()
|
|
|
45979f |
{
|
|
|
45979f |
ccenv_expr=${1}='${'${1}':-false}'
|
|
|
45979f |
eval "$ccenv_expr"
|
|
|
45979f |
|
|
|
45979f |
ccenv_expr='${'${1}'}'
|
|
|
45979f |
eval ccenv_tool_epilog "$ccenv_expr"
|
|
|
45979f |
}
|
|
|
45979f |
|
|
|
45979f |
|
|
|
fad405 |
ccenv_attr_prolog()
|
|
|
fad405 |
{
|
|
|
88afb3 |
ccenv_line_dots=' .....................................'
|
|
|
88afb3 |
ccenv_attr_desc=" == detect ${ccenv_cfgtype} ${1}"
|
|
|
fad405 |
ccenv_attr_dlen="${#ccenv_line_dots}"
|
|
|
fad405 |
|
|
|
fad405 |
printf "%${ccenv_attr_dlen}.${ccenv_attr_dlen}s" \
|
|
|
fad405 |
"${ccenv_attr_desc} ${ccenv_line_dots}"
|
|
|
2e6edf |
|
|
|
2e6edf |
printf '\n%s\n' '________________________' >&3
|
|
|
2e6edf |
printf "ccenv: detecting ${1}\n\n" >&3
|
|
|
fad405 |
}
|
|
|
fad405 |
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_attr_epilog()
|
|
|
fad405 |
{
|
|
|
2e6edf |
ccenv_line_dots='................................'
|
|
|
88afb3 |
ccenv_tool_dlen="$((${#ccenv_line_dots} - 1 - ${#1}))"
|
|
|
2e6edf |
|
|
|
69f390 |
case ${ccenv_tool_dlen} in
|
|
|
69f390 |
0 | -* )
|
|
|
69f390 |
ccenv_tool_dlen='3' ;;
|
|
|
69f390 |
esac
|
|
|
69f390 |
|
|
|
88afb3 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \
|
|
|
2e6edf |
"${ccenv_line_dots}" "${1}"
|
|
|
2e6edf |
|
|
|
2e6edf |
printf '\n\nccenv: detected result: %s\n' "${1}" >&3
|
|
|
2e6edf |
printf '%s\n' '------------------------' >&3
|
|
|
fad405 |
}
|
|
|
fad405 |
|
|
|
fad405 |
|
|
|
ce6529 |
ccenv_find_tool()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
if [ -z "$ccenv_prefixes" ]; then
|
|
|
a03255 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
e9bb78 |
ccenv_cmd_args="${@:-}"
|
|
|
e9bb78 |
|
|
|
e9bb78 |
if [ -z "$ccenv_cmd_args" ]; then
|
|
|
c55058 |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
c55058 |
ccenv_tool="$ccenv_candidate"
|
|
|
12c8cd |
return 0
|
|
|
c6156c |
fi
|
|
|
12c8cd |
else
|
|
|
c55058 |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
2e6edf |
if "$ccenv_candidate" $@ > /dev/null 2>&3; then
|
|
|
c55058 |
ccenv_tool="$ccenv_candidate"
|
|
|
12c8cd |
return 0
|
|
|
c6156c |
fi
|
|
|
c6156c |
fi
|
|
|
12c8cd |
fi
|
|
|
ce6529 |
done
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_tool=false
|
|
|
ce6529 |
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
a03255 |
for ccenv_prefix in $(printf '%s' "$ccenv_prefixes"); do
|
|
|
a03255 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
ce6529 |
ccenv_tool="$ccenv_prefix$ccenv_candidate"
|
|
|
c6156c |
|
|
|
c6156c |
if command -v "$ccenv_tool" > /dev/null; then
|
|
|
c6156c |
return 0
|
|
|
c6156c |
fi
|
|
|
ce6529 |
done
|
|
|
ce6529 |
done
|
|
|
ce6529 |
|
|
|
a03255 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
c55058 |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
c55058 |
ccenv_tool="$ccenv_candidate"
|
|
|
c6156c |
return 0
|
|
|
c6156c |
fi
|
|
|
ce6529 |
done
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_tool=false
|
|
|
ce6529 |
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_primary_tools()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_core_tools="ar nm objdump ranlib size strip strings objcopy"
|
|
|
2f682f |
ccenv_hack_tools="addr2line cov elfedit readelf readobj otool"
|
|
|
d4e15e |
ccenv_peep_tools="perk mdso dlltool windmc windres pkgconf"
|
|
|
ce6529 |
|
|
|
a03255 |
for __tool in $(printf '%s' "$ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools"); do
|
|
|
fad405 |
ccenv_tool_prolog "$__tool"
|
|
|
fad405 |
|
|
|
ce6529 |
if [ -n "$mb_agnostic" ]; then
|
|
|
ce6529 |
ccenv_candidates=" $__tool"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ -n "$mb_zealous" ]; then
|
|
|
ce6529 |
ccenv_candidates="$mb_zealous-$__tool"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
ce6529 |
ccenv_candidates="gcc-$__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
ce6529 |
ccenv_candidates="llvm-$__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ -n "$mb_toolchain" ]; then
|
|
|
ce6529 |
ccenv_candidates="$mb_toolchain-$__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
ce6529 |
|
|
|
2932df |
elif [ "$__tool" = 'pkgconf' ]; then
|
|
|
2932df |
ccenv_candidates="$__tool pkg-config"
|
|
|
2932df |
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_candidates="$__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
ce6529 |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
ce6529 |
ccenv_var_prefix='mb_'
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_var_prefix='mb_native_'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
22e585 |
ccenv_tool=
|
|
|
ce6529 |
ccenv_var_name=$ccenv_var_prefix$__tool
|
|
|
ce6529 |
ccenv_var_expr='${'$ccenv_var_name':-}'
|
|
|
ce6529 |
eval ccenv_var_val=$ccenv_var_expr
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_var_val" ]; then
|
|
|
ce6529 |
eval ccenv_$__tool="$ccenv_var_val"
|
|
|
22e585 |
ccenv_tool="$ccenv_var_val"
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
eval ccenv_$__tool="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_tool_epilog "$ccenv_tool"
|
|
|
ce6529 |
done
|
|
|
ce6529 |
|
|
|
ce6529 |
# windrc
|
|
|
ce6529 |
ccenv_windrc="$ccenv_windres"
|
|
|
753312 |
|
|
|
753312 |
# archive format preamble
|
|
|
681d89 |
if [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
2ebebe |
ccenv_libgcc_path=$($ccenv_cc -print-file-name=libgcc.a \
|
|
|
2ebebe |
2>/dev/null)
|
|
|
2ebebe |
|
|
|
2ebebe |
if [ -n "$ccenv_libgcc_path" ]; then
|
|
|
2ebebe |
ccenv_libgcc_a_header=$(od -b -N8 \
|
|
|
2ebebe |
$($ccenv_cc -print-file-name=libgcc.a) \
|
|
|
2ebebe |
| head -n1)
|
|
|
2ebebe |
else
|
|
|
2ebebe |
ccenv_libgcc_a_header=
|
|
|
2ebebe |
fi
|
|
|
681d89 |
else
|
|
|
681d89 |
ccenv_libgcc_a_header=
|
|
|
681d89 |
fi
|
|
|
681d89 |
|
|
|
681d89 |
# ar (default)
|
|
|
753312 |
ccenv_cc_arfmt='common'
|
|
|
753312 |
|
|
|
753312 |
# ar (big)
|
|
|
753312 |
ccenv_bigaf_header=$(printf '%s\n' '<bigaf>' | od -b | head -n1)
|
|
|
753312 |
|
|
|
753312 |
if [ "$ccenv_libgcc_a_header" = "$ccenv_bigaf_header" ]; then
|
|
|
753312 |
ccenv_cc_arfmt='bigaf'
|
|
|
753312 |
|
|
|
753312 |
for __tool in $(printf '%s' "$ccenv_core_tools"); do
|
|
|
753312 |
ccenv_var_name=ccenv_$__tool
|
|
|
753312 |
ccenv_var_expr='${'$ccenv_var_name':-}'
|
|
|
753312 |
eval ccenv_var_val="$ccenv_var_expr"
|
|
|
753312 |
|
|
|
753312 |
if [ "$ccenv_var_val" != false ]; then
|
|
|
753312 |
ccenv_var_val="$ccenv_var_val -X64"
|
|
|
753312 |
ccenv_var_expr='${ccenv_var_val:-}'
|
|
|
753312 |
eval ccenv_$__tool="$ccenv_var_expr"
|
|
|
753312 |
fi
|
|
|
753312 |
done
|
|
|
753312 |
fi
|
|
|
753312 |
|
|
|
753312 |
# ar (small)
|
|
|
753312 |
ccenv_aiaff_header=$(printf '%s\n' '<aiaff>' | od -b | head -n1)
|
|
|
753312 |
|
|
|
753312 |
if [ "$ccenv_libgcc_a_header" = "$ccenv_aiaff_header" ]; then
|
|
|
753312 |
ccenv_cc_arfmt='aiaff'
|
|
|
753312 |
|
|
|
753312 |
for __tool in $(printf '%s' "$ccenv_core_tools"); do
|
|
|
753312 |
ccenv_var_name=ccenv_$__tool
|
|
|
753312 |
ccenv_var_expr='${'$ccenv_var_name':-}'
|
|
|
753312 |
eval ccenv_var_val="$ccenv_var_expr"
|
|
|
753312 |
|
|
|
753312 |
if [ "$ccenv_var_val" != false ]; then
|
|
|
753312 |
ccenv_var_val="$ccenv_var_val -X32"
|
|
|
753312 |
ccenv_var_expr='${ccenv_var_val:-}'
|
|
|
753312 |
eval ccenv_$__tool="$ccenv_var_expr"
|
|
|
753312 |
fi
|
|
|
753312 |
done
|
|
|
753312 |
fi
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_tool_variants()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
# as (asm)
|
|
|
fad405 |
ccenv_tool_prolog 'as (asm)'
|
|
|
ce6529 |
ccenv_candidates=as
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" = false ]; then
|
|
|
ce6529 |
ccenv_as_asm=
|
|
|
ce6529 |
else
|
|
|
db1df2 |
$ccenv_tool --help 2>&1 | grep -i '.bc assembler' \
|
|
|
ce6529 |
|| ccenv_as_asm="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_as_asm'
|
|
|
fad405 |
|
|
|
ce6529 |
# as (ll)
|
|
|
fad405 |
ccenv_tool_prolog 'as (ll)'
|
|
|
ce6529 |
ccenv_candidates=llvm-as
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" != false ]; then
|
|
|
ce6529 |
ccenv_as_ll="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_as_ll'
|
|
|
fad405 |
|
|
|
ce6529 |
# as (mc)
|
|
|
fad405 |
ccenv_tool_prolog 'as (mc)'
|
|
|
ce6529 |
ccenv_candidates=llvm-mc
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" != false ]; then
|
|
|
ce6529 |
ccenv_as_mc="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_as_mc'
|
|
|
fad405 |
|
|
|
ce6529 |
# ld (bfd)
|
|
|
fad405 |
ccenv_tool_prolog 'ld (bfd)'
|
|
|
ce6529 |
ccenv_candidates=ld.bfd
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" != false ]; then
|
|
|
ce6529 |
ccenv_ld_bfd="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_ld_bfd'
|
|
|
fad405 |
|
|
|
ce6529 |
# ld (gold)
|
|
|
fad405 |
ccenv_tool_prolog 'ld (gold)'
|
|
|
ce6529 |
ccenv_candidates=ld.gold
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" != false ]; then
|
|
|
ce6529 |
ccenv_ld_gold="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_ld_gold'
|
|
|
fad405 |
|
|
|
ce6529 |
# ld (lld)
|
|
|
fad405 |
ccenv_tool_prolog 'ld (lld)'
|
|
|
ce6529 |
ccenv_candidates=lld
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" != false ]; then
|
|
|
ce6529 |
ccenv_ld_lld="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_ld_lld'
|
|
|
fad405 |
|
|
|
ce6529 |
# objdump (bfd)
|
|
|
fad405 |
ccenv_tool_prolog 'objdump (bfd)'
|
|
|
ce6529 |
ccenv_candidates=objdump
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
a5c9ed |
if $ccenv_tool --version | grep -i Binutils > /dev/null; then
|
|
|
a5c9ed |
ccenv_objdump_bfd="$ccenv_tool"
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_objdump_bfd'
|
|
|
fad405 |
|
|
|
ce6529 |
# objdump (llvm)
|
|
|
fad405 |
ccenv_tool_prolog 'objdump (llvm)'
|
|
|
ce6529 |
ccenv_candidates=llvm-objdump
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
a5c9ed |
if $ccenv_tool --version | grep -i LLVM > /dev/null; then
|
|
|
a5c9ed |
ccenv_objdump_llvm="$ccenv_tool"
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_objdump_llvm'
|
|
|
fad405 |
|
|
|
ce6529 |
# readelf (bfd)
|
|
|
fad405 |
ccenv_tool_prolog 'readelf (bfd)'
|
|
|
ce6529 |
ccenv_candidates=readelf
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
a5c9ed |
if $ccenv_tool --version | grep -i Binutils > /dev/null; then
|
|
|
a5c9ed |
ccenv_readelf_bfd="$ccenv_tool"
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_readelf_bfd'
|
|
|
fad405 |
|
|
|
ce6529 |
# readelf (llvm)
|
|
|
fad405 |
ccenv_tool_prolog 'readelf (llvm)'
|
|
|
ce6529 |
ccenv_candidates=llvm-readelf
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
a5c9ed |
if $ccenv_tool --version | grep -i LLVM > /dev/null; then
|
|
|
a5c9ed |
ccenv_readelf_llvm="$ccenv_tool"
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
|
|
|
45979f |
ccenv_tool_variant_epilog 'ccenv_readelf_llvm'
|
|
|
fad405 |
|
|
|
ce6529 |
# as
|
|
|
ce6529 |
if [ -n "$ccenv_cc" ]; then
|
|
|
f5d6c8 |
ccenv_as='$('"$ccenv_makevar_prefix"'CC) -c -x assembler'
|
|
|
ce6529 |
elif [ -n "$mb_agnostic" ]; then
|
|
|
ce6529 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
ce6529 |
elif [ "$mb_zealous" = 'gcc' ]; then
|
|
|
ce6529 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
ce6529 |
elif [ -n "$mb_zealous" = 'llvm' ]; then
|
|
|
ce6529 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
|
|
|
ce6529 |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
ce6529 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
ce6529 |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
ce6529 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# ld
|
|
|
ce6529 |
if [ -n "$ccenv_cc" ]; then
|
|
|
ce6529 |
ccenv_ld='$('"$ccenv_makevar_prefix"'CC) -nostdlib -nostartfiles'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_c_compiler_candidates()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
if [ -n "$mb_compiler" ]; then
|
|
|
ce6529 |
ccenv_candidates="$mb_compiler"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ -n "$mb_agnostic" ]; then
|
|
|
ce6529 |
ccenv_candidates="c99 c11 cc"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ "$mb_zealous" = 'gcc' ]; then
|
|
|
ce6529 |
ccenv_candidates="gcc"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ "$mb_zealous" = 'llvm' ]; then
|
|
|
ce6529 |
ccenv_candidates="clang"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
ce6529 |
ccenv_candidates="gcc c99 c11 cc clang"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
ce6529 |
ccenv_candidates="clang c99 c11 cc gcc"
|
|
|
ce6529 |
|
|
|
ce6529 |
elif [ -n "$mb_toolchain" ]; then
|
|
|
ce6529 |
ccenv_candidates="$mb_toolchain c99 c11 cc gcc clang"
|
|
|
ce6529 |
|
|
|
ce6529 |
else
|
|
|
8bd597 |
ccenv_candidates="cc gcc clang c99 c11"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_cc()
|
|
|
ce6529 |
{
|
|
|
fad405 |
ccenv_tool_prolog 'C compiler'
|
|
|
fad405 |
|
|
|
ce6529 |
if [ -z "$ccenv_cc" ]; then
|
|
|
ce6529 |
ccenv_set_c_compiler_candidates
|
|
|
681d89 |
ccenv_find_tool
|
|
|
ce6529 |
ccenv_cc="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
681d89 |
|
|
|
ce6529 |
if [ "$ccenv_cc" = false ] && [ -n "$mb_compiler" ]; then
|
|
|
ce6529 |
ccenv_cc="$mb_compiler"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
681d89 |
ccenv_tool_epilog "$ccenv_cc"
|
|
|
681d89 |
|
|
|
681d89 |
|
|
|
681d89 |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
681d89 |
ccenv_host_cc="$ccenv_cc"
|
|
|
681d89 |
cfgtest_host_section
|
|
|
681d89 |
ccenv_host_cc=
|
|
|
681d89 |
else
|
|
|
681d89 |
ccenv_native_cc="$ccenv_cc"
|
|
|
681d89 |
cfgtest_native_section
|
|
|
681d89 |
ccenv_native_cc=
|
|
|
681d89 |
fi
|
|
|
681d89 |
|
|
|
ae00d3 |
cfgtest_silent='yes'
|
|
|
ae00d3 |
|
|
|
681d89 |
if cfgtest_compiler_switch -dumpmachine ; then
|
|
|
681d89 |
ccenv_dumpmachine_switch='-dumpmachine'
|
|
|
681d89 |
else
|
|
|
681d89 |
ccenv_dumpmachine_switch=
|
|
|
681d89 |
fi
|
|
|
681d89 |
|
|
|
b89e89 |
if cfgtest_code_snippet_asm 'typedef int dummy;' ; then
|
|
|
b89e89 |
eval ccenv_${ccenv_cfgtype}_stdin_input='yes'
|
|
|
b89e89 |
else
|
|
|
b89e89 |
eval ccenv_${ccenv_cfgtype}_stdin_input='no'
|
|
|
b89e89 |
fi
|
|
|
b89e89 |
|
|
|
ae00d3 |
unset cfgtest_silent
|
|
|
ae00d3 |
|
|
|
ce6529 |
ccenv_cc_cmd="$ccenv_cc"
|
|
|
42c825 |
ccenv_errors=
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_cfgtype" = 'native' ]; then
|
|
|
773bee |
ccenv_host=
|
|
|
773bee |
|
|
|
69e992 |
if [ -n "$mb_native_host" ]; then
|
|
|
69e992 |
ccenv_host="$mb_native_host"
|
|
|
69e992 |
|
|
|
69e992 |
elif [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
681d89 |
ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
681d89 |
$ccenv_dumpmachine_switch 2>&3)
|
|
|
773bee |
|
|
|
773bee |
elif command -v slibtool > /dev/null 2>&1; then
|
|
|
505fe0 |
ccenv=$(slibtool --dumpmachine 2>/dev/null || true)
|
|
|
773bee |
fi
|
|
|
773bee |
|
|
|
773bee |
if [ -z "$ccenv_host" ]; then
|
|
|
69e992 |
ccenv_machine=$(uname -m 2>/dev/null)
|
|
|
69e992 |
ccenv_system=$(uname -s 2>/dev/null)
|
|
|
69e992 |
|
|
|
69e992 |
ccenv_machine="${ccenv_machine:-unknown}"
|
|
|
69e992 |
ccenv_system="${ccenv_system:-anyos}"
|
|
|
69e992 |
|
|
|
69e992 |
ccenv_host=$(printf '%s' "${ccenv_machine}-unknown-${ccenv_system}" \
|
|
|
d6eb8b |
| tr '[[:upper:]]' '[[:lower:]]')
|
|
|
681d89 |
fi
|
|
|
681d89 |
|
|
|
1f89c2 |
ccenv_cchost=$ccenv_host
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
681d89 |
|
|
|
ce6529 |
if [ -n "$mb_cchost" ]; then
|
|
|
ce6529 |
ccenv_host="$mb_cchost"
|
|
|
ce6529 |
elif [ -n "$mb_host" ]; then
|
|
|
ce6529 |
ccenv_host="$mb_host"
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_host=
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
681d89 |
if [ -z "$ccenv_host" ] && [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
681d89 |
ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
681d89 |
$ccenv_dumpmachine_switch 2>&3)
|
|
|
ce6529 |
ccenv_cchost=$ccenv_host
|
|
|
681d89 |
|
|
|
681d89 |
elif [ -z "$ccenv_host" ]; then
|
|
|
773bee |
# no -dumpmachine support and no --host argument implies native build
|
|
|
773bee |
if command -v slibtool > /dev/null 2>&1; then
|
|
|
505fe0 |
ccenv=$(slibtool --dumpmachine 2>/dev/null || true)
|
|
|
773bee |
fi
|
|
|
69e992 |
|
|
|
773bee |
if [ -z "$ccenv_host" ]; then
|
|
|
773bee |
ccenv_machine=$(uname -m 2>/dev/null)
|
|
|
773bee |
ccenv_system=$(uname -s 2>/dev/null)
|
|
|
773bee |
|
|
|
773bee |
ccenv_machine="${ccenv_machine:-unknown}"
|
|
|
773bee |
ccenv_system="${ccenv_system:-anyos}"
|
|
|
69e992 |
|
|
|
773bee |
ccenv_host=$(printf '%s' "${ccenv_machine}-unknown-${ccenv_system}" \
|
|
|
773bee |
| tr '[[:upper:]]' '[[:lower:]]')
|
|
|
773bee |
fi
|
|
|
69e992 |
|
|
|
681d89 |
ccenv_cchost=$ccenv_host
|
|
|
681d89 |
|
|
|
681d89 |
elif [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
7efa04 |
ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
|
|
|
ce6529 |
ccenv_cmd="$ccenv_cc --target=$ccenv_host -E -xc -"
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "$mb_user_cc" ]; then
|
|
|
81f346 |
$(printf %s "$ccenv_cmd") < /dev/null > /dev/null \
|
|
|
ce6529 |
2>"$ccenv_tmp" || true
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_errors=$(cat "$ccenv_tmp")
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "$ccenv_errors" ]; then
|
|
|
681d89 |
ccenv_tool_prolog 'C compiler for host'
|
|
|
ce6529 |
ccenv_tflags="--target=$ccenv_host"
|
|
|
ce6529 |
ccenv_cc="$ccenv_cc $ccenv_tflags"
|
|
|
681d89 |
ccenv_tool_epilog "$ccenv_cc"
|
|
|
2e6edf |
else
|
|
|
2e6edf |
printf '%s' "$ccenv_errors" >&3
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
7efa04 |
rm -f "$ccenv_tmp"
|
|
|
7efa04 |
unset ccenv_tmp
|
|
|
7efa04 |
|
|
|
681d89 |
ccenv_cchost=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
681d89 |
$ccenv_dumpmachine_switch 2>&3)
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
227885 |
if [ -z "$ccenv_dumpmachine_switch" ] && [ -n "$ccenv_host" ]; then
|
|
|
227885 |
ccenv_cchost="$ccenv_host"
|
|
|
227885 |
|
|
|
227885 |
elif [ "$ccenv_cchost" != "$ccenv_host" ]; then
|
|
|
2e6edf |
printf 'error!\n' >&2
|
|
|
ce6529 |
printf 'ccenv:\n' >&2
|
|
|
ce6529 |
printf 'ccenv: ccenv_host: %s \n' $ccenv_host >&2
|
|
|
ce6529 |
printf 'ccenv: ccenv_cchost: %s \n' $ccenv_cchost >&2
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "$ccenv_tflags" ]; then
|
|
|
ce6529 |
printf 'ccenv:\n' >&2
|
|
|
ce6529 |
printf 'ccenv: ccenv_host and ccenv_cchost do not match, most likely because:\n' >&2
|
|
|
ce6529 |
printf 'ccenv: (1) you explicitly set CC (or passed
|
|
|
ce6529 |
printf 'ccenv: (2) the selected compiler does not accept --target=...\n' >&2
|
|
|
ce6529 |
printf 'ccenv: (3) the host reported by -dumpmachine differs from the one you requested.\n' >&2
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_errors" ]; then
|
|
|
ce6529 |
printf 'ccenv:\n' >&2
|
|
|
ce6529 |
printf 'ccenv: something went wrong, see the command and compiler message below.\n\n' >&2
|
|
|
ce6529 |
printf 'cmd: %s < /dev/null > /dev/null\n' "$ccenv_cmd" >&2
|
|
|
ce6529 |
printf '%s\n\n' "$ccenv_errors" >&2
|
|
|
ce6529 |
else
|
|
|
ce6529 |
printf 'ccenv:\n' >&2
|
|
|
ce6529 |
printf 'ccenv: something went wrong, bailing out.\n\n' >&2
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
return 2
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_cpp()
|
|
|
ce6529 |
{
|
|
|
fad405 |
ccenv_tool_prolog 'C pre-processor'
|
|
|
fad405 |
|
|
|
ce6529 |
case "$ccenv_cc_cmd" in
|
|
|
ce6529 |
cc | c99 | c11 | gcc)
|
|
|
ce6529 |
ccenv_cpp_prefix=
|
|
|
ce6529 |
ccenv_candidates="cpp" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
clang )
|
|
|
ce6529 |
ccenv_cpp_prefix=
|
|
|
ce6529 |
ccenv_candidates="clang-cpp" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
*-cc )
|
|
|
ce6529 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-cc*}-
|
|
|
ce6529 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
*-c99 )
|
|
|
ce6529 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-c99*}-
|
|
|
ce6529 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
*-c11 )
|
|
|
ce6529 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-c11*}-
|
|
|
ce6529 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
*-gcc )
|
|
|
ce6529 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
|
|
|
ce6529 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
*-clang )
|
|
|
ce6529 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
|
|
|
ce6529 |
ccenv_candidates="${ccenv_cpp_prefix}clang-cpp" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
* )
|
|
|
ce6529 |
ccenv_cpp="$ccenv_cc -E"
|
|
|
fad405 |
ccenv_tool_epilog "$ccenv_cpp"
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" = false ]; then
|
|
|
ce6529 |
ccenv_cpp="$ccenv_cc -E"
|
|
|
ce6529 |
elif [ -n "$ccenv_tflags" ]; then
|
|
|
ce6529 |
ccenv_cpp="$ccenv_tool $ccenv_tflags"
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_cpp="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_tool_epilog "$ccenv_cpp"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_cxx()
|
|
|
ce6529 |
{
|
|
|
fad405 |
ccenv_tool_prolog 'C++ compiler'
|
|
|
fad405 |
|
|
|
ce6529 |
case "$ccenv_cc_cmd" in
|
|
|
ce6529 |
cc | c99 | c11 )
|
|
|
ce6529 |
ccenv_cxx_prefix=
|
|
|
ce6529 |
ccenv_candidates="cxx c++" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
gcc )
|
|
|
ce6529 |
ccenv_cxx_prefix=
|
|
|
ce6529 |
ccenv_candidates="g++" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
clang )
|
|
|
ce6529 |
ccenv_cxx_prefix=
|
|
|
ce6529 |
ccenv_candidates="clang++" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
*-gcc )
|
|
|
3cc03e |
ccenv_cxx_prefix=${ccenv_cc_cmd%-gcc*}-
|
|
|
3cc03e |
ccenv_candidates="${ccenv_cxx_prefix}g++" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
*-clang )
|
|
|
3cc03e |
ccenv_cxx_prefix=${ccenv_cc_cmd%-clang*}-
|
|
|
3cc03e |
ccenv_candidates="${ccenv_cxx_prefix}clang++" ;;
|
|
|
3cc03e |
|
|
|
3cc03e |
/*cc | /*c99 | /*c11 )
|
|
|
3cc03e |
ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
|
|
|
3cc03e |
ccenv_candidates="${ccenv_cxx_prefix}/cxx"
|
|
|
3cc03e |
ccenv_candidates="${ccenv_candidates} ${ccenv_cxx_prefix}/c++" ;;
|
|
|
3cc03e |
|
|
|
3cc03e |
/*gcc )
|
|
|
3cc03e |
ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
|
|
|
3cc03e |
ccenv_candidates="${ccenv_cxx_prefix}/g++" ;;
|
|
|
ce6529 |
|
|
|
3cc03e |
/*clang )
|
|
|
3cc03e |
ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
|
|
|
3cc03e |
ccenv_candidates="${ccenv_cxx_prefix}/clang++" ;;
|
|
|
ce6529 |
|
|
|
ce6529 |
* )
|
|
|
ce6529 |
ccenv_cxx="$ccenv_cc -xc++"
|
|
|
fad405 |
ccenv_tool_epilog "$ccenv_cxx"
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_find_tool
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ "$ccenv_tool" = false ]; then
|
|
|
ce6529 |
ccenv_cxx="$ccenv_cc -xc++"
|
|
|
ce6529 |
elif [ -n "$ccenv_tflags" ]; then
|
|
|
ce6529 |
ccenv_cxx="$ccenv_tool $ccenv_tflags"
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_cxx="$ccenv_tool"
|
|
|
ce6529 |
fi
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_tool_epilog "$ccenv_cxx"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_cc_host()
|
|
|
ce6529 |
{
|
|
|
972150 |
ccenv_attr_prolog 'system'
|
|
|
ce6529 |
ccenv_cc_host="$ccenv_cchost"
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_cc_host"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_cc_bits()
|
|
|
ce6529 |
{
|
|
|
fad405 |
ccenv_attr_prolog 'bits'
|
|
|
fad405 |
|
|
|
ce6529 |
ccenv_internal_size=
|
|
|
ce6529 |
ccenv_internal_type='void *'
|
|
|
ce6529 |
ccenv_internal_test='char x[(sizeof(%s) == %s/8) ? 1 : -1];'
|
|
|
ce6529 |
|
|
|
ce6529 |
for ccenv_internal_guess in 64 32 128; do
|
|
|
a78382 |
if [ -z "${ccenv_internal_size:-}" ]; then
|
|
|
46e7ee |
ccenv_internal_str=$(printf "$ccenv_internal_test" \
|
|
|
46e7ee |
"$ccenv_internal_type" \
|
|
|
ce6529 |
"$ccenv_internal_guess")
|
|
|
ce6529 |
|
|
|
3a4602 |
ccenv_expr='ccenv_stdin_input=$ccenv_'${ccenv_cfgtype}'_stdin_input'
|
|
|
3a4602 |
eval ${ccenv_expr}
|
|
|
3a4602 |
|
|
|
3a4602 |
if [ "$ccenv_stdin_input" = 'yes' ]; then
|
|
|
a1e779 |
printf '%s' "$ccenv_internal_str" \
|
|
|
a1e779 |
| eval $ccenv_cc -S -xc - -o - \
|
|
|
a1e779 |
$(printf '%s' "$ccenv_cflags") \
|
|
|
a1e779 |
> /dev/null 2>&3 \
|
|
|
a1e779 |
&& ccenv_internal_size=$ccenv_internal_guess
|
|
|
a1e779 |
else
|
|
|
a1e779 |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
a1e779 |
|
|
|
a1e779 |
printf '%s' "$ccenv_internal_str" \
|
|
|
a1e779 |
> "$ccenv_tmpname"
|
|
|
a1e779 |
|
|
|
a1e779 |
$ccenv_cc -c "$ccenv_tmpname" -o a.out \
|
|
|
a1e779 |
> /dev/null 2>&3 \
|
|
|
a1e779 |
&& ccenv_internal_size=$ccenv_internal_guess
|
|
|
a1e779 |
|
|
|
a1e779 |
rm "$ccenv_tmpname"
|
|
|
a1e779 |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
done
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_cc_bits=$ccenv_internal_size
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_cc_bits"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_cc_underscore()
|
|
|
ce6529 |
{
|
|
|
fad405 |
ccenv_attr_prolog 'prepended underscores'
|
|
|
fad405 |
|
|
|
ce6529 |
ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe'
|
|
|
ce6529 |
ccenv_fn_code='int %s(void){return 0;}'
|
|
|
ce6529 |
|
|
|
2b0b49 |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
2b0b49 |
|
|
|
2b0b49 |
printf "$ccenv_fn_code" $ccenv_fn_name \
|
|
|
2b0b49 |
> "$ccenv_tmpname"
|
|
|
2b0b49 |
|
|
|
2b0b49 |
$ccenv_cc -c "$ccenv_tmpname" -o a.out \
|
|
|
2b0b49 |
> /dev/null 2>&3
|
|
|
2b0b49 |
|
|
|
2b0b49 |
if "$ccenv_nm" a.out | grep \
|
|
|
2b0b49 |
-e "^_$ccenv_fn_name" \
|
|
|
2b0b49 |
-e " _$ccenv_fn_name" \
|
|
|
2b0b49 |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_underscore='_'
|
|
|
fad405 |
ccenv_attr_epilog 'yes'
|
|
|
2b0b49 |
else
|
|
|
2b0b49 |
ccenv_attr_epilog 'no'
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
|
|
|
2b0b49 |
rm "$ccenv_tmpname"
|
|
|
2b0b49 |
rm a.out
|
|
|
fad405 |
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_create_framework_executable()
|
|
|
ce6529 |
{
|
|
|
8f2e6b |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
8f2e6b |
if [ "$mb_freestanding" = 'yes' ]; then
|
|
|
8f2e6b |
return 1
|
|
|
8f2e6b |
fi
|
|
|
8f2e6b |
fi
|
|
|
8f2e6b |
|
|
|
ce6529 |
if [ -f $ccenv_image ]; then
|
|
|
ce6529 |
mv $ccenv_image $ccenv_image.tmp
|
|
|
ce6529 |
rm -f $ccenv_image.tmp
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
5fe324 |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
5fe324 |
|
|
|
ce6529 |
printf 'int main(void){return 0;}' \
|
|
|
5fe324 |
> "$ccenv_tmpname"
|
|
|
ce6529 |
|
|
|
5fe324 |
if $ccenv_cc "$ccenv_tmpname" -o $ccenv_image 2>&3; then
|
|
|
5fe324 |
ccenv_ret=0
|
|
|
8f2e6b |
ccenv_cc_environment='hosted'
|
|
|
5fe324 |
else
|
|
|
5fe324 |
ccenv_ret=1
|
|
|
5fe324 |
fi
|
|
|
5fe324 |
|
|
|
5fe324 |
rm "$ccenv_tmpname"
|
|
|
5fe324 |
|
|
|
5fe324 |
return $ccenv_ret
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_create_freestanding_executable()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
if [ -f $ccenv_image ]; then
|
|
|
ce6529 |
mv $ccenv_image $ccenv_image.tmp
|
|
|
ce6529 |
rm -f $ccenv_image.tmp
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "ccenv_cc_underscore" ]; then
|
|
|
ce6529 |
ccenv_start_fn='_start'
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_start_fn='start'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
5fe324 |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
ce6529 |
|
|
|
5fe324 |
printf 'int %s(void){return 0;}' "$ccenv_start_fn" \
|
|
|
5fe324 |
> "$ccenv_tmpname"
|
|
|
ce6529 |
|
|
|
5fe324 |
if $ccenv_cc "$ccenv_tmpname" \
|
|
|
5fe324 |
-ffreestanding \
|
|
|
5fe324 |
-nostdlib -nostartfiles \
|
|
|
5fe324 |
-o $ccenv_image \
|
|
|
5fe324 |
2>&3; then
|
|
|
5fe324 |
ccenv_ret=0
|
|
|
8f2e6b |
ccenv_cc_environment='freestanding'
|
|
|
5fe324 |
else
|
|
|
5fe324 |
ccenv_ret=1
|
|
|
5fe324 |
fi
|
|
|
5fe324 |
|
|
|
5fe324 |
rm "$ccenv_tmpname"
|
|
|
5fe324 |
|
|
|
5fe324 |
return $ccenv_ret
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
fad405 |
ccenv_set_cc_binfmt_error()
|
|
|
fad405 |
{
|
|
|
fad405 |
ccenv_attr_epilog '(unable to create executable)'
|
|
|
fad405 |
}
|
|
|
fad405 |
|
|
|
ce6529 |
ccenv_set_cc_binfmt()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_use_perk=
|
|
|
2f682f |
ccenv_use_otool=
|
|
|
ce6529 |
ccenv_use_readelf=
|
|
|
ce6529 |
ccenv_use_readobj=
|
|
|
ce6529 |
ccenv_use_bfd_objdump=
|
|
|
ce6529 |
ccenv_use_llvm_objdump=
|
|
|
ce6529 |
|
|
|
fad405 |
ccenv_attr_prolog 'binary format'
|
|
|
fad405 |
|
|
|
ce6529 |
ccenv_create_framework_executable \
|
|
|
ce6529 |
|| ccenv_create_freestanding_executable \
|
|
|
fad405 |
|| ccenv_set_cc_binfmt_error \
|
|
|
ce6529 |
|| return 0
|
|
|
ce6529 |
|
|
|
ce6529 |
# PE / perk
|
|
|
ce6529 |
if [ -n "$ccenv_perk" ]; then
|
|
|
2e6edf |
if $ccenv_perk $ccenv_image 2>&3; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='PE'
|
|
|
a5c9ed |
ccenv_use_perk=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# ELF / readelf
|
|
|
ce6529 |
if [ -n "$ccenv_readelf" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_readelf -h $ccenv_image 2>&3 \
|
|
|
a5c9ed |
| grep 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
a5c9ed |
| grep 'Magic:7f454c46' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='ELF'
|
|
|
a5c9ed |
ccenv_use_readelf=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
|
|
|
ce6529 |
# llvm-readelf also parses PE and Mach-O
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_readelf_llvm" ]; then
|
|
|
ce6529 |
ccenv_readany="$ccenv_readelf_llvm"
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_readany="$ccenv_readelf"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# PE / readelf
|
|
|
ce6529 |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_readany -h $ccenv_image 2>&3 \
|
|
|
a5c9ed |
| grep 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
a5c9ed |
| grep 'Magic:MZ' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='PE'
|
|
|
a5c9ed |
ccenv_use_readelf=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
2f682f |
# MACHO-64 / otool
|
|
|
2f682f |
if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_otool -hv $ccenv_image 2>&3 \
|
|
|
a5c9ed |
| grep -i 'MH_MAGIC_64' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='MACHO'
|
|
|
a5c9ed |
ccenv_use_otool=yes
|
|
|
a5c9ed |
fi
|
|
|
2f682f |
fi
|
|
|
2f682f |
|
|
|
2f682f |
# MACHO-32 / otool
|
|
|
2f682f |
if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_otool -hv $ccenv_image 2>&3 \
|
|
|
a5c9ed |
| grep -i 'MH_MAGIC' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='MACHO'
|
|
|
a5c9ed |
ccenv_use_otool=yes
|
|
|
a5c9ed |
fi
|
|
|
2f682f |
fi
|
|
|
2f682f |
|
|
|
ce6529 |
# MACHO-64 / readelf
|
|
|
ce6529 |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_readany -h $ccenv_image 2>&3 \
|
|
|
a5c9ed |
| grep -i 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
a5c9ed |
| grep -i '(0xfeedfacf)' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='MACHO'
|
|
|
a5c9ed |
ccenv_use_readelf=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# MACHO-32 / readelf
|
|
|
ce6529 |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_readany -h $ccenv_image 2>&3 \
|
|
|
a5c9ed |
| grep -i 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
a5c9ed |
| grep -i '(0xcafebabe)' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='MACHO'
|
|
|
a5c9ed |
ccenv_use_readelf=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# MACHO / readobj
|
|
|
ce6529 |
if [ -n "$ccenv_readobj" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_readobj $ccenv_image 2>&3 \
|
|
|
f04242 |
| grep -i 'Format:' \
|
|
|
f04242 |
| sed -e 's/ /_/g' \
|
|
|
a5c9ed |
| grep -i '_Mach-O_' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='MACHO'
|
|
|
a5c9ed |
ccenv_use_readobj=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# MACHO / objdump (llvm)
|
|
|
ce6529 |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
a5c9ed |
if $ccenv_objdump -section-headers $ccenv_image \
|
|
|
2e6edf |
2>&3 \
|
|
|
a5c9ed |
| grep -i 'file format Mach-O' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='MACHO'
|
|
|
a5c9ed |
ccenv_use_objdump=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# MACHO / objdump (bfd)
|
|
|
ce6529 |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
$ccenv_objdump -h $ccenv_image 2>&3 \
|
|
|
ce6529 |
| grep -i 'file format Mach-O' \
|
|
|
ce6529 |
> /dev/null \
|
|
|
ce6529 |
&& ccenv_cc_binfmt='MACHO' \
|
|
|
ce6529 |
&& ccenv_use_objdump=yes
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
# PE / objdump (bfd)
|
|
|
ce6529 |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
2e6edf |
if $ccenv_objdump -h $ccenv_image 2>&3 \
|
|
|
a5c9ed |
| grep -i 'file format pei-' \
|
|
|
a5c9ed |
> /dev/null; then
|
|
|
a5c9ed |
ccenv_cc_binfmt='PE'
|
|
|
a5c9ed |
ccenv_use_bfd_objdump=yes
|
|
|
a5c9ed |
fi
|
|
|
ce6529 |
fi
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_cc_binfmt"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_pe()
|
|
|
ce6529 |
{
|
|
|
8f2e6b |
if [ "$ccenv_cc_environment" = 'freestanding' ]; then
|
|
|
ce6529 |
case "$ccenv_cchost" in
|
|
|
ce6529 |
*-midipix | *-midipix-* )
|
|
|
ce6529 |
ccenv_os='midipix' ;;
|
|
|
ce6529 |
*-mingw | *-mingw32 | *-mingw64 )
|
|
|
ce6529 |
ccenv_os='mingw' ;;
|
|
|
ce6529 |
*-mingw-* | *-mingw32-* | *-mingw64 )
|
|
|
ce6529 |
ccenv_os='mingw' ;;
|
|
|
ce6529 |
*-msys | *-msys2 | *-msys-* | *-msys2-* )
|
|
|
ce6529 |
ccenv_os='msys' ;;
|
|
|
ce6529 |
*-cygwin | *-cygwin-* )
|
|
|
ce6529 |
ccenv_os='cygwin' ;;
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_os" ]; then
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_use_perk" ]; then
|
|
|
ce6529 |
ccenv_framework=$($ccenv_perk -y $ccenv_image)
|
|
|
ce6529 |
ccenv_os=${ccenv_framework
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
ce6529 |
$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
|
|
|
ce6529 |
| grep 'cygwin1.dll' > /dev/null \
|
|
|
ce6529 |
&& ccenv_os='cygwin'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
ce6529 |
$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
|
|
|
ce6529 |
| grep 'msys-2.0.dll' > /dev/null \
|
|
|
ce6529 |
&& ccenv_os='msys'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
ce6529 |
$ccenv_objdump_bfd -x $ccenv_image \
|
|
|
ce6529 |
| grep -i 'DLL Name' | grep '.CRT' \
|
|
|
ce6529 |
> /dev/null \
|
|
|
ce6529 |
&& $ccenv_objdump_bfd -x $ccenv_image \
|
|
|
ce6529 |
| grep -i 'DLL Name' | grep '.bss' \
|
|
|
ce6529 |
> /dev/null \
|
|
|
ce6529 |
&& $ccenv_objdump_bfd -x $ccenv_image \
|
|
|
ce6529 |
| grep -i 'DLL Name' | grep '.tls' \
|
|
|
ce6529 |
> /dev/null \
|
|
|
ce6529 |
&& ccenv_os='mingw'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_macho()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
case "$ccenv_cchost" in
|
|
|
ce6529 |
*-apple-darwin* )
|
|
|
ce6529 |
ccenv_os='darwin' ;;
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os()
|
|
|
ce6529 |
{
|
|
|
fad405 |
ccenv_attr_prolog 'os name'
|
|
|
fad405 |
|
|
|
ce6529 |
case "$ccenv_cc_binfmt" in
|
|
|
ce6529 |
PE )
|
|
|
ce6529 |
ccenv_set_os_pe ;;
|
|
|
ce6529 |
MACHO )
|
|
|
ce6529 |
ccenv_set_os_macho ;;
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_os" ]; then
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_os"
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
case "$ccenv_cchost" in
|
|
|
ce6529 |
*-*-*-* )
|
|
|
320f78 |
ccenv_tip=${ccenv_cchost%-*}
|
|
|
ce6529 |
ccenv_os=${ccenv_tip
|
|
|
ce6529 |
|
|
|
320f78 |
*-*-musl | *-*-gnu )
|
|
|
320f78 |
ccenv_tip=${ccenv_cchost%-*}
|
|
|
ce6529 |
ccenv_os=${ccenv_tip
|
|
|
ce6529 |
|
|
|
320f78 |
*-*-* )
|
|
|
320f78 |
ccenv_os=${ccenv_cchost
|
|
|
320f78 |
|
|
|
320f78 |
*-* )
|
|
|
320f78 |
ccenv_os=${ccenv_cchost
|
|
|
320f78 |
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -z "$ccenv_os" ]; then
|
|
|
ce6529 |
ccenv_os='anyos'
|
|
|
ce6529 |
fi
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_os"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_flags()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
case "$ccenv_os" in
|
|
|
ce6529 |
darwin )
|
|
|
ce6529 |
ccenv_cflags_os='-D_DARWIN_C_SOURCE'
|
|
|
ce6529 |
ccenv_cflags_pic='-fPIC'
|
|
|
ce6529 |
|
|
|
ce6529 |
midipix )
|
|
|
ce6529 |
ccenv_cflags_os=
|
|
|
ce6529 |
ccenv_cflags_pic='-fPIC'
|
|
|
ce6529 |
|
|
|
ce6529 |
cygwin )
|
|
|
ce6529 |
ccenv_cflags_os=
|
|
|
ce6529 |
ccenv_cflags_pic=
|
|
|
ce6529 |
|
|
|
ce6529 |
msys | msys* | mingw | mingw* )
|
|
|
ce6529 |
ccenv_cflags_os='-U__STRICT_ANSI__'
|
|
|
ce6529 |
ccenv_cflags_pic=
|
|
|
ce6529 |
|
|
|
ce6529 |
* )
|
|
|
ce6529 |
ccenv_cflags_os=
|
|
|
ce6529 |
ccenv_cflags_pic='-fPIC'
|
|
|
ce6529 |
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_semantics()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
# binary_format - core_api - ex_api - dependency_resolution
|
|
|
ce6529 |
|
|
|
fad405 |
ccenv_attr_prolog 'os semantics'
|
|
|
fad405 |
|
|
|
ce6529 |
case "$ccenv_os" in
|
|
|
ce6529 |
linux )
|
|
|
ce6529 |
ccenv_os_semantics='elf-posix-linux-ldso'
|
|
|
ce6529 |
|
|
|
ce6529 |
bsd )
|
|
|
ce6529 |
ccenv_os_semantics='elf-posix-bsd-ldso'
|
|
|
ce6529 |
|
|
|
ce6529 |
darwin )
|
|
|
ce6529 |
ccenv_os_semantics='macho-posix-osx-ldso'
|
|
|
ce6529 |
|
|
|
ce6529 |
midipix )
|
|
|
ce6529 |
ccenv_os_semantics='pe-posix-winnt-ldso'
|
|
|
ce6529 |
|
|
|
ce6529 |
cygwin )
|
|
|
ce6529 |
ccenv_os_semantics='pe-hybrid-winnt-unsafe'
|
|
|
ce6529 |
|
|
|
ce6529 |
msys )
|
|
|
ce6529 |
ccenv_os_semantics='pe-hybrid-winnt-unsafe'
|
|
|
ce6529 |
|
|
|
ce6529 |
mingw )
|
|
|
ce6529 |
ccenv_os_semantics='pe-win32-winnt-unsafe'
|
|
|
ce6529 |
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_os_semantics" ]; then
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_os_semantics"
|
|
|
ce6529 |
return 0
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ -n "$ccenv_cc_binfmt" ]; then
|
|
|
ce6529 |
ccenv_os_semantics_pattern='%s-posix-anyos-unknown'
|
|
|
ce6529 |
ccenv_os_semantics=$(printf \
|
|
|
ce6529 |
"$ccenv_os_semantics_pattern" \
|
|
|
ce6529 |
"$ccenv_cc_binfmt" \
|
|
|
ce6529 |
| tr '[:upper:]' '[:lower:]')
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_os_semantics='unknown-posix-anyos-unknown'
|
|
|
ce6529 |
fi
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_os_semantics"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
bdcaa4 |
ccenv_set_os_dso_format()
|
|
|
bdcaa4 |
{
|
|
|
bdcaa4 |
ccenv_attr_prolog 'os dso format'
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
case "$ccenv_cc_arfmt" in
|
|
|
bdcaa4 |
common )
|
|
|
bdcaa4 |
ccenv_cc_sofmt="$ccenv_cc_binfmt"
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
bigaf )
|
|
|
bdcaa4 |
ccenv_libgcc_s_a_header=$(od -b -N8 \
|
|
|
bdcaa4 |
$($ccenv_cc -print-file-name=libgcc_s.a) \
|
|
|
bdcaa4 |
2>/dev/null \
|
|
|
bdcaa4 |
| head -n1)
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
ccenv_libgcc_s_so_header=$(od -b -N8 \
|
|
|
bdcaa4 |
$($ccenv_cc -print-file-name=libgcc_s.so) \
|
|
|
bdcaa4 |
2>/dev/null \
|
|
|
bdcaa4 |
| head -n1)
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
if [ "$ccenv_libgcc_s_a_header" = "$ccenv_bigaf_header" ]; then
|
|
|
bdcaa4 |
ccenv_cc_sofmt='bigaf'
|
|
|
bdcaa4 |
elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_bigaf_header" ]; then
|
|
|
bdcaa4 |
ccenv_cc_sofmt='bigaf'
|
|
|
bdcaa4 |
else
|
|
|
bdcaa4 |
ccenv_cc_sofmt="$ccenv_cc_binfmt"
|
|
|
bdcaa4 |
fi
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
aiaff )
|
|
|
bdcaa4 |
ccenv_libgcc_s_a_header=$(od -b -N8 \
|
|
|
bdcaa4 |
$($ccenv_cc -print-file-name=libgcc_s.a) \
|
|
|
bdcaa4 |
| head -n1)
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
ccenv_libgcc_s_so_header=$(od -b -N8 \
|
|
|
bdcaa4 |
$($ccenv_cc -print-file-name=libgcc_s.so) \
|
|
|
bdcaa4 |
| head -n1)
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
if [ "$ccenv_libgcc_s_a_header" = "$ccenv_aiaff_header" ]; then
|
|
|
bdcaa4 |
ccenv_cc_sofmt='aiaff'
|
|
|
bdcaa4 |
elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_aiaff_header" ]; then
|
|
|
bdcaa4 |
ccenv_cc_sofmt='aiaff'
|
|
|
bdcaa4 |
else
|
|
|
bdcaa4 |
ccenv_cc_sofmt="$ccenv_cc_binfmt"
|
|
|
bdcaa4 |
fi
|
|
|
bdcaa4 |
|
|
|
bdcaa4 |
esac
|
|
|
bdcaa4 |
|
|
|
d126e0 |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
d126e0 |
case "$ccenv_cc_sofmt" in
|
|
|
d126e0 |
bigaf | aiaff )
|
|
|
d126e0 |
mb_shared_lib_cmd='$(AR) -rcs'
|
|
|
d126e0 |
mb_shared_lib_ldflags=
|
|
|
d126e0 |
|
|
|
d126e0 |
|
|
|
d126e0 |
* )
|
|
|
d126e0 |
mb_shared_lib_cmd='$(CC) -shared -o'
|
|
|
d126e0 |
mb_shared_lib_ldflags='$(LDFLAGS_SHARED)'
|
|
|
d126e0 |
|
|
|
d126e0 |
esac
|
|
|
d126e0 |
fi
|
|
|
d126e0 |
|
|
|
bdcaa4 |
ccenv_attr_epilog "$ccenv_cc_sofmt"
|
|
|
bdcaa4 |
}
|
|
|
bdcaa4 |
|
|
|
ce6529 |
ccenv_set_os_dso_exrules()
|
|
|
ce6529 |
{
|
|
|
fad405 |
ccenv_attr_prolog 'os dso exrules'
|
|
|
fad405 |
|
|
|
ce6529 |
case "$ccenv_os" in
|
|
|
ce6529 |
midipix )
|
|
|
ce6529 |
ccenv_os_dso_exrules='pe-mdso'
|
|
|
ce6529 |
|
|
|
ce6529 |
* )
|
|
|
ce6529 |
if [ "$ccenv_cc_binfmt" = 'PE' ]; then
|
|
|
ce6529 |
ccenv_os_dso_exrules='pe-dlltool'
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_os_dso_exrules='default'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
esac
|
|
|
fad405 |
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_os_dso_exrules"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_dso_linkage()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
# todo: PIC, PIE, and friends
|
|
|
fad405 |
ccenv_attr_prolog 'os linkage'
|
|
|
ce6529 |
ccenv_os_dso_linkage='default'
|
|
|
fad405 |
ccenv_attr_epilog "$ccenv_os_dso_linkage"
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_darwin()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_os_app_prefix=
|
|
|
ce6529 |
ccenv_os_app_suffix=
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefix=lib
|
|
|
ce6529 |
ccenv_os_lib_suffix=.dylib
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_implib_ext=.invalid
|
|
|
ce6529 |
ccenv_os_libdef_ext=.invalid
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_archive_ext=.a
|
|
|
ce6529 |
ccenv_os_soname=symlink
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefixed_suffix=
|
|
|
ce6529 |
ccenv_os_lib_suffixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_mdso()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_os_app_prefix=
|
|
|
ce6529 |
ccenv_os_app_suffix=
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefix=lib
|
|
|
ce6529 |
ccenv_os_lib_suffix=.so
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_implib_ext=.lib.a
|
|
|
ce6529 |
ccenv_os_libdef_ext=.so.def
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_archive_ext=.a
|
|
|
ce6529 |
ccenv_os_soname=symlink
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
ce6529 |
ccenv_os_lib_suffixed_suffix=
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_dlltool()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_os_app_prefix=
|
|
|
ce6529 |
ccenv_os_app_suffix=.exe
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefix=lib
|
|
|
ce6529 |
ccenv_os_lib_suffix=.dll
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_implib_ext=.dll.a
|
|
|
ce6529 |
ccenv_os_libdef_ext=.def
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_archive_ext=.a
|
|
|
ce6529 |
ccenv_os_soname=copy
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
ce6529 |
ccenv_os_lib_suffixed_suffix=
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_default()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_os_app_prefix=
|
|
|
ce6529 |
ccenv_os_app_suffix=
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefix=lib
|
|
|
ce6529 |
ccenv_os_lib_suffix=.so
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_implib_ext=.invalid
|
|
|
ce6529 |
ccenv_os_libdef_ext=.invalid
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_archive_ext=.a
|
|
|
ce6529 |
ccenv_os_soname=symlink
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
ce6529 |
ccenv_os_lib_suffixed_suffix=
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os_dso_patterns()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
# sover: .so.x.y.z
|
|
|
ce6529 |
# verso: .x.y.z.so
|
|
|
ce6529 |
|
|
|
ce6529 |
case "$ccenv_os" in
|
|
|
ce6529 |
darwin )
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_darwin
|
|
|
ce6529 |
|
|
|
ce6529 |
midipix )
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_mdso
|
|
|
ce6529 |
|
|
|
ce6529 |
cygwin | msys | mingw )
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_dlltool
|
|
|
ce6529 |
|
|
|
ce6529 |
* )
|
|
|
ce6529 |
ccenv_set_os_dso_patterns_default
|
|
|
ce6529 |
|
|
|
ce6529 |
esac
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
3b58c7 |
ccenv_set_os_pe_switches()
|
|
|
3b58c7 |
{
|
|
|
70059d |
if [ "$ccenv_cc_binfmt" = 'PE' ] && [ -z "$ccenv_pe_subsystem" ]; then
|
|
|
3b58c7 |
case "$ccenv_os" in
|
|
|
3b58c7 |
midipix | mingw )
|
|
|
3b58c7 |
ccenv_pe_subsystem='windows'
|
|
|
3b58c7 |
|
|
|
3b58c7 |
* )
|
|
|
3b58c7 |
ccenv_pe_subsystem='console'
|
|
|
3b58c7 |
|
|
|
3b58c7 |
esac
|
|
|
3b58c7 |
fi
|
|
|
3b58c7 |
}
|
|
|
3b58c7 |
|
|
|
ce6529 |
ccenv_output_defs()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_in="$mb_project_dir/sofort/ccenv/ccenv.in"
|
|
|
ce6529 |
ccenv_mk="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
|
|
|
cc40ec |
ccenv_tmp=
|
|
|
ce6529 |
|
|
|
3b58c7 |
if [ "$ccenv_cc_binfmt" = 'PE' ]; then
|
|
|
3b58c7 |
ccenv_pe="$mb_project_dir/sofort/ccenv/pedefs.in"
|
|
|
3b58c7 |
ccenv_in="$ccenv_in $ccenv_pe"
|
|
|
3b58c7 |
fi
|
|
|
3b58c7 |
|
|
|
ce6529 |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
ce6529 |
|
|
|
7efa04 |
ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
|
|
|
ce6529 |
|
|
|
2e4331 |
sed \
|
|
|
16e769 |
-e 's/^[[:space:]]*$/@/g' \
|
|
|
2e4331 |
-e 's/^/NATIVE_/' \
|
|
|
2e4331 |
-e 's/NATIVE_@//g' \
|
|
|
2e4331 |
-e 's/NATIVE_#/#/g' \
|
|
|
2e4331 |
-e 's/ =/=/g' \
|
|
|
2e4331 |
-e 's/ +=/+=/g' \
|
|
|
376970 |
$(printf '%s ' $ccenv_in) \
|
|
|
376970 |
> "$ccenv_tmp"
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_in="$ccenv_tmp"
|
|
|
7efa04 |
else
|
|
|
cc40ec |
unset ccenv_tmp
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
519106 |
ccenv_var_defs=
|
|
|
b6a788 |
ccenv_sed_substs="-e s/@ccenv_cfgtype@/${ccenv_cfgtype}/g"
|
|
|
519106 |
|
|
|
ce6529 |
ccenv_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/ccenv/ccenv.vars" \
|
|
|
519106 |
| grep -v '^#');
|
|
|
ce6529 |
|
|
|
b6a788 |
ccenv_exvars="ccenv_makevar_prefix"
|
|
|
ce6529 |
|
|
|
519106 |
for __var in $(printf '%s' "$ccenv_vars $ccenv_exvars"); do
|
|
|
519106 |
ccenv_sed_subst=$(printf '%s %s%s%s' \
|
|
|
519106 |
'-e' "'s^@$__var@" \
|
|
|
519106 |
"^___${__var}___" \
|
|
|
519106 |
"^g'")
|
|
|
519106 |
|
|
|
519106 |
ccenv_sed_substs="$ccenv_sed_substs $ccenv_sed_subst"
|
|
|
519106 |
|
|
|
519106 |
ccenv_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "${__var}")
|
|
|
519106 |
eval ccenv_var_defs='"$ccenv_var_defs "$ccenv_var_def'
|
|
|
519106 |
done
|
|
|
ce6529 |
|
|
|
519106 |
eval sed $ccenv_sed_substs $(printf '%s ' $ccenv_in) \
|
|
|
519106 |
| eval m4 $ccenv_var_defs - \
|
|
|
519106 |
| sed -e 's/[[:blank:]]*$//g' \
|
|
|
ce6529 |
> "$ccenv_mk"
|
|
|
ce6529 |
|
|
|
7cb1fe |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
a03255 |
for __var in $(printf '%s' "$ccenv_vars"); do
|
|
|
7cb1fe |
ccenv_src_var=$__var
|
|
|
7cb1fe |
ccenv_dst_var=mb_${__var
|
|
|
7cb1fe |
ccenv_var_expr='${'$ccenv_src_var':-}'
|
|
|
7cb1fe |
eval $ccenv_dst_var=$ccenv_var_expr
|
|
|
7cb1fe |
|
|
|
7cb1fe |
done
|
|
|
7cb1fe |
|
|
|
7cb1fe |
mb_host=$ccenv_host
|
|
|
7cb1fe |
mb_cchost=$ccenv_cchost
|
|
|
7cb1fe |
else
|
|
|
a03255 |
for __var in $(printf '%s' "$ccenv_vars"); do
|
|
|
7cb1fe |
ccenv_src_var=$__var
|
|
|
7cb1fe |
ccenv_dst_var=mb_native_${__var
|
|
|
7cb1fe |
ccenv_var_expr='${'$ccenv_src_var':-}'
|
|
|
7cb1fe |
eval "$ccenv_dst_var=$ccenv_var_expr"
|
|
|
7cb1fe |
done
|
|
|
7cb1fe |
|
|
|
7cb1fe |
mb_native_host=$ccenv_host
|
|
|
7cb1fe |
mb_native_cchost=$ccenv_cchost
|
|
|
7cb1fe |
fi
|
|
|
7efa04 |
|
|
|
7efa04 |
if [ -n "${ccenv_tmp:-}" ]; then
|
|
|
7efa04 |
rm -f "$ccenv_tmp"
|
|
|
7efa04 |
unset ccenv_tmp
|
|
|
7efa04 |
fi
|
|
|
617842 |
|
|
|
e5fd9a |
|
|
|
e5fd9a |
if [ "${ccenv_cfgtype}" = 'host' ]; then
|
|
|
e5fd9a |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .cflags-host)
|
|
|
e5fd9a |
ccenv_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .ldflags-host)
|
|
|
e5fd9a |
else
|
|
|
e5fd9a |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .cflags-native)
|
|
|
e5fd9a |
ccenv_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .ldflags-native)
|
|
|
e5fd9a |
fi
|
|
|
e5fd9a |
|
|
|
e5fd9a |
ccenv_cflags="${ccenv_cflags#*: }"
|
|
|
e5fd9a |
ccenv_ldflags="${ccenv_ldflags#*: }"
|
|
|
e5fd9a |
|
|
|
8917cb |
ccenv_sysroot=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
8917cb |
-print-sysroot 2>/dev/null || true)
|
|
|
8917cb |
|
|
|
e5fd9a |
eval 'ccenv_'${ccenv_cfgtype}'_cflags'=\'$ccenv_cflags\'
|
|
|
e5fd9a |
eval 'ccenv_'${ccenv_cfgtype}'_ldflags'=\'$ccenv_ldflags\'
|
|
|
8917cb |
eval 'ccenv_'${ccenv_cfgtype}'_sysroot'=\'$ccenv_sysroot\'
|
|
|
e5fd9a |
|
|
|
617842 |
eval 'ccenv_'${ccenv_cfgtype}'_cc'=\'$ccenv_cc\'
|
|
|
aafb78 |
eval 'ccenv_'${ccenv_cfgtype}'_cc_environment'=\'$ccenv_cc_environment\'
|
|
|
ebece9 |
eval 'ccenv_'${ccenv_cfgtype}'_dumpmachine_switch'=\'$ccenv_dumpmachine_switch\'
|
|
|
141146 |
eval 'ccenv_'${ccenv_cfgtype}'_pkgconf'=\'$ccenv_pkgconf\'
|
|
|
e5fd9a |
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
982049 |
ccenv_set_cc_sysroot_vars()
|
|
|
982049 |
{
|
|
|
982049 |
if [ "$ccenv_cfgtype" = 'native' ] || [ -z "$mb_sysroot" ]; then
|
|
|
982049 |
return 0
|
|
|
982049 |
fi
|
|
|
982049 |
|
|
|
982049 |
cfgtest_host_section
|
|
|
982049 |
ccenv_switch_var="--sysroot=${mb_sysroot}"
|
|
|
982049 |
|
|
|
982049 |
if cfgtest_compiler_switch_arg "${ccenv_switch_var}"; then
|
|
|
982049 |
printf '\n# %s sysroot: cflags and ldflags\n' "$ccenv_cfgtype" \
|
|
|
982049 |
>> "$ccenv_mk"
|
|
|
982049 |
|
|
|
982049 |
for ccenv_make_var in '_CFLAGS_SYSROOT' '_LDFLAGS_SYSROOT'; do
|
|
|
982049 |
printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
|
|
|
982049 |
>> "$ccenv_mk"
|
|
|
982049 |
done
|
|
|
982049 |
else
|
|
|
982049 |
printf '\n# %s sysroot: cflags and ldflags %s\n' "$ccenv_cfgtype" \
|
|
|
982049 |
'(not supported: see config.log)' \
|
|
|
982049 |
>> "$ccenv_mk"
|
|
|
982049 |
|
|
|
982049 |
for ccenv_make_var in '_CFLAGS_SYSROOT' '_LDFLAGS_SYSROOT'; do
|
|
|
982049 |
printf '%-40s=\n' "${ccenv_make_var}" \
|
|
|
982049 |
>> "$ccenv_mk"
|
|
|
982049 |
done
|
|
|
982049 |
fi
|
|
|
982049 |
}
|
|
|
982049 |
|
|
|
c34014 |
ccenv_set_cc_switch_vars()
|
|
|
c34014 |
{
|
|
|
9b5226 |
printf '\n# %s cflags: supported compiler switches\n' "$ccenv_cfgtype" \
|
|
|
9b5226 |
>> "$ccenv_mk"
|
|
|
9b5226 |
|
|
|
c34014 |
if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
|
|
|
f0d2f0 |
ccenv_switch_vars=$(cat \
|
|
|
c34014 |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
c34014 |
$mb_project_dir/project/config/ccswitch.strs \
|
|
|
f0d2f0 |
| grep -v -e '^#' -e '^-Wl,' \
|
|
|
f0d2f0 |
| sort -u)
|
|
|
c34014 |
else
|
|
|
9cdfeb |
ccenv_switch_vars=$(grep -v -e '^#' -e '^-Wl,' \
|
|
|
c34014 |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
c34014 |
| sort -u)
|
|
|
c34014 |
fi
|
|
|
c34014 |
|
|
|
c34014 |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
c34014 |
ccenv_makevar_prefix='_CFLAGS_'
|
|
|
c34014 |
cfgtest_host_section
|
|
|
c34014 |
else
|
|
|
c34014 |
ccenv_makevar_prefix='_NATIVE_CFLAGS_'
|
|
|
c34014 |
cfgtest_native_section
|
|
|
c34014 |
fi
|
|
|
c34014 |
|
|
|
c34014 |
for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
|
|
|
c34014 |
ccenv_make_var=${ccenv_switch_var%=}
|
|
|
c34014 |
ccenv_make_var=${ccenv_make_var%,}
|
|
|
c34014 |
|
|
|
c34014 |
ccenv_make_var=${ccenv_make_var
|
|
|
c34014 |
ccenv_make_var=${ccenv_make_var
|
|
|
c34014 |
ccenv_make_var=${ccenv_make_var
|
|
|
c34014 |
|
|
|
c34014 |
ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
|
|
|
c34014 |
| sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
|
|
|
c34014 |
|
|
|
c34014 |
ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
|
|
|
c34014 |
|
|
|
c34014 |
if cfgtest_compiler_switch "$ccenv_switch_var"; then
|
|
|
c34014 |
ccenv_switch_var=${ccenv_switch_var%=}
|
|
|
c34014 |
ccenv_switch_var=${ccenv_switch_var%,}
|
|
|
c34014 |
|
|
|
7e50d9 |
printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
|
|
|
c34014 |
>> "$ccenv_mk"
|
|
|
c34014 |
else
|
|
|
7e50d9 |
printf '%-40s=\n' "${ccenv_make_var}" \
|
|
|
c34014 |
>> "$ccenv_mk"
|
|
|
c34014 |
fi
|
|
|
c34014 |
done
|
|
|
c34014 |
}
|
|
|
c34014 |
|
|
|
9cdfeb |
ccenv_set_cc_linker_switch_vars()
|
|
|
9cdfeb |
{
|
|
|
9cdfeb |
printf '\n# %s ldflags: supported compiler switches\n' "$ccenv_cfgtype" \
|
|
|
9cdfeb |
>> "$ccenv_mk"
|
|
|
9cdfeb |
|
|
|
9cdfeb |
if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
|
|
|
f0d2f0 |
ccenv_switch_vars=$(cat \
|
|
|
9cdfeb |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
9cdfeb |
$mb_project_dir/project/config/ccswitch.strs \
|
|
|
f0d2f0 |
| grep -e '^-Wl,' \
|
|
|
9cdfeb |
| sort -u)
|
|
|
9cdfeb |
else
|
|
|
9cdfeb |
ccenv_switch_vars=$(grep -e '^-Wl,' \
|
|
|
9cdfeb |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
9cdfeb |
| sort -u)
|
|
|
9cdfeb |
fi
|
|
|
9cdfeb |
|
|
|
9cdfeb |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
9cdfeb |
ccenv_makevar_prefix='_LDFLAGS_'
|
|
|
9cdfeb |
cfgtest_host_section
|
|
|
9cdfeb |
else
|
|
|
9cdfeb |
ccenv_makevar_prefix='_NATIVE_LDFLAGS_'
|
|
|
9cdfeb |
cfgtest_native_section
|
|
|
9cdfeb |
fi
|
|
|
9cdfeb |
|
|
|
9cdfeb |
for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
|
|
|
9cdfeb |
ccenv_make_var=${ccenv_switch_var%=}
|
|
|
9cdfeb |
ccenv_make_var=${ccenv_make_var%,}
|
|
|
9cdfeb |
|
|
|
9cdfeb |
ccenv_make_var=${ccenv_make_var
|
|
|
9cdfeb |
ccenv_make_var=${ccenv_make_var
|
|
|
9cdfeb |
ccenv_make_var=${ccenv_make_var
|
|
|
9cdfeb |
|
|
|
9cdfeb |
ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
|
|
|
9cdfeb |
| sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
|
|
|
9cdfeb |
|
|
|
9cdfeb |
ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
|
|
|
9cdfeb |
|
|
|
9cdfeb |
if cfgtest_compiler_switch "$ccenv_switch_var"; then
|
|
|
9cdfeb |
ccenv_switch_var=${ccenv_switch_var%=}
|
|
|
9cdfeb |
ccenv_switch_var=${ccenv_switch_var%,}
|
|
|
9cdfeb |
|
|
|
9cdfeb |
printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
|
|
|
9cdfeb |
>> "$ccenv_mk"
|
|
|
9cdfeb |
else
|
|
|
9cdfeb |
printf '%-40s=\n' "${ccenv_make_var}" \
|
|
|
9cdfeb |
>> "$ccenv_mk"
|
|
|
9cdfeb |
fi
|
|
|
9cdfeb |
done
|
|
|
9cdfeb |
}
|
|
|
9cdfeb |
|
|
|
ead578 |
ccenv_dso_verify()
|
|
|
ead578 |
{
|
|
|
ead578 |
ccenv_str='int foo(int x){return ++x;}'
|
|
|
ead578 |
ccenv_cmd="$ccenv_cc -xc - -shared -o a.out"
|
|
|
ead578 |
|
|
|
ead578 |
rm -f a.out
|
|
|
ead578 |
|
|
|
81f346 |
printf '%s' "$ccenv_str" | $(printf %s "$ccenv_cmd") \
|
|
|
2e6edf |
> /dev/null 2>&3 \
|
|
|
ead578 |
|| mb_disable_shared=yes
|
|
|
ead578 |
|
|
|
ead578 |
rm -f a.out
|
|
|
ead578 |
}
|
|
|
ead578 |
|
|
|
ce6529 |
ccenv_clean_up()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
rm -f $ccenv_image
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_common_init()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
. "$mb_project_dir/sofort/ccenv/ccenv.vars"
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_cfgtype=$1
|
|
|
ce6529 |
ccenv_cfgfile="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
|
|
|
1f89c2 |
ccenv_cchost=
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
ce6529 |
ccenv_makevar_prefix='NATIVE_'
|
|
|
ce6529 |
ccenv_image='./ccenv/native.a.out'
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_makevar_prefix=
|
|
|
ce6529 |
ccenv_image='./ccenv/host.a.out'
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
ce6529 |
ccenv_prefixes=
|
|
|
ce6529 |
elif [ -n "$mb_cross_compile" ]; then
|
|
|
ce6529 |
ccenv_prefixes="$mb_cross_compile"
|
|
|
ce6529 |
elif [ -n "$mb_host" ]; then
|
|
|
ce6529 |
ccenv_prefixes="$mb_host-"
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_prefixes=
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
|
|
|
ce6529 |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
ce6529 |
ccenv_tflags=
|
|
|
342e5b |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
|
|
|
5e87b7 |
OS_DSO_EXRULES=default \
|
|
|
5e87b7 |
OS_SONAME=symlink \
|
|
|
3c751e |
OS_ARCHIVE_EXT='.a' \
|
|
|
5e87b7 |
.cflags-host)
|
|
|
0379b6 |
|
|
|
342e5b |
ccenv_cflags="${ccenv_cflags#*: }"
|
|
|
342e5b |
|
|
|
ce6529 |
ccenv_cc="$mb_user_cc"
|
|
|
ce6529 |
ccenv_cpp="$mb_user_cpp"
|
|
|
ce6529 |
ccenv_cxx="$mb_user_cxx"
|
|
|
3b58c7 |
|
|
|
3b58c7 |
ccenv_pe_subsystem="$mb_pe_subsystem"
|
|
|
3b58c7 |
ccenv_pe_image_base="$mb_pe_image_base"
|
|
|
ce6529 |
else
|
|
|
ce6529 |
ccenv_tflags=
|
|
|
342e5b |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
|
|
|
5e87b7 |
OS_DSO_EXRULES=default \
|
|
|
5e87b7 |
OS_SONAME=symlink \
|
|
|
3c751e |
OS_ARCHIVE_EXT='.a' \
|
|
|
5e87b7 |
.cflags-native)
|
|
|
5e87b7 |
|
|
|
342e5b |
ccenv_cflags="${ccenv_cflags#*: }"
|
|
|
342e5b |
|
|
|
ce6529 |
ccenv_cc="$mb_native_cc"
|
|
|
ce6529 |
ccenv_cpp="$mb_native_cpp"
|
|
|
ce6529 |
ccenv_cxx="$mb_native_cxx"
|
|
|
3b58c7 |
|
|
|
3b58c7 |
ccenv_pe_subsystem="$mb_native_pe_subsystem"
|
|
|
3b58c7 |
ccenv_pe_image_base="$mb_native_pe_image_base"
|
|
|
ce6529 |
fi
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_characteristics()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_set_cc_host
|
|
|
ce6529 |
ccenv_set_cc_bits
|
|
|
ce6529 |
ccenv_set_cc_binfmt
|
|
|
fad405 |
ccenv_set_cc_underscore
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_toolchain_variables()
|
|
|
ce6529 |
{
|
|
|
ce6529 |
ccenv_common_init $1
|
|
|
ce6529 |
ccenv_set_cc
|
|
|
ce6529 |
ccenv_set_cpp
|
|
|
ce6529 |
ccenv_set_cxx
|
|
|
ce6529 |
ccenv_set_primary_tools
|
|
|
ce6529 |
ccenv_set_tool_variants
|
|
|
ce6529 |
ccenv_set_characteristics
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_os
|
|
|
ce6529 |
ccenv_set_os_flags
|
|
|
ce6529 |
ccenv_set_os_semantics
|
|
|
bdcaa4 |
ccenv_set_os_dso_format
|
|
|
ce6529 |
ccenv_set_os_dso_exrules
|
|
|
ce6529 |
ccenv_set_os_dso_linkage
|
|
|
ce6529 |
ccenv_set_os_dso_patterns
|
|
|
3b58c7 |
ccenv_set_os_pe_switches
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_output_defs
|
|
|
ce6529 |
ccenv_clean_up
|
|
|
c34014 |
|
|
|
982049 |
ccenv_set_cc_sysroot_vars
|
|
|
c34014 |
ccenv_set_cc_switch_vars
|
|
|
9cdfeb |
ccenv_set_cc_linker_switch_vars
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_host_variables()
|
|
|
ce6529 |
{
|
|
|
fad405 |
output_script_status ${mb_script} \
|
|
|
c5618c |
'detect and query host (targeted) system'
|
|
|
fad405 |
|
|
|
ce6529 |
ccenv_set_toolchain_variables 'host'
|
|
|
ead578 |
ccenv_dso_verify
|
|
|
ce6529 |
}
|
|
|
ce6529 |
|
|
|
ce6529 |
ccenv_set_native_variables()
|
|
|
ce6529 |
{
|
|
|
fad405 |
output_script_status ${mb_script} \
|
|
|
c5618c |
'detect and query native (local build) system'
|
|
|
fad405 |
|
|
|
ea06a1 |
if [ _$mb_ccenv_skip_native != _yes ]; then
|
|
|
ea06a1 |
ccenv_set_toolchain_variables 'native'
|
|
|
ea06a1 |
fi
|
|
|
ce6529 |
}
|