include ../Rules.mak


UCLIB = ../tools/uClibc-0.9.28

all:build_lib 

build_lib: mips-linux-uclibc
	$(MAKE) -C $(UCLIB)
	$(MAKE) -C $(UCLIB) install_target	
	$(MAKE) -C makeimage


mips-linux-uclibc:
	cd $(UCLIB)/extra/config && make clean && make
	if [ ! -f .config ] ; then \
	    cp -f $(UCLIB)/dot_config_dm111 $(UCLIB)/.config; \
	fi
	$(MAKE) -C $(UCLIB)
	$(MAKE) -C $(UCLIB) install
#	ln -sf ../../../apps/openssl-0.9.7e/include/openssl/ mips-linux-uclibc/include
#	ln -sf asm/avalanche/generic/pal.h mipsel-linux-uclibc/include
clean:
	$(MAKE) -C makeimage clean
	$(MAKE) -C $(UCLIB) clean
	rm -rf mips-linux-uclibc




LIB_SRC=$(UCLIB)
GPL_TOOLS_DIR=$(GPL_DIR)/tools

GPL:
	@if [ ! -d $(GPL_DIR) ]; then echo "GPL directory not exist!!"; exit 1; fi 
	@if [ ! -d $(GPL_TOOLS_DIR) ]; then mkdir $(GPL_TOOLS_DIR); fi
	
	$(MAKE) -C $(LIB_SRC) clean
	cp -a $(LIB_SRC) $(GPL_TOOLS_DIR)/

	make -C ./makeimage GPL  GPL_TOOLS_DIR=$(GPL_TOOLS_DIR)
	
	echo UCLIB=tools/$(UCLIB) >> $(GPL_DIR)/Rules.mak


