#!/bin/bash
#
# This script creates the hal_dhrystone Board Support Package (BSP).

BSP_TYPE=hal
BSP_DIR=.
SOPC_DIR=../../..

# Run nios2-bsp utility to create a HAL BSP in this directory
# for the system with a .sopc file in $SOPC_DIR.
cmd="nios2-bsp $BSP_TYPE $BSP_DIR $SOPC_DIR \
--set hal.sys_clk_timer none \
--set hal.timestamp_timer HIGH_RES_TIMER \
--set hal.enable_lightweight_device_driver_api true \
--set hal.enable_reduced_device_drivers true \
--set hal.enable_sim_optimize false \
--set hal.make.bsp_cflags_debug \"-g1\" \
--set hal.make.bsp_cflags_user_flags \"-funsigned-char -fno-inline\" \
--set hal.make.bsp_cflags_optimization \"-O3\" \
--set hal.make.bsp_cflags_defined_symbols \"-DALT_RELEASE -DWANT_INLINE_STRCMP\" $@"

echo "create-this-bsp: Running \"$cmd\""
$cmd || {
    echo "$cmd failed"
    exit 1
}

echo "create-this-bsp: Running make"
make
