summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRasmus Thomsen <oss@cogitri.dev>2020-05-19 12:02:03 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-10-02 12:07:05 +0300
commit75d1a80c3ae67656652e4260ea84433c556dd6ea (patch)
tree7560aebdaa74e15d3089a3cf440c8baf355994b6 /scripts
parenta904939a43bf43289345321da68b743e0d9ea804 (diff)
downloadapk-tools-75d1a80c3ae67656652e4260ea84433c556dd6ea.tar.gz
apk-tools-75d1a80c3ae67656652e4260ea84433c556dd6ea.tar.bz2
apk-tools-75d1a80c3ae67656652e4260ea84433c556dd6ea.tar.xz
apk-tools-75d1a80c3ae67656652e4260ea84433c556dd6ea.zip
scripts: add script to generate APK cross file
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate-meson-crossfile.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/generate-meson-crossfile.sh b/scripts/generate-meson-crossfile.sh
new file mode 100755
index 0000000..31fc0e0
--- /dev/null
+++ b/scripts/generate-meson-crossfile.sh
@@ -0,0 +1,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."