Redfoxmoon / cross / slibtool

Forked from cross/slibtool 10 months ago
Clone

Blame sofort/ccenv/ccenv.sh

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