Blame sofort/ccenv/ccenv.sh

b8199b
# ccenv.sh: sofort's tool-finding bits,
b8199b
# invoked from within the project-agnostic configure script.
b8199b
9c88f2
# this file is covered by COPYING.SOFORT.
9c88f2
b8199b
# invocation and names of binary tools:
b8199b
# agnostic names (ar, nm, objdump, ...);
b8199b
# target-prefixed agnostic names (x86_64-nt64-midipix-ar, ...);
b8199b
# branded names (llvm-ar, llvm-nm, llvm-objdump, ...);
b8199b
# target-prefixed branded names (x86_64-linux-gnu-gcc-ar, ...);
b8199b
# target-specifying branded tools (llvm-ar --target=x86_64-linux, ...).
b8199b
b8199b
# cross-compilation: default search order:
b8199b
# target-prefixed agnostic tools;
b8199b
# target-prefixed branded tools, starting with the prefix
b8199b
# most commonly associated with the selected compiler (that is,
b8199b
# ``gcc'' when using gcc, and ``llvm'' when using clang);
b8199b
# target-speficying branded tools, starting once again with the
b8199b
# prefix most commonly associated with the selected compiler.
b8199b
b8199b
# internal variables of interest:
b8199b
# ccenv_cfgtype: the type of host being tested (host/native)
b8199b
# ccenv_cfgfile: the configuration file for the host being tested
b8199b
# ccenv_cflags:  the comprehensive cflags for the host being tested
b8199b
# ccenv_cchost:  the host being tested, as reported by -dumpmachine
b8199b
b8199b
b8199b
ccenv_usage()
b8199b
{
b8199b
	cat "$mb_project_dir"/sofort/ccenv/ccenv.usage
b8199b
	exit 0
b8199b
}
b8199b
b8199b
b8199b
ccenv_newline()
b8199b
{
b8199b
	printf '\n' >> "$ccenv_cfgfile"
b8199b
}
b8199b
b8199b
b8199b
ccenv_comment()
b8199b
{
b8199b
	ccenv_internal_str='#'
b8199b
b8199b
	for ccenv_internal_arg ; do
b8199b
		ccenv_internal_str="$ccenv_internal_str $ccenv_internal_arg"
b8199b
	done
b8199b
b8199b
	printf '%s\n' "$ccenv_internal_str" >> "$ccenv_cfgfile"
b8199b
}
b8199b
b8199b
41a2ad
ccenv_tool_prolog()
41a2ad
{
9d04ad
	ccenv_line_dots='.....................................'
27f073
	ccenv_tool_desc=" == checking for ${1}"
41a2ad
	ccenv_tool_dlen="${#ccenv_line_dots}"
41a2ad
0506d8
	printf '\n%s\n' '________________________' >&3
0506d8
	printf "ccenv: checking for ${1}\n\n" >&3
41a2ad
	printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s" \
9d04ad
		"${ccenv_tool_desc}  ${mb_line_dots}"
41a2ad
}
41a2ad
41a2ad
41a2ad
ccenv_tool_epilog()
41a2ad
{
41a2ad
	ccenv_line_dots='................................'
41a2ad
	ccenv_tool_dlen="$((${#ccenv_line_dots} - ${#1}))"
41a2ad
d06451
	case ${ccenv_tool_dlen} in
d06451
		0 | -* )
d06451
			ccenv_tool_dlen='3' ;;
d06451
	esac
d06451
9d04ad
	printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s  %s.\n" \
41a2ad
		"${ccenv_line_dots}" "${1}"
0506d8
0506d8
	if [ "${1}" = 'false' ]; then
0506d8
		printf '\n\nccenv: not (yet) found.\n' >&3
0506d8
	else
0506d8
		printf "\n\nccenv : found $(command -v ${1}).\n" >&3
0506d8
	fi
0506d8
0506d8
	printf '%s\n' '------------------------' >&3
41a2ad
}
41a2ad
41a2ad
e42464
ccenv_tool_variant_epilog()
e42464
{
e42464
	ccenv_expr=${1}='${'${1}':-false}'
e42464
	eval "$ccenv_expr"
e42464
e42464
	ccenv_expr='${'${1}'}'
e42464
	eval ccenv_tool_epilog "$ccenv_expr"
e42464
}
e42464
e42464
41a2ad
ccenv_attr_prolog()
41a2ad
{
9d04ad
	ccenv_line_dots=' .....................................'
9d04ad
	ccenv_attr_desc=" == detect ${ccenv_cfgtype} ${1}"
41a2ad
	ccenv_attr_dlen="${#ccenv_line_dots}"
41a2ad
41a2ad
	printf "%${ccenv_attr_dlen}.${ccenv_attr_dlen}s" \
41a2ad
		"${ccenv_attr_desc} ${ccenv_line_dots}"
0506d8
0506d8
	printf '\n%s\n' '________________________' >&3
0506d8
	printf "ccenv: detecting ${1}\n\n" >&3
41a2ad
}
41a2ad
41a2ad
41a2ad
ccenv_attr_epilog()
41a2ad
{
0506d8
	ccenv_line_dots='................................'
9d04ad
	ccenv_tool_dlen="$((${#ccenv_line_dots} - 1 - ${#1}))"
0506d8
d06451
	case ${ccenv_tool_dlen} in
d06451
		0 | -* )
d06451
			ccenv_tool_dlen='3' ;;
d06451
	esac
d06451
9d04ad
	printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s  %s.\n" \
0506d8
		"${ccenv_line_dots}" "${1}"
0506d8
0506d8
	printf '\n\nccenv: detected result: %s\n' "${1}" >&3
0506d8
	printf '%s\n' '------------------------' >&3
