|
|
46447e |
|
|
|
eb4330 |
# ccenv.sh: sofort's tool-finding bits,
|
|
|
eb4330 |
# invoked from within the project-agnostic configure script.
|
|
|
eb4330 |
|
|
|
12fcaa |
# this file is covered by COPYING.SOFORT.
|
|
|
12fcaa |
|
|
|
eb4330 |
# invocation and names of binary tools:
|
|
|
eb4330 |
# agnostic names (ar, nm, objdump, ...);
|
|
|
eb4330 |
# target-prefixed agnostic names (x86_64-nt64-midipix-ar, ...);
|
|
|
eb4330 |
# branded names (llvm-ar, llvm-nm, llvm-objdump, ...);
|
|
|
eb4330 |
# target-prefixed branded names (x86_64-linux-gnu-gcc-ar, ...);
|
|
|
eb4330 |
# target-specifying branded tools (llvm-ar --target=x86_64-linux, ...).
|
|
|
eb4330 |
|
|
|
eb4330 |
# cross-compilation: default search order:
|
|
|
eb4330 |
# target-prefixed agnostic tools;
|
|
|
eb4330 |
# target-prefixed branded tools, starting with the prefix
|
|
|
eb4330 |
# most commonly associated with the selected compiler (that is,
|
|
|
eb4330 |
# ``gcc'' when using gcc, and ``llvm'' when using clang);
|
|
|
eb4330 |
# target-speficying branded tools, starting once again with the
|
|
|
eb4330 |
# prefix most commonly associated with the selected compiler.
|
|
|
eb4330 |
|
|
|
eb4330 |
# internal variables of interest:
|
|
|
eb4330 |
# ccenv_cfgtype: the type of host being tested (host/native)
|
|
|
eb4330 |
# ccenv_cfgfile: the configuration file for the host being tested
|
|
|
eb4330 |
# ccenv_cflags: the comprehensive cflags for the host being tested
|
|
|
eb4330 |
# ccenv_cchost: the host being tested, as reported by -dumpmachine
|
|
|
eb4330 |
|
|
|
46447e |
# variables available to cfgdefs.sh and cfgfini.sh:
|
|
|
46447e |
# ccenv_host_cflags: expanded cflags, valid for the host compiler
|
|
|
46447e |
# ccenv_host_ldflags: expanded ldflags, valid for the host compiler
|
|
|
c6ae3d |
# ccenv_host_sysroot: host sysroot, as reported by the host compiler
|
|
|
46447e |
# ccenv_native_cflags: expanded cflags, valid for the native compiler
|
|
|
46447e |
# ccenv_native_ldflags: expanded ldflags, valid for the native compiler
|
|
|
c6ae3d |
# ccenv_native_sysroot: native sysroot, as reported by the native compiler
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_usage()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
cat "$mb_project_dir"/sofort/ccenv/ccenv.usage
|
|
|
eb4330 |
exit 0
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_newline()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
printf '\n' >> "$ccenv_cfgfile"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_comment()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_internal_str='#'
|
|
|
eb4330 |
|
|
|
eb4330 |
for ccenv_internal_arg ; do
|
|
|
eb4330 |
ccenv_internal_str="$ccenv_internal_str $ccenv_internal_arg"
|
|
|
eb4330 |
done
|
|
|
eb4330 |
|
|
|
eb4330 |
printf '%s\n' "$ccenv_internal_str" >> "$ccenv_cfgfile"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
|
|
|
487309 |
ccenv_tool_prolog()
|
|
|
487309 |
{
|
|
|
e6e220 |
ccenv_line_dots='.....................................'
|
|
|
f520d8 |
ccenv_tool_desc=" == checking for ${1}"
|
|
|
487309 |
ccenv_tool_dlen="${#ccenv_line_dots}"
|
|
|
487309 |
|
|
|
0d8567 |
printf '\n%s\n' '________________________' >&3
|
|
|
0d8567 |
printf "ccenv: checking for ${1}\n\n" >&3
|
|
|
487309 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s" \
|
|
|
e6e220 |
"${ccenv_tool_desc} ${mb_line_dots}"
|
|
|
487309 |
}
|
|
|
487309 |
|
|
|
487309 |
|
|
|
487309 |
ccenv_tool_epilog()
|
|
|
487309 |
{
|
|
|
487309 |
ccenv_line_dots='................................'
|
|
|
487309 |
ccenv_tool_dlen="$((${#ccenv_line_dots} - ${#1}))"
|
|
|
487309 |
|
|
|
197652 |
case ${ccenv_tool_dlen} in
|
|
|
197652 |
0 | -* )
|
|
|
197652 |
ccenv_tool_dlen='3' ;;
|
|
|
197652 |
esac
|
|
|
197652 |
|
|
|
e6e220 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \
|
|
|
487309 |
"${ccenv_line_dots}" "${1}"
|
|
|
0d8567 |
|
|
|
0d8567 |
if [ "${1}" = 'false' ]; then
|
|
|
0d8567 |
printf '\n\nccenv: not (yet) found.\n' >&3
|
|
|
0d8567 |
else
|
|
|
0d8567 |
printf "\n\nccenv : found $(command -v ${1}).\n" >&3
|
|
|
0d8567 |
fi
|
|
|
0d8567 |
|
|
|
0d8567 |
printf '%s\n' '------------------------' >&3
|
|
|
487309 |
}
|
|
|
487309 |
|
|
|
487309 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog()
|
|
|
ed2324 |
{
|
|
|
ed2324 |
ccenv_expr=${1}='${'${1}':-false}'
|
|
|
ed2324 |
eval "$ccenv_expr"
|
|
|
ed2324 |
|
|
|
ed2324 |
ccenv_expr='${'${1}'}'
|
|
|
ed2324 |
eval ccenv_tool_epilog "$ccenv_expr"
|
|
|
ed2324 |
}
|
|
|
ed2324 |
|
|
|
ed2324 |
|
|
|
487309 |
ccenv_attr_prolog()
|
|
|
487309 |
{
|
|
|
e6e220 |
ccenv_line_dots=' .....................................'
|
|
|
e6e220 |
ccenv_attr_desc=" == detect ${ccenv_cfgtype} ${1}"
|
|
|
487309 |
ccenv_attr_dlen="${#ccenv_line_dots}"
|
|
|
487309 |
|
|
|
487309 |
printf "%${ccenv_attr_dlen}.${ccenv_attr_dlen}s" \
|
|
|
487309 |
"${ccenv_attr_desc} ${ccenv_line_dots}"
|
|
|
0d8567 |
|
|
|
0d8567 |
printf '\n%s\n' '________________________' >&3
|
|
|
0d8567 |
printf "ccenv: detecting ${1}\n\n" >&3
|
|
|
487309 |
}
|
|
|
487309 |
|
|
|
487309 |
|
|
|
487309 |
ccenv_attr_epilog()
|
|
|
487309 |
{
|
|
|
0d8567 |
ccenv_line_dots='................................'
|
|
|
e6e220 |
ccenv_tool_dlen="$((${#ccenv_line_dots} - 1 - ${#1}))"
|
|
|
0d8567 |
|
|
|
197652 |
case ${ccenv_tool_dlen} in
|
|
|
197652 |
0 | -* )
|
|
|
197652 |
ccenv_tool_dlen='3' ;;
|
|
|
197652 |
esac
|
|
|
197652 |
|
|
|
e6e220 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \
|
|
|
0d8567 |
"${ccenv_line_dots}" "${1}"
|
|
|
0d8567 |
|
|
|
0d8567 |
printf '\n\nccenv: detected result: %s\n' "${1}" >&3
|
|
|
0d8567 |
printf '%s\n' '------------------------' >&3
|
|
|
487309 |
}
|
|
|
487309 |
|
|
|
487309 |
|
|
|
eb4330 |
ccenv_find_tool()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
if [ -z "$ccenv_prefixes" ]; then
|
|
|
aecab0 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
4d67e0 |
ccenv_cmd_args="${@:-}"
|
|
|
4d67e0 |
|
|
|
4d67e0 |
if [ -z "$ccenv_cmd_args" ]; then
|
|
|
9980ab |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
9980ab |
ccenv_tool="$ccenv_candidate"
|
|
|
fb505a |
return 0
|
|
|
bb3f66 |
fi
|
|
|
fb505a |
else
|
|
|
9980ab |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
0d8567 |
if "$ccenv_candidate" $@ > /dev/null 2>&3; then
|
|
|
9980ab |
ccenv_tool="$ccenv_candidate"
|
|
|
fb505a |
return 0
|
|
|
bb3f66 |
fi
|
|
|
bb3f66 |
fi
|
|
|
fb505a |
fi
|
|
|
eb4330 |
done
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_tool=false
|
|
|
eb4330 |
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
aecab0 |
for ccenv_prefix in $(printf '%s' "$ccenv_prefixes"); do
|
|
|
aecab0 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
eb4330 |
ccenv_tool="$ccenv_prefix$ccenv_candidate"
|
|
|
bb3f66 |
|
|
|
bb3f66 |
if command -v "$ccenv_tool" > /dev/null; then
|
|
|
bb3f66 |
return 0
|
|
|
bb3f66 |
fi
|
|
|
eb4330 |
done
|
|
|
eb4330 |
done
|
|
|
eb4330 |
|
|
|
aecab0 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
9980ab |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
9980ab |
ccenv_tool="$ccenv_candidate"
|
|
|
bb3f66 |
return 0
|
|
|
bb3f66 |
fi
|
|
|
eb4330 |
done
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_tool=false
|
|
|
eb4330 |
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_primary_tools()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_core_tools="ar nm objdump ranlib size strip strings objcopy"
|
|
|
72602c |
ccenv_hack_tools="addr2line cov elfedit readelf readobj otool"
|
|
|
a1f8d4 |
ccenv_peep_tools="perk mdso dlltool windmc windres pkgconf"
|
|
|
eb4330 |
|
|
|
aecab0 |
for __tool in $(printf '%s' "$ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools"); do
|
|
|
487309 |
ccenv_tool_prolog "$__tool"
|
|
|
487309 |
|
|
|
eb4330 |
if [ -n "$mb_agnostic" ]; then
|
|
|
eb4330 |
ccenv_candidates=" $__tool"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ -n "$mb_zealous" ]; then
|
|
|
eb4330 |
ccenv_candidates="$mb_zealous-$__tool"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
eb4330 |
ccenv_candidates="gcc-$__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
eb4330 |
ccenv_candidates="llvm-$__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ -n "$mb_toolchain" ]; then
|
|
|
eb4330 |
ccenv_candidates="$mb_toolchain-$__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
eb4330 |
|
|
|
93a628 |
elif [ "$__tool" = 'pkgconf' ]; then
|
|
|
93a628 |
ccenv_candidates="$__tool pkg-config"
|
|
|
93a628 |
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_candidates="$__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
eb4330 |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
eb4330 |
ccenv_var_prefix='mb_'
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_var_prefix='mb_native_'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
9fb5ee |
ccenv_tool=
|
|
|
eb4330 |
ccenv_var_name=$ccenv_var_prefix$__tool
|
|
|
eb4330 |
ccenv_var_expr='${'$ccenv_var_name':-}'
|
|
|
eb4330 |
eval ccenv_var_val=$ccenv_var_expr
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_var_val" ]; then
|
|
|
eb4330 |
eval ccenv_$__tool="$ccenv_var_val"
|
|
|
9fb5ee |
ccenv_tool="$ccenv_var_val"
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
eval ccenv_$__tool="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
487309 |
|
|
|
487309 |
ccenv_tool_epilog "$ccenv_tool"
|
|
|
eb4330 |
done
|
|
|
eb4330 |
|
|
|
eb4330 |
# windrc
|
|
|
eb4330 |
ccenv_windrc="$ccenv_windres"
|
|
|
320a40 |
|
|
|
320a40 |
# archive format preamble
|
|
|
2737b9 |
if [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
6671d2 |
ccenv_libgcc_path=$($ccenv_cc -print-file-name=libgcc.a \
|
|
|
6671d2 |
2>/dev/null)
|
|
|
6671d2 |
|
|
|
6671d2 |
if [ -n "$ccenv_libgcc_path" ]; then
|
|
|
6671d2 |
ccenv_libgcc_a_header=$(od -b -N8 \
|
|
|
6671d2 |
$($ccenv_cc -print-file-name=libgcc.a) \
|
|
|
6671d2 |
| head -n1)
|
|
|
6671d2 |
else
|
|
|
6671d2 |
ccenv_libgcc_a_header=
|
|
|
6671d2 |
fi
|
|
|
2737b9 |
else
|
|
|
2737b9 |
ccenv_libgcc_a_header=
|
|
|
2737b9 |
fi
|
|
|
2737b9 |
|
|
|
2737b9 |
# ar (default)
|
|
|
320a40 |
ccenv_cc_arfmt='common'
|
|
|
320a40 |
|
|
|
320a40 |
# ar (big)
|
|
|
320a40 |
ccenv_bigaf_header=$(printf '%s\n' '<bigaf>' | od -b | head -n1)
|
|
|
320a40 |
|
|
|
320a40 |
if [ "$ccenv_libgcc_a_header" = "$ccenv_bigaf_header" ]; then
|
|
|
320a40 |
ccenv_cc_arfmt='bigaf'
|
|
|
320a40 |
|
|
|
320a40 |
for __tool in $(printf '%s' "$ccenv_core_tools"); do
|
|
|
320a40 |
ccenv_var_name=ccenv_$__tool
|
|
|
320a40 |
ccenv_var_expr='${'$ccenv_var_name':-}'
|
|
|
320a40 |
eval ccenv_var_val="$ccenv_var_expr"
|
|
|
320a40 |
|
|
|
320a40 |
if [ "$ccenv_var_val" != false ]; then
|
|
|
320a40 |
ccenv_var_val="$ccenv_var_val -X64"
|
|
|
320a40 |
ccenv_var_expr='${ccenv_var_val:-}'
|
|
|
320a40 |
eval ccenv_$__tool="$ccenv_var_expr"
|
|
|
320a40 |
fi
|
|
|
320a40 |
done
|
|
|
320a40 |
fi
|
|
|
320a40 |
|
|
|
320a40 |
# ar (small)
|
|
|
320a40 |
ccenv_aiaff_header=$(printf '%s\n' '<aiaff>' | od -b | head -n1)
|
|
|
320a40 |
|
|
|
320a40 |
if [ "$ccenv_libgcc_a_header" = "$ccenv_aiaff_header" ]; then
|
|
|
320a40 |
ccenv_cc_arfmt='aiaff'
|
|
|
320a40 |
|
|
|
320a40 |
for __tool in $(printf '%s' "$ccenv_core_tools"); do
|
|
|
320a40 |
ccenv_var_name=ccenv_$__tool
|
|
|
320a40 |
ccenv_var_expr='${'$ccenv_var_name':-}'
|
|
|
320a40 |
eval ccenv_var_val="$ccenv_var_expr"
|
|
|
320a40 |
|
|
|
320a40 |
if [ "$ccenv_var_val" != false ]; then
|
|
|
320a40 |
ccenv_var_val="$ccenv_var_val -X32"
|
|
|
320a40 |
ccenv_var_expr='${ccenv_var_val:-}'
|
|
|
320a40 |
eval ccenv_$__tool="$ccenv_var_expr"
|
|
|
320a40 |
fi
|
|
|
320a40 |
done
|
|
|
320a40 |
fi
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_tool_variants()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
# as (asm)
|
|
|
487309 |
ccenv_tool_prolog 'as (asm)'
|
|
|
eb4330 |
ccenv_candidates=as
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" = false ]; then
|
|
|
eb4330 |
ccenv_as_asm=
|
|
|
eb4330 |
else
|
|
|
c780a1 |
$ccenv_tool --help 2>&1 | grep -i '.bc assembler' \
|
|
|
eb4330 |
|| ccenv_as_asm="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_as_asm'
|
|
|
487309 |
|
|
|
eb4330 |
# as (ll)
|
|
|
487309 |
ccenv_tool_prolog 'as (ll)'
|
|
|
eb4330 |
ccenv_candidates=llvm-as
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" != false ]; then
|
|
|
eb4330 |
ccenv_as_ll="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_as_ll'
|
|
|
487309 |
|
|
|
eb4330 |
# as (mc)
|
|
|
487309 |
ccenv_tool_prolog 'as (mc)'
|
|
|
eb4330 |
ccenv_candidates=llvm-mc
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" != false ]; then
|
|
|
eb4330 |
ccenv_as_mc="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_as_mc'
|
|
|
487309 |
|
|
|
eb4330 |
# ld (bfd)
|
|
|
487309 |
ccenv_tool_prolog 'ld (bfd)'
|
|
|
eb4330 |
ccenv_candidates=ld.bfd
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" != false ]; then
|
|
|
eb4330 |
ccenv_ld_bfd="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_ld_bfd'
|
|
|
487309 |
|
|
|
eb4330 |
# ld (gold)
|
|
|
487309 |
ccenv_tool_prolog 'ld (gold)'
|
|
|
eb4330 |
ccenv_candidates=ld.gold
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" != false ]; then
|
|
|
eb4330 |
ccenv_ld_gold="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_ld_gold'
|
|
|
487309 |
|
|
|
eb4330 |
# ld (lld)
|
|
|
487309 |
ccenv_tool_prolog 'ld (lld)'
|
|
|
eb4330 |
ccenv_candidates=lld
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" != false ]; then
|
|
|
eb4330 |
ccenv_ld_lld="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_ld_lld'
|
|
|
487309 |
|
|
|
eb4330 |
# objdump (bfd)
|
|
|
487309 |
ccenv_tool_prolog 'objdump (bfd)'
|
|
|
eb4330 |
ccenv_candidates=objdump
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
c6f04a |
if $ccenv_tool --version | grep -i Binutils > /dev/null; then
|
|
|
c6f04a |
ccenv_objdump_bfd="$ccenv_tool"
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_objdump_bfd'
|
|
|
487309 |
|
|
|
eb4330 |
# objdump (llvm)
|
|
|
487309 |
ccenv_tool_prolog 'objdump (llvm)'
|
|
|
eb4330 |
ccenv_candidates=llvm-objdump
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
c6f04a |
if $ccenv_tool --version | grep -i LLVM > /dev/null; then
|
|
|
c6f04a |
ccenv_objdump_llvm="$ccenv_tool"
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_objdump_llvm'
|
|
|
487309 |
|
|
|
eb4330 |
# readelf (bfd)
|
|
|
487309 |
ccenv_tool_prolog 'readelf (bfd)'
|
|
|
eb4330 |
ccenv_candidates=readelf
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
c6f04a |
if $ccenv_tool --version | grep -i Binutils > /dev/null; then
|
|
|
c6f04a |
ccenv_readelf_bfd="$ccenv_tool"
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_readelf_bfd'
|
|
|
487309 |
|
|
|
eb4330 |
# readelf (llvm)
|
|
|
487309 |
ccenv_tool_prolog 'readelf (llvm)'
|
|
|
eb4330 |
ccenv_candidates=llvm-readelf
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
c6f04a |
if $ccenv_tool --version | grep -i LLVM > /dev/null; then
|
|
|
c6f04a |
ccenv_readelf_llvm="$ccenv_tool"
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
|
|
|
ed2324 |
ccenv_tool_variant_epilog 'ccenv_readelf_llvm'
|
|
|
487309 |
|
|
|
eb4330 |
# as
|
|
|
eb4330 |
if [ -n "$ccenv_cc" ]; then
|
|
|
a0a8cc |
ccenv_as='$('"$ccenv_makevar_prefix"'CC) -c -x assembler'
|
|
|
eb4330 |
elif [ -n "$mb_agnostic" ]; then
|
|
|
eb4330 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
eb4330 |
elif [ "$mb_zealous" = 'gcc' ]; then
|
|
|
eb4330 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
eb4330 |
elif [ -n "$mb_zealous" = 'llvm' ]; then
|
|
|
eb4330 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
|
|
|
eb4330 |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
eb4330 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
eb4330 |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
eb4330 |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# ld
|
|
|
eb4330 |
if [ -n "$ccenv_cc" ]; then
|
|
|
eb4330 |
ccenv_ld='$('"$ccenv_makevar_prefix"'CC) -nostdlib -nostartfiles'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_c_compiler_candidates()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
if [ -n "$mb_compiler" ]; then
|
|
|
eb4330 |
ccenv_candidates="$mb_compiler"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ -n "$mb_agnostic" ]; then
|
|
|
eb4330 |
ccenv_candidates="c99 c11 cc"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ "$mb_zealous" = 'gcc' ]; then
|
|
|
eb4330 |
ccenv_candidates="gcc"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ "$mb_zealous" = 'llvm' ]; then
|
|
|
eb4330 |
ccenv_candidates="clang"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
eb4330 |
ccenv_candidates="gcc c99 c11 cc clang"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
eb4330 |
ccenv_candidates="clang c99 c11 cc gcc"
|
|
|
eb4330 |
|
|
|
eb4330 |
elif [ -n "$mb_toolchain" ]; then
|
|
|
eb4330 |
ccenv_candidates="$mb_toolchain c99 c11 cc gcc clang"
|
|
|
eb4330 |
|
|
|
eb4330 |
else
|
|
|
a16b01 |
ccenv_candidates="cc gcc clang c99 c11"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_cc()
|
|
|
eb4330 |
{
|
|
|
487309 |
ccenv_tool_prolog 'C compiler'
|
|
|
487309 |
|
|
|
eb4330 |
if [ -z "$ccenv_cc" ]; then
|
|
|
eb4330 |
ccenv_set_c_compiler_candidates
|
|
|
2737b9 |
ccenv_find_tool
|
|
|
eb4330 |
ccenv_cc="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
2737b9 |
|
|
|
eb4330 |
if [ "$ccenv_cc" = false ] && [ -n "$mb_compiler" ]; then
|
|
|
eb4330 |
ccenv_cc="$mb_compiler"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
2737b9 |
ccenv_tool_epilog "$ccenv_cc"
|
|
|
2737b9 |
|
|
|
2737b9 |
|
|
|
2737b9 |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
2737b9 |
ccenv_host_cc="$ccenv_cc"
|
|
|
2737b9 |
cfgtest_host_section
|
|
|
2737b9 |
ccenv_host_cc=
|
|
|
2737b9 |
else
|
|
|
2737b9 |
ccenv_native_cc="$ccenv_cc"
|
|
|
2737b9 |
cfgtest_native_section
|
|
|
2737b9 |
ccenv_native_cc=
|
|
|
2737b9 |
fi
|
|
|
2737b9 |
|
|
|
ab3d17 |
cfgtest_silent='yes'
|
|
|
ab3d17 |
|
|
|
2737b9 |
if cfgtest_compiler_switch -dumpmachine ; then
|
|
|
2737b9 |
ccenv_dumpmachine_switch='-dumpmachine'
|
|
|
2737b9 |
else
|
|
|
2737b9 |
ccenv_dumpmachine_switch=
|
|
|
2737b9 |
fi
|
|
|
2737b9 |
|
|
|
bab003 |
if cfgtest_code_snippet_asm 'typedef int dummy;' ; then
|
|
|
bab003 |
eval ccenv_${ccenv_cfgtype}_stdin_input='yes'
|
|
|
bab003 |
else
|
|
|
bab003 |
eval ccenv_${ccenv_cfgtype}_stdin_input='no'
|
|
|
bab003 |
fi
|
|
|
bab003 |
|
|
|
ab3d17 |
unset cfgtest_silent
|
|
|
ab3d17 |
|
|
|
eb4330 |
ccenv_cc_cmd="$ccenv_cc"
|
|
|
c519de |
ccenv_errors=
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_cfgtype" = 'native' ]; then
|
|
|
518f6f |
ccenv_host=
|
|
|
518f6f |
|
|
|
829bd8 |
if [ -n "$mb_native_host" ]; then
|
|
|
829bd8 |
ccenv_host="$mb_native_host"
|
|
|
829bd8 |
|
|
|
829bd8 |
elif [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
2737b9 |
ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
2737b9 |
$ccenv_dumpmachine_switch 2>&3)
|
|
|
518f6f |
|
|
|
518f6f |
elif command -v slibtool > /dev/null 2>&1; then
|
|
|
000a6d |
ccenv=$(slibtool --dumpmachine 2>/dev/null || true)
|
|
|
518f6f |
fi
|
|
|
518f6f |
|
|
|
518f6f |
if [ -z "$ccenv_host" ]; then
|
|
|
829bd8 |
ccenv_machine=$(uname -m 2>/dev/null)
|
|
|
829bd8 |
ccenv_system=$(uname -s 2>/dev/null)
|
|
|
829bd8 |
|
|
|
829bd8 |
ccenv_machine="${ccenv_machine:-unknown}"
|
|
|
829bd8 |
ccenv_system="${ccenv_system:-anyos}"
|
|
|
829bd8 |
|
|
|
829bd8 |
ccenv_host=$(printf '%s' "${ccenv_machine}-unknown-${ccenv_system}" \
|
|
|
e891ac |
| tr '[[:upper:]]' '[[:lower:]]')
|
|
|
2737b9 |
fi
|
|
|
2737b9 |
|
|
|
ec706e |
ccenv_cchost=$ccenv_host
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
2737b9 |
|
|
|
eb4330 |
if [ -n "$mb_cchost" ]; then
|
|
|
eb4330 |
ccenv_host="$mb_cchost"
|
|
|
eb4330 |
elif [ -n "$mb_host" ]; then
|
|
|
eb4330 |
ccenv_host="$mb_host"
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_host=
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
2737b9 |
if [ -z "$ccenv_host" ] && [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
2737b9 |
ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
2737b9 |
$ccenv_dumpmachine_switch 2>&3)
|
|
|
eb4330 |
ccenv_cchost=$ccenv_host
|
|
|
2737b9 |
|
|
|
2737b9 |
elif [ -z "$ccenv_host" ]; then
|
|
|
518f6f |
# no -dumpmachine support and no --host argument implies native build
|
|
|
518f6f |
if command -v slibtool > /dev/null 2>&1; then
|
|
|
000a6d |
ccenv=$(slibtool --dumpmachine 2>/dev/null || true)
|
|
|
518f6f |
fi
|
|
|
829bd8 |
|
|
|
518f6f |
if [ -z "$ccenv_host" ]; then
|
|
|
518f6f |
ccenv_machine=$(uname -m 2>/dev/null)
|
|
|
518f6f |
ccenv_system=$(uname -s 2>/dev/null)
|
|
|
518f6f |
|
|
|
518f6f |
ccenv_machine="${ccenv_machine:-unknown}"
|
|
|
518f6f |
ccenv_system="${ccenv_system:-anyos}"
|
|
|
829bd8 |
|
|
|
518f6f |
ccenv_host=$(printf '%s' "${ccenv_machine}-unknown-${ccenv_system}" \
|
|
|
518f6f |
| tr '[[:upper:]]' '[[:lower:]]')
|
|
|
518f6f |
fi
|
|
|
829bd8 |
|
|
|
2737b9 |
ccenv_cchost=$ccenv_host
|
|
|
2737b9 |
|
|
|
2737b9 |
elif [ -n "$ccenv_dumpmachine_switch" ]; then
|
|
|
1ea231 |
ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
|
|
|
eb4330 |
ccenv_cmd="$ccenv_cc --target=$ccenv_host -E -xc -"
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "$mb_user_cc" ]; then
|
|
|
4da44e |
$(printf %s "$ccenv_cmd") < /dev/null > /dev/null \
|
|
|
eb4330 |
2>"$ccenv_tmp" || true
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_errors=$(cat "$ccenv_tmp")
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "$ccenv_errors" ]; then
|
|
|
2737b9 |
ccenv_tool_prolog 'C compiler for host'
|
|
|
eb4330 |
ccenv_tflags="--target=$ccenv_host"
|
|
|
eb4330 |
ccenv_cc="$ccenv_cc $ccenv_tflags"
|
|
|
2737b9 |
ccenv_tool_epilog "$ccenv_cc"
|
|
|
0d8567 |
else
|
|
|
0d8567 |
printf '%s' "$ccenv_errors" >&3
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
1ea231 |
rm -f "$ccenv_tmp"
|
|
|
1ea231 |
unset ccenv_tmp
|
|
|
1ea231 |
|
|
|
2737b9 |
ccenv_cchost=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
2737b9 |
$ccenv_dumpmachine_switch 2>&3)
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
938d0a |
if [ -z "$ccenv_dumpmachine_switch" ] && [ -n "$ccenv_host" ]; then
|
|
|
938d0a |
ccenv_cchost="$ccenv_host"
|
|
|
938d0a |
|
|
|
938d0a |
elif [ "$ccenv_cchost" != "$ccenv_host" ]; then
|
|
|
0d8567 |
printf 'error!\n' >&2
|
|
|
eb4330 |
printf 'ccenv:\n' >&2
|
|
|
eb4330 |
printf 'ccenv: ccenv_host: %s \n' $ccenv_host >&2
|
|
|
eb4330 |
printf 'ccenv: ccenv_cchost: %s \n' $ccenv_cchost >&2
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "$ccenv_tflags" ]; then
|
|
|
eb4330 |
printf 'ccenv:\n' >&2
|
|
|
eb4330 |
printf 'ccenv: ccenv_host and ccenv_cchost do not match, most likely because:\n' >&2
|
|
|
eb4330 |
printf 'ccenv: (1) you explicitly set CC (or passed --compiler=...)\n' >&2
|
|
|
eb4330 |
printf 'ccenv: (2) the selected compiler does not accept --target=...\n' >&2
|
|
|
eb4330 |
printf 'ccenv: (3) the host reported by -dumpmachine differs from the one you requested.\n' >&2
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_errors" ]; then
|
|
|
eb4330 |
printf 'ccenv:\n' >&2
|
|
|
eb4330 |
printf 'ccenv: something went wrong, see the command and compiler message below.\n\n' >&2
|
|
|
eb4330 |
printf 'cmd: %s < /dev/null > /dev/null\n' "$ccenv_cmd" >&2
|
|
|
eb4330 |
printf '%s\n\n' "$ccenv_errors" >&2
|
|
|
eb4330 |
else
|
|
|
eb4330 |
printf 'ccenv:\n' >&2
|
|
|
eb4330 |
printf 'ccenv: something went wrong, bailing out.\n\n' >&2
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
return 2
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_cpp()
|
|
|
eb4330 |
{
|
|
|
487309 |
ccenv_tool_prolog 'C pre-processor'
|
|
|
487309 |
|
|
|
eb4330 |
case "$ccenv_cc_cmd" in
|
|
|
eb4330 |
cc | c99 | c11 | gcc)
|
|
|
eb4330 |
ccenv_cpp_prefix=
|
|
|
eb4330 |
ccenv_candidates="cpp" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
clang )
|
|
|
eb4330 |
ccenv_cpp_prefix=
|
|
|
eb4330 |
ccenv_candidates="clang-cpp" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
*-cc )
|
|
|
eb4330 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-cc*}-
|
|
|
eb4330 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
*-c99 )
|
|
|
eb4330 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-c99*}-
|
|
|
eb4330 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
*-c11 )
|
|
|
eb4330 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-c11*}-
|
|
|
eb4330 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
*-gcc )
|
|
|
eb4330 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
|
|
|
eb4330 |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
*-clang )
|
|
|
eb4330 |
ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
|
|
|
eb4330 |
ccenv_candidates="${ccenv_cpp_prefix}clang-cpp" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
* )
|
|
|
eb4330 |
ccenv_cpp="$ccenv_cc -E"
|
|
|
487309 |
ccenv_tool_epilog "$ccenv_cpp"
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" = false ]; then
|
|
|
eb4330 |
ccenv_cpp="$ccenv_cc -E"
|
|
|
eb4330 |
elif [ -n "$ccenv_tflags" ]; then
|
|
|
eb4330 |
ccenv_cpp="$ccenv_tool $ccenv_tflags"
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_cpp="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
487309 |
|
|
|
487309 |
ccenv_tool_epilog "$ccenv_cpp"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_cxx()
|
|
|
eb4330 |
{
|
|
|
487309 |
ccenv_tool_prolog 'C++ compiler'
|
|
|
487309 |
|
|
|
eb4330 |
case "$ccenv_cc_cmd" in
|
|
|
eb4330 |
cc | c99 | c11 )
|
|
|
eb4330 |
ccenv_cxx_prefix=
|
|
|
eb4330 |
ccenv_candidates="cxx c++" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
gcc )
|
|
|
eb4330 |
ccenv_cxx_prefix=
|
|
|
eb4330 |
ccenv_candidates="g++" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
clang )
|
|
|
eb4330 |
ccenv_cxx_prefix=
|
|
|
eb4330 |
ccenv_candidates="clang++" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
*-gcc )
|
|
|
44d4bf |
ccenv_cxx_prefix=${ccenv_cc_cmd%-gcc*}-
|
|
|
44d4bf |
ccenv_candidates="${ccenv_cxx_prefix}g++" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
*-clang )
|
|
|
44d4bf |
ccenv_cxx_prefix=${ccenv_cc_cmd%-clang*}-
|
|
|
44d4bf |
ccenv_candidates="${ccenv_cxx_prefix}clang++" ;;
|
|
|
44d4bf |
|
|
|
44d4bf |
/*cc | /*c99 | /*c11 )
|
|
|
44d4bf |
ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
|
|
|
44d4bf |
ccenv_candidates="${ccenv_cxx_prefix}/cxx"
|
|
|
44d4bf |
ccenv_candidates="${ccenv_candidates} ${ccenv_cxx_prefix}/c++" ;;
|
|
|
44d4bf |
|
|
|
44d4bf |
/*gcc )
|
|
|
44d4bf |
ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
|
|
|
44d4bf |
ccenv_candidates="${ccenv_cxx_prefix}/g++" ;;
|
|
|
eb4330 |
|
|
|
44d4bf |
/*clang )
|
|
|
44d4bf |
ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
|
|
|
44d4bf |
ccenv_candidates="${ccenv_cxx_prefix}/clang++" ;;
|
|
|
eb4330 |
|
|
|
eb4330 |
* )
|
|
|
eb4330 |
ccenv_cxx="$ccenv_cc -xc++"
|
|
|
487309 |
ccenv_tool_epilog "$ccenv_cxx"
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_find_tool
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ "$ccenv_tool" = false ]; then
|
|
|
eb4330 |
ccenv_cxx="$ccenv_cc -xc++"
|
|
|
eb4330 |
elif [ -n "$ccenv_tflags" ]; then
|
|
|
eb4330 |
ccenv_cxx="$ccenv_tool $ccenv_tflags"
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_cxx="$ccenv_tool"
|
|
|
eb4330 |
fi
|
|
|
487309 |
|
|
|
487309 |
ccenv_tool_epilog "$ccenv_cxx"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_cc_host()
|
|
|
eb4330 |
{
|
|
|
0e4b02 |
ccenv_attr_prolog 'system'
|
|
|
eb4330 |
ccenv_cc_host="$ccenv_cchost"
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_cc_host"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_cc_bits()
|
|
|
eb4330 |
{
|
|
|
487309 |
ccenv_attr_prolog 'bits'
|
|
|
487309 |
|
|
|
eb4330 |
ccenv_internal_size=
|
|
|
eb4330 |
ccenv_internal_type='void *'
|
|
|
eb4330 |
ccenv_internal_test='char x[(sizeof(%s) == %s/8) ? 1 : -1];'
|
|
|
eb4330 |
|
|
|
eb4330 |
for ccenv_internal_guess in 64 32 128; do
|
|
|
15e4c2 |
if [ -z "${ccenv_internal_size:-}" ]; then
|
|
|
409f71 |
ccenv_internal_str=$(printf "$ccenv_internal_test" \
|
|
|
409f71 |
"$ccenv_internal_type" \
|
|
|
eb4330 |
"$ccenv_internal_guess")
|
|
|
eb4330 |
|
|
|
71c4ec |
ccenv_expr='ccenv_stdin_input=$ccenv_'${ccenv_cfgtype}'_stdin_input'
|
|
|
71c4ec |
eval ${ccenv_expr}
|
|
|
71c4ec |
|
|
|
71c4ec |
if [ "$ccenv_stdin_input" = 'yes' ]; then
|
|
|
351cc6 |
printf '%s' "$ccenv_internal_str" \
|
|
|
351cc6 |
| eval $ccenv_cc -S -xc - -o - \
|
|
|
351cc6 |
$(printf '%s' "$ccenv_cflags") \
|
|
|
351cc6 |
> /dev/null 2>&3 \
|
|
|
351cc6 |
&& ccenv_internal_size=$ccenv_internal_guess
|
|
|
351cc6 |
else
|
|
|
351cc6 |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
351cc6 |
|
|
|
351cc6 |
printf '%s' "$ccenv_internal_str" \
|
|
|
351cc6 |
> "$ccenv_tmpname"
|
|
|
351cc6 |
|
|
|
351cc6 |
$ccenv_cc -c "$ccenv_tmpname" -o a.out \
|
|
|
351cc6 |
> /dev/null 2>&3 \
|
|
|
351cc6 |
&& ccenv_internal_size=$ccenv_internal_guess
|
|
|
351cc6 |
|
|
|
351cc6 |
rm "$ccenv_tmpname"
|
|
|
351cc6 |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
done
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_cc_bits=$ccenv_internal_size
|
|
|
487309 |
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_cc_bits"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_cc_underscore()
|
|
|
eb4330 |
{
|
|
|
487309 |
ccenv_attr_prolog 'prepended underscores'
|
|
|
487309 |
|
|
|
eb4330 |
ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe'
|
|
|
eb4330 |
ccenv_fn_code='int %s(void){return 0;}'
|
|
|
eb4330 |
|
|
|
d0def7 |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
d0def7 |
|
|
|
d0def7 |
printf "$ccenv_fn_code" $ccenv_fn_name \
|
|
|
d0def7 |
> "$ccenv_tmpname"
|
|
|
d0def7 |
|
|
|
d0def7 |
$ccenv_cc -c "$ccenv_tmpname" -o a.out \
|
|
|
d0def7 |
> /dev/null 2>&3
|
|
|
d0def7 |
|
|
|
d0def7 |
if "$ccenv_nm" a.out | grep \
|
|
|
d0def7 |
-e "^_$ccenv_fn_name" \
|
|
|
d0def7 |
-e " _$ccenv_fn_name" \
|
|
|
d0def7 |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_underscore='_'
|
|
|
487309 |
ccenv_attr_epilog 'yes'
|
|
|
d0def7 |
else
|
|
|
d0def7 |
ccenv_attr_epilog 'no'
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
|
|
|
d0def7 |
rm "$ccenv_tmpname"
|
|
|
d0def7 |
rm a.out
|
|
|
487309 |
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_create_framework_executable()
|
|
|
eb4330 |
{
|
|
|
9dff60 |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
9dff60 |
if [ "$mb_freestanding" = 'yes' ]; then
|
|
|
9dff60 |
return 1
|
|
|
9dff60 |
fi
|
|
|
9dff60 |
fi
|
|
|
9dff60 |
|
|
|
eb4330 |
if [ -f $ccenv_image ]; then
|
|
|
eb4330 |
mv $ccenv_image $ccenv_image.tmp
|
|
|
eb4330 |
rm -f $ccenv_image.tmp
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
81feac |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
81feac |
|
|
|
eb4330 |
printf 'int main(void){return 0;}' \
|
|
|
81feac |
> "$ccenv_tmpname"
|
|
|
eb4330 |
|
|
|
81feac |
if $ccenv_cc "$ccenv_tmpname" -o $ccenv_image 2>&3; then
|
|
|
81feac |
ccenv_ret=0
|
|
|
9dff60 |
ccenv_cc_environment='hosted'
|
|
|
81feac |
else
|
|
|
81feac |
ccenv_ret=1
|
|
|
81feac |
fi
|
|
|
81feac |
|
|
|
81feac |
rm "$ccenv_tmpname"
|
|
|
81feac |
|
|
|
81feac |
return $ccenv_ret
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_create_freestanding_executable()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
if [ -f $ccenv_image ]; then
|
|
|
eb4330 |
mv $ccenv_image $ccenv_image.tmp
|
|
|
eb4330 |
rm -f $ccenv_image.tmp
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "ccenv_cc_underscore" ]; then
|
|
|
eb4330 |
ccenv_start_fn='_start'
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_start_fn='start'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
81feac |
ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
|
|
|
eb4330 |
|
|
|
81feac |
printf 'int %s(void){return 0;}' "$ccenv_start_fn" \
|
|
|
81feac |
> "$ccenv_tmpname"
|
|
|
eb4330 |
|
|
|
81feac |
if $ccenv_cc "$ccenv_tmpname" \
|
|
|
81feac |
-ffreestanding \
|
|
|
81feac |
-nostdlib -nostartfiles \
|
|
|
81feac |
-o $ccenv_image \
|
|
|
81feac |
2>&3; then
|
|
|
81feac |
ccenv_ret=0
|
|
|
9dff60 |
ccenv_cc_environment='freestanding'
|
|
|
81feac |
else
|
|
|
81feac |
ccenv_ret=1
|
|
|
81feac |
fi
|
|
|
81feac |
|
|
|
81feac |
rm "$ccenv_tmpname"
|
|
|
81feac |
|
|
|
81feac |
return $ccenv_ret
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
487309 |
ccenv_set_cc_binfmt_error()
|
|
|
487309 |
{
|
|
|
487309 |
ccenv_attr_epilog '(unable to create executable)'
|
|
|
487309 |
}
|
|
|
487309 |
|
|
|
eb4330 |
ccenv_set_cc_binfmt()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_use_perk=
|
|
|
72602c |
ccenv_use_otool=
|
|
|
eb4330 |
ccenv_use_readelf=
|
|
|
eb4330 |
ccenv_use_readobj=
|
|
|
eb4330 |
ccenv_use_bfd_objdump=
|
|
|
eb4330 |
ccenv_use_llvm_objdump=
|
|
|
eb4330 |
|
|
|
487309 |
ccenv_attr_prolog 'binary format'
|
|
|
487309 |
|
|
|
eb4330 |
ccenv_create_framework_executable \
|
|
|
eb4330 |
|| ccenv_create_freestanding_executable \
|
|
|
487309 |
|| ccenv_set_cc_binfmt_error \
|
|
|
eb4330 |
|| return 0
|
|
|
eb4330 |
|
|
|
eb4330 |
# PE / perk
|
|
|
eb4330 |
if [ -n "$ccenv_perk" ]; then
|
|
|
0d8567 |
if $ccenv_perk $ccenv_image 2>&3; then
|
|
|
c6f04a |
ccenv_cc_binfmt='PE'
|
|
|
c6f04a |
ccenv_use_perk=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# ELF / readelf
|
|
|
eb4330 |
if [ -n "$ccenv_readelf" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_readelf -h $ccenv_image 2>&3 \
|
|
|
c6f04a |
| grep 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
c6f04a |
| grep 'Magic:7f454c46' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='ELF'
|
|
|
c6f04a |
ccenv_use_readelf=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# a marble of astonishing design:
|
|
|
eb4330 |
# llvm-readelf also parses PE and Mach-O
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_readelf_llvm" ]; then
|
|
|
eb4330 |
ccenv_readany="$ccenv_readelf_llvm"
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_readany="$ccenv_readelf"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# PE / readelf
|
|
|
eb4330 |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_readany -h $ccenv_image 2>&3 \
|
|
|
c6f04a |
| grep 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
c6f04a |
| grep 'Magic:MZ' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='PE'
|
|
|
c6f04a |
ccenv_use_readelf=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
72602c |
# MACHO-64 / otool
|
|
|
72602c |
if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_otool -hv $ccenv_image 2>&3 \
|
|
|
c6f04a |
| grep -i 'MH_MAGIC_64' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='MACHO'
|
|
|
c6f04a |
ccenv_use_otool=yes
|
|
|
c6f04a |
fi
|
|
|
72602c |
fi
|
|
|
72602c |
|
|
|
72602c |
# MACHO-32 / otool
|
|
|
72602c |
if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_otool -hv $ccenv_image 2>&3 \
|
|
|
c6f04a |
| grep -i 'MH_MAGIC' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='MACHO'
|
|
|
c6f04a |
ccenv_use_otool=yes
|
|
|
c6f04a |
fi
|
|
|
72602c |
fi
|
|
|
72602c |
|
|
|
eb4330 |
# MACHO-64 / readelf
|
|
|
eb4330 |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_readany -h $ccenv_image 2>&3 \
|
|
|
c6f04a |
| grep -i 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
c6f04a |
| grep -i '(0xfeedfacf)' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='MACHO'
|
|
|
c6f04a |
ccenv_use_readelf=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# MACHO-32 / readelf
|
|
|
eb4330 |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_readany -h $ccenv_image 2>&3 \
|
|
|
c6f04a |
| grep -i 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
c6f04a |
| grep -i '(0xcafebabe)' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='MACHO'
|
|
|
c6f04a |
ccenv_use_readelf=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# MACHO / readobj
|
|
|
eb4330 |
if [ -n "$ccenv_readobj" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_readobj $ccenv_image 2>&3 \
|
|
|
499abd |
| grep -i 'Format:' \
|
|
|
499abd |
| sed -e 's/ /_/g' \
|
|
|
c6f04a |
| grep -i '_Mach-O_' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='MACHO'
|
|
|
c6f04a |
ccenv_use_readobj=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# MACHO / objdump (llvm)
|
|
|
eb4330 |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
c6f04a |
if $ccenv_objdump -section-headers $ccenv_image \
|
|
|
0d8567 |
2>&3 \
|
|
|
c6f04a |
| grep -i 'file format Mach-O' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='MACHO'
|
|
|
c6f04a |
ccenv_use_objdump=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# MACHO / objdump (bfd)
|
|
|
eb4330 |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
$ccenv_objdump -h $ccenv_image 2>&3 \
|
|
|
eb4330 |
| grep -i 'file format Mach-O' \
|
|
|
eb4330 |
> /dev/null \
|
|
|
eb4330 |
&& ccenv_cc_binfmt='MACHO' \
|
|
|
eb4330 |
&& ccenv_use_objdump=yes
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
# PE / objdump (bfd)
|
|
|
eb4330 |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
0d8567 |
if $ccenv_objdump -h $ccenv_image 2>&3 \
|
|
|
c6f04a |
| grep -i 'file format pei-' \
|
|
|
c6f04a |
> /dev/null; then
|
|
|
c6f04a |
ccenv_cc_binfmt='PE'
|
|
|
c6f04a |
ccenv_use_bfd_objdump=yes
|
|
|
c6f04a |
fi
|
|
|
eb4330 |
fi
|
|
|
487309 |
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_cc_binfmt"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_pe()
|
|
|
eb4330 |
{
|
|
|
9dff60 |
if [ "$ccenv_cc_environment" = 'freestanding' ]; then
|
|
|
eb4330 |
case "$ccenv_cchost" in
|
|
|
eb4330 |
*-midipix | *-midipix-* )
|
|
|
eb4330 |
ccenv_os='midipix' ;;
|
|
|
eb4330 |
*-mingw | *-mingw32 | *-mingw64 )
|
|
|
eb4330 |
ccenv_os='mingw' ;;
|
|
|
eb4330 |
*-mingw-* | *-mingw32-* | *-mingw64 )
|
|
|
eb4330 |
ccenv_os='mingw' ;;
|
|
|
eb4330 |
*-msys | *-msys2 | *-msys-* | *-msys2-* )
|
|
|
eb4330 |
ccenv_os='msys' ;;
|
|
|
eb4330 |
*-cygwin | *-cygwin-* )
|
|
|
eb4330 |
ccenv_os='cygwin' ;;
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_os" ]; then
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_use_perk" ]; then
|
|
|
eb4330 |
ccenv_framework=$($ccenv_perk -y $ccenv_image)
|
|
|
eb4330 |
ccenv_os=${ccenv_framework#*-*-*-*}
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
eb4330 |
$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
|
|
|
eb4330 |
| grep 'cygwin1.dll' > /dev/null \
|
|
|
eb4330 |
&& ccenv_os='cygwin'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
eb4330 |
$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
|
|
|
eb4330 |
| grep 'msys-2.0.dll' > /dev/null \
|
|
|
eb4330 |
&& ccenv_os='msys'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
eb4330 |
$ccenv_objdump_bfd -x $ccenv_image \
|
|
|
eb4330 |
| grep -i 'DLL Name' | grep '.CRT' \
|
|
|
eb4330 |
> /dev/null \
|
|
|
eb4330 |
&& $ccenv_objdump_bfd -x $ccenv_image \
|
|
|
eb4330 |
| grep -i 'DLL Name' | grep '.bss' \
|
|
|
eb4330 |
> /dev/null \
|
|
|
eb4330 |
&& $ccenv_objdump_bfd -x $ccenv_image \
|
|
|
eb4330 |
| grep -i 'DLL Name' | grep '.tls' \
|
|
|
eb4330 |
> /dev/null \
|
|
|
eb4330 |
&& ccenv_os='mingw'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_macho()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
case "$ccenv_cchost" in
|
|
|
eb4330 |
*-apple-darwin* )
|
|
|
eb4330 |
ccenv_os='darwin' ;;
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os()
|
|
|
eb4330 |
{
|
|
|
487309 |
ccenv_attr_prolog 'os name'
|
|
|
487309 |
|
|
|
eb4330 |
case "$ccenv_cc_binfmt" in
|
|
|
eb4330 |
PE )
|
|
|
eb4330 |
ccenv_set_os_pe ;;
|
|
|
eb4330 |
MACHO )
|
|
|
eb4330 |
ccenv_set_os_macho ;;
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_os" ]; then
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_os"
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
case "$ccenv_cchost" in
|
|
|
eb4330 |
*-*-*-* )
|
|
|
c6a6d5 |
ccenv_tip=${ccenv_cchost%-*}
|
|
|
eb4330 |
ccenv_os=${ccenv_tip#*-*-}
|
|
|
eb4330 |
;;
|
|
|
c6a6d5 |
*-*-musl | *-*-gnu )
|
|
|
c6a6d5 |
ccenv_tip=${ccenv_cchost%-*}
|
|
|
eb4330 |
ccenv_os=${ccenv_tip#*-}
|
|
|
eb4330 |
;;
|
|
|
c6a6d5 |
*-*-* )
|
|
|
c6a6d5 |
ccenv_os=${ccenv_cchost#*-*-}
|
|
|
c6a6d5 |
;;
|
|
|
c6a6d5 |
*-* )
|
|
|
c6a6d5 |
ccenv_os=${ccenv_cchost#*-}
|
|
|
c6a6d5 |
;;
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -z "$ccenv_os" ]; then
|
|
|
eb4330 |
ccenv_os='anyos'
|
|
|
eb4330 |
fi
|
|
|
487309 |
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_os"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_flags()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
case "$ccenv_os" in
|
|
|
eb4330 |
darwin )
|
|
|
eb4330 |
ccenv_cflags_os='-D_DARWIN_C_SOURCE'
|
|
|
eb4330 |
ccenv_cflags_pic='-fPIC'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
midipix )
|
|
|
eb4330 |
ccenv_cflags_os=
|
|
|
eb4330 |
ccenv_cflags_pic='-fPIC'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
cygwin )
|
|
|
eb4330 |
ccenv_cflags_os=
|
|
|
eb4330 |
ccenv_cflags_pic=
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
msys | msys* | mingw | mingw* )
|
|
|
eb4330 |
ccenv_cflags_os='-U__STRICT_ANSI__'
|
|
|
eb4330 |
ccenv_cflags_pic=
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
* )
|
|
|
eb4330 |
ccenv_cflags_os=
|
|
|
eb4330 |
ccenv_cflags_pic='-fPIC'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_semantics()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
# binary_format - core_api - ex_api - dependency_resolution
|
|
|
eb4330 |
|
|
|
487309 |
ccenv_attr_prolog 'os semantics'
|
|
|
487309 |
|
|
|
eb4330 |
case "$ccenv_os" in
|
|
|
eb4330 |
linux )
|
|
|
eb4330 |
ccenv_os_semantics='elf-posix-linux-ldso'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
bsd )
|
|
|
eb4330 |
ccenv_os_semantics='elf-posix-bsd-ldso'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
darwin )
|
|
|
eb4330 |
ccenv_os_semantics='macho-posix-osx-ldso'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
midipix )
|
|
|
eb4330 |
ccenv_os_semantics='pe-posix-winnt-ldso'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
cygwin )
|
|
|
eb4330 |
ccenv_os_semantics='pe-hybrid-winnt-unsafe'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
msys )
|
|
|
eb4330 |
ccenv_os_semantics='pe-hybrid-winnt-unsafe'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
mingw )
|
|
|
eb4330 |
ccenv_os_semantics='pe-win32-winnt-unsafe'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_os_semantics" ]; then
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_os_semantics"
|
|
|
eb4330 |
return 0
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ -n "$ccenv_cc_binfmt" ]; then
|
|
|
eb4330 |
ccenv_os_semantics_pattern='%s-posix-anyos-unknown'
|
|
|
eb4330 |
ccenv_os_semantics=$(printf \
|
|
|
eb4330 |
"$ccenv_os_semantics_pattern" \
|
|
|
eb4330 |
"$ccenv_cc_binfmt" \
|
|
|
eb4330 |
| tr '[:upper:]' '[:lower:]')
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_os_semantics='unknown-posix-anyos-unknown'
|
|
|
eb4330 |
fi
|
|
|
487309 |
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_os_semantics"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
95c797 |
ccenv_set_os_dso_format()
|
|
|
95c797 |
{
|
|
|
95c797 |
ccenv_attr_prolog 'os dso format'
|
|
|
95c797 |
|
|
|
95c797 |
case "$ccenv_cc_arfmt" in
|
|
|
95c797 |
common )
|
|
|
95c797 |
ccenv_cc_sofmt="$ccenv_cc_binfmt"
|
|
|
95c797 |
;;
|
|
|
95c797 |
|
|
|
95c797 |
bigaf )
|
|
|
95c797 |
ccenv_libgcc_s_a_header=$(od -b -N8 \
|
|
|
95c797 |
$($ccenv_cc -print-file-name=libgcc_s.a) \
|
|
|
95c797 |
2>/dev/null \
|
|
|
95c797 |
| head -n1)
|
|
|
95c797 |
|
|
|
95c797 |
ccenv_libgcc_s_so_header=$(od -b -N8 \
|
|
|
95c797 |
$($ccenv_cc -print-file-name=libgcc_s.so) \
|
|
|
95c797 |
2>/dev/null \
|
|
|
95c797 |
| head -n1)
|
|
|
95c797 |
|
|
|
95c797 |
if [ "$ccenv_libgcc_s_a_header" = "$ccenv_bigaf_header" ]; then
|
|
|
95c797 |
ccenv_cc_sofmt='bigaf'
|
|
|
95c797 |
elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_bigaf_header" ]; then
|
|
|
95c797 |
ccenv_cc_sofmt='bigaf'
|
|
|
95c797 |
else
|
|
|
95c797 |
ccenv_cc_sofmt="$ccenv_cc_binfmt"
|
|
|
95c797 |
fi
|
|
|
95c797 |
;;
|
|
|
95c797 |
|
|
|
95c797 |
aiaff )
|
|
|
95c797 |
ccenv_libgcc_s_a_header=$(od -b -N8 \
|
|
|
95c797 |
$($ccenv_cc -print-file-name=libgcc_s.a) \
|
|
|
95c797 |
| head -n1)
|
|
|
95c797 |
|
|
|
95c797 |
ccenv_libgcc_s_so_header=$(od -b -N8 \
|
|
|
95c797 |
$($ccenv_cc -print-file-name=libgcc_s.so) \
|
|
|
95c797 |
| head -n1)
|
|
|
95c797 |
|
|
|
95c797 |
if [ "$ccenv_libgcc_s_a_header" = "$ccenv_aiaff_header" ]; then
|
|
|
95c797 |
ccenv_cc_sofmt='aiaff'
|
|
|
95c797 |
elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_aiaff_header" ]; then
|
|
|
95c797 |
ccenv_cc_sofmt='aiaff'
|
|
|
95c797 |
else
|
|
|
95c797 |
ccenv_cc_sofmt="$ccenv_cc_binfmt"
|
|
|
95c797 |
fi
|
|
|
95c797 |
;;
|
|
|
95c797 |
esac
|
|
|
95c797 |
|
|
|
18acfc |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
18acfc |
case "$ccenv_cc_sofmt" in
|
|
|
18acfc |
bigaf | aiaff )
|
|
|
18acfc |
mb_shared_lib_cmd='$(AR) -rcs'
|
|
|
18acfc |
mb_shared_lib_ldflags=
|
|
|
18acfc |
;;
|
|
|
18acfc |
|
|
|
18acfc |
* )
|
|
|
18acfc |
mb_shared_lib_cmd='$(CC) -shared -o'
|
|
|
18acfc |
mb_shared_lib_ldflags='$(LDFLAGS_SHARED)'
|
|
|
18acfc |
;;
|
|
|
18acfc |
esac
|
|
|
18acfc |
fi
|
|
|
18acfc |
|
|
|
95c797 |
ccenv_attr_epilog "$ccenv_cc_sofmt"
|
|
|
95c797 |
}
|
|
|
95c797 |
|
|
|
eb4330 |
ccenv_set_os_dso_exrules()
|
|
|
eb4330 |
{
|
|
|
487309 |
ccenv_attr_prolog 'os dso exrules'
|
|
|
487309 |
|
|
|
eb4330 |
case "$ccenv_os" in
|
|
|
eb4330 |
midipix )
|
|
|
eb4330 |
ccenv_os_dso_exrules='pe-mdso'
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
* )
|
|
|
eb4330 |
if [ "$ccenv_cc_binfmt" = 'PE' ]; then
|
|
|
eb4330 |
ccenv_os_dso_exrules='pe-dlltool'
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_os_dso_exrules='default'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
esac
|
|
|
487309 |
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_os_dso_exrules"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_dso_linkage()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
# todo: PIC, PIE, and friends
|
|
|
487309 |
ccenv_attr_prolog 'os linkage'
|
|
|
eb4330 |
ccenv_os_dso_linkage='default'
|
|
|
487309 |
ccenv_attr_epilog "$ccenv_os_dso_linkage"
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_darwin()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_os_app_prefix=
|
|
|
eb4330 |
ccenv_os_app_suffix=
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefix=lib
|
|
|
eb4330 |
ccenv_os_lib_suffix=.dylib
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_implib_ext=.invalid
|
|
|
eb4330 |
ccenv_os_libdef_ext=.invalid
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_archive_ext=.a
|
|
|
eb4330 |
ccenv_os_soname=symlink
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefixed_suffix=
|
|
|
eb4330 |
ccenv_os_lib_suffixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_mdso()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_os_app_prefix=
|
|
|
eb4330 |
ccenv_os_app_suffix=
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefix=lib
|
|
|
eb4330 |
ccenv_os_lib_suffix=.so
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_implib_ext=.lib.a
|
|
|
eb4330 |
ccenv_os_libdef_ext=.so.def
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_archive_ext=.a
|
|
|
eb4330 |
ccenv_os_soname=symlink
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
eb4330 |
ccenv_os_lib_suffixed_suffix=
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_dlltool()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_os_app_prefix=
|
|
|
eb4330 |
ccenv_os_app_suffix=.exe
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefix=lib
|
|
|
eb4330 |
ccenv_os_lib_suffix=.dll
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_implib_ext=.dll.a
|
|
|
eb4330 |
ccenv_os_libdef_ext=.def
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_archive_ext=.a
|
|
|
eb4330 |
ccenv_os_soname=copy
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
eb4330 |
ccenv_os_lib_suffixed_suffix=
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_default()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_os_app_prefix=
|
|
|
eb4330 |
ccenv_os_app_suffix=
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefix=lib
|
|
|
eb4330 |
ccenv_os_lib_suffix=.so
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_implib_ext=.invalid
|
|
|
eb4330 |
ccenv_os_libdef_ext=.invalid
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_archive_ext=.a
|
|
|
eb4330 |
ccenv_os_soname=symlink
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
eb4330 |
ccenv_os_lib_suffixed_suffix=
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os_dso_patterns()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
# sover: .so.x.y.z
|
|
|
eb4330 |
# verso: .x.y.z.so
|
|
|
eb4330 |
|
|
|
eb4330 |
case "$ccenv_os" in
|
|
|
eb4330 |
darwin )
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_darwin
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
midipix )
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_mdso
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
cygwin | msys | mingw )
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_dlltool
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
* )
|
|
|
eb4330 |
ccenv_set_os_dso_patterns_default
|
|
|
eb4330 |
;;
|
|
|
eb4330 |
esac
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
6598d3 |
ccenv_set_os_pe_switches()
|
|
|
6598d3 |
{
|
|
|
9a7d8a |
if [ "$ccenv_cc_binfmt" = 'PE' ] && [ -z "$ccenv_pe_subsystem" ]; then
|
|
|
6598d3 |
case "$ccenv_os" in
|
|
|
6598d3 |
midipix | mingw )
|
|
|
6598d3 |
ccenv_pe_subsystem='windows'
|
|
|
6598d3 |
;;
|
|
|
6598d3 |
* )
|
|
|
6598d3 |
ccenv_pe_subsystem='console'
|
|
|
6598d3 |
;;
|
|
|
6598d3 |
esac
|
|
|
6598d3 |
fi
|
|
|
6598d3 |
}
|
|
|
6598d3 |
|
|
|
eb4330 |
ccenv_output_defs()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_in="$mb_project_dir/sofort/ccenv/ccenv.in"
|
|
|
eb4330 |
ccenv_mk="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
|
|
|
25b012 |
ccenv_tmp=
|
|
|
eb4330 |
|
|
|
6598d3 |
if [ "$ccenv_cc_binfmt" = 'PE' ]; then
|
|
|
6598d3 |
ccenv_pe="$mb_project_dir/sofort/ccenv/pedefs.in"
|
|
|
6598d3 |
ccenv_in="$ccenv_in $ccenv_pe"
|
|
|
6598d3 |
fi
|
|
|
6598d3 |
|
|
|
eb4330 |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
eb4330 |
|
|
|
1ea231 |
ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
|
|
|
eb4330 |
|
|
|
6fdafe |
sed \
|
|
|
f4c2b9 |
-e 's/^[[:space:]]*$/@/g' \
|
|
|
6fdafe |
-e 's/^/NATIVE_/' \
|
|
|
6fdafe |
-e 's/NATIVE_@//g' \
|
|
|
6fdafe |
-e 's/NATIVE_#/#/g' \
|
|
|
6fdafe |
-e 's/ =/=/g' \
|
|
|
6fdafe |
-e 's/ +=/+=/g' \
|
|
|
03d824 |
$(printf '%s ' $ccenv_in) \
|
|
|
03d824 |
> "$ccenv_tmp"
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_in="$ccenv_tmp"
|
|
|
1ea231 |
else
|
|
|
25b012 |
unset ccenv_tmp
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
cdd2f6 |
ccenv_var_defs=
|
|
|
e92e22 |
ccenv_sed_substs="-e s/@ccenv_cfgtype@/${ccenv_cfgtype}/g"
|
|
|
cdd2f6 |
|
|
|
eb4330 |
ccenv_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/ccenv/ccenv.vars" \
|
|
|
cdd2f6 |
| grep -v '^#');
|
|
|
eb4330 |
|
|
|
e92e22 |
ccenv_exvars="ccenv_makevar_prefix"
|
|
|
eb4330 |
|
|
|
cdd2f6 |
for __var in $(printf '%s' "$ccenv_vars $ccenv_exvars"); do
|
|
|
cdd2f6 |
ccenv_sed_subst=$(printf '%s %s%s%s' \
|
|
|
cdd2f6 |
'-e' "'s^@$__var@" \
|
|
|
cdd2f6 |
"^___${__var}___" \
|
|
|
cdd2f6 |
"^g'")
|
|
|
cdd2f6 |
|
|
|
cdd2f6 |
ccenv_sed_substs="$ccenv_sed_substs $ccenv_sed_subst"
|
|
|
cdd2f6 |
|
|
|
cdd2f6 |
ccenv_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "${__var}")
|
|
|
cdd2f6 |
eval ccenv_var_defs='"$ccenv_var_defs "$ccenv_var_def'
|
|
|
cdd2f6 |
done
|
|
|
eb4330 |
|
|
|
cdd2f6 |
eval sed $ccenv_sed_substs $(printf '%s ' $ccenv_in) \
|
|
|
cdd2f6 |
| eval m4 $ccenv_var_defs - \
|
|
|
cdd2f6 |
| sed -e 's/[[:blank:]]*$//g' \
|
|
|
eb4330 |
> "$ccenv_mk"
|
|
|
eb4330 |
|
|
|
44cc21 |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
aecab0 |
for __var in $(printf '%s' "$ccenv_vars"); do
|
|
|
44cc21 |
ccenv_src_var=$__var
|
|
|
44cc21 |
ccenv_dst_var=mb_${__var#*ccenv_}
|
|
|
44cc21 |
ccenv_var_expr='${'$ccenv_src_var':-}'
|
|
|
44cc21 |
eval $ccenv_dst_var=$ccenv_var_expr
|
|
|
44cc21 |
|
|
|
44cc21 |
done
|
|
|
44cc21 |
|
|
|
44cc21 |
mb_host=$ccenv_host
|
|
|
44cc21 |
mb_cchost=$ccenv_cchost
|
|
|
44cc21 |
else
|
|
|
aecab0 |
for __var in $(printf '%s' "$ccenv_vars"); do
|
|
|
44cc21 |
ccenv_src_var=$__var
|
|
|
44cc21 |
ccenv_dst_var=mb_native_${__var#*ccenv_}
|
|
|
44cc21 |
ccenv_var_expr='${'$ccenv_src_var':-}'
|
|
|
44cc21 |
eval "$ccenv_dst_var=$ccenv_var_expr"
|
|
|
44cc21 |
done
|
|
|
44cc21 |
|
|
|
44cc21 |
mb_native_host=$ccenv_host
|
|
|
44cc21 |
mb_native_cchost=$ccenv_cchost
|
|
|
44cc21 |
fi
|
|
|
1ea231 |
|
|
|
1ea231 |
if [ -n "${ccenv_tmp:-}" ]; then
|
|
|
1ea231 |
rm -f "$ccenv_tmp"
|
|
|
1ea231 |
unset ccenv_tmp
|
|
|
1ea231 |
fi
|
|
|
6ae395 |
|
|
|
46447e |
|
|
|
46447e |
if [ "${ccenv_cfgtype}" = 'host' ]; then
|
|
|
46447e |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .cflags-host)
|
|
|
46447e |
ccenv_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .ldflags-host)
|
|
|
46447e |
else
|
|
|
46447e |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .cflags-native)
|
|
|
46447e |
ccenv_ldflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" .ldflags-native)
|
|
|
46447e |
fi
|
|
|
46447e |
|
|
|
46447e |
ccenv_cflags="${ccenv_cflags#*: }"
|
|
|
46447e |
ccenv_ldflags="${ccenv_ldflags#*: }"
|
|
|
46447e |
|
|
|
c6ae3d |
ccenv_sysroot=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
|
|
|
c6ae3d |
-print-sysroot 2>/dev/null || true)
|
|
|
c6ae3d |
|
|
|
46447e |
eval 'ccenv_'${ccenv_cfgtype}'_cflags'=\'$ccenv_cflags\'
|
|
|
46447e |
eval 'ccenv_'${ccenv_cfgtype}'_ldflags'=\'$ccenv_ldflags\'
|
|
|
c6ae3d |
eval 'ccenv_'${ccenv_cfgtype}'_sysroot'=\'$ccenv_sysroot\'
|
|
|
46447e |
|
|
|
6ae395 |
eval 'ccenv_'${ccenv_cfgtype}'_cc'=\'$ccenv_cc\'
|
|
|
5d48ed |
eval 'ccenv_'${ccenv_cfgtype}'_cc_environment'=\'$ccenv_cc_environment\'
|
|
|
f2e6a7 |
eval 'ccenv_'${ccenv_cfgtype}'_dumpmachine_switch'=\'$ccenv_dumpmachine_switch\'
|
|
|
a7dd26 |
eval 'ccenv_'${ccenv_cfgtype}'_pkgconf'=\'$ccenv_pkgconf\'
|
|
|
46447e |
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
f91c90 |
ccenv_set_cc_sysroot_vars()
|
|
|
f91c90 |
{
|
|
|
f91c90 |
if [ "$ccenv_cfgtype" = 'native' ] || [ -z "$mb_sysroot" ]; then
|
|
|
f91c90 |
return 0
|
|
|
f91c90 |
fi
|
|
|
f91c90 |
|
|
|
f91c90 |
cfgtest_host_section
|
|
|
f91c90 |
ccenv_switch_var="--sysroot=${mb_sysroot}"
|
|
|
f91c90 |
|
|
|
f91c90 |
if cfgtest_compiler_switch_arg "${ccenv_switch_var}"; then
|
|
|
f91c90 |
printf '\n# %s sysroot: cflags and ldflags\n' "$ccenv_cfgtype" \
|
|
|
f91c90 |
>> "$ccenv_mk"
|
|
|
f91c90 |
|
|
|
f91c90 |
for ccenv_make_var in '_CFLAGS_SYSROOT' '_LDFLAGS_SYSROOT'; do
|
|
|
f91c90 |
printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
|
|
|
f91c90 |
>> "$ccenv_mk"
|
|
|
f91c90 |
done
|
|
|
f91c90 |
else
|
|
|
f91c90 |
printf '\n# %s sysroot: cflags and ldflags %s\n' "$ccenv_cfgtype" \
|
|
|
f91c90 |
'(not supported: see config.log)' \
|
|
|
f91c90 |
>> "$ccenv_mk"
|
|
|
f91c90 |
|
|
|
f91c90 |
for ccenv_make_var in '_CFLAGS_SYSROOT' '_LDFLAGS_SYSROOT'; do
|
|
|
f91c90 |
printf '%-40s=\n' "${ccenv_make_var}" \
|
|
|
f91c90 |
>> "$ccenv_mk"
|
|
|
f91c90 |
done
|
|
|
f91c90 |
fi
|
|
|
f91c90 |
}
|
|
|
f91c90 |
|
|
|
280cab |
ccenv_set_cc_switch_vars()
|
|
|
280cab |
{
|
|
|
6962e5 |
printf '\n# %s cflags: supported compiler switches\n' "$ccenv_cfgtype" \
|
|
|
6962e5 |
>> "$ccenv_mk"
|
|
|
6962e5 |
|
|
|
280cab |
if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
|
|
|
bfa291 |
ccenv_switch_vars=$(cat \
|
|
|
280cab |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
280cab |
$mb_project_dir/project/config/ccswitch.strs \
|
|
|
bfa291 |
| grep -v -e '^#' -e '^-Wl,' \
|
|
|
bfa291 |
| sort -u)
|
|
|
280cab |
else
|
|
|
29dbd5 |
ccenv_switch_vars=$(grep -v -e '^#' -e '^-Wl,' \
|
|
|
280cab |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
280cab |
| sort -u)
|
|
|
280cab |
fi
|
|
|
280cab |
|
|
|
280cab |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
280cab |
ccenv_makevar_prefix='_CFLAGS_'
|
|
|
280cab |
cfgtest_host_section
|
|
|
280cab |
else
|
|
|
280cab |
ccenv_makevar_prefix='_NATIVE_CFLAGS_'
|
|
|
280cab |
cfgtest_native_section
|
|
|
280cab |
fi
|
|
|
280cab |
|
|
|
280cab |
for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
|
|
|
280cab |
ccenv_make_var=${ccenv_switch_var%=}
|
|
|
280cab |
ccenv_make_var=${ccenv_make_var%,}
|
|
|
280cab |
|
|
|
280cab |
ccenv_make_var=${ccenv_make_var##---}
|
|
|
280cab |
ccenv_make_var=${ccenv_make_var##--}
|
|
|
280cab |
ccenv_make_var=${ccenv_make_var##-}
|
|
|
280cab |
|
|
|
280cab |
ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
|
|
|
280cab |
| sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
|
|
|
280cab |
|
|
|
280cab |
ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
|
|
|
280cab |
|
|
|
280cab |
if cfgtest_compiler_switch "$ccenv_switch_var"; then
|
|
|
280cab |
ccenv_switch_var=${ccenv_switch_var%=}
|
|
|
280cab |
ccenv_switch_var=${ccenv_switch_var%,}
|
|
|
280cab |
|
|
|
cbb162 |
printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
|
|
|
280cab |
>> "$ccenv_mk"
|
|
|
280cab |
else
|
|
|
cbb162 |
printf '%-40s=\n' "${ccenv_make_var}" \
|
|
|
280cab |
>> "$ccenv_mk"
|
|
|
280cab |
fi
|
|
|
280cab |
done
|
|
|
280cab |
}
|
|
|
280cab |
|
|
|
29dbd5 |
ccenv_set_cc_linker_switch_vars()
|
|
|
29dbd5 |
{
|
|
|
29dbd5 |
printf '\n# %s ldflags: supported compiler switches\n' "$ccenv_cfgtype" \
|
|
|
29dbd5 |
>> "$ccenv_mk"
|
|
|
29dbd5 |
|
|
|
29dbd5 |
if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
|
|
|
bfa291 |
ccenv_switch_vars=$(cat \
|
|
|
29dbd5 |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
29dbd5 |
$mb_project_dir/project/config/ccswitch.strs \
|
|
|
bfa291 |
| grep -e '^-Wl,' \
|
|
|
29dbd5 |
| sort -u)
|
|
|
29dbd5 |
else
|
|
|
29dbd5 |
ccenv_switch_vars=$(grep -e '^-Wl,' \
|
|
|
29dbd5 |
$mb_project_dir/sofort/ccenv/ccswitch.strs \
|
|
|
29dbd5 |
| sort -u)
|
|
|
29dbd5 |
fi
|
|
|
29dbd5 |
|
|
|
29dbd5 |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
29dbd5 |
ccenv_makevar_prefix='_LDFLAGS_'
|
|
|
29dbd5 |
cfgtest_host_section
|
|
|
29dbd5 |
else
|
|
|
29dbd5 |
ccenv_makevar_prefix='_NATIVE_LDFLAGS_'
|
|
|
29dbd5 |
cfgtest_native_section
|
|
|
29dbd5 |
fi
|
|
|
29dbd5 |
|
|
|
29dbd5 |
for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
|
|
|
29dbd5 |
ccenv_make_var=${ccenv_switch_var%=}
|
|
|
29dbd5 |
ccenv_make_var=${ccenv_make_var%,}
|
|
|
29dbd5 |
|
|
|
29dbd5 |
ccenv_make_var=${ccenv_make_var##---}
|
|
|
29dbd5 |
ccenv_make_var=${ccenv_make_var##--}
|
|
|
29dbd5 |
ccenv_make_var=${ccenv_make_var##-}
|
|
|
29dbd5 |
|
|
|
29dbd5 |
ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
|
|
|
29dbd5 |
| sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
|
|
|
29dbd5 |
|
|
|
29dbd5 |
ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
|
|
|
29dbd5 |
|
|
|
29dbd5 |
if cfgtest_compiler_switch "$ccenv_switch_var"; then
|
|
|
29dbd5 |
ccenv_switch_var=${ccenv_switch_var%=}
|
|
|
29dbd5 |
ccenv_switch_var=${ccenv_switch_var%,}
|
|
|
29dbd5 |
|
|
|
29dbd5 |
printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
|
|
|
29dbd5 |
>> "$ccenv_mk"
|
|
|
29dbd5 |
else
|
|
|
29dbd5 |
printf '%-40s=\n' "${ccenv_make_var}" \
|
|
|
29dbd5 |
>> "$ccenv_mk"
|
|
|
29dbd5 |
fi
|
|
|
29dbd5 |
done
|
|
|
29dbd5 |
}
|
|
|
29dbd5 |
|
|
|
e2a42e |
ccenv_set_cc_attr_visibility_vars()
|
|
|
e2a42e |
{
|
|
|
e2a42e |
if cfgtest_attr_visibility 'default'; then
|
|
|
e2a42e |
ccenv_attr_visibility_default="$mb_cfgtest_attr"
|
|
|
e2a42e |
fi
|
|
|
e2a42e |
|
|
|
e2a42e |
if cfgtest_attr_visibility 'hidden'; then
|
|
|
e2a42e |
ccenv_attr_visibility_hidden="$mb_cfgtest_attr"
|
|
|
e2a42e |
fi
|
|
|
e2a42e |
|
|
|
e2a42e |
if cfgtest_attr_visibility 'internal'; then
|
|
|
e2a42e |
ccenv_attr_visibility_internal="$mb_cfgtest_attr"
|
|
|
e2a42e |
fi
|
|
|
e2a42e |
|
|
|
e2a42e |
if cfgtest_attr_visibility 'protected'; then
|
|
|
e2a42e |
ccenv_attr_visibility_protected="$mb_cfgtest_attr"
|
|
|
e2a42e |
fi
|
|
|
e2a42e |
}
|
|
|
e2a42e |
|
|
|
8c2980 |
ccenv_dso_verify()
|
|
|
8c2980 |
{
|
|
|
8c2980 |
ccenv_str='int foo(int x){return ++x;}'
|
|
|
8c2980 |
ccenv_cmd="$ccenv_cc -xc - -shared -o a.out"
|
|
|
8c2980 |
|
|
|
8c2980 |
rm -f a.out
|
|
|
8c2980 |
|
|
|
4da44e |
printf '%s' "$ccenv_str" | $(printf %s "$ccenv_cmd") \
|
|
|
0d8567 |
> /dev/null 2>&3 \
|
|
|
8c2980 |
|| mb_disable_shared=yes
|
|
|
8c2980 |
|
|
|
8c2980 |
rm -f a.out
|
|
|
8c2980 |
}
|
|
|
8c2980 |
|
|
|
eb4330 |
ccenv_clean_up()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
rm -f $ccenv_image
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_common_init()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
. "$mb_project_dir/sofort/ccenv/ccenv.vars"
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_cfgtype=$1
|
|
|
eb4330 |
ccenv_cfgfile="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
|
|
|
ec706e |
ccenv_cchost=
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
eb4330 |
ccenv_makevar_prefix='NATIVE_'
|
|
|
eb4330 |
ccenv_image='./ccenv/native.a.out'
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_makevar_prefix=
|
|
|
eb4330 |
ccenv_image='./ccenv/host.a.out'
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
eb4330 |
ccenv_prefixes=
|
|
|
eb4330 |
elif [ -n "$mb_cross_compile" ]; then
|
|
|
eb4330 |
ccenv_prefixes="$mb_cross_compile"
|
|
|
eb4330 |
elif [ -n "$mb_host" ]; then
|
|
|
eb4330 |
ccenv_prefixes="$mb_host-"
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_prefixes=
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
|
|
|
eb4330 |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
eb4330 |
ccenv_tflags=
|
|
|
55d840 |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
|
|
|
beafec |
OS_DSO_EXRULES=default \
|
|
|
beafec |
OS_SONAME=symlink \
|
|
|
2521cb |
OS_ARCHIVE_EXT='.a' \
|
|
|
beafec |
.cflags-host)
|
|
|
52d597 |
|
|
|
55d840 |
ccenv_cflags="${ccenv_cflags#*: }"
|
|
|
55d840 |
|
|
|
eb4330 |
ccenv_cc="$mb_user_cc"
|
|
|
eb4330 |
ccenv_cpp="$mb_user_cpp"
|
|
|
eb4330 |
ccenv_cxx="$mb_user_cxx"
|
|
|
6598d3 |
|
|
|
6598d3 |
ccenv_pe_subsystem="$mb_pe_subsystem"
|
|
|
6598d3 |
ccenv_pe_image_base="$mb_pe_image_base"
|
|
|
eb4330 |
else
|
|
|
eb4330 |
ccenv_tflags=
|
|
|
55d840 |
ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
|
|
|
beafec |
OS_DSO_EXRULES=default \
|
|
|
beafec |
OS_SONAME=symlink \
|
|
|
2521cb |
OS_ARCHIVE_EXT='.a' \
|
|
|
beafec |
.cflags-native)
|
|
|
beafec |
|
|
|
55d840 |
ccenv_cflags="${ccenv_cflags#*: }"
|
|
|
55d840 |
|
|
|
eb4330 |
ccenv_cc="$mb_native_cc"
|
|
|
eb4330 |
ccenv_cpp="$mb_native_cpp"
|
|
|
eb4330 |
ccenv_cxx="$mb_native_cxx"
|
|
|
6598d3 |
|
|
|
6598d3 |
ccenv_pe_subsystem="$mb_native_pe_subsystem"
|
|
|
6598d3 |
ccenv_pe_image_base="$mb_native_pe_image_base"
|
|
|
eb4330 |
fi
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_characteristics()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_set_cc_host
|
|
|
eb4330 |
ccenv_set_cc_bits
|
|
|
eb4330 |
ccenv_set_cc_binfmt
|
|
|
487309 |
ccenv_set_cc_underscore
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_toolchain_variables()
|
|
|
eb4330 |
{
|
|
|
eb4330 |
ccenv_common_init $1
|
|
|
eb4330 |
ccenv_set_cc
|
|
|
eb4330 |
ccenv_set_cpp
|
|
|
eb4330 |
ccenv_set_cxx
|
|
|
eb4330 |
ccenv_set_primary_tools
|
|
|
eb4330 |
ccenv_set_tool_variants
|
|
|
eb4330 |
ccenv_set_characteristics
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_os
|
|
|
eb4330 |
ccenv_set_os_flags
|
|
|
eb4330 |
ccenv_set_os_semantics
|
|
|
95c797 |
ccenv_set_os_dso_format
|
|
|
eb4330 |
ccenv_set_os_dso_exrules
|
|
|
eb4330 |
ccenv_set_os_dso_linkage
|
|
|
eb4330 |
ccenv_set_os_dso_patterns
|
|
|
6598d3 |
ccenv_set_os_pe_switches
|
|
|
e2a42e |
ccenv_set_cc_attr_visibility_vars
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_output_defs
|
|
|
eb4330 |
ccenv_clean_up
|
|
|
280cab |
|
|
|
f91c90 |
ccenv_set_cc_sysroot_vars
|
|
|
280cab |
ccenv_set_cc_switch_vars
|
|
|
29dbd5 |
ccenv_set_cc_linker_switch_vars
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_host_variables()
|
|
|
eb4330 |
{
|
|
|
487309 |
output_script_status ${mb_script} \
|
|
|
93d557 |
'detect and query host (targeted) system'
|
|
|
487309 |
|
|
|
eb4330 |
ccenv_set_toolchain_variables 'host'
|
|
|
8c2980 |
ccenv_dso_verify
|
|
|
eb4330 |
}
|
|
|
eb4330 |
|
|
|
eb4330 |
ccenv_set_native_variables()
|
|
|
eb4330 |
{
|
|
|
487309 |
output_script_status ${mb_script} \
|
|
|
93d557 |
'detect and query native (local build) system'
|
|
|
487309 |
|
|
|
55f528 |
if [ _$mb_ccenv_skip_native != _yes ]; then
|
|
|
55f528 |
ccenv_set_toolchain_variables 'native'
|
|
|
55f528 |
fi
|
|
|
eb4330 |
}
|