#!/bin/bash
cd "$(dirname "$0")"
echo "=== RTU_ALL_AI Build ==="

# 删除 config 同级目录下的旧 RTU (即项目根目录)
rm -f ../RTU

if [ "$1" = "arm" ]; then
    echo "ARM cross-compile..."
    make CROSS=arm clean && make CROSS=arm
    cp arm/exe/RTU ../RTU
elif [ "$1" = "debug" ]; then
    echo "x86 DEBUG build (-O0 -g)..."
    make clean && make DEBUG=1
    cp x86/exe/RTU ../RTU
else
    echo "x86 release build (-O2 -g)..."
    make clean && make
    cp x86/exe/RTU ../RTU
fi

echo "=== Done === RTU copied to $(dirname "$0")/../RTU"