41a2ad
}
41a2ad
41a2ad
b8199b
ccenv_find_tool()
b8199b
{
b8199b
	if [ -z "$ccenv_prefixes" ]; then
820082
		for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
20c025
			ccenv_cmd_args="${@:-}"
20c025
20c025
			if [ -z "$ccenv_cmd_args" ]; then
1a3ec0
				if command -v "$ccenv_candidate" > /dev/null; then
1a3ec0
					ccenv_tool="$ccenv_candidate"
a646dd
					return 0
defc02
				fi
a646dd
			else
1a3ec0
				if command -v "$ccenv_candidate" > /dev/null; then
0506d8
					if "$ccenv_candidate" $@ > /dev/null 2>&3; then
1a3ec0
						ccenv_tool="$ccenv_candidate"
a646dd
						return 0
defc02
					fi
defc02
				fi
a646dd
			fi
b8199b
		done
b8199b
b8199b
		ccenv_tool=false
b8199b
b8199b
		return 0
b8199b
	fi
b8199b
820082
	for ccenv_prefix in $(printf '%s' "$ccenv_prefixes"); do
820082
		for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
b8199b
			ccenv_tool="$ccenv_prefix$ccenv_candidate"
defc02
defc02
			if command -v "$ccenv_tool" > /dev/null; then
defc02
				return 0
defc02
			fi
b8199b
		done
b8199b
	done
b8199b
820082
	for ccenv_candidate in $(printf '%s' "$ccenv_candidates"); do
1a3ec0
		if command -v "$ccenv_candidate" > /dev/null; then
1a3ec0
			ccenv_tool="$ccenv_candidate"
defc02
			return 0
defc02
		fi
b8199b
	done
b8199b
b8199b
	ccenv_tool=false
b8199b
b8199b
	return 0
b8199b
}
b8199b
b8199b
b8199b
ccenv_set_primary_tools()
b8199b
{
b8199b
	ccenv_core_tools="ar nm objdump ranlib size strip strings objcopy"
184bce
	ccenv_hack_tools="addr2line cov elfedit readelf readobj otool"
b8199b
	ccenv_peep_tools="perk mdso dlltool windmc windres"
b8199b
820082
	for __tool in $(printf '%s' "$ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools"); do
41a2ad
		ccenv_tool_prolog "$__tool"
41a2ad
b8199b
		if [ -n "$mb_agnostic" ]; then
b8199b
			ccenv_candidates=" $__tool"
b8199b
b8199b
		elif [ -n "$mb_zealous" ]; then
b8199b
			ccenv_candidates="$mb_zealous-$__tool"
b8199b
b8199b
		elif [ "$mb_toolchain" = 'gcc' ]; then
b8199b
			ccenv_candidates="gcc-$__tool"
b8199b
			ccenv_candidates="$ccenv_candidates $__tool"
b8199b
			ccenv_candidates="$ccenv_candidates llvm-$__tool"
b8199b
b8199b
		elif [ "$mb_toolchain" = 'llvm' ]; then
b8199b
			ccenv_candidates="llvm-$__tool"
b8199b
			ccenv_candidates="$ccenv_candidates $__tool"
b8199b
			ccenv_candidates="$ccenv_candidates gcc-$__tool"
b8199b
b8199b
		elif [ -n "$mb_toolchain" ]; then
b8199b
			ccenv_candidates="$mb_toolchain-$__tool"
b8199b
			ccenv_candidates="$ccenv_candidates $__tool"
b8199b
			ccenv_candidates="$ccenv_candidates gcc-$__tool"
b8199b
			ccenv_candidates="$ccenv_candidates llvm-$__tool"
b8199b
b8199b
		else
b8199b
			ccenv_candidates="$__tool"
b8199b
			ccenv_candidates="$ccenv_candidates gcc-$__tool"
b8199b
			ccenv_candidates="$ccenv_candidates llvm-$__tool"
b8199b
		fi
b8199b
b8199b
		if [ "$ccenv_cfgtype" = 'host' ]; then
b8199b
			ccenv_var_prefix='mb_'
b8199b
		else
b8199b
			ccenv_var_prefix='mb_native_'
b8199b
		fi
b8199b
b8199b
		ccenv_var_name=$ccenv_var_prefix$__tool
b8199b
		ccenv_var_expr='${'$ccenv_var_name':-}'
b8199b
		eval ccenv_var_val=$ccenv_var_expr
b8199b
b8199b
		if [ -n "$ccenv_var_val" ]; then
b8199b
			eval ccenv_$__tool="$ccenv_var_val"
b8199b
		else
b8199b
			ccenv_find_tool
b8199b
			eval ccenv_$__tool="$ccenv_tool"
b8199b
		fi
41a2ad
41a2ad
		ccenv_tool_epilog "$ccenv_tool"
b8199b
	done
b8199b
b8199b
	# windrc
b8199b
	ccenv_windrc="$ccenv_windres"
9a2dde
9a2dde
	# archive format preamble
af3ba4
	if [ -n "$ccenv_dumpmachine_switch" ]; then
af3ba4
		ccenv_libgcc_a_header=$(od -b -N8             \
af3ba4
			$($ccenv_cc -print-file-name=libgcc.a) \
af3ba4
			| head -n1)
af3ba4
	else
af3ba4
		ccenv_libgcc_a_header=
af3ba4
	fi
af3ba4
af3ba4
	# ar (default)
9a2dde
	ccenv_cc_arfmt='common'
9a2dde
9a2dde
	# ar (big)
9a2dde
	ccenv_bigaf_header=$(printf '%s\n' '<bigaf>' | od -b | head -n1)
9a2dde
9a2dde
	if [ "$ccenv_libgcc_a_header" = "$ccenv_bigaf_header" ]; then
9a2dde
		ccenv_cc_arfmt='bigaf'
9a2dde
9a2dde
		for __tool in $(printf '%s' "$ccenv_core_tools"); do
9a2dde
			ccenv_var_name=ccenv_$__tool
9a2dde
			ccenv_var_expr='${'$ccenv_var_name':-}'
9a2dde
			eval ccenv_var_val="$ccenv_var_expr"
9a2dde
9a2dde
			if [ "$ccenv_var_val" != false ]; then
9a2dde
				ccenv_var_val="$ccenv_var_val -X64"
9a2dde
				ccenv_var_expr='${ccenv_var_val:-}'
9a2dde
				eval ccenv_$__tool="$ccenv_var_expr"
9a2dde
			fi
9a2dde
		done
9a2dde
	fi
9a2dde
9a2dde
	# ar (small)
9a2dde
	ccenv_aiaff_header=$(printf '%s\n' '<aiaff>' | od -b | head -n1)
9a2dde
9a2dde
	if [ "$ccenv_libgcc_a_header" = "$ccenv_aiaff_header" ]; then
9a2dde
		ccenv_cc_arfmt='aiaff'
9a2dde
9a2dde
		for __tool in $(printf '%s' "$ccenv_core_tools"); do
9a2dde
			ccenv_var_name=ccenv_$__tool
9a2dde
			ccenv_var_expr='${'$ccenv_var_name':-}'
9a2dde
			eval ccenv_var_val="$ccenv_var_expr"
9a2dde
9a2dde
			if [ "$ccenv_var_val" != false ]; then
9a2dde
				ccenv_var_val="$ccenv_var_val -X32"
9a2dde
				ccenv_var_expr='${ccenv_var_val:-}'
9a2dde
				eval ccenv_$__tool="$ccenv_var_expr"
9a2dde
			fi
9a2dde
		done
9a2dde
	fi
b8199b
}
b8199b
b8199b
ccenv_set_tool_variants()
b8199b
{
b8199b
	# as (asm)
41a2ad
	ccenv_tool_prolog 'as (asm)'
b8199b
	ccenv_candidates=as
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" = false ]; then
b8199b
		ccenv_as_asm=
b8199b
	else
ad0f74
		$ccenv_tool --help 2>&1 | grep -i '.bc assembler' \
b8199b
		|| ccenv_as_asm="$ccenv_tool"
b8199b
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_as_asm'
41a2ad
b8199b
	# as (ll)
41a2ad
	ccenv_tool_prolog 'as (ll)'
b8199b
	ccenv_candidates=llvm-as
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" != false ]; then
b8199b
		ccenv_as_ll="$ccenv_tool"
b8199b
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_as_ll'
41a2ad
b8199b
	# as (mc)
41a2ad
	ccenv_tool_prolog 'as (mc)'
b8199b
	ccenv_candidates=llvm-mc
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" != false ]; then
b8199b
		ccenv_as_mc="$ccenv_tool"
b8199b
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_as_mc'
41a2ad
b8199b
	# ld (bfd)
41a2ad
	ccenv_tool_prolog 'ld (bfd)'
b8199b
	ccenv_candidates=ld.bfd
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" != false ]; then
b8199b
		ccenv_ld_bfd="$ccenv_tool"
b8199b
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_ld_bfd'
41a2ad
b8199b
	# ld (gold)
41a2ad
	ccenv_tool_prolog 'ld (gold)'
b8199b
	ccenv_candidates=ld.gold
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" != false ]; then
b8199b
		ccenv_ld_gold="$ccenv_tool"
b8199b
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_ld_gold'
41a2ad
b8199b
	# ld (lld)
41a2ad
	ccenv_tool_prolog 'ld (lld)'
b8199b
	ccenv_candidates=lld
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" != false ]; then
b8199b
		ccenv_ld_lld="$ccenv_tool"
b8199b
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_ld_lld'
41a2ad
b8199b
	# objdump (bfd)
41a2ad
	ccenv_tool_prolog 'objdump (bfd)'
b8199b
	ccenv_candidates=objdump
b8199b
	ccenv_find_tool
b8199b
241171
	if $ccenv_tool --version | grep -i Binutils > /dev/null; then
241171
		ccenv_objdump_bfd="$ccenv_tool"
241171
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_objdump_bfd'
41a2ad
b8199b
	# objdump (llvm)
41a2ad
	ccenv_tool_prolog 'objdump (llvm)'
b8199b
	ccenv_candidates=llvm-objdump
b8199b
	ccenv_find_tool
b8199b
241171
	if $ccenv_tool --version | grep -i LLVM > /dev/null; then
241171
		ccenv_objdump_llvm="$ccenv_tool"
241171
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_objdump_llvm'
41a2ad
b8199b
	# readelf (bfd)
41a2ad
	ccenv_tool_prolog 'readelf (bfd)'
b8199b
	ccenv_candidates=readelf
b8199b
	ccenv_find_tool
b8199b
241171
	if $ccenv_tool --version | grep -i Binutils > /dev/null; then
241171
		ccenv_readelf_bfd="$ccenv_tool"
241171
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_readelf_bfd'
41a2ad
b8199b
	# readelf (llvm)
41a2ad
	ccenv_tool_prolog 'readelf (llvm)'
b8199b
	ccenv_candidates=llvm-readelf
b8199b
	ccenv_find_tool
b8199b
241171
	if $ccenv_tool --version | grep -i LLVM > /dev/null; then
241171
		ccenv_readelf_llvm="$ccenv_tool"
241171
	fi
b8199b
e42464
	ccenv_tool_variant_epilog 'ccenv_readelf_llvm'
41a2ad
b8199b
	# as
b8199b
	if [ -n "$ccenv_cc" ]; then
b62af2
		ccenv_as='$('"$ccenv_makevar_prefix"'CC) -c -x assembler'
b8199b
	elif [ -n "$mb_agnostic" ]; then
b8199b
		ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
b8199b
	elif [ "$mb_zealous" = 'gcc' ]; then
b8199b
		ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
b8199b
	elif [ -n "$mb_zealous" = 'llvm' ]; then
b8199b
		ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
b8199b
	elif [ "$mb_toolchain" = 'gcc' ]; then
b8199b
		ccenv_as='$('"$ccenv_makevar_prefix"'AS_ASM)'
b8199b
	elif [ "$mb_toolchain" = 'llvm' ]; then
b8199b
		ccenv_as='$('"$ccenv_makevar_prefix"'AS_MC)'
b8199b
	fi
b8199b
b8199b
	# ld
b8199b
	if [ -n "$ccenv_cc" ]; then
b8199b
		ccenv_ld='$('"$ccenv_makevar_prefix"'CC) -nostdlib -nostartfiles'
b8199b
	fi
b8199b
}
b8199b
b8199b
ccenv_set_c_compiler_candidates()
b8199b
{
b8199b
	if   [ -n "$mb_compiler" ]; then
b8199b
		ccenv_candidates="$mb_compiler"
b8199b
b8199b
	elif [ -n "$mb_agnostic" ]; then
b8199b
		ccenv_candidates="c99 c11 cc"
b8199b
b8199b
	elif [ "$mb_zealous" = 'gcc' ]; then
b8199b
		ccenv_candidates="gcc"
b8199b
b8199b
	elif [ "$mb_zealous" = 'llvm' ]; then
b8199b
		ccenv_candidates="clang"
b8199b
b8199b
	elif [ "$mb_toolchain" = 'gcc' ]; then
b8199b
		ccenv_candidates="gcc c99 c11 cc clang"
b8199b
b8199b
	elif [ "$mb_toolchain" = 'llvm' ]; then
b8199b
		ccenv_candidates="clang c99 c11 cc gcc"
b8199b
b8199b
	elif [ -n "$mb_toolchain" ]; then
b8199b
		ccenv_candidates="$mb_toolchain c99 c11 cc gcc clang"
b8199b
b8199b
	else
32fde7
		ccenv_candidates="cc gcc clang c99 c11"
b8199b
	fi
b8199b
}
b8199b
b8199b
b8199b
ccenv_set_cc()
b8199b
{
41a2ad
	ccenv_tool_prolog 'C compiler'
41a2ad
b8199b
	if [ -z "$ccenv_cc" ]; then
b8199b
		ccenv_set_c_compiler_candidates
af3ba4
		ccenv_find_tool
b8199b
		ccenv_cc="$ccenv_tool"
b8199b
	fi
b8199b
af3ba4
b8199b
	if [ "$ccenv_cc" = false ] && [ -n "$mb_compiler" ]; then
b8199b
		ccenv_cc="$mb_compiler"
b8199b
	fi
b8199b
af3ba4
	ccenv_tool_epilog "$ccenv_cc"
af3ba4
af3ba4
af3ba4
	if [ $ccenv_cfgtype = 'host' ]; then
af3ba4
		ccenv_host_cc="$ccenv_cc"
af3ba4
		cfgtest_host_section
af3ba4
		ccenv_host_cc=
af3ba4
	else
af3ba4
		ccenv_native_cc="$ccenv_cc"
af3ba4
		cfgtest_native_section
af3ba4
		ccenv_native_cc=
af3ba4
	fi
af3ba4
33391b
	cfgtest_silent='yes'
33391b
af3ba4
	if cfgtest_compiler_switch -dumpmachine ; then
af3ba4
		ccenv_dumpmachine_switch='-dumpmachine'
af3ba4
	else
af3ba4
		ccenv_dumpmachine_switch=
af3ba4
	fi
af3ba4
19db2b
	if cfgtest_code_snippet_asm 'typedef int dummy;' ; then
19db2b
		eval ccenv_${ccenv_cfgtype}_stdin_input='yes'
19db2b
	else
19db2b
		eval ccenv_${ccenv_cfgtype}_stdin_input='no'
19db2b
	fi
19db2b
33391b
	unset cfgtest_silent
33391b
b8199b
	ccenv_cc_cmd="$ccenv_cc"
993569
	ccenv_errors=
b8199b
b8199b
	if [ "$ccenv_cfgtype" = 'native' ]; then
af3ba4
		if [ -n "$ccenv_dumpmachine_switch" ]; then
af3ba4
			ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
af3ba4
				$ccenv_dumpmachine_switch 2>&3)
