Blame sofort/cfgtest/cfgtest.sh

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