Files
cam-mitm/build_tutk.sh

55 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# Build TUTK IOTC shared library from static libs
cd "$(dirname "$0")"
OUTPUT="lib/libIOTCAPIs_ALL.so"
# Try each compatible ARM lib directory until one works
LIBDIRS=(
"Arm11_CLFSX_4.4.1"
"Armv7a_Hi8107_4.4.6"
"Arm11_BCM2835_4.5.1"
"Arm9_EPN7530X_4.5.2"
"Arm9_trident_4.5.2"
"Arm_IMAPx15_4.7.3"
"Arm_X41_4.8.2"
)
BASE="lib/tutk/TUTK_IOTC_Platform_14W36/Lib/Linux"
for dir in "${LIBDIRS[@]}"; do
LIBDIR="$BASE/$dir"
if [ ! -f "$LIBDIR/libIOTCAPIs.a" ]; then
continue
fi
echo "Trying $dir..."
arm-linux-gnueabihf-gcc -shared -fpic -Wl,--whole-archive "$LIBDIR/libIOTCAPIs.a" "$LIBDIR/libAVAPIs.a" "$LIBDIR/libRDTAPIs.a" -Wl,--no-whole-archive -lpthread -o "$OUTPUT" 2>/dev/null
if [ $? -eq 0 ]; then
echo "Success with $dir!"
break
fi
echo " Failed, trying next..."
done
# If all hard-float attempts fail, try with arm-linux-gnueabi (soft-float) toolchain
if [ ! -f "$OUTPUT" ]; then
echo ""
echo "All hard-float attempts failed."
echo "Install soft-float toolchain: sudo apt install gcc-arm-linux-gnueabi -y"
echo "Then re-run this script."
if command -v arm-linux-gnueabi-gcc &>/dev/null; then
LIBDIR="$BASE/Arm11_BCM2835_4.8.3"
echo "Trying soft-float toolchain with $LIBDIR..."
arm-linux-gnueabi-gcc -shared -fpic -Wl,--whole-archive "$LIBDIR/libIOTCAPIs.a" "$LIBDIR/libAVAPIs.a" "$LIBDIR/libRDTAPIs.a" -Wl,--no-whole-archive -lpthread -o "$OUTPUT"
fi
fi
if [ $? -eq 0 ]; then
echo "Success: $(file $OUTPUT)"
echo "Size: $(ls -lh $OUTPUT | awk '{print $5}')"
else
echo "Build failed"
exit 1
fi