af3ba4
		else
687bbd
			ccenv_host=$(printf '%s' $(uname -m)-$(uname -p)-$(uname -o) \
687bbd
				| tr '[[:upper:]]' '[[:lower:]]')
af3ba4
		fi
af3ba4
6894ee
		ccenv_cchost=$ccenv_host
b8199b
		return 0
b8199b
	fi
b8199b
af3ba4
b8199b
	if [ -n "$mb_cchost" ]; then
b8199b
		ccenv_host="$mb_cchost"
b8199b
	elif [ -n "$mb_host" ]; then
b8199b
		ccenv_host="$mb_host"
b8199b
	else
b8199b
		ccenv_host=
b8199b
	fi
b8199b
af3ba4
	if [ -z "$ccenv_host" ] && [ -n "$ccenv_dumpmachine_switch" ]; then
af3ba4
		ccenv_host=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
af3ba4
			$ccenv_dumpmachine_switch 2>&3)
b8199b
		ccenv_cchost=$ccenv_host
af3ba4
af3ba4
	elif [ -z "$ccenv_host" ]; then
af3ba4
		# assume that no -dumpmachine support means native build (fixme)
687bbd
		ccenv_host=$(printf '%s' $(uname -m)-$(uname -p)-$(uname -o) \
687bbd
			| tr '[[:upper:]]' '[[:lower:]]')
af3ba4
		ccenv_cchost=$ccenv_host
af3ba4
af3ba4
	elif [ -n "$ccenv_dumpmachine_switch" ]; then
6136a7
		ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
b8199b
		ccenv_cmd="$ccenv_cc --target=$ccenv_host -E -xc -"
b8199b
b8199b
		if [ -z "$mb_user_cc" ]; then
d769c5
			$(printf %s "$ccenv_cmd") < /dev/null > /dev/null \
b8199b
				2>"$ccenv_tmp" || true
b8199b
b8199b
			ccenv_errors=$(cat "$ccenv_tmp")
b8199b
b8199b
			if [ -z "$ccenv_errors" ]; then
af3ba4
				ccenv_tool_prolog 'C compiler for host'
b8199b
				ccenv_tflags="--target=$ccenv_host"
b8199b
				ccenv_cc="$ccenv_cc $ccenv_tflags"
af3ba4
				ccenv_tool_epilog "$ccenv_cc"
0506d8
			else
0506d8
				printf '%s' "$ccenv_errors" >&3
b8199b
			fi
b8199b
		fi
b8199b
6136a7
		rm -f "$ccenv_tmp"
6136a7
		unset ccenv_tmp
6136a7
af3ba4
		ccenv_cchost=$(eval $ccenv_cc $(printf '%s' "$ccenv_cflags") \
af3ba4
			$ccenv_dumpmachine_switch 2>&3)
b8199b
	fi
b8199b
42085e
	if [ -z "$ccenv_dumpmachine_switch" ] && [ -n "$ccenv_host" ]; then
42085e
		ccenv_cchost="$ccenv_host"
42085e
42085e
	elif [ "$ccenv_cchost" != "$ccenv_host" ]; then
0506d8
		printf 'error!\n' >&2
b8199b
		printf 'ccenv:\n' >&2
b8199b
		printf 'ccenv: ccenv_host:   %s \n' $ccenv_host >&2
b8199b
		printf 'ccenv: ccenv_cchost: %s \n' $ccenv_cchost >&2
b8199b
b8199b
		if [ -z "$ccenv_tflags" ]; then
b8199b
			printf 'ccenv:\n' >&2
b8199b
			printf 'ccenv: ccenv_host and ccenv_cchost do not match, most likely because:\n' >&2
b8199b
			printf 'ccenv: (1) you explicitly set CC (or passed --compiler=...)\n' >&2
b8199b
			printf 'ccenv: (2) the selected compiler does not accept --target=...\n' >&2
b8199b
			printf 'ccenv: (3) the host reported by -dumpmachine differs from the one you requested.\n' >&2
b8199b
		fi
b8199b
b8199b
		if [ -n "$ccenv_errors" ]; then
b8199b
			printf 'ccenv:\n' >&2
b8199b
			printf 'ccenv: something went wrong, see the command and compiler message below.\n\n' >&2
b8199b
			printf 'cmd: %s < /dev/null > /dev/null\n' "$ccenv_cmd" >&2
b8199b
			printf '%s\n\n' "$ccenv_errors" >&2
b8199b
		else
b8199b
			printf 'ccenv:\n' >&2
b8199b
			printf 'ccenv: something went wrong, bailing out.\n\n' >&2
b8199b
		fi
b8199b
b8199b
		return 2
b8199b
	fi
b8199b
}
b8199b
b8199b
ccenv_set_cpp()
b8199b
{
41a2ad
	ccenv_tool_prolog 'C pre-processor'
41a2ad
b8199b
	case "$ccenv_cc_cmd" in
b8199b
		cc | c99 | c11 | gcc)
b8199b
			ccenv_cpp_prefix=
b8199b
			ccenv_candidates="cpp" ;;
b8199b
b8199b
		clang )
b8199b
			ccenv_cpp_prefix=
b8199b
			ccenv_candidates="clang-cpp" ;;
b8199b
b8199b
		*-cc )
b8199b
			ccenv_cpp_prefix=${ccenv_cc_cmd%-cc*}-
b8199b
			ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
b8199b
b8199b
		*-c99 )
b8199b
			ccenv_cpp_prefix=${ccenv_cc_cmd%-c99*}-
b8199b
			ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
b8199b
b8199b
		*-c11 )
b8199b
			ccenv_cpp_prefix=${ccenv_cc_cmd%-c11*}-
b8199b
			ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
b8199b
b8199b
		*-gcc )
b8199b
			ccenv_cpp_prefix=${ccenv_cc_cmd%-gcc*}-
b8199b
			ccenv_candidates="${ccenv_cpp_prefix}cpp" ;;
b8199b
b8199b
		*-clang )
b8199b
			ccenv_cpp_prefix=${ccenv_cc_cmd%-clang*}-
b8199b
			ccenv_candidates="${ccenv_cpp_prefix}clang-cpp" ;;
b8199b
b8199b
		* )
b8199b
			ccenv_cpp="$ccenv_cc -E"
41a2ad
			ccenv_tool_epilog "$ccenv_cpp"
b8199b
			return 0
b8199b
	esac
b8199b
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" = false ]; then
b8199b
		ccenv_cpp="$ccenv_cc -E"
b8199b
	elif [ -n "$ccenv_tflags" ]; then
b8199b
		ccenv_cpp="$ccenv_tool $ccenv_tflags"
b8199b
	else
b8199b
		ccenv_cpp="$ccenv_tool"
b8199b
	fi
41a2ad
41a2ad
	ccenv_tool_epilog "$ccenv_cpp"
b8199b
}
b8199b
b8199b
ccenv_set_cxx()
b8199b
{
41a2ad
	ccenv_tool_prolog 'C++ compiler'
41a2ad
b8199b
	case "$ccenv_cc_cmd" in
b8199b
		cc | c99 | c11 )
b8199b
			ccenv_cxx_prefix=
b8199b
			ccenv_candidates="cxx c++" ;;
b8199b
b8199b
		gcc )
b8199b
			ccenv_cxx_prefix=
b8199b
			ccenv_candidates="g++" ;;
b8199b
b8199b
		clang )
b8199b
			ccenv_cxx_prefix=
b8199b
			ccenv_candidates="clang++" ;;
b8199b
b8199b
		*-gcc )
8bb863
			ccenv_cxx_prefix=${ccenv_cc_cmd%-gcc*}-
8bb863
			ccenv_candidates="${ccenv_cxx_prefix}g++" ;;
b8199b
b8199b
		*-clang )
8bb863
			ccenv_cxx_prefix=${ccenv_cc_cmd%-clang*}-
8bb863
			ccenv_candidates="${ccenv_cxx_prefix}clang++" ;;
8bb863
8bb863
		/*cc | /*c99 | /*c11 )
8bb863
			ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
8bb863
			ccenv_candidates="${ccenv_cxx_prefix}/cxx"
8bb863
			ccenv_candidates="${ccenv_candidates} ${ccenv_cxx_prefix}/c++" ;;
8bb863
8bb863
		/*gcc )
8bb863
			ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
8bb863
			ccenv_candidates="${ccenv_cxx_prefix}/g++" ;;
b8199b
8bb863
		/*clang )
8bb863
			ccenv_cxx_prefix=${ccenv_cc_cmd%/*}
8bb863
			ccenv_candidates="${ccenv_cxx_prefix}/clang++" ;;
b8199b
b8199b
		* )
b8199b
			ccenv_cxx="$ccenv_cc -xc++"
41a2ad
			ccenv_tool_epilog "$ccenv_cxx"
b8199b
			return 0
b8199b
	esac
b8199b
b8199b
	ccenv_find_tool
b8199b
b8199b
	if [ "$ccenv_tool" = false ]; then
b8199b
		ccenv_cxx="$ccenv_cc -xc++"
b8199b
	elif [ -n "$ccenv_tflags" ]; then
b8199b
		ccenv_cxx="$ccenv_tool $ccenv_tflags"
b8199b
	else
b8199b
		ccenv_cxx="$ccenv_tool"
b8199b
	fi
41a2ad
41a2ad
	ccenv_tool_epilog "$ccenv_cxx"
b8199b
}
b8199b
b8199b
ccenv_set_cc_host()
b8199b
{
40017f
	ccenv_attr_prolog 'system'
b8199b
	ccenv_cc_host="$ccenv_cchost"
41a2ad
	ccenv_attr_epilog "$ccenv_cc_host"
b8199b
}
b8199b
b8199b
ccenv_set_cc_bits()
b8199b
{
41a2ad
	ccenv_attr_prolog 'bits'
41a2ad
b8199b
	ccenv_internal_size=
b8199b
	ccenv_internal_type='void *'
b8199b
	ccenv_internal_test='char x[(sizeof(%s) == %s/8) ? 1 : -1];'
b8199b
b8199b
	for ccenv_internal_guess in 64 32 128; do
bd8e11
		if [ -z "${ccenv_internal_size:-}" ]; then
14d3e8
			ccenv_internal_str=$(printf "$ccenv_internal_test"  \
14d3e8
				"$ccenv_internal_type"                      \
b8199b
				"$ccenv_internal_guess")
b8199b
cd7ba4
			ccenv_expr='ccenv_stdin_input=$ccenv_'${ccenv_cfgtype}'_stdin_input'
cd7ba4
			eval ${ccenv_expr}
cd7ba4
cd7ba4
			if [ "$ccenv_stdin_input" = 'yes' ]; then
d466ef
				printf '%s' "$ccenv_internal_str"                   \
d466ef
						| eval $ccenv_cc -S -xc - -o -      \
d466ef
						  $(printf '%s' "$ccenv_cflags")    \
d466ef
					> /dev/null 2>&3                            \
d466ef
				&& ccenv_internal_size=$ccenv_internal_guess
d466ef
			else
d466ef
				ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
d466ef
d466ef
				printf '%s' "$ccenv_internal_str" \
d466ef
					> "$ccenv_tmpname"
d466ef
d466ef
				$ccenv_cc -c "$ccenv_tmpname" -o a.out \
d466ef
					> /dev/null 2>&3                \
d466ef
				&& ccenv_internal_size=$ccenv_internal_guess
d466ef
d466ef
				rm "$ccenv_tmpname"
d466ef
			fi
b8199b
		fi
b8199b
	done
b8199b
b8199b
	ccenv_cc_bits=$ccenv_internal_size
41a2ad
41a2ad
	ccenv_attr_epilog "$ccenv_cc_bits"
b8199b
}
b8199b
b8199b
ccenv_set_cc_underscore()
b8199b
{
41a2ad
	ccenv_attr_prolog 'prepended underscores'
41a2ad
b8199b
	ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe'
b8199b
	ccenv_fn_code='int %s(void){return 0;}'
b8199b
8882cf
	ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
8882cf
8882cf
	printf "$ccenv_fn_code" $ccenv_fn_name \
8882cf
		> "$ccenv_tmpname"
8882cf
8882cf
	$ccenv_cc -c "$ccenv_tmpname" -o a.out \
8882cf
		> /dev/null 2>&3
8882cf
8882cf
	if "$ccenv_nm" a.out | grep          \
8882cf
			-e "^_$ccenv_fn_name" \
8882cf
			-e " _$ccenv_fn_name"  \
8882cf
			> /dev/null; then
241171
		ccenv_cc_underscore='_'
41a2ad
		ccenv_attr_epilog 'yes'
8882cf
	else
8882cf
		ccenv_attr_epilog 'no'
241171
	fi
b8199b
8882cf
	rm "$ccenv_tmpname"
8882cf
	rm a.out
41a2ad
b8199b
	return 0
b8199b
}
b8199b
b8199b
ccenv_create_framework_executable()
b8199b
{
0959e7
	if [ "$ccenv_cfgtype" = 'host' ]; then
0959e7
		if [ "$mb_freestanding" = 'yes' ]; then
0959e7
			return 1
0959e7
		fi
0959e7
	fi
0959e7
b8199b
	if [ -f $ccenv_image ]; then
b8199b
		mv $ccenv_image $ccenv_image.tmp
b8199b
		rm -f $ccenv_image.tmp
b8199b
	fi
b8199b
59541a
	ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
59541a
b8199b
	printf 'int main(void){return 0;}'  \
59541a
		> "$ccenv_tmpname"
b8199b
59541a
	if $ccenv_cc "$ccenv_tmpname" -o $ccenv_image 2>&3; then
59541a
		ccenv_ret=0
0959e7
		ccenv_cc_environment='hosted'
59541a
	else
59541a
		ccenv_ret=1
59541a
	fi
59541a
59541a
	rm "$ccenv_tmpname"
59541a
59541a
	return $ccenv_ret
b8199b
}
b8199b
b8199b
ccenv_create_freestanding_executable()
b8199b
{
b8199b
	if [ -f $ccenv_image ]; then
b8199b
		mv $ccenv_image $ccenv_image.tmp
b8199b
		rm -f $ccenv_image.tmp
b8199b
	fi
b8199b
b8199b
	if [ -z "ccenv_cc_underscore" ]; then
b8199b
		ccenv_start_fn='_start'
b8199b
	else
b8199b
		ccenv_start_fn='start'
b8199b
	fi
b8199b
59541a
	ccenv_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
b8199b
59541a
	printf 'int %s(void){return 0;}' "$ccenv_start_fn" \
59541a
		> "$ccenv_tmpname"
b8199b
59541a
	if $ccenv_cc "$ccenv_tmpname"         \
59541a
			-ffreestanding         \
59541a
			-nostdlib -nostartfiles \
59541a
			-o $ccenv_image          \
59541a
			2>&3; then
59541a
		ccenv_ret=0
0959e7
		ccenv_cc_environment='freestanding'
59541a
	else
59541a
		ccenv_ret=1
59541a
	fi
59541a
59541a
	rm "$ccenv_tmpname"
59541a
59541a
	return $ccenv_ret
b8199b
}
b8199b
41a2ad
ccenv_set_cc_binfmt_error()
41a2ad
{
41a2ad
	ccenv_attr_epilog '(unable to create executable)'
41a2ad
}
41a2ad
b8199b
ccenv_set_cc_binfmt()
b8199b
{
b8199b
	ccenv_use_perk=
184bce
	ccenv_use_otool=
b8199b
	ccenv_use_readelf=
b8199b
	ccenv_use_readobj=
b8199b
	ccenv_use_bfd_objdump=
b8199b
	ccenv_use_llvm_objdump=
b8199b
41a2ad
	ccenv_attr_prolog 'binary format'
41a2ad
b8199b
	ccenv_create_framework_executable               \
b8199b
		|| ccenv_create_freestanding_executable \
41a2ad
		|| ccenv_set_cc_binfmt_error            \
b8199b
		|| return 0
b8199b
b8199b
	# PE / perk
b8199b
	if [ -n "$ccenv_perk" ]; then
0506d8
		if $ccenv_perk $ccenv_image 2>&3; then
241171
			ccenv_cc_binfmt='PE'
241171
			ccenv_use_perk=yes
241171
		fi
b8199b
	fi
b8199b
b8199b
	# ELF / readelf
b8199b
	if [ -n "$ccenv_readelf" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_readelf -h $ccenv_image 2>&3               \
241171
				| grep 'Magic:' | sed -e 's/[ ]*//g' \
241171
				| grep 'Magic:7f454c46'              \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='ELF'
241171
			ccenv_use_readelf=yes
241171
		fi
b8199b
	fi
b8199b
b8199b
	# a marble of astonishing design:
b8199b
	# llvm-readelf also parses PE and Mach-O
b8199b
b8199b
	if [ -n "$ccenv_readelf_llvm" ]; then
b8199b
		ccenv_readany="$ccenv_readelf_llvm"
b8199b
	else
b8199b
		ccenv_readany="$ccenv_readelf"
b8199b
	fi
b8199b
b8199b
	# PE / readelf
b8199b
	if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_readany -h $ccenv_image 2>&3               \
241171
				| grep 'Magic:' | sed -e 's/[ ]*//g' \
241171
				| grep 'Magic:MZ'                    \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='PE'
241171
			ccenv_use_readelf=yes
241171
		fi
b8199b
	fi
b8199b
184bce
	# MACHO-64 / otool
184bce
	if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_otool -hv $ccenv_image 2>&3        \
241171
				| grep -i 'MH_MAGIC_64'      \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='MACHO'
241171
			ccenv_use_otool=yes
241171
		fi
184bce
	fi
184bce
184bce
	# MACHO-32 / otool
184bce
	if [ -n "$ccenv_otool" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_otool -hv $ccenv_image 2>&3        \
241171
				| grep -i 'MH_MAGIC'         \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='MACHO'
241171
			ccenv_use_otool=yes
241171
		fi
184bce
	fi
184bce
b8199b
	# MACHO-64 / readelf
b8199b
	if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_readany -h $ccenv_image 2>&3                    \
241171
				| grep -i 'Magic:' | sed -e 's/[ ]*//g'   \
241171
				| grep -i '(0xfeedfacf)'                  \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='MACHO'
241171
			ccenv_use_readelf=yes
241171
		fi
b8199b
	fi
b8199b
b8199b
	# MACHO-32 / readelf
b8199b
	if [ -n "$ccenv_readany" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_readany -h $ccenv_image 2>&3                    \
241171
				| grep -i 'Magic:' | sed -e 's/[ ]*//g'   \
241171
				| grep -i '(0xcafebabe)'                  \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='MACHO'
241171
			ccenv_use_readelf=yes
241171
		fi
b8199b
	fi
b8199b
b8199b
	# MACHO / readobj
b8199b
	if [ -n "$ccenv_readobj" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_readobj $ccenv_image 2>&3                  \
054076
				| grep -i 'Format:'                  \
054076
				| sed  -e 's/ /_/g'                  \
241171
				| grep -i '_Mach-O_'                 \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='MACHO'
241171
			ccenv_use_readobj=yes
241171
		fi
b8199b
	fi
b8199b
b8199b
	# MACHO / objdump (llvm)
b8199b
	if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
241171
		if $ccenv_objdump -section-headers $ccenv_image  \
0506d8
					2>&3                     \
241171
				| grep -i 'file format Mach-O'   \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='MACHO'
241171
			ccenv_use_objdump=yes
241171
		fi
b8199b
	fi
b8199b
b8199b
	# MACHO / objdump (bfd)
b8199b
	if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		$ccenv_objdump -h  $ccenv_image 2>&3              \
b8199b
			| grep -i 'file format Mach-O'            \
b8199b
				> /dev/null                       \
b8199b
		&& ccenv_cc_binfmt='MACHO'                        \
b8199b
		&& ccenv_use_objdump=yes
b8199b
	fi
b8199b
b8199b
	# PE / objdump (bfd)
b8199b
	if [ -n "$ccenv_objdump" ] && [ -z "$ccenv_cc_binfmt" ]; then
0506d8
		if $ccenv_objdump -h  $ccenv_image 2>&3        \
241171
				| grep -i 'file format pei-'   \
241171
					> /dev/null; then
241171
			ccenv_cc_binfmt='PE'
241171
			ccenv_use_bfd_objdump=yes
241171
		fi
b8199b
	fi
41a2ad
41a2ad
	ccenv_attr_epilog "$ccenv_cc_binfmt"
b8199b
}
b8199b
b8199b
ccenv_set_os_pe()
b8199b
{
0959e7
	if [ "$ccenv_cc_environment" = 'freestanding' ]; then
b8199b
		case "$ccenv_cchost" in
b8199b
			*-midipix | *-midipix-* )
b8199b
				ccenv_os='midipix' ;;
b8199b
			*-mingw | *-mingw32 | *-mingw64 )
b8199b
				ccenv_os='mingw' ;;
b8199b
			*-mingw-* | *-mingw32-* | *-mingw64 )
b8199b
				ccenv_os='mingw' ;;
b8199b
			*-msys | *-msys2 | *-msys-* | *-msys2-* )
b8199b
				ccenv_os='msys' ;;
b8199b
			*-cygwin | *-cygwin-* )
b8199b
				ccenv_os='cygwin' ;;
b8199b
		esac
b8199b
	fi
b8199b
b8199b
	if [ -n "$ccenv_os" ]; then
b8199b
		return 0
b8199b
	fi
b8199b
b8199b
	if [ -n "$ccenv_use_perk" ]; then
b8199b
		ccenv_framework=$($ccenv_perk -y $ccenv_image)
b8199b
		ccenv_os=${ccenv_framework#*-*-*-*}
b8199b
	fi
b8199b
b8199b
	if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
b8199b
		$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
b8199b
			| grep 'cygwin1.dll' > /dev/null                \
b8199b
		&& ccenv_os='cygwin'
b8199b
	fi
b8199b
b8199b
	if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
b8199b
		$ccenv_objdump_bfd -x $ccenv_image | grep -i 'DLL Name' \
b8199b
			| grep 'msys-2.0.dll' > /dev/null               \
b8199b
		&& ccenv_os='msys'
b8199b
	fi
b8199b
b8199b
	if [ -z "$ccenv_os" ] && [ -n "$ccenv_objdump_bfd" ]; then
b8199b
		$ccenv_objdump_bfd -x $ccenv_image          \
b8199b
			| grep -i 'DLL Name' | grep '.CRT'  \
b8199b
				> /dev/null                 \
b8199b
		&& $ccenv_objdump_bfd -x $ccenv_image       \
b8199b
			| grep -i 'DLL Name' | grep '.bss'  \
b8199b
				> /dev/null                 \
b8199b
		&& $ccenv_objdump_bfd -x $ccenv_image       \
b8199b
			| grep -i 'DLL Name' | grep '.tls'  \
b8199b
				> /dev/null                 \
b8199b
		&& ccenv_os='mingw'
b8199b
	fi
b8199b
}
b8199b
b8199b
ccenv_set_os_macho()
b8199b
{
b8199b
	case "$ccenv_cchost" in
b8199b
		*-apple-darwin* )
b8199b
			ccenv_os='darwin' ;;
b8199b
	esac
b8199b
}
b8199b
b8199b
ccenv_set_os()
b8199b
{
41a2ad
	ccenv_attr_prolog 'os name'
41a2ad
b8199b
	case "$ccenv_cc_binfmt" in
b8199b
		PE )
b8199b
			ccenv_set_os_pe ;;
b8199b
		MACHO )
b8199b
			ccenv_set_os_macho ;;
b8199b
	esac
