aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/generate-meson-crossfile.sh
blob: 31fc0e09507e02979817e4778387c3cd3f4393a0 (plain) (blame)
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
#!/bin/sh

set -eu

_target_endianess=little
_target_cpu="$CARCH"

case "$CARCH" in
	mips*)
		_target_endianness=big
		_target_cpu_family=mips
		;;
	arm*)
		_target_cpu_family=arm
		;;
	ppc64le)
		_target_cpu_family=ppc64
		;;
	aarch64|x86*)
		# $CARCH maps 1:1 to _cpu_family for meson for these arches
		_target_cpu_family="$CARCH"
		;;
esac

# Keep in mind that CC, CXX etc. are the binaries to compile from host
# to target, not from host to host!
cat > apk.cross <<EOF
[binaries]
c = '${CC}'
cpp = '${CXX}'
ar = '${AR}'
nm = '${NM}'
ld = '${LD}'
strip = '${STRIP}'
readelf = '${READELF}'
objcopy = '${OBJCOPY}'
pkgconfig = 'pkg-config'
[properties]
needs_exe_wrapper = true
c_args = ['$(echo ${CFLAGS} | sed -r "s/\s+/','/g")']
c_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
cpp_args = ['$(echo ${CXXFLAGS} | sed -r "s/\s+/','/g")']
cpp_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
[host_machine]
system = 'linux'
cpu_family = '${_target_cpu_family}'
cpu = '${_target_cpu}'
endian = '${_target_endianess}'
EOF

echo "Generating crossfile is done. You can invoke meson with the cross file with 'meson --cross apk.cross' now."