###############################################################################
# Copyright (c) 2012-2012 Integrated Device Technology, Inc.
# All Rights Reserved
#
# This file is provided for use with IDT products only, and does not
# convey any license, whether express or implied, to any intellectual
# property rights of Integrated Device Technology, Inc.  Distribution,
# copying or modification of the contents of this file and/or any
# derivatives thereto is not permitted, except as specifically
# authorized in writing. This notice shall be included in its entirety
# on all copies made from this file.
#
# The contents herein are the proprietary and confidential information
# of Integrated Device Technology Inc. and shall not be distributed or
# furnished to third parties or made public without prior written
# permission by Integrated Device Technology Inc.  Disclosures of this
# file in any form to the United States Government may not be made
# without a written predetermination that it will be protected by
# limited or restricted rights as set forth in the applicable Federal
# Acquisition Regulations or other equivalent governmental rule or
# regulation.
#
# The contents herein are provided "as is" and without any express or
# implied warranties, including, without limitation, the implied
# warranties of merchantability and fitness for a particular purpose.
#
# Last modified: <lastCommitDate>
# Release: <releaseName>
# Id: <gitCommitHash>
#
###############################################################################

##############################################################################
# B U I L D    E N V I R O N M E N T
##############################################################################
HOST_PLATFORM := $(shell uname | cut -d _ -f 1 | tr [:upper:] [:lower:])

# If HARDWARE_TARGET is defined then we'll append it to the host platform 
# that we are running on.
ifdef HARDWARE_TARGET
TARGET := $(HOST_PLATFORM).$(HARDWARE_TARGET)
else
TARGET := $(HOST_PLATFORM)
endif

# Device
DEVICE := 82V3910

# Include host/target specific options
OSADAPT_PLATFORMDIR := ../../osAdaptation/$(TARGET)
include ../../osAdaptation/$(TARGET)/osConfig.mk

##############################################################################

##############################################################################
# Include directories 
INCL_DIRS := \
           . \
           ../../common/include \
           ../../common/hlapi/include \
           ../../common/access/sim \
           ../../apll/include \
           ../../apll/access/sim \
           ../../$(DEVICE)/dev/include/ \
           $(OSADAPT_PLATFORMDIR)/include

# Compiler Options
CFLAGS += \
          $(foreach i,$(INCL_DIRS),-I$(i)) \
          -g \
          -Werror \
          -Wall \
          -pedantic

# Shared Libraries
SHARED_LIBS = \

# LIbrary search paths
LD_DIRS = \

# Linker Options
LDFLAGS += \
           $(foreach i,$(LD_DIRS),-L$(i)) \
           -Wall \
           $(foreach i,$(SHARED_LIBS),-l$(i))


##############################################################################
# I N P U T    A R T I F A C T S
##############################################################################
VPATH := \
         . \
         ../../common/src \
         ../../apll/src \
         ../../common/access/sim \
         ../../apll/access/sim \
         ../../$(DEVICE)/dev/src \
         $(OSADAPT_PLATFORMDIR)/src

SOURCE := \
          ReadWrite_sim.c \
          ApllReadWrite_sim.c \
          osAdapt.c \
          $(DEVICE).c \
          Hal.c \
          General.c \
          DpllCnfg.c \
          Output.c \
          Apll.c \
          ApllApi.c \
          ApllFreqProfile.c \
          save.c \
          load.c \
          main.c

OBJS := $(SOURCE:.c=.o)

##############################################################################
# O U T P U T    A R T I F A C T S
##############################################################################
PROGNAME := rgf$(PROG_EXT)

##############################################################################
# M A K E F I L E    T A R G E T S
##############################################################################
all: $(PROGNAME)

$(PROGNAME): $(OBJS)
	@echo "$(OBJS)"
	$(CC) $(OBJS) $(LDFLAGS) -o $(PROGNAME)


%.o : %.c
	$(CC) $(CFLAGS) -c -o $@ $<

clean:
	$(RM) -Rf $(OBJS) $(PROGNAME) *~
