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
d1a04d
# build-time-generated cfgdefs.mk.
d1a04d
04aa65
# cfgdefs helper functions
04aa65
. "$mb_project_dir/project/config/cfghost.sh"
04aa65
d1a04d
d1a04d
# no custom switches yet
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
04aa65
# cfghost
04aa65
cfgdefs_set_cfghost_flavors
d1a04d
268884
# system tests: target
268884
mb_cfgdefs_cc=$(make -s -f Makefile.tmp .display-cc)
268884
mb_cfgdefs_cflags=$(make -s -f Makefile.tmp .display-cflags)
268884
268884
printf '\n\n#system tests: target\n' >> $mb_pwd/cfgdefs.mk
268884
746657
# <stropts.h>
268884
$mb_cfgdefs_cc $mb_cfgdefs_cflags -E -xc - \
268884
	--include=stropts.h < /dev/null    \
268884
	> /dev/null 2>/dev/null ||         \
268884
		printf 'CFLAGS_CONFIG\t\t+= -DHAVE_NO_STROPTS_H\n' \
268884
			>> $mb_pwd/cfgdefs.mk
268884
dc8af2
# openssl 1.1 or newer or a compatible libressl
dc8af2
printf 'void * addr = &X509_NAME_ENTRY_set;'           \
dc8af2
	| $mb_cfgdefs_cc $mb_cfgdefs_cflags            \
dc8af2
		--include=openssl/x509.h -S -xc - -o - \
dc8af2
		> /dev/null 2>/dev/null &&             \
dc8af2
	printf 'CFLAGS_CONFIG\t\t+= -DOPENSSL_VERSION_1_1\n' \
dc8af2
		>> $mb_pwd/cfgdefs.mk
dc8af2
c69aa8
# ncurses: python refers to the internals of typedef struct _win_st WINDOW
3ebdb8
printf 'CFLAGS_CONFIG\t\t+= -DNCURSES_INTERNALS\n' >> $mb_pwd/cfgdefs.mk
3ebdb8
3ebdb8
# ncurses: tinfo
3ebdb8
mb_ncurses_libs="-lpanelw -lncursesw"
3ebdb8
3ebdb8
if [ $mb_disable_shared = 'yes' ]; then
3ebdb8
	printf 'int main(void){return 0;}'          \
3ebdb8
		| $mb_cfgdefs_cc $mb_cfgdefs_cflags \
3ebdb8
			-ltinfo -o a.out -xc -      \
3ebdb8
			< /dev/null 2>/dev/null     \
3ebdb8
		&& mb_ncurses_libs="$mb_ncurses_libs -ltinfo"
3ebdb8
else
3ebdb8
	$mb_cfgdefs_cc $mb_cfgdefs_cflags               \
3ebdb8
			-shared -ltinfo -o a.out -xc -  \
3ebdb8
			< /dev/null 2>/dev/null         \
3ebdb8
		&& mb_ncurses_libs="$mb_ncurses_libs -ltinfo"
3ebdb8
fi
3ebdb8
3ebdb8
printf 'LDFLAGS_NCURSES_LIBS\t+= %s\n' "$mb_ncurses_libs" \
3ebdb8
	>> $mb_pwd/cfgdefs.mk
c69aa8
dc8af2
268884
# system tests: (native) pycompile
268884
printf '\n\n#system tests: (native) pycompile\n' >> $mb_pwd/cfgdefs.mk
268884
268884
$mb_native_cc -E -xc -                     \
268884
	--include=stropts.h < /dev/null    \
268884
	> /dev/null 2>/dev/null ||         \
268884
		printf 'PYCOMPILE_CFLAGS\t+= -DHAVE_NO_STROPTS_H\n' \
268884
			>> $mb_pwd/cfgdefs.mk
268884
3ebdb8
# ncurses: tinfo
3ebdb8
mb_ncurses_libs="-lpanelw -lncursesw"
3ebdb8
3ebdb8
printf 'int main(void){return 0;}'        \
3ebdb8
	| $mb_native_cc                   \
3ebdb8
		-ltinfo -o a.out -xc -    \
3ebdb8
		< /dev/null 2>/dev/null   \
3ebdb8
	&& mb_ncurses_libs="$mb_ncurses_libs -ltinfo"
3ebdb8
3ebdb8
printf 'PYCOMPILE_NCURSES_LIBS\t+= %s\n' "$mb_ncurses_libs" \
3ebdb8
	>> $mb_pwd/cfgdefs.mk
3ebdb8
3ebdb8
3ebdb8
# clean-up
3ebdb8
rm -f a.out
3ebdb8
3ebdb8
d1a04d
# all done
d1a04d
return 0