firasuke / cross / slibtool

Forked from cross/slibtool 3 months ago
Clone

Blame sofort/cfgtest/cfgtest.sh

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