package third_party.tcl

@Build(stage=1,script="$(EXTERNAL_MAKE) MOD_BUILD_DIR=$(abspath $(EXTERNAL_BUILD_DIR))/third_party/tcl/core download extract patch")
static module tclsh_export_scripts {
	@InitFS
	@AddPrefix("../../../build/extbld/third_party/tcl/core/tcl8.6.1/library")
	source "init.tcl",
		"history.tcl",
		"tclIndex"

	@InitFS
	@AddPrefix("../example")
	source "tcp_server.tcl",
		"udp_server.tcl",
		"fib.tcl",
		"run_embox_cmd.tcl"
}

@Build(stage=2, script="$(EXTERNAL_MAKE)")
static module core {
	@AddPrefix("^BUILD/extbld/^MOD_PATH/install")
	source "libtcl8.6.a", "libtclstub8.6.a"

	@NoRuntime depends embox.compat.libc.all

	depends tclsh_export_scripts
	@NoRuntime depends embox.compat.posix.file_system
}

@App
@AutoCmd(preserve_locals=true)
@Build(stage=2,script="true")
@BuildDepends(core)
@Cmd(name = "tclsh",
	help = "TCL shell",
	man = '''
		AUTHORS
			Alexander Kalmuk
	''')
module tclsh {
	@AddPrefix("^BUILD/extbld/third_party/tcl/core/install")
	source "tclsh.o"

	@NoRuntime depends third_party.tcl.core
	depends embox.compat.posix.stubs
}
