##
## cct - TMakeLib
##
## IPN - Ingenieurbuero fuer Praezisionsnumerik
##
## Dipl.-Ing. Andreas Otto
## Ulmenstrasse 3
## D-34289 Zierenberg
##
## Alle Rechte vorbehalten
##
##
## --------------------------------------------
##
package require StdLib
PkgProvide TMakeLib
package require Target
package require Config
if {![info exists COMPILER_TMakeLib]} {
lappend auto_path [ file dirname [info script] ]
}
##########################################################################
## Init
##########################################################################
set OT_HOME [ ::Env::COMPILER_HOME ]
set OT_UNAME [ ::Env::COMPILER_ARCH ]
set OT_TARGET [ ::Env::Get CCT_TARGET ]
set OT_CONFIG [ ::Env::Get CMP_CONFIG ]
set OT_DIR [ ::Env::Get CMP_DIR ]
set SRCDIR [ ::Env::Get CMP_SRCDIR ]
set VARDIR [ ::Env::Get CMP_VARDIR ]
if {![ file isdirectory $SRCDIR ]} { MkDir $SRCDIR }
if {![ file isdirectory $VARDIR ]} { MkDir $VARDIR }
::Config::Main project.cct -dir $OT_DIR -cache yes
##
## -----------------------------------
## directory setup
##
set TMPDIR [ file join $VARDIR Tmp ]
set CACHE [ file join $TMPDIR Cache ]
set EXEDIR [ file join $VARDIR Exe ]
set M_DIR [ file join $VARDIR Meta ]
set T_DIR [ file join $VARDIR ETcl ]
set C_DIR [ file join $VARDIR C ]
set VENVDIR [ file join $VARDIR Env $OT_TARGET ]
set OT_EXPORT [ file join $OT_DIR export $OT_CONFIG ]
set OT_PROJECT [ file join $OT_DIR project.cct ]
set BINDIR [ file join $OT_HOME bin ]
set SHELLDIR [ file join $OT_HOME lib ksh ]
set TPLDIR [ file join $OT_HOME template Env ]
foreach Dir { TMPDIR EXEDIR M_DIR T_DIR C_DIR VENVDIR OT_EXPORT } {
if {![ file isdirectory $Dir ]} { file mkdir [ set $Dir ] }
}
##########################################################################
## Help
##########################################################################
::bras::Make help {[true]} {
puts "
Usage: TMake <target>
Target Description
================= =========================================
C Back-End :
make c build the \"C\" library
make c.all full rebuild and install
make c.cmp recompile the c files
make c.is up-to-date install
make c.rm clean the distribution
make c.rb rebuild no install
or ...
make c_FileName file based interface
make c_FileName.rm
make c_FileName.rb
TCL Back-End :
make tcl build the \"Tcl\" library
make tcl.all full rebuild and install
make tcl.is up-to-date install
make tcl.rm clean the distribution
make tcl.rb rebuild no install
or ...
make t_FileName file based interface
make t_FileName.rm
make t_FileName.rb
META Back-End :
make m create the \"*.meta\" file's
make m.rm clean the \"*.meta\" file's
make m.rb rebuild the \"*.meta\" file's
or ...
make m_FileName file based interface
make m_FileName.rm
make m_FileName.rb
generic :
help get this message
clean clean your project
only BUILD will be left
"
}
##########################################################################
# RULES INIT
##########################################################################
set ONLY_C {}
set ALL_C {}
##########################################################################
# RULES
##########################################################################
proc _Clean {} {
package require FileLib
global VARDIR TMPDIR VENVDIR EXEDIR C_DIR T_DIR M_DIR \
OT_CONFIG C_INSTDIR OT_LIB TCL_INSTDIR OT_PKG \
SRCDIR
set REPDIR [ file join $VARDIR REPOSITORY ]
set Len [ expr { [ string length $SRCDIR ] + 1 } ]
foreach D [list $SRCDIR $VARDIR ] {
foreach F [ glob -nocomplain -directory $D -types f * ] {
set S [ string range $F $Len end ]
puts "removing \"[ file join .project.cct $OT_CONFIG $S ]\" ..."
file delete -force -- $F
}
}
foreach D [list $TMPDIR $C_DIR $VENVDIR $EXEDIR $T_DIR $M_DIR $REPDIR] {
set S [ string range $D $Len end ]
if {![ file exists $D ]} continue
puts "removing \"[ file join .project.cct $OT_CONFIG $S ]\" ..."
::FileLib::RemoveDir $D
#file delete -force -- $D
}
DelIfExist [ file join $C_INSTDIR $OT_LIB ]
DelIfExist [ file join $TCL_INSTDIR $OT_PKG.tcl ]
DelIfExist [ file dirname $VENVDIR ]
}
::bras::Make clean {[true]} _Clean
##########################################################################
# Project CCT
##########################################################################
set OT_CSHELL tcl
set C_INSTDIR [ ::Config::Get [list PACKAGE:$OT_CONFIG C_INSTDIR] ]
set TCL_INSTDIR [ ::Config::Get [list PACKAGE:$OT_CONFIG TCL_INSTDIR] ]
set OT_DEBUG [ ::Config::Get [list PACKAGE:$OT_CONFIG DEBUGMODE] ]
set OT_STRIP [ expr { $OT_DEBUG ? 0 : [ ::Config::Get [list PACKAGE:$OT_CONFIG STRIP] ] } ]
set OT_BASE [ file join $OT_HOME exe $OT_UNAME ]
##########################################################################
# REPOSITORY setup
##########################################################################
set REP_DIR [ ::Config::Get REPOSITORY ]
proc OtREPOSITORY {} {
global REP_DIR OT_HOME
if {[file exists [file join $REP_DIR tcl_8_3]]} return
set TMP [ file join $OT_HOME template Rep ]
if {![ file exists $TMP ]} return
puts "init REPOSITORY"
foreach D [ glob -nocomplain -types d -directory $TMP * ] {
set T [file join $REP_DIR [ file tail $D ]]
if {![file exists $T]} continue
file delete -force $T
}
package require FileLib
::FileLib::CopyDirOrFileNoLink $TMP $REP_DIR
}
OtREPOSITORY
##########################################################################
# CONFIGURE setup
##########################################################################
set OT_TCL_LIB [ file join $OT_BASE lib ]
set OT_TCL_INCLUDE [ file join $OT_BASE include ]
if {?$} $OT_CONFIG DUMMY OT_PKG OT_MAJOR OT_MINOR ]} {
set OT_PKG $OT_CONFIG
set OT_MAJOR [ ::Config::Get [list PACKAGE:$OT_CONFIG MAJOR] ]
set OT_MINOR [ ::Config::Get [list PACKAGE:$OT_CONFIG MINOR] ]
}
set OT_REL ${OT_MAJOR}.${OT_MINOR}
set OT_LIB [ ::Target::Lib lib${OT_PKG} ${OT_REL} $OT_DEBUG ]
set SOURCEDIR [ file join $OT_HOME template Env ]
set OT_PKG2 [ string totitle ${OT_PKG} ]
set OT_PKG3 "COMPILER_[ string toupper ${OT_PKG} ]"
set OT_PKG4 [ string tolower ${OT_PKG} ]
##########################################################################
# setup the input files
##########################################################################
OtBuild
proc OtSetup {} {
global OT_CONFIG ALL_C
set TCL_FILEs [ ::Config::Query [list PACKAGE:$OT_CONFIG TCL_FILE] ]
set C_FILEs [ ::Config::Query [list PACKAGE:$OT_CONFIG C_FILE ] ]
set ALL_FILEs [ ::Config::Query [list PACKAGE:$OT_CONFIG FILE] ]
## check for SAFE
if {[::Env::Get CCT_TARGET] != "mac91ppc"} {
foreach f $TCL_FILEs {
set S [ ::Config::Get [list PACKAGE:$OT_CONFIG TCL_FILE:$f TCL2META SAFE] ]
set O [ ::Config::Get [list PACKAGE:$OT_CONFIG TCL_FILE:$f META2C OPTIMIZATION] ]
if {$S && $O != 0} {
::StdLib::ErrorN {CONFIG ERROR} [ list \
"can not resolve switch dependency" \
" PACKAGE:$OT_CONFIG TCL_FILE:$f" \
" PACKAGE->TCL_FILE->TCL2META->SAFE : yes" \
" PACKAGE->TCL_FILE->META2C->OPTIMIZATION : 0" \
]
}
}
}
foreach I $ALL_FILEs {
set NI [ file tail $I ]
set RI [ file rootname $NI ]
if {[ string equal -length 9 $NI COMPILER_ ]} {
::StdLib::ErrorN {TMAKE ERROR} [ list \
"filename \"$NI\" not allowed" \
"the prefix \"COMPILER\" is reseved for internal use" \
"please change your filename" \
]
}
if {[lsearch -exact $ALL_C $RI] != -1} {
::StdLib::ErrorN {FILE ERROR} [list \
"multiple use of file rootname \"$RI\"" \
]
}
switch -exact [ file extension $I ] {
.c {
if {[ lsearch -exact $C_FILEs $I ] == -1} {
::StdLib::ErrorN {C_FILE ERROR} [ list \
"got file \"$I\" which was not defined as \"C_FILE\"" \
"please update \"project.cct\"" \
]
}
OtEnvC $I [ ::Config::Get [list PACKAGE:$OT_CONFIG C_FILE:$I HEADER] ]
}
default {
if {[ lsearch -exact $TCL_FILEs $I ] == -1} {
::StdLib::ErrorN {TCL_FILE ERROR} [ list \
"got file \"$I\" which was not defined as \"TCL_FILE\"" \
"please update \"project.cct\"" \
]
}
OtEnvTcl $I [ ::Config::Get [list PACKAGE:$OT_CONFIG TCL_FILE:$I HEADER] ]
}
}
}
}
OtSetup
##########################################################################
# Special TAGS
##########################################################################
OtEXE_ETCL
OtEXE_C
OtEXE_C_BE
OtEXE_TCL_BE
OtEXE_META_BE
##########################################################################
# Special TAGS
##########################################################################
if {![file exists [ file join $VARDIR Tmp BFLAG ]]} { SetBuildString }