Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | # This tcl script generates the makefile. |
| 2 | # |
||
| 3 | # This script begins life as "makemake.tcl.in". A "configure" |
||
| 4 | # shell script will read "makemake.tcl.in" and generate |
||
| 5 | # "makemake.tcl". The makemake.tcl script then runs to |
||
| 6 | # produce the makefile. |
||
| 7 | # |
||
| 8 | # This script needs to know the following information about |
||
| 9 | # the build environment: |
||
| 10 | # |
||
| 11 | # * The location of the source code. |
||
| 12 | # |
||
| 13 | # This is the name of the directory that contains |
||
| 14 | # makemake.tcl.in and configure. The build products |
||
| 15 | # (the *.o and *.exe files) and makemake.tcl will |
||
| 16 | # be written into the working directory. The working |
||
| 17 | # directory can and should be distinct and separate from |
||
| 18 | # the source directory. The source directory can be |
||
| 19 | # on a read-only filesystem. The name of the source |
||
| 20 | # directory is stored in the $TOP variable. |
||
| 21 | # |
||
| 22 | # * How to compile and link C code into command-line programs to |
||
| 23 | # run on the build platform. |
||
| 24 | # |
||
| 25 | # The compiler command name is stored in $BCC. If any |
||
| 26 | # libraries are required, they are stored in $BLIBS |
||
| 27 | # |
||
| 28 | # * The suffix to give to command-line programs that run |
||
| 29 | # on the build platform. |
||
| 30 | # |
||
| 31 | # This is stored in $BEXE |
||
| 32 | # |
||
| 33 | # * How to compile C modules into *.o files for the target |
||
| 34 | # platform. |
||
| 35 | # |
||
| 36 | # This is the $TCC variable. |
||
| 37 | # |
||
| 38 | # * The suffix to give to programs that run on the target |
||
| 39 | # platform. |
||
| 40 | # |
||
| 41 | # This is the $TEXE variable. |
||
| 42 | # |
||
| 43 | # * How to link *.o files produced by $TCC command into |
||
| 44 | # an executable that runs on the target platform. |
||
| 45 | # |
||
| 46 | # The $TLINK command does the linking. It requires |
||
| 47 | # arguments stored in $TLIBS |
||
| 48 | # |
||
| 49 | # * The names of directories containing Tcl script libraries |
||
| 50 | # that are compatible with the Tcl C libraries on the |
||
| 51 | # target platform. |
||
| 52 | # |
||
| 53 | # These are the $TCLSCRIPTDIR and $TKSCRIPTDIR variables. |
||
| 54 | # |
||
| 55 | # * The name of a tclsh that works on the build platform. |
||
| 56 | # |
||
| 57 | # This is the $BTCLSH variable. |
||
| 58 | # |
||
| 59 | # All of the above information is discovered by the configure |
||
| 60 | # shell script. The configure shell script then inserts the |
||
| 61 | # information here: |
||
| 62 | # |
||
| 63 | set TOP [list @srcdir@] |
||
| 64 | set BCC [list @BUILD_CC@ @BUILD_CFLAGS@] |
||
| 65 | set BLIBS [list @BUILD_LIBS@] |
||
| 66 | set BEXE [list @BUILD_EXEEXT@] |
||
| 67 | set BTCLSH [list @BUILD_TCLSH@] |
||
| 68 | set TCC [list @TARGET_CC@ @TARGET_CFLAGS@ -I. @TARGET_TK_INC@ \ |
||
| 69 | @TARGET_X_INC@ @TARGET_TCL_INC@ @TARGET_BLT_INC@] |
||
| 70 | set TEXE [list @TARGET_EXEEXT@] |
||
| 71 | set TLINK [list @TARGET_LINK@ @TARGET_LFLAGS@] |
||
| 72 | set TLIBS [list @TARGET_BLT_LIBS@ @TARGET_TK_LIBS@ @TARGET_X_LIBS@ \ |
||
| 73 | @TARGET_TCL_LIBS@ @TARGET_LIBS@] |
||
| 74 | set TCLSCRIPTDIR [list @TARGET_TCL_SCRIPT_DIR@] |
||
| 75 | set TKSCRIPTDIR [list @TARGET_TK_SCRIPT_DIR@] |
||
| 76 | # |
||
| 77 | # The "configure" script makes no changes beyond this point. |
||
| 78 | ############################################################################# |
||
| 79 | |||
| 80 | # To customize the makefile, begin by adding or removing |
||
| 81 | # files from the following four lists. |
||
| 82 | |||
| 83 | # Put the basename of each C source code modules |
||
| 84 | # here. Omit the ".c" suffix. |
||
| 85 | # |
||
| 86 | set srcc { |
||
| 87 | src/cell |
||
| 88 | src/psdgui |
||
| 89 | } |
||
| 90 | |||
| 91 | # Put the names of all TCL source files here. Include the ".tcl" |
||
| 92 | # suffix. |
||
| 93 | # |
||
| 94 | set srctcl { |
||
| 95 | src/balloon.tcl |
||
| 96 | src/build.tcl |
||
| 97 | src/calibrate.tcl |
||
| 98 | src/cell.tcl |
||
| 99 | src/console.tcl |
||
| 100 | src/enable.tcl |
||
| 101 | src/labelframe.tcl |
||
| 102 | src/notebook.tcl |
||
| 103 | src/psdgui.tcl |
||
| 104 | } |
||
| 105 | |||
| 106 | # Put here the basenames of all C code modules that are |
||
| 107 | # generated by helper programs or/and automated scripts. These |
||
| 108 | # files are C code but they are not source code. The output |
||
| 109 | # of mktclapp goes on this list, as does any other C file that |
||
| 110 | # gets automatically generated. Omit the ".c" suffix. |
||
| 111 | # |
||
| 112 | set autoc { |
||
| 113 | xrayinit |
||
| 114 | } |
||
| 115 | |||
| 116 | # Put here the names of all TCL code modules that are |
||
| 117 | # generated by helper programs and/or scripts. Include the |
||
| 118 | # ".tcl" suffix. |
||
| 119 | # |
||
| 120 | set autotcl { |
||
| 121 | help.tcl |
||
| 122 | } |
||
| 123 | |||
| 124 | # Remove surplus white-space from the named |
||
| 125 | # variable. |
||
| 126 | # |
||
| 127 | proc Strip varname { |
||
| 128 | upvar 1 $varname v |
||
| 129 | regsub -all "\[ \t\n\r\]\[ \t\n\r\]*" $v { } v |
||
| 130 | } |
||
| 131 | |||
| 132 | # Remove surplus whitespace from the lists of files defined above. |
||
| 133 | # |
||
| 134 | Strip srcc |
||
| 135 | Strip srctcl |
||
| 136 | Strip autoc |
||
| 137 | Strip autotcl |
||
| 138 | |||
| 139 | # Remove surplus ".." and "." elements from a pathname. |
||
| 140 | # |
||
| 141 | proc CleanPath path { |
||
| 142 | regsub -all {/\./} $path / path |
||
| 143 | while {[regsub -all {[^/]*[^/.]/\.\./} $path {} path]} {} |
||
| 144 | return $path |
||
| 145 | } |
||
| 146 | |||
| 147 | # Convert a pathname to an absolute pathname. |
||
| 148 | # |
||
| 149 | proc AbsPath path { |
||
| 150 | switch [file pathtype $path] { |
||
| 151 | absolute { |
||
| 152 | set path [CleanPath $path] |
||
| 153 | } |
||
| 154 | relative { |
||
| 155 | set path [CleanPath [pwd]/$path] |
||
| 156 | } |
||
| 157 | default { |
||
| 158 | } |
||
| 159 | } |
||
| 160 | return $path |
||
| 161 | } |
||
| 162 | |||
| 163 | |||
| 164 | # Prefix on all executable names |
||
| 165 | # |
||
| 166 | set PFX {} |
||
| 167 | |||
| 168 | # The cleanable variable collects the names of all |
||
| 169 | # build products so they can be deleted by "make clean" |
||
| 170 | # |
||
| 171 | set cleanable {} |
||
| 172 | |||
| 173 | # The exelist variable collects the names of all executables |
||
| 174 | # |
||
| 175 | set exelist {} |
||
| 176 | |||
| 177 | # Write an introduction to the generated makefile. Include the |
||
| 178 | # "all" target here. |
||
| 179 | # |
||
| 180 | puts "# Automatically generated by makemake.tcl" |
||
| 181 | puts "# Do Not Edit!" |
||
| 182 | puts "" |
||
| 183 | if {$TEXE==""} { |
||
| 184 | puts "tests: ${PFX}psdgui-dev ${PFX}psdhost" |
||
| 185 | } |
||
| 186 | puts "all: ${PFX}psdgui$TEXE" |
||
| 187 | puts "" |
||
| 188 | puts "${PFX}psdhost$TEXE: ${PFX}psdsim$TEXE" |
||
| 189 | puts " cp ${PFX}psdsim$TEXE ${PFX}psdhost$TEXE" |
||
| 190 | puts "" |
||
| 191 | |||
| 192 | # Call this routine to generate code that will build a |
||
| 193 | # utility that will run on the host. |
||
| 194 | # |
||
| 195 | proc MakeUtil {name src} { |
||
| 196 | global cleanable BCC BEXE BLIBS |
||
| 197 | puts "$name$BEXE: $src" |
||
| 198 | puts " $BCC -o $name$BEXE $src $BLIBS" |
||
| 199 | puts "" |
||
| 200 | lappend cleanable $name$BEXE |
||
| 201 | } |
||
| 202 | |||
| 203 | # Call this routine to generate code that will link a program |
||
| 204 | # to run on the target. |
||
| 205 | # |
||
| 206 | proc MakeProg {name obj} { |
||
| 207 | global exelist TEXE TLINK TLIBS |
||
| 208 | puts "$name$TEXE: $obj" |
||
| 209 | puts " $TLINK -o $name$TEXE $obj $TLIBS" |
||
| 210 | puts "" |
||
| 211 | lappend exelist $name$TEXE |
||
| 212 | } |
||
| 213 | |||
| 214 | # Call this routine to generate code that will convert C code |
||
| 215 | # into a *.o file that will ultimately run on the target. |
||
| 216 | # |
||
| 217 | proc MakeObj {name src dep} { |
||
| 218 | global cleanable TCC TOP |
||
| 219 | puts "$name: $src $dep" |
||
| 220 | set inc "-DSRCDIR='\"[AbsPath $TOP/src]\"' -DBUILDDIR='\"[pwd]\"'" |
||
| 221 | puts " $TCC $inc -o $name -c $src" |
||
| 222 | puts "" |
||
| 223 | lappend cleanable $name |
||
| 224 | } |
||
| 225 | |||
| 226 | # Compile host-side utilities |
||
| 227 | # |
||
| 228 | MakeUtil makeheaders [CleanPath $TOP/tools/makeheaders.c] |
||
| 229 | MakeUtil mktclapp [CleanPath $TOP/tools/mktclapp.c] |
||
| 230 | MakeUtil help2tk [CleanPath $TOP/tools/help2tk.c] |
||
| 231 | |||
| 232 | # The main program |
||
| 233 | # |
||
| 234 | set obj {} |
||
| 235 | foreach f [concat $srcc $autoc] { |
||
| 236 | set m [file tail $f] |
||
| 237 | lappend obj $m.o |
||
| 238 | } |
||
| 239 | set obj [lsort $obj] |
||
| 240 | MakeProg ${PFX}psdgui $obj |
||
| 241 | regsub xrayinit.o $obj xrayinit-dev.o obj |
||
| 242 | MakeProg ${PFX}psdgui-dev $obj |
||
| 243 | |||
| 244 | # Generate code to prepare all the *.o files. We'll collect |
||
| 245 | # information about headers at the same time. |
||
| 246 | # |
||
| 247 | set hdr {} |
||
| 248 | set mharg {} |
||
| 249 | foreach f $srcc { |
||
| 250 | set m [file tail $f] |
||
| 251 | MakeObj $m.o [CleanPath $TOP/$f.c] $m.h |
||
| 252 | lappend hdr $m.h |
||
| 253 | lappend cleanable $m.h |
||
| 254 | lappend mharg [CleanPath $TOP/$f.c]:$m.h |
||
| 255 | } |
||
| 256 | foreach f $autoc { |
||
| 257 | MakeObj $f.o $f.c $f.h |
||
| 258 | # lappend hdr $f.h |
||
| 259 | lappend cleanable $f.h |
||
| 260 | } |
||
| 261 | MakeObj xrayinit-dev.o xrayinit-dev.c {} |
||
| 262 | |||
| 263 | # Generate code to make the header files. |
||
| 264 | # |
||
| 265 | foreach h $hdr { |
||
| 266 | puts "$h: headers" |
||
| 267 | } |
||
| 268 | puts "" |
||
| 269 | puts "headers: makeheaders$BEXE xrayinit.h" |
||
| 270 | puts " ./makeheaders$BEXE $mharg" |
||
| 271 | puts " touch headers" |
||
| 272 | puts "" |
||
| 273 | lappend cleanable headers |
||
| 274 | puts "xrayinit.h: mktclapp$BEXE" |
||
| 275 | puts " ./mktclapp$BEXE -header >xrayinit.h" |
||
| 276 | puts "" |
||
| 277 | lappend cleanable xrayinit.h |
||
| 278 | |||
| 279 | # Generate the application initializtion file using mktclapp. |
||
| 280 | # |
||
| 281 | set allsrc {} |
||
| 282 | foreach f $srcc { |
||
| 283 | lappend allsrc [CleanPath $TOP/$f.c] |
||
| 284 | } |
||
| 285 | puts "xrayinit-dev.c: mktclapp$BEXE $allsrc xrayinit-dev.mta" |
||
| 286 | puts " ./mktclapp$BEXE -f xrayinit-dev.mta >xrayinit-dev.c" |
||
| 287 | puts "" |
||
| 288 | lappend cleanable xrayinit-dev.c |
||
| 289 | foreach f $srctcl { |
||
| 290 | lappend allsrc [CleanPath $TOP/$f] |
||
| 291 | } |
||
| 292 | foreach f $autotcl { |
||
| 293 | lappend allsrc $f |
||
| 294 | } |
||
| 295 | puts "xrayinit.c: mktclapp$BEXE $allsrc xrayinit.mta" |
||
| 296 | puts " ./mktclapp$BEXE -f xrayinit.mta >xrayinit.c" |
||
| 297 | puts "" |
||
| 298 | lappend cleanable xrayinit.c |
||
| 299 | |||
| 300 | # Generate the *.mta file that mktclapp requires. The *.mta |
||
| 301 | # file tells mktclapp what components go into the application |
||
| 302 | # initializatio file. See the documentation on mkclapp for |
||
| 303 | # details. |
||
| 304 | # |
||
| 305 | set mtasrc {} |
||
| 306 | foreach f $srcc { |
||
| 307 | lappend mtasrc $TOP/$f.c |
||
| 308 | } |
||
| 309 | foreach f $srctcl { |
||
| 310 | lappend mtasrc [AbsPath $TOP/$f] |
||
| 311 | } |
||
| 312 | foreach f $autotcl { |
||
| 313 | lappend mtasrc [pwd]/$f |
||
| 314 | } |
||
| 315 | set n xrayinit-dev.mta |
||
| 316 | puts "$n: " |
||
| 317 | puts " echo -main-script [AbsPath $TOP/src/psdgui.tcl] >$n" |
||
| 318 | puts " echo -tcl-library $TCLSCRIPTDIR >>$n" |
||
| 319 | puts " echo -tk-library $TKSCRIPTDIR >>$n" |
||
| 320 | puts " echo $TCLSCRIPTDIR/*.tcl >>$n" |
||
| 321 | puts " echo $TCLSCRIPTDIR/tclIndex >>$n" |
||
| 322 | puts " echo $TKSCRIPTDIR/*.tcl >>$n" |
||
| 323 | puts " echo $TKSCRIPTDIR/tclIndex >>$n" |
||
| 324 | puts "" |
||
| 325 | lappend cleanable $n |
||
| 326 | set n xrayinit.mta |
||
| 327 | puts "$n: xrayinit-dev.mta" |
||
| 328 | puts " cat xrayinit-dev.mta >$n" |
||
| 329 | puts " echo $mtasrc >>$n" |
||
| 330 | puts "" |
||
| 331 | lappend cleanable $n |
||
| 332 | |||
| 333 | # Generate the help screens. |
||
| 334 | # |
||
| 335 | puts "help.tcl: help2tk$BEXE $TOP/src/psdgui.help" |
||
| 336 | puts " ./help2tk$BEXE $TOP/src/psdgui.help >help.tcl" |
||
| 337 | puts "" |
||
| 338 | |||
| 339 | ############################################################################## |
||
| 340 | # The rest is for the psdhost simulator. |
||
| 341 | # |
||
| 342 | |||
| 343 | # Put the basename of each C source code modules |
||
| 344 | # here. Omit the ".c" suffix. |
||
| 345 | # |
||
| 346 | set srcc { |
||
| 347 | src/psdsim |
||
| 348 | } |
||
| 349 | |||
| 350 | # Put the names of all TCL modules here. Include the ".tcl" |
||
| 351 | # suffix. |
||
| 352 | # |
||
| 353 | set srctcl { |
||
| 354 | src/notebook.tcl |
||
| 355 | src/psdsim.tcl |
||
| 356 | } |
||
| 357 | |||
| 358 | # Put here the basenames of all C code modules that are |
||
| 359 | # generated by helper programs or/and automated scripts. These |
||
| 360 | # files are C code but they are not source code. Omit the ".c" |
||
| 361 | # suffix. |
||
| 362 | # |
||
| 363 | set autoc { |
||
| 364 | siminit |
||
| 365 | } |
||
| 366 | |||
| 367 | # Put here the names of all TCL code modules that are |
||
| 368 | # generated by helper programs and/or scripts. Include the |
||
| 369 | # ".tcl" suffix. |
||
| 370 | # |
||
| 371 | set autotcl { |
||
| 372 | } |
||
| 373 | |||
| 374 | # Remove surplus whitespace from the lists of files. |
||
| 375 | # |
||
| 376 | Strip srcc |
||
| 377 | Strip srctcl |
||
| 378 | Strip autoc |
||
| 379 | Strip autotcl |
||
| 380 | |||
| 381 | # The main program |
||
| 382 | # |
||
| 383 | set obj {} |
||
| 384 | foreach f [concat $srcc $autoc] { |
||
| 385 | set m [file tail $f] |
||
| 386 | lappend obj $m.o |
||
| 387 | } |
||
| 388 | set obj [lsort $obj] |
||
| 389 | MakeProg ${PFX}psdsim $obj |
||
| 390 | |||
| 391 | # Generate code to prepare all the *.o files. We'll collect |
||
| 392 | # information about headers at the same time. |
||
| 393 | # |
||
| 394 | set hdr {} |
||
| 395 | set mharg {} |
||
| 396 | foreach f $srcc { |
||
| 397 | set m [file tail $f] |
||
| 398 | MakeObj $m.o [CleanPath $TOP/$f.c] $m.h |
||
| 399 | lappend hdr $m.h |
||
| 400 | lappend cleanable $m.h |
||
| 401 | lappend mharg [CleanPath $TOP/$f.c]:$m.h |
||
| 402 | } |
||
| 403 | foreach f $autoc { |
||
| 404 | MakeObj $f.o $f.c $f.h |
||
| 405 | lappend hdr $f.h |
||
| 406 | lappend cleanable $f.h |
||
| 407 | } |
||
| 408 | |||
| 409 | # Generate code to make the header files. |
||
| 410 | # |
||
| 411 | foreach h $hdr { |
||
| 412 | puts "$h: headers2" |
||
| 413 | } |
||
| 414 | puts "" |
||
| 415 | puts "headers2: makeheaders$BEXE" |
||
| 416 | puts " ./makeheaders$BEXE $mharg" |
||
| 417 | puts " touch headers2" |
||
| 418 | puts "" |
||
| 419 | lappend cleanable headers2 |
||
| 420 | |||
| 421 | # Generate the application initializtion file using mktclapp. |
||
| 422 | # |
||
| 423 | set allsrc {} |
||
| 424 | foreach f $srcc { |
||
| 425 | lappend allsrc [CleanPath $TOP/$f.c] |
||
| 426 | } |
||
| 427 | foreach f $srctcl { |
||
| 428 | lappend allsrc [CleanPath $TOP/$f] |
||
| 429 | } |
||
| 430 | foreach f $autotcl { |
||
| 431 | lappend allsrc $f |
||
| 432 | } |
||
| 433 | puts "siminit.c: mktclapp$BEXE $allsrc siminit.mta" |
||
| 434 | puts " ./mktclapp$BEXE -f siminit.mta >siminit.c" |
||
| 435 | puts "" |
||
| 436 | lappend cleanable siminit.c |
||
| 437 | |||
| 438 | # Generate the *.mta file that mktclapp requires. The *.mta |
||
| 439 | # file tells mktclapp what components go into the application |
||
| 440 | # initializatio file. See the documentation on mkclapp for |
||
| 441 | # details. |
||
| 442 | # |
||
| 443 | set mtasrc {} |
||
| 444 | foreach f $srcc { |
||
| 445 | lappend mtasrc $TOP/$f.c |
||
| 446 | } |
||
| 447 | foreach f $srctcl { |
||
| 448 | lappend mtasrc [AbsPath $TOP/$f] |
||
| 449 | } |
||
| 450 | foreach f $autotcl { |
||
| 451 | lappend mtasrc [pwd]/$f |
||
| 452 | } |
||
| 453 | set n siminit.mta |
||
| 454 | puts "$n: " |
||
| 455 | puts " echo $mtasrc >$n" |
||
| 456 | puts " echo -main-script [AbsPath $TOP/src/psdgui.tcl] >>$n" |
||
| 457 | puts " echo -tcl-library $TCLSCRIPTDIR >>$n" |
||
| 458 | puts " echo -tk-library $TKSCRIPTDIR >>$n" |
||
| 459 | puts " echo $TCLSCRIPTDIR/*.tcl >>$n" |
||
| 460 | puts " echo $TCLSCRIPTDIR/tclIndex >>$n" |
||
| 461 | puts " echo $TKSCRIPTDIR/*.tcl >>$n" |
||
| 462 | puts " echo $TKSCRIPTDIR/tclIndex >>$n" |
||
| 463 | puts "" |
||
| 464 | lappend cleanable $n |
||
| 465 | |||
| 466 | # The usual makefile target... |
||
| 467 | # |
||
| 468 | puts "clean: " |
||
| 469 | puts " rm -f $cleanable" |
||
| 470 | puts "" |
||
| 471 | puts "distclean: " |
||
| 472 | puts " rm -f $cleanable $exelist config.cache config.log config.status all.mk" |
||
| 473 | puts "" |
||
| 474 | puts "install: all" |
||
| 475 | puts " if test ! -d ../bin; then mkdir ../bin; fi" |
||
| 476 | puts " mv $exelist ../bin" |
||
| 477 | puts "" |