# Comply with RDS/00008: OASIS Makefile Conventions

ifdef TARGET
    TARGET_PREFIX = $(TARGET)-
endif

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

ifdef LOG_COLLECTOR
    CFLAGS += -DLOG_COLLECTOR=$(LOG_COLLECTOR)
endif

ifdef DEBUG_LEVEL
    CFLAGS += -DDEBUG_LEVEL=$(DEBUG_LEVEL)
endif

all: precheck
	 make -C ./src
	 
clean:
	make -C ./src clean
	rm -f *.uo

install: postcheck
	@cp	-a src/radvd				$(INSTALL_ROOT)/usr/sbin
	@cp	-a radvd-sh					$(INSTALL_ROOT)/usr/bin
ifdef FULL_COPY
	@cp	-a radvd.conf.uo			$(INSTALL_ROOT)/usr/uo
endif  

precheck:
	@echo ""
	@echo "Build $(shell basename `pwd`) for $(PROJECT_NAME) ($(PROJECT_CUSTOMER))"
ifeq ($(PROJECT_CUSTOMER), ) 
	@echo ""
	@echo "No specify PROJECT_CUSTOMER in Makefile. "
	@echo "Maybe you should update the components Makefile of the Project"
	@echo ""
	@exit 1
endif 

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   


.PHONY: all clean

export CROSS_COMPILE CFLAGS TARGET_PREFIX

