default: it

clean:
	rm -f accuracy accuracy.o choose compile floatasm.h hasgethr.h \
	hasmftb.h hasrdtick.h hasrdtsc.h hasrpcc.h it load main.o makelib \
	myrandom.o nistp224 nistp224-56 nistp224-56.o nistp224.a nistp224.c \
	nistp224.h nistp224.o rts speed speed.o sysdeps systype

accuracy: accuracy.o load myrandom.o nistp224.a
	./load accuracy myrandom.o nistp224.a 

accuracy.o: accuracy.c compile myrandom.h nistp224.h
	./compile accuracy.c

choose: choose.sh conf-home warn-auto.sh
	rm -f choose
	cat warn-auto.sh choose.sh \
	| sed s}HOME}"`head -1 conf-home`"}g \
	> choose
	chmod 555 choose

compile: conf-cc print-cc.sh systype warn-auto.sh
	rm -f compile
	sh print-cc.sh > compile
	chmod 555 compile

floatasm.h: choose compile floatasm.h1 floatasm.h2 load tryfnmadd.c
	./choose clr tryfnmadd floatasm.h1 floatasm.h2 > floatasm.h

hasgethr.h: choose compile hasgethr.h1 hasgethr.h2 load trygethr.c
	./choose cl trygethr hasgethr.h1 hasgethr.h2 > hasgethr.h

hasmftb.h: choose compile hasmftb.h1 hasmftb.h2 load trymftb.c
	./choose cl trymftb hasmftb.h1 hasmftb.h2 > hasmftb.h

hasrdtick.h: choose compile hasrdtick.h1 hasrdtick.h2 load \
tryrdtick.c
	./choose clr tryrdtick hasrdtick.h1 hasrdtick.h2 > hasrdtick.h

hasrdtsc.h: choose compile hasrdtsc.h1 hasrdtsc.h2 load tryrdtsc.c
	./choose clr tryrdtsc hasrdtsc.h1 hasrdtsc.h2 > hasrdtsc.h

hasrpcc.h: choose compile hasrpcc.h1 hasrpcc.h2 load tryrpcc.c
	./choose cl tryrpcc hasrpcc.h1 hasrpcc.h2 > hasrpcc.h

it: rts sysdeps

load: conf-ld print-ld.sh systype warn-auto.sh
	rm -f load
	sh print-ld.sh > load
	chmod 555 load

main.o: compile main.c nistp224.h
	./compile main.c

makelib: print-ar.sh systype warn-auto.sh
	rm -f makelib
	sh print-ar.sh > makelib
	chmod 555 makelib

myrandom.o: compile myrandom.c myrandom.h
	./compile myrandom.c

nistp224: load main.o nistp224.o
	./load nistp224 main.o 

nistp224-56: load nistp224-56.o nistp224.o
	./load nistp224-56 nistp224.o 

nistp224-56.o: compile nistp224-56.c nistp224.h
	./compile nistp224-56.c

nistp224.a: makelib nistp224.o
	./makelib nistp224.a nistp224.o

nistp224.c: conf-opt floatasm.h opt-idea53.c opt-idea64.c \
opt-pentium-f2g.c opt-pentium-fgh.c opt-pentium-fghi.c opt-pentium.c \
opt-powerpc-f2g.c opt-powerpc-fgh.c opt-powerpc-fghi.c opt-powerpc.c \
opt-ppro-f2.c opt-ppro-f2g.c opt-ppro-fg.c opt-ppro-fg8h2.c \
opt-ppro-fgh.c opt-ppro-fghi.c opt-ppro.c opt-sparc-f2g.c \
opt-sparc-fgh.c opt-sparc-fghi.c opt-sparc.c print-opt.sh systype
	rm -f nistp224.c
	sh print-opt.sh c > nistp224.c
	chmod 444 nistp224.c

nistp224.h: conf-opt opt-idea53.h opt-idea64.h opt-pentium.h \
opt-powerpc.h opt-ppro.h opt-sparc.h print-opt.sh systype
	rm -f nistp224.h
	sh print-opt.sh h > nistp224.h
	chmod 444 nistp224.h

nistp224.o: compile nistp224.c nistp224.h opt-ppro-f2.c \
opt-ppro-f2g.c opt-ppro-fg.c opt-ppro-fg8h2.c opt-ppro-fgh.c \
opt-ppro-fghi.c sqtab64.c
	./compile nistp224.c

rts: accuracy nistp224 nistp224-56 rts.tests speed
	env - /bin/sh rts.tests 2>&1 | cat -v > rts

speed: load myrandom.o nistp224.a speed.o
	./load speed myrandom.o nistp224.a 

speed.o: compile hasgethr.h hasmftb.h hasrdtick.h hasrdtsc.h \
hasrpcc.h myrandom.h nistp224.h speed.c timing.h
	./compile speed.c

sysdeps: compile floatasm.h hasgethr.h hasrdtick.h hasrdtsc.h \
hasrpcc.h load rts rts.exp speed systype
	rm -f sysdeps
	echo nistp224 0.75 >> sysdeps
	gcc --version >> sysdeps
	cat systype compile load >> sysdeps
	grep sysdep hasgethr.h >> sysdeps
	grep sysdep hasrdtsc.h >> sysdeps
	grep sysdep hasrpcc.h >> sysdeps
	grep sysdep hasrdtick.h >> sysdeps
	grep sysdep floatasm.h >> sysdeps
	cmp rts rts.exp >> sysdeps
	./speed >> sysdeps

systype: find-systype.sh trycpp.c x86cpuid.c
	sh find-systype.sh > systype

