# $Id: Makefile,v 1.3 2001/09/28 12:11:43 ddr Exp $

include ../config/Makefile

INCLUDES=-I ../camlp4 -I ../boot
OCAMLCFLAGS=$(INCLUDES)
OBJS=q_phony.cmo pa_o.cmo pa_op.cmo pa_oop.cmo pa_ru.cmo pa_format.cmo pa_olabl.cmo pa_sml.cmo pa_lisp.cmo pa_extfun.cmo pa_fstream.cmo pr_r.cmo pr_rp.cmo pr_o.cmo pr_op.cmo pr_extend.cmo pr_extfun.cmo pr_null.cmo pr_depend.cmo
INTF=pa_o.cmi
CAMLP4OM=pa_o.cmo pa_op.cmo ../meta/pr_dump.cmo
CAMLP4OMX=pa_o.cmx pa_op.cmx ../meta/pr_dump.cmx
SHELL=/bin/sh
COUT=$(OBJS) camlp4o$(EXE)
COPT=camlp4o.opt

all: $(COUT) mkcamlp4.sh
opt: $(COPT)

camlp4o$(EXE): ../camlp4/camlp4$(EXE) $(CAMLP4OM)
	rm -f camlp4o$(EXE)
	cd ../camlp4; $(MAKE) CAMLP4=../etc/camlp4o$(EXE) CAMLP4M="-I ../etc $(CAMLP4OM)"

camlp4o.opt: $(CAMLP4OMX)
	rm -f camlp4o.opt
	cd ../camlp4; $(MAKE) optp4 CAMLP4OPT=../etc/camlp4o.opt CAMLP4M="-I ../etc $(CAMLP4OMX)"

mkcamlp4.sh: mkcamlp4.sh.tpl
	sed -e "s'LIBDIR'$(LIBDIR)'g" mkcamlp4.sh.tpl > mkcamlp4.sh

bootstrap_lisp:
	../boot/camlp4 ./pa_lispr.cmo -I ../boot pa_extend.cmo q_MLast.cmo ./pr_r.cmo ./pr_extend.cmo ./pr_rp.cmo -phony_quot pa_lisp.ml | sed -e 's/^;; \(.*\)$$/(* \1 *)/' -e 's|./pa_lispr.cmo|pa_r.cmo pa_rp.cmo|' -e 's/$$Id.*\$$/File generated by pretty print; do not edit!/' > tmp
	mv pa_lispr.ml pa_lispr.ml.old
	mv tmp pa_lispr.ml

compare_lisp:
	../boot/camlp4 ./pa_lispr.cmo -I ../boot pa_extend.cmo q_MLast.cmo ./pr_r.cmo ./pr_extend.cmo ./pr_rp.cmo -phony_quot pa_lisp.ml | sed -e 's/^;; \(.*\)$$/(* \1 *)/' -e 's|./pa_lispr.cmo|pa_r.cmo pa_rp.cmo|' -e 's/$$Id.*\$$/File generated by pretty print; do not edit!/' | diff pa_lispr.ml -

clean::
	rm -f *.cm* *.pp[io] *.o *.bak .*.bak *.out *.opt
	rm -f mkcamlp4.sh camlp4o$(EXE)

depend:
	cp .depend .depend.bak
	> .depend
	@for i in *.mli *.ml; do \
	  ../tools/apply.sh pr_depend.cmo -- $(INCLUDES) $$i >> .depend; \
	done

get_promote:

install:
	-$(MKDIR) $(LIBDIR) $(BINDIR)
	cp $(OBJS) $(LIBDIR)/.
	cp $(INTF) $(LIBDIR)/.
	cp lib.sml $(LIBDIR)/.
	cp camlp4o$(EXE) $(BINDIR)/.
	if test -f $(COPT); then cp $(COPT) $(BINDIR)/.; fi
	cp mkcamlp4.sh $(BINDIR)/mkcamlp4
	chmod a+x $(BINDIR)/mkcamlp4

pa_lisp.cmo: pa_lispr.cmo
pr_extend.cmo: pa_extfun.cmo
pr_o.cmo: pa_extfun.cmo
pr_op.cmo: pa_extfun.cmo
pr_r.cmo: pa_extfun.cmo
pr_rp.cmo: pa_extfun.cmo

include .depend
