Blame project/config/cfgdefs.sh

d1a04d
# in projects where [ $mb_use_custom_cfgdefs = yes ],
d1a04d
# cfgdefs.sh is invoked from within ./configure via
d1a04d
# . $mb_project_dir/project/cfgdefs.sh
d1a04d
d1a04d
# a successful return from cfgdefs.sh will be followed
d1a04d
# by a second invocation of the config_copy() function,
d1a04d
# reflecting any changes to common config variables
d1a04d
# made by cfgdefs.sh.
d1a04d
d1a04d
# finally, cfgdefs.sh may update the contents of the
95aa55
# config-time generated cfgdefs.mk.
d1a04d
2216cf
04aa65
# cfgdefs helper functions
04aa65
. "$mb_project_dir/project/config/cfghost.sh"
04aa65
d1a04d
2216cf
# sofort's config test framework
2216cf
. "$mb_project_dir/sofort/cfgtest.sh"
2216cf
2216cf
d1a04d
for arg ; do
d1a04d
	case "$arg" in
d1a04d
		*)
d1a04d
			error_msg ${arg#}: "unsupported config argument."
d1a04d
			exit 2
d1a04d
	esac
d1a04d
done
d1a04d
d1a04d
04aa65
cfgdefs_set_cfghost_flavors()
04aa65
{
04aa65
	cfghost_set_target_cfghost
04aa65
	cfghost_set_native_cfghost
04aa65
}
d1a04d
d1a04d
21274e
cfgdefs_detect_python_version()
21274e
{
21274e
	mb_internal_verinfo=$(mktemp)
21274e
21274e
	if [ -z "$mb_internal_verinfo" ]; then
21274e
		exit 2
21274e
	fi
21274e
21274e
	"$mb_native_cc" -E -dM "$mb_source_dir/Include/patchlevel.h" \
21274e
		> "$mb_internal_verinfo"
21274e
21274e
	python_major=$(grep '#define PY_MAJOR_VERSION ' "$mb_internal_verinfo" | cut -d' ' -f3)
21274e
	python_minor=$(grep '#define PY_MINOR_VERSION ' "$mb_internal_verinfo" | cut -d' ' -f3)
21274e
	python_micro=$(grep '#define PY_MICRO_VERSION ' "$mb_internal_verinfo" | cut -d' ' -f3)
21274e
21274e
	if [ -z "$python_major" ] || [ -z "$python_minor" ] || [ -z "$python_micro" ]; then
21274e
		error_msg "Could not properly parse Python's patchlevel.h"
21274e
		exit 2
21274e
	fi
21274e
21274e
	python_ver="$python_major.$python_minor"
21274e
21274e
	[ -z "$mb_package"  ] && mb_package='python'"$python_ver"
21274e
	[ -z "$mb_nickname" ] && mb_nickname="$mb_package"
21274e
	[ -z "$mb_pkgname"  ] && mb_pkgname="$mb_package"
21274e
	[ -z "$mb_pkgdesc"  ] && mb_pkgdesc="$mb_package"
21274e
}
21274e
21274e
21274e
cfgdefs_output_custom_defs()
21274e
{
21274e
	sed \
21274e
			-e 's/@python_ver@/'"$python_ver"'/g'       \
21274e
			-e 's/@python_major@/'"$python_major"'/g'   \
21274e
			-e 's/@python_minor@/'"$python_minor"'/g'   \
21274e
			-e 's/@python_micro@/'"$python_micro"'/g'   \
21274e
		"$mb_project_dir/project/config/cfgdefs.in"         \
21274e
			>> "$mb_pwd/cfgdefs.mk"
21274e
}
21274e
21274e
dc4640
cfgdefs_perform_common_tests()
2216cf
{
2216cf
	# headers
c8c262
	cfgtest_header_absence  'stropts.h'
c8c262
	cfgtest_header_presence 'endian.h'
c8c262
	cfgtest_header_presence 'net/if.h'
c8c262
	cfgtest_header_presence 'sched.h'
c8c262
	cfgtest_header_presence 'sys/ioctl.h'
c8c262
	cfgtest_header_presence 'sys/sendfile.h'
c8c262
	cfgtest_header_presence 'sys/syscall.h'
c8c262
	cfgtest_header_presence 'sys/sysmacros.h'
c8c262
	cfgtest_header_presence 'sys/uio.h'
c8c262
	cfgtest_header_presence 'sys/xattr.h'
c8c262
c8c262
	# interfaces
c8c262
	mb_cfgtest_headers='sys/epoll.h'
c8c262
	cfgtest_interface_presence 'epoll_create1'
c8c262
c8c262
	mb_cfgtest_headers='sched.h'
c8c262
	cfgtest_interface_presence 'sched_get_priority_max'
c8c262
	cfgtest_interface_presence 'sched_rr_get_interval'
c8c262
	cfgtest_interface_presence 'sched_setaffinity'
c8c262
	cfgtest_interface_presence 'sched_setparam'
c8c262
	cfgtest_interface_presence 'sched_setscheduler'
c8c262
c8c262
	mb_cfgtest_headers='sys/sendfile.h'
c8c262
	cfgtest_interface_presence 'sendfile'
268884
2216cf
	# ncurses: python refers to members of typedef struct _win_st WINDOW
2216cf
	cfgtest_cflags_append '-DNCURSES_INTERNALS'
3ebdb8
dc4640
	# ncurses libs (common part)
2216cf
	mb_ncurses_libs='-lpanelw -lncursesw'
2216cf
	mb_ncurses_tinfo='-ltinfo'
3ebdb8
2216cf
	cfgtest_library_presence $mb_ncurses_tinfo \
2216cf
		&& mb_ncurses_libs="$mb_ncurses_libs $mb_ncurses_tinfo"
dc4640
}
dc4640
dc4640
dc4640
cfgdefs_perform_target_tests()
dc4640
{
dc4640
	# init
dc4640
	cfgtest_target_section
dc4640
dc4640
	# common tests
dc4640
	cfgdefs_perform_common_tests
3ebdb8
dc4640
	# openssl
dc4640
	mb_cfgtest_headers='openssl/x509.h'
dc4640
dc4640
	cfgtest_interface_presence 'X509_NAME_ENTRY_set' \
dc4640
		&& cfgtest_cflags_append '-DOPENSSL_VERSION_1_1'
dc4640
dc4640
	# ncurses libs
2216cf
	mb_cfgtest_makevar='LDFLAGS_NCURSES_LIBS'
2216cf
	cfgtest_makevar_append $mb_ncurses_libs
c69aa8
2216cf
	# pretty cfgdefs.mk
2216cf
	cfgtest_newline
2216cf
}
dc8af2
268884
2216cf
cfgdefs_perform_native_tests()
2216cf
{
2216cf
	# init
2216cf
	cfgtest_native_section
268884
dc4640
	# common tests
dc4640
	cfgdefs_perform_common_tests
3ebdb8
2216cf
	# ncurses libs
2216cf
	cfgtest_ldflags_append $mb_ncurses_libs
2216cf
2216cf
	# pretty cfgdefs.mk
2216cf
	cfgtest_newline
2216cf
}
2216cf
2216cf
2216cf
# cfghost
2216cf
cfgdefs_set_cfghost_flavors
3ebdb8
21274e
# python version info
21274e
cfgdefs_detect_python_version
21274e
21274e
# cfgdefs.in --> cfgdefs.mk
21274e
cfgdefs_output_custom_defs
21274e
2216cf
# target-specific tests
2216cf
cfgdefs_perform_target_tests
3ebdb8
2216cf
# native system tests
2216cf
cfgdefs_perform_native_tests
3ebdb8
d1a04d
# all done
d1a04d
return 0