#include <psf_pre.imake>
#include <installmanpage.imake>

TBSIMLIB = $(DESTINATION)/lib/tbsim
ANIMLIB = $(DESTINATION)/lib/animation

TCLPACKAGES = Choose.tcl ComboBox.tcl Display.tcl History.tcl Pane.tcl \
	Process.tcl
TCLSRC = actionchooser.tcltmpl allgui.tcltmpl breakctrl.tcltmpl \
	display.tcltmpl function.tcltmpl process.tcltmpl tracectrl.tcltmpl
TCLTOOLS = $(TCLSRC:.tcltmpl=.tcl)

AllTarget(tbsim simkernel-adapter $(TCLTOOLS) tbsim.man)

simkernel-adapter: simkernel-adapter.tmpl
	sed -e s+@PROG_MKNOD@+$(PROG_MKNOD)+g \
		< simkernel-adapter.tmpl > simkernel-adapter

tbsim: tbsim.tmpl
	sed -e s+@PSF_LIB@+$(TBSIMLIB)+g \
	-e s+@PROG_PERL@+$(PROG_PERL)+g \
	-e s+@PROG_WISH@+$(PROG_WISH)+g \
		< tbsim.tmpl > tbsim
	chmod +x tbsim

.SUFFIXES: .tcltmpl .tcl

.tcltmpl.tcl:
	sed -e s+@TBSIMLIB@+$(TBSIMLIB)+g \
		-e s+@ANIMLIB@+$(ANIMLIB)+g \
		< $< > $@
	chmod +x $@


InstallProgram(tbsim,$(BINDIR))
MakeDirectories(install,$(TBSIMLIB))
InstallNonExecFile(tbsim_script.tb,$(TBSIMLIB))
InstallNonExecFile(simkernel-adapter,$(TBSIMLIB))
InstallMultiple($(TCLTOOLS),$(TBSIMLIB))
InstallMultiple($(TCLPACKAGES),$(TBSIMLIB))
install:: $(TCLPACKAGES)
	echo "pkg_mkIndex $(TBSIMLIB) $(TCLPACKAGES) ; exit" | $(PROG_WISH)

PSFInstallManPage(tbsim,1)

tbsim.man: tbsim.man.tmpl
	sed -e s+@DEFPSFBINDIR@+$(BINDIR)+g                               \
		< tbsim.man.tmpl > tbsim.man
clean::
	$(RM) tbsim simkernel-adapter $(TCLTOOLS) tbsim.man

ARCHIVE = Imakefile tbsim.tmpl simkernel-adapter.tmpl \
     tbsim_script.tb tbsim.man.tmpl $(TCLPACKAGES) $(TCLSRC)

#include <psf_post.imake>
