Blame sofort/cfgtest/cfgtest.sh

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