#-----------------------------------------------------------------------------
#
# make libs    - build library routines and install them in the appropriate
#		 modules in ../lib
#
# make <fxn>-test   - build interactive program to test the table driven 
#		      routine FXN()
# make <fnx>-inline - build interactive program to test the inline version
#		      of the routine FXN()
#
#-----------------------------------------------------------------------------

CFLAGS = $(RCC_CFLAGS)
INLINE = inlinemath.sed contants.sed
LIBS = ../lib/libCtree.a ../lib/libC.a 

rciCtrlModuleDep(mt_sin)
rciCtrlModuleDep(mt_atan2)
rciCtrlModuleDep(sin)
rciCtrlModuleDep(atan2)
rciCtrlModuleDep(sqrt)

maintainRciCtrl(libs)
maintainVxwLibs(vxwFastmath,vxlibs)

#ifdef VaxArch
asmCppModule(sin,SIN_Cdefs.h SIN_Adefs.h)
asmCppModule(atan2,ATAN2_Cdefs.h ATAN2_Adefs.h)
sqrt.o:	sqrt-s.s
	$(CC) -E $(AS_CFLAGS) sqrt-s.s | as -o sqrt.o
#else
basicModule(sin)
basicModule(atan2)
basicModule(sqrt)
#endif

basicModule(mt_sin)
basicModule(mt_atan2)

#if !VxWorksConfig

basicProgram(maketable,maketable.o,-lm $(LLIBC))

mt_sin.c: 	SIN.conf maketable
		./maketable < SIN.conf

mt_atan2.c: 	ATAN2.conf maketable
		./maketable < ATAN2.conf

SIN_Cdefs.h SIN_Adefs.h SIN_Adefs.sed: SIN.conf maketable
		./maketable -h < SIN.conf

ATAN2_Cdefs.h ATAN2_Adefs.h ATAN2_Adefs.sed: ATAN2.conf maketable
		./maketable -h < ATAN2.conf
#else
../mt_atan2.c ../ATAN2_Cdefs.h:
		cd ..; $(MAKE) $(MFLAGS) mt_atan2.c
../mt_sin.c ../SIN_Cdefs.h:
		cd ..; $(MAKE) $(MFLAGS) mt_sin.c
#endif

basicProgram(sin-test,sin-test.o sin.o mt_sin.o,-lm $(LIBS))
basicProgram(atan2-test,atan2-test.o atan2.o mt_atan2.o,-lm $(LIBS))
basicProgram(sqrt-test,sqrt-test.o sqrt.o,-lm $(LIBS))

#ifdef VaxArch
#define inlineModule(mod,src,defs)mod.o:  src.c defs $(INLINE)		@@\
	$(CC) $(CFLAGS) -S src.c					@@\
	inlinemath src.s mod.s						@@\
	$(CC) -c mod.s							@@\
	$(RMCMD) -f mod.s src.s						@@\

inlineModule(sin-inline,sin-test,SIN_Adefs.sed)
inlineModule(atan2-inline,atan2-test,ATAN2_Adefs.sed)
basicProgram(sin-inline,sin-inline.o mt_sin.o,-lm)
basicProgram(atan2-inline,atan2-inline.o mt_atan2.o,-lm)
#endif

makeClean(*test *inline maketable)
makeDepend()
maintainVxwSubdir()
