export BUILD_TOPDIR=$(PWD)
export STAGING_DIR=$(BUILD_TOPDIR)/tmp
export TOPDIR=$(PWD)
export UBOOTDIR=$(TOPDIR)/u-boot

### Toolchain config ###
#buildroot
#CONFIG_TOOLCHAIN_PREFIX=/opt/build/toolchain-mipsbe-4.7.3/bin/mips-linux-

#openwrt NOT YET
#CONFIG_TOOLCHAIN_PREFIX=mips-openwrt-linux-uclibc-
#export PATH:=/mnt/projects/lynxis/openwrt/lazus_2/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin:$(PATH)

#CONFIG_TOOLCHAIN_PREFIX=mips-openwrt-linux-uclibc-
#export PATH:=/home/lynxis/projects/work/sysmocom/Caraboot/OpenWrt-Toolchain-ar71xx-for-mips_r2-gcc-4.6-linaro_uClibc-0.9.33.2/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin:$(PATH)

CONFIG_TOOLCHAIN_PREFIX=mips-buildroot-linux-uclibc-
export PATH:=/home/lynxis/projects/work/sysmocom/buildroot/output/host/usr/bin/:$(PATH)

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

export CROSS_COMPILE=$(CONFIG_TOOLCHAIN_PREFIX)
export MAKECMD=make ARCH=mips

export UBOOT_GCC_4_3_3_EXTRA_CFLAGS=-fPIC
export BUILD_TYPE=squashfs

IMAGEPATH=$(BUILD_TOPDIR)/bin
UBOOT_BINARY=u-boot.bin
BOARD_TYPE:=

skylab_config:
	export COMPRESSED_UBOOT=0
	export CARABOOT_RELEASE=v2.2-dev

carambola2_config:
	export COMPRESSED_UBOOT=0
	export CARABOOT_RELEASE=v2.2-dev

compile:
	cd $(UBOOTDIR) && $(MAKECMD) distclean
	cd $(UBOOTDIR) && $(MAKECMD) $(BOARD_TYPE)_config
	cd $(UBOOTDIR) && $(MAKECMD) all
	@echo Copy binaries to $(IMAGEPATH)/$(UBOOTFILE)
	mkdir -p $(IMAGEPATH)
	cp -f $(UBOOTDIR)/$(UBOOT_BINARY) $(IMAGEPATH)/$(UBOOTFILE)

	@echo Done

carambola2: BOARD_TYPE:= carambola2
carambola2: UBOOTFILE=$(BOARD_TYPE)_u-boot.bin
carambola2: carambola2_config compile

skylab: BOARD_TYPE:= skylab
skylab: UBOOTFILE=$(BOARD_TYPE)_u-boot.bin
skylab: skylab_config compile

all: carambola2 skylab

clean:
	cd $(UBOOTDIR) && $(MAKECMD) distclean
