Blame project/config/cfgdefs.sh

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