Blame sofort/cfgtest/cfgtest.sh

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