Blame sofort/cfgtest/cfgtest.sh

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