-
Notifications
You must be signed in to change notification settings - Fork 16
/
mk-meson-cross.sh
executable file
·108 lines (99 loc) · 1.79 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
#!/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 [[ ! -v CC ]]; then
CC=${TARGET_HOST}-gcc
fi
if [[ ! -v CXX ]]; then
CXX=${TARGET_HOST}-g++
fi
if [[ ! -v AR ]]; then
AR=${TARGET_HOST}-gcc-ar
fi
if [[ ! -v 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"
;;
esac
STRIP="llvm-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