Blame project/config/cfgdefs.sh

5f905a
for arg ; do
5f905a
	case "$arg" in
5f905a
		*)
5f905a
			error_msg ${arg#}: "unsupported config argument."
5f905a
			exit 2
5f905a
	esac
5f905a
done
5f905a
5f905a
cfgdefs_set_arch()
5f905a
{
5f905a
	if [ -n "$mb_arch" ]; then
5f905a
		return 0
5f905a
	fi
5f905a
5f905a
	case "$mb_cchost" in
5f905a
		*-*-*-* )
5f905a
			mb_arch=${mb_cchost%-*-*-*}
5f905a
			;;
5f905a
		*-*-* )
5f905a
			mb_arch=${mb_cchost%-*-*}
5f905a
			;;
5f905a
		*-* )
5f905a
			mb_arch=${mb_cchost%-*-*-*}
5f905a
			;;
5f905a
		* )
5f905a
			mb_arch='unknown'
5f905a
			;;
5f905a
	esac
5f905a
5f905a
	if [ "$mb_os" = 'midipix' ]; then
5f905a
		case "$mb_arch" in
5f905a
			x86_64 )
5f905a
				mb_arch='nt64'
5f905a
				;;
5f905a
			i[3-6]86 )
5f905a
				mb_arch='nt32'
5f905a
				;;
5f905a
		esac
5f905a
	fi
5f905a
}
5f905a
ba1678
ba1678
cfgdefs_detect_libc_version()
ba1678
{
ba1678
	mb_libc_verinfo=$(cat "$mb_source_dir/VERSION")
ba1678
ba1678
	case "$mb_libc_verinfo" in
ba1678
		*.*.* )
ba1678
			libc_ver=${mb_libc_verinfo}
ba1678
			libc_major=${mb_libc_verinfo%.*.*}
ba1678
			libc_micro=${mb_libc_verinfo#*.*.}
ba1678
ba1678
			libc_minor=${libc_ver#*.}
ba1678
			libc_minor=${libc_minor%.*}
ba1678
			;;
ba1678
		* )
ba1678
			error_msg "Could not properly parse $mb_source_dir/VERSION"
ba1678
			exit 2
ba1678
	esac
ba1678
}
ba1678
ba1678
dd6f0e
cfgdefs_set_libc_options()
dd6f0e
{
dd6f0e
	if [ -d $mb_project_dir/arch/$mb_arch ]; then
dd6f0e
		port_dir='$(PROJECT_DIR)'
dd6f0e
		arch_dir=$mb_project_dir
dd6f0e
	else
dd6f0e
		port_dir='$(SOURCE_DIR)'
dd6f0e
		arch_dir=$mb_source_dir
dd6f0e
	fi
dd6f0e
dd6f0e
	if [ -f $arch_dir/arch/$mb_arch/bits/syscall.h.in ]; then
dd6f0e
		libc_syscall_arch='syscall-gen'
dd6f0e
	else
dd6f0e
		libc_syscall_arch='syscall-copy'
dd6f0e
	fi
dd6f0e
}
dd6f0e
dd6f0e
ba1678
cfgdefs_output_custom_defs()
ba1678
{
ba1678
	sed \
dd6f0e
			-e 's/@port_dir@/'"$port_dir"'/g'       \
ba1678
			-e 's/@libc_ver@/'"$libc_ver"'/g'       \
ba1678
			-e 's/@libc_major@/'"$libc_major"'/g'   \
ba1678
			-e 's/@libc_minor@/'"$libc_minor"'/g'   \
ba1678
			-e 's/@libc_micro@/'"$libc_micro"'/g'   \
dd6f0e
			-e 's/@libc_syscall_arch@/'"$libc_syscall_arch"'/g' \
ba1678
		"$mb_project_dir/project/config/cfgdefs.in"         \
ba1678
	| sed -e 's/[ \t]*$//g'                                     \
ba1678
			>> "$mb_pwd/cfgdefs.mk"
ba1678
}
ba1678
ba1678
5f905a
# arch
5f905a
cfgdefs_set_arch
5f905a
ba1678
# libc version info
ba1678
cfgdefs_detect_libc_version
ba1678
dd6f0e
# libc (variant-specific) options
dd6f0e
cfgdefs_set_libc_options
dd6f0e
ba1678
# cfgdefs.in --> cfgdefs.mk
ba1678
cfgdefs_output_custom_defs
ba1678
5f905a
# all done
5f905a
return 0