Posted to tcl by hypnotoad at Thu Apr 07 23:21:25 GMT 2016view raw
- ###
- # This file contains instructions for how to build the Odielib library
- # It will produce the following files in whatever directory it was called from:
- #
- # * odielibc.mk - A Makefile snippet needed to compile the odielib sources
- # * odielibc.c - A C file which acts as the loader for odielibc
- # * logicset.c/h - A c
- # * (several .c and .h files) - C sources that are generated on the fly by automation
- ###
- # Ad a "just in case" version or practcl we ship locally
- set CWD [pwd]
- set ::project(srcdir) [file dirname [file normalize [info script]]]
- set ::project(sandbox) [file dirname $::project(srcdir)]
- set ::project(download) [file join $::project(sandbox) download]
- set ::project(teapot) [file join $::project(sandbox) teapot]
- if {[file exists [file join $::project(sandbox) odielib modules practcl pratcl.tcl]]} {
- source [file join $::project(sandbox) odielib modules practcl pratcl.tcl]
- } else {
- source [file join $::project(srcdir) tclconfig practcl.tcl]
- }
- if {[file exists project.rc]} {
- source project.rc
- } else {
- ###
- # Go with baked in assumptions
- ###
- set os [practcl::os]
- switch $os {
- windows {
- set ::project(EXEEXT) .exe
- }
- default {
- set ::project(EXEEXT) {}
- }
- }
- }
- set SRCPATH $::project(srcdir)
- set SANDBOX $::project(sandbox)
- ::practcl::target deps {
- triggers {tcltk script-packages script-pkgindex}
- filename [file join $CWD deps]
- }
- ::practcl::target cstruct {
- }
- ::practcl::target autoconf {
- triggers {script-packages script-pkgindex cstruct}
- }
- ::practcl::target tcltk {
- depends deps
- triggers {script-packages script-pkgindex toadkit.rc}
- }
- ::practcl::target basekit {
- depends {deps tcltk toadkit.rc}
- triggers {}
- filename [file join $CWD tclkit_bare$::project(EXEEXT)]
- }
- ::practcl::target packages {
- depends {deps tcltk}
- }
- ::practcl::target script-packages {
- depends deps
- triggers {script-pkgindex}
- }
- ::practcl::target script-pkgindex {
- depends script-packages
- filename [file join $CWD build script-pkgIndex.tcl]
- }
- ::practcl::target toadkit.rc {
- filename [file join $CWD build toadkit.rc]
- depends tcltk
- }
- ::practcl::target distclean {}
- switch [lindex $argv 0] {
- pre -
- deps {
- ::practcl::trigger deps tcltk script-packages script-pkgindex
- }
- os {
- puts "OS: [practcl::os]"
- parray ::project
- exit 0
- }
- wrap {
- ::practcl::depends basekit
- }
- all {
- # Auto detect missing bits
- foreach {item obj} $::make_objects {
- if {[$obj check]} {
- $obj trigger
- }
- }
- }
- package {
- ::practcl::trigger packages
- }
- default {
- ::practcl::trigger {*}$argv
- }
- }
- parray make
- set ::CWD [pwd]
- ::practcl::tclkit create BASEKIT {}
- BASEKIT source [file join $SRCPATH basekit.ini]
- if {$make(distclean)} {
- # Clean all source code back to it's pristine state from fossil
- foreach item [BASEKIT link list package] {
- $item go
- set projdir [$item define get localsrcdir]
- if {$projdir ne {} && [file exists $projdir]} {
- fossil $projdir clean -force
- }
- }
- }
- file mkdir [file join $CWD build]
- if {$make(deps)} {
- file mkdir $::project(download)
- foreach item [BASEKIT link core.library] {
- $item unpack
- }
- foreach item [BASEKIT link package] {
- $item unpack
- }
- cd $::project(srcdir)
- catch {doexec autoconf -f}
- cd $CWD
- set fout [open $target(deps) w]
- puts $fout [clock format [clock seconds]]
- close $fout
- }
- if {$make(tcltk)} {
- ###
- # Download our required packages
- ###
- set tcl_config_opts {}
- set tk_config_opts {}
- switch [::practcl::os] {
- windows {
- }
- linux {
- lappend tk_config_opts --enable-xft=no --enable-xss=no
- }
- macosx {
- lappend tcl_config_opts --enable-corefoundation=yes --enable-framework=no
- lappend tk_config_opts --enable-aqua=yes
- }
- }
- lappend tcl_config_opts --with-tzdata --prefix [BASEKIT define get prefix]
- BASEKIT.TCLCORE define set config_opts $tcl_config_opts
- BASEKIT.TCLCORE go
- set _TclSrcDir [BASEKIT.TCLCORE define get localsrcdir]
- BASEKIT define set tclsrcdir $_TclSrcDir
- lappend tk_config_opts --with-tcl=$_TclSrcDir
- BASEKIT.TKCORE define set config_opts $tk_config_opts
- BASEKIT.TCLCORE compile
- BASEKIT.TKCORE compile
- }
- if {$make(script-packages)} {
- foreach item [BASEKIT link list package] {
- if {[string is true -strict [$item define get preload]]} {
- $item install
- }
- }
- }
- if {$make(script-pkgindex)} {
- set fout [open $target(script-pkgindex) w]
- puts $fout "### Built [clock format [clock seconds]]"
- foreach path [list \
- [file join $::project(sandbox) tcllib modules] \
- [file join $::project(sandbox) taolib modules] \
- [file join $::project(sandbox) odielib modules] \
- [file join $::project(sandbox) odielib] \
- [file join $::project(sandbox) sqlite] \
- [file join $::project(srcdir) modules] ] {
- puts $fout [list set dir $path]
- if {[file exists [file join $path pkgIndex.tcl]]} {
- puts $fout [list source [file join $path pkgIndex.tcl]]
- } else {
- puts $fout [::practcl::pkgindex_path $path]
- }
- }
- close $fout
- }
- if {$make(cstruct)} {
- ::practcl::library create IRMLIB {}
- source $::target(script-pkgindex)
- IRMLIB source [file join $SRCPATH library.ini]
- ###
- # Bootstrap our pkgindex
- ###
- set shlib [IRMLIB shared_library]
- IRMLIB define set shared_library $shlib
- IRMLIB implement $CWD
- set fout [open pkgIndex.tcl w]
- puts $fout "
- #
- # Tcl package index file
- #
- "
- set VERSION [IRMLIB define get pkg_vers]
- puts $fout [IRMLIB package-ifneeded odielib odielibc odielibtk]
- puts $fout [string map [list @VERSION@ $VERSION] {package ifneeded irm::simdoc_seed @VERSION@ [list source [file join $dir irmdoc.tcl]]}]
- close $fout
- }
- if {$make(toadkit.rc)} {
- array set ::TCL [BASEKIT.TCLCORE config.sh]
- array set ::TK [BASEKIT.TKCORE config.sh]
- array set ::KIT [dict merge [array get ::TK] [array get ::TCL] [array get ::project]]
- ###
- # Add/synthesize bits
- ###
- set ::KIT(LIBS) {}
- set ::KIT(defs) $::TK(defs)
- set fout [open $::target(toadkit.rc) w]
- puts $fout "array set ::TCL \{"
- foreach {field value} [lsort -stride 2 [array get ::TCL]] {
- puts $fout " [list $field $value]"
- }
- puts $fout "\}"
- puts $fout "array set ::TK \{"
- foreach {field value} [lsort -stride 2 [array get ::TK]] {
- puts $fout " [list $field $value]"
- }
- puts $fout "\}"
- puts $fout "array set ::TARGET \{"
- foreach {field value} [lsort -stride 2 [array get ::TARGET]] {
- puts $fout " [list $field $value]"
- }
- puts $fout "\}"
- puts $fout "array set ::KIT \{"
- foreach {field value} [lsort -stride 2 [array get ::KIT]] {
- puts $fout " [list $field $value]"
- }
- puts $fout "\}"
- close $fout
- }
- if {$make(basekit)} {
- if {![info exists ::TCL]} {
- source $::target(toadkit.rc)
- }
- BASEKIT generate-static-tclsh $target(basekit) [array get ::TCL] [array get ::TK] [array get ::KIT]
- }
- if {[lindex $argv 0] eq "package"} {
- foreach item [lrange $argv 1 end] {
- PKG.$item install
- }
- } elseif {$make(packages)} {
- foreach item [BASEKIT link list package] {
- $item install
- }
- }
- if {[lindex $argv 0] eq "wrap"} {
- BASEKIT wrap $CWD {*}[lrange $argv 1 end]
- }