#******************************************************************************
#
# makedefs - used in all armv5/gcc makefiles
#
# Copyright (C) 2011 Texas Instruments Incorporated. - http://www.ti.com/ 
# All rights reserved.
#
#******************************************************************************
# Contents
# 1. Common paths and options
# 2. Settings for GCC + ARM9 makefiles
#******************************************************************************

#
# Toolchain/library path. LIB_PATH is an exported environmental variable which
# shall point to the installation of toolchain
#
LIB_GCC=${LIB_PATH}/lib/gcc/arm-none-eabi/4.3.3/
LIB_C=${LIB_PATH}/arm-none-eabi/lib/

#
# Target and Compiler definitions (Device and EVM specified by makefile)
#
TARGET=armv5
COMPILER=gcc

#
# Convert Windows native style filenames to POSIX style filenames
#
CYGPATH=cypath

#
# Target directories to be built
#
DRIVERS_BLD=${ROOT}/build/${TARGET}/${COMPILER}/${DEVICE}/drivers
PLATFORM_BLD=${ROOT}/build/${TARGET}/${COMPILER}/${DEVICE}/${EVM}/platform
SYSCONFIG_BLD=${ROOT}/build/${TARGET}/${COMPILER}/${DEVICE}/system_config
IPCLIB_BLD=${ROOT}/build/${TARGET}/${COMPILER}/${DEVICE}/ipclite
UTILITY_BLD=${ROOT}/build/${TARGET}/${COMPILER}/utils
USBLIB_BLD=${ROOT}/build/${TARGET}/${COMPILER}/${DEVICE}/usblib
GRLIB_BLD=${ROOT}/build/${TARGET}/${COMPILER}/grlib
NANDLIB_BLD=${ROOT}/build/${TARGET}/${COMPILER}/nandlib

#
# Pre/recompiled library paths
#
DRIVERS_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/${DEVICE}/drivers
PLATFORM_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/${DEVICE}/${EVM}/platform
SYSCONFIG_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/${DEVICE}/system_config
IPCLIB_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/${DEVICE}/ipclite
UTILITY_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/utils
USBLIB_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/${DEVICE}/usblib
GRLIB_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/grlib
NANDLIB_BIN=${ROOT}/binary/${TARGET}/${COMPILER}/nandlib

#
# Source code paths
#
DRIVERS_SRC=${ROOT}/drivers
PLATFORM_SRC=${ROOT}/platform/${EVM}
SYSCONFIG_SRC=${ROOT}/system_config/${TARGET}
IPCLIB_SRC=${ROOT}/ipclite/src
UTILITY_SRC=${ROOT}/utils
USBLIB_SRC=${ROOT}/usblib
GRLIB_SRC=${ROOT}/grlib
NANDLIB_SRC=${ROOT}/nandlib

#
# Include paths
#
IPATH=-I${ROOT}/include \
      -I${ROOT}/include/hw \
      -I${ROOT}/include/armv5 \
      -I${ROOT}/include/armv5/${DEVICE} \
      -I${ROOT}/grlib/include \
      -I${ROOT}/usblib/include \
      -I${ROOT}/ipclite/include \
      -I${ROOT}/nandlib/include \
      -I"${LIB_PATH}/include"

#
# Library paths
#
LPATH=-L"${LIB_C}" \
      -L"${LIB_GCC}" \
      -L${DRIVERS_BIN}/${TARGET_MODE} \
      -L${PLATFORM_BIN}/${TARGET_MODE} \
      -L${SYSCONFIG_BIN}/${TARGET_MODE} \
      -L${IPCLIB_BIN}/${TARGET_MODE} \
      -L${UTILITY_BIN}/${TARGET_MODE} \
      -L${USBLIB_BIN}/${TARGET_MODE} \
      -L${GRLIB_BIN}/${TARGET_MODE} \
      -L${NANDLIB_BIN}/${TARGET_MODE}

#
# C compilation options
#
Debug_FLAG=-g
Release_FLAG=-g -O2
ifdef DEVICE
DEVICE_D=-D${DEVICE}
endif
ifdef EVM
EVM_D=-D${EVM}
endif
CFLAGS=-c ${${TARGET_MODE}_FLAG} -fdata-sections -ffunction-sections -Wall ${IPATH} -Dgcc ${DEVICE_D} ${EVM_D}

#
# Defining the cross compiler tool prefix
#
ifndef PREFIX
PREFIX=arm-none-eabi-
endif

#
# Compiler, Linker and Archiver with respect to the toolchain
#
CC=${PREFIX}gcc
LD=${PREFIX}ld
AR=${PREFIX}ar
BIN=$(PREFIX)objcopy

#
# Archiver options
#
ARFLAGS=-c -r

#
# Linker options
#
LDFLAGS=-e Entry -u Entry -u __aeabi_uidiv -u __aeabi_idiv --gc-sections

#
# Binary options
#
BINFLAGS=-O binary