#!/bin/bash

set -e -u

rm -rf build
mkdir build
cd build
export CC=arm-linux-gnueabihf-gcc-12
export CXX=arm-linux-gnueabihf-g++-12
# export CXX=arm-linux-gnueabi-as
export aCFLAGS="-march=armv7e-m -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb"
export aLDFLAGS="-march=armv7e-m -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb"

cmake .. -DMCU_REV_LONG=f303x8 -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX \
	-DCMAKE_C_FLAGS="$aCFLAGS" \
	-DCMAKE_LD_FLAGS="$aLDFLAGS" \
	-DCMAKE_SYSTEM_PROCESSOR=arm \
	-DCMAKE_CROSSCOMPILING=1 \
	-DCMAKE_C_COMPILER_WORKS=1 \
	-DCMAKE_CXX_COMPILER_WORKS=1

make -j32 VERBOSE=1
# HAL/src/f3/stm32f3xx_hal_cortex.o

#--- fin ----------------------------------------------------------------------
