############################################################################
#                  Makefile for the ALMOS-MKH specific library             #
############################################################################

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

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

SRCS = almosmkh.c 

OBJS = $(addprefix build/, $(SRCS:.c=.o)) \
       $(HAL_ARCH)/build/core/hal_user.o

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

libs : build/lib/libalmosmkh.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 $(SRCS:.c=.h)  build/include/.

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

.PHONY = build clean headers

clean:
	rm -rf build/
