# This file is part of the FreeWRT project. FreeWRT is copyrighted
# material, please see the LICENCE file in the top-level directory

include $(TOPDIR)/rules.mk

define kernel_template

$(1)/$(2)/$(3)-clean:
	@$(TRACE) target/linux/$(2)-$(1)-clean
	$(MAKE) -C $(2)-$(1) BOARD="$(2)" MODEL="$(3)" clean

$(1)/$(2)/$(3)-prepare:
	@$(TRACE) target/linux/$(2)-$(1)-prepare
	$(MAKE) -C $(2)-$(1) BOARD="$(2)" MODEL="$(3)" prepare

$(1)/$(2)/$(3)-compile:
	@$(TRACE) target/linux/$(2)-$(1)-compile
	$(MAKE) -C $(2)-$(1) BOARD="$(2)" MODEL="$(3)" compile

$(1)/$(2)/$(3)-rebuild:
	@$(TRACE) target/linux/$(2)-$(1)-rebuild
	$(MAKE) -C $(2)-$(1) BOARD="$(2)" MODEL="$(3)" rebuild

$(1)/$(2)/$(3)-install:
	@$(TRACE) target/linux/$(2)-$(1)-install
	$(MAKE) -C $(2)-$(1) BOARD="$(2)" MODEL="$(3)" install

ifeq ($(FWRT_LINUX_$(4)),y)
clean: $(1)/$(2)/$(3)-clean
prepare: $(1)/$(2)/$(3)-prepare
compile: $(1)/$(2)/$(3)-compile
rebuild: $(1)/$(2)/$(3)-rebuild
install: $(1)/$(2)/$(3)-install
endif

.PHONY: $(1)/$(2)/$(3)-clean $(1)/$(2)/$(3)-prepare \
	$(1)/$(2)/$(3)-compile $(1)/$(2)/$(3)-rebuild \
	$(1)/$(2)/$(3)-install
endef

.PHONY: clean prepare compile rebuild install

prepare:
compile:
install:
rebuild:
clean:

# asus models
$(eval $(call kernel_template,6.12,brcm,asus-wl500g,BRCM_ASUS_WL500G))
$(eval $(call kernel_template,6.12,brcm,asus-wl500g-deluxe,BRCM_ASUS_WL500G_DELUXE))
$(eval $(call kernel_template,6.12,brcm,asus-wl500g-premium,BRCM_ASUS_WL500G_PREMIUM))
# linksys models
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54gs-10,BRCM_LINKSYS_WRT54GS_10))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54gs-11,BRCM_LINKSYS_WRT54GS_11))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54gs-4,BRCM_LINKSYS_WRT54GS_4))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g-10,BRCM_LINKSYS_WRT54G_10))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g-11,BRCM_LINKSYS_WRT54G_11))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g-20,BRCM_LINKSYS_WRT54G_20))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g-22,BRCM_LINKSYS_WRT54G_22))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g-30,BRCM_LINKSYS_WRT54G_30))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g-31,BRCM_LINKSYS_WRT54G_31))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g-4,BRCM_LINKSYS_WRT54G_4))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54gl,BRCM_LINKSYS_WRT54GL))
$(eval $(call kernel_template,6.12,brcm,linksys-wrt54g3g,BRCM_LINKSYS_WRT54G3G))
# netgear models
$(eval $(call kernel_template,6.12,brcm,netgear-wgt634u,BRCM_NETGEAR_WGT634U))
