
ifeq "$(_TMTGTENDIAN)" "el"
LDSCRIPT=$(TOPDIR)/board/$(BOARDDIR)/u-boot.le.lds
this_buildinfo := le
else
LDSCRIPT=$(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
this_buildinfo := be
endif

ifdef GENERATED_CONFIG
GENERATED_CONFIG_DIR := $(PRJROOT)/etc/hardware/startup_reg_settings/generated
PLATFORM_CPPFLAGS += -DGENERATED_CONFIG=$(GENERATED_CONFIG) -I$(GENERATED_CONFIG_DIR)
this_buildinfo += $(GENERATED_CONFIG)
export GENERATED_CONFIG
endif

TEXT_BASE = 0x80800000

ifdef BOOT_TARGET_GRIFFIN
CONFIG_BOOT_TARGET = GRIFFIN
else
ifdef BOOT_TARGET_MONACO
CONFIG_BOOT_TARGET = MONACO
else
ifdef BOOT_TARGET_MOJITO
CONFIG_BOOT_TARGET = MOJITO
else
ifdef BOOT_TARGET_PANDORA3
CONFIG_BOOT_TARGET = PANDORA3
else
ifdef BOOT_TARGET_APOLLO
CONFIG_BOOT_TARGET = APOLLO
else
ifdef BOOT_TARGET_BPOLLO
CONFIG_BOOT_TARGET = BPOLLO
else
ifdef BOOT_TARGET_CINDYKATE
CONFIG_BOOT_TARGET = CINDYKATE
else
ifdef BOOT_TARGET_GENERIC_NAND
CONFIG_BOOT_TARGET = GENERIC_NAND
else
ifdef BOOT_TARGET_GENERIC_NOR
CONFIG_BOOT_TARGET = GENERIC_NOR
ifndef RESCUE
TEXT_BASE = 0xb8000000
endif
else
ifeq ($(filter clean distclean mrproper,$(MAKECMDGOALS)),)
$(error unexpected or undefined boot target)
endif
endif
endif
endif  
endif  
endif  
endif  
endif  
endif
endif  

this_buildinfo += $(CONFIG_BOOT_TARGET)

ifdef RESCUE
PLATFORM_CPPFLAGS += -DBOOT_TARGET_$(CONFIG_BOOT_TARGET)_RESCUE
this_buildinfo += rescue
export RESCUE
else
PLATFORM_CPPFLAGS += -DBOOT_TARGET_$(CONFIG_BOOT_TARGET)
endif

ifdef SPLASH
PLATFORM_CPPFLAGS += -DSPLASH
endif
ifdef MODE_NTSC
PLATFORM_CPPFLAGS += -DMODE_NTSC
endif
ifdef MODE_PAL
PLATFORM_CPPFLAGS += -DMODE_PAL
endif
ifdef MODE_480P
PLATFORM_CPPFLAGS += -DMODE_480P
endif
ifdef MODE_576P
PLATFORM_CPPFLAGS += -DMODE_576P
endif
ifdef MODE_720P
PLATFORM_CPPFLAGS += -DMODE_720P
endif

ifdef SCART_OUTPUT
PLATFORM_CPPFLAGS += -DSCART_OUTPUT
endif
ifdef SCART_CONNECTED_ON_I2C0
PLATFORM_CPPFLAGS += -DSCART_CONNECTED_ON_I2C0
endif
ifdef SCART_ENCODER_CVBS
PLATFORM_CPPFLAGS += -DSCART_ENCODER_CVBS
endif
ifdef SCART_UDA3000
PLATFORM_CPPFLAGS += -DSCART_UDA3000
endif

ifdef HDMI_OUTPUT
PLATFORM_CPPFLAGS += -DHDMI_OUTPUT
endif

ifdef ETHERNET_PRESENT
PLATFORM_CPPFLAGS += -DETHERNET_PRESENT
endif
ifdef ETHERNET_IP3902
PLATFORM_CPPFLAGS += -DETHERNET_IP3902
endif
ifdef ETHERNET_SMSC911X
PLATFORM_CPPFLAGS += -DETHERNET_SMSC911X
endif
ifdef ETHERNET_OSCILLATOR
PLATFORM_CPPFLAGS += -DETHERNET_OSCILLATOR
endif
ifdef ETHERNET_NETPHY_RESET_PIO_29
PLATFORM_CPPFLAGS += -DETHERNET_NETPHY_RESET_PIO_29
endif
ifdef ETHERNET_FORCE_100M_FULL_DUPLEX
PLATFORM_CPPFLAGS += -DETHERNET_FORCE_100M_FULL_DUPLEX
endif

ifdef NAND_SUPPORTS_READY_SIGNAL
PLATFORM_CPPFLAGS += -DNAND_SUPPORTS_READY_SIGNAL
endif

ifdef SUNPIPE_OC2WAY
PLATFORM_CPPFLAGS += -DSUNPIPE_OC2WAY
endif

ifdef IPADDR_DEFAULT
PLATFORM_CPPFLAGS += -DIPADDR_DEFAULT=\"$(IPADDR_DEFAULT)\"
endif
ifdef SERVERIP_DEFAULT
PLATFORM_CPPFLAGS += -DSERVERIP_DEFAULT=\"$(SERVERIP_DEFAULT)\"
endif
ifdef GATEWAYIP_DEFAULT
PLATFORM_CPPFLAGS += -DGATEWAYIP_DEFAULT=\"$(GATEWAYIP_DEFAULT)\"
endif

ifdef CPU_CLK_MHZ
PLATFORM_CPPFLAGS += -DCPU_CLK_MHZ=$(CPU_CLK_MHZ)
endif

ifdef BUILDNAME
PLATFORM_CPPFLAGS += -DBUILDNAME=\"$(BUILDNAME)\"
this_buildinfo += buildname=$(BUILDNAME)
export BUILDNAME
endif

CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)

ifeq ($(filter clean distclean mrproper, $(MAKECMDGOALS)),)
prev_buildinfo := $(shell cat $(TOPDIR)/.buildinfo 2>/dev/null)
ifneq ($(prev_buildinfo),)
ifneq ($(prev_buildinfo),$(this_buildinfo))
$(error Build parameters changed: saved "$(prev_buildinfo)", new "$(this_buildinfo)". Please run 'make clean')
endif
else
$(shell echo $(this_buildinfo) > $(TOPDIR)/.buildinfo)
endif
endif
