SICSTUS=sicstus3.3 -f

# compiled grammars for MiMo2:
MIMO= mimo_lc.ql mimo_hc.ql mimo_bu.ql mimo_inact_p.ql
# compiled grammars for ANLT
ANLT= anlt_lc.ql anlt_hc.ql anlt_hc_lc.ql anlt_bu.ql anlt_inact_p.ql

default:
	echo "If you get an error, please install Hdrug, and/or edit ./sh"
	touch mimo.g anlt.g
	sleep 1
	touch  mimo.pl anlt.pl lc_mixtus.pl hc_mixtus.pl
	make all

all: $(MIMO) $(ANLT)

clean: 
	/bin/rm -f *.ql mimo_*.pl anlt_*.pl *.xlog *.log


anlt.ql: anlt.pl
	-echo "prolog_flag(compiling,_,compactcode),\
                   fcompile(mj_in:anlt)." | $(SICSTUS) 

mimo.ql: mimo.pl
	-echo "prolog_flag(compiling,_,compactcode),\
                   fcompile(mj_in:mimo)." | $(SICSTUS) 

# how to create .ql files. Change this if your system supports native code
# compilation.
.SUFFIXES: .ql .pl
.pl.ql: 
	-echo "prolog_flag(compiling,_,compactcode),fcompile($*)." | $(SICSTUS)

mimo_lc.pl: mimo.conv.lc mimo.ql
	echo "compile(lc),\
              set_flag(parser,lc),\
              set_flag(parser(lc),on),\
              load_grammar_file('mimo.conv.lc'),\
              dump_grammar('mimo_lc.pl')." | ./sh

mimo_hc.pl: mimo.conv
	echo "compile(hc),\
              set_flag(parser,hc),\
              set_flag(parser(hc),on),\
              load_grammar_file('mimo.conv'),\
              dump_grammar('mimo_hc.pl')." | ./sh

mimo_bu.pl: mimo.ql 
	echo "compile(bu),\
              set_flag(parser,bu),\
              set_flag(parser(bu),on),\
              load_grammar_file('mimo.g'),\
              dump_grammar('mimo_bu.pl')." | ./sh

mimo_inact_p.pl: mimo.ql
	echo "compile(bu),\
              compile(inact_p),\
              set_flag(parser,inact_p),\
              set_flag(parser(inact_p),on),\
              load_grammar_file('mimo.g'),\
              dump_grammar('mimo_inact_p.pl')." | ./sh

anlt_lc.pl: anlt.conv
	echo "compile(lc),\
              set_flag(parser,lc),\
              set_flag(parser(lc),on),\
              load_grammar_file('anlt.conv'),\
              dump_grammar('anlt_lc.pl')." | ./sh

anlt_hc.pl: anlt.conv anlt.head
	echo "compile(hc),\
              set_flag(parser,hc),\
              set_flag(parser(hc),on),\
              load_grammar_file('anlt.conv'),\
              dump_grammar('anlt_hc.pl')." | ./sh

anlt_hc_lc.pl: anlt.conv
	echo "compile(hc),\
              set_flag(parser,hc),\
              set_flag(parser(hc),on),\
              set_flag(head,left),\
              load_grammar_file('anlt.conv'),\
              dump_grammar('anlt_hc_lc.pl')." | ./sh

anlt_bu.pl: anlt.ql
	echo "compile(bu),\
              set_flag(parser,bu),\
              set_flag(parser(bu),on),\
              load_grammar_file('anlt.g'),\
              dump_grammar('anlt_bu.pl')." | ./sh

anlt_inact_p.pl: anlt.ql
	echo "compile(bu),\
              compile(inact_p),\
              set_flag(parser,inact_p),\
              set_flag(parser(inact_p),on),\
              load_grammar_file('anlt.g'),\
              dump_grammar('anlt_inact_p.pl')." | ./sh

mimo_test: 
	date >>mimo.results
	./shgm act2 	mimo_bu 	mimo.suite 	>>mimo.results
	./shgm hc_mixtus mimo_hc 	mimo.suite 	>>mimo.results
	./shgm lc_mixtus mimo_lc 	mimo.suite	>>mimo.results
	./shgm inact_p 	mimo_inact_p 	mimo.suite 	>>mimo.results
	./shgm bu 	mimo_bu 	mimo.suite	>>mimo.results
	date >>mimo.results

anlt_test: 
	date >>anlt.results
	echo "129 short" >>anlt.results
	./shg act2	anlt_bu		anlt.suite	>>anlt.results
	./shg bu	anlt_bu		anlt.suite	>>anlt.results
	./shg lc_mixtus	anlt_lc		anlt.suite	>>anlt.results
	./shg hc_mixtus	anlt_hc_lc	anlt.suite	>>anlt.results
	./shg hc_mixtus	anlt_hc		anlt.suite	>>anlt.results
	./shg inact_p	anlt_inact_p	anlt.suite	>>anlt.results
	echo "100 long" >>anlt.results
	./shg lcr	anlt_bu		anlt.long.suite	>>anlt.results
	./shg hcr	anlt_bu		anlt.long.suite	>>anlt.results
	./shg bu	anlt_bu		anlt.long.suite	>>anlt.results
	./shg lc_mixtus	anlt_lc		anlt.long.suite	>>anlt.results
	./shg hc_mixtus	anlt_hc_lc	anlt.long.suite	>>anlt.results
	./shg hc_mixtus	anlt_hc		anlt.long.suite	>>anlt.results
	./shg inact_p	anlt_inact_p	anlt.long.suite	>>anlt.results
#	./shg act2	anlt_bu		anlt.long.suite	>>anlt.results
	date >>anlt.results

# these are only used by me, GvN. 
QUERIES=[parse(o(_,_,_)),dump_grammar,count,count(_),clean,compile_grammar(_)]

hc_mixtus.pl: hc_out hc_head
	cp -f hc_head hc_mixtus.pl
	cat hc_out >> hc_mixtus.pl

hc_out: hc.pl
	echo "pconsult(hc), \
              set(print_settings),\
              pe($(QUERIES),hc_out)." | mixtus -f

lc_mixtus.pl: lc_out lc_head
	cp -f lc_head lc_mixtus.pl
	cat lc_out >> lc_mixtus.pl

lc_out: lc.pl
	echo "pconsult(lc), \
              set(print_settings),\
              pe($(QUERIES),lc_out)." | mixtus -f

OVISPREFIX=/usr/local/src/ovis/Sources3.3
PARSER_GENERATOR_CMD=$(SICSTUS) -l $(OVISPREFIX)/ParserGenerator/ovispg  -a

anlt.g: anlt.conv
	echo "load_grammar_file('anlt.conv'),\
              dump_grammar_g('anlt.g')." | ./sh

mimo.g: mimo.conv
	echo "load_grammar_file('mimo.conv'),\
              dump_grammar_g('mimo.g')." | ./sh

anlt.pl: anlt.g
	$(PARSER_GENERATOR_CMD) -q anlt

mimo.pl: mimo.g
	$(PARSER_GENERATOR_CMD) -q mimo

