Blame sofort/ccenv/ccenv.sh

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