Blame sofort/cfgtest/cfgtest.sh

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