Blame project/config/cfgdefs.sh

5f905a
for arg ; do
5f905a
	case "$arg" in
0563c2
		--no-complex )
0563c2
			libc_no_complex=yes
0563c2
			;;
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
155000
		libc_syscall_arch='syscall-gen.tag'
dd6f0e
	else
155000
		libc_syscall_arch='syscall-copy.tag'
dd6f0e
	fi
15ddf0
15ddf0
	if [ -f $mb_source_dir/arch/x86_64/atomic_arch.h ]; then
15ddf0
		libc_source_tree='-D__LIBC_MODERN_SOURCE_TREE'
15ddf0
	else
15ddf0
		libc_source_tree='-D__LIBC_LEGACY_SOURCE_TREE'
15ddf0
	fi
0563c2
fe59d4
	if [ -f $arch_dir/arch/$mb_arch/bits/alltypes.sed ]; then
fe59d4
		alltypes_sed=$arch_dir/arch/$mb_arch/bits/alltypes.sed
fe59d4
	else
fe59d4
		alltypes_sed=build/alltypes.sed
fe59d4
	fi
fe59d4
0563c2
	if [ _${libc_no_complex:-} = _yes ]; then
0563c2
		libc_deps=
0563c2
		libc_excl_files='$(filter ./src/complex/%, $(libc_all_files))'
0563c2
	else
0563c2
		libc_deps='-lgcc -lgcc_eh'
0563c2
		libc_excl_files=
0563c2
	fi
dd6f0e
}
dd6f0e
dd6f0e
3d4ab4
cfgdefs_set_libc_cflags()
3d4ab4
{
3d4ab4
	libc_td_tid_addr=
3d4ab4
	mb_init_tls_src_file=$mb_source_dir/src/env/__init_tls.c
3d4ab4
3d4ab4
	[ -z $libc_td_tid_addr ] \
3d4ab4
		&& grep '__syscall(SYS_set_tid_address, &td->tid)' $mb_init_tls_src_file > /dev/null \
3d4ab4
			&& libc_td_tid_addr='-D__LIBC_TD_TID_ADDR_TID'
3d4ab4
3d4ab4
	[ -z $libc_td_tid_addr ] \
3d4ab4
		&& grep '__syscall(SYS_set_tid_address, &td->join_futex)' $mb_init_tls_src_file > /dev/null \
3d4ab4
			&& libc_td_tid_addr='-D__LIBC_TD_TID_ADDR_JOIN_FUTEX'
3d4ab4
3d4ab4
	[ -z $libc_td_tid_addr ] \
3d4ab4
		&& grep '__syscall(SYS_set_tid_address, &td->detach_state)' $mb_init_tls_src_file > /dev/null \
3d4ab4
			&& libc_td_tid_addr='-D__LIBC_TD_TID_ADDR_DETACH_STATE'
3d4ab4
3d4ab4
	[ -z $libc_td_tid_addr ] \
3d4ab4
		&& grep '__syscall(SYS_set_tid_address, &__thread_list_lock)' $mb_init_tls_src_file > /dev/null \
3d4ab4
			&& libc_td_tid_addr='-D__LIBC_TD_TID_ADDR_THREAD_LIST_LOCK'
3d4ab4
3d4ab4
	return 0
3d4ab4
}
3d4ab4
3d4ab4
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'   \
0563c2
			-e 's/@libc_deps@/'"$libc_deps"'/g'     \
0563c2
			-e 's^@libc_excl_files@^'"$libc_excl_files"'^g'   \
15ddf0
			-e 's/@libc_source_tree@/'"$libc_source_tree"'/g'  \
dd6f0e
			-e 's/@libc_syscall_arch@/'"$libc_syscall_arch"'/g' \
3d4ab4
			-e 's/@libc_td_tid_addr@/'"$libc_td_tid_addr"'/g'    \
3d4ab4
			-e 's!@alltypes_sed@!'"$alltypes_sed"'!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
3d4ab4
# libc (variant-specific) cflags
3d4ab4
cfgdefs_set_libc_cflags
3d4ab4
ba1678
# cfgdefs.in --> cfgdefs.mk
ba1678
cfgdefs_output_custom_defs
ba1678
5f905a
# all done
5f905a
return 0