Blob Blame History Raw
# in projects where [ $mb_use_custom_cfgdefs = yes ],
# cfgdefs.sh is invoked from within ./configure via
# . $mb_project_dir/project/cfgdefs.sh

# a successful return from cfgdefs.sh will be followed
# by a second invocation of the config_copy() function,
# reflecting any changes to common config variables
# made by cfgdefs.sh.

# finally, cfgdefs.sh may update the contents of the
# config-time generated cfgdefs.mk.


# cfgdefs helper functions
. "$mb_project_dir/project/config/cfghost.sh"


# sofort's config test framework
. "$mb_project_dir/sofort/cfgtest.sh"


for arg ; do
	case "$arg" in
		*)
			error_msg ${arg#}: "unsupported config argument."
			exit 2
	esac
done


cfgdefs_set_cfghost_flavors()
{
	cfghost_set_target_cfghost
	cfghost_set_native_cfghost
}


cfgdefs_perform_target_tests()
{
	# init
	cfgtest_target_section

	# headers
	cfgtest_header_absence  'stropts.h'
	cfgtest_header_presence 'endian.h'
	cfgtest_header_presence 'net/if.h'
	cfgtest_header_presence 'sched.h'
	cfgtest_header_presence 'sys/ioctl.h'
	cfgtest_header_presence 'sys/sendfile.h'
	cfgtest_header_presence 'sys/syscall.h'
	cfgtest_header_presence 'sys/sysmacros.h'
	cfgtest_header_presence 'sys/uio.h'
	cfgtest_header_presence 'sys/xattr.h'

	# interfaces
	mb_cfgtest_headers='sys/epoll.h'
	cfgtest_interface_presence 'epoll_create1'

	mb_cfgtest_headers='sched.h'
	cfgtest_interface_presence 'sched_get_priority_max'
	cfgtest_interface_presence 'sched_rr_get_interval'
	cfgtest_interface_presence 'sched_setaffinity'
	cfgtest_interface_presence 'sched_setparam'
	cfgtest_interface_presence 'sched_setscheduler'

	mb_cfgtest_headers='sys/sendfile.h'
	cfgtest_interface_presence 'sendfile'

	# openssl
	mb_cfgtest_headers='openssl/x509.h'

	cfgtest_interface_presence 'X509_NAME_ENTRY_set' \
		&& cfgtest_cflags_append '-DOPENSSL_VERSION_1_1'

	# ncurses: python refers to members of typedef struct _win_st WINDOW
	cfgtest_cflags_append '-DNCURSES_INTERNALS'

	# ncurses libs
	mb_ncurses_libs='-lpanelw -lncursesw'
	mb_ncurses_tinfo='-ltinfo'

	cfgtest_library_presence $mb_ncurses_tinfo \
		&& mb_ncurses_libs="$mb_ncurses_libs $mb_ncurses_tinfo"

	mb_cfgtest_makevar='LDFLAGS_NCURSES_LIBS'
	cfgtest_makevar_append $mb_ncurses_libs

	# pretty cfgdefs.mk
	cfgtest_newline
}


cfgdefs_perform_native_tests()
{
	# init
	cfgtest_native_section

	# headers
	cfgtest_header_absence  'stropts.h'
	cfgtest_header_presence 'endian.h'
	cfgtest_header_presence 'net/if.h'
	cfgtest_header_presence 'sched.h'
	cfgtest_header_presence 'sys/ioctl.h'
	cfgtest_header_presence 'sys/sendfile.h'
	cfgtest_header_presence 'sys/syscall.h'
	cfgtest_header_presence 'sys/sysmacros.h'
	cfgtest_header_presence 'sys/uio.h'
	cfgtest_header_presence 'sys/xattr.h'

	# interfaces
	mb_cfgtest_headers='sys/epoll.h'
	cfgtest_interface_presence 'epoll_create1'

	mb_cfgtest_headers='sched.h'
	cfgtest_interface_presence 'sched_get_priority_max'
	cfgtest_interface_presence 'sched_rr_get_interval'
	cfgtest_interface_presence 'sched_setaffinity'
	cfgtest_interface_presence 'sched_setparam'
	cfgtest_interface_presence 'sched_setscheduler'

	mb_cfgtest_headers='sys/sendfile.h'
	cfgtest_interface_presence 'sendfile'

	# ncurses: python refers to members of typedef struct _win_st WINDOW
	cfgtest_cflags_append '-DNCURSES_INTERNALS'

	# ncurses libs
	mb_ncurses_libs='-lpanelw -lncursesw'
	mb_ncurses_tinfo='-ltinfo'

	cfgtest_library_presence $mb_ncurses_tinfo \
		&& mb_ncurses_libs="$mb_ncurses_libs $mb_ncurses_tinfo"

	cfgtest_ldflags_append $mb_ncurses_libs

	# pretty cfgdefs.mk
	cfgtest_newline
}


# cfghost
cfgdefs_set_cfghost_flavors

# target-specific tests
cfgdefs_perform_target_tests

# native system tests
cfgdefs_perform_native_tests

# all done
return 0