Posted to tcl by hypnotoad at Thu Apr 07 23:21:25 GMT 2016view raw

  1. ###
  2. # This file contains instructions for how to build the Odielib library
  3. # It will produce the following files in whatever directory it was called from:
  4. #
  5. # * odielibc.mk - A Makefile snippet needed to compile the odielib sources
  6. # * odielibc.c - A C file which acts as the loader for odielibc
  7. # * logicset.c/h - A c
  8. # * (several .c and .h files) - C sources that are generated on the fly by automation
  9. ###
  10. # Ad a "just in case" version or practcl we ship locally
  11.  
  12. set CWD [pwd]
  13. set ::project(srcdir) [file dirname [file normalize [info script]]]
  14. set ::project(sandbox) [file dirname $::project(srcdir)]
  15. set ::project(download) [file join $::project(sandbox) download]
  16. set ::project(teapot) [file join $::project(sandbox) teapot]
  17. if {[file exists [file join $::project(sandbox) odielib modules practcl pratcl.tcl]]} {
  18. source [file join $::project(sandbox) odielib modules practcl pratcl.tcl]
  19. } else {
  20. source [file join $::project(srcdir) tclconfig practcl.tcl]
  21. }
  22. if {[file exists project.rc]} {
  23. source project.rc
  24. } else {
  25. ###
  26. # Go with baked in assumptions
  27. ###
  28.  
  29. set os [practcl::os]
  30. switch $os {
  31. windows {
  32. set ::project(EXEEXT) .exe
  33. }
  34. default {
  35. set ::project(EXEEXT) {}
  36. }
  37. }
  38. }
  39. set SRCPATH $::project(srcdir)
  40. set SANDBOX $::project(sandbox)
  41.  
  42. ::practcl::target deps {
  43. triggers {tcltk script-packages script-pkgindex}
  44. filename [file join $CWD deps]
  45. }
  46. ::practcl::target cstruct {
  47. }
  48. ::practcl::target autoconf {
  49. triggers {script-packages script-pkgindex cstruct}
  50. }
  51. ::practcl::target tcltk {
  52. depends deps
  53. triggers {script-packages script-pkgindex toadkit.rc}
  54. }
  55. ::practcl::target basekit {
  56. depends {deps tcltk toadkit.rc}
  57. triggers {}
  58. filename [file join $CWD tclkit_bare$::project(EXEEXT)]
  59. }
  60. ::practcl::target packages {
  61. depends {deps tcltk}
  62. }
  63. ::practcl::target script-packages {
  64. depends deps
  65. triggers {script-pkgindex}
  66. }
  67. ::practcl::target script-pkgindex {
  68. depends script-packages
  69. filename [file join $CWD build script-pkgIndex.tcl]
  70. }
  71. ::practcl::target toadkit.rc {
  72. filename [file join $CWD build toadkit.rc]
  73. depends tcltk
  74. }
  75. ::practcl::target distclean {}
  76.  
  77. switch [lindex $argv 0] {
  78. pre -
  79. deps {
  80. ::practcl::trigger deps tcltk script-packages script-pkgindex
  81. }
  82. os {
  83. puts "OS: [practcl::os]"
  84. parray ::project
  85. exit 0
  86. }
  87. wrap {
  88. ::practcl::depends basekit
  89. }
  90. all {
  91. # Auto detect missing bits
  92. foreach {item obj} $::make_objects {
  93. if {[$obj check]} {
  94. $obj trigger
  95. }
  96. }
  97. }
  98. package {
  99. ::practcl::trigger packages
  100. }
  101. default {
  102. ::practcl::trigger {*}$argv
  103. }
  104. }
  105.  
  106. parray make
  107.  
  108. set ::CWD [pwd]
  109. ::practcl::tclkit create BASEKIT {}
  110. BASEKIT source [file join $SRCPATH basekit.ini]
  111.  
  112. if {$make(distclean)} {
  113. # Clean all source code back to it's pristine state from fossil
  114. foreach item [BASEKIT link list package] {
  115. $item go
  116. set projdir [$item define get localsrcdir]
  117. if {$projdir ne {} && [file exists $projdir]} {
  118. fossil $projdir clean -force
  119. }
  120. }
  121. }
  122.  
  123. file mkdir [file join $CWD build]
  124.  
  125. if {$make(deps)} {
  126. file mkdir $::project(download)
  127. foreach item [BASEKIT link core.library] {
  128. $item unpack
  129. }
  130. foreach item [BASEKIT link package] {
  131. $item unpack
  132. }
  133. cd $::project(srcdir)
  134. catch {doexec autoconf -f}
  135. cd $CWD
  136. set fout [open $target(deps) w]
  137. puts $fout [clock format [clock seconds]]
  138. close $fout
  139. }
  140.  
  141. if {$make(tcltk)} {
  142. ###
  143. # Download our required packages
  144. ###
  145. set tcl_config_opts {}
  146. set tk_config_opts {}
  147. switch [::practcl::os] {
  148. windows {
  149.  
  150. }
  151. linux {
  152. lappend tk_config_opts --enable-xft=no --enable-xss=no
  153. }
  154. macosx {
  155. lappend tcl_config_opts --enable-corefoundation=yes --enable-framework=no
  156. lappend tk_config_opts --enable-aqua=yes
  157. }
  158. }
  159. lappend tcl_config_opts --with-tzdata --prefix [BASEKIT define get prefix]
  160. BASEKIT.TCLCORE define set config_opts $tcl_config_opts
  161. BASEKIT.TCLCORE go
  162. set _TclSrcDir [BASEKIT.TCLCORE define get localsrcdir]
  163. BASEKIT define set tclsrcdir $_TclSrcDir
  164. lappend tk_config_opts --with-tcl=$_TclSrcDir
  165. BASEKIT.TKCORE define set config_opts $tk_config_opts
  166. BASEKIT.TCLCORE compile
  167. BASEKIT.TKCORE compile
  168. }
  169.  
  170. if {$make(script-packages)} {
  171. foreach item [BASEKIT link list package] {
  172. if {[string is true -strict [$item define get preload]]} {
  173. $item install
  174. }
  175. }
  176. }
  177.  
  178. if {$make(script-pkgindex)} {
  179. set fout [open $target(script-pkgindex) w]
  180. puts $fout "### Built [clock format [clock seconds]]"
  181. foreach path [list \
  182. [file join $::project(sandbox) tcllib modules] \
  183. [file join $::project(sandbox) taolib modules] \
  184. [file join $::project(sandbox) odielib modules] \
  185. [file join $::project(sandbox) odielib] \
  186. [file join $::project(sandbox) sqlite] \
  187. [file join $::project(srcdir) modules] ] {
  188. puts $fout [list set dir $path]
  189. if {[file exists [file join $path pkgIndex.tcl]]} {
  190. puts $fout [list source [file join $path pkgIndex.tcl]]
  191. } else {
  192. puts $fout [::practcl::pkgindex_path $path]
  193. }
  194. }
  195. close $fout
  196. }
  197.  
  198. if {$make(cstruct)} {
  199. ::practcl::library create IRMLIB {}
  200. source $::target(script-pkgindex)
  201. IRMLIB source [file join $SRCPATH library.ini]
  202. ###
  203. # Bootstrap our pkgindex
  204. ###
  205. set shlib [IRMLIB shared_library]
  206. IRMLIB define set shared_library $shlib
  207. IRMLIB implement $CWD
  208. set fout [open pkgIndex.tcl w]
  209. puts $fout "
  210. #
  211. # Tcl package index file
  212. #
  213. "
  214. set VERSION [IRMLIB define get pkg_vers]
  215. puts $fout [IRMLIB package-ifneeded odielib odielibc odielibtk]
  216. puts $fout [string map [list @VERSION@ $VERSION] {package ifneeded irm::simdoc_seed @VERSION@ [list source [file join $dir irmdoc.tcl]]}]
  217. close $fout
  218. }
  219.  
  220.  
  221. if {$make(toadkit.rc)} {
  222. array set ::TCL [BASEKIT.TCLCORE config.sh]
  223. array set ::TK [BASEKIT.TKCORE config.sh]
  224. array set ::KIT [dict merge [array get ::TK] [array get ::TCL] [array get ::project]]
  225.  
  226.  
  227. ###
  228. # Add/synthesize bits
  229. ###
  230. set ::KIT(LIBS) {}
  231. set ::KIT(defs) $::TK(defs)
  232.  
  233. set fout [open $::target(toadkit.rc) w]
  234. puts $fout "array set ::TCL \{"
  235. foreach {field value} [lsort -stride 2 [array get ::TCL]] {
  236. puts $fout " [list $field $value]"
  237. }
  238. puts $fout "\}"
  239. puts $fout "array set ::TK \{"
  240. foreach {field value} [lsort -stride 2 [array get ::TK]] {
  241. puts $fout " [list $field $value]"
  242. }
  243. puts $fout "\}"
  244. puts $fout "array set ::TARGET \{"
  245. foreach {field value} [lsort -stride 2 [array get ::TARGET]] {
  246. puts $fout " [list $field $value]"
  247. }
  248. puts $fout "\}"
  249. puts $fout "array set ::KIT \{"
  250. foreach {field value} [lsort -stride 2 [array get ::KIT]] {
  251. puts $fout " [list $field $value]"
  252. }
  253. puts $fout "\}"
  254. close $fout
  255. }
  256.  
  257.  
  258. if {$make(basekit)} {
  259. if {![info exists ::TCL]} {
  260. source $::target(toadkit.rc)
  261. }
  262. BASEKIT generate-static-tclsh $target(basekit) [array get ::TCL] [array get ::TK] [array get ::KIT]
  263. }
  264.  
  265. if {[lindex $argv 0] eq "package"} {
  266. foreach item [lrange $argv 1 end] {
  267. PKG.$item install
  268. }
  269. } elseif {$make(packages)} {
  270. foreach item [BASEKIT link list package] {
  271. $item install
  272. }
  273. }
  274.  
  275. if {[lindex $argv 0] eq "wrap"} {
  276. BASEKIT wrap $CWD {*}[lrange $argv 1 end]
  277. }
  278.