#
# default base directory for YAP installation
#
ROOTDIR = /usr/pkg
#
# where the binary should be
#
BINDIR = $(ROOTDIR)/bin
#
# where YAP should look for libraries
#
LIBDIR=${exec_prefix}/lib
YAPLIBDIR=${exec_prefix}/lib/Yap
#
# where YAP should look for architecture-independent Prolog libraries
#
SHAREDIR=$(ROOTDIR)/share/Yap
#
# where YAP should store documentation
#
DOCDIR=$(ROOTDIR)/share/doc/Yap
EXDIR=$(DOCDIR)/packages/examples/CLPBN
#
#
# You shouldn't need to change what follows.
#
INSTALL=/usr/bin/install -c -o pbulk -g users
INSTALL_DATA=/usr/bin/install -c -o pbulk -g users -m 644
INSTALL_PROGRAM=/usr/bin/install -c -s -o pbulk -g users -m 755
srcdir=.
PDFLATEX=pdflatex

PFL_MANUAL = $(srcdir)/pfl

CLPBN_SRCDIR = $(srcdir)/clpbn

CLPBN_LEARNING_SRCDIR = $(srcdir)/learning

CLPBN_EXDIR = $(srcdir)/examples

CLPBN_TOP= \
	$(srcdir)/clpbn.yap \
	$(srcdir)/pfl.yap

CLPBN_PROGRAMS= \
	$(CLPBN_SRCDIR)/aggregates.yap \
	$(CLPBN_SRCDIR)/bdd.yap \
	$(CLPBN_SRCDIR)/bnt.yap \
	$(CLPBN_SRCDIR)/connected.yap \
	$(CLPBN_SRCDIR)/discrete_utils.yap \
	$(CLPBN_SRCDIR)/display.yap \
	$(CLPBN_SRCDIR)/dists.yap \
	$(CLPBN_SRCDIR)/evidence.yap \
	$(CLPBN_SRCDIR)/gibbs.yap \
	$(CLPBN_SRCDIR)/graphs.yap \
	$(CLPBN_SRCDIR)/graphviz.yap \
	$(CLPBN_SRCDIR)/ground_factors.yap \
	$(CLPBN_SRCDIR)/hmm.yap \
	$(CLPBN_SRCDIR)/horus.yap \
	$(CLPBN_SRCDIR)/horus_ground.yap \
	$(CLPBN_SRCDIR)/horus_lifted.yap \
	$(CLPBN_SRCDIR)/jt.yap \
	$(CLPBN_SRCDIR)/matrix_cpt_utils.yap \
	$(CLPBN_SRCDIR)/numbers.yap \
	$(CLPBN_SRCDIR)/pgrammar.yap \
	$(CLPBN_SRCDIR)/table.yap \
	$(CLPBN_SRCDIR)/topsort.yap \
	$(CLPBN_SRCDIR)/utils.yap \
	$(CLPBN_SRCDIR)/ve.yap \
	$(CLPBN_SRCDIR)/viterbi.yap \
	$(CLPBN_SRCDIR)/vmap.yap \
	$(CLPBN_SRCDIR)/xbif.yap

CLPBN_LEARNING_PROGRAMS= \
	$(CLPBN_LEARNING_SRCDIR)/aleph_params.yap \
	$(CLPBN_LEARNING_SRCDIR)/bnt_parms.yap \
	$(CLPBN_LEARNING_SRCDIR)/em.yap \
	$(CLPBN_LEARNING_SRCDIR)/learn_utils.yap \
	$(CLPBN_LEARNING_SRCDIR)/mle.yap

CLPBN_EXAMPLES= \
	$(CLPBN_EXDIR)/burglary-alarm.fg \
	$(CLPBN_EXDIR)/burglary-alarm.pfl \
	$(CLPBN_EXDIR)/burglary-alarm.uai \
	$(CLPBN_EXDIR)/cg.yap \
	$(CLPBN_EXDIR)/city.pfl \
	$(CLPBN_EXDIR)/comp_workshops.pfl \
	$(CLPBN_EXDIR)/social_network1.pfl \
	$(CLPBN_EXDIR)/social_network2.pfl \
	$(CLPBN_EXDIR)/sprinkler.pfl \
	$(CLPBN_EXDIR)/workshop_attrs.pfl

CLPBN_SCHOOL_EXAMPLES= \
	$(CLPBN_EXDIR)/School/README \
	$(CLPBN_EXDIR)/School/evidence_128.yap \
	$(CLPBN_EXDIR)/School/parschema.pfl \
	$(CLPBN_EXDIR)/School/school_128.yap \
	$(CLPBN_EXDIR)/School/school_32.yap \
	$(CLPBN_EXDIR)/School/school_64.yap \
	$(CLPBN_EXDIR)/School/tables.yap

CLPBN_HMMER_EXAMPLES= \
	$(CLPBN_EXDIR)/HMMer/Artemia.fa \
	$(CLPBN_EXDIR)/HMMer/fasta.yap \
	$(CLPBN_EXDIR)/HMMer/globin.hmm \
	$(CLPBN_EXDIR)/HMMer/globin.yap \
	$(CLPBN_EXDIR)/HMMer/plan7.yap \
	$(CLPBN_EXDIR)/HMMer/scan.yap \
	$(CLPBN_EXDIR)/HMMer/score.yap

CLPBN_LEARNING_EXAMPLES= \
	$(CLPBN_EXDIR)/learning/debug_school.yap \
	$(CLPBN_EXDIR)/learning/prof_params.pfl \
	$(CLPBN_EXDIR)/learning/school_params.yap \
	$(CLPBN_EXDIR)/learning/sprinkler_params.yap \
	$(CLPBN_EXDIR)/learning/train.yap


install: $(CLBN_TOP) $(CLBN_PROGRAMS) $(CLPBN_LEARNING_PROGRAMS) $(CLPBN_SCHOOL_EXAMPLES) $(CLPBN_HMMER_EXAMPLES) $(CLPBN_LEARNING_EXAMPLES)
	mkdir -p $(DESTDIR)$(SHAREDIR)/clpbn
	mkdir -p $(DESTDIR)$(SHAREDIR)/clpbn/learning
	mkdir -p $(DESTDIR)$(EXDIR)
	mkdir -p $(DESTDIR)$(EXDIR)/School
	mkdir -p $(DESTDIR)$(EXDIR)/HMMer
	mkdir -p $(DESTDIR)$(EXDIR)/learning
	for h in $(CLPBN_TOP); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR); done
	for h in $(CLPBN_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpbn; done
	for h in $(CLPBN_LEARNING_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpbn/learning; done
	for h in $(CLPBN_EXAMPLES); do $(INSTALL_DATA) $$h $(DESTDIR)$(EXDIR); done
	for h in $(CLPBN_SCHOOL_EXAMPLES); do $(INSTALL_DATA) $$h $(DESTDIR)$(EXDIR)/School; done
	for h in $(CLPBN_HMMER_EXAMPLES); do $(INSTALL_DATA) $$h $(DESTDIR)$(EXDIR)/HMMer; done
	for h in $(CLPBN_LEARNING_EXAMPLES); do $(INSTALL_DATA) $$h $(DESTDIR)$(EXDIR)/learning; done


docs: $(MANUAL)
	$(PDFLATEX) $(PFL_MANUAL)
	$(PDFLATEX) $(PFL_MANUAL)
	rm -f pfl.aux pfl.bbl pfl.blg pfl.log pfl.out


install_docs: docs
	$(INSTALL_DATA) pfl.pdf $(DESTDIR)$(EXDIR)

