#
# (C) Copyright 2000, 2001, 2002
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#

include $(TOPDIR)/config.mk

LIB	= lib$(SOC).a

OBJS	= serial.o astserial.o 
OBJS    +=reset.o
OBJS    +=astintr.o asttimer.o
OBJS	+=astmac.o astmii.o
OBJS 	+=misc.o
OBJS	+=pilot3spi_bkup.o
OBJS	+=pilot3spi.o pilot3spi_bkup.o
OBJS	+=HW_init.o
OBJS 	+=kcsifc.o
OBJS	+=monolithic.o
OBJS	+=ledcontrol.o
OBJS	+=strutils.o
OBJS	+=strtol.o
OBJS	+=strtoul.o
OBJS	+=resetreason.o

OBJS	+=mailbox.o
OBJS	+=pilot3_watchdog.o

DBGFLAGS = -g
OPTFLAGS = -fPIC -fno-schedule-insns -fno-schedule-insns2 -fomit-frame-pointer 
CFLAGS += $(DBGFLAGS) #$(OPTFLAGS) -Wall -Wstrict-prototypes

#define NO_GZIP when compiling if you want to disable gzip header trailer decoding by inflate()
CFLAGS += -DNO_GZIP

CFLAGS += -I$(TOPDIR)/include/ -I$(TOPDIR)/include/pilot3
CFLAGS += -I$(TOPDIR)/../../../development/common/include/fwinfo -I$(TOPDIR)/../..
CFLAGS += -I$(TOPDIR)/vendors/ami/ncsi
CFLAGS += -I$(TOPDIR)/vendors/ami/IPMI
CFLAGS += -I$(TOPDIR)/vendors/intel
CFLAGS += -I$(TOPDIR)/cpu/arm926ejs/PILOT3
CFLAGS += -D_BYTESWAP_H -DU_BOOT
CFLAGS += -DGNU

all:	$(LIB)

$(LIB):	$(OBJS) BootDIB.o
	@echo "Creating $(LIB) ..."
	@$(AR) crv $@ $(OBJS)

# want our firmware download as fast as possible.
#CFLAGS += -O3
# the RSA code does not work when optimized.
CFLAGS += -O0

# extract the boot major & minor version numbers from config.genimage
# assumes version numbers are decimal, not hex...
# assumes Major and Minor fields are the first two lines after the section label...
include $(TOPDIR)/../../projdef.mk
CONFIG_FILE=$(TOPDIR)/../../../configs.$(PROJECT)/config.genimage2
BOOT_MAJOR = $(shell grep -i -A 2 -e "\[UBOOT1]" $(CONFIG_FILE) | grep -i Major | sed s/"[ \t]*Major[ \t]*\=[ \t]*"//g)
BOOT_MINOR = $(shell grep -i -A 2 -e "\[UBOOT1]" $(CONFIG_FILE) | grep -i Minor | sed s/"[ \t]*Minor[ \t]*\=[ \t]*"//g)

BootDIB.o: BootDIB.c
	@$(CC) $(CFLAGS) -DBOOT_MAJOR=0x$(BOOT_MAJOR) -DBOOT_MINOR=0x$(BOOT_MINOR) -c -o $@ $<


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

-include $(DFILES)

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