all: SS.1.txt SS.1.html all-SS.html SS.html plots date_time.out

SS="../SS"

C2HTML="./c2html"

WEBLINT="./weblint"

SRC = antelopes.ss cycles.ss date_time.ss expr_list.ss grades.ss plot.ss \
	plot3d.ss poly.ss rand.ss sqrt.ss syms.ss numeric_vs_range.ss \
	bank.ss exp.ss search.ss Copy.ss Cell.ss find.ss loop.ss while.ss \
	logic.ss

HELP = help.out Operators Numeric Range Commands Constants Options

TMPS = cycles.out.tmp grades.out.tmp rand.out.tmp expr_list.out.tmp \
	sqrt.out.tmp syms.out.tmp atan2.c.tmp constants.tmp antelopes.out.tmp \
	poly.sh.tmp numeric_vs_range.out.tmp bank.out.tmp exp.sh.tmp \
	search.out.tmp bank.ss.tmp Copy.out.tmp Copy.ss.tmp \
	Cell.out.tmp Cell.ss.tmp find.out.tmp find.ss.tmp loop.out.tmp loop.ss.tmp \
	while.out.tmp while.ss.tmp logic.ss.tmp logic.out.tmp

$(HELP): help.sh
	./help.sh

tmps: $(TMPS)

plots: plot.gif plot3d.gif poly.gif exp.gif

plot.gif: plot.ss SS.sdf
	$(SS) -p plot.ss > plot.gif

plot3d.gif: plot3d.ss SS.sdf
	$(SS) -p3 plot3d.ss > plot3d.gif

poly.gif: poly.ss poly.sh SS.sdf
	./poly.sh

exp.gif: exp.ss exp.sh SS.sdf
	./exp.sh

SS.1: SS.1.so $(HELP) Makefile
	(echo ".TH SS 1 \"`$(SS) --version`\""; cat SS.1.so) | soelim -r > SS.1
#soelim | grep -v '^\.lf ' > SS.1

SS.1.txt: SS.1 Makefile
	nroff -man SS.1 | col -b > SS.1.txt

SS.1.html: SS.1 Makefile
	nroff -man SS.1 | ./man2html -title SS > SS.1.html

SS.sdf: SS.so Makefile $(HELP) $(TMPS) $(SRC)
	soelim -r SS.so > SS.sdf
#soelim SS.so | grep -v '^\.lf ' > SS.sdf

SS.html: SS.sdf Makefile
	sdf -2topics -n3 SS
	printf "/^<ADDRESS CLASS=\"doc-modified\">\ns/.*/`$(SS) --version`\nw\nq\n" | ed SS.html
	-$(WEBLINT) -x microsoft SS*.html
	rm -f $(HELP) $(TMPS) SS.sdf

all-SS.html: SS.sdf Makefile
	sdf -2html all-SS
	printf "/^<ADDRESS CLASS=\"doc-modified\">\ns/.*/`$(SS) --version`\nw\nq\n" | ed all-SS.html
	-$(WEBLINT) -x microsoft all-SS.html

backup:
	cp -p all-SS.html all-SS.html.OLD

diff:
	-diff all-SS.html.OLD all-SS.html

date_time.out: SS.sdf date_time.ss
	echo "print;" | $(SS) date_time.ss - > date_time.out

syms.out.tmp: syms.ss
	$(SS) syms.ss | $(C2HTML) > syms.out.tmp

logic.ss.tmp: logic.ss
	$(C2HTML) < logic.ss > logic.ss.tmp

logic.out.tmp: logic.ss
	$(SS) logic.ss | $(C2HTML) > logic.out.tmp

numeric_vs_range.out.tmp: numeric_vs_range.ss
	$(SS) numeric_vs_range.ss | $(C2HTML) > numeric_vs_range.out.tmp

cycles.out.tmp: cycles.ss
	echo "print values; eval 1; eval 1000; print values;" | \
	  $(SS) cycles.ss - | $(C2HTML) > cycles.out.tmp

rand.out.tmp: rand.ss
	$(SS) rand.ss | $(C2HTML) > rand.out.tmp

expr_list.out.tmp: expr_list.ss
	$(SS) expr_list.ss | $(C2HTML) > expr_list.out.tmp

sqrt.out.tmp: sqrt.ss
	echo "print all; eval a0:b0 10; print values;" | \
	  $(SS) -T sqrt.ss - > sqrt.out.tmp

grades.out.tmp: grades.ss
	$(SS) -T grades.ss > grades.out.tmp

bank.out.tmp: bank.ss
	$(SS) -c 10 -T bank.ss > bank.out.tmp

bank.ss.tmp: bank.ss
	$(C2HTML) < bank.ss > bank.ss.tmp

Copy.out.tmp: Copy.ss
	$(SS) Copy.ss > Copy.out.tmp

Copy.ss.tmp: Copy.ss
	$(C2HTML) < Copy.ss > Copy.ss.tmp

Cell.out.tmp: Cell.ss
	$(SS) Cell.ss > Cell.out.tmp

Cell.ss.tmp: Cell.ss
	$(C2HTML) < Cell.ss > Cell.ss.tmp

find.out.tmp: find.ss
	$(SS) find.ss > find.out.tmp

find.ss.tmp: find.ss
	$(C2HTML) < find.ss > find.ss.tmp

loop.out.tmp: loop.ss
	$(SS) loop.ss > loop.out.tmp

loop.ss.tmp: loop.ss
	$(C2HTML) < loop.ss > loop.ss.tmp

while.out.tmp: while.ss
	$(SS) while.ss > while.out.tmp

while.ss.tmp: while.ss
	$(C2HTML) < while.ss > while.ss.tmp

antelopes.out.tmp: antelopes.ss
	$(SS) -T antelopes.ss > antelopes.out.tmp

search.out.tmp: search.ss
	$(SS) search.ss > search.out.tmp

atan2.c.tmp: ../nf/atan2.c
	$(C2HTML) < ../nf/atan2.c > atan2.c.tmp

poly.sh.tmp: poly.sh
	$(C2HTML) < poly.sh > poly.sh.tmp

exp.sh.tmp: exp.sh
	$(C2HTML) < exp.sh > exp.sh.tmp

constants.tmp: ../parse.so
	grep install_constant ../parse.so > constants.tmp

clean:
	rm -f $(HELP) $(TMPS) SS.sdf