# search file from current folder to parent folders
# cutoff at 14th parent folder
search_cutoff := ../../../../../../../../../../../../../../
define search-file
	$(if $(filter $(search_cutoff)%,$1),,$(if $(wildcard $1),$1,$(call search-file,../$1)))
endef

include $(call search-file,arch.mk)
include $(call search-file,path.mk)

targets :=
targets += all
all: brctl

brctl:	
	if [ ! -f ./.configured ]; then \
	cd bridge-utils-1.5 && /bin/sh configure --prefix=$(TARGET) --host=$(HOST_TYPE) CC=$(CC) AS=$(AS) AR=$(AR) \
	LD=$(LD) RANLIB=$(RANLIB) STRIP=$(STRIP) CFLAGS=-I$(TOPDIR)/include; \
	fi	
	touch ./.configured;
	make -C bridge-utils-1.5

targets += install
install:
	cp bridge-utils-1.5/brctl/brctl $(TARGET)/usr/sbin/

targets += clean
clean:
	make -C bridge-utils-1.5 clean
	rm -f .configured

.PHONY: $(targets)
