Blame sofort/cfgtest/cfgtest.sh

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