Blame sofort/cfgtest/cfgtest.sh

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