CODEGEN=code-generator.py
DISJUNCTOR = -DDISJUNCTOR

yap:  gecode_yap.so gecode.yap

gecode_yap.o: gecode_yap.cc gecode-common.icc \
	gecode_yap_cc_impl_auto_generated.icc \
	gecode_yap_cc_init_auto_generated.icc \
	gecode_yap_cc_forward_auto_generated.icc \
	disjunctor.icc disjunctor.hh
	$(CXX) -Wall -ggdb -c -shared -fPIC $(DISJUNCTOR) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $<

gecode_yap.so: gecode_yap.o
	$(CXX) -shared $(LDFLAGS) -o $@ $< -lgecodeint -lgecodeset -lgecodesearch

gecode_yap_cc_init_auto_generated.icc: $(CODEGEN)
	python $< -t yap-cc-init > $@

gecode_yap_cc_impl_auto_generated.icc: $(CODEGEN)
	python $< -t yap-cc-impl > $@

gecode_yap_cc_forward_auto_generated.icc: $(CODEGEN)
	python $< -t yap-cc-forward > $@

gecode_yap_auto_generated.yap: $(CODEGEN)
	python $< -t yap-prolog > $@

gecode.yap: gecode_yap_hand_written.yap gecode_yap_auto_generated.yap
	cat $^ > $@

.PHONY: yap

clean:
	-rm -f *.o *.so *~ *_auto_generated* gecode.yap