#
# Copyright 2011 Freescale Semiconductor, Inc.
# (C) Copyright 2001-2006
# 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	= $(obj)lib$(BOARD).o

%.c: %.bin
	xxd -i $< $@

%.itb: %.its
	$(OBJTREE)/tools/mkimage -f $< $@

%.bin: %.itb
	dd if=/dev/zero bs=256K count=1 of=$@
	dd if=$< bs=256K of=$@ conv=notrunc

ifeq ($(CONFIG_FMAN_ENET),y)
FMAN_UCODE = fsl_fman_ucode_P2041_101_8.bin
FMAN_UCODE_C = $(patsubst %.bin,%.c,$(FMAN_UCODE))
FMAN_UCODE_OBJ = $(patsubst %.bin,%.o,$(FMAN_UCODE))
endif

FPGA_IMAGE = x930_fpga.bin
FPGA_IMAGE_C = $(patsubst %.bin,%.c,$(FPGA_IMAGE))
FPGA_IMAGE_OBJ = $(patsubst %.bin,%.o,$(FPGA_IMAGE))

COBJS-y				+= $(BOARD).o
COBJS-y				+= ddr.o
COBJS-y				+= ddr_param.o
COBJS-y				+= eth.o
COBJS-y				+= law.o
COBJS-$(CONFIG_PCI)		+= pci.o
COBJS-y				+= tlb.o
COBJS-y				+= fpga.o
COBJS-y				+= ../SBx8100/common.o
COBJS-y				+= ../SBx8100/mpi.o
COBJS-$(CONFIG_SHOW_BOOT_PROGRESS)	+= ../common/progress.o

SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
OBJS	:= $(addprefix $(obj),$(COBJS-y))
SOBJS	:= $(addprefix $(obj),$(SOBJS))

$(LIB):	$(obj).depend $(OBJS) $(SOBJS) blobs.bin $(CONFIG_PBLRCW_CONFIG) $(CONFIG_PBLPBI_CONFIG)
	$(call cmd_link_o_target, $(OBJS))

ifeq ($(CONFIG_RAMBOOT_PBL),y)
ifeq ($(CONFIG_SPIFLASH),y)
$(CONFIG_PBLRCW_CONFIG): rcw_ramboot_spi.cfg.in
	cat $^ > $@

$(CONFIG_PBLPBI_CONFIG): pbi_workarounds.cfg.in pbi_ramboot_spi.cfg.in
	cat $^ > $@
else
$(CONFIG_PBLRCW_CONFIG): rcw_ramboot_nor.cfg.in
	cat $^ > $@

$(CONFIG_PBLPBI_CONFIG): pbi_workarounds.cfg.in pbi_ramboot_nor.cfg.in
	cat $^ > $@
endif
endif

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

# defines $(obj).depend target
include $(SRCTREE)/rules.mk

sinclude $(obj).depend

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