############################################################################
#                  Makefile for the ALMOS-MKH "mini-libc"                  #
############################################################################

-include ../../params-soft.mk
ifeq ($(ARCH_NAME),)
$(error Please define in ARCH_NAME parameter in params-soft.mk!)
endif




compiling: build build/Makefile
	echo $(HAL_ARCH)
	cd build && SHARED_INCLUDE=$(SHARED_INCLUDE) HAL=$(HAL) HAL_ARCH=$(HAL_ARCH) make
	cd build && make install
	cd $(LIBC_INCLUDE) && rm pthread.h && rm sys/_pthreadtypes.h && sed -i "s&#include <sys/_pthreadtypes.h>&&" sys/types.h && sed -i "s/^int pthread.*//" sys/signal.h
	$(AR) rc $(LIBC)/libc.a $(HAL_ARCH)/build/core/hal_user.o
	ranlib $(LIBC)/libc.a

headers:
	echo "Hum ça va posser pb non ?"

build/Makefile: build #configure
	- test ! -f build/Makefile && cd build && LIBALMOSMKH_INCLUDE=$(LIBALMOSMKH_INCLUDE) SHARED_INCLUDE=$(SHARED_INCLUDE) HAL=$(HAL) HAL_ARCH=$(HAL_ARCH) ../src/newlib/configure --host=$(ARCH_NEWLIB)-almosmkh --prefix=`pwd` --with-newlib --disable-multilib --disable-newlib-io-float

build :
	@mkdir build


.PHONY = clean compiling


clean:
	rm -rf build/
