Menu

[r3]: / cmp / TMakeLib / TMakeLib.tcl  Maximize  Restore  History

Download this file

316 lines (248 with data), 10.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
##
## 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 {![ regexp {^(\w+)(\d+)[.](\d+)?$} $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 }
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.