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'
080425
	cfgtest_header_presence 'stdatomic.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
0d929e
	# getrandom: easier to simply test,
0d929e
	# than to test whether we need to test
0d929e
	# (and then test).
0d929e
	mb_cfgtest_headers='sys/syscall.h'
0d929e
0d929e
	if cfgtest_decl_presence 'SYS_getrandom'; then
0d929e
		cfgtest_cflags_append '-DHAVE_GETRANDOM_SYSCALL'
0d929e
	fi
0d929e
c2e600
	# ncurses
c2e600
	cfgtest_newline
c2e600
	cfgtest_comment 'ncurses/ncursesw'
c2e600
	mb_cfgtest_headers='ncurses.h'
c2e600
c2e600
	if [ $mb_cfgtest_cfgtype = 'target' ]; then
c2e600
		mb_cfgtest_makevar='CFLAGS_NCURSES'
c2e600
	else
c2e600
		mb_cfgtest_makevar='NATIVE_CC_CFLAGS'
c2e600
	fi
c2e600
c2e600
	cfgtest_unit_header_presence 'curses.h'
c2e600
	cfgtest_unit_header_presence 'ncurses.h'
c2e600
c2e600
	cfgtest_unit_header_presence 'ncurses/panel.h'  && mb_panel_wrapper='yes'
c2e600
	cfgtest_unit_header_presence 'ncursesw/panel.h' && mb_panel_wrapper='yes'
c2e600
c2e600
	if cfgtest_unit_interface_presence 'is_term_resized'; then
c2e600
		cfgtest_makevar_append '-DHAVE_CURSES_IS_TERM_RESIZED'
c2e600
	fi
c2e600
c2e600
	if cfgtest_unit_interface_presence 'resizeterm'; then
c2e600
		cfgtest_makevar_append '-DHAVE_CURSES_RESIZETERM'
c2e600
	fi
c2e600
c2e600
	if cfgtest_unit_interface_presence 'resize_term'; then
c2e600
		cfgtest_makevar_append '-DHAVE_CURSES_RESIZE_TERM'
c2e600
	fi
c2e600
c2e600
	# ncursesw
c2e600
	if cfgtest_unit_interface_presence 'mvwget_wch'; then
c2e600
		cfgtest_makevar_append '-DHAVE_NCURSESW'
c2e600
	fi
c2e600
2216cf
	# ncurses: python refers to members of typedef struct _win_st WINDOW
c2e600
	cfgtest_makevar_append '-DNCURSES_INTERNALS'
c2e600
c2e600
	# <panel.h>
c2e600
	if [ -n "$mb_panel_wrapper" ]; then
c2e600
		cfgtest_makevar_append '-I$(PROJECT_DIR)/wrappers'
c2e600
		unset mb_panel_wrapper
c2e600
	fi
3ebdb8
dc4640
	# ncurses libs (common part)
2216cf
	mb_ncurses_libs='-lpanelw -lncursesw'
2216cf
	mb_ncurses_tinfo='-ltinfo'
3ebdb8
c2e600
	if cfgtest_library_presence $mb_ncurses_tinfo; then
c2e600
		mb_ncurses_libs="$mb_ncurses_libs $mb_ncurses_tinfo"
c2e600
	fi
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
817f37
	# ncurses libs
817f37
	mb_cfgtest_makevar='LDFLAGS_NCURSES_LIBS'
817f37
	cfgtest_makevar_append $mb_ncurses_libs
817f37
c2e600
	mb_cfgtest_makevar='LDFLAGS_NCURSES'
c2e600
	cfgtest_makevar_append \
c2e600
		'-Wl,--as-needed $(LDFLAGS_NCURSES_LIBS)' \
c2e600
		'-Wl,--no-as-needed'
c2e600
c2e600
	mb_cfgtest_makevar='LDFLAGS_NCURSES_STATIC'
c2e600
	cfgtest_makevar_append '$(LDFLAGS_NCURSES)'
c2e600
5eb3ab
	# ndbm
817f37
	cfgtest_newline
817f37
	cfgtest_comment 'ndbm'
5eb3ab
	cfgtest_header_presence 'ndbm.h'
5eb3ab
dc4640
	# openssl
817f37
	cfgtest_newline
817f37
	cfgtest_comment 'openssl/libressl'
dc4640
817f37
	mb_cfgtest_headers='openssl/x509.h'
dc4640
817f37
	if cfgtest_interface_presence 'X509_NAME_ENTRY_set'; then
817f37
		cfgtest_cflags_append '-DOPENSSL_VERSION_1_1'
817f37
	fi
c69aa8
644d3c
	# tcl/tk libc
817f37
	cfgtest_newline
817f37
	cfgtest_comment 'tcl/tk'
817f37
644d3c
	for mb_tcltk_ver in 8.9 8.8 8.7 8.6 8.5; do
644d3c
		if [ -z "$mb_tcltk_libs" ]; then
644d3c
			mb_tcltk_libs="-ltk$mb_tcltk_ver -ltcl$mb_tcltk_ver"
644d3c
			cfgtest_library_presence $mb_tcltk_libs \
644d3c
				|| mb_tcltk_libs=''
644d3c
		fi
644d3c
	done
644d3c
644d3c
	mb_cfgtest_makevar='LDFLAGS_TCLTK_LIBS'
644d3c
	cfgtest_makevar_append "$mb_tcltk_libs"
644d3c
7219fd
	# sqlite
7219fd
	cfgtest_newline
7219fd
	cfgtest_comment 'sqlite3'
7219fd
7219fd
	mb_cfgtest_makevar='CFLAGS_SQLITE'
7219fd
	cfgtest_makevar_append '-DMODULE_NAME=\"sqlite3\"'
7219fd
	cfgtest_makevar_append '-DSQLITE_OMIT_LOAD_EXTENSION'
7219fd
7219fd
	mb_cfgtest_makevar='LDFLAGS_SQLITE'
7219fd
	cfgtest_makevar_append '-lsqlite3'
7219fd
7219fd
	mb_cfgtest_makevar='LDFLAGS_SQLITE_STATIC'
7219fd
	cfgtest_makevar_append '$(LDFLAGS_SQLITE)'
7219fd
d1b52c
	# expat
d1b52c
	cfgtest_newline
d1b52c
	cfgtest_comment 'expat'
d1b52c
d1b52c
	mb_cfgtest_makevar='CFLAGS_EXPAT'
d1b52c
	cfgtest_makevar_append '-DXML_DEV_URANDOM'
d1b52c
d1b52c
	mb_cfgtest_makevar='LDFLAGS_EXPAT'
d1b52c
	cfgtest_makevar_append '-lexpat'
d1b52c
d1b52c
	mb_cfgtest_makevar='LDFLAGS_EXPAT_STATIC'
d1b52c
	cfgtest_makevar_append '$(LDFLAGS_EXPAT)'
d1b52c
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