include ../support/Makefile.common

all: tk.ml labltk.ml .depend

_tkgen.ml: ../Widgets.src ../compiler/tkcompiler$(EXE)
	cd ..; $(CAMLRUNGEN) compiler/tkcompiler$(EXE) -outdir labltk

# dependencies are broken: wouldn't work with gmake 3.77

#tk.ml labltk.ml .depend: generate

tk.ml labltk.ml .depend: _tkgen.ml ../builtin/report.ml ../compiler/pp$(EXE) #../builtin/builtin_*.ml
	(echo 'open StdLabels'; \
	 echo 'open Widget'; \
	 echo 'open Protocol'; \
	 echo 'open Support'; \
	 echo 'open Textvariable'; \
	 cat ../builtin/report.ml; \
	 cat ../builtin/builtin_*.ml; \
	 cat _tkgen.ml; \
	 echo ; \
	 echo ; \
	 echo 'module Tkintf = struct'; \
	 cat ../builtin/builtini_*.ml; \
	 cat _tkigen.ml; \
	 echo 'end (* module Tkintf *)'; \
	 echo ; \
	 echo ; \
	 echo 'open Tkintf' ;\
	 echo ; \
	 echo ; \
	 cat ../builtin/builtinf_*.ml; \
	 cat _tkfgen.ml; \
	 echo ; \
	) > _tk.ml
	$(CAMLRUN) ../compiler/pp < _tk.ml > tk.ml
	rm -f _tk.ml
	$(CAMLDEP) -slash -I ../support [a-z]*.mli [a-z]*.ml > .depend

../compiler/pp$(EXE):
	cd ../compiler; $(MAKE) pp$(EXE)

../compiler/tkcompiler$(EXE):
	cd ../compiler; $(MAKE) tkcompiler$(EXE)

# All .{ml,mli} files are generated in this directory
clean:
	rm -f *.cm* *.ml *.mli *.$(O) *.$(A) .depend

#	rm -f modules

.PHONY: all generate clean
