Blame sofort/cfgtest/cfgtest.sh

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