
#
#               Makefile for wm-FPU-emu for djgpp
#
#  Copyright (C) 1994
#                        W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
#                        Australia.  E-mail   billm@vaxc.cc.monash.edu.au
#
#  See the files "README" and "COPYING" for further copyright and warranty
#  information.
#
# ------------------------------------------------------------------

# Customization Section

# This is the MS-DOS directory where the intermediate assembler
# files are to go:
DJGPP_FPU_EMU_DIR	= /d/djgpp/fpu-emu

# This is the MS-DOS directory holding the djgpp header files
DJGPP_INCLUDE	= /d/djgpp/include

# One file, FPU-emu.c, needs the standard header files.
# Either the standard Linux header files or the djgpp header files
# can be used.
# If the djgpp headers are chosen then it is necessary to edit
# stdio.h to remove a few CR (0x0d) characters where they follow
# a continuation ('\') character.
#MAIN_INCLUDE	= -I$(DJGPP_INCLUDE) -DDJGPP_INCLUDES
MAIN_INCLUDE	= -I/usr/include    # Use the standard Linux header files

#DEBUG	= -DDEBUGGING
DEBUG	=


#--------------------------------------------------------------------
# It should not be necessary to change anything past this point.

# This is the directory where the Linux FPU emulator sources are located:
LINUX_FPU_DIR	= /usr/src/linux/drivers/FPU-emu

VPATH = $(LINUX_FPU_DIR)

INCLUDES	= -I- -I. -I$(LINUX_FPU_DIR)
CFLAGS	+= -D__KERNEL__ -Wall -Wstrict-prototypes -O6 \
	  -fomit-frame-pointer -fno-builtin $(INCLUDES) \
	  -DPARANOID $(DEBUG) -DCONFIG_MATH_EMULATION
ASMFLAGS	= $(INCLUDES) -D__KERNEL__ -D__ASSEMBLER__ -DPARANOID
DEPFLAGS	= -M $(INCLUDES)

# These objects are DJGPP-specific:
CINTERMED2	= FPU-emu.s install.s
ASMINTERMED2 =

# These objects are made from the un-modified Linux sources:
CINTERMED	= fpu_entry.s errors.s \
	fpu_arith.s fpu_aux.s fpu_etc.s fpu_trig.s \
	load_store.s get_address.s reg_mul.s \
	poly_atan.s poly_l2.s poly_2xm1.s poly_sin.s poly_tan.s \
	reg_add_sub.s reg_compare.s reg_constant.s reg_ld_str.s
ASMINTERMED =	reg_div.s poly_mul64.s polynomial.s reg_norm.s \
	reg_u_add.s reg_u_div.s reg_u_mul.s reg_u_sub.s \
	reg_round.s wm_shrx.s wm_sqrt.s div_small.s poly_div.s

INTERMED	= $(CINTERMED) $(ASMINTERMED) $(CINTERMED2) $(ASMINTERMED2)

# The default target
all:	$(INTERMED)

# Put the intermediate assembler files in the DOS directory
djgpp: $(INTERMED)
	@( cd $(DJGPP_FPU_EMU_DIR); rm -f $(INTERMED) )
	-@if [ -f $(DJGPP_FPU_EMU_DIR)/*.s ]; then \
	     rm -i $(DJGPP_FPU_EMU_DIR)/*.s; fi;
	cp $(INTERMED) $(DJGPP_FPU_EMU_DIR)
	cp makefile.djgpp $(DJGPP_FPU_EMU_DIR)/makefile

$(CINTERMED) : %.s : %.c
	$(CC) $(CFLAGS) -S $<

$(ASMINTERMED) $(ASMINTERMED2) : %.s : %.S
	$(CC) $(ASMFLAGS) -E $< > $@

$(CINTERMED2) : %.s : %.c
	$(CC) $(CFLAGS) $(MAIN_INCLUDE) -S $<

OBJS =	$(patsubst %.s,%.o,$(INTERMED)) 

$(OBJS) : %.o : %.s
	$(AS) -o $@ $<

test: test.c $(OBJS)
	$(CC) $(CFLAGS) -o test $< $(OBJS)

tar:
	( cd /; tar cvf wmfpu111.tar ./usr/src/djgpp/wm-FPU-emu \
	./usr/src/linux/drivers/FPU-emu/[MR]* \
	./usr/src/linux/drivers/FPU-emu/*.[cSh] \
	; gzip wmfpu111.tar )

clean:
	rm -f core *.o *.a *.s test *.map *~

dep:
	$(CPP) $(DEPFLAGS) $(MAIN_INCLUDE) *.c > .depend
	$(CPP) $(DEPFLAGS) $(LINUX_FPU_DIR)/*.c >> .depend
	$(CPP) $(DEPFLAGS) -D__ASSEMBLER__ $(LINUX_FPU_DIR)/*.S >> .depend
	sed 's/.o : /.s : /' < .depend > .tmp
	mv .tmp .depend

dummy:

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
