
ifdef TARGET
	TARGET_PREFIX = $(TARGET)-
endif

ifndef CROSS_COMPILE
	CROSS_COMPILE = $(TARGET_PREFIX)
	CC = $(CROSS_COMPILE)gcc
	STRIP = $(CROSS_COMPILE)strip
endif

ifndef KERNEL_DIR
	KERNEL_DIR=/usr/src/linux
endif


INCLUDE = -I$(KERNEL_DIR)/include 

ifneq ($(TC_CFLAGS), )
        CFLAGS+=$(TC_CFLAGS)
endif

ifneq ($(strip $(TCSUPPORT_CODE_SHRINK)),)
CFLAGS += -Os
endif

export LDFLAGS =-L$(shell pwd)/../../$(TARGET_PREFIX)lib

general_config= --host=$(TARGET) --prefix=$(shell pwd)/install --enable-mpoa_1_1 --with-kernel-headers=$(KERNEL_DIR) --disable-thomflex --disable-thomflex --enable-static --disable-shared

EXECS= install/sbin/br2684ctl

all: $(EXECS)

$(EXECS):  
	cd linux-atm-2.5.2; ./configure $(general_config);make;make install
	$(STRIP) --strip-unneeded $(EXECS)
install: postcheck
	cp install/sbin/br2684ctl $(INSTALL_ROOT)/usr/sbin/
	
clean:
	rm -rf install/
	make -C linux-atm-2.5.2 distclean

postcheck:
	@echo ""
	@echo "Install $(shell basename `pwd`) to $(INSTALL_ROOT)"
ifeq ($(INSTALL_ROOT), )
	@echo ""
	@echo "No specify INSTALL_ROOT in Makefile. "
	@echo "Maybe you should update the components Makefile of the Project"
	@echo ""
	@exit 1
endif

