aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-08-11 11:21:06 +0200
committerToni Uhlig <matzeton@googlemail.com>2024-05-08 09:02:27 +0200
commitc04fdc0518bf37070c8dacc2370b21fb82d5a128 (patch)
treeb1f752cdf7f7f403ea4e0548dab9c42c11ae6745
parent5783fa87ed62682e17554b41e0e25d16f403b3ab (diff)
added sdkenv.sh: set env vars to build foreign packages
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rwxr-xr-xsdkenv.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/sdkenv.sh b/sdkenv.sh
new file mode 100755
index 0000000000..67f282bb10
--- /dev/null
+++ b/sdkenv.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+OWRT="$(realpath $(dirname ${BASH_SOURCE}))"
+echo "* OpenWRT...: ${OWRT}"
+
+ARCH="$(cat ${OWRT}/.config | sed -n 's/^CONFIG_ARCH="\(.*\)"$/\1/p')"
+echo "* ARCH......: ${ARCH}"
+export HOST="${ARCH}-openwrt-linux"
+
+CPU_TYPE="$(cat ${OWRT}/.config | sed -n 's/^CONFIG_CPU_TYPE="\(.*\)"$/\1/p')"
+echo "* CPU TYPE..: ${CPU_TYPE}"
+
+TARGET_BOARD="$(cat ${OWRT}/.config | sed -n 's/^CONFIG_TARGET_BOARD="\(.*\)"$/\1/p')"
+echo "* TARGET....: ${TARGET_BOARD}"
+
+TOOLCHAIN_DIR="$(realpath ${OWRT}/staging_dir/toolchain-${ARCH}_${CPU_TYPE}*)"
+echo "* Toolchain.: ${TOOLCHAIN_DIR}"
+
+export PATH="${TOOLCHAIN_DIR}/bin:${PATH}"
+export STAGING_DIR="${OWRT}/staging_dir"
+TARGET_DIR="$(realpath ${STAGING_DIR}/target-${ARCH}_${CPU_TYPE}*)"
+echo "* Target dir: ${TARGET_DIR}"
+export CC="${HOST}-gcc"
+export CXX="${HOST}-g++"
+export CFLAGS="-I${TARGET_DIR}/usr/include"
+export CXXFLAGS="${CFLAGS}"
+TARGET_DIR_ROOT="$(realpath ${TARGET_DIR}/root-${TARGET_BOARD})"
+echo "* Target dir: ${TARGET_DIR_ROOT}"
+export LDFLAGS="-L${TARGET_DIR}/usr/lib -L${TARGET_DIR_ROOT}/usr/lib"
+export PKG_CONFIG_PATH="${TARGET_DIR}/usr/lib/pkgconfig"
+export PKG_CONFIG_LIBDIR="${TARGET_DIR}/usr/lib/pkgconfig"
+
+check_dirs[0]="${TOOLCHAIN_DIR}"
+check_dirs[1]="${TARGET_DIR}"
+check_dirs[2]="${TARGET_DIR_ROOT}"
+for dir in ${check_dirs[*]}; do
+ test -d "${dir}" || echo "* NOT EXIST: ${dir}" >&2
+done