@@ -22,11 +22,15 @@ set tcc_handle ::tcc4tcl::tcc_[incr count] if {$output == ""} { set type "memory" } else { - set type "dll" + if {$pkgName == ""} { + set type "exe" + } else { + set type "dll" + } } array set $handle [list tcc $tcc_handle code "" type $type filename $output package $pkgName] proc $handle {cmd args} [string map [list @@HANDLE@@ $handle] { @@ -82,10 +86,25 @@ foreach {procname cname} $state(procs) { tcc command $procname $cname } } + "exe" { + if {[info exists state(procs)] && [llength $state(procs)] > 0} { + append state(code) "int _initProcs(Tcl_Interp *interp) \{\n" + + foreach {procname cname} $state(procs) { + append state(code) " Tcl_CreateObjCommand(interp, \"$procname\", $cname, NULL, NULL);" + } + + append state(code) "\}" + } + + tcc compile $state(code) + + tcc output_file $state(filename) + } "dll" { append state(code) "int [string totitle $state(package)]_Init(Tcl_Interp *interp) \{\n" append state(code) "#ifdef USE_TCL_STUBS\n" append state(code) " if (Tcl_InitStubs(interp, \"8.4\" , 0) == 0L) \{\n" append state(code) " return TCL_ERROR;\n"