############################################################################
#          Makefile for the "math" library.                                #
############################################################################

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

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

SRCS = e_pow.c        \
       e_rem_pio2.c   \
       e_sqrt.c       \
       fmod.c         \
       k_cos.c        \
       k_rem_pio2.c   \
       k_sin.c        \
       s_ceil.c       \
       s_copysign.c   \
       s_cos.c        \
       s_fabs.c       \
       s_finite.c     \
       s_floor.c      \
       s_isnan.c      \
       s_rint.c       \
       s_scalbn.c     \
       s_sin.c 

OBJS = $(addprefix build/, $(SRCS:.c=.o))

libs : build/lib/libmath.a  headers

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

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

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

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

.PHONY = build clean headers

clean:
	rm -rf build/
