|
|
7e34aa |
# ccenv.sh: sofort's tool-finding bits,
|
|
|
7e34aa |
# invoked from within the project-agnostic configure script.
|
|
|
7e34aa |
|
|
|
7e34aa |
# invocation and names of binary tools:
|
|
|
7e34aa |
# agnostic names (ar, nm, objdump, ...);
|
|
|
7e34aa |
# target-prefixed agnostic names (x86_64-nt64-midipix-ar, ...);
|
|
|
7e34aa |
# branded names (llvm-ar, llvm-nm, llvm-objdump, ...);
|
|
|
7e34aa |
# target-prefixed branded names (x86_64-linux-gnu-gcc-ar, ...);
|
|
|
7e34aa |
# target-specifying branded tools (llvm-ar --target=x86_64-linux, ...).
|
|
|
7e34aa |
|
|
|
7e34aa |
# cross-compilation: default search order:
|
|
|
7e34aa |
# target-prefixed agnostic tools;
|
|
|
7e34aa |
# target-prefixed branded tools, starting with the prefix
|
|
|
7e34aa |
# most commonly associated with the selected compiler (that is,
|
|
|
7e34aa |
# ``gcc'' when using gcc, and ``llvm'' when using clang);
|
|
|
7e34aa |
# target-speficying branded tools, starting once again with the
|
|
|
7e34aa |
# prefix most commonly associated with the selected compiler.
|
|
|
7e34aa |
|
|
|
7e34aa |
# internal variables of interest:
|
|
|
7e34aa |
# ccenv_cfgtype: the type of host being tested (host/native)
|
|
|
7e34aa |
# ccenv_cfgfile: the configuration file for the host being tested
|
|
|
7e34aa |
# ccenv_cflags: the comprehensive cflags for the host being tested
|
|
|
7e34aa |
# ccenv_cchost: the host being tested, as reported by -dumpmachine
|
|
|
7e34aa |
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_usage()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
cat "$mb_project_dir"/sofort/ccenv/ccenv.usage
|
|
|
7e34aa |
exit 0
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_newline()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
printf '\n' >> "$ccenv_cfgfile"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_comment()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_internal_str='#'
|
|
|
7e34aa |
|
|
|
7e34aa |
for ccenv_internal_arg ; do
|
|
|
7e34aa |
ccenv_internal_str="$ccenv_internal_str $ccenv_internal_arg"
|
|
|
7e34aa |
done
|
|
|
7e34aa |
|
|
|
7e34aa |
printf '%s\n' "$ccenv_internal_str" >> "$ccenv_cfgfile"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_prolog()
|
|
|
28f188 |
{
|
|
|
28f188 |
ccenv_line_dots='......................................'
|
|
|
28f188 |
ccenv_tool_desc="=== checking for ${1}"
|
|
|
28f188 |
ccenv_tool_dlen="${#ccenv_line_dots}"
|
|
|
28f188 |
|
|
|
28f188 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s" \
|
|
|
28f188 |
"${ccenv_tool_desc} ${mb_line_dots}"
|
|
|
28f188 |
}
|
|
|
28f188 |
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_tool_epilog()
|
|
|
28f188 |
{
|
|
|
28f188 |
ccenv_line_dots='................................'
|
|
|
28f188 |
ccenv_tool_dlen="$((${#ccenv_line_dots} - ${#1}))"
|
|
|
28f188 |
|
|
|
28f188 |
printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \
|
|
|
28f188 |
"${ccenv_line_dots}" "${1}"
|
|
|
28f188 |
}
|
|
|
28f188 |
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_attr_prolog()
|
|
|
28f188 |
{
|
|
|
28f188 |
ccenv_line_dots='......................................'
|
|
|
28f188 |
ccenv_attr_desc="=== detect ${ccenv_cfgtype} ${1}"
|
|
|
28f188 |
ccenv_attr_dlen="${#ccenv_line_dots}"
|
|
|
28f188 |
|
|
|
28f188 |
printf "%${ccenv_attr_dlen}.${ccenv_attr_dlen}s" \
|
|
|
28f188 |
"${ccenv_attr_desc} ${ccenv_line_dots}"
|
|
|
28f188 |
}
|
|
|
28f188 |
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_attr_epilog()
|
|
|
28f188 |
{
|
|
|
28f188 |
ccenv_tool_epilog "${1}"
|
|
|
28f188 |
}
|
|
|
28f188 |
|
|
|
28f188 |
|
|
|
7e34aa |
ccenv_find_tool()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
if [ -z "$ccenv_prefixes" ]; then
|
|
|
e2dba3 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
150610 |
if [ -z ${@:-} ]; then
|
|
|
d3b49f |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
d3b49f |
ccenv_tool="$ccenv_candidate"
|
|
|
150610 |
return 0
|
|
|
749dc9 |
fi
|
|
|
150610 |
else
|
|
|
d3b49f |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
d3b49f |
if "$ccenv_candidate" $@ > /dev/null 2>&1; then
|
|
|
d3b49f |
ccenv_tool="$ccenv_candidate"
|
|
|
150610 |
return 0
|
|
|
749dc9 |
fi
|
|
|
749dc9 |
fi
|
|
|
150610 |
fi
|
|
|
7e34aa |
done
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_tool=false
|
|
|
7e34aa |
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
e2dba3 |
for ccenv_prefix in $(printf '%s' "$ccenv_prefixes"); do
|
|
|
e2dba3 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
7e34aa |
ccenv_tool="$ccenv_prefix$ccenv_candidate"
|
|
|
749dc9 |
|
|
|
749dc9 |
if command -v "$ccenv_tool" > /dev/null; then
|
|
|
749dc9 |
return 0
|
|
|
749dc9 |
fi
|
|
|
7e34aa |
done
|
|
|
7e34aa |
done
|
|
|
7e34aa |
|
|
|
e2dba3 |
for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
|
|
|
d3b49f |
if command -v "$ccenv_candidate" > /dev/null; then
|
|
|
d3b49f |
ccenv_tool="$ccenv_candidate"
|
|
|
749dc9 |
return 0
|
|
|
749dc9 |
fi
|
|
|
7e34aa |
done
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_tool=false
|
|
|
7e34aa |
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_primary_tools()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_core_tools="ar nm objdump ranlib size strip strings objcopy"
|
|
|
400106 |
ccenv_hack_tools="addr2line cov elfedit readelf readobj otool"
|
|
|
7e34aa |
ccenv_peep_tools="perk mdso dlltool windmc windres"
|
|
|
7e34aa |
|
|
|
e2dba3 |
for __tool in $(printf '%s' "$ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools"); do
|
|
|
28f188 |
ccenv_tool_prolog "$__tool"
|
|
|
28f188 |
|
|
|
7e34aa |
if [ -n "$mb_agnostic" ]; then
|
|
|
7e34aa |
ccenv_candidates=" $__tool"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ -n "$mb_zealous" ]; then
|
|
|
7e34aa |
ccenv_candidates="$mb_zealous-$__tool"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
7e34aa |
ccenv_candidates="gcc-$__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
7e34aa |
ccenv_candidates="llvm-$__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ -n "$mb_toolchain" ]; then
|
|
|
7e34aa |
ccenv_candidates="$mb_toolchain-$__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates $__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
7e34aa |
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_candidates="$__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates gcc-$__tool"
|
|
|
7e34aa |
ccenv_candidates="$ccenv_candidates llvm-$__tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
7e34aa |
ccenv_var_prefix='mb_'
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_var_prefix='mb_native_'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_var_name=$ccenv_var_prefix$__tool
|
|
|
7e34aa |
ccenv_var_expr='${'$ccenv_var_name':-}'
|
|
|
7e34aa |
eval ccenv_var_val=$ccenv_var_expr
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_var_val" ]; then
|
|
|
7e34aa |
eval ccenv_$__tool="$ccenv_var_val"
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
eval ccenv_$__tool="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_tool"
|
|
|
7e34aa |
done
|
|
|
7e34aa |
|
|
|
7e34aa |
# windrc
|
|
|
7e34aa |
ccenv_windrc="$ccenv_windres"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_tool_variants()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
# as (asm)
|
|
|
28f188 |
ccenv_tool_prolog 'as (asm)'
|
|
|
7e34aa |
ccenv_candidates=as
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" = false ]; then
|
|
|
7e34aa |
ccenv_as_asm=
|
|
|
7e34aa |
else
|
|
|
7e34aa |
$ccenv_tool --help | grep -i '.bc assembler' \
|
|
|
7e34aa |
|| ccenv_as_asm="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_as_asm"
|
|
|
28f188 |
|
|
|
7e34aa |
# as (ll)
|
|
|
28f188 |
ccenv_tool_prolog 'as (ll)'
|
|
|
7e34aa |
ccenv_candidates=llvm-as
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" != false ]; then
|
|
|
7e34aa |
ccenv_as_ll="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_as_ll"
|
|
|
28f188 |
|
|
|
7e34aa |
# as (mc)
|
|
|
28f188 |
ccenv_tool_prolog 'as (mc)'
|
|
|
7e34aa |
ccenv_candidates=llvm-mc
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" != false ]; then
|
|
|
7e34aa |
ccenv_as_mc="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_as_mc"
|
|
|
28f188 |
|
|
|
7e34aa |
# ld (bfd)
|
|
|
28f188 |
ccenv_tool_prolog 'ld (bfd)'
|
|
|
7e34aa |
ccenv_candidates=ld.bfd
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" != false ]; then
|
|
|
7e34aa |
ccenv_ld_bfd="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_ld_bfd"
|
|
|
28f188 |
|
|
|
7e34aa |
# ld (gold)
|
|
|
28f188 |
ccenv_tool_prolog 'ld (gold)'
|
|
|
7e34aa |
ccenv_candidates=ld.gold
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" != false ]; then
|
|
|
7e34aa |
ccenv_ld_gold="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_ld_gold"
|
|
|
28f188 |
|
|
|
7e34aa |
# ld (lld)
|
|
|
28f188 |
ccenv_tool_prolog 'ld (lld)'
|
|
|
7e34aa |
ccenv_candidates=lld
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" != false ]; then
|
|
|
7e34aa |
ccenv_ld_lld="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_ld_lld"
|
|
|
28f188 |
|
|
|
7e34aa |
# objdump (bfd)
|
|
|
28f188 |
ccenv_tool_prolog 'objdump (bfd)'
|
|
|
7e34aa |
ccenv_candidates=objdump
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
305cb2 |
if $ccenv_tool --version | grep -i Binutils > /dev/null; then
|
|
|
305cb2 |
ccenv_objdump_bfd="$ccenv_tool"
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_objdump_bfd"
|
|
|
28f188 |
|
|
|
7e34aa |
# objdump (llvm)
|
|
|
28f188 |
ccenv_tool_prolog 'objdump (llvm)'
|
|
|
7e34aa |
ccenv_candidates=llvm-objdump
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
305cb2 |
if $ccenv_tool --version | grep -i LLVM > /dev/null; then
|
|
|
305cb2 |
ccenv_objdump_llvm="$ccenv_tool"
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_objdump_llvm"
|
|
|
28f188 |
|
|
|
7e34aa |
# readelf (bfd)
|
|
|
28f188 |
ccenv_tool_prolog 'readelf (bfd)'
|
|
|
7e34aa |
ccenv_candidates=readelf
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
305cb2 |
if $ccenv_tool --version | grep -i Binutils > /dev/null; then
|
|
|
305cb2 |
ccenv_readelf_bfd="$ccenv_tool"
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_readelf_bfd"
|
|
|
28f188 |
|
|
|
7e34aa |
# readelf (llvm)
|
|
|
28f188 |
ccenv_tool_prolog 'readelf (llvm)'
|
|
|
7e34aa |
ccenv_candidates=llvm-readelf
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
305cb2 |
if $ccenv_tool --version | grep -i LLVM > /dev/null; then
|
|
|
305cb2 |
ccenv_readelf_llvm="$ccenv_tool"
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_readelf_llvm"
|
|
|
28f188 |
|
|
|
7e34aa |
# as
|
|
|
7e34aa |
if [ -n "$ccenv_cc" ]; then
|
|
|
a77aa5 |
ccenv_as='$('"$ccenv_makevar_prefix"'CC) -c -x assembler'
|
|
|
7e34aa |
elif [ -n "$mb_agnostic" ]; then
|
|
|
7e34aa |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
7e34aa |
elif [ "$mb_zealous" = 'gcc' ]; then
|
|
|
7e34aa |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
7e34aa |
elif [ -n "$mb_zealous" = 'llvm' ]; then
|
|
|
7e34aa |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
|
|
|
7e34aa |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
7e34aa |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
|
|
|
7e34aa |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
7e34aa |
ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# ld
|
|
|
7e34aa |
if [ -n "$ccenv_cc" ]; then
|
|
|
7e34aa |
ccenv_ld='$('"$ccenv_makevar_prefix"'CC) -nostdlib -nostartfiles'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_c_compiler_candidates()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
if [ -n "$mb_compiler" ]; then
|
|
|
7e34aa |
ccenv_candidates="$mb_compiler"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ -n "$mb_agnostic" ]; then
|
|
|
7e34aa |
ccenv_candidates="c99 c11 cc"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ "$mb_zealous" = 'gcc' ]; then
|
|
|
7e34aa |
ccenv_candidates="gcc"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ "$mb_zealous" = 'llvm' ]; then
|
|
|
7e34aa |
ccenv_candidates="clang"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ "$mb_toolchain" = 'gcc' ]; then
|
|
|
7e34aa |
ccenv_candidates="gcc c99 c11 cc clang"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ "$mb_toolchain" = 'llvm' ]; then
|
|
|
7e34aa |
ccenv_candidates="clang c99 c11 cc gcc"
|
|
|
7e34aa |
|
|
|
7e34aa |
elif [ -n "$mb_toolchain" ]; then
|
|
|
7e34aa |
ccenv_candidates="$mb_toolchain c99 c11 cc gcc clang"
|
|
|
7e34aa |
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_candidates="c99 c11 cc gcc clang"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_cc()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_tool_prolog 'C compiler'
|
|
|
28f188 |
|
|
|
7e34aa |
if [ -z "$ccenv_cc" ]; then
|
|
|
7e34aa |
ccenv_set_c_compiler_candidates
|
|
|
150610 |
ccenv_find_tool -dumpmachine
|
|
|
7e34aa |
ccenv_cc="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_cc" = false ] && [ -n "$mb_compiler" ]; then
|
|
|
7e34aa |
ccenv_cc="$mb_compiler"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_cc_cmd="$ccenv_cc"
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_cfgtype" = 'native' ]; then
|
|
|
1e3ee5 |
ccenv_host=$($ccenv_cc $(printf '%s' "$ccenv_cflags") -dumpmachine 2>/dev/null)
|
|
|
308fbf |
ccenv_cchost=$ccenv_host
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_cc"
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$mb_cchost" ]; then
|
|
|
7e34aa |
ccenv_host="$mb_cchost"
|
|
|
7e34aa |
elif [ -n "$mb_host" ]; then
|
|
|
7e34aa |
ccenv_host="$mb_host"
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_host=
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$ccenv_host" ]; then
|
|
|
1e3ee5 |
ccenv_host=$($ccenv_cc $(printf '%s' "$ccenv_cflags") -dumpmachine 2>/dev/null)
|
|
|
7e34aa |
ccenv_cchost=$ccenv_host
|
|
|
7e34aa |
else
|
|
|
47d854 |
ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
|
|
|
7e34aa |
ccenv_cmd="$ccenv_cc --target=$ccenv_host -E -xc -"
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$mb_user_cc" ]; then
|
|
|
7e34aa |
$ccenv_cmd < /dev/null > /dev/null \
|
|
|
7e34aa |
2>"$ccenv_tmp" || true
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_errors=$(cat "$ccenv_tmp")
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$ccenv_errors" ]; then
|
|
|
7e34aa |
ccenv_tflags="--target=$ccenv_host"
|
|
|
7e34aa |
ccenv_cc="$ccenv_cc $ccenv_tflags"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
47d854 |
rm -f "$ccenv_tmp"
|
|
|
47d854 |
unset ccenv_tmp
|
|
|
47d854 |
|
|
|
1e3ee5 |
ccenv_cchost=$($ccenv_cc $(printf '%s' "$ccenv_cflags") -dumpmachine 2>/dev/null)
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_cchost" != "$ccenv_host" ]; then
|
|
|
7e34aa |
printf 'ccenv:\n' >&2
|
|
|
7e34aa |
printf 'ccenv: ccenv_host: %s \n' $ccenv_host >&2
|
|
|
7e34aa |
printf 'ccenv: ccenv_cchost: %s \n' $ccenv_cchost >&2
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$ccenv_tflags" ]; then
|
|
|
7e34aa |
printf 'ccenv:\n' >&2
|
|
|
7e34aa |
printf 'ccenv: ccenv_host and ccenv_cchost do not match, most likely because:\n' >&2
|
|
|
7e34aa |
printf 'ccenv: (1) you explicitly set CC (or passed --compiler=...)\n' >&2
|
|
|
7e34aa |
printf 'ccenv: (2) the selected compiler does not accept --target=...\n' >&2
|
|
|
7e34aa |
printf 'ccenv: (3) the host reported by -dumpmachine differs from the one you requested.\n' >&2
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_errors" ]; then
|
|
|
7e34aa |
printf 'ccenv:\n' >&2
|
|
|
7e34aa |
printf 'ccenv: something went wrong, see the command and compiler message below.\n\n' >&2
|
|
|
7e34aa |
printf 'cmd: %s < /dev/null > /dev/null\n' "$ccenv_cmd" >&2
|
|
|
7e34aa |
printf '%s\n\n' "$ccenv_errors" >&2
|
|
|
7e34aa |
else
|
|
|
7e34aa |
printf 'ccenv:\n' >&2
|
|
|
7e34aa |
printf 'ccenv: something went wrong, bailing out.\n\n' >&2
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
return 2
|
|
|
7e34aa |
fi
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_cc"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_cpp()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_tool_prolog 'C pre-processor'
|
|
|
28f188 |
|
|
|
7e34aa |
case "$ccenv_cc_cmd" in
|
|
|
7e34aa |
cc | c99 | c11 | gcc)
|
|
|
7e34aa |
ccenv_cpp_prefix=
|
|
|
7e34aa |
ccenv_candidates="cpp" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
clang )
|
|
|
7e34aa |
ccenv_cpp_prefix=
|
|
|
7e34aa |
ccenv_candidates="clang-cpp" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*-cc )
|
|
|
7e34aa |
ccenv_cpp_prefix=${ccenv_cc_cmd%-cc*}-
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*-c99 )
|
|
|
7e34aa |
ccenv_cpp_prefix=${ccenv_cc_cmd%-c99*}-
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*-c11 )
|
|
|
7e34aa |
ccenv_cpp_prefix=${ccenv_cc_cmd%-c11*}-
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*-gcc )
|
|
|
7e34aa |
ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*-clang )
|
|
|
7e34aa |
ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}clang-cpp" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
* )
|
|
|
7e34aa |
ccenv_cpp="$ccenv_cc -E"
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_cpp"
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" = false ]; then
|
|
|
7e34aa |
ccenv_cpp="$ccenv_cc -E"
|
|
|
7e34aa |
elif [ -n "$ccenv_tflags" ]; then
|
|
|
7e34aa |
ccenv_cpp="$ccenv_tool $ccenv_tflags"
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_cpp="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_cpp"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_cxx()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_tool_prolog 'C++ compiler'
|
|
|
28f188 |
|
|
|
7e34aa |
case "$ccenv_cc_cmd" in
|
|
|
7e34aa |
cc | c99 | c11 )
|
|
|
7e34aa |
ccenv_cxx_prefix=
|
|
|
7e34aa |
ccenv_candidates="cxx c++" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
gcc )
|
|
|
7e34aa |
ccenv_cxx_prefix=
|
|
|
7e34aa |
ccenv_candidates="g++" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
clang )
|
|
|
7e34aa |
ccenv_cxx_prefix=
|
|
|
7e34aa |
ccenv_candidates="clang++" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*-gcc )
|
|
|
7e34aa |
ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}g++" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*-clang )
|
|
|
7e34aa |
ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}clang++" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
*cc )
|
|
|
7e34aa |
ccenv_cxx_prefix=${ccenv_cc_cmd%cc*}
|
|
|
7e34aa |
ccenv_candidates="${ccenv_cpp_prefix}++" ;;
|
|
|
7e34aa |
|
|
|
7e34aa |
* )
|
|
|
7e34aa |
ccenv_cxx="$ccenv_cc -xc++"
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_cxx"
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_find_tool
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ "$ccenv_tool" = false ]; then
|
|
|
7e34aa |
ccenv_cxx="$ccenv_cc -xc++"
|
|
|
7e34aa |
elif [ -n "$ccenv_tflags" ]; then
|
|
|
7e34aa |
ccenv_cxx="$ccenv_tool $ccenv_tflags"
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_cxx="$ccenv_tool"
|
|
|
7e34aa |
fi
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_tool_epilog "$ccenv_cxx"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_cc_host()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_attr_prolog 'name'
|
|
|
7e34aa |
ccenv_cc_host="$ccenv_cchost"
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_cc_host"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_cc_bits()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_attr_prolog 'bits'
|
|
|
28f188 |
|
|
|
7e34aa |
ccenv_internal_size=
|
|
|
7e34aa |
ccenv_internal_type='void *'
|
|
|
7e34aa |
ccenv_internal_test='char x[(sizeof(%s) == %s/8) ? 1 : -1];'
|
|
|
7e34aa |
|
|
|
7e34aa |
for ccenv_internal_guess in 64 32 128; do
|
|
|
7e34aa |
if [ -z $ccenv_internal_size ]; then
|
|
|
ca7f9d |
ccenv_internal_str=$(printf "$ccenv_internal_test" \
|
|
|
ca7f9d |
"$ccenv_internal_type" \
|
|
|
7e34aa |
"$ccenv_internal_guess")
|
|
|
7e34aa |
|
|
|
44c175 |
printf '%s' "$ccenv_internal_str" \
|
|
|
44c175 |
| $ccenv_cc -S -xc - -o - \
|
|
|
44c175 |
$(printf '%s' "$ccenv_cflags") \
|
|
|
44c175 |
> /dev/null 2>/dev/null \
|
|
|
7e34aa |
&& ccenv_internal_size=$ccenv_internal_guess
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
done
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_cc_bits=$ccenv_internal_size
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_cc_bits"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_cc_underscore()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_attr_prolog 'prepended underscores'
|
|
|
28f188 |
|
|
|
7e34aa |
ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe'
|
|
|
7e34aa |
ccenv_fn_code='int %s(void){return 0;}'
|
|
|
7e34aa |
|
|
|
305cb2 |
if printf "$ccenv_fn_code" $ccenv_fn_name \
|
|
|
305cb2 |
| $ccenv_cc -xc - -S -o - \
|
|
|
305cb2 |
| grep "^_$ccenv_fn_name:" \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_underscore='_'
|
|
|
28f188 |
ccenv_attr_epilog 'yes'
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_attr_epilog 'no'
|
|
|
28f188 |
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_create_framework_executable()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
if [ -f $ccenv_image ]; then
|
|
|
7e34aa |
mv $ccenv_image $ccenv_image.tmp
|
|
|
7e34aa |
rm -f $ccenv_image.tmp
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
printf 'int main(void){return 0;}' \
|
|
|
7e34aa |
| $ccenv_cc -xc - \
|
|
|
7e34aa |
-o $ccenv_image \
|
|
|
7e34aa |
|| return 1
|
|
|
7e34aa |
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_create_freestanding_executable()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
if [ -f $ccenv_image ]; then
|
|
|
7e34aa |
mv $ccenv_image $ccenv_image.tmp
|
|
|
7e34aa |
rm -f $ccenv_image.tmp
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "ccenv_cc_underscore" ]; then
|
|
|
7e34aa |
ccenv_start_fn='_start'
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_start_fn='start'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
printf 'int %s(void){return 0;}' "$ccenv_start_fn" \
|
|
|
7e34aa |
| $ccenv_cc -xc - \
|
|
|
7e34aa |
-ffreestanding \
|
|
|
7e34aa |
-nostdlib -nostartfiles \
|
|
|
7e34aa |
-o $ccenv_image \
|
|
|
7e34aa |
|| return 1
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_freestd=yes
|
|
|
7e34aa |
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_set_cc_binfmt_error()
|
|
|
28f188 |
{
|
|
|
28f188 |
ccenv_attr_epilog '(unable to create executable)'
|
|
|
28f188 |
}
|
|
|
28f188 |
|
|
|
7e34aa |
ccenv_set_cc_binfmt()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_use_perk=
|
|
|
400106 |
ccenv_use_otool=
|
|
|
7e34aa |
ccenv_use_readelf=
|
|
|
7e34aa |
ccenv_use_readobj=
|
|
|
7e34aa |
ccenv_use_bfd_objdump=
|
|
|
7e34aa |
ccenv_use_llvm_objdump=
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_attr_prolog 'binary format'
|
|
|
28f188 |
|
|
|
7e34aa |
ccenv_create_framework_executable \
|
|
|
7e34aa |
|| ccenv_create_freestanding_executable \
|
|
|
28f188 |
|| ccenv_set_cc_binfmt_error \
|
|
|
7e34aa |
|| return 0
|
|
|
7e34aa |
|
|
|
7e34aa |
# PE / perk
|
|
|
7e34aa |
if [ -n "$ccenv_perk" ]; then
|
|
|
305cb2 |
if $ccenv_perk $ccenv_image 2>/dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='PE'
|
|
|
305cb2 |
ccenv_use_perk=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# ELF / readelf
|
|
|
7e34aa |
if [ -n "$ccenv_readelf" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_readelf -h $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
305cb2 |
| grep 'Magic:7f454c46' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='ELF'
|
|
|
305cb2 |
ccenv_use_readelf=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# a marble of astonishing design:
|
|
|
7e34aa |
# llvm-readelf also parses PE and Mach-O
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_readelf_llvm" ]; then
|
|
|
7e34aa |
ccenv_readany="$ccenv_readelf_llvm"
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_readany="$ccenv_readelf"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# PE / readelf
|
|
|
7e34aa |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_readany -h $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
305cb2 |
| grep 'Magic:MZ' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='PE'
|
|
|
305cb2 |
ccenv_use_readelf=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
400106 |
# MACHO-64 / otool
|
|
|
400106 |
if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_otool -hv $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep -i 'MH_MAGIC_64' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='MACHO'
|
|
|
305cb2 |
ccenv_use_otool=yes
|
|
|
305cb2 |
fi
|
|
|
400106 |
fi
|
|
|
400106 |
|
|
|
400106 |
# MACHO-32 / otool
|
|
|
400106 |
if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_otool -hv $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep -i 'MH_MAGIC' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='MACHO'
|
|
|
305cb2 |
ccenv_use_otool=yes
|
|
|
305cb2 |
fi
|
|
|
400106 |
fi
|
|
|
400106 |
|
|
|
7e34aa |
# MACHO-64 / readelf
|
|
|
7e34aa |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_readany -h $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep -i 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
305cb2 |
| grep -i '(0xfeedfacf)' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='MACHO'
|
|
|
305cb2 |
ccenv_use_readelf=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# MACHO-32 / readelf
|
|
|
7e34aa |
if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_readany -h $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep -i 'Magic:' | sed -e 's/[ ]*//g' \
|
|
|
305cb2 |
| grep -i '(0xcafebabe)' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='MACHO'
|
|
|
305cb2 |
ccenv_use_readelf=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# MACHO / readobj
|
|
|
7e34aa |
if [ -n "$ccenv_readobj" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_readobj $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep -i 'Format:' | sed 's/ /_/g' \
|
|
|
305cb2 |
| grep -i '_Mach-O_' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='MACHO'
|
|
|
305cb2 |
ccenv_use_readobj=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# MACHO / objdump (llvm)
|
|
|
7e34aa |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_objdump -section-headers $ccenv_image \
|
|
|
305cb2 |
2>/dev/null \
|
|
|
305cb2 |
| grep -i 'file format Mach-O' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='MACHO'
|
|
|
305cb2 |
ccenv_use_objdump=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# MACHO / objdump (bfd)
|
|
|
7e34aa |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
7e34aa |
$ccenv_objdump -h $ccenv_image 2>/dev/null \
|
|
|
7e34aa |
| grep -i 'file format Mach-O' \
|
|
|
7e34aa |
> /dev/null \
|
|
|
7e34aa |
&& ccenv_cc_binfmt='MACHO' \
|
|
|
7e34aa |
&& ccenv_use_objdump=yes
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
# PE / objdump (bfd)
|
|
|
7e34aa |
if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
|
|
|
305cb2 |
if $ccenv_objdump -h $ccenv_image 2>/dev/null \
|
|
|
305cb2 |
| grep -i 'file format pei-' \
|
|
|
305cb2 |
> /dev/null; then
|
|
|
305cb2 |
ccenv_cc_binfmt='PE'
|
|
|
305cb2 |
ccenv_use_bfd_objdump=yes
|
|
|
305cb2 |
fi
|
|
|
7e34aa |
fi
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_cc_binfmt"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_pe()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
if [ -n "$ccenv_freestd" ]; then
|
|
|
7e34aa |
case "$ccenv_cchost" in
|
|
|
7e34aa |
*-midipix | *-midipix-* )
|
|
|
7e34aa |
ccenv_os='midipix' ;;
|
|
|
7e34aa |
*-mingw | *-mingw32 | *-mingw64 )
|
|
|
7e34aa |
ccenv_os='mingw' ;;
|
|
|
7e34aa |
*-mingw-* | *-mingw32-* | *-mingw64 )
|
|
|
7e34aa |
ccenv_os='mingw' ;;
|
|
|
7e34aa |
*-msys | *-msys2 | *-msys-* | *-msys2-* )
|
|
|
7e34aa |
ccenv_os='msys' ;;
|
|
|
7e34aa |
*-cygwin | *-cygwin-* )
|
|
|
7e34aa |
ccenv_os='cygwin' ;;
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_os" ]; then
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_use_perk" ]; then
|
|
|
7e34aa |
ccenv_framework=$($ccenv_perk -y $ccenv_image)
|
|
|
7e34aa |
ccenv_os=${ccenv_framework#*-*-*-*}
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
7e34aa |
$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
|
|
|
7e34aa |
| grep 'cygwin1.dll' > /dev/null \
|
|
|
7e34aa |
&& ccenv_os='cygwin'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
7e34aa |
$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
|
|
|
7e34aa |
| grep 'msys-2.0.dll' > /dev/null \
|
|
|
7e34aa |
&& ccenv_os='msys'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
|
|
|
7e34aa |
$ccenv_objdump_bfd -x $ccenv_image \
|
|
|
7e34aa |
| grep -i 'DLL Name' | grep '.CRT' \
|
|
|
7e34aa |
> /dev/null \
|
|
|
7e34aa |
&& $ccenv_objdump_bfd -x $ccenv_image \
|
|
|
7e34aa |
| grep -i 'DLL Name' | grep '.bss' \
|
|
|
7e34aa |
> /dev/null \
|
|
|
7e34aa |
&& $ccenv_objdump_bfd -x $ccenv_image \
|
|
|
7e34aa |
| grep -i 'DLL Name' | grep '.tls' \
|
|
|
7e34aa |
> /dev/null \
|
|
|
7e34aa |
&& ccenv_os='mingw'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_macho()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
case "$ccenv_cchost" in
|
|
|
7e34aa |
*-apple-darwin* )
|
|
|
7e34aa |
ccenv_os='darwin' ;;
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_attr_prolog 'os name'
|
|
|
28f188 |
|
|
|
7e34aa |
case "$ccenv_cc_binfmt" in
|
|
|
7e34aa |
PE )
|
|
|
7e34aa |
ccenv_set_os_pe ;;
|
|
|
7e34aa |
MACHO )
|
|
|
7e34aa |
ccenv_set_os_macho ;;
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_os" ]; then
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_os"
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
case "$ccenv_cchost" in
|
|
|
7e34aa |
*-*-*-* )
|
|
|
18920b |
ccenv_tip=${ccenv_cchost%-*}
|
|
|
7e34aa |
ccenv_os=${ccenv_tip#*-*-}
|
|
|
7e34aa |
;;
|
|
|
18920b |
*-*-musl | *-*-gnu )
|
|
|
18920b |
ccenv_tip=${ccenv_cchost%-*}
|
|
|
7e34aa |
ccenv_os=${ccenv_tip#*-}
|
|
|
7e34aa |
;;
|
|
|
18920b |
*-*-* )
|
|
|
18920b |
ccenv_os=${ccenv_cchost#*-*-}
|
|
|
18920b |
;;
|
|
|
18920b |
*-* )
|
|
|
18920b |
ccenv_os=${ccenv_cchost#*-}
|
|
|
18920b |
;;
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -z "$ccenv_os" ]; then
|
|
|
7e34aa |
ccenv_os='anyos'
|
|
|
7e34aa |
fi
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_os"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_flags()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
case "$ccenv_os" in
|
|
|
7e34aa |
darwin )
|
|
|
7e34aa |
ccenv_cflags_os='-D_DARWIN_C_SOURCE'
|
|
|
7e34aa |
ccenv_cflags_pic='-fPIC'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
midipix )
|
|
|
7e34aa |
ccenv_cflags_os=
|
|
|
7e34aa |
ccenv_cflags_pic='-fPIC'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
cygwin )
|
|
|
7e34aa |
ccenv_cflags_os=
|
|
|
7e34aa |
ccenv_cflags_pic=
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
msys | msys* | mingw | mingw* )
|
|
|
7e34aa |
ccenv_cflags_os='-U__STRICT_ANSI__'
|
|
|
7e34aa |
ccenv_cflags_pic=
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
* )
|
|
|
7e34aa |
ccenv_cflags_os=
|
|
|
7e34aa |
ccenv_cflags_pic='-fPIC'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_semantics()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
# binary_format - core_api - ex_api - dependency_resolution
|
|
|
7e34aa |
|
|
|
28f188 |
ccenv_attr_prolog 'os semantics'
|
|
|
28f188 |
|
|
|
7e34aa |
case "$ccenv_os" in
|
|
|
7e34aa |
linux )
|
|
|
7e34aa |
ccenv_os_semantics='elf-posix-linux-ldso'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
bsd )
|
|
|
7e34aa |
ccenv_os_semantics='elf-posix-bsd-ldso'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
darwin )
|
|
|
7e34aa |
ccenv_os_semantics='macho-posix-osx-ldso'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
midipix )
|
|
|
7e34aa |
ccenv_os_semantics='pe-posix-winnt-ldso'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
cygwin )
|
|
|
7e34aa |
ccenv_os_semantics='pe-hybrid-winnt-unsafe'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
msys )
|
|
|
7e34aa |
ccenv_os_semantics='pe-hybrid-winnt-unsafe'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
mingw )
|
|
|
7e34aa |
ccenv_os_semantics='pe-win32-winnt-unsafe'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_os_semantics" ]; then
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_os_semantics"
|
|
|
7e34aa |
return 0
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ -n "$ccenv_cc_binfmt" ]; then
|
|
|
7e34aa |
ccenv_os_semantics_pattern='%s-posix-anyos-unknown'
|
|
|
7e34aa |
ccenv_os_semantics=$(printf \
|
|
|
7e34aa |
"$ccenv_os_semantics_pattern" \
|
|
|
7e34aa |
"$ccenv_cc_binfmt" \
|
|
|
7e34aa |
| tr '[:upper:]' '[:lower:]')
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_os_semantics='unknown-posix-anyos-unknown'
|
|
|
7e34aa |
fi
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_os_semantics"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_dso_exrules()
|
|
|
7e34aa |
{
|
|
|
28f188 |
ccenv_attr_prolog 'os dso exrules'
|
|
|
28f188 |
|
|
|
7e34aa |
case "$ccenv_os" in
|
|
|
7e34aa |
midipix )
|
|
|
7e34aa |
ccenv_os_dso_exrules='pe-mdso'
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
* )
|
|
|
7e34aa |
if [ "$ccenv_cc_binfmt" = 'PE' ]; then
|
|
|
7e34aa |
ccenv_os_dso_exrules='pe-dlltool'
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_os_dso_exrules='default'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
esac
|
|
|
28f188 |
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_os_dso_exrules"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_dso_linkage()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
# todo: PIC, PIE, and friends
|
|
|
28f188 |
ccenv_attr_prolog 'os linkage'
|
|
|
7e34aa |
ccenv_os_dso_linkage='default'
|
|
|
28f188 |
ccenv_attr_epilog "$ccenv_os_dso_linkage"
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_darwin()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_os_app_prefix=
|
|
|
7e34aa |
ccenv_os_app_suffix=
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefix=lib
|
|
|
7e34aa |
ccenv_os_lib_suffix=.dylib
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_implib_ext=.invalid
|
|
|
7e34aa |
ccenv_os_libdef_ext=.invalid
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_archive_ext=.a
|
|
|
7e34aa |
ccenv_os_soname=symlink
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefixed_suffix=
|
|
|
7e34aa |
ccenv_os_lib_suffixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_mdso()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_os_app_prefix=
|
|
|
7e34aa |
ccenv_os_app_suffix=
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefix=lib
|
|
|
7e34aa |
ccenv_os_lib_suffix=.so
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_implib_ext=.lib.a
|
|
|
7e34aa |
ccenv_os_libdef_ext=.so.def
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_archive_ext=.a
|
|
|
7e34aa |
ccenv_os_soname=symlink
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
7e34aa |
ccenv_os_lib_suffixed_suffix=
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_dlltool()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_os_app_prefix=
|
|
|
7e34aa |
ccenv_os_app_suffix=.exe
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefix=lib
|
|
|
7e34aa |
ccenv_os_lib_suffix=.dll
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_implib_ext=.dll.a
|
|
|
7e34aa |
ccenv_os_libdef_ext=.def
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_archive_ext=.a
|
|
|
7e34aa |
ccenv_os_soname=copy
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
7e34aa |
ccenv_os_lib_suffixed_suffix=
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_default()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_os_app_prefix=
|
|
|
7e34aa |
ccenv_os_app_suffix=
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefix=lib
|
|
|
7e34aa |
ccenv_os_lib_suffix=.so
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_implib_ext=.invalid
|
|
|
7e34aa |
ccenv_os_libdef_ext=.invalid
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_archive_ext=.a
|
|
|
7e34aa |
ccenv_os_soname=symlink
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
|
|
|
7e34aa |
ccenv_os_lib_suffixed_suffix=
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os_dso_patterns()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
# sover: .so.x.y.z
|
|
|
7e34aa |
# verso: .x.y.z.so
|
|
|
7e34aa |
|
|
|
7e34aa |
case "$ccenv_os" in
|
|
|
7e34aa |
darwin )
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_darwin
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
midipix )
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_mdso
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
cygwin | msys | mingw )
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_dlltool
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
* )
|
|
|
7e34aa |
ccenv_set_os_dso_patterns_default
|
|
|
7e34aa |
;;
|
|
|
7e34aa |
esac
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
b39a10 |
ccenv_set_os_pe_switches()
|
|
|
b39a10 |
{
|
|
|
6173e9 |
if [ "$ccenv_cc_binfmt" = 'PE' ] && [ -z "$ccenv_pe_subsystem" ]; then
|
|
|
b39a10 |
case "$ccenv_os" in
|
|
|
b39a10 |
midipix | mingw )
|
|
|
b39a10 |
ccenv_pe_subsystem='windows'
|
|
|
b39a10 |
;;
|
|
|
b39a10 |
* )
|
|
|
b39a10 |
ccenv_pe_subsystem='console'
|
|
|
b39a10 |
;;
|
|
|
b39a10 |
esac
|
|
|
b39a10 |
fi
|
|
|
b39a10 |
}
|
|
|
b39a10 |
|
|
|
7e34aa |
ccenv_output_defs()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_in="$mb_project_dir/sofort/ccenv/ccenv.in"
|
|
|
7e34aa |
ccenv_mk="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
|
|
|
7c7144 |
ccenv_tmp=
|
|
|
7e34aa |
|
|
|
b39a10 |
if [ "$ccenv_cc_binfmt" = 'PE' ]; then
|
|
|
b39a10 |
ccenv_pe="$mb_project_dir/sofort/ccenv/pedefs.in"
|
|
|
b39a10 |
ccenv_in="$ccenv_in $ccenv_pe"
|
|
|
b39a10 |
fi
|
|
|
b39a10 |
|
|
|
7e34aa |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
7e34aa |
|
|
|
47d854 |
ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
|
|
|
7e34aa |
|
|
|
7e34aa |
sed \
|
|
|
7e34aa |
-e 's/^\s*$/@/g' \
|
|
|
7e34aa |
-e 's/^/NATIVE_/' \
|
|
|
7e34aa |
-e 's/NATIVE_@//g' \
|
|
|
7e34aa |
-e 's/NATIVE_#/#/g' \
|
|
|
7e34aa |
-e 's/ =/=/g' \
|
|
|
7e34aa |
-e 's/ +=/+=/g' \
|
|
|
b39a10 |
$ccenv_in > "$ccenv_tmp"
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_in="$ccenv_tmp"
|
|
|
47d854 |
else
|
|
|
7c7144 |
unset ccenv_tmp
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/ccenv/ccenv.vars" \
|
|
|
7e34aa |
| grep -v '^#')
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_exvars="ccenv_cfgtype ccenv_makevar_prefix"
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_sed_substs=" \
|
|
|
e2dba3 |
$(for __var in $(printf '%s' "$ccenv_vars $ccenv_exvars"); do \
|
|
|
7e34aa |
printf '%s"$%s"%s' "-e 's/@$__var@/'" \
|
|
|
7e34aa |
"$__var" "'/g' "; \
|
|
|
7e34aa |
done)"
|
|
|
7e34aa |
|
|
|
b39a10 |
eval sed $ccenv_sed_substs $ccenv_in \
|
|
|
aa2edb |
| sed -e 's/[[:blank:]]*$//g' \
|
|
|
7e34aa |
> "$ccenv_mk"
|
|
|
7e34aa |
|
|
|
819fc1 |
if [ "$ccenv_cfgtype" = 'host' ]; then
|
|
|
e2dba3 |
for __var in $(printf '%s' "$ccenv_vars"); do
|
|
|
819fc1 |
ccenv_src_var=$__var
|
|
|
819fc1 |
ccenv_dst_var=mb_${__var#*ccenv_}
|
|
|
819fc1 |
ccenv_var_expr='${'$ccenv_src_var':-}'
|
|
|
819fc1 |
eval $ccenv_dst_var=$ccenv_var_expr
|
|
|
819fc1 |
|
|
|
819fc1 |
done
|
|
|
819fc1 |
|
|
|
819fc1 |
mb_host=$ccenv_host
|
|
|
819fc1 |
mb_cchost=$ccenv_cchost
|
|
|
819fc1 |
else
|
|
|
e2dba3 |
for __var in $(printf '%s' "$ccenv_vars"); do
|
|
|
819fc1 |
ccenv_src_var=$__var
|
|
|
819fc1 |
ccenv_dst_var=mb_native_${__var#*ccenv_}
|
|
|
819fc1 |
ccenv_var_expr='${'$ccenv_src_var':-}'
|
|
|
819fc1 |
eval "$ccenv_dst_var=$ccenv_var_expr"
|
|
|
819fc1 |
done
|
|
|
819fc1 |
|
|
|
819fc1 |
mb_native_host=$ccenv_host
|
|
|
819fc1 |
mb_native_cchost=$ccenv_cchost
|
|
|
819fc1 |
fi
|
|
|
47d854 |
|
|
|
47d854 |
if [ -n "${ccenv_tmp:-}" ]; then
|
|
|
47d854 |
rm -f "$ccenv_tmp"
|
|
|
47d854 |
unset ccenv_tmp
|
|
|
47d854 |
fi
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
f4f58f |
ccenv_dso_verify()
|
|
|
f4f58f |
{
|
|
|
f4f58f |
ccenv_str='int foo(int x){return ++x;}'
|
|
|
f4f58f |
ccenv_cmd="$ccenv_cc -xc - -shared -o a.out"
|
|
|
f4f58f |
|
|
|
f4f58f |
rm -f a.out
|
|
|
f4f58f |
|
|
|
f4f58f |
printf '%s' "$ccenv_str" | $ccenv_cmd \
|
|
|
f4f58f |
> /dev/null 2>/dev/null \
|
|
|
f4f58f |
|| mb_disable_shared=yes
|
|
|
f4f58f |
|
|
|
f4f58f |
rm -f a.out
|
|
|
f4f58f |
}
|
|
|
f4f58f |
|
|
|
7e34aa |
ccenv_clean_up()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
rm -f $ccenv_image
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_common_init()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
. "$mb_project_dir/sofort/ccenv/ccenv.vars"
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_cfgtype=$1
|
|
|
7e34aa |
ccenv_cfgfile="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
|
|
|
7e34aa |
ccenv_freestd=
|
|
|
308fbf |
ccenv_cchost=
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
7e34aa |
ccenv_makevar_prefix='NATIVE_'
|
|
|
7e34aa |
ccenv_image='./ccenv/native.a.out'
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_makevar_prefix=
|
|
|
7e34aa |
ccenv_image='./ccenv/host.a.out'
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ $ccenv_cfgtype = 'native' ]; then
|
|
|
7e34aa |
ccenv_prefixes=
|
|
|
7e34aa |
elif [ -n "$mb_cross_compile" ]; then
|
|
|
7e34aa |
ccenv_prefixes="$mb_cross_compile"
|
|
|
7e34aa |
elif [ -n "$mb_host" ]; then
|
|
|
7e34aa |
ccenv_prefixes="$mb_host-"
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_prefixes=
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
|
|
|
7e34aa |
if [ $ccenv_cfgtype = 'host' ]; then
|
|
|
7e34aa |
ccenv_tflags=
|
|
|
248936 |
ccenv_cflags=
|
|
|
248936 |
|
|
|
248936 |
ccenv_cflags="$ccenv_cflags $mb_cflags_debug $mb_cflags_config"
|
|
|
248936 |
ccenv_cflags="$ccenv_cflags $mb_cflags_sysroot $mb_cflags_common"
|
|
|
248936 |
ccenv_cflags="$ccenv_cflags $mb_cflags_cmdline $mb_cflags"
|
|
|
248936 |
ccenv_cflags="$ccenv_cflags $mb_cflags_path $mb_cflags_os"
|
|
|
248936 |
ccenv_cflags="$ccenv_cflags $mb_cflags_site $mb_cflags_strict"
|
|
|
248936 |
ccenv_cflags="$ccenv_cflags $mb_cflags_last $mb_cflags_once"
|
|
|
248936 |
|
|
|
7e34aa |
ccenv_cc="$mb_user_cc"
|
|
|
7e34aa |
ccenv_cpp="$mb_user_cpp"
|
|
|
7e34aa |
ccenv_cxx="$mb_user_cxx"
|
|
|
b39a10 |
|
|
|
b39a10 |
ccenv_pe_subsystem="$mb_pe_subsystem"
|
|
|
b39a10 |
ccenv_pe_image_base="$mb_pe_image_base"
|
|
|
7e34aa |
else
|
|
|
7e34aa |
ccenv_tflags=
|
|
|
7e34aa |
ccenv_cflags="$mb_native_cflags"
|
|
|
7e34aa |
ccenv_cc="$mb_native_cc"
|
|
|
7e34aa |
ccenv_cpp="$mb_native_cpp"
|
|
|
7e34aa |
ccenv_cxx="$mb_native_cxx"
|
|
|
b39a10 |
|
|
|
b39a10 |
ccenv_pe_subsystem="$mb_native_pe_subsystem"
|
|
|
b39a10 |
ccenv_pe_image_base="$mb_native_pe_image_base"
|
|
|
7e34aa |
fi
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_characteristics()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_set_cc_host
|
|
|
7e34aa |
ccenv_set_cc_bits
|
|
|
7e34aa |
ccenv_set_cc_binfmt
|
|
|
28f188 |
ccenv_set_cc_underscore
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_toolchain_variables()
|
|
|
7e34aa |
{
|
|
|
7e34aa |
ccenv_common_init $1
|
|
|
7e34aa |
ccenv_set_cc
|
|
|
7e34aa |
ccenv_set_cpp
|
|
|
7e34aa |
ccenv_set_cxx
|
|
|
7e34aa |
ccenv_set_primary_tools
|
|
|
7e34aa |
ccenv_set_tool_variants
|
|
|
7e34aa |
ccenv_set_characteristics
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_os
|
|
|
7e34aa |
ccenv_set_os_flags
|
|
|
7e34aa |
ccenv_set_os_semantics
|
|
|
7e34aa |
ccenv_set_os_dso_exrules
|
|
|
7e34aa |
ccenv_set_os_dso_linkage
|
|
|
7e34aa |
ccenv_set_os_dso_patterns
|
|
|
b39a10 |
ccenv_set_os_pe_switches
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_output_defs
|
|
|
7e34aa |
ccenv_clean_up
|
|
|
248936 |
|
|
|
1f7e7b |
eval 'ccenv_'${ccenv_cfgtype}'_cc'=\'$ccenv_cc\'
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_host_variables()
|
|
|
7e34aa |
{
|
|
|
28f188 |
output_script_status ${mb_script} \
|
|
|
28f188 |
'detect and query host toolchain ==>'
|
|
|
28f188 |
|
|
|
7e34aa |
ccenv_set_toolchain_variables 'host'
|
|
|
f4f58f |
ccenv_dso_verify
|
|
|
7e34aa |
}
|
|
|
7e34aa |
|
|
|
7e34aa |
ccenv_set_native_variables()
|
|
|
7e34aa |
{
|
|
|
28f188 |
output_script_status ${mb_script} \
|
|
|
28f188 |
'detect and query native toolchain ==>'
|
|
|
28f188 |
|
|
|
52f7e5 |
if [ _$mb_ccenv_skip_native != _yes ]; then
|
|
|
52f7e5 |
ccenv_set_toolchain_variables 'native'
|
|
|
52f7e5 |
fi
|
|
|
7e34aa |
}
|