all: # parser.c takeon.c update_astcode.c c.c check-missing.c regexp-lexer.c regexp-lexer.h
	grep ^//\\\\ c.c > parser-c.g
	ecce parser-c.g --command "(v.//\\\\ .s..m,m)0m-0(r0 (v-/ /e-)0 m)0 m-0 (rm,k)0 m-0 (r0v-/;/b,m)0 m-0 (v/B/\m,mr\j,m)0 m0 (m-v/B/\)0 mb;%c" > /dev/null 2>&1
	cc -g -o takeon takeon.c
	./takeon parser-c.g > parser-c.h
	cc -g -o update_astcode-c -DINCLUDE="\"parser-c.h\"" -Wno-format-extra-args update_astcode.c
	./update_astcode-c > c-new.c
	mv c-new.c c.c
	grep ^//\\\\ c.c > parser-c.g
	ecce parser-c.g --command "(v.//\\\\ .s..m,m)0m-0(r0 (v-/ /e-)0 m)0 m-0 (rm,k)0 m-0 (r0v-/;/b,m)0 m-0 (v/B/\m,mr\j,m)0 m0 (m-v/B/\)0 mb;%c" > /dev/null 2>&1
	cc -g -o takeon takeon.c
	./takeon parser-c.g > parser-c.h
	cc -g -o check-missing-c -DTABLE="\"parser-c.h\"" check-missing.c
	cc -O -DLEX_H="\"line_reconstruction-c.h\"" -DLEX_C="\"line_reconstruction-c.c\"" -DTABLE="\"parser-c.h\"" -DINCLUDE="\"c.c\"" -DCOMPILE="\"compile-c.c\"" -Wno-div-by-zero -o parser-c-opt parser.c
	cc -g -o generate-compiler-c -DTABLE="\"parser-c.h\"" generate-compiler.c
	./generate-compiler-c > compile-c.c
	cc -g -DLEX_H="\"line_reconstruction-c.h\"" -DLEX_C="\"line_reconstruction-c.c\"" -DTABLE="\"parser-c.h\"" -DCHECK_INDEXES=1 -DINCLUDE="\"c.c\"" -DCOMPILE="\"compile-c.c\"" -Wno-div-by-zero -o parser-c parser.c
	ctohtml compile-c.c > compile-c.c.html
	ctohtml c.c > c.c.html
	ctohtml compile-c.c > compile-c.c.html
	ctohtml line_reconstruction-c.c > line_reconstruction-c.c.html
	ctohtml parser.c > parser.c.html
	ctohtml regexp-lexer.c > regexp-lexer.c.html
        
clean:
	rm -f *~ parser-c parser-c-opt takeon check-missing-c update_astcode-c generate-compiler-c *.[ch].html

upload: all
	scp README.txt README-TO-DO.txt Makefile Makefile-c parser-c.g parser-c.h parser.c \
	    line_reconstruction-c.h line_reconstruction-c.c takeon.c update_astcode.c \
	    c.c c.c.html parser.c.html line_reconstruction-c.c.html check-missing.c \
	    generate-compiler.c compile-c.c compile-c.c.html \
            regexp-lexer.c regexp-lexer.h regexp-lexer.c.html \
	    gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/experimental/generic-parser/
	scp RCS/*,v gtoal@gtoal.com:gtoal.com/SBTPROJECT/6809sbt/experimental/generic-parser/RCS/backup/