b8199b
b8199b
	if [ -n "$ccenv_os" ]; then
41a2ad
		ccenv_attr_epilog "$ccenv_os"
b8199b
		return 0
b8199b
	fi
b8199b
b8199b
	case "$ccenv_cchost" in
b8199b
		*-*-*-* )
54622d
			ccenv_tip=${ccenv_cchost%-*}
b8199b
			ccenv_os=${ccenv_tip#*-*-}
b8199b
			;;
54622d
		*-*-musl | *-*-gnu )
54622d
			ccenv_tip=${ccenv_cchost%-*}
b8199b
			ccenv_os=${ccenv_tip#*-}
b8199b
			;;
54622d
		*-*-* )
54622d
			ccenv_os=${ccenv_cchost#*-*-}
54622d
			;;
54622d
		*-* )
54622d
			ccenv_os=${ccenv_cchost#*-}
54622d
			;;
b8199b
	esac
b8199b
b8199b
	if [ -z "$ccenv_os" ]; then
b8199b
		ccenv_os='anyos'
b8199b
	fi
41a2ad
41a2ad
	ccenv_attr_epilog "$ccenv_os"
b8199b
}
b8199b
b8199b
ccenv_set_os_flags()
b8199b
{
b8199b
	case "$ccenv_os" in
b8199b
		darwin )
b8199b
			ccenv_cflags_os='-D_DARWIN_C_SOURCE'
b8199b
			ccenv_cflags_pic='-fPIC'
b8199b
			;;
b8199b
		midipix )
b8199b
			ccenv_cflags_os=
b8199b
			ccenv_cflags_pic='-fPIC'
b8199b
			;;
b8199b
		cygwin )
b8199b
			ccenv_cflags_os=
b8199b
			ccenv_cflags_pic=
b8199b
			;;
b8199b
		msys | msys* | mingw | mingw* )
b8199b
			ccenv_cflags_os='-U__STRICT_ANSI__'
b8199b
			ccenv_cflags_pic=
b8199b
			;;
b8199b
		* )
b8199b
			ccenv_cflags_os=
b8199b
			ccenv_cflags_pic='-fPIC'
b8199b
			;;
b8199b
	esac
b8199b
}
b8199b
b8199b
ccenv_set_os_semantics()
b8199b
{
b8199b
	# binary_format - core_api - ex_api - dependency_resolution
b8199b
41a2ad
	ccenv_attr_prolog 'os semantics'
41a2ad
b8199b
	case "$ccenv_os" in
b8199b
		linux )
b8199b
			ccenv_os_semantics='elf-posix-linux-ldso'
b8199b
			;;
b8199b
		bsd )
b8199b
			ccenv_os_semantics='elf-posix-bsd-ldso'
b8199b
			;;
b8199b
		darwin )
b8199b
			ccenv_os_semantics='macho-posix-osx-ldso'
b8199b
			;;
b8199b
		midipix )
b8199b
			ccenv_os_semantics='pe-posix-winnt-ldso'
b8199b
			;;
b8199b
		cygwin )
b8199b
			ccenv_os_semantics='pe-hybrid-winnt-unsafe'
b8199b
			;;
b8199b
		msys )
b8199b
			ccenv_os_semantics='pe-hybrid-winnt-unsafe'
b8199b
			;;
b8199b
		mingw )
b8199b
			ccenv_os_semantics='pe-win32-winnt-unsafe'
b8199b
			;;
b8199b
	esac
b8199b
b8199b
	if [ -n "$ccenv_os_semantics" ]; then
41a2ad
		ccenv_attr_epilog "$ccenv_os_semantics"
b8199b
		return 0
b8199b
	fi
b8199b
b8199b
	if [ -n "$ccenv_cc_binfmt" ]; then
b8199b
		ccenv_os_semantics_pattern='%s-posix-anyos-unknown'
b8199b
		ccenv_os_semantics=$(printf                   \
b8199b
				"$ccenv_os_semantics_pattern"  \
b8199b
				"$ccenv_cc_binfmt"              \
b8199b
			| tr '[:upper:]' '[:lower:]')
b8199b
	else
b8199b
		ccenv_os_semantics='unknown-posix-anyos-unknown'
b8199b
	fi
41a2ad
41a2ad
	ccenv_attr_epilog "$ccenv_os_semantics"
b8199b
}
b8199b
58d03d
ccenv_set_os_dso_format()
58d03d
{
58d03d
	ccenv_attr_prolog 'os dso format'
58d03d
58d03d
	case "$ccenv_cc_arfmt" in
58d03d
		common )
58d03d
			ccenv_cc_sofmt="$ccenv_cc_binfmt"
58d03d
			;;
58d03d
58d03d
		bigaf )
58d03d
			ccenv_libgcc_s_a_header=$(od -b -N8             \
58d03d
				$($ccenv_cc -print-file-name=libgcc_s.a) \
58d03d
					2>/dev/null                       \
58d03d
					| head -n1)
58d03d
58d03d
			ccenv_libgcc_s_so_header=$(od -b -N8             \
58d03d
				$($ccenv_cc -print-file-name=libgcc_s.so) \
58d03d
					2>/dev/null                        \
58d03d
					| head -n1)
58d03d
58d03d
			if [ "$ccenv_libgcc_s_a_header" = "$ccenv_bigaf_header" ]; then
58d03d
				ccenv_cc_sofmt='bigaf'
58d03d
			elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_bigaf_header" ]; then
58d03d
				ccenv_cc_sofmt='bigaf'
58d03d
			else
58d03d
				ccenv_cc_sofmt="$ccenv_cc_binfmt"
58d03d
			fi
58d03d
			;;
58d03d
58d03d
		aiaff )
58d03d
			ccenv_libgcc_s_a_header=$(od -b -N8               \
58d03d
				$($ccenv_cc -print-file-name=libgcc_s.a) \
58d03d
					| head -n1)
58d03d
58d03d
			ccenv_libgcc_s_so_header=$(od -b -N8               \
58d03d
				$($ccenv_cc -print-file-name=libgcc_s.so) \
58d03d
					| head -n1)
58d03d
58d03d
			if [ "$ccenv_libgcc_s_a_header" = "$ccenv_aiaff_header" ]; then
58d03d
				ccenv_cc_sofmt='aiaff'
58d03d
			elif [ "$ccenv_libgcc_s_so_header" = "$ccenv_aiaff_header" ]; then
58d03d
				ccenv_cc_sofmt='aiaff'
58d03d
			else
58d03d
				ccenv_cc_sofmt="$ccenv_cc_binfmt"
58d03d
			fi
58d03d
			;;
58d03d
	esac
58d03d
95d930
	if [ "$ccenv_cfgtype" = 'host' ]; then
95d930
		case "$ccenv_cc_sofmt" in
95d930
			bigaf | aiaff )
95d930
				mb_shared_lib_cmd='$(AR) -rcs'
95d930
				mb_shared_lib_ldflags=
95d930
				;;
95d930
95d930
			* )
95d930
				mb_shared_lib_cmd='$(CC) -shared -o'
95d930
				mb_shared_lib_ldflags='$(LDFLAGS_SHARED)'
95d930
				;;
95d930
		esac
95d930
	fi
95d930
58d03d
	ccenv_attr_epilog "$ccenv_cc_sofmt"
58d03d
}
58d03d
b8199b
ccenv_set_os_dso_exrules()
b8199b
{
41a2ad
	ccenv_attr_prolog 'os dso exrules'
41a2ad
b8199b
	case "$ccenv_os" in
b8199b
		midipix )
b8199b
			ccenv_os_dso_exrules='pe-mdso'
b8199b
			;;
b8199b
		* )
b8199b
			if [ "$ccenv_cc_binfmt" = 'PE' ]; then
b8199b
				ccenv_os_dso_exrules='pe-dlltool'
b8199b
			else
b8199b
				ccenv_os_dso_exrules='default'
b8199b
			fi
b8199b
	esac
41a2ad
41a2ad
	ccenv_attr_epilog "$ccenv_os_dso_exrules"
b8199b
}
b8199b
b8199b
ccenv_set_os_dso_linkage()
b8199b
{
b8199b
	# todo: PIC, PIE, and friends
41a2ad
	ccenv_attr_prolog 'os linkage'
b8199b
	ccenv_os_dso_linkage='default'
41a2ad
	ccenv_attr_epilog "$ccenv_os_dso_linkage"
b8199b
}
b8199b
b8199b
ccenv_set_os_dso_patterns_darwin()
b8199b
{
b8199b
	ccenv_os_app_prefix=
b8199b
	ccenv_os_app_suffix=
b8199b
b8199b
	ccenv_os_lib_prefix=lib
b8199b
	ccenv_os_lib_suffix=.dylib
b8199b
b8199b
	ccenv_os_implib_ext=.invalid
b8199b
	ccenv_os_libdef_ext=.invalid
b8199b
b8199b
	ccenv_os_archive_ext=.a
b8199b
	ccenv_os_soname=symlink
b8199b
b8199b
	ccenv_os_lib_prefixed_suffix=
b8199b
	ccenv_os_lib_suffixed_suffix='$(OS_LIB_SUFFIX)'
b8199b
}
b8199b
b8199b
ccenv_set_os_dso_patterns_mdso()
b8199b
{
b8199b
	ccenv_os_app_prefix=
b8199b
	ccenv_os_app_suffix=
b8199b
b8199b
	ccenv_os_lib_prefix=lib
b8199b
	ccenv_os_lib_suffix=.so
b8199b
b8199b
	ccenv_os_implib_ext=.lib.a
b8199b
	ccenv_os_libdef_ext=.so.def
b8199b
b8199b
	ccenv_os_archive_ext=.a
b8199b
	ccenv_os_soname=symlink
b8199b
b8199b
	ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
b8199b
	ccenv_os_lib_suffixed_suffix=
b8199b
}
b8199b
b8199b
ccenv_set_os_dso_patterns_dlltool()
b8199b
{
b8199b
	ccenv_os_app_prefix=
b8199b
	ccenv_os_app_suffix=.exe
b8199b
b8199b
	ccenv_os_lib_prefix=lib
b8199b
	ccenv_os_lib_suffix=.dll
b8199b
b8199b
	ccenv_os_implib_ext=.dll.a
b8199b
	ccenv_os_libdef_ext=.def
b8199b
b8199b
	ccenv_os_archive_ext=.a
b8199b
	ccenv_os_soname=copy
b8199b
b8199b
	ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
b8199b
	ccenv_os_lib_suffixed_suffix=
b8199b
}
b8199b
b8199b
ccenv_set_os_dso_patterns_default()
b8199b
{
b8199b
	ccenv_os_app_prefix=
b8199b
	ccenv_os_app_suffix=
b8199b
b8199b
	ccenv_os_lib_prefix=lib
b8199b
	ccenv_os_lib_suffix=.so
b8199b
b8199b
	ccenv_os_implib_ext=.invalid
b8199b
	ccenv_os_libdef_ext=.invalid
b8199b
b8199b
	ccenv_os_archive_ext=.a
b8199b
	ccenv_os_soname=symlink
b8199b
b8199b
	ccenv_os_lib_prefixed_suffix='$(OS_LIB_SUFFIX)'
b8199b
	ccenv_os_lib_suffixed_suffix=
b8199b
}
b8199b
b8199b
ccenv_set_os_dso_patterns()
b8199b
{
b8199b
	# sover: .so.x.y.z
b8199b
	# verso: .x.y.z.so
b8199b
b8199b
	case "$ccenv_os" in
b8199b
		darwin )
b8199b
			ccenv_set_os_dso_patterns_darwin
b8199b
			;;
b8199b
		midipix )
b8199b
			ccenv_set_os_dso_patterns_mdso
b8199b
			;;
b8199b
		cygwin | msys | mingw )
b8199b
			ccenv_set_os_dso_patterns_dlltool
b8199b
			;;
b8199b
		* )
b8199b
			ccenv_set_os_dso_patterns_default
b8199b
			;;
b8199b
	esac
b8199b
}
b8199b
ef8273
ccenv_set_os_pe_switches()
ef8273
{
01c95d
	if [ "$ccenv_cc_binfmt" = 'PE' ] && [ -z "$ccenv_pe_subsystem" ]; then
ef8273
		case "$ccenv_os" in
ef8273
			midipix | mingw )
ef8273
				ccenv_pe_subsystem='windows'
ef8273
				;;
ef8273
			* )
ef8273
				ccenv_pe_subsystem='console'
ef8273
				;;
ef8273
		esac
ef8273
	fi
ef8273
}
ef8273
b8199b
ccenv_output_defs()
b8199b
{
b8199b
	ccenv_in="$mb_project_dir/sofort/ccenv/ccenv.in"
b8199b
	ccenv_mk="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
9cdade
	ccenv_tmp=
b8199b
ef8273
	if [ "$ccenv_cc_binfmt" = 'PE' ]; then
ef8273
		ccenv_pe="$mb_project_dir/sofort/ccenv/pedefs.in"
ef8273
		ccenv_in="$ccenv_in $ccenv_pe"
ef8273
	fi
ef8273
b8199b
	if [ $ccenv_cfgtype = 'native' ]; then
b8199b
6136a7
		ccenv_tmp=$(mktemp ./tmp_XXXXXXXXXXXXXXXX)
b8199b
585853
		sed                                      \
2ab193
				-e 's/^[[:space:]]*$/@/g' \
585853
				-e 's/^/NATIVE_/'          \
585853
				-e 's/NATIVE_@//g'          \
585853
				-e 's/NATIVE_#/#/g'          \
585853
				-e 's/       =/=/g'           \
585853
				-e 's/       +=/+=/g'          \
0f92f3
			$(printf '%s ' $ccenv_in)               \
0f92f3
				> "$ccenv_tmp"
b8199b
b8199b
		ccenv_in="$ccenv_tmp"
6136a7
	else
9cdade
		unset ccenv_tmp
b8199b
	fi
b8199b
b53480
	ccenv_var_defs=
c39156
	ccenv_sed_substs="-e s/@ccenv_cfgtype@/${ccenv_cfgtype}/g"
b53480
b8199b
	ccenv_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/ccenv/ccenv.vars" \
b53480
		| grep -v '^#');
b8199b
c39156
	ccenv_exvars="ccenv_makevar_prefix"
b8199b
b53480
	for __var in $(printf '%s' "$ccenv_vars $ccenv_exvars"); do
b53480
		ccenv_sed_subst=$(printf '%s %s%s%s' \
b53480
				'-e' "'s^@$__var@"    \
b53480
				"^___${__var}___"      \
b53480
				"^g'")
b53480
b53480
		ccenv_sed_substs="$ccenv_sed_substs $ccenv_sed_subst"
b53480
b53480
		ccenv_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "${__var}")
b53480
		eval ccenv_var_defs='"$ccenv_var_defs "$ccenv_var_def'
b53480
	done
b8199b
b53480
	eval sed $ccenv_sed_substs $(printf '%s ' $ccenv_in) \
b53480
			| eval m4 $ccenv_var_defs -           \
b53480
			| sed -e 's/[[:blank:]]*$//g'          \
b8199b
		> "$ccenv_mk"
b8199b
42dc30
	if [ "$ccenv_cfgtype" = 'host' ]; then
820082
		for __var in $(printf '%s' "$ccenv_vars"); do
42dc30
			ccenv_src_var=$__var
42dc30
			ccenv_dst_var=mb_${__var#*ccenv_}
42dc30
			ccenv_var_expr='${'$ccenv_src_var':-}'
42dc30
			eval $ccenv_dst_var=$ccenv_var_expr
42dc30
42dc30
		done
42dc30
42dc30
		mb_host=$ccenv_host
42dc30
		mb_cchost=$ccenv_cchost
42dc30
	else
820082
		for __var in $(printf '%s' "$ccenv_vars"); do
42dc30
			ccenv_src_var=$__var
42dc30
			ccenv_dst_var=mb_native_${__var#*ccenv_}
42dc30
			ccenv_var_expr='${'$ccenv_src_var':-}'
42dc30
			eval "$ccenv_dst_var=$ccenv_var_expr"
42dc30
		done
42dc30
42dc30
		mb_native_host=$ccenv_host
42dc30
		mb_native_cchost=$ccenv_cchost
42dc30
	fi
6136a7
6136a7
	if [ -n "${ccenv_tmp:-}" ]; then
6136a7
		rm -f "$ccenv_tmp"
6136a7
		unset ccenv_tmp
6136a7
	fi
a4bfd2
a4bfd2
	eval 'ccenv_'${ccenv_cfgtype}'_cc'=\'$ccenv_cc\'
df7105
	eval 'ccenv_'${ccenv_cfgtype}'_cc_environment'=\'$ccenv_cc_environment\'
b8199b
}
b8199b
4063aa
ccenv_set_cc_switch_vars()
4063aa
{
46f7fe
	printf '\n# %s cflags: supported compiler switches\n' "$ccenv_cfgtype" \
46f7fe
		>> "$ccenv_mk"
46f7fe
4063aa
	if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
95c68a
		ccenv_switch_vars=$(cat                            \
4063aa
			$mb_project_dir/sofort/ccenv/ccswitch.strs  \
4063aa
			$mb_project_dir/project/config/ccswitch.strs \
95c68a
		| grep -v -e '^#' -e '^-Wl,'                          \
95c68a
		| sort -u)
4063aa
	else
b34058
		ccenv_switch_vars=$(grep -v -e '^#' -e '^-Wl,'     \
4063aa
			$mb_project_dir/sofort/ccenv/ccswitch.strs  \
4063aa
			| sort -u)
4063aa
	fi
4063aa
4063aa
	if [ $ccenv_cfgtype = 'host' ]; then
4063aa
		ccenv_makevar_prefix='_CFLAGS_'
4063aa
		cfgtest_host_section
4063aa
	else
4063aa
		ccenv_makevar_prefix='_NATIVE_CFLAGS_'
4063aa
		cfgtest_native_section
4063aa
	fi
4063aa
4063aa
	for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
4063aa
		ccenv_make_var=${ccenv_switch_var%=}
4063aa
		ccenv_make_var=${ccenv_make_var%,}
4063aa
4063aa
		ccenv_make_var=${ccenv_make_var##---}
4063aa
		ccenv_make_var=${ccenv_make_var##--}
4063aa
		ccenv_make_var=${ccenv_make_var##-}
4063aa
4063aa
		ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
4063aa
			| sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
4063aa
4063aa
		ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
4063aa
4063aa
		if cfgtest_compiler_switch "$ccenv_switch_var"; then
4063aa
			ccenv_switch_var=${ccenv_switch_var%=}
4063aa
			ccenv_switch_var=${ccenv_switch_var%,}
4063aa
9484e0
			printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
4063aa
				>> "$ccenv_mk"
4063aa
		else
9484e0
			printf '%-40s=\n' "${ccenv_make_var}" \
4063aa
				>> "$ccenv_mk"
4063aa
		fi
4063aa
	done
4063aa
}
4063aa
b34058
ccenv_set_cc_linker_switch_vars()
b34058
{
b34058
	printf '\n# %s ldflags: supported compiler switches\n' "$ccenv_cfgtype" \
b34058
		>> "$ccenv_mk"
b34058
b34058
	if [ -f $mb_project_dir/project/config/ccswitch.strs ]; then
95c68a
		ccenv_switch_vars=$(cat                            \
b34058
			$mb_project_dir/sofort/ccenv/ccswitch.strs  \
b34058
			$mb_project_dir/project/config/ccswitch.strs \
95c68a
			| grep -e '^-Wl,'                             \
b34058
			| sort -u)
b34058
	else
b34058
		ccenv_switch_vars=$(grep -e '^-Wl,'                \
b34058
			$mb_project_dir/sofort/ccenv/ccswitch.strs  \
b34058
			| sort -u)
b34058
	fi
b34058
b34058
	if [ $ccenv_cfgtype = 'host' ]; then
b34058
		ccenv_makevar_prefix='_LDFLAGS_'
b34058
		cfgtest_host_section
b34058
	else
b34058
		ccenv_makevar_prefix='_NATIVE_LDFLAGS_'
b34058
		cfgtest_native_section
b34058
	fi
b34058
b34058
	for ccenv_switch_var in $(printf '%s' "$ccenv_switch_vars"); do
b34058
		ccenv_make_var=${ccenv_switch_var%=}
b34058
		ccenv_make_var=${ccenv_make_var%,}
b34058
b34058
		ccenv_make_var=${ccenv_make_var##---}
b34058
		ccenv_make_var=${ccenv_make_var##--}
b34058
		ccenv_make_var=${ccenv_make_var##-}
b34058
b34058
		ccenv_make_var=$(printf '%s' "$ccenv_make_var" \
b34058
			| sed -e 's/=/_/g' -e 's/-/_/g' -e 's/,/_/g')
b34058
b34058
		ccenv_make_var="${ccenv_makevar_prefix}${ccenv_make_var}"
b34058
b34058
		if cfgtest_compiler_switch "$ccenv_switch_var"; then
b34058
			ccenv_switch_var=${ccenv_switch_var%=}
b34058
			ccenv_switch_var=${ccenv_switch_var%,}
b34058
b34058
			printf '%-40s= %s\n' "${ccenv_make_var}" "${ccenv_switch_var}" \
b34058
				>> "$ccenv_mk"
b34058
		else
b34058
			printf '%-40s=\n' "${ccenv_make_var}" \
b34058
				>> "$ccenv_mk"
b34058
		fi
b34058
	done
b34058
}
b34058
a1d0ef
ccenv_dso_verify()
a1d0ef
{
a1d0ef
	ccenv_str='int foo(int x){return ++x;}'
a1d0ef
	ccenv_cmd="$ccenv_cc -xc - -shared -o a.out"
a1d0ef
a1d0ef
	rm -f a.out
a1d0ef
d769c5
	printf '%s' "$ccenv_str" | $(printf %s "$ccenv_cmd") \
0506d8
		> /dev/null 2>&3              \
a1d0ef
	|| mb_disable_shared=yes
a1d0ef
a1d0ef
	rm -f a.out
a1d0ef
}
a1d0ef
b8199b
ccenv_clean_up()
b8199b
{
b8199b
	rm -f $ccenv_image
b8199b
}
b8199b
b8199b
ccenv_common_init()
b8199b
{
b8199b
	. "$mb_project_dir/sofort/ccenv/ccenv.vars"
b8199b
b8199b
	ccenv_cfgtype=$1
b8199b
	ccenv_cfgfile="$mb_pwd/ccenv/$ccenv_cfgtype.mk"
6894ee
	ccenv_cchost=
b8199b
b8199b
	if [ $ccenv_cfgtype = 'native' ]; then
b8199b
		ccenv_makevar_prefix='NATIVE_'
b8199b
		ccenv_image='./ccenv/native.a.out'
b8199b
	else
b8199b
		ccenv_makevar_prefix=
b8199b
		ccenv_image='./ccenv/host.a.out'
b8199b
	fi
b8199b
b8199b
	if [ $ccenv_cfgtype = 'native' ]; then
b8199b
		ccenv_prefixes=
b8199b
	elif [ -n "$mb_cross_compile" ]; then
b8199b
		ccenv_prefixes="$mb_cross_compile"
b8199b
	elif [ -n "$mb_host" ]; then
b8199b
		ccenv_prefixes="$mb_host-"
b8199b
	else
b8199b
		ccenv_prefixes=
b8199b
	fi
b8199b
b8199b
	if [ $ccenv_cfgtype = 'host' ]; then
b8199b
		ccenv_tflags=
b06837
		ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
f11003
			OS_DSO_EXRULES=default                          \
f11003
			OS_SONAME=symlink                                \
2a07d4
			OS_ARCHIVE_EXT='.a'                               \
f11003
			.cflags-host)
6701c9
b06837
		ccenv_cflags="${ccenv_cflags#*: }"
b06837
b8199b
		ccenv_cc="$mb_user_cc"
b8199b
		ccenv_cpp="$mb_user_cpp"
b8199b
		ccenv_cxx="$mb_user_cxx"
ef8273
ef8273
		ccenv_pe_subsystem="$mb_pe_subsystem"
ef8273
		ccenv_pe_image_base="$mb_pe_image_base"
b8199b
	else
b8199b
		ccenv_tflags=
b06837
		ccenv_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
f11003
			OS_DSO_EXRULES=default                          \
f11003
			OS_SONAME=symlink                                \
2a07d4
			OS_ARCHIVE_EXT='.a'                               \
f11003
			.cflags-native)
f11003
b06837
		ccenv_cflags="${ccenv_cflags#*: }"
b06837
b8199b
		ccenv_cc="$mb_native_cc"
b8199b
		ccenv_cpp="$mb_native_cpp"
b8199b
		ccenv_cxx="$mb_native_cxx"
ef8273
ef8273
		ccenv_pe_subsystem="$mb_native_pe_subsystem"
ef8273
		ccenv_pe_image_base="$mb_native_pe_image_base"
b8199b
	fi
b8199b
}
b8199b
b8199b
ccenv_set_characteristics()
b8199b
{
b8199b
	ccenv_set_cc_host
b8199b
	ccenv_set_cc_bits
b8199b
	ccenv_set_cc_binfmt
41a2ad
	ccenv_set_cc_underscore
b8199b
}
b8199b
b8199b
ccenv_set_toolchain_variables()
b8199b
{
b8199b
	ccenv_common_init $1
b8199b
	ccenv_set_cc
b8199b
	ccenv_set_cpp
b8199b
	ccenv_set_cxx
b8199b
	ccenv_set_primary_tools
b8199b
	ccenv_set_tool_variants
b8199b
	ccenv_set_characteristics
b8199b
b8199b
	ccenv_set_os
b8199b
	ccenv_set_os_flags
b8199b
	ccenv_set_os_semantics
58d03d
	ccenv_set_os_dso_format
b8199b
	ccenv_set_os_dso_exrules
b8199b
	ccenv_set_os_dso_linkage
b8199b
	ccenv_set_os_dso_patterns
ef8273
	ccenv_set_os_pe_switches
b8199b
b8199b
	ccenv_output_defs
b8199b
	ccenv_clean_up
4063aa
4063aa
	ccenv_set_cc_switch_vars
b34058
	ccenv_set_cc_linker_switch_vars
b8199b
}
b8199b
b8199b
ccenv_set_host_variables()
b8199b
{
41a2ad
	output_script_status ${mb_script} \
581684
		'detect and query host (targeted) system'
41a2ad
b8199b
	ccenv_set_toolchain_variables 'host'
a1d0ef
	ccenv_dso_verify
b8199b
}
b8199b
b8199b
ccenv_set_native_variables()
b8199b
{
41a2ad
	output_script_status ${mb_script} \
581684
		'detect and query native (local build) system'
41a2ad
9aae4c
	if [ _$mb_ccenv_skip_native != _yes ]; then
9aae4c
		ccenv_set_toolchain_variables 'native'
9aae4c
	fi
b8199b
}