#/**************************************************************************
# *                                                                        *
# *       Copyright (c) 2005-2006 by Sunplus Technology Co., Ltd.          *
# *                                                                        *
# *  This software is copyrighted by and is the property of Sunplus        *
# *  Technology Co., Ltd. All rights are reserved by Sunplus Technology    *
# *  Co., Ltd. This software may only be used in accordance with the       *
# *  corresponding license agreement. Any unauthorized use, duplication,   *
# *  distribution, or disclosure of this software is expressly forbidden.  *
# *                                                                        *
# *  This Copyright notice MUST not be removed or modified without prior   *
# *  written consent of Sunplus Technology Co., Ltd.                       *
# *                                                                        *
# *  Sunplus Technology Co., Ltd. reserves the right to modify this        *
# *  software without notice.                                              *
# *                                                                        *
# *  Sunplus Technology Co., Ltd.                                          *
# *  19, Innovation First Road, Science-Based Industrial Park,             *
# *  Hsin-Chu, Taiwan, R.O.C.                                              *
# *                                                                        *
# *  Author: Anmin Deng                                                    *
# *                                                                        *
# **************************************************************************/
ROOT = ../../../..
# Include the definition of tool chain
include $(ROOT)/tool_chain.def

#---------------------------------------------------------------------------
# Variable definition:
#   1. Cross-compling tools
#   2. Linker script file
#   3. C complier options
#   4. Assembly compiler options
#   5. Linker options
#---------------------------------------------------------------------------
CC      = $(PREFIX)/gcc
AR      = $(PREFIX)/ar
NM      = $(PREFIX)/nm
ECHO    = echo

ROOT_DIR = $(ROOT)
GOAL     = libsensor_custom.a

CFLAGS += -Wall
CFLAGS += -Os
CFLAGS += -G 8
CFLAGS += -ansi
CFLAGS += -msoft-float
CFLAGS += -I$(ROOT_DIR)/app/include
CFLAGS += -EL
CFLAGS += -fno-common

#---------------------------------------------------------------------------
# Intermediate objects
#---------------------------------------------------------------------------
OBJS += model/sensor_tg_custom.o
OBJS += model/sensor_afe_custom.o

#---------------------------------------------------------------------------
# Implicit rules
#---------------------------------------------------------------------------
.c.o:
	$(MSG_SPLIT_LINE)
	$(MSG_COMPILING)
	@$(CC) $(CFLAGS) -MM -MT $@ -o $(@:.o=.d) $<
	@$(CC) -c $(CFLAGS) -o $@ $<

.S.o:
	$(MSG_SPLIT_LINE)
	$(MSG_COMPILING)
	@$(CC) $(CFLAGS) -MM -MT $@ -o $(@:.o=.d) $<
	@$(CC) -c $(ASFLAGS) $(CFLAGS) -o $@ $<

#---------------------------------------------------------------------------
# Explicit ruls
#---------------------------------------------------------------------------
all: $(GOAL)

$(GOAL): $(OBJS)
	$(MSG_SPLIT_LINE)
	@/bin/sh -c 'if $(NM) -g --defined-only -o $(OBJS) | \
		grep -w -v -e "sensor\(Tg\|Afe\)_.\+_Install"; \
		then $(ECHO) "...unexpected definitions"; exit 1; fi'
	@$(AR) ru $(GOAL) $(OBJS)
	$(MSG_GOAL_OK)

.PHONY: clean
clean:
	$(MSG_SPLIT_LINE)
	rm -f $(OBJS:.o=.d) $(OBJS) $(GOAL)

-include $(OBJS:.o=.d)
