

BR2_EXTERNAL ?= $(AW_PROJECT)/../../bsp/buildroot_external/

BR_ENV = BR2_EXTERNAL=$(BR2_EXTERNAL) O=$(AW_STAGING)/buildroot/ WORKSPACE_DIR=$(AW_STAGING) BUILDS_ROOT=$(AW_LOCAL_BUILDS_ROOT) BOARD=$(AW_BOARD) PROJECT=$(AW_PROJECT)

buildroot.menuconfig: buildroot.config
	$(MAKE) $(BR_ENV) -C $(AW_PROJECT)/../../bsp/buildroot/ menuconfig
	cmp -s $(AW_STAGING)/buildroot/.config $(AW_PROJECT)/configs/buildroot.config; \
	if test $$? -ne 0; then echo "Config Files has changed......"; \
		cp $(AW_STAGING)/buildroot/.config $(AW_PROJECT)/configs/buildroot.config; \
	fi

buildroot: buildroot.config
	$(MAKE) $(BR_ENV) -C $(AW_PROJECT)/../../bsp/buildroot/

buildroot.shell: buildroot.config
	$(eval export $(BR_ENV))
	cd $(AW_STAGING)/buildroot/; $(BR_ENV) bash

buildroot.config:
	@mkdir -p $(AW_STAGING)/buildroot/
ifeq ("$(wildcard $(AW_STAGING)/buildroot/.config)","")
	@cp $(AW_PROJECT)/configs/buildroot.config $(AW_STAGING)/buildroot/.config
else
	cmp -s $(AW_PROJECT)/configs/buildroot.config $(AW_STAGING)/buildroot/.config; \
	if test $$? -ne 0; then echo "Config Files has changed......"; \
		cp $(AW_PROJECT)/configs/buildroot.config $(AW_STAGING)/buildroot/.config; \
	fi
endif
