#!/bin/bash
###############################################################################
# Copyright (c) 2012-2017, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
###############################################################################

if [[ -z $T32SYS ]]; then
    echo "ERROR: Environment variable T32SYS not set"
    echo "ERROR: T32SYS should point to the directory where the Lauterbach software is installed"
    exit 1
fi

if [[ -f $T32SYS/user_config_customer.cmm ]]; then
    rm -f $T32SYS/user_config_customer.cmm.backup
    cp $T32SYS/user_config_customer.cmm $T32SYS/user_config_customer.cmm.backup
    echo ""
    echo "Saving old $T32SYS/user_config_customer.cmm as $T32SYS/user_config_customer.cmm.backup"
fi

echo ""
echo "Installing Lauterbach scripts to $T32SYS"
rm -f $T32SYS/config_cpu.t32
rm -f $T32SYS/config_coredump.t32
rm -f $T32SYS/t32.cmm
rm -f $T32SYS/user_config.cmm
cp ./config_cpu.t32 $T32SYS/.
cp ./config_coredump.t32 $T32SYS/.
cp ./t32_customer.cmm $T32SYS/t32.cmm
cp ./user_config_customer.cmm $T32SYS/user_config_customer.cmm

# Make sure user configuration file is writable
chmod +w $T32SYS/user_config_customer.cmm

# Let the user know they need to customize user_config.cmm
echo ""
echo "Customize $T32SYS/user_config.cmm to match your debug environment"
echo ""
