summaryrefslogtreecommitdiff
path: root/project/config/cfgdefs.sh
blob: a8e4d533ae6d155ca3f83a1cf5b06a99db83e3ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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
# build-time-generated cfgdefs.mk.


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


# cfghost: target
if [ -z "$mb_cfghost" ]; then
	case "$mb_cchost" in
		x86_64-*-linux | x86_64-*-linux-* | x86_64-linux-* )
			mb_cfghost=x86_64-linux ;;

		x86_64-*-midipix | x86_64-*-midipix-* | x86_64-midipix-* )
			mb_cfghost=x86_64-midipix ;;
	esac
fi


# cfghost: (native) pycompile
mb_pycompile_cfghost=$($mb_native_cc -dumpmachine)

case "$mb_pycompile_cfghost" in
	x86_64-*-linux | x86_64-*-linux-* | x86_64-linux-* )
		mb_pycompile_cfghost=x86_64-linux ;;

	x86_64-*-midipix | x86_64-*-midipix-* | x86_64-midipix-* )
		mb_pycompile_cfghost=x86_64-midipix ;;
esac


# update cfgdefs.mk
sed -e 's^@pycompile_cfghost@^'"$mb_pycompile_cfghost"'^g' \
	$mb_project_dir/project/config/cfgdefs.in          \
		> $mb_pwd/cfgdefs.mk || exit 2


# system tests: target
mb_cfgdefs_cc=$(make -s -f Makefile.tmp .display-cc)
mb_cfgdefs_cflags=$(make -s -f Makefile.tmp .display-cflags)

printf '\n\n#system tests: target\n' >> $mb_pwd/cfgdefs.mk

# <stropts.h>
$mb_cfgdefs_cc $mb_cfgdefs_cflags -E -xc - \
	--include=stropts.h < /dev/null    \
	> /dev/null 2>/dev/null ||         \
		printf 'CFLAGS_CONFIG\t\t+= -DHAVE_NO_STROPTS_H\n' \
			>> $mb_pwd/cfgdefs.mk

# openssl 1.1 or newer or a compatible libressl
printf 'void * addr = &X509_NAME_ENTRY_set;'           \
	| $mb_cfgdefs_cc $mb_cfgdefs_cflags            \
		--include=openssl/x509.h -S -xc - -o - \
		> /dev/null 2>/dev/null &&             \
	printf 'CFLAGS_CONFIG\t\t+= -DOPENSSL_VERSION_1_1\n' \
		>> $mb_pwd/cfgdefs.mk

# ncurses: python refers to the internals of typedef struct _win_st WINDOW
printf 'CFLAGS_CONFIG\t\t+= -DNCURSES_INTERNALS' >> $mb_pwd/cfgdefs.mk


# system tests: (native) pycompile
printf '\n\n#system tests: (native) pycompile\n' >> $mb_pwd/cfgdefs.mk

$mb_native_cc -E -xc -                     \
	--include=stropts.h < /dev/null    \
	> /dev/null 2>/dev/null ||         \
		printf 'PYCOMPILE_CFLAGS\t+= -DHAVE_NO_STROPTS_H\n' \
			>> $mb_pwd/cfgdefs.mk

# all done
return 0