Blame sofort/cfgtest/cfgtest.sh

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