-
Notifications
You must be signed in to change notification settings - Fork 16
/
mk-meson-cross.sh
executable file
·132 lines (123 loc) · 2.11 KB
/
mk-meson-cross.sh
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
function array2list() {
while (( "$#" )); do
echo -n "'$1'";
[ $# -gt 1 ] && printf ",\n " || echo ""
shift
done
}
# sanity
if [ -z "$1" ]; then
echo "No platform specified." 1>&2
exit 1
fi
# defaults
PLAT_ENDIAN="little"
# prefer from environment
if [ -z "$CC" ]; then
CC=${TARGET_HOST}-gcc
fi
if [ -z "$CXX" ]; then
CXX=${TARGET_HOST}-g++
fi
if [ -z "$AR" ]; then
AR=${TARGET_HOST}-gcc-ar
fi
if [ -z "$STRIP" ]; then
STRIP=${TARGET_HOST}-strip
fi
case "$1" in
"vita")
PLAT_SYSTEM="vita"
PLAT_CPU_FAMILY="arm"
PLAT_CPU="cortex-a9mpcore"
;;
"switch")
PLAT_SYSTEM="horizon"
PLAT_CPU_FAMILY="aarch64"
PLAT_CPU="cortex-a57"
;;
"3ds")
PLAT_SYSTEM="horizon"
PLAT_CPU_FAMILY="arm"
PLAT_CPU="arm11mpcore"
;;
"ogc")
PLAT_SYSTEM="bare"
PLAT_CPU_FAMILY="ppc"
PLAT_CPU="ppc750"
PLAT_ENDIAN="big"
;;
"asmjs")
PLAT_SYSTEM="emscripten"
PLAT_CPU_FAMILY="wasm32"
PLAT_CPU="wasm32"
STRIP=emstrip
;;
*android*)
PLAT_SYSTEM="android"
case "$1" in
armv7a*)
PLAT_CPU_FAMILY="arm"
;;
aarch64*)
PLAT_CPU_FAMILY="aarch64"
;;
i686*)
PLAT_CPU_FAMILY="x86"
;;
x86_64*)
PLAT_CPU_FAMILY="x86_64"
;;
*)
echo "Unsupported Android platform." 1>&2
exit 1
;;
esac
STRIP="llvm-strip"
;;
*apple-darwin)
PLAT_SYSTEM="darwin"
case "$1" in
arm*)
PLAT_CPU_FAMILY="arm"
;;
aarch64*)
PLAT_CPU_FAMILY="aarch64"
;;
x86_64*)
PLAT_CPU_FAMILY="x86_64"
;;
*)
echo "Unsupported macOS/iOS platform." 1>&2
exit 1
;;
esac
AR="ar"
STRIP="strip"
;;
*)
echo "Unsupported platform." 1>&2
exit 1
;;
esac
# CC and CXX are usually not lists, good thing meson does just join() them
cat << EOF
# autogenerated, do not edit
[binaries]
c = [` array2list ${CC} `]
cpp = [` array2list ${CXX} `]
ar = '${AR}'
strip = '${STRIP}'
pkg-config = 'pkg-config'
[built-in options]
c_args = [` array2list ${CPPFLAGS} ${CFLAGS} `]
c_link_args = [` array2list ${LDFLAGS} ${LIBS} `]
cpp_args = [` array2list ${CPPFLAGS} ${CXXFLAGS} `]
cpp_link_args = [` array2list ${LDFLAGS} ${LIBS} `]
[host_machine]
system = '${PLAT_SYSTEM}'
cpu_family = '${PLAT_CPU_FAMILY}'
cpu = '${PLAT_CPU}'
endian = '${PLAT_ENDIAN}'
EOF