GPLC      = @GPLC@
EXEEXT    = @EXEEXT@

GPLCFLAGS = --fast-math
OBJS      = pl2wam.o read_file.o bip_list.o syn_sugar.o internal.o \
            code_gen.o reg_alloc.o inst_codif.o first_arg.o \
            indexing.o wam_emit.o
PLS       = pl2wam.pl read_file.pl bip_list.pl syn_sugar.pl internal.pl \
            code_gen.pl reg_alloc.pl inst_codif.pl first_arg.pl \
            indexing.pl wam_emit.pl


.SUFFIXES:
.SUFFIXES: .o .wam .pl $(SUFFIXES)


.pl.wam:
	$(GPLC) -W $(GPLCFLAGS) $*.pl
.wam.o:
	$(GPLC) -c $*.wam


pl2wam$(EXEEXT): $(OBJS)
	-cp pl2wam$(EXEEXT) pl2wam0$(EXEEXT)
	$(GPLC) -o pl2wam$(EXEEXT) --no-fd-lib --min-bips $(OBJS)


clean:
	-mv pl2wam$(EXEEXT) pl2wam0$(EXEEXT)
	rm -f *.o


clean-wam:
	rm -f *.wam


clean-full: clean-wam clean


distclean: clean
	rm -f pl2wam$(EXEEXT) pl2wam0$(EXEEXT) make_bip_list$(EXEEXT)




pl2wam.wam:     pl2wam.pl
read_file.wam:  read_file.pl
bip_list.wam:   bip_list.pl
syn_sugar.wam:  syn_sugar.pl
internal.wam:   internal.pl
code_gen.wam:   code_gen.pl
reg_alloc.wam:  reg_alloc.pl
inst_codif.wam: inst_codif.pl
first_arg.wam:  first_arg.pl
indexing.wam:   indexing.pl
wam_emit.wam:   wam_emit.pl




make_bip_list$(EXEEXT): make_bip_list.pl ../Bips??/[a-z]??*.pl
	$(GPLC) -o make_bip_list$(EXEEXT) make_bip_list.pl --no-top-level
	./make_bip_list$(EXEEXT) >bip_list.pl
	make


swi_pl2wam: swilib.pl $(PLS)
	pl -o swi_pl2wam_main -c swilib.pl $(PLS) 
	echo "#!/bin/sh" >swi_pl2wam
	echo 'swi_pl2wam_main -g go -t halt -- $$*' >>swi_pl2wam
	chmod a+x swi_pl2wam
