############################################################################
#               Makefile for the "pthread" library.                        #
############################################################################

-include ../../params-soft.mk

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

OBJS = build/pthread.o                    \
       $(HAL_ARCH)/build/core/hal_user.o

INCLUDES = -I.                     \
           -I$(LIBC_PATH)          \
           -I$(LIBALMOSMKH_PATH)   \
           -I$(SHARED_INCLUDE)     \
           -I$(HAL)/generic        \
           -I$(HAL_ARCH)/core      \
           -I$(KERNEL) 

libs : build/lib/libpthread.a  headers

build :
	@mkdir build
	@mkdir build/lib
	@mkdir build/include

$(HAL_ARCH)/build/core/hal_user.o :
	$(MAKE) -C $(HAL_ARCH)

build/%.o : %.c %.h
	$(CC) $(INCLUDES) $(CFLAGS) -c -o  $@ $<
	$(DU) -D $@ > $@.txt

headers: build
	cp pthread.h  build/include/.


build/lib/libpthread.a: build  $(OBJS)
	$(AR) rc $@ $(OBJS) 
	$(RANLIB) $@

.PHONY = build clean headers


clean:
	rm -rf build/
