#
#		Makefile for wm-FPU-emu
#

CC	= gcc
CFLAGS	= -Wall -fno-builtin -DRSX -Ic:/rsx/source/fpu-emu/include -O6
BUILD = build

.c.o:
	$(CC) $(CFLAGS) -c -o $(BUILD)/$*.o $<

.S.o:
	$(CC) -D__ASSEMBLER__ -c -o $(BUILD)/$*.o $*.S

.s.o:
	$(CC) -D__ASSEMBLER__ -c -o $(BUILD)/$*.o $*.S


OBJS =	$(BUILD)/verify.o \
	$(BUILD)/div_smal.o \
	$(BUILD)/poly_div.o \
	$(BUILD)/poly_mul.o \
	$(BUILD)/polynomi.o \
	$(BUILD)/reg_div.o \
	$(BUILD)/reg_norm.o \
	$(BUILD)/reg_u_ad.o \
	$(BUILD)/reg_u_di.o \
	$(BUILD)/reg_u_mu.o \
	$(BUILD)/reg_u_su.o \
	$(BUILD)/wm_shrx.o \
	$(BUILD)/wm_sqrt.o \
	$(BUILD)/errors.o \
	$(BUILD)/fpu_arit.o \
	$(BUILD)/fpu_aux.o \
	$(BUILD)/fpu_entr.o \
	$(BUILD)/fpu_etc.o \
	$(BUILD)/fpu_trig.o \
	$(BUILD)/get_addr.o \
	$(BUILD)/load_sto.o \
	$(BUILD)/poly_2xm.o \
	$(BUILD)/poly_ata.o \
	$(BUILD)/poly_l2.o \
	$(BUILD)/poly_sin.o \
	$(BUILD)/poly_tan.o \
	$(BUILD)/reg_add_.o \
	$(BUILD)/reg_comp.o \
	$(BUILD)/reg_roun.o \
	$(BUILD)/reg_cons.o \
	$(BUILD)/reg_ld_s.o \
	$(BUILD)/reg_mul.o

FPU-OBJ = $(BUILD)/fpu-emu.o

all: rsx387 rsxw387
	@echo make ready!

$(FPU-OBJ): $(OBJS)
	ld -r -o $(FPU-OBJ) @fpu-emu.rsp

rsx387: $(BUILD)/crt0fpu.o $(BUILD)/printk.o $(FPU-OBJ)
	ld -o rsx387 $(BUILD)/crt0fpu.o $(BUILD)/printk.o $(FPU-OBJ)
	strip rsx387

rsxw387: $(BUILD)/crt0fpuw.o $(BUILD)/printk.o $(FPU-OBJ)
	ld -o rsxw387 $(BUILD)/crt0fpuw.o $(BUILD)/printk.o $(FPU-OBJ)
	strip rsxw387
