#******************************************************************************
#
# Makefile - Rules for building the osal_tidrivers.
#
#  Copyright (C) 2015 Texas Instruments Incorporated - http:#www.ti.com/
#
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#
#    Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#    Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the
#    distribution.
#
#    Neither the name of Texas Instruments Incorporated nor the names of
#    its contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#*****************************************************************************

#
# Include the common make definitions.
#
include Makefile.defs

.PHONY: help all clean ccs ewarm gcc ccs_clean ewarm_clean gcc_clean \
clean_all ccs_freertos ccs_nonos ewarm_freertos ewarm_nonos gcc_freertos \
gcc_nonos clean_ccs_freertos clean_ccs_nonos clean_ewarm_freertos \
clean_ewarm_nonos clean_gcc_freertos clean_gcc_nonos

ifndef BUILD_TOOL
abort:
	make help
endif

#
# The rule to create the osal_tidrivers library
#
build: $(BUILDDIR) $(OBJ) .$(LIBRARY)

#
# The rule to display the available options
#
help:
	@echo Makefile to build osal_tidrivers component with CCS, IAR and GCC Tools
	@echo   goal              description
	@echo  -----------------------------------------------------------------------------
	@echo   "all			Builds osal_tidrivers using CCS, IAR and GCC"
	@echo   "ccs			Builds osal_tidrivers using CCS"
	@echo   "ewarm			Builds osal_tidrivers using IAR"
	@echo   "gcc			Builds osal_tidrivers using GCC"
	@echo   "ccs_freertos		Builds osal_tidrivers for freertos using CCS"
	@echo   "ccs_nonos		Builds osal_tidrivers for nonos using CCS"
	@echo   "ewarm_freertos		Builds osal_tidrivers for freertos using IAR"
	@echo   "ewarm_nonos		Builds osal_tidrivers for nonos using IAR"
	@echo   "gcc_freertos		Builds osal_tidrivers for freertos using GCC"
	@echo   "gcc_nonos		Builds osal_tidrivers for nonos using GCC"
	@echo   "clean_all		Cleans osal_tidrivers using CCS, IAR and GCC"
	@echo   "clean_ccs		Cleans osal_tidrivers using CCS"
	@echo   "clean_ewarm		Cleans osal_tidrivers using IAR"
	@echo   "clean_gcc		Cleans osal_tidrivers using GCC"
	@echo   "clean_ccs_freertos	Cleans osal_tidrivers for freertos using CCS"
	@echo   "clean_ccs_nonos		Cleans osal_tidrivers for nonos using CCS"
	@echo   "clean_ewarm_freertos	Cleans osal_tidrivers for freertos using IAR"
	@echo   "clean_ewarm_nonos	Cleans osal_tidrivers for nonos using IAR"
	@echo   "clean_gcc_freertos	Cleans osal_tidrivers for freertos using GCC"
	@echo   "clean_gcc_nonos		Cleans osal_tidrivers for nonos using GCC"
	@echo   "help			Displays this description"
	
#
# The rule to create the build directory
#
$(BUILDDIR):
	@mkdir -p $(BUILDDIR)

#
# The rule to clean the build and output directories
#
clean:
	@rm -rf $(BUILDDIR)/../exe
	@rm -rf $(BUILDDIR)/../Exe
	@rm -rf $(BUILDDIR)/../List	
	@rm -rf $(BUILDDIR)

#
# The rule to build the libraries using CCS, IAR and GCC tools
#
all: ccs ewarm gcc

#
# The rule to clean the libraries using CCS, IAR and GCC tool
#
clean_all: clean_ccs clean_ewarm clean_gcc

#
# The rule to build the libraries using CCS tool
#
ccs: ccs_freertos ccs_nonos
	
#
# The rule to build the freertos library using CCS tool
#
ccs_freertos:
	make BUILD_TOOL=ccs CONFIG=freertos

#
# The rule to build the nonos library using CCS tool
#
ccs_nonos:
	make BUILD_TOOL=ccs CONFIG=nonos

#
# The rule to clean the libraries using CCS tool
#
clean_ccs: clean_ccs_freertos clean_ccs_nonos

#
# The rule to clean the free_rtos library using CCS tool
#
clean_ccs_freertos:
	make BUILD_TOOL=ccs CONFIG=freertos clean

#
# The rule to clean the free_rtos_pm library using CCS tool
#
clean_ccs_nonos:
	make BUILD_TOOL=ccs CONFIG=nonos clean

#
# The rule to build the libraries using IAR tool
#
ewarm: 	ewarm_freertos ewarm_nonos

#
# The rule to build the freertos library using IAR tool
#
ewarm_freertos:
	make BUILD_TOOL=ewarm CONFIG=freertos

#
# The rule to build the nonos library using IAR tool
#
ewarm_nonos:
	make BUILD_TOOL=ewarm CONFIG=nonos

#
# The rule to clean the libraries using IAR tool
#
clean_ewarm: clean_ewarm_freertos clean_ewarm_nonos

#
# The rule to clean the freertos library using IAR tool
#
clean_ewarm_freertos:
	make BUILD_TOOL=ewarm CONFIG=freertos clean

#
# The rule to clean the nonos library using IAR tool
#
clean_ewarm_nonos:
	make BUILD_TOOL=ewarm CONFIG=nonos clean

#
# The rule to build the libraries using GCC tool
#
gcc: gcc_freertos gcc_nonos

#
# The rule to build the freertos library using GCC tool
#
gcc_freertos:
	make BUILD_TOOL=gcc CONFIG=freertos

#
# The rule to build the nonos library using GCC tool
#
gcc_nonos:
	make BUILD_TOOL=gcc CONFIG=nonos

#
# The rule to clean the libraries using GCC tool
#
clean_gcc: clean_gcc_freertos clean_gcc_nonos

#
# The rule to clean the freertos library using GCC tool
#
clean_gcc_freertos:
	make BUILD_TOOL=gcc CONFIG=freertos clean

#
# The rule to clean the nonos library using GCC tool
#
clean_gcc_nonos:
	make BUILD_TOOL=gcc CONFIG=nonos clean