Blame sofort/cfgtest/cfgtest.sh

f008d3
# cfgtest.sh: sofort's config test framework,
f008d3
# for use from within a project's custom cfgdefs.sh.
f008d3
f008d3
# this file is covered by COPYING.SOFORT.
f008d3
f008d3
# in the common scenario, host-specific tests are preceded
f008d3
# by a single invocation of cfgtest_host_section, whereas
f008d3
# native (build) system tests are preceded by the invocation
f008d3
# of cfgtest_native_section.
f008d3
f008d3
# cfgdefs fraework variables:
f008d3
# mb_cfgtest_cc:      the compiler used for the current test
f008d3
# mb_cfgtest_cflags:  the compiler flags used for the current test
f008d3
# mb_cfgtest_cfgtype: the type of the current test (host/native)
f008d3
# mb_cfgtest_makevar: the make variable affected by the current test
f008d3
# mb_cfgtest_headers: headers for ad-hoc inclusion with the current test
f008d3
f008d3
f008d3
cfgtest_newline()
f008d3
{
f008d3
	printf '\n' >> $mb_pwd/cfgdefs.mk
f008d3
}
f008d3
f008d3
f008d3
cfgtest_comment()
f008d3
{
f008d3
	mb_internal_str='#'
f008d3
f008d3
	for mb_internal_arg ; do
f008d3
		mb_internal_str="$mb_internal_str $mb_internal_arg"
f008d3
	done
f008d3
f008d3
	printf '%s\n' "$mb_internal_str" >> $mb_pwd/cfgdefs.mk
f008d3
}
f008d3
f008d3
f008d3
cfgtest_host_section()
f008d3
{
f008d3
	mb_cfgtest_cc="$ccenv_host_cc"
f008d3
	mb_cfgtest_cfgtype='host'
10b5c0
10b5c0
	mb_cfgtest_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
10b5c0
		OS_DSO_EXRULES=default                              \
10b5c0
		OS_SONAME=symlink                                   \
10b5c0
		OS_ARCHIVE_EXT='.a'                                 \
10b5c0
		.cflags-host)
10b5c0
f008d3
	mb_cfgtest_cflags="${mb_cfgtest_cflags#*: }"
f008d3
f008d3
	mb_cfgtest_ldflags="$mb_ldflags_cmdline"
f008d3
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_debug"
f008d3
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_common"
f008d3
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_strict"
f008d3
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_config"
f008d3
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_sysroot"
f008d3
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_path"
f008d3
	mb_cfgtest_ldflags="$mb_cfgtest_ldflags $mb_ldflags_last"
f008d3
}
f008d3
f008d3
f008d3
cfgtest_native_section()
f008d3
{
10b5c0
	mb_cfgtest_cc="$ccenv_native_cc"
f008d3
	mb_cfgtest_cfgtype='native'
10b5c0
10b5c0
	mb_cfgtest_cflags=$(${mb_make} -n -f "$mb_pwd/Makefile.tmp" \
10b5c0
		OS_DSO_EXRULES=default                              \
10b5c0
		OS_SONAME=symlink                                   \
10b5c0
		OS_ARCHIVE_EXT='.a'                                 \
10b5c0
		.cflags-native)
10b5c0
f008d3
	mb_cfgtest_cflags="${mb_cfgtest_cflags#*: }"
f008d3
	mb_cfgtest_ldflags="$mb_native_ldflags"
f008d3
}
f008d3
f008d3
f008d3
cfgtest_prolog()
f008d3
{
cfdd3f
	cfgtest_line_dots='...........................'
f008d3
	cfgtest_line_dots="${cfgtest_line_dots}${cfgtest_line_dots}"
f008d3
	cfgtest_tool_desc=" == trying ${mb_cfgtest_cfgtype} ${1}: ${2}"
f008d3
	cfgtest_tool_dlen="${#cfgtest_line_dots}"
f008d3
f008d3
	printf '\n%s\n' '________________________' >&3
f008d3
	printf "cfgtest: probing for ${mb_cfgtest_cfgtype} ${1}: ${2}\n\n" >&3
70971e
70971e
	if [ "${cfgtest_silent:-}" != 'yes' ]; then
70971e
		printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s" \
70971e
			"${cfgtest_tool_desc}  ${mb_line_dots}"
70971e
	fi
f008d3
}
f008d3
f008d3
f008d3
cfgtest_epilog()
f008d3
{
cfdd3f
	cfgtest_line_dots='...............'
f008d3
	cfgtest_tool_dlen="$((${#cfgtest_line_dots} - ${#2}))"
f008d3
70971e
	if [ "${cfgtest_silent:-}" != 'yes' ]; then
70971e
		printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s  %s.\n" \
70971e
			"${cfgtest_line_dots}" "${2}"
70971e
	fi
f008d3
0ddff7
	if [ "${1}" = 'snippet' ] && [ -f 'a.out' ]; then
f008d3
		rm -f 'a.out'
f008d3
	fi
f008d3
f008d3
	if [ "${1}" = 'snippet' ] && [ "${2}" = '(error)' ]; then
f008d3
		printf '\n\ncfgtest: the %s compiler %s %s.\n' \
f008d3
			"$mb_cfgtest_cfgtype"                 \
f008d3
			'failed to compile the above code'   \
f008d3
			"${1}" >&3
f008d3
		printf '%s\n' '------------------------' >&3
f008d3
		return 1
f008d3
	fi
f008d3
f008d3
	if [ "${2}" = '-----' ]; then
f008d3
		printf '\n\ncfgtest: %s %s is missing or cannot be found.\n' "${1}" "${3}" >&3
f008d3
		printf '%s\n' '------------------------' >&3
f008d3
		return 1
f008d3
	elif [ "${1}" = 'size-of-type' ] && [ "${2}" = '(error)' ]; then
f008d3
		printf '\n\ncfgtest: could not determine size of type `%s.\n' "${3}'" >&3
f008d3
		printf '%s\n' '------------------------' >&3
f008d3
		return 1
dde97b
	elif [ "${1}" = 'switch' ] && [ "${2}" = '(error)' ]; then
dde97b
		printf '\n\ncfgtest: the switch `%s is not supported by the %s compiler.\n' \
dde97b
			"${3}'" "$mb_cfgtest_cfgtype" >&3
dde97b
		printf '%s\n' '------------------------' >&3
dde97b
		return 1
f008d3
	elif [ "${2}" = '(error)' ]; then
f008d3
		printf '\n\ncfgtest: %s `%s is not defined or cannot be used.\n' "${1}" "${3}'" >&3
f008d3
		printf '%s\n' '------------------------' >&3
f008d3
		return 1
f008d3
	fi
f008d3
}
f008d3
f008d3
f008d3
cfgtest_entity_size_prolog()
f008d3
{
f008d3
	cfgtest_line_dots='.......................'
f008d3
	cfgtest_line_dots="${cfgtest_line_dots}${cfgtest_line_dots}"
f008d3
	cfgtest_tool_desc=" == checking size of ${mb_cfgtest_cfgtype} type: ${@}"
f008d3
	cfgtest_tool_dlen="${#cfgtest_line_dots}"
f008d3
f008d3
	printf '\n%s\n' '________________________' >&3
f008d3
	printf "cfgtest: checking size of ${mb_cfgtest_cfgtype} type: ${@}\n\n" >&3
f008d3
f008d3
	printf "%${cfgtest_tool_dlen}.${cfgtest_tool_dlen}s" \
f008d3
		"${cfgtest_tool_desc}  ${mb_line_dots}"
f008d3
}
f008d3
f008d3
f008d3
cfgtest_makevar_append()
f008d3
{
f008d3
	mb_internal_str='+='
f008d3
f008d3
	for mb_internal_arg ; do
f008d3
		if ! [ -z "$mb_internal_arg" ]; then
f008d3
			mb_internal_str="$mb_internal_str $mb_internal_arg"
f008d3
		fi
f008d3
	done
f008d3
f008d3
	printf '%-24s%s\n' "$mb_cfgtest_makevar" "$mb_internal_str" \
f008d3
		>> $mb_pwd/cfgdefs.mk
f008d3
f008d3
	unset cfgtest_internal_unit_test
f008d3
}
f008d3
f008d3
f008d3
cfgtest_cflags_append()
f008d3
{
f008d3
	if [ $mb_cfgtest_cfgtype = 'host' ]; then
f008d3
		mb_internal_makevar='CFLAGS_CONFIG'
f008d3
	else
f008d3
		mb_internal_makevar='NATIVE_CFLAGS'
f008d3
	fi
f008d3
f008d3
	mb_cfgtest_makevar_saved=$mb_cfgtest_makevar
f008d3
	mb_cfgtest_makevar=$mb_internal_makevar
f008d3
f008d3
	cfgtest_makevar_append "$@"
f008d3
	mb_cfgtest_makevar=$mb_cfgtest_makevar_saved
f008d3
}
f008d3
f008d3
f008d3
cfgtest_ldflags_append()
f008d3
{
f008d3
	if [ $mb_cfgtest_cfgtype = 'host' ]; then
f008d3
		mb_internal_makevar='LDFLAGS_CONFIG'
f008d3
	else
f008d3
		mb_internal_makevar='NATIVE_LDFLAGS'
f008d3
	fi
f008d3
f008d3
	mb_cfgtest_makevar_saved=$mb_cfgtest_makevar
f008d3
	mb_cfgtest_makevar=$mb_internal_makevar
f008d3
f008d3
	cfgtest_makevar_append "$@"
f008d3
	mb_cfgtest_makevar=$mb_cfgtest_makevar_saved
f008d3
}
f008d3
f008d3
f008d3
cfgtest_common_init()
f008d3
{
f008d3
	# cfgtest variables
f84d3a
	cfgtest_type="${1:-}"
f84d3a
f84d3a
	if [ "$cfgtest_type" = 'asm' ]; then
f008d3
		cfgtest_fmt='%s -c -xc - -o a.out'
f84d3a
	elif [ "$cfgtest_type" = 'lib' ]; then
f008d3
		cfgtest_fmt='%s -xc - -o a.out'
f008d3
	else
f008d3
		cfgtest_fmt='%s -S -xc - -o -'
f008d3
	fi
f008d3
dde97b
f84d3a
	if [ "$cfgtest_type" = 'lib' ]; then
f008d3
		cfgtest_cmd=$(printf "$cfgtest_fmt %s %s %s" \
f008d3
			"$mb_cfgtest_cc"                     \
f008d3
			"$mb_cfgtest_cflags"                 \
f008d3
			"$mb_cfgtest_ldflags"                \
f008d3
			"$cfgtest_libs")
dde97b
dde97b
	elif [ "$cfgtest_type" = 'switch' ]; then
dde97b
		cfgtest_cmd=$(printf "$cfgtest_fmt %s %s" \
dde97b
			"$mb_cfgtest_cc"                  \
dde97b
			"$mb_cfgtest_cflags"              \
dde97b
			"$cfgtest_switches")
f008d3
	else
f008d3
		cfgtest_cmd=$(printf "$cfgtest_fmt %s" \
f008d3
			"$mb_cfgtest_cc"               \
f008d3
			"$mb_cfgtest_cflags")
f008d3
	fi
f008d3
dde97b
f84d3a
	if [ -z "$mb_cfgtest_headers" ] || [ "$cfgtest_type" = 'lib' ]; then
f008d3
		cfgtest_inc=
f008d3
		cfgtest_src="$cfgtest_code_snippet"
dde97b
dde97b
	elif [ "$cfgtest_type" = 'switch' ]; then
dde97b
		cfgtest_inc=
dde97b
		cfgtest_src=
f008d3
	else
f008d3
		cfgtest_inc=$(printf '#include <%s>\n' $mb_cfgtest_headers)
f008d3
		cfgtest_src=$(printf '%s\n_\n' "$cfgtest_inc" \
f008d3
			| m4 -D_="$cfgtest_code_snippet")
f008d3
	fi
f008d3
dde97b
f008d3
	# config.log
f008d3
	printf "$cfgtest_fmt" "$mb_cfgtest_cc" >&3
f008d3
d360e0
	for cfgtest_cflag in $(printf '%s' "$mb_cfgtest_cflags"); do
f008d3
		printf ' \\\n\t%s' "$cfgtest_cflag" >&3
f008d3
	done
f008d3
f84d3a
	if [ "$cfgtest_type" = 'lib' ]; then
d360e0
		for cfgtest_lib in $(printf '%s' "$cfgtest_libs"); do
f008d3
			printf ' \\\n\t%s' "$cfgtest_lib" >&3
f008d3
		done
dde97b
dde97b
	elif [ "$cfgtest_type" = 'switch' ]; then
d360e0
		for cfgtest_switch in $(printf '%s' "$cfgtest_switches"); do
dde97b
			printf ' \\\n\t%s' "$cfgtest_switch" >&3
dde97b
		done
f008d3
	fi
f008d3
f008d3
	printf ' \\\n'                           >&3
f008d3
	printf '<< _SRCEOF\n%s\n' "$cfgtest_src" >&3
f008d3
	printf '_SRCEOF \n\n\n'                  >&3
f008d3
}
f008d3
f008d3
f008d3
cfgtest_header_presence()
f008d3
{
f008d3
	#init
f008d3
	cfgtest_prolog 'header' "${1}"
f008d3
f008d3
	cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}")
f008d3
f008d3
	cfgtest_common_init
f008d3
f008d3
	# execute
f008d3
	printf '%s' "$cfgtest_src"                  \
f008d3
		| eval $(printf '%s' "$cfgtest_cmd") \
f008d3
		> /dev/null 2>&3                      \
f008d3
	|| cfgtest_epilog 'header' '-----' "<${1}>"    \
f008d3
	|| return
f008d3
f008d3
	# result
f008d3
	mb_internal_str=$(printf '%s%s' '-DHAVE_' "${1}"  \
f008d3
			| sed -e 's/\./_/g' -e 's@/@_@g'  \
f008d3
			| tr "[:lower:]" "[:upper:]")
f008d3
f008d3
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
f008d3
		cfgtest_cflags_append "$mb_internal_str"
f008d3
	else
f008d3
		cfgtest_makevar_append "$mb_internal_str"
f008d3
	fi
f008d3
f008d3
	printf 'cfgtest: %s header <%s> was found and may be included.\n' \
f008d3
		"$mb_cfgtest_cfgtype" "${1}" >&3
f008d3
	printf '%s\n' '------------------------' >&3
f008d3
f008d3
	cfgtest_epilog 'header' "${1}"
f008d3
}
f008d3
f008d3
f008d3
cfgtest_header_absence()
f008d3
{
f008d3
	#init
f008d3
	cfgtest_prolog 'header absence' "${1}"
f008d3
f008d3
	cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}")
f008d3
f008d3
	cfgtest_common_init
f008d3
f008d3
	# execute
f008d3
	printf '%s' "$cfgtest_src"                  \
f008d3
		| eval $(printf '%s' "$cfgtest_cmd") \
f008d3
		> /dev/null 2>&3                      \
f008d3
	&& printf 'cfgtest: %s header <%s>: no error.' \
f008d3
		"$mb_cfgtest_cfgtype" "${1}" >&3        \
f008d3
	&& cfgtest_epilog 'header' "${1}"                \
f008d3
	&& return
f008d3
f008d3
	# result
f008d3
	mb_internal_str=$(printf '%s%s' '-DHAVE_NO_' "$@" \
f008d3
			| sed -e 's/\./_/g' -e 's@/@_@g'  \
f008d3
			| tr "[:lower:]" "[:upper:]")
f008d3
f008d3
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
f008d3
		cfgtest_cflags_append "$mb_internal_str"
f008d3
	else
f008d3
		cfgtest_makevar_append "$mb_internal_str"
f008d3
	fi
f008d3
f008d3
	printf 'cfgtest: %s header <%s> may not be included.\n' \
f008d3
		"$mb_cfgtest_cfgtype" "${1}" >&3
f008d3
	printf '%s\n' '------------------------' >&3
f008d3
c294c6
	cfgtest_epilog 'header' '-----' "${1}"
f008d3
}
f008d3
f008d3
f008d3
cfgtest_interface_presence()
f008d3
{
f008d3
	# init
f008d3
	cfgtest_prolog 'interface' "${1}"
f008d3
f008d3
	cfgtest_code_snippet=$(printf 'void * addr = &%;;\n' "${1}")
f008d3
f008d3
	cfgtest_common_init
f008d3
f008d3
	# execute
f008d3
	printf '%s' "$cfgtest_src"                    \
f008d3
		| eval $(printf '%s' "$cfgtest_cmd")   \
f008d3
		> /dev/null 2>&3                        \
f008d3
	|| cfgtest_epilog 'interface' '(error)' "${1}"   \
f008d3
	|| return
f008d3
f008d3
	# result
f008d3
	mb_internal_str=$(printf '%s%s' '-DHAVE_' "$@"  \
f008d3
			| sed -e 's/\./_/g'             \
f008d3
			| tr "[:lower:]" "[:upper:]")
f008d3
f008d3
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
f008d3
		cfgtest_cflags_append "$mb_internal_str"
f008d3
	else
f008d3
		cfgtest_makevar_append "$mb_internal_str"
f008d3
	fi
f008d3
f008d3
	printf 'cfgtest: %s interface `%s'"'"' is available.\n' \
f008d3
		"$mb_cfgtest_cfgtype" "${1}" >&3
f008d3
	printf '%s\n' '------------------------' >&3
f008d3
f008d3
	cfgtest_epilog 'interface' "${1}"
f008d3
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_decl_presence()
f008d3
{
f008d3
	# init
f008d3
	cfgtest_prolog 'decl' "${1}"
f008d3
f008d3
	cfgtest_code_snippet=$(printf 'void * any = (void *)(%s);' "${1}")
f008d3
f008d3
	cfgtest_common_init
f008d3
f008d3
	# execute
f008d3
	printf '%s' "$cfgtest_src"                  \
f008d3
		| eval $(printf '%s' "$cfgtest_cmd") \
f008d3
		> /dev/null 2>&3                      \
f008d3
	|| cfgtest_epilog 'decl' '(error)' "${1}"      \
f008d3
	|| return
f008d3
f008d3
	# does the argument solely consist of the macro or enum member name?
f008d3
	mb_internal_str=$(printf '%s' "$@" | tr -d '[a-z][A-Z][0-9][_]')
f008d3
f008d3
	if [ -n "$mb_internal_str" ]; then
f008d3
		cfgtest_epilog 'decl' '(defined)'
f008d3
		return 0
f008d3
	fi
f008d3
f008d3
	# result
f008d3
	mb_internal_str=$(printf '%s%s' '-DHAVE_DECL_' "$@"  \
f008d3
			| sed -e 's/\./_/g'                  \
f008d3
			| tr "[:lower:]" "[:upper:]")
f008d3
f008d3
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
f008d3
		cfgtest_cflags_append "$mb_internal_str"
f008d3
	else
f008d3
		cfgtest_makevar_append "$mb_internal_str"
f008d3
	fi
f008d3
f008d3
	printf 'cfgtest: `%s'"'"' is defined for the %s system.\n' \
f008d3
		"${1}" "$mb_cfgtest_cfgtype" >&3
f008d3
	printf '%s\n' '------------------------' >&3
f008d3
f008d3
	cfgtest_epilog 'decl' '(defined)'
f008d3
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_type_size()
f008d3
{
f008d3
	cfgtest_entity_size_prolog "$@"
f008d3
f008d3
	mb_internal_size=''
f008d3
	mb_internal_test='char x[(sizeof(%s) == %s) ? 1 : -1];'
f008d3
f008d3
	for mb_internal_guess in 8 4 2 1 16 32 64 128; do
f008d3
		if [ -z $mb_internal_size ]; then
f008d3
			printf '# guess %s ===>\n' "$mb_internal_guess" >&3
f008d3
f008d3
			mb_internal_type="$@"
f008d3
f008d3
			cfgtest_code_snippet=$(printf "$mb_internal_test" \
f008d3
				"$mb_internal_type" "$mb_internal_guess")
f008d3
f008d3
			cfgtest_common_init
f008d3
f008d3
			printf '%s' "$cfgtest_src"                  \
f008d3
				| eval $(printf '%s' "$cfgtest_cmd") \
f008d3
				> /dev/null 2>&3                      \
f008d3
			&& mb_internal_size=$mb_internal_guess
f008d3
f008d3
			printf '\n' >&3
f008d3
		fi
f008d3
	done
f008d3
f008d3
	# unrecognized type, or type size not within range
f008d3
	if [ -z $mb_internal_size ]; then
f008d3
		cfgtest_epilog 'size-of-type' '(error)' "@"
f008d3
		return 1
f008d3
	fi
f008d3
f008d3
	# -DSIZEOF_TYPE=SIZE
f008d3
	mb_internal_str=$(printf '%s%s=%s' '-DSIZEOF_'        \
f008d3
				"$mb_internal_type"           \
f008d3
				"$mb_internal_size"           \
f008d3
			| sed -e 's/\ /_/g' -e 's/*/P/g'      \
f008d3
			| tr "[:lower:]" "[:upper:]")
f008d3
f008d3
	if [ -z ${cfgtest_internal_unit_test:-} ]; then
f008d3
		cfgtest_cflags_append "$mb_internal_str"
f008d3
	else
f008d3
		cfgtest_makevar_append "$mb_internal_str"
f008d3
	fi
f008d3
f008d3
	printf 'cfgtest: size of type `%s'"'"' determined to be %s\n' \
f008d3
		"${@}" "$mb_internal_size" >&3
f008d3
	printf '%s\n' '------------------------' >&3
f008d3
f008d3
	cfgtest_epilog 'size-of-type' "$mb_internal_size"
f008d3
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_code_snippet_asm()
f008d3
{
f008d3
	# init
f008d3
	cfgtest_prolog 'support of code snippet' '<...>'
f008d3
f008d3
	cfgtest_code_snippet="$@"
f008d3
f008d3
	cfgtest_common_init 'asm'
f008d3
f008d3
	# execute
f008d3
	cfgtest_ret=1
f008d3
f008d3
	printf '%s' "$cfgtest_src"                  \
f008d3
		| eval $(printf '%s' "$cfgtest_cmd") \
f008d3
		> /dev/null 2>&3                      \
f008d3
	|| cfgtest_epilog 'snippet' '(error)'          \
f008d3
	|| return
f008d3
f008d3
	# result
f008d3
	cfgtest_ret=0
f008d3
f008d3
	printf 'cfgtest: %s compiler: above code snippet compiled successfully.\n\n' \
f008d3
		"$mb_cfgtest_cfgtype" >&3
f008d3
f008d3
	cfgtest_epilog 'snippet' '(ok)'
f008d3
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_library_presence()
f008d3
{
f008d3
	# init
f008d3
	cfgtest_libs=
f008d3
	cfgtest_spc=
f008d3
f008d3
	for cfgtest_lib in ${@}; do
f008d3
		cfgtest_libs="$cfgtest_libs$cfgtest_spc$cfgtest_lib"
f008d3
		cfgtest_spc=' '
f008d3
	done
f008d3
f008d3
	if [ "${1}" = "$cfgtest_libs" ]; then
f008d3
		cfgtest_prolog 'library' "${1#*-l}"
f008d3
	else
f008d3
		cfgtest_prolog 'lib module' '(see config.log)'
f008d3
	fi
f008d3
f008d3
	cfgtest_code_snippet='int main(void){return 0;}'
f008d3
f008d3
	cfgtest_common_init 'lib'
f008d3
f008d3
	# execute
f008d3
	printf '%s' "$cfgtest_src"                  \
f008d3
		| eval $(printf '%s' "$cfgtest_cmd") \
f008d3
		> /dev/null 2>&3                      \
f008d3
	|| cfgtest_epilog 'library' '-----' "$@"       \
f008d3
	|| return 1
f008d3
f008d3
	# result
f008d3
	printf 'cfgtest: `%s'"'"' was accepted by the linker driver.\n' \
f008d3
		"$cfgtest_libs" >&3
f008d3
	printf '%s\n' '------------------------' >&3
f008d3
f008d3
	cfgtest_epilog 'library' '(present)'
f008d3
f008d3
	return 0
f008d3
}
f008d3
f008d3
dde97b
cfgtest_compiler_switch()
dde97b
{
dde97b
	# init
dde97b
	cfgtest_switches=
dde97b
	cfgtest_spc=
dde97b
d360e0
	for cfgtest_switch in $(printf '%s' "${@}"); do
dde97b
		cfgtest_switches="$cfgtest_switches$cfgtest_spc$cfgtest_switch"
dde97b
		cfgtest_spc=' '
dde97b
	done
dde97b
dde97b
	if [ "${1}" = "$cfgtest_switches" ]; then
dde97b
		cfgtest_prolog 'compiler switch' "$cfgtest_switches"
dde97b
	else
dde97b
		cfgtest_prolog 'compiler switch combination' "$cfgtest_switches"
dde97b
	fi
dde97b
dde97b
	cfgtest_code_snippet=
dde97b
dde97b
	cfgtest_common_init 'switch'
dde97b
dde97b
	# execute
dde97b
	printf '%s' "$cfgtest_src"                  \
dde97b
		| eval $(printf '%s' "$cfgtest_cmd") \
dde97b
		> /dev/null 2>&3                      \
dde97b
	|| cfgtest_epilog 'switch' '(error)' "$@"      \
dde97b
	|| return 1
dde97b
dde97b
	# result
dde97b
	printf 'cfgtest: the switch `%s was accepted by the compier.\n' \
dde97b
		"$cfgtest_switches'" >&3
dde97b
	printf '%s\n' '------------------------' >&3
dde97b
dde97b
	cfgtest_epilog 'switch' '(accepted)'
dde97b
dde97b
	return 0
dde97b
}
dde97b
dde97b
f008d3
cfgtest_unit_header_presence()
f008d3
{
f008d3
	cfgtest_internal_unit_test='unit_test'
f008d3
	cfgtest_header_presence "$@" || return 1
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_unit_header_absence()
f008d3
{
f008d3
	cfgtest_internal_unit_test='unit_test'
f008d3
	cfgtest_header_absence "$@" || return 1
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_unit_interface_presence()
f008d3
{
f008d3
	cfgtest_internal_unit_test='unit_test'
f008d3
	cfgtest_interface_presence "$@" || return 1
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_unit_decl_presence()
f008d3
{
f008d3
	cfgtest_internal_unit_test='unit_test'
f008d3
	cfgtest_decl_presence "$@" || return 1
f008d3
	return 0
f008d3
}
f008d3
f008d3
f008d3
cfgtest_unit_type_size()
f008d3
{
f008d3
	cfgtest_internal_unit_test='unit_test'
f008d3
	cfgtest_type_size "$@" || return 1
f008d3
	return 0
f008d3
}