Mercurial > ecos
annotate packages/pkgconf.tcl @ 46:797268ecc331 ecos-sw-1999-10-19
Merge from eCos master repository on 1999-10-19-18:55:31-BST
| author | jlarmour |
|---|---|
| date | Tue, 19 Oct 1999 19:19:52 +0000 |
| parents | 41bd4f3a90de |
| children | c38311975d4f |
| rev | line source |
|---|---|
| 0 | 1 # {{{ Banner |
| 2 | |
| 3 #=============================================================================== | |
| 4 # | |
| 5 # pkgconf.tcl | |
| 6 # | |
| 7 # A temporary build system for target-side software. | |
| 8 # | |
| 9 #=============================================================================== | |
| 10 #####COPYRIGHTBEGIN#### | |
| 11 # | |
| 12 # ------------------------------------------- | |
| 13 # The contents of this file are subject to the Cygnus eCos Public License | |
| 14 # Version 1.0 (the "License"); you may not use this file except in | |
| 15 # compliance with the License. You may obtain a copy of the License at | |
| 16 # http://sourceware.cygnus.com/ecos | |
| 17 # | |
| 18 # Software distributed under the License is distributed on an "AS IS" | |
| 19 # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 20 # License for the specific language governing rights and limitations under | |
| 21 # the License. | |
| 22 # | |
| 23 # The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 24 # September 30, 1998. | |
| 25 # | |
| 26 # The Initial Developer of the Original Code is Cygnus. Portions created | |
| 2 | 27 # by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
| 0 | 28 # ------------------------------------------- |
| 29 # | |
| 30 #####COPYRIGHTEND#### | |
| 31 #=============================================================================== | |
| 32 ######DESCRIPTIONBEGIN#### | |
| 33 # | |
| 34 # Author(s): bartv | |
| 35 # Contributors: bartv | |
| 36 # Date: 1998-04-10 | |
| 37 # Purpose: To generate a build tree (aka a configuration directory) | |
| 38 # and fill in basic configurability information. | |
| 39 # Description: | |
| 40 # Usage: | |
| 41 # | |
| 42 #####DESCRIPTIONEND#### | |
| 43 #=============================================================================== | |
| 44 # | |
| 45 | |
| 46 # }}} | |
| 47 | |
| 48 # {{{ Version check | |
| 49 | |
| 50 # ---------------------------------------------------------------------------- | |
| 51 # pkgconf.tcl requires at least version 8.0 of Tcl, since it makes use of | |
| 52 # namespaces. It is possible that some users still have older versions. | |
| 53 | |
| 54 if { [info tclversion] < 8.0 } { | |
| 55 puts "You are running Tcl version [info tclversion], patchlevel [info patchlevel]" | |
| 56 puts "The pkgconf.tcl script requires version 8.0 or later." | |
| 57 puts "Tcl is open source software and can be readily obtained via the internet." | |
| 58 puts "Good starting places for more information include www.tclconsortium.org" | |
| 59 puts "and www.scriptics.com" | |
| 60 exit 0 | |
| 61 } | |
| 62 | |
| 63 # }}} | |
| 64 # {{{ Namespace definition | |
| 65 | |
| 66 # ---------------------------------------------------------------------------- | |
| 67 # Namespaces. All code and variables in this script are kept in the namespace | |
| 68 # "pkgconf". This is not really necessary for stand-alone operation, but if it | |
| 69 # ever becomes desirable to embed this script in a larger application then | |
| 70 # using a namespace is a lot easier. | |
| 71 # | |
| 72 # As a fringe benefit, all global variables can be declared inside this | |
| 73 # namespace and initialised. | |
| 74 # | |
| 75 | |
| 76 namespace eval pkgconf { | |
| 77 | |
| 78 # Is this program running on a real operating system or under Windows ? | |
| 79 variable windows_host [expr {$tcl_platform(platform) == "windows"}] | |
| 80 | |
| 81 # Is this script running in command-line or GUI mode ? This is determined | |
| 82 # in large part by the command used to invoke the script. | |
| 83 variable gui_mode 0 | |
| 84 | |
| 85 # Keep track of whether or not GUI mode is possible at all. If | |
| 86 # TK is not loaded into the current interpreter then only | |
| 87 # command-line operation is possible. | |
| 88 variable gui_possible 0 | |
| 89 | |
| 90 # Where is the component repository ? The following input sources | |
| 91 # are available: | |
| 92 # 1) the command line argument --srcdir. This requires | |
| 93 # the arguments to be parsed early on. | |
| 94 # 2) the environment variable PKGCONF_COMPONENT_REPOSITORY. | |
| 95 # 3) $argv0 should correspond to the location of the pkgconf.tcl | |
| 96 # script. | |
| 97 # | |
| 98 variable component_repository "" | |
| 99 if { [info exists ::env(PKGCONF_COMPONENT_REPOSITORY)] } { | |
| 100 set component_repository $::env(PKGCONF_COMPONENT_REPOSITORY) | |
| 101 } else { | |
| 102 # Care has to be taken not to end up with a spurious /. at the end, | |
| 103 # since that would confuse later checks of component_repository != build_tree | |
| 104 set component_repository [pwd] | |
| 105 if { [file dirname $argv0] != "." } { | |
| 106 set component_repository [file join $component_repository [file dirname $argv0]] | |
| 107 } | |
| 108 } | |
| 109 | |
| 110 # Where is the build tree ? This can be specified using the command | |
| 111 # line argument --builddir, the environment variable PKGCONF_BUILD_TREE, | |
| 112 # or it defaults to the current directory (in accordance with the | |
| 113 # normal behaviour of configure scripts). | |
| 114 variable build_tree "" | |
| 115 if { [info exists ::env(PKGCONF_BUILD_TREE)] } { | |
| 116 set build_tree $::env(PKGCONF_BUILD_TREE) | |
| 117 } else { | |
| 118 set build_tree [pwd] | |
| 119 } | |
| 120 | |
| 121 # Details of the command line arguments, if any. | |
| 122 variable list_targets_arg 0; # --targets | |
| 123 variable list_packages_arg 0; # --packages | |
| 124 variable list_pkgdata_arg 0; # --pkgdata | |
| 125 variable list_flags_arg 0; # --flags | |
| 126 variable no_windows_arg 0; # --nw | |
| 127 variable target_arg ""; # --target=abc | |
| 128 variable platform_arg ""; # --platform=sim | |
| 129 variable startup_arg ""; # --platform=rom | |
| 130 variable prefix_arg ""; # --prefix=/tmp/install | |
| 131 variable disable_args ""; # --disable-uitron | |
| 132 # This is a list of all disabled packages. | |
| 133 variable enable_args ""; # --enable-uitron, as above. | |
| 134 array set version_args {}; # --kernel_version=v0.3 | |
| 135 # This is an array indexed by package name. | |
| 136 array set cflags_args {}; # DBGFLAGS="-Wall -Werror" | |
| 137 # This is an array indexed by flag name. | |
| 138 variable force_arg 0; # Forcibly overwrite configuration files. | |
| 139 variable defaults_arg 0; # Do not use the values from the save file. | |
| 140 variable use_links_arg 0; # Make use of symbolic links. | |
| 141 variable use_copies_arg 0; # The inverse. | |
| 2 | 142 variable debug_arg 0; # --debug, control infrastructure options |
| 143 variable nodebug_arg 0; # --nodebug, ditto | |
| 0 | 144 |
| 145 # Details of all known packages. These come out of the packages file. | |
| 146 # The variable known_packages is a simple list, and the rest of the | |
| 147 # data is held in an array package_data(). | |
| 148 variable known_packages "" | |
| 149 array set package_data {}; | |
| 150 | |
| 151 # Details of all known targets, as supplied by the targets file. | |
| 152 # The variable known_targets is a simple list, and the rest of the | |
| 153 # data is held in an array target_data. | |
| 154 variable known_targets "" | |
| 155 array set target_data {}; | |
| 156 | |
| 157 # Details of all the compiler flags that can be used within the | |
| 158 # build system. | |
| 159 variable known_compiler_flags { | |
| 160 ARCHFLAGS CARCHFLAGS CXXARCHFLAGS LDARCHFLAGS | |
| 161 ERRFLAGS CERRFLAGS CXXERRFLAGS LDERRFLAGS | |
| 162 LANGFLAGS CLANGFLAGS CXXLANGFLAGS LDLANGFLAGS | |
| 163 DBGFLAGS CDBGFLAGS CXXDBGFLAGS LDDBGFLAGS | |
| 164 EXTRAFLAGS CEXTRAFLAGS CXXEXTRAFLAGS LDEXTRAFLAGS | |
| 165 } | |
| 166 | |
| 167 # Details of the current configuration values. It is convenient | |
| 168 # to store these in an array as well. The array gets filled in by | |
| 169 # pkgconf::setup_defaults | |
| 170 array set config_data {}; | |
| 171 | |
| 172 # Contents of the current save file, if any. | |
| 173 array set saved_data {}; | |
| 174 | |
| 175 # These variables are used by the code that creates the build tree | |
| 176 variable inc_dirs; # For each package with exported header | |
| 177 # files, the path to those header files | |
| 178 # relative to either the component repository | |
| 179 # or the build tree. | |
| 2 | 180 variable misc_dirs; # Ditto for package misc directories. |
| 0 | 181 variable tests_dirs; # Ditto for package tests directories. |
| 182 variable src_dirs; # Ditto for src directories. | |
| 183 | |
| 184 variable install_inc_dirs; # Names of all the directories that should | |
| 185 # exist below install/include, including pkgconf. | |
| 186 variable install_inc_files; # Ditto for all the files, but excluding | |
| 187 # ones in pkgconf. | |
| 188 variable pkgconf_files; # Names of all the configuration headers | |
| 189 variable install_test_dirs; # What directories should be created in install/tests | |
| 190 | |
| 191 # What routines should be invoked for outputting fatal errors and | |
| 192 # for warning messages ? | |
| 193 variable fatal_error_handler pkgconf::cli_fatal_error | |
| 194 variable warning_handler pkgconf::cli_warning | |
| 195 variable report_handler pkgconf::cli_report | |
| 196 } | |
| 197 | |
| 198 # }}} | |
| 199 # {{{ Infrastructure | |
| 200 | |
| 201 # ---------------------------------------------------------------------------- | |
| 202 # Minimal infrastructure support. | |
| 203 # | |
| 204 # There must be some way of reporting fatal errors, of outputting warnings, | |
| 205 # and of generating report messages. The implementation of these things | |
| 206 # obviously depends on whether or not TK is present. In addition, if this | |
| 207 # script is being run inside a larger application then that larger | |
| 208 # application must be able to install its own versions of the routines. | |
| 209 # | |
| 210 # Once it is possible to report fatal errors, an assertion facility becomes | |
| 211 # feasible. | |
| 212 # | |
| 213 | |
| 214 # | |
| 215 # These routines output fatal errors, warnings or miscellaneous messages. | |
| 216 # Their implementations depend on the mode in which this script is operating. | |
| 217 # | |
| 218 proc pkgconf::fatal_error { msg } { | |
| 219 $pkgconf::fatal_error_handler "$msg" | |
| 220 } | |
| 221 | |
| 222 proc pkgconf::warning { msg } { | |
| 223 $pkgconf::warning_handler "$msg" | |
| 224 } | |
| 225 | |
| 226 proc pkgconf::report { msg } { | |
| 227 $pkgconf::report_handler "$msg" | |
| 228 } | |
| 229 | |
| 230 # | |
| 231 # Command line versions. | |
| 232 # NOTE: some formatting so that there are linebreaks at ~72 columns would be | |
| 233 # a good idea. | |
| 234 # | |
| 235 proc pkgconf::cli_fatal_error_handler { msg } { | |
| 236 puts "pkgconf fatal error: $msg" | |
| 237 exit 1 | |
| 238 } | |
| 239 | |
| 240 proc pkgconf::cli_warning_handler { msg } { | |
| 241 puts "pkgconf warning: $msg" | |
| 242 } | |
| 243 | |
| 244 proc pkgconf::cli_report_handler { msg } { | |
| 245 puts "$msg" | |
| 246 } | |
| 247 | |
| 248 # | |
| 249 # Determine the default destination for warnings and for fatal errors. | |
| 250 # In GUI mode message boxes should be used, otherwise the text should just | |
| 251 # go to stdout (stderr is more dubious). | |
| 252 # | |
| 253 # This routine gets invoked before any command line arguments have | |
| 254 # been processed, to set up a sensible default. It gets invoked again | |
| 255 # afterwards, since there may have been a change between GUI and CLI | |
| 256 # mode. | |
| 257 # | |
| 258 # After the first call to this function it is possible to use assertions. | |
| 259 # | |
| 260 proc pkgconf::initialise_error_handling { } { | |
| 261 | |
| 262 if { $pkgconf::gui_mode } { | |
| 263 set pkgconf::fatal_error_handler pkgconf::gui_fatal_error_handler | |
| 264 set pkgconf::warning_handler pkgconf::gui_warning_handler | |
| 265 set pkgconf::report_handler pkgconf::gui_report_handler | |
| 266 } else { | |
| 267 set pkgconf::fatal_error_handler pkgconf::cli_fatal_error_handler | |
| 268 set pkgconf::warning_handler pkgconf::cli_warning_handler | |
| 269 set pkgconf::report_handler pkgconf::cli_report_handler | |
| 270 } | |
| 271 } | |
| 272 | |
| 273 # | |
| 274 # These routines can be used by containing programs to provide their | |
| 275 # own error handling. | |
| 276 # | |
| 277 proc pkgconf::set_fatal_error_handler { fn } { | |
| 278 ASSERT { $fn != "" } | |
| 279 set pkgconf::fatal_error_handler $fn | |
| 280 } | |
| 281 | |
| 282 proc pkgconf::set_warning_handler { fn } { | |
| 283 ASSERT { $fn != "" } | |
| 284 set pkgconf::warning_handler $fn | |
| 285 } | |
| 286 | |
| 287 proc pkgconf::set_report_handler { fn } { | |
| 288 ASSERT { $fn != "" } | |
| 289 set pkgconf::report_handler $fn | |
| 290 } | |
| 291 | |
| 292 # | |
| 293 # A very simple assertion facility. It takes a single argument, an expression | |
| 294 # that should be evaluated in the calling function's scope, and on failure it | |
| 295 # should generate a fatal error. | |
| 296 # | |
| 297 proc pkgconf::ASSERT { condition } { | |
| 298 | |
| 299 set result [uplevel 1 [list expr $condition]] | |
| 300 | |
| 301 if { $result == 0 } { | |
| 302 fatal_error "Assertion failure.\nPredicate \"$condition\"\nThe failure occurred in \"[info level -1]\"" | |
| 303 } | |
| 304 } | |
| 305 | |
| 306 # }}} | |
| 307 # {{{ Utilities | |
| 308 | |
| 309 # ---------------------------------------------------------------------------- | |
| 310 # cdl_compare_version. This is a partial implementation of the full | |
| 311 # cdl_compare_version facility defined in the product specification. Its | |
| 312 # purpose is to order the various versions of a given package with | |
| 313 # the most recent version first. As a special case, "current" is | |
| 314 # always considered the most recent. | |
| 315 # | |
| 316 # There are similarities between cdl_compare_version and with Tcl's | |
| 317 # package vcompare, but cdl_compare_version is more general. | |
| 318 # | |
| 319 | |
| 320 proc pkgconf::cdl_compare_version { arg1 arg2 } { | |
| 321 | |
| 322 if { $arg1 == $arg2 } { | |
| 323 return 0 | |
| 324 } | |
| 325 if { $arg1 == "current"} { | |
| 326 return -1 | |
| 327 } | |
| 328 if { $arg2 == "current" } { | |
| 329 return 1 | |
| 330 } | |
| 331 | |
| 332 set index1 0 | |
| 333 set index2 0 | |
| 334 set ch1 "" | |
| 335 set ch2 "" | |
| 336 set num1 "" | |
| 337 set num2 "" | |
| 338 | |
| 339 while { 1} { | |
| 340 | |
| 341 set ch1 [string index $arg1 $index1] | |
| 342 set ch2 [string index $arg2 $index2] | |
| 343 set num1 "" | |
| 344 set num2 "" | |
| 345 | |
| 346 if { ($ch1 == "") && ($ch2 == "") } { | |
| 347 | |
| 348 # Both strings have terminated at the same time. There may have | |
| 349 # been some spurious leading zeroes in numbers. | |
| 350 return 0 | |
| 351 | |
| 352 } elseif { $ch1 == "" } { | |
| 353 | |
| 354 # The first string has ended first. If ch2 is a separator then | |
| 355 # arg2 is a derived version, e.g. v0.3.p1 and hence newer. Otherwise ch2 | |
| 356 # is an experimental version v0.3beta and hence older. | |
| 357 if { [string match \[-._\] $ch2] } { | |
| 358 return 1 | |
| 359 } else { | |
| 360 return -1 | |
| 361 } | |
| 362 } elseif { $ch2 == "" } { | |
| 363 | |
| 364 # Equivalent to the above. | |
| 365 if { [string match \[-._\] $ch1] } { | |
| 366 return -1 | |
| 367 } else { | |
| 368 return 1 | |
| 369 } | |
| 370 } | |
| 371 | |
| 372 # There is still data to be processed. | |
| 373 # Check for both strings containing numbers at the current index. | |
| 374 if { ( [string match \[0-9\] $ch1] ) && ( [string match \[0-9\] $ch2] ) } { | |
| 375 | |
| 376 # Extract the entire numbers from the version string. | |
| 377 while { [string match \[0-9\] $ch1] } { | |
| 378 set num1 "$num1$ch1" | |
| 379 incr index1 | |
| 380 set ch1 [string index $arg1 $index1] | |
| 381 } | |
| 382 while { [string match \[0-9\] $ch2] } { | |
| 383 set num2 "$num2$ch2" | |
| 384 incr index2 | |
| 385 set ch2 [string index $arg2 $index2] | |
| 386 } | |
| 387 | |
| 388 if { $num1 < $num2 } { | |
| 389 return 1 | |
| 390 } elseif { $num1 > $num2 } { | |
| 391 return -1 | |
| 392 } | |
| 393 continue | |
| 394 } | |
| 395 | |
| 396 # This is not numerical data. If the two characters are the same then | |
| 397 # move on. | |
| 398 if { $ch1 == $ch2 } { | |
| 399 incr index1 | |
| 400 incr index2 | |
| 401 continue | |
| 402 } | |
| 403 | |
| 404 # Next check if both strings are at a separator. All separators can be | |
| 405 # used interchangeably. | |
| 406 if { ( [string match \[-._\] $ch1] ) && ( [string match \[-._\] $ch2] ) } { | |
| 407 incr index1 | |
| 408 incr index2 | |
| 409 continue | |
| 410 } | |
| 411 | |
| 412 # There are differences in the characters and they are not interchangeable. | |
| 413 # Just return a standard string comparison. | |
| 414 return [string compare $ch1 $ch2] | |
| 415 } | |
| 416 } | |
| 417 | |
| 418 if { 0 } { | |
| 419 | |
| 420 puts "compare current v0.1 : [pkgconf::cdl_compare_version current v0.1]" | |
| 421 puts "compare v0.1 current : [pkgconf::cdl_compare_version v0.1 current]" | |
| 422 puts "compare current current : [pkgconf::cdl_compare_version current current]" | |
| 423 puts "compare v0.1 v0.1 : [pkgconf::cdl_compare_version v0.1 v0.1]" | |
| 424 puts "compare v0_1 v0.1 : [pkgconf::cdl_compare_version v0_1 v0.1]" | |
| 425 puts "compare v0.1 v0_1 : [pkgconf::cdl_compare_version v0.1 v0_1]" | |
| 426 puts "compare v0_1 v0-1 : [pkgconf::cdl_compare_version v0_1 v0-1]" | |
| 427 puts "compare v0-1 v0_1 : [pkgconf::cdl_compare_version v0-1 v0_1]" | |
| 428 puts "compare v0.2 v0.1 : [pkgconf::cdl_compare_version v0.2 v0.1]" | |
| 429 puts "compare v0.1 v0.2 : [pkgconf::cdl_compare_version v0.1 v0.2]" | |
| 430 puts "compare v0.10 v0.2 : [pkgconf::cdl_compare_version v0.10 v0.2]" | |
| 431 puts "compare v0.2 v0.10 : [pkgconf::cdl_compare_version v0.2 v0.10]" | |
| 432 puts "compare 980410 980412 : [pkgconf::cdl_compare_version 980410 980412]" | |
| 433 puts "compare 980412 980410 : [pkgconf::cdl_compare_version 980412 980410]" | |
| 434 puts "compare ss980410 ss980412 : [pkgconf::cdl_compare_version ss980410 ss980412]" | |
| 435 puts "compare ss980412 ss980410 : [pkgconf::cdl_compare_version ss980412 ss980410]" | |
| 436 puts "compare v0.1.2 v0.1.3 : [pkgconf::cdl_compare_version v0.1.2 v0.1.3]" | |
| 437 puts "compare v0.1.3 v0.1.2 : [pkgconf::cdl_compare_version v0.1.3 v0.1.2]" | |
| 438 puts "compare v1.0 v0.1.3 : [pkgconf::cdl_compare_version v1.0 v0.1.3]" | |
| 439 puts "compare v0.1.3 v1.0 : [pkgconf::cdl_compare_version v0.1.3 v1.0]" | |
| 440 puts "compare v1.0beta v1.0 : [pkgconf::cdl_compare_version v1.0beta v1.0]" | |
| 441 puts "compare v1.0 v1.0beta : [pkgconf::cdl_compare_version v1.0 v1.0beta]" | |
| 442 puts "compare v1.0.p1 v1.0 : [pkgconf::cdl_compare_version v1.0.p1 v1.0]" | |
| 443 puts "compare v1.0 v1.0.p1 : [pkgconf::cdl_compare_version v1.0 v1.0.p1]" | |
| 444 } | |
| 445 | |
| 446 # }}} | |
| 447 # {{{ Argument parsing | |
| 448 | |
| 449 # ---------------------------------------------------------------------------- | |
| 450 # Parsing the arguments. The following arguments should be accepted for | |
| 451 # backwards compatibility reasons. | |
| 452 # | |
| 453 # --target=<arch_name> | |
| 454 # --platform=sim | |
| 455 # --startup=rom or --startup=ram | |
| 456 # --prefix=<directory> | |
| 457 # --disable-uitron | |
| 458 # --disable-libc | |
| 459 # | |
| 460 # There was also a --disable-kernel_c_api, but that is no longer supported. | |
| 461 # For now disabling only applies to entire packages, not to components | |
| 462 # within a package. The argument --release=debug has also been disabled | |
| 463 # because it affects too many things (the makevars file, various #define's, | |
| 464 # etc.). | |
| 465 # | |
| 466 # Also it was possible to use --disable-uitron=yes, but that was | |
| 467 # undocumented and is not worth supporting. | |
| 468 # | |
| 469 # Configure allowed --srcdir=xxx, although it did not need it. It is useful | |
| 470 # to support this, and to add --builddir. --installdir as a prefix alias | |
| 471 # then makes sense. | |
| 472 # | |
| 473 # --help should be supported if present as a single argument. | |
| 474 # | |
| 475 # It is desirable to support additional arguments of the form: | |
| 476 # | |
| 477 # --enable-uitron (to undo a disable in the saved data) | |
| 478 # --kernel-version=current | |
| 479 # --uitron-version=v0.3 | |
| 480 # | |
| 481 # Similarly it is desirable to allow users to control compiler flags, e.g. | |
| 482 # DBGFLAGS="-Wall -Werror" | |
| 483 # | |
| 2 | 484 # --debug can be used to set appropriate debug options in the |
| 485 # infrastructure. This should probably be --enable-debug, but that | |
| 486 # could cause confusion. There is also a --nodebug option. | |
| 487 # | |
| 0 | 488 # A new argument is --nw, to disable the GUI environment. Other new |
| 489 # arguments are: | |
| 490 # --targets and --packages to display the appropriate details | |
| 491 # --force to force files to be copied across from the repository | |
| 492 # --defaults to cause the program to ignore the values in the save file. | |
| 493 # --linkhdrs and --copyhdrs to control how header files should be handled. | |
| 494 # | |
| 495 # It is also a good idea to be a bit more flexible about the format | |
| 496 # of the command line arguments, for example -target=xxx should work, | |
| 497 # as should -target xxx | |
| 498 # | |
| 499 # The argv0 argument should be the name of this script. It can be used | |
| 500 # to get at the component repository location. If this script has been | |
| 501 # run incorrectly then currently it will fail: in future it may be | |
| 502 # desirable to check an environment variable instead. | |
| 503 # | |
| 504 # The argv argument is a string containing the rest of the arguments. | |
| 505 # If any of the arguments contain spaces then this argument will be | |
| 506 # surrounded by braces. If any of the arguments contain braces then | |
| 507 # things will break. | |
| 508 # | |
| 509 | |
| 510 proc pkgconf::parse_arguments { argv0 argv } { | |
| 511 | |
| 512 # First, check for --help or any of the variants. If this script | |
| 513 # is running in a larger program then it is assumed that the | |
| 514 # containing program will not pass --help as an argument. | |
| 515 if { ( $argv == "--help" ) || ( $argv == "-help" ) || | |
| 516 ( $argv == "--H" ) || ( $argv == "-H" ) } { | |
| 517 | |
| 518 argument_help | |
| 519 exit 0 | |
| 520 } | |
| 521 | |
| 522 if { $argv != "" } { | |
| 523 | |
| 524 # There are arguments. If any of the arguments contained | |
| 525 # spaces then these arguments will have been surrounded | |
| 526 # by braces, which is a nuisance. So start by turning the | |
| 527 # arguments into a numerically indexed array. | |
| 528 | |
| 529 set argc 0 | |
| 530 array set args { } | |
| 531 foreach arg $argv { | |
| 532 set args([incr argc]) $arg | |
| 533 } | |
| 534 | |
| 535 # Now examine each argument with regular expressions. It is | |
| 536 # useful to have some variables filled in by the regexp | |
| 537 # matching. | |
| 538 set dummy "" | |
| 539 set match1 "" | |
| 540 set match2 "" | |
| 541 for { set i 1 } { $i <= $argc } { incr i } { | |
| 542 | |
| 543 # Check for -nw. The regexp allows an optional -, followed by | |
| 544 # the text -nw, and nothing else. | |
| 545 if { [regexp -- {^-?-nw$} $args($i)] == 1 } { | |
| 546 set pkgconf::no_windows_arg 1 | |
| 547 continue | |
| 548 } | |
| 549 | |
| 550 # Check for --packages and the other simple ones. | |
| 551 if { [regexp -- {^-?-packages$} $args($i)] == 1 } { | |
| 552 set pkgconf::list_packages_arg 1 | |
| 553 continue | |
| 554 } | |
| 555 if { [regexp -- {^-?-pkgdata$} $args($i)] == 1 } { | |
| 556 set pkgconf::list_pkgdata_arg 1 | |
| 557 continue | |
| 558 } | |
| 559 if { [regexp -- {^-?-targets$} $args($i)] == 1 } { | |
| 560 set pkgconf::list_targets_arg 1 | |
| 561 continue | |
| 562 } | |
| 563 if { [regexp -- {^-?-flags$} $args($i)] == 1 } { | |
| 564 set pkgconf::list_flags_arg 1 | |
| 565 continue | |
| 566 } | |
| 567 if { [regexp -- {^-?-force$} $args($i)] == 1 } { | |
| 568 set pkgconf::force_arg 1 | |
| 569 continue | |
| 570 } | |
| 571 if { [regexp -- {^-?-defaults$} $args($i)] == 1 } { | |
| 572 set pkgconf::defaults_arg 1 | |
| 573 continue | |
| 574 } | |
| 575 if { [regexp -- {^-?-linkhdrs$} $args($i)] == 1 } { | |
| 576 set pkgconf::use_links_arg 1 | |
| 577 continue | |
| 578 } | |
| 579 if { [regexp -- {^-?-copyhdrs$} $args($i)] == 1 } { | |
| 580 set pkgconf::use_copies_arg 1 | |
| 581 continue | |
| 582 } | |
| 2 | 583 if { [regexp -- {^-?-debug$} $args($i)] == 1 } { |
| 584 set pkgconf::debug_arg 1 | |
| 585 continue | |
| 586 } | |
| 587 if { [regexp -- {^-?-nodebug$} $args($i)] == 1 } { | |
| 588 set pkgconf::nodebug_arg 1 | |
| 589 continue | |
| 590 } | |
| 0 | 591 |
| 592 # Now for the directories. srcdir and builddir will have | |
| 593 # been calculated already, but may be overridden here. | |
| 594 if { [regexp -- {^-?-src_?dir=?(.*)$} $args($i) dummy match1] == 1 } { | |
| 595 if { $match1 != "" } { | |
| 596 set pkgconf::component_repository $match1 | |
| 597 } else { | |
| 598 if { $i == $argc } { | |
| 599 fatal_error "pkgconf: missing argument after --srcdir" | |
| 600 } else { | |
| 601 set pkgconf::component_repository $args([incr i]) | |
| 602 } | |
| 603 } | |
| 604 continue | |
| 605 } | |
| 606 if { [regexp -- {^-?-build_?dir=?(.*)$} $args($i) dummy match1] == 1 } { | |
| 607 if { $match1 != "" } { | |
| 608 set pkgconf::build_tree $match1 | |
| 609 } else { | |
| 610 if { $i == $argc } { | |
| 611 fatal_error "pkgconf: missing argument after --builddir" | |
| 612 } else { | |
| 613 set pkgconf::build_tree $args([incr i]) | |
| 614 } | |
| 615 } | |
| 616 continue | |
| 617 } | |
| 618 | |
| 619 # And prefix, before moving on to the more interesting ones. | |
| 620 # Prefix is a pathname so spaces are legitimate, as are dots, | |
| 621 # directory separators, and drive indicators. | |
| 622 # | |
| 623 # NOTE: strictly speaking the pattern should be platform specific. | |
| 624 if { [regexp -- {^-?-prefix=?(.*)$} $args($i) dummy match1] == 1 } { | |
| 625 if { $match1 != "" } { | |
| 626 set pkgconf::prefix_arg $match1 | |
| 627 } else { | |
| 628 if { $i == $argc } { | |
| 629 fatal_error "pkgconf: missing argument after --prefix" | |
| 630 } else { | |
| 631 set pkgconf::prefix_arg $args([incr i]) | |
| 632 } | |
| 633 } | |
| 634 continue | |
| 635 } | |
| 636 | |
| 637 # --installdir is a useful alias for prefix. | |
| 638 if { [regexp -- {^-?-install_?dir=?(.*)$} $args($i) dummy match1] == 1 } { | |
| 639 if { $match1 != "" } { | |
| 640 set pkgconf::prefix_arg $match1 | |
| 641 } else { | |
| 642 if { $i == $argc } { | |
| 643 fatal_error "pkgconf: missing argument after --installdir" | |
| 644 } else { | |
| 645 set pkgconf::prefix_arg $args([incr i]) | |
| 646 } | |
| 647 } | |
| 648 continue | |
| 649 } | |
| 650 | |
| 651 | |
| 652 # Now check for a --target arg. The -target must match exactly, | |
| 653 # but there can be one leading hyphen that gets ignored. The | |
| 654 # target can be part of the same argument (with an = in between) | |
| 655 # or it can be all of the next argument. | |
| 656 # | |
| 657 # This code will match spuriously with --targetxxx, i.e. the | |
| 658 # = is optional. This is harmless. | |
| 659 # | |
| 660 # The target is not validated at this point, that happens after | |
| 661 # reading in the targets file. It is possible to specify | |
| 662 # several --target arguments, and only the last one takes | |
| 663 # effect. | |
| 664 if { [regexp -- {^-?-target=?([_a-zA-Z0-9]*)$} $args($i) dummy match1] == 1 } { | |
| 665 if { $match1 != "" } { | |
| 666 set pkgconf::target_arg $match1 | |
| 667 } else { | |
| 668 if { $i == $argc } { | |
| 669 fatal_error "pkgconf: missing argument after --target" | |
| 670 } else { | |
| 671 set pkgconf::target_arg $args([incr i]) | |
| 672 } | |
| 673 } | |
| 674 continue | |
| 675 } | |
| 676 | |
| 677 # Ditto for --platform. | |
| 678 if { [regexp -- {^-?-platform=?([_a-zA-Z0-9]*)$} $args($i) dummy match1] == 1 } { | |
| 679 if { $match1 != "" } { | |
| 680 set pkgconf::platform_arg $match1 | |
| 681 } else { | |
| 682 if { $i == $argc } { | |
| 683 fatal_error "pkgconf: missing argument after --platform" | |
| 684 } else { | |
| 685 set pkgconf::platform_arg $args([incr i]) | |
| 686 } | |
| 687 } | |
| 688 continue | |
| 689 } | |
| 690 | |
| 691 # And for --startup. | |
| 692 if { [regexp -- {^-?-startup=?([_a-zA-Z0-9]*)$} $args($i) dummy match1] == 1 } { | |
| 693 if { $match1 != "" } { | |
| 694 set pkgconf::startup_arg $match1 | |
| 695 } else { | |
| 696 if { $i == $argc } { | |
| 697 fatal_error "pkgconf: missing argument after --startup" | |
| 698 } else { | |
| 699 set pkgconf::startup_arg $args([incr i]) | |
| 700 } | |
| 701 } | |
| 702 continue | |
| 703 } | |
| 704 | |
| 705 # Now for --disable-<package>. The disabled packages are stored | |
| 706 # in a simple list. | |
| 707 if { [regexp -- {^-?-disable-?=?([_a-zA-Z0-9]*)$} $args($i) dummy match1] == 1 } { | |
| 708 if { $match1 != "" } { | |
| 709 lappend pkgconf::disable_args $match1 | |
| 710 } else { | |
| 711 if { $i == $argc } { | |
| 712 fatal_error "pkgconf: missing argument after --disable" | |
| 713 } else { | |
| 714 lappend pkgconf::disable_args $args([incr i]) | |
| 715 } | |
| 716 } | |
| 717 continue | |
| 718 } | |
| 719 | |
| 720 # The same for --enable-<package>. | |
| 721 if { [regexp -- {^-?-enable-?=?([_a-zA-Z0-9]*)$} $args($i) dummy match1] == 1 } { | |
| 722 if { $match1 != "" } { | |
| 723 lappend pkgconf::enable_args $match1 | |
| 724 } else { | |
| 725 if { $i == $argc } { | |
| 726 fatal_error "pkgconf: missing argument after --enable" | |
| 727 } else { | |
| 728 lappend pkgconf::enable_args $args([incr i]) | |
| 729 } | |
| 730 } | |
| 731 continue | |
| 732 } | |
| 733 | |
| 734 # And for --<package>-version=xxx | |
| 735 # These versions are stored in an array indexed by the | |
| 736 # package string. | |
| 737 if {[regexp -- {^-?-([_a-zA-Z0-9]+)-?version=?([_\.a-zA-Z0-9]*)$} $args($i) dummy match1 match2] == 1} { | |
| 738 if { $match2 != "" } { | |
| 739 set pkgconf::version_args($match1) $match2 | |
| 740 } else { | |
| 741 if { $i == $argc } { | |
| 742 fatal_error "pkgconf: missing argument after --$match1-version" | |
| 743 } else { | |
| 744 set pkgconf::version_args($match1) $args([incr i]) | |
| 745 } | |
| 746 } | |
| 747 continue | |
| 748 } | |
| 749 | |
| 750 # For each of the known compiler flags, check for a definition of | |
| 751 # this flag. The flags are stored in an array cflags_args(). | |
| 752 # Note that an empty string is legal, so that the default flags | |
| 753 # from the targets file can be disabled. | |
| 754 set its_a_flag 0 | |
| 755 foreach flag $pkgconf::known_compiler_flags { | |
| 756 if { [regexp -- "^[set flag]=(.*)\$" $args($i) dummy match1] == 1 } { | |
| 757 set pkgconf::cflags_args($flag) $match1 | |
| 758 set its_a_flag 1 | |
| 759 break | |
| 760 } | |
| 761 } | |
| 762 if { $its_a_flag != 0 } { | |
| 763 continue | |
| 764 } | |
| 765 | |
| 766 # An unrecognised argument. | |
| 767 fatal_error "pkgconf: invalid argument $args($i)" | |
| 768 } | |
| 769 } | |
| 770 | |
| 771 # Under Windows it is desirable to do some checking on any directories that | |
| 772 # have been provided. Some cygwin pathnames that a user might supply are | |
| 773 # not acceptable to Tcl. | |
| 774 if { $pkgconf::windows_host } { | |
| 775 set pkgconf::component_repository [get_pathname_for_tcl $pkgconf::component_repository] | |
| 776 set pkgconf::build_tree [get_pathname_for_tcl $pkgconf::build_tree] | |
| 777 if { $pkgconf::prefix_arg != "" } { | |
| 778 set pkgconf::prefix_arg [get_pathname_for_tcl $pkgconf::prefix_arg] | |
| 779 } | |
| 780 } | |
| 781 | |
| 782 # Enabling this facilitates testing of the parsing code. | |
| 783 if { 0 } { | |
| 784 puts "component repository is $pkgconf::component_repository" | |
| 785 puts "build tree is $pkgconf::build_tree" | |
| 786 puts "prefix_arg is $pkgconf::prefix_arg" | |
| 787 puts "list_targets_arg is $pkgconf::list_targets_arg" | |
| 788 puts "list_packages_arg is $pkgconf::list_packages_arg" | |
| 789 puts "list_pkgdata_arg is $pkgconf::list_pkgdata_arg" | |
| 790 puts "list_flags_arg is $pkgconf::list_flags_arg" | |
| 791 puts "no_windows_arg is $pkgconf::no_windows_arg" | |
| 792 puts "target_arg is $pkgconf::target_arg" | |
| 793 puts "platform_arg is $pkgconf::platform_arg" | |
| 794 puts "startup_arg is $pkgconf::startup_arg" | |
| 795 puts "disable_args is $pkgconf::disable_args" | |
| 796 puts "enable_args is $pkgconf::enable_args" | |
| 797 puts "force_arg is $pkgconf::force_arg" | |
| 798 puts "defaults_arg is $pkgconf::defaults_arg" | |
| 799 puts "use_links_arg is $pkgconf::use_links_arg" | |
| 800 puts "use_copies_arg is $pkgconf::use_copies_arg" | |
| 2 | 801 puts "debug_arg is $pkgconf::debug_arg" |
| 802 puts "nodebug_arg is $pkgconf::nodebug_arg" | |
| 0 | 803 foreach i [array names pkgconf::version_args] { |
| 804 puts "Package $i needs version $pkgconf::version_args($i)" | |
| 805 } | |
| 806 foreach flag [array names pkgconf::cflags_args] { | |
| 807 puts "Compiler flag $flag has value $pkgconf::cflags_args($flag)" | |
| 808 } | |
| 809 exit 0 | |
| 810 } | |
| 811 | |
| 812 } | |
| 813 | |
| 814 # | |
| 815 # Display help information if the user has typed --help, -H, --H, or -help. | |
| 816 # The help text uses two hyphens for consistency with configure. | |
| 817 # Arguably this should change. | |
| 818 # | |
| 819 # Not all legal command line arguments are listed. Some of the command | |
| 820 # line arguments like --flags are intended for internal use only. | |
| 821 # | |
| 822 # NOTE: if this command is being invoked from a shell script that sets | |
| 823 # the defaults for a particular architecture then the information will not | |
| 824 # be completely accurate. There is no easy solution for this problem. | |
| 825 # | |
| 826 # NOTE: it would be a really good idea to give an example command line. | |
| 827 # Unfortunately this command line must include a target architecture, | |
| 828 # and there is no sensible default for that. | |
| 829 # | |
| 830 proc pkgconf::argument_help { } { | |
| 831 | |
| 832 puts "Usage: pkgconf \[options\]" | |
| 833 puts "Available options are:" | |
| 834 puts " --help : display this text." | |
| 835 puts " --packages : list all packages." | |
| 836 puts " --targets : list all possible targets." | |
| 837 puts " --target=<arch> : target the specified architecture." | |
| 838 puts " --platform=sim : target the simulator rather than hardware." | |
| 839 puts " --startup=rom : generate code suitable for ROMming." | |
| 840 puts " --disable-<pkg> : disable a given package." | |
| 841 puts " --enable-<pkg> : enable a given package." | |
| 842 puts " --<pkg>-version=v0.3 : use a specific version of a package." | |
| 843 puts " --defaults : use default settings instead of the save file." | |
| 844 puts " --srcdir=<dir> : specify location of the component repository." | |
| 845 puts " --builddir=<dir> : specify location of the build directory." | |
| 846 puts " --prefix=<dir> : specify location of the install directory." | |
| 847 } | |
| 848 | |
| 849 # }}} | |
| 850 # {{{ Packages file | |
| 851 | |
| 852 # ---------------------------------------------------------------------------- | |
| 853 # The component repository should contain a file "packages" containing details | |
| 854 # of all supported packages. This file is actually an executable Tcl script | |
| 855 # containing instances of the "package" command, which takes three arguments. | |
| 856 # It is necessary to update the variables pkgconf::known_packages and | |
| 857 # pkgconf::package_data. | |
| 858 # | |
| 859 | |
| 860 proc pkgconf::read_packages { } { | |
| 861 | |
| 862 ASSERT { $pkgconf::component_repository != "" } | |
| 863 ASSERT { [array names pkgconf::package_data] == "" } | |
| 864 ASSERT { $pkgconf::known_packages == "" } | |
| 865 | |
| 866 # A safe interpreter is used to process the packages file. | |
| 867 # This is somewhat overcautious, but it is also harmless. | |
| 868 # The following two commands are made accessible to the slave | |
| 869 # interpreter and are responsible for updating the actual data. | |
| 870 proc set_package_data { name value } { | |
| 2 | 871 set ::pkgconf::package_data($name) $value |
| 0 | 872 } |
| 873 proc add_known_package { name } { | |
| 2 | 874 lappend ::pkgconf::known_packages $name |
| 0 | 875 } |
| 876 | |
| 877 # Create the parser, add the aliased commands, and then define | |
| 878 # the routines that do the real work. | |
| 879 set parser [interp create -safe] | |
| 880 $parser alias set_package_data pkgconf::set_package_data | |
| 881 $parser alias add_known_package pkgconf::add_known_package | |
| 882 | |
| 883 $parser eval { | |
| 884 | |
| 885 set current_package "" | |
| 886 | |
| 887 proc package { name body } { | |
| 888 | |
| 889 add_known_package $name | |
| 890 set_package_data "$name,alias" $name | |
| 891 set_package_data "$name,dir" "" | |
| 892 set_package_data "$name,versions" "" | |
| 893 set_package_data "$name,default" 0 | |
| 894 set_package_data "$name,incdir" "" | |
| 895 set_package_data "$name,hardware" 0 | |
| 896 | |
| 897 # Evaluate the body such that the commands know what the current package is. | |
| 898 set ::current_package $name | |
| 899 eval $body | |
| 900 set ::current_package "" | |
| 901 } | |
| 902 | |
| 903 proc alias { str } { | |
| 904 set_package_data "$::current_package,alias" $str | |
| 905 } | |
| 906 | |
| 907 # The remaining commands are basically clones of alias. | |
| 908 proc directory { dir } { | |
| 909 set_package_data "$::current_package,dir" $dir | |
| 910 } | |
| 911 | |
| 912 proc default_value { val } { | |
| 913 set_package_data "$::current_package,default" $val | |
| 914 } | |
| 915 | |
| 916 proc include_dir { dir } { | |
| 917 set_package_data "$::current_package,incdir" $dir | |
| 918 } | |
| 919 | |
| 920 proc hardware { } { | |
| 921 set_package_data "$::current_package,hardware" 1 | |
| 922 } | |
| 923 } | |
| 924 | |
| 925 # The parser is ready to evaluate the script. To avoid having to give the | |
| 926 # safe interpreter file I/O capabilities, the file is actually read in | |
| 927 # here and then evaluated. | |
| 928 set filename [file join $pkgconf::component_repository "packages"] | |
| 929 set status [ catch { | |
| 930 set fd [open $filename r] | |
| 931 set script [read $fd] | |
| 932 close $fd | |
| 933 $parser eval $script | |
| 934 } message] | |
| 935 | |
| 936 if { $status != 0 } { | |
| 937 pkgconf::fatal_error "Unexpected error while processing $filename\n$message" | |
| 938 } | |
| 939 | |
| 940 # The interpreter and the aliased commands are no longer required. | |
| 941 rename set_package_data {} | |
| 942 rename add_known_package {} | |
| 943 interp delete $parser | |
| 944 | |
| 945 # At this stage the packages file has been read in. It is a good idea to | |
| 946 # check that all of these packages are present and correct, and incidentally | |
| 947 # figure out which versions are present. | |
| 948 foreach pkg $pkgconf::known_packages { | |
| 949 | |
| 950 set pkgdir [file join $pkgconf::component_repository $pkgconf::package_data($pkg,dir)] | |
| 951 if { ![file exists $pkgdir] || ![file isdir $pkgdir] } { | |
| 952 fatal_error \ | |
| 953 "The file [file join $pkgconf::component_repository "packages"] lists a package\ | |
| 954 $pkg which should be present in $pkgdir. This package is missing." | |
| 955 } | |
| 956 | |
| 957 # Each subdirectory should correspond to a release. A utility routine | |
| 958 # is available for this. | |
| 959 set pkgconf::package_data($pkg,versions) [locate_subdirs $pkgdir] | |
| 960 if { $pkgconf::package_data($pkg,versions) == "" } { | |
| 961 fatal_error "The package $pkg does not contain any version directories." | |
| 962 } | |
| 963 | |
| 964 # Sort all the versions using a version-aware comparison version | |
| 965 set pkgconf::package_data($pkg,versions) [ | |
| 966 lsort -command pkgconf::cdl_compare_version $pkgconf::package_data($pkg,versions) | |
| 967 ] | |
| 968 } | |
| 969 | |
| 970 # Handle the --packages argument. | |
| 971 if { $pkgconf::list_packages_arg != 0 } { | |
| 972 | |
| 973 # The user wants to know about all the arguments. Just to be fancy | |
| 974 # this code does some alignment. | |
| 975 set name_maxlen 0 | |
| 976 | |
| 977 foreach pkg $pkgconf::known_packages { | |
| 978 if { [string length $pkg] > $name_maxlen} { | |
| 979 set name_maxlen [string length $pkg] | |
| 980 } | |
| 981 } | |
| 982 | |
| 983 puts "Known packages are:" | |
| 984 foreach pkg $pkgconf::known_packages { | |
| 985 puts "[format " %-*s : " $name_maxlen $pkg]" | |
| 986 puts " Available versions: $pkgconf::package_data($pkg,versions)" | |
| 987 puts " Aliases : $pkgconf::package_data($pkg,alias)" | |
| 988 if { $pkgconf::package_data($pkg,hardware) } { | |
| 989 puts " This package is only available on specific hardware." | |
| 990 } | |
| 991 if { $pkgconf::package_data($pkg,default) } { | |
| 992 puts " This package is enabled by default." | |
| 993 } else { | |
| 994 puts " This package is disabled by default." | |
| 995 } | |
| 996 } | |
| 997 } | |
| 998 | |
| 999 # Ditto for the --pkgdata argument. In this case the data is intended for use | |
| 1000 # by other programs, and is not necessarily intelligible to users. | |
| 1001 if { $pkgconf::list_pkgdata_arg != 0 } { | |
| 1002 foreach pkg $pkgconf::known_packages { | |
| 1003 set dir [file join $pkgconf::package_data($pkg,dir) [lindex $pkgconf::package_data($pkg,versions) 0]] | |
| 1004 set dir [file nativename $dir] | |
| 1005 if { $pkgconf::windows_host != 0 } { | |
| 1006 regsub -all {\\} $dir {\\\\} dir | |
| 1007 } | |
| 1008 set alias [get_build_alias $pkg] | |
| 1009 puts "\"$pkg\" \"$alias\" \"$dir\"" | |
| 1010 } | |
| 1011 } | |
| 1012 } | |
| 1013 | |
| 1014 # | |
| 1015 # Given a package name as supplied by the user, return the internal package name. | |
| 1016 # This involves searching through the list of aliases. | |
| 1017 # | |
| 1018 proc pkgconf::find_package { name } { | |
| 1019 | |
| 1020 foreach pkg $pkgconf::known_packages { | |
| 1021 | |
| 1022 if { [string toupper $pkg] == [string toupper $name] } { | |
| 1023 return $pkg | |
| 1024 } | |
| 1025 | |
| 1026 foreach alias $pkgconf::package_data($pkg,alias) { | |
| 1027 if { [string toupper $alias] == [string toupper $name] } { | |
| 1028 return $pkg | |
| 1029 } | |
| 1030 } | |
| 1031 } | |
| 1032 | |
| 1033 return "" | |
| 1034 } | |
| 1035 | |
| 1036 # | |
| 1037 # Given a package name, return the first alias string. This is useful for | |
| 1038 # output code. | |
| 1039 # | |
| 1040 proc pkgconf::get_package_alias { name } { | |
| 1041 | |
| 1042 pkgconf::ASSERT { [lsearch -exact $pkgconf::known_packages $name] != -1 } | |
| 1043 set alias [lindex $pkgconf::package_data($name,alias) 0] | |
| 1044 return $alias | |
| 1045 } | |
| 1046 | |
| 1047 # | |
| 1048 # Does a given package actually exist ? This copes with aliases | |
| 1049 # as well. | |
| 1050 proc pkgconf::is_package { name } { | |
| 1051 | |
| 1052 ASSERT { $name != "" } | |
| 1053 | |
| 1054 set result 0 | |
| 1055 set name [find_package $name] | |
| 1056 if { $name != "" } { | |
| 1057 set result 1 | |
| 1058 } | |
| 1059 return $result | |
| 1060 } | |
| 1061 | |
| 1062 # | |
| 1063 # Is a particular package a hardware-specific package ? This code | |
| 1064 # deals with aliases as well | |
| 1065 proc pkgconf::is_hardware_package { name } { | |
| 1066 | |
| 1067 ASSERT { $name != "" } | |
| 1068 | |
| 1069 set name [find_package $name] | |
| 1070 ASSERT { $name != "" } | |
| 1071 | |
| 1072 set result 0 | |
| 1073 if { $pkgconf::package_data($name,hardware) != 0 } { | |
| 1074 set result 1 | |
| 1075 } | |
| 1076 return $result | |
| 1077 } | |
| 1078 | |
| 1079 # | |
| 1080 # Is a particular version string valid for the given package ? | |
| 1081 proc pkgconf::is_valid_version { pkg version } { | |
| 1082 | |
| 1083 ASSERT { $pkg != "" } | |
| 1084 ASSERT { $version != "" } | |
| 1085 | |
| 1086 set pkg [find_package $pkg] | |
| 1087 ASSERT { $pkg != "" } | |
| 1088 | |
| 1089 set result 0 | |
| 1090 set index [lsearch -exact $pkgconf::package_data($pkg,versions) $version] | |
| 1091 if { $index != -1 } { | |
| 1092 set result 1 | |
| 1093 } | |
| 1094 return $result | |
| 1095 } | |
| 1096 | |
| 1097 # }}} | |
| 1098 # {{{ Targets file | |
| 1099 | |
| 1100 # ---------------------------------------------------------------------------- | |
| 1101 # The handling of the targets file is similar to that for the packages file, | |
| 1102 # but a targets file is a bit more complicated. | |
| 1103 # | |
| 1104 | |
| 1105 proc pkgconf::read_targets { } { | |
| 1106 | |
| 1107 ASSERT { $pkgconf::component_repository != "" } | |
| 1108 ASSERT { [array names pkgconf::target_data] == "" } | |
| 1109 ASSERT { $pkgconf::known_targets == "" } | |
| 1110 ASSERT { $pkgconf::known_compiler_flags != "" } | |
| 1111 | |
| 1112 proc add_known_target { name } { | |
| 2 | 1113 lappend ::pkgconf::known_targets $name |
| 1114 set ::pkgconf::target_data($name,alias) $name | |
| 1115 set ::pkgconf::target_data($name,prefix) "" | |
| 1116 set ::pkgconf::target_data($name,known_platforms) "" | |
| 1117 set ::pkgconf::target_data($name,packages) "" | |
| 0 | 1118 } |
| 1119 proc add_known_platform { arch name } { | |
| 2 | 1120 lappend ::pkgconf::target_data($arch,known_platforms) $name |
| 1121 set ::pkgconf::target_data($arch,$name,alias) "" | |
| 1122 set ::pkgconf::target_data($arch,$name,startup) "" | |
| 1123 set ::pkgconf::target_data($arch,$name,packages) "" | |
| 0 | 1124 } |
| 1125 proc set_target_data { name value } { | |
| 2 | 1126 set ::pkgconf::target_data($name) $value |
| 0 | 1127 } |
| 1128 | |
| 1129 set parser [interp create -safe] | |
| 1130 interp share {} stdout $parser | |
| 1131 $parser alias set_target_data pkgconf::set_target_data | |
| 1132 $parser alias add_known_target pkgconf::add_known_target | |
| 1133 $parser alias add_known_platform pkgconf::add_known_platform | |
| 1134 $parser eval [list set known_compiler_flags $pkgconf::known_compiler_flags] | |
| 1135 | |
| 1136 $parser eval { | |
| 1137 | |
| 1138 set current_target "" | |
| 1139 set current_platform "" | |
| 1140 | |
| 1141 proc target { name body } { | |
| 1142 | |
| 1143 add_known_target $name | |
| 1144 | |
| 1145 # Evaluate the body such that the commands know what the current target is. | |
| 1146 set ::current_target $name | |
| 1147 eval $body | |
| 1148 set ::current_target "" | |
| 1149 } | |
| 1150 | |
| 1151 proc alias { str } { | |
| 1152 | |
| 1153 # If processing a platform body, update the platform data. Otherwise update the | |
| 1154 # target data. There should be only one alias command per body. | |
| 1155 if { $::current_platform != "" } { | |
| 1156 set_target_data "$::current_target,$::current_platform,alias" $str | |
| 1157 } else { | |
| 1158 set_target_data "$::current_target,alias" $str | |
| 1159 } | |
| 1160 } | |
| 1161 | |
| 1162 proc command_prefix { str } { | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1163 # Allow the command prefix to be overridden on a per-platform basis |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1164 if { $::current_platform != "" } { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1165 set_target_data "$::current_target,$::current_platform,prefix" $str |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1166 } else { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1167 set_target_data "$::current_target,prefix" $str |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1168 } |
| 0 | 1169 } |
| 1170 | |
| 1171 proc packages { list } { | |
| 1172 if { $::current_platform != "" } { | |
| 1173 set_target_data "$::current_target,$::current_platform,packages" $list | |
| 1174 } else { | |
| 1175 set_target_data "$::current_target,packages" $list | |
| 1176 } | |
| 1177 } | |
| 1178 | |
| 1179 proc hal { dir } { | |
| 1180 if { $::current_platform != "" } { | |
| 1181 set_target_data "$::current_target,$::current_platform,haldir" $dir | |
| 1182 } else { | |
| 1183 set_target_data "$::current_target,haldir" $dir | |
| 1184 } | |
| 1185 } | |
| 1186 | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1187 proc base_platform { str } { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1188 if { $::current_platform != "" } { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1189 set_target_data "$::current_target,$::current_platform,base_platform" $str |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1190 } else { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1191 set_target_data "$::current_target,base_platform" $str |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1192 } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1193 } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1194 |
| 0 | 1195 proc platform { name body } { |
| 1196 | |
| 1197 add_known_platform $::current_target $name | |
| 1198 | |
| 1199 set ::current_platform $name | |
| 1200 eval $body | |
| 1201 set ::current_platform "" | |
| 1202 } | |
| 1203 | |
| 1204 proc startup { types } { | |
| 1205 set_target_data "$::current_target,$::current_platform,startup" $types | |
| 1206 } | |
| 1207 | |
| 1208 # The cflags command is much more complicated than the others. The argument | |
| 1209 # to cflags should be a list of paired data, e.g. ERRFLAGS -Wall. | |
| 1210 # The first entry in each pair should be one of the known compiler | |
| 1211 # flags, the second one should be its value. | |
| 1212 proc cflags { str } { | |
| 1213 | |
| 1214 set arg_count [llength $str] | |
| 1215 if { ($arg_count % 2) != 0 } { | |
| 1216 error "Invalid argument list to cflags command in $current_target" | |
| 1217 } | |
| 1218 for { set i 0 } { $i < $arg_count } { incr i 2 } { | |
| 1219 set flag [lindex $str $i] | |
| 1220 set value [lindex $str [expr $i + 1]] | |
| 1221 if { [lsearch -exact $::known_compiler_flags $flag] == -1 } { | |
| 1222 error "Invalid compiler flag $flag for target $::current_target" | |
| 1223 } | |
| 1224 if { $::current_platform != "" } { | |
| 1225 set_target_data "$::current_target,$::current_platform,cflags,$flag" $value | |
| 1226 } else { | |
| 1227 set_target_data "$::current_target,cflags,$flag" $value | |
| 1228 } | |
| 1229 } | |
| 1230 } | |
| 1231 | |
| 1232 } | |
| 1233 | |
| 1234 # The parser is ready to evaluate the script. To avoid having to give the | |
| 1235 # safe interpreter file I/O capabilities, the file is actually read in | |
| 1236 # here and then evaluated. | |
| 1237 set filename [file join $pkgconf::component_repository "targets"] | |
| 1238 set status [ catch { | |
| 1239 set fd [open $filename r] | |
| 1240 set script [read $fd] | |
| 1241 close $fd | |
| 1242 $parser eval $script | |
| 1243 } message] | |
| 1244 | |
| 1245 if { $status != 0 } { | |
| 1246 puts "Unexpected error while processing $filename\n$message" | |
| 1247 exit 1 | |
| 1248 } | |
| 1249 | |
| 1250 # The interpreter and the aliased commands are no longer required. | |
| 1251 rename add_known_target {} | |
| 1252 rename add_known_platform {} | |
| 1253 rename set_target_data {} | |
| 1254 interp delete $parser | |
| 1255 | |
| 1256 # The targets file has been read in, so it is time for some consistency checks. | |
| 1257 foreach target $pkgconf::known_targets { | |
| 1258 | |
| 1259 # If this target involves some special packages, check that these | |
| 1260 # packages were actually defined in the packages file. Also check | |
| 1261 # that these packages are listed as hardware packages so that | |
| 1262 # they will not be enabled by default. | |
| 1263 ASSERT { [info exists pkgconf::target_data($target,packages)] } | |
| 1264 foreach pkg $pkgconf::target_data($target,packages) { | |
| 1265 | |
| 1266 if { [is_package $pkg] == 0 } { | |
| 1267 fatal_error \ | |
| 1268 "The targets file $filename lists a package $pkg\ | |
| 1269 for the $target architecture. This package is not listed\ | |
| 1270 in the packages file." | |
| 1271 | |
| 1272 } elseif { [is_hardware_package $pkg] == 0 } { | |
| 1273 | |
| 1274 fatal_error \ | |
| 1275 "The targets file $filename lists a package $pkg\ | |
| 1276 for the $target architecture. According to the packages\ | |
| 1277 file this package is not hardware-specific." | |
| 1278 } | |
| 1279 } | |
| 1280 | |
| 1281 ASSERT { [info exists pkgconf::target_data($target,known_platforms)] } | |
| 1282 foreach platform $pkgconf::target_data($target,known_platforms) { | |
| 1283 | |
| 1284 ASSERT { [info exists pkgconf::target_data($target,$platform,packages)] } | |
| 1285 foreach pkg $pkgconf::target_data($target,packages) { | |
| 1286 | |
| 1287 if { [is_package $pkg] == 0 } { | |
| 1288 | |
| 1289 fatal_error \ | |
| 1290 "The target file $filename lists a package $pkg\ | |
| 1291 for the $target architecture and the $platform platform.\ | |
| 1292 This package is not listed in the packages file." | |
| 1293 | |
| 1294 } elseif { [is_hardware_package $pkg] == 0 } { | |
| 1295 | |
| 1296 fatal_error \ | |
| 1297 "The target file $filename lists a package $pkg\ | |
| 1298 for the $target architecture and the $platform platform.\ | |
| 1299 According to the packages file this package is not hardware-specific." | |
| 1300 } | |
| 1301 } | |
| 1302 } | |
| 1303 | |
| 1304 # Also check that all required data for all targets and platforms has | |
| 1305 # been supplied. A command prefix is required, as is a startup list. | |
| 1306 | |
| 1307 if { [llength $pkgconf::target_data($target,known_platforms)] == 0 } { | |
| 1308 warning "The targets file $filename lists the $target architecture but no platforms." | |
| 1309 set index [lsearch -exact $pkgconf::known_targets $target] | |
| 1310 ASSERT { $index != -1 } | |
| 1311 set pkgconf::known_targets [lreplace $pkgconf::known_targets $index $index] | |
| 1312 continue | |
| 1313 } | |
| 1314 | |
| 1315 foreach platform $pkgconf::target_data($target,known_platforms) { | |
| 1316 if { [llength $pkgconf::target_data($target,$platform,startup)] == 0 } { | |
| 1317 fatal_error \ | |
| 1318 "The targets file $filename does not list any startup options for target $target, platform $platform." | |
| 1319 } | |
| 1320 } | |
| 1321 } | |
| 1322 | |
| 1323 # At this stage there may be no targets left over. | |
| 1324 if { [llength $pkgconf::known_targets] == 0 } { | |
| 1325 fatal_error "The targets file $filename does not list any usable targets." | |
| 1326 } | |
| 1327 | |
| 1328 # All the directories exist. Did the user ask for a list of all targets ? | |
| 1329 if { $pkgconf::list_targets_arg } { | |
| 1330 | |
| 1331 # The user wants to know about all the targets. Just to be fancy | |
| 1332 # this code does some alignment. | |
| 1333 set name_maxlen 0 | |
| 1334 | |
| 1335 foreach target $pkgconf::known_targets { | |
| 1336 if { [string length $target] > $name_maxlen} { | |
| 1337 set name_maxlen [string length $target] | |
| 1338 } | |
| 1339 } | |
| 1340 | |
| 1341 puts "Known targets:" | |
| 1342 foreach target $pkgconf::known_targets { | |
| 1343 | |
| 1344 puts "[format " %-*s : aliases $pkgconf::target_data($target,alias)" $name_maxlen $target]" | |
| 1345 | |
| 1346 set packages $pkgconf::target_data($target,packages) | |
| 1347 if { [llength $packages] > 0 } { | |
| 1348 puts " Required packages" | |
| 1349 foreach package $packages { | |
| 1350 puts " [pkgconf::get_package_alias $package] ($package)" | |
| 1351 } | |
| 1352 } | |
| 1353 | |
| 1354 foreach platform $pkgconf::target_data($target,known_platforms) { | |
| 1355 puts " Platform $platform, supported startups $pkgconf::target_data($target,$platform,startup)" | |
| 1356 set packages $pkgconf::target_data($target,$platform,packages) | |
| 1357 if { [llength $packages] > 0 } { | |
| 1358 puts " Required packages" | |
| 1359 foreach package $packages { | |
| 1360 puts " [pkgconf::get_package_alias $package] ($package)" | |
| 1361 } | |
| 1362 } | |
| 1363 } | |
| 1364 } | |
| 1365 } | |
| 1366 } | |
| 1367 | |
| 1368 # | |
| 1369 # Given a target name as supplied by the user, return the internal target name. | |
| 1370 # This involves searching through the list of aliases. | |
| 1371 # | |
| 1372 proc pkgconf::find_target { name } { | |
| 1373 | |
| 1374 foreach target $pkgconf::known_targets { | |
| 1375 | |
| 1376 if { [string toupper $target] == [string toupper $name] } { | |
| 1377 return $target | |
| 1378 } | |
| 1379 | |
| 1380 foreach alias $pkgconf::target_data($target,alias) { | |
| 1381 if { [string toupper $alias] == [string toupper $name] } { | |
| 1382 return $target | |
| 1383 } | |
| 1384 } | |
| 1385 } | |
| 1386 | |
| 1387 return "" | |
| 1388 } | |
| 1389 | |
| 1390 # | |
| 1391 # Ditto but for a given platform name. The target name must be known already. | |
| 1392 # | |
| 1393 | |
| 1394 proc pkgconf::find_platform { target name } { | |
| 1395 | |
| 1396 pkgconf::ASSERT { [lsearch -exact $pkgconf::known_targets $target] != -1 } | |
| 1397 | |
| 1398 foreach platform $pkgconf::target_data($target,known_platforms) { | |
| 1399 | |
| 1400 if { [string toupper $platform] == [string toupper $name] } { | |
| 1401 return $platform | |
| 1402 } | |
| 1403 | |
| 1404 foreach alias $pkgconf::target_data($target,$platform,alias) { | |
| 1405 | |
| 1406 if { [string toupper $alias] == [string toupper $name] } { | |
| 1407 return $platform | |
| 1408 } | |
| 1409 } | |
| 1410 } | |
| 1411 return "" | |
| 1412 } | |
| 1413 | |
| 1414 # | |
| 1415 # Given a target name, return the first alias. This is useful for output | |
| 1416 # code. | |
| 1417 # | |
| 1418 proc pkgconf::get_target_alias { name } { | |
| 1419 | |
| 1420 pkgconf::ASSERT { [lsearch -exact $pkgconf::known_targets $name] != -1 } | |
| 1421 | |
| 1422 set alias [lindex $pkgconf::target_data($name,alias) 0] | |
| 1423 return $alias | |
| 1424 } | |
| 1425 | |
| 1426 # | |
| 1427 # Ditto for platforms. | |
| 1428 # | |
| 1429 proc pkgconf::get_platform_alias { target name } { | |
| 1430 | |
| 1431 pkgconf::ASSERT { [lsearch -exact $pkgconf::known_targets $target] != -1 } | |
| 1432 pkgconf::ASSERT { [lsearch -exact $pkgconf::target_data($target,known_platforms) $name] != -1 } | |
| 1433 | |
| 1434 set alias [lindex $pkgconf::target_data($target,$name,alias) 0] | |
| 1435 return $alias | |
| 1436 } | |
| 1437 | |
| 1438 # | |
| 1439 # For a given target and platform, return an appropriate set of compiler flags. | |
| 1440 # | |
| 1441 proc pkgconf::get_platform_cflags { target platform flag } { | |
| 1442 | |
| 1443 ASSERT { [lsearch -exact $pkgconf::known_targets $target] != -1 } | |
| 1444 ASSERT { [lsearch -exact $pkgconf::target_data($target,known_platforms) $platform] != -1 } | |
| 1445 ASSERT { [lsearch -exact $pkgconf::known_compiler_flags $flag] != -1 } | |
| 1446 | |
| 1447 # A particular flag may be defined specifically for a platform. | |
| 1448 # Or it may come from the target information. Or there may not be | |
| 1449 # a default value. | |
| 1450 if { [info exists pkgconf::target_data($target,$platform,cflags,$flag)] != 0 } { | |
| 1451 return $pkgconf::target_data($target,$platform,cflags,$flag) | |
| 1452 } elseif { [info exists pkgconf::target_data($target,cflags,$flag)] != 0 } { | |
| 1453 return $pkgconf::target_data($target,cflags,$flag) | |
| 1454 } else { | |
| 1455 return "" | |
| 1456 } | |
| 1457 } | |
| 1458 | |
| 1459 # | |
| 1460 # Is a given target or platform actually valid ? This code copes | |
| 1461 # with aliases as well. | |
| 1462 proc pkgconf::is_target { name } { | |
| 1463 | |
| 1464 ASSERT { $name != "" } | |
| 1465 | |
| 1466 set name [find_target $name] | |
| 1467 set result 0 | |
| 1468 if { $name != "" } { | |
| 1469 set result 1 | |
| 1470 } | |
| 1471 return $result | |
| 1472 } | |
| 1473 | |
| 1474 proc pkgconf::is_platform { target name } { | |
| 1475 | |
| 1476 ASSERT { $target != "" } | |
| 1477 ASSERT { $name != "" } | |
| 1478 | |
| 1479 set target [find_target $target] | |
| 1480 ASSERT { $target != "" } | |
| 1481 | |
| 1482 set name [find_platform $target $name] | |
| 1483 set result 0 | |
| 1484 if { $name != "" } { | |
| 1485 set result 1 | |
| 1486 } | |
| 1487 return $result | |
| 1488 } | |
| 1489 | |
| 1490 proc pkgconf::is_startup { target platform name } { | |
| 1491 | |
| 1492 ASSERT { $target != "" } | |
| 1493 ASSERT { $name != "" } | |
| 1494 | |
| 1495 set target [find_target $target] | |
| 1496 ASSERT { $target != "" } | |
| 1497 | |
| 1498 set platform [find_platform $target $platform] | |
| 1499 ASSERT { $platform != "" } | |
| 1500 | |
| 1501 set index [lsearch -exact $pkgconf::target_data($target,$platform,startup) $name] | |
| 1502 set result 0 | |
| 1503 if { $index != -1 } { | |
| 1504 set result 1 | |
| 1505 } | |
| 1506 return $result | |
| 1507 } | |
| 1508 | |
| 1509 # | |
| 1510 # Get hold of the default platform and startup for a given target. | |
| 1511 | |
| 1512 proc pkgconf::get_default_platform { target } { | |
| 1513 | |
| 1514 ASSERT { $target != "" } | |
| 1515 | |
| 1516 set target [find_target $target] | |
| 1517 ASSERT { $target != "" } | |
| 1518 | |
| 1519 set platform [lindex $pkgconf::target_data($target,known_platforms) 0] | |
| 1520 return $platform | |
| 1521 } | |
| 1522 | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1523 proc pkgconf::get_base_platform { target platform } { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1524 |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1525 ASSERT { $target != "" } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1526 ASSERT { $platform != "" } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1527 |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1528 set target [find_target $target] |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1529 ASSERT { $target != "" } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1530 set platform [find_platform $target $platform] |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1531 ASSERT { $platform != "" } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1532 |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1533 if [info exists pkgconf::target_data($target,$platform,base_platform) ] { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1534 set base_platform [lindex $pkgconf::target_data($target,$platform,base_platform) 0] |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1535 } else { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1536 set base_platform $platform |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1537 } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1538 return $base_platform |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1539 } |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1540 |
| 0 | 1541 proc pkgconf::get_default_startup { target platform } { |
| 1542 | |
| 1543 ASSERT { $target != "" } | |
| 1544 ASSERT { $platform != "" } | |
| 1545 | |
| 1546 set target [find_target $target] | |
| 1547 ASSERT { $target != "" } | |
| 1548 set platform [find_platform $target $platform] | |
| 1549 ASSERT { $platform != "" } | |
| 1550 | |
| 1551 set startup [lindex $pkgconf::target_data($target,$platform,startup) 0] | |
| 1552 return $startup | |
| 1553 } | |
| 1554 | |
| 1555 # }}} | |
| 1556 # {{{ Configuration Data | |
| 1557 | |
| 1558 # {{{ setup_defaults | |
| 1559 | |
| 1560 # ---------------------------------------------------------------------------- | |
| 1561 # The setup_defaults routine is responsible for deciding on default values. | |
| 1562 # If there is only one supported architecture then this can be selected, | |
| 1563 # and then it is also possible to select a platform and a startup mode. | |
| 1564 # All known packages can be enabled by default, and the latest version | |
| 1565 # of each package can be selected. | |
| 1566 # | |
| 1567 # All configuration data is held in the array config_data(). It is | |
| 1568 # important to make sure that all fields are initialised. | |
| 1569 # | |
| 1570 | |
| 1571 proc pkgconf::setup_defaults { } { | |
| 1572 | |
| 1573 ASSERT { [llength [array names pkgconf::config_data] ] == 0 } | |
| 1574 ASSERT { $pkgconf::known_packages != "" } | |
| 1575 ASSERT { $pkgconf::known_targets != "" } | |
| 1576 ASSERT { $pkgconf::build_tree != "" } | |
| 1577 | |
| 1578 set pkgconf::config_data(target) "" | |
| 1579 set pkgconf::config_data(platform) "" | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1580 set pkgconf::config_data(base_platform) "" |
| 0 | 1581 set pkgconf::config_data(startup) "" |
| 1582 set pkgconf::config_data(prefix) "" | |
| 1583 set pkgconf::config_data(use_links) 0 | |
| 1584 | |
| 1585 # Packages fall into a number of different categories. | |
| 1586 # | |
| 1587 # 1) some packages are hardware-specific. They should be enabled | |
| 1588 # by default if that hardware has been selected, but the user | |
| 1589 # must still be able to disable them in case they cause problems. | |
| 1590 # | |
| 1591 # 2) some packages are enabled by default, but can be disabled by | |
| 1592 # the user. There are actually some packages that should never | |
| 1593 # be disabled, especially infra, but that would complicate things. | |
| 1594 # | |
| 1595 # 3) some packages are disabled by default, but can be enabled by | |
| 1596 # the user. | |
| 1597 # | |
| 1598 # The easiest way to track this information is to store the target | |
| 1599 # and platform data, which gives us the hardware packages, plus | |
| 1600 # separate lists of which packages are explicitly enabled or disabled. | |
| 1601 # All other information can be derived from that. | |
| 1602 set pkgconf::config_data(enabled_packages) "" | |
| 1603 set pkgconf::config_data(disabled_packages) "" | |
| 1604 | |
| 1605 # For each package fill in a default version number. | |
| 1606 foreach pkg $pkgconf::known_packages { | |
| 1607 | |
| 1608 ASSERT { $pkgconf::package_data($pkg,versions) != "" } | |
| 1609 ASSERT { [info exists pkgconf::config_data($pkg,version)] == 0 } | |
| 1610 set pkgconf::config_data($pkg,version) [lindex $pkgconf::package_data($pkg,versions) 0] | |
| 1611 } | |
| 1612 | |
| 1613 # If there is only one target architecture, default to it. Also | |
| 1614 # default to the first platform for that target and the first | |
| 1615 # startup for that platform. | |
| 1616 if { [llength $pkgconf::known_targets] == 1 } { | |
| 1617 set pkgconf::config_data(target) [lindex $pkgconf::known_targets 0] | |
| 1618 | |
| 1619 ASSERT { $pkgconf::target_data($pkgconf::config_data(target),known_platforms) != "" } | |
| 1620 set pkgconf::config_data(platform) [get_default_platform $pkgconf::config_data(target)] | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1621 set pkgconf::config_data(base_platform) [get_base_platform $pkgconf::config_data(target) $pkgconf::config_data(platform)] |
| 0 | 1622 |
| 1623 ASSERT { $pkgconf::target_data($pkgconf::config_data(target),$pkgconf::config_data(platform),startup) != "" } | |
| 1624 set pkgconf::config_data(startup) [get_default_startup $pkgconf::config_data(target) $pkgconf::config_data(platform)] | |
| 1625 } | |
| 1626 | |
| 1627 if { [info exists ::env(PKGCONF_USE_LINKS)] } { | |
| 1628 set pkgconf::config_data(use_links) 1 | |
| 1629 } | |
| 1630 | |
| 1631 if { 0 } { | |
| 1632 foreach i [array names pkgconf::config_data] { | |
| 1633 puts "pkgconf::config_data($i) : $pkgconf::config_data($i)" | |
| 1634 } | |
| 1635 exit 0 | |
| 1636 } | |
| 1637 } | |
| 1638 | |
| 1639 # }}} | |
| 1640 # {{{ read_save_file | |
| 1641 | |
| 1642 # ---------------------------------------------------------------------------- | |
| 1643 # The build tree may have a save file. The aim here is that | |
| 1644 # if the user wants to change some aspects of the configuration, e.g. to | |
| 1645 # switch between the eval board and the simulator, it should not be | |
| 1646 # necessary to pass all the command line arguments again. Instead the | |
| 1647 # system should work out past settings and re-use those where possible. | |
| 1648 # | |
| 1649 # This routine should be invoked after the defaults are set up but | |
| 1650 # before the command line arguments take effect. | |
| 1651 # | |
| 1652 # There is a command line argument --defaults which stops the saved | |
| 1653 # values from taking effect. The save file is still read in because | |
| 1654 # it is useful to know what is in the build tree at the moment. | |
| 1655 # | |
| 1656 | |
| 1657 proc pkgconf::read_save_file { } { | |
| 1658 | |
| 1659 ASSERT { $pkgconf::build_tree != "" } | |
| 1660 | |
| 1661 # Get rid of any old settings that might be hanging around. | |
| 1662 foreach i [array names pkgconf::saved_data] { | |
| 1663 unset pkgconf::saved_data($i) | |
| 1664 } | |
| 1665 | |
| 1666 set filename [file join $pkgconf::build_tree "pkgconf.sav"] | |
| 1667 if { [file exists $filename] && [file isfile $filename] } { | |
| 1668 | |
| 1669 # Read in the saved data. A safe interpreter is used, just in case. | |
| 1670 proc set_saved_data { name value } { | |
| 1671 set pkgconf::saved_data($name) $value | |
| 1672 } | |
| 1673 set parser [interp create -safe] | |
| 1674 $parser alias set_saved_data pkgconf::set_saved_data | |
| 1675 | |
| 1676 set status [ catch { | |
| 1677 set fd [open $filename r] | |
| 1678 set script [read $fd] | |
| 1679 close $fd | |
| 1680 $parser eval $script | |
| 1681 } message] | |
| 1682 if { $status != 0 } { | |
| 1683 pkgconf::fatal_error "Unexpected error while reading back save file $filename\n$message" | |
| 1684 } | |
| 1685 | |
| 1686 rename set_saved_data {} | |
| 1687 interp delete $parser | |
| 1688 } | |
| 1689 | |
| 1690 # It is a good idea to check that the data read back is consistent. | |
| 1691 # It is also a good idea to check some aliases, in case something | |
| 1692 # has been renamed between releases. | |
| 1693 if { [info exists pkgconf::saved_data(target)] } { | |
| 1694 | |
| 1695 set target_name [find_target $pkgconf::saved_data(target)] | |
| 1696 if { $target_name == "" } { | |
| 1697 warning "The save file $filename contained an invalid target $pkgconf::saved_data(target). This has been ignored." | |
| 1698 } else { | |
| 1699 set pkgconf::saved_data(target) $target_name | |
| 1700 set pkgconf::config_data(target) $target_name | |
| 1701 set pkgconf::config_data(platform) [get_default_platform $pkgconf::config_data(target)] | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1702 set pkgconf::config_data(base_platform) [get_base_platform $pkgconf::config_data(target) $pkgconf::config_data(platform)] |
| 0 | 1703 set pkgconf::config_data(startup) \ |
| 1704 [get_default_startup $pkgconf::config_data(target) $pkgconf::config_data(platform)] | |
| 1705 } | |
| 1706 } | |
| 1707 | |
| 1708 # There is no point in validating platform or startup unless the target is known. | |
| 1709 if { $pkgconf::config_data(target) != "" } { | |
| 1710 | |
| 1711 ASSERT { $pkgconf::target_data($pkgconf::config_data(target),known_platforms) != "" } | |
| 1712 | |
| 1713 if { [info exists pkgconf::saved_data(platform)] } { | |
| 1714 | |
| 1715 set platform_name [find_platform $pkgconf::config_data(target) $pkgconf::saved_data(platform)] | |
| 1716 if { $platform_name == "" } { | |
| 1717 warning \ | |
| 1718 "The save file $filename specified an unknown platform $pkgconf::saved_data(platform).\ | |
| 1719 The platform $pkgconf::config_data(platform) has been substituted." | |
| 1720 } else { | |
| 1721 set pkgconf::saved_data(platform) $platform_name | |
| 1722 set pkgconf::config_data(platform) $platform_name | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1723 set pkgconf::config_data(base_platform) [get_base_platform $pkgconf::config_data(target) $pkgconf::saved_data(platform)] |
| 0 | 1724 set pkgconf::config_data(startup) [get_default_startup $pkgconf::config_data(target) $platform_name] |
| 1725 } | |
| 1726 | |
| 1727 } | |
| 1728 | |
| 1729 # Currently if there is a target then there is always a platform, | |
| 1730 # possibly the default one. | |
| 1731 ASSERT { $pkgconf::target_data($pkgconf::config_data(target),$pkgconf::config_data(platform),startup) != "" } | |
| 1732 | |
| 1733 if { [info exists pkgconf::saved_data(startup)] } { | |
| 1734 | |
| 1735 if { [is_startup $pkgconf::config_data(target) $pkgconf::config_data(platform) $pkgconf::saved_data(startup)] \ | |
| 1736 == 0 } { | |
| 1737 warning \ | |
| 1738 "The save file $filename specified an unknown startup $pkgconf::saved_data(startup).\ | |
| 1739 $pkgconf::config_data(startup) startup has been substituted." | |
| 1740 } else { | |
| 1741 set pkgconf::config_data(startup) $pkgconf::saved_data(startup) | |
| 1742 } | |
| 1743 } | |
| 1744 } | |
| 1745 | |
| 1746 # There should be an entry listing all packages for which there is | |
| 1747 # a version entry. This can be used to update the version numbers | |
| 1748 # which should be used in this configuration. | |
| 1749 if { [info exists pkgconf::saved_data(versioned_packages) ] != 0 } { | |
| 1750 foreach pkg $pkgconf::saved_data(versioned_packages) { | |
| 1751 | |
| 1752 # Check that there is a saved version string for this package. | |
| 1753 # There should be, but it is not worth worrying about. | |
| 1754 if { [info exists pkgconf::saved_data($pkg,version)] == 0 } { | |
| 1755 continue | |
| 1756 } | |
| 1757 set version $pkgconf::saved_data($pkg,version) | |
| 1758 | |
| 1759 # Does this package still exist ? | |
| 1760 if { [is_package $pkg] == 0 } { | |
| 1761 warning \ | |
| 1762 "The save file $filename specified version $version for package $pkg.\ | |
| 1763 This package does not exist in the current repository, so the version string\ | |
| 1764 has been ignored." | |
| 1765 continue | |
| 1766 } | |
| 1767 set pkg [find_package $pkg] | |
| 1768 ASSERT { $pkg != "" } | |
| 1769 | |
| 1770 # Is the version valid ? | |
| 1771 if { [is_valid_version $pkg $version] == 0 } { | |
| 1772 warning \ | |
| 1773 "The save file $filename specified version $version for package $pkg.\ | |
| 1774 This version is not present in the current repository so the version\ | |
| 1775 string has been ignored." | |
| 1776 } else { | |
| 1777 set pkgconf::config_data($pkg,version) $version | |
| 1778 } | |
| 1779 } | |
| 1780 } | |
| 1781 | |
| 1782 # Now check that all the packages listed in the save file are known. | |
| 1783 # If any are missing then they are just discarded. Known packages | |
| 1784 # are used to update the appropriate current configuration data. | |
| 1785 if { [info exists pkgconf::saved_data(enabled_packages)] == 0 } { | |
| 1786 set pkgconf::saved_data(enabled_packages) "" | |
| 1787 } | |
| 1788 if { [info exists pkgconf::saved_data(disabled_packages)] == 0 } { | |
| 1789 set pkgconf::saved_data(disabled_packages) "" | |
| 1790 } | |
| 1791 | |
| 1792 foreach pkg $pkgconf::saved_data(enabled_packages) { | |
| 1793 | |
| 1794 if { [is_package $pkg] == 0 } { | |
| 1795 warning \ | |
| 1796 "The save file $filename mentioned a package $pkg.\ | |
| 1797 This package does not exist in the current repository and | |
| 1798 has been ignored." | |
| 1799 continue | |
| 1800 } | |
| 1801 | |
| 1802 set pkg [find_package $pkg] | |
| 1803 set index [lsearch -exact $pkgconf::config_data(enabled_packages) $pkg] | |
| 1804 if { $index == -1 } { | |
| 1805 lappend pkgconf::config_data(enabled_packages) $pkg | |
| 1806 } | |
| 1807 } | |
| 1808 | |
| 1809 foreach pkg $pkgconf::saved_data(disabled_packages) { | |
| 1810 | |
| 1811 if { [is_package $pkg] == 0 } { | |
| 1812 warning \ | |
| 1813 "The save file $filename mentioned a package $pkg.\ | |
| 1814 This package does not exist in the current repository and | |
| 1815 has been ignored." | |
| 1816 continue | |
| 1817 } | |
| 1818 | |
| 1819 set pkg [find_package $pkg] | |
| 1820 set index [lsearch -exact $pkgconf::config_data(disabled_packages) $pkg] | |
| 1821 if { $index == -1 } { | |
| 1822 lappend pkgconf::config_data(disabled_packages) $pkg | |
| 1823 } | |
| 1824 | |
| 1825 # Better make sure that a package is not simultaneously enabled and disabled. | |
| 1826 set index [lsearch -exact $pkgconf::config_data(enabled_packages) $pkg] | |
| 1827 if { $index != -1 } { | |
| 1828 set pkgconf::config_data(enabled_packages) [lreplace $pkgconf::config_data(enabled_packages) $index $index] | |
| 1829 } | |
| 1830 } | |
| 1831 | |
| 1832 # Now check for any compiler flags | |
| 1833 foreach flag $pkgconf::known_compiler_flags { | |
| 1834 if { [info exists pkgconf::saved_data(cflags,$flag)] } { | |
| 1835 set pkgconf::config_data(cflags,$flag) $pkgconf::saved_data(cflags,$flag) | |
| 1836 } | |
| 1837 } | |
| 1838 | |
| 1839 # Update the install directory if appropriate. | |
| 1840 # There is not a lot of checking that can be done here. | |
| 1841 if { [info exists pkgconf::saved_data(prefix) ] } { | |
| 1842 set pkgconf::config_data(prefix) $pkgconf::saved_data(prefix) | |
| 1843 } | |
| 1844 | |
| 1845 # And check for the use_links option | |
| 1846 if { [info exists pkgconf::saved_data(use_links)] } { | |
| 1847 set pkgconf::config_data(use_links) $pkgconf::saved_data(use_links) | |
| 1848 } | |
| 1849 | |
| 1850 # Now, possibly undo all of this if the user specified --defaults. | |
| 1851 if { $pkgconf::defaults_arg != 0 } { | |
| 1852 foreach entry [array names pkgconf::config_data] { | |
| 1853 unset pkgconf::config_data($entry) | |
| 1854 } | |
| 1855 setup_defaults | |
| 1856 } | |
| 1857 | |
| 1858 if { 0 } { | |
| 1859 foreach i [array names pkgconf::config_data] { | |
| 1860 puts "pkgconf::config_data($i) : $pkgconf::config_data($i)" | |
| 1861 } | |
| 1862 exit 0 | |
| 1863 } | |
| 1864 } | |
| 1865 | |
| 1866 # }}} | |
| 1867 # {{{ write_save_file | |
| 1868 | |
| 1869 # ---------------------------------------------------------------------------- | |
| 1870 # Outputting the save file. This is a relatively simple operation assuming | |
| 1871 # no file I/O errors happen. The saved_data array is updated with the new | |
| 1872 # contents of the save file. It is not yet clear whether this will be useful, | |
| 1873 # but it should not cause any problems either. | |
| 1874 # | |
| 1875 | |
| 1876 proc pkgconf::write_save_file { } { | |
| 1877 | |
| 1878 # Check for minimal consistency. If any variables are missing then | |
| 1879 # this will be handled (poorly) by the catch statement. | |
| 1880 ASSERT { [info exists pkgconf::config_data(target)] } | |
| 1881 ASSERT { $pkgconf::build_tree != "" } | |
| 1882 | |
| 1883 set savename [file join $pkgconf::build_tree "pkgconf.sav"] | |
| 1884 set open_file "" | |
| 1885 | |
| 1886 set status [catch { | |
| 1887 | |
| 1888 set open_file [open $savename w] | |
| 1889 output_banner $open_file "pkgconf.sav" | |
| 1890 | |
| 1891 if { $pkgconf::config_data(target) != "" } { | |
| 1892 puts $open_file "set_saved_data target $pkgconf::config_data(target)" | |
| 1893 set pkgconf::saved_data(target) $pkgconf::config_data(target) | |
| 1894 } | |
| 1895 if { $pkgconf::config_data(platform) != "" } { | |
| 1896 puts $open_file "set_saved_data platform $pkgconf::config_data(platform)" | |
| 1897 set pkgconf::saved_data(platform) $pkgconf::config_data(platform) | |
| 1898 } | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1899 if { $pkgconf::config_data(base_platform) != "" } { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1900 puts $open_file "set_saved_data base_platform $pkgconf::config_data(base_platform)" |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1901 set pkgconf::saved_data(base_platform) $pkgconf::config_data(base_platform) |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
1902 } |
| 0 | 1903 if { $pkgconf::config_data(startup) != "" } { |
| 1904 puts $open_file "set_saved_data startup $pkgconf::config_data(startup)" | |
| 1905 set pkgconf::saved_data(startup) $pkgconf::config_data(startup) | |
| 1906 } | |
| 1907 if { $pkgconf::config_data(enabled_packages) != "" } { | |
| 1908 # The use of the list command here avoids problems with multiple | |
| 1909 # arguments when the file is read back. | |
| 1910 puts $open_file "set_saved_data enabled_packages [list $pkgconf::config_data(enabled_packages)]" | |
| 1911 set pkgconf::saved_data(enabled_packages) $pkgconf::config_data(enabled_packages) | |
| 1912 } | |
| 1913 if { $pkgconf::config_data(disabled_packages) != "" } { | |
| 1914 puts $open_file "set_saved_data disabled_packages [list $pkgconf::config_data(disabled_packages)]" | |
| 1915 set pkgconf::saved_data(disabled_packages) $pkgconf::config_data(disabled_packages) | |
| 1916 } | |
| 1917 foreach pkg $pkgconf::known_packages { | |
| 1918 ASSERT { [info exists pkgconf::config_data($pkg,version)] } | |
| 1919 puts $open_file "set_saved_data \"$pkg,version\" $pkgconf::config_data($pkg,version)" | |
| 1920 set pkgconf::saved_data($pkg,version) $pkgconf::config_data($pkg,version) | |
| 1921 } | |
| 1922 # This allows the versions to be read back in more easily, even if | |
| 1923 # there is a change to the number of packages. | |
| 1924 puts $open_file "set_saved_data versioned_packages [list $pkgconf::known_packages]" | |
| 1925 | |
| 1926 foreach flag $pkgconf::known_compiler_flags { | |
| 1927 if { [info exists pkgconf::config_data(cflags,$flag)] != 0 } { | |
| 1928 puts $open_file "set_saved_data \"cflags,$flag\" \"$pkgconf::config_data(cflags,$flag)\"" | |
| 1929 } | |
| 1930 } | |
| 1931 if { $pkgconf::config_data(use_links) != 0 } { | |
| 1932 puts $open_file "set_saved_data use_links 1" | |
| 1933 } | |
| 1934 | |
| 1935 puts $open_file "set_saved_data prefix \"$pkgconf::config_data(prefix)\"" | |
| 1936 set pkgconf::saved_data(prefix) $pkgconf::config_data(prefix) | |
| 1937 | |
| 1938 puts $open_file "\n# End of $savename" | |
| 1939 close $open_file | |
| 1940 } message ] | |
| 1941 | |
| 1942 if { $status != 0 } { | |
| 1943 | |
| 1944 if { $open_file != "" } { | |
| 1945 # Whatever error occurred, it happened after the file was opened. | |
| 1946 # This is bad news, the file may be corrupt. To avoid complications, | |
| 1947 # try to delete it. | |
| 1948 catch { | |
| 1949 close $open_file | |
| 1950 file delete $savename | |
| 1951 } | |
| 1952 # Also get rid of the saved_data array. | |
| 1953 foreach i [array names saved_data] { | |
| 1954 unset saved_data($i) | |
| 1955 } | |
| 1956 } | |
| 1957 fatal_error "An unexpected error occurred while generating the save file $savename: $message" | |
| 1958 } | |
| 1959 } | |
| 1960 | |
| 1961 # }}} | |
| 1962 # {{{ process_arguments() | |
| 1963 | |
| 1964 # ---------------------------------------------------------------------------- | |
| 1965 # This procedure takes care of updating the configuration information using | |
| 1966 # the command line arguments, for example if there was an argument specifying | |
| 1967 # a different version for a particular package then it is this procedure | |
| 1968 # which takes care of it. This procedure also takes care of validating the | |
| 1969 # arguments. | |
| 1970 # | |
| 1971 # This procedure should be invoked after setup_defaults has filled in the | |
| 1972 # default values for all configuration data, and after read_save_file | |
| 1973 # has updated them with saved data. | |
| 1974 # | |
| 1975 # There is a separate validation routine which gets invoked first. | |
| 1976 # This takes care of serious errors in the command line arguments. | |
| 1977 # | |
| 1978 | |
| 1979 proc pkgconf::process_arguments { } { | |
| 1980 | |
| 1981 variable known_compiler_flags | |
| 1982 variable known_packages | |
| 1983 variable package_data | |
| 1984 variable known_targets | |
| 1985 variable target_data | |
| 1986 | |
| 1987 variable config_data | |
| 1988 variable target_arg | |
| 1989 variable platform_arg | |
| 1990 variable startup_arg | |
| 1991 variable prefix_arg | |
| 1992 variable disable_args | |
| 1993 variable enable_args | |
| 1994 variable version_args | |
| 1995 variable use_links_arg | |
| 1996 variable use_copies_arg | |
| 1997 variable cflags_args | |
| 1998 | |
| 1999 # Constructing the file name strings here facilitates generating | |
| 2000 # error messages. | |
| 2001 set packages_file [file join $pkgconf::component_repository "packages"] | |
| 2002 set targets_file [file join $pkgconf::component_repository "targets"] | |
| 2003 | |
| 2004 # The target, platform, and startup values are used throughout so it | |
| 2005 # is convenient to have locals. | |
| 2006 set target $pkgconf::config_data(target) | |
| 2007 set platform $pkgconf::config_data(platform) | |
| 2008 set startup $pkgconf::config_data(startup) | |
| 2009 | |
| 2010 # Start by validating the --target argument This target must | |
| 2011 # be present in the known_targets list. If it is then the | |
| 2012 # target architecture can be updated. | |
| 2013 | |
| 2014 if { $pkgconf::target_arg != "" } { | |
| 2015 | |
| 2016 set target [find_target $pkgconf::target_arg] | |
| 2017 if { $target == "" } { | |
| 2018 fatal_error "Invalid argument --target=$target_arg, this target is not listed in $targets_file" | |
| 2019 } | |
| 2020 set pkgconf::config_data(target) $target | |
| 2021 | |
| 2022 # It is possible that the platform and startup data from the save file | |
| 2023 # are no longer valid because of a change in the target. If so then the | |
| 2024 # relevant fields have to be cleared. | |
| 2025 if { $platform != "" } { | |
| 2026 set platform [find_platform $target $platform] | |
| 2027 set pkgconf::config_data(platform) $platform | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
2028 set pkgconf::config_data(base_platform) [get_base_platform $target $platform] |
| 0 | 2029 if { ($platform != "") && ($startup != "") } { |
| 2030 if { [lsearch -exact $pkgconf::target_data($target,$platform,startup) $startup] == -1 } { | |
| 2031 set startup "" | |
| 2032 set pkgconf::config_data(startup) "" | |
| 2033 } | |
| 2034 } | |
| 2035 } | |
| 2036 | |
| 2037 # Next, if the platform and startup are not currently known then | |
| 2038 # it is possible to set up defaults for this target. | |
| 2039 if { $platform == "" } { | |
| 2040 set platform [lindex $pkgconf::target_data($target,known_platforms) 0] | |
| 2041 set pkgconf::config_data(platform) $platform | |
| 2042 } | |
| 2043 if { $startup == "" } { | |
| 2044 set startup [lindex $pkgconf::target_data($target,$platform,startup) 0] | |
| 2045 set pkgconf::config_data(startup) $startup | |
| 2046 } | |
| 2047 } | |
| 2048 | |
| 2049 # If the target is known then it is possible to verify platform and startup | |
| 2050 # arguments. Without a target these arguments are meaningless. | |
| 2051 | |
| 2052 if { ($target != "") && ($pkgconf::platform_arg != "") } { | |
| 2053 | |
| 2054 set platform [find_platform $target $pkgconf::platform_arg] | |
| 2055 if { $platform == "" } { | |
| 2056 fatal_error "Invalid argument --platform=$pkgconf::platform_arg, this platform is not listed in $targets_file" | |
| 2057 } | |
| 2058 set pkgconf::config_data(platform) $platform | |
| 2059 } | |
| 2060 | |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
12
diff
changeset
|
2061 if { ($target != "") && ($platform != "") } { |
|
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
12
diff
changeset
|
2062 set pkgconf::config_data(base_platform) [get_base_platform $target $platform] |
|
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
12
diff
changeset
|
2063 } |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
2064 |
| 0 | 2065 if { ($target != "") && ($platform != "") && ($pkgconf::startup_arg != "" ) } { |
| 2066 | |
| 2067 if { [lsearch -exact $pkgconf::target_data($target,$platform,startup) $pkgconf::startup_arg] == -1 } { | |
| 2068 fatal_error "Invalid argument --startup=$startup_arg, this startup is not listed in $targets_file" | |
| 2069 } | |
| 2070 set startup $pkgconf::startup_arg | |
| 2071 set config_data(startup) $startup | |
| 2072 } | |
| 2073 | |
| 2074 # It is not really possible to validate the prefix argument. | |
| 2075 if { $pkgconf::prefix_arg != "" } { | |
| 2076 set pkgconf::config_data(prefix) $pkgconf::prefix_arg | |
| 2077 } | |
| 2078 | |
| 2079 # Cope with the use of symbolic links vs. copies | |
| 2080 if { $pkgconf::use_links_arg } { | |
| 2081 set pkgconf::config_data(use_links) 1 | |
| 2082 } | |
| 2083 if { $pkgconf::use_copies_arg } { | |
| 2084 set pkgconf::config_data(use_links) 0 | |
| 2085 } | |
| 2086 | |
| 2087 # For each package that is being disabled, make sure it is on the | |
| 2088 # list of disabled packages and not on the list of enabled packages. | |
| 2089 # The former operation is actually unnecessary if the package is | |
| 2090 # disabled by default, but harmless. | |
| 2091 foreach pkg $pkgconf::disable_args { | |
| 2092 set match [find_package $pkg] | |
| 2093 if { $match == "" } { | |
| 2094 fatal_error "Invalid argument --disable-$pkg, package $pkg is not listed in $packages_file." | |
| 2095 } | |
| 2096 | |
| 2097 set index [lsearch -exact $pkgconf::config_data(enabled_packages) $match] | |
| 2098 if { $index != -1 } { | |
| 2099 set pkgconf::config_data(enabled_packages) [lreplace $pkgconf::config_data(enabled_packages) $index $index] | |
| 2100 } | |
| 2101 set index [lsearch -exact $pkgconf::config_data(disabled_packages) $match] | |
| 2102 if { $index == -1 } { | |
| 2103 lappend pkgconf::config_data(disabled_packages) $match | |
| 2104 } | |
| 2105 } | |
| 2106 | |
| 2107 # For each package that should be enabled, add it to the list of enabled | |
| 2108 # packages and remove it from the list of disabled packages. Again the | |
| 2109 # former is actually unnecessary if the package is enabled by default. | |
| 2110 foreach pkg $pkgconf::enable_args { | |
| 2111 set match [find_package $pkg] | |
| 2112 if { $match == "" } { | |
| 2113 fatal_error "Invalid argument --enable-$pkg, package $pkg is not listed in $packages_file." | |
| 2114 } | |
| 2115 | |
| 2116 set index [lsearch -exact $pkgconf::config_data(disabled_packages) $match] | |
| 2117 if { $index != -1 } { | |
| 2118 set pkgconf::config_data(disabled_packages) [lreplace $pkgconf::config_data(disabled_packages) $index $index] | |
| 2119 } | |
| 2120 set index [lsearch -exact $pkgconf::config_data(enabled_packages) $match] | |
| 2121 if { $index == -1 } { | |
| 2122 lappend config_data(enabled_packages) $match | |
| 2123 } | |
| 2124 } | |
| 2125 | |
| 2126 # For each package where a version has been specified, validate this | |
| 2127 # version and use it. Also make sure that the package is enabled. | |
| 2128 foreach pkg [array names pkgconf::version_args] { | |
| 2129 | |
| 2130 set match [find_package $pkg] | |
| 2131 if { $match == "" } { | |
| 2132 fatal_error "Invalid argument --$pkg-version, package $pkg is not listed in $packages_file." | |
| 2133 } | |
| 2134 if { [lsearch -exact $pkgconf::package_data($match,versions) $pkgconf::version_args($pkg)] == -1 } { | |
| 2135 fatal_error "Invalid argument --$pkg-version=$pkgconf::version_args($pkg), that version is not available." | |
| 2136 } | |
| 2137 set pkgconf::config_data($match,version) $pkgconf::version_args($pkg) | |
| 2138 | |
| 2139 set index [lsearch -exact $pkgconf::config_data(disabled_packages) $match] | |
| 2140 if { $index != -1 } { | |
| 2141 set pkgconf::config_data(disabled_packages) [lreplace $pkgconf::config_data(disabled_packages) $index $index] | |
| 2142 } | |
| 2143 if { ($pkgconf::package_data($match,hardware) == 1) || ($pkgconf::package_data($match,default) == 0) } { | |
| 2144 set index [lsearch -exact $pkgconf::config_data(enabled_packages) $match] | |
| 2145 if { $index == -1 } { | |
| 2146 lappend config_data(enabled_packages) $match | |
| 2147 } | |
| 2148 } | |
| 2149 } | |
| 2150 | |
| 2151 # For each compiler flag that has been specified explicitly on the command line, | |
| 2152 # store it in the configuration data | |
| 2153 foreach flag [array names pkgconf::cflags_args] { | |
| 2154 set pkgconf::config_data(cflags,$flag) $pkgconf::cflags_args($flag) | |
| 2155 } | |
| 2156 } | |
| 2157 | |
| 2158 # }}} | |
| 2159 # {{{ reset_data() | |
| 2160 | |
| 2161 # ---------------------------------------------------------------------------- | |
| 2162 # This routine gets rid of all data. It can be used if the script is | |
| 2163 # switching from one configuration to a different one. | |
| 2164 # | |
| 2165 proc pkgconf::reset_data { } { | |
| 2166 | |
| 2167 foreach i [array names pkgconf::config_data] { | |
| 2168 unset pkgconf::config_data($i) | |
| 2169 } | |
| 2170 foreach i [array names pkgconf::saved_data] { | |
| 2171 unset pkgconf::saved_data($i) | |
| 2172 } | |
| 2173 } | |
| 2174 | |
| 2175 # }}} | |
| 2176 | |
| 2177 # }}} | |
| 2178 # {{{ GUI | |
| 2179 | |
| 2180 # {{{ GUI variables | |
| 2181 | |
| 2182 namespace eval pkgconf { | |
| 2183 | |
| 2184 namespace export gui | |
| 2185 | |
| 2186 # Which editor should be used for fine-grained configuration options ? | |
| 2187 # The VISUAL environment variable is the correct way to obtain this | |
| 2188 # information on Unix operating systems. Windows machines do not | |
| 2189 # seem to have an obvious equivalent. | |
| 2190 variable editor "" | |
| 2191 if { [info exists ::env(VISUAL)] } { | |
| 2192 set editor $::env(VISUAL) | |
| 2193 } | |
| 2194 | |
| 2195 # The names of the pages in the notebook. These names are | |
| 2196 # invented by the notebook widget. | |
| 2197 variable target_frame "" | |
| 2198 variable packages_frame "" | |
| 2199 variable options_frame "" | |
| 2200 variable flags_frame "" | |
| 2201 variable build_frame "" | |
| 2202 | |
| 2203 # It is convenient to keep track of whether or not certain information | |
| 2204 # has changed. This simplifies the task of deciding whether or not | |
| 2205 # a page in the notebook needs redrawing. | |
| 2206 # | |
| 2207 # Note: currently if the user makes a change and then undoes that | |
| 2208 # change the variable remains set. It is possible to get around this, | |
| 2209 # but that would require a bit more work. | |
| 2210 variable packages_page_needs_refresh 0 | |
| 2211 variable options_page_needs_refresh 0 | |
| 2212 variable build_page_needs_refresh 0 | |
| 2213 | |
| 2214 # Is it currently possible to do a build, or is it necessary to | |
| 2215 # update the build tree first. | |
| 2216 variable build_tree_needs_update 0 | |
| 2217 | |
| 2218 # Each notebook page is given its own array of global data. | |
| 2219 array set target_page_data {}; | |
| 2220 array set packages_page_data {}; | |
| 2221 array set options_page_data {}; | |
| 2222 array set flags_page_data {}; | |
| 2223 array set build_page_data {}; | |
| 2224 | |
| 2225 # The state of the build output window. There are two flags to consider: | |
| 2226 # whether the output window is visible or not; and whether the output | |
| 2227 # window is docked or not. | |
| 2228 variable output_docked 1 | |
| 2229 variable output_visible 0 | |
| 2230 | |
| 2231 # For gui mode, what is the name of the toplevel window ? | |
| 2232 # If this script is embedded in a larger application then it can | |
| 2233 # be made to run inside a frame in that window. | |
| 2234 namespace export set_toplevel_window | |
| 2235 variable toplevel ".pkgconf" | |
| 2236 } | |
| 2237 | |
| 2238 # }}} | |
| 2239 # {{{ Effective Tcl support | |
| 2240 | |
| 2241 # ---------------------------------------------------------------------------- | |
| 2242 # For now the intention is to allow this script to be run from a completely | |
| 2243 # standard wish or tclsh interpreter, version 8.0 or later. This means it is | |
| 2244 # not possible to use extensions such as TIX or ITCL. However in the GUI | |
| 2245 # it is still desirable to have a notebook widget, so here is an | |
| 2246 # implementation in vanilla TK. The balloon widget from the same source | |
| 2247 # is used as well. | |
| 2248 # | |
| 2249 # The code derives from the book Effective Tcl/Tk programming by Mark | |
| 2250 # Harrison and Michael McLennan. The actual source code was obtained from | |
| 2251 # the Addison-Wesley web site and contains the following copyright. | |
| 2252 # | |
| 2253 # This distribution contains examples from the "Effective Tcl/Tk | |
| 2254 # Programming" book. You can study these examples as you read | |
| 2255 # through the book, and you can steal the code for your own | |
| 2256 # applications! | |
| 2257 # | |
| 2258 # | |
| 2259 # The code is enclosed in a separate namespace. Also I have modified | |
| 2260 # the code in a number of places to make it more general-purpose. | |
| 2261 # | |
| 2262 namespace eval pkgconf::efftcl { | |
| 2263 | |
| 2264 # ---------------------------------------------------------------------- | |
| 2265 # EXAMPLE: tabnotebook that can dial up pages | |
| 2266 # ---------------------------------------------------------------------- | |
| 2267 # Effective Tcl/Tk Programming | |
| 2268 # Mark Harrison, DSC Communications Corp. | |
| 2269 # Michael McLennan, Bell Labs Innovations for Lucent Technologies | |
| 2270 # Addison-Wesley Professional Computing Series | |
| 2271 # ====================================================================== | |
| 2272 # Copyright (c) 1996-1997 Lucent Technologies Inc. and Mark Harrison | |
| 2273 # ====================================================================== | |
| 2274 | |
| 2275 # BLV fix: this script may execute in tclsh rather than in wish, | |
| 2276 # so the option command may not be available. | |
| 2277 if { [info command "option"] == "option"} { | |
| 2278 | |
| 2279 # BLV: I do not like this background colour for the tabs. | |
| 2280 if { 0 } { | |
| 2281 option add *Tabnotebook.tabs.background #666666 widgetDefault | |
| 2282 } | |
| 2283 option add *Tabnotebook.margin 6 widgetDefault | |
| 2284 option add *Tabnotebook.tabColor #a6a6a6 widgetDefault | |
| 2285 option add *Tabnotebook.activeTabColor #d9d9d9 widgetDefault | |
| 2286 option add *Tabnotebook.tabFont \ | |
| 2287 -*-helvetica-bold-r-normal--*-120-* widgetDefault | |
| 2288 } | |
| 2289 | |
| 2290 # BLV fix: replace global variables with per-namespace ones. | |
| 2291 array set tnInfo {} | |
| 2292 array set bhInfo {} | |
| 2293 | |
| 2294 proc tabnotebook_create {win} { | |
| 2295 variable tnInfo | |
| 2296 | |
| 2297 frame $win -class Tabnotebook | |
| 2298 canvas $win.tabs -highlightthickness 0 | |
| 2299 pack $win.tabs -fill x | |
| 2300 | |
| 2301 notebook_create $win.notebook | |
| 2302 pack $win.notebook -expand yes -fill both | |
| 2303 | |
| 2304 set tnInfo($win-tabs) "" | |
| 2305 set tnInfo($win-current) "" | |
| 2306 set tnInfo($win-pending) "" | |
| 2307 return $win | |
| 2308 } | |
| 2309 | |
| 2310 # | |
| 2311 # BLV fix: add three arguments, one specifying a function to be | |
| 2312 # invoked when the tab becomes visible, another for when the user | |
| 2313 # leaves the tab, and a text string for balloon help. This function can | |
| 2314 # be used to redraw a page if this is necessary due to changes in other | |
| 2315 # pages, and an empty string can be used if desired. An empty string | |
| 2316 # can also be used for the balloon help. | |
| 2317 # | |
| 2318 | |
| 2319 proc tabnotebook_page {win name enterfn leavefn help} { | |
| 2320 variable tnInfo | |
| 2321 | |
| 2322 set page [notebook_page $win.notebook $name] | |
| 2323 lappend tnInfo($win-tabs) $name | |
| 2324 set tnInfo($name-enterfn) $enterfn | |
| 2325 set tnInfo($name-leavefn) $leavefn | |
| 2326 set tnInfo($name-help) $help | |
| 2327 | |
| 2328 if {$tnInfo($win-pending) == ""} { | |
| 2329 set id [after idle [list pkgconf::efftcl::tabnotebook_refresh $win]] | |
| 2330 set tnInfo($win-pending) $id | |
| 2331 } | |
| 2332 return $page | |
| 2333 } | |
| 2334 | |
| 2335 proc tabnotebook_refresh {win} { | |
| 2336 variable tnInfo | |
| 2337 | |
| 2338 $win.tabs delete all | |
| 2339 | |
| 2340 set margin [option get $win margin Margin] | |
| 2341 set color [option get $win tabColor Color] | |
| 2342 set font [option get $win tabFont Font] | |
| 2343 set x 2 | |
| 2344 set maxh 0 | |
| 2345 | |
| 2346 foreach name $tnInfo($win-tabs) { | |
| 2347 set id [$win.tabs create text \ | |
| 2348 [expr $x+$margin+2] [expr -0.5*$margin] \ | |
| 2349 -anchor sw -text $name -font $font \ | |
| 2350 -tags [list $name]] | |
| 2351 | |
| 2352 set bbox [$win.tabs bbox $id] | |
| 2353 set wd [expr [lindex $bbox 2]-[lindex $bbox 0]] | |
| 2354 set ht [expr [lindex $bbox 3]-[lindex $bbox 1]] | |
| 2355 if {$ht > $maxh} { | |
| 2356 set maxh $ht | |
| 2357 } | |
| 2358 | |
| 2359 $win.tabs create polygon 0 0 $x 0 \ | |
| 2360 [expr $x+$margin] [expr -$ht-$margin] \ | |
| 2361 [expr $x+$margin+$wd] [expr -$ht-$margin] \ | |
| 2362 [expr $x+$wd+2*$margin] 0 \ | |
| 2363 2000 0 2000 10 0 10 \ | |
| 2364 -outline black -fill $color \ | |
| 2365 -tags [list $name tab tab-$name] | |
| 2366 | |
| 2367 $win.tabs raise $id | |
| 2368 | |
| 2369 $win.tabs bind $name <ButtonPress-1> \ | |
| 2370 [list pkgconf::efftcl::tabnotebook_display $win $name] | |
| 2371 | |
| 2372 # BLV - add support for balloon help | |
| 2373 if { $tnInfo($name-help) != "" } { | |
| 2374 balloonhelp_canvas_for $win.tabs $name $tnInfo($name-help) | |
| 2375 } | |
| 2376 set x [expr $x+$wd+2*$margin] | |
| 2377 } | |
| 2378 set height [expr $maxh+2*$margin] | |
| 2379 $win.tabs move all 0 $height | |
| 2380 | |
| 2381 $win.tabs configure -width $x -height [expr $height+4] | |
| 2382 | |
| 2383 if {$tnInfo($win-current) != ""} { | |
| 2384 tabnotebook_display $win $tnInfo($win-current) | |
| 2385 } else { | |
| 2386 tabnotebook_display $win [lindex $tnInfo($win-tabs) 0] | |
| 2387 } | |
| 2388 set tnInfo($win-pending) "" | |
| 2389 } | |
| 2390 | |
| 2391 proc tabnotebook_display {win name} { | |
| 2392 variable tnInfo | |
| 2393 variable nbInfo | |
| 2394 | |
| 2395 # BLV: invoke appropriate callbacks in the current and new | |
| 2396 # tabs. | |
| 2397 set old_tab $tnInfo($win-current) | |
| 2398 if { ($old_tab != "") && ($tnInfo($old_tab-leavefn) != "") } { | |
| 2399 $tnInfo($old_tab-leavefn) $nbInfo($win.notebook-page-$old_tab)) | |
| 2400 } | |
| 2401 if { $tnInfo($name-enterfn) != "" } { | |
| 2402 $tnInfo($name-enterfn) $nbInfo($win.notebook-page-$name) | |
| 2403 } | |
| 2404 | |
| 2405 notebook_display $win.notebook $name | |
| 2406 | |
| 2407 set normal [option get $win tabColor Color] | |
| 2408 $win.tabs itemconfigure tab -fill $normal | |
| 2409 | |
| 2410 set active [option get $win activeTabColor Color] | |
| 2411 $win.tabs itemconfigure tab-$name -fill $active | |
| 2412 $win.tabs raise $name | |
| 2413 | |
| 2414 set tnInfo($win-current) $name | |
| 2415 } | |
| 2416 | |
| 2417 # ---------------------------------------------------------------------- | |
| 2418 # EXAMPLE: simple notebook that can dial up pages | |
| 2419 # ---------------------------------------------------------------------- | |
| 2420 # Effective Tcl/Tk Programming | |
| 2421 # Mark Harrison, DSC Communications Corp. | |
| 2422 # Michael McLennan, Bell Labs Innovations for Lucent Technologies | |
| 2423 # Addison-Wesley Professional Computing Series | |
| 2424 # ====================================================================== | |
| 2425 # Copyright (c) 1996-1997 Lucent Technologies Inc. and Mark Harrison | |
| 2426 # ====================================================================== | |
| 2427 | |
| 2428 # BLV - again check for TK being present. | |
| 2429 if { [info command option] == "option" } { | |
| 2430 option add *Notebook.borderWidth 2 widgetDefault | |
| 2431 option add *Notebook.relief sunken widgetDefault | |
| 2432 } | |
| 2433 | |
| 2434 # BLV: replace nbInfo global with a per-namespace variable | |
| 2435 array set nbInfo {} | |
| 2436 | |
| 2437 proc notebook_create {win} { | |
| 2438 variable nbInfo | |
| 2439 | |
| 2440 frame $win -class Notebook | |
| 2441 pack propagate $win 0 | |
| 2442 | |
| 2443 set nbInfo($win-count) 0 | |
| 2444 set nbInfo($win-pages) "" | |
| 2445 set nbInfo($win-current) "" | |
| 2446 return $win | |
| 2447 } | |
| 2448 | |
| 2449 proc notebook_page {win name} { | |
| 2450 variable nbInfo | |
| 2451 | |
| 2452 set page "$win.page[incr nbInfo($win-count)]" | |
| 2453 lappend nbInfo($win-pages) $page | |
| 2454 set nbInfo($win-page-$name) $page | |
| 2455 | |
| 2456 frame $page | |
| 2457 | |
| 2458 if {$nbInfo($win-count) == 1} { | |
| 2459 after idle [list pkgconf::efftcl::notebook_display $win $name] | |
| 2460 } | |
| 2461 | |
| 2462 return $page | |
| 2463 } | |
| 2464 | |
| 2465 proc notebook_display {win name} { | |
| 2466 variable nbInfo | |
| 2467 | |
| 2468 set page "" | |
| 2469 if {[info exists nbInfo($win-page-$name)]} { | |
| 2470 set page $nbInfo($win-page-$name) | |
| 2471 } elseif {[winfo exists $win.page$name]} { | |
| 2472 set page $win.page$name | |
| 2473 } | |
| 2474 if {$page == ""} { | |
| 2475 error "bad notebook page \"$name\"" | |
| 2476 } | |
| 2477 | |
| 2478 notebook_fix_size $win | |
| 2479 | |
| 2480 if {$nbInfo($win-current) != ""} { | |
| 2481 pack forget $nbInfo($win-current) | |
| 2482 } | |
| 2483 pack $page -expand yes -fill both | |
| 2484 set nbInfo($win-current) $page | |
| 2485 } | |
| 2486 | |
| 2487 proc notebook_fix_size {win} { | |
| 2488 variable nbInfo | |
| 2489 | |
| 2490 update idletasks | |
| 2491 | |
| 2492 set maxw 0 | |
| 2493 set maxh 0 | |
| 2494 foreach page $nbInfo($win-pages) { | |
| 2495 set w [winfo reqwidth $page] | |
| 2496 if {$w > $maxw} { | |
| 2497 set maxw $w | |
| 2498 } | |
| 2499 set h [winfo reqheight $page] | |
| 2500 if {$h > $maxh} { | |
| 2501 set maxh $h | |
| 2502 } | |
| 2503 } | |
| 2504 set bd [$win cget -borderwidth] | |
| 2505 set maxw [expr $maxw+2*$bd] | |
| 2506 set maxh [expr $maxh+2*$bd] | |
| 2507 $win configure -width $maxw -height $maxh | |
| 2508 } | |
| 2509 | |
| 2510 # ---------------------------------------------------------------------- | |
| 2511 # EXAMPLE: use "wm" commands to manage a balloon help window | |
| 2512 # ---------------------------------------------------------------------- | |
| 2513 # Effective Tcl/Tk Programming | |
| 2514 # Mark Harrison, DSC Communications Corp. | |
| 2515 # Michael McLennan, Bell Labs Innovations for Lucent Technologies | |
| 2516 # Addison-Wesley Professional Computing Series | |
| 2517 # ====================================================================== | |
| 2518 # Copyright (c) 1996-1997 Lucent Technologies Inc. and Mark Harrison | |
| 2519 # ====================================================================== | |
| 2520 | |
| 2521 # BLV fix: again this script may execute in tclsh rather than in wish. | |
| 2522 if { [info command "option"] == "option" } { | |
| 2523 option add *Balloonhelp*background white widgetDefault | |
| 2524 option add *Balloonhelp*foreground black widgetDefault | |
| 2525 option add *Balloonhelp.info.wrapLength 3i widgetDefault | |
| 2526 option add *Balloonhelp.info.justify left widgetDefault | |
| 2527 option add *Balloonhelp.info.font \ | |
| 2528 -*-lucida-medium-r-normal-sans-*-120-* widgetDefault | |
| 2529 | |
| 2530 toplevel .balloonhelp -class Balloonhelp \ | |
| 2531 -background black -borderwidth 1 -relief flat | |
| 2532 | |
| 2533 # BLV fix: I want to create the arrow image inline rather than | |
| 2534 # read it in from a file. | |
| 2535 image create bitmap arrow -data "\ | |
| 2536 #define arrow_width 8 | |
| 2537 #define arrow_height 8 | |
| 2538 static unsigned char arrow_bits[] = { | |
| 2539 0x1f, 0x0f, 0x0f, 0x1f, 0x39, 0x70, 0x20, 0x00}; | |
| 2540 " | |
| 2541 label .balloonhelp.arrow -anchor nw -image arrow | |
| 2542 | |
| 2543 # label .balloonhelp.arrow -anchor nw \ | |
| 2544 # -bitmap @[file join $env(EFFTCL_LIBRARY) images arrow.xbm] | |
| 2545 pack .balloonhelp.arrow -side left -fill y | |
| 2546 | |
| 2547 label .balloonhelp.info | |
| 2548 pack .balloonhelp.info -side left -fill y | |
| 2549 | |
| 2550 wm overrideredirect .balloonhelp 1 | |
| 2551 wm withdraw .balloonhelp | |
| 2552 } | |
| 2553 | |
| 2554 # ---------------------------------------------------------------------- | |
| 2555 # USAGE: balloonhelp_for <win> <mesg> | |
| 2556 # | |
| 2557 # Adds balloon help to the widget named <win>. Whenever the mouse | |
| 2558 # pointer enters this widget and rests within it for a short delay, | |
| 2559 # a balloon help window will automatically appear showing the | |
| 2560 # help <mesg>. | |
| 2561 # ---------------------------------------------------------------------- | |
| 2562 | |
| 2563 proc balloonhelp_for {win mesg} { | |
| 2564 variable bhInfo | |
| 2565 set bhInfo($win) $mesg | |
| 2566 | |
| 2567 bind $win <Enter> {pkgconf::efftcl::balloonhelp_pending %W %W} | |
| 2568 bind $win <Leave> {pkgconf::efftcl::balloonhelp_cancel} | |
| 2569 } | |
| 2570 | |
| 2571 # BLV: a variant that can be used for canvas items. | |
| 2572 | |
| 2573 proc balloonhelp_canvas_for { canvas id mesg } { | |
| 2574 variable bhInfo | |
| 2575 set bhInfo($canvas-$id) $mesg | |
| 2576 | |
| 2577 $canvas bind $id <Enter> [list pkgconf::efftcl::balloonhelp_pending $canvas $canvas-$id] | |
| 2578 $canvas bind $id <Leave> {pkgconf::efftcl::balloonhelp_cancel} | |
| 2579 } | |
| 2580 | |
| 2581 # ---------------------------------------------------------------------- | |
| 2582 # USAGE: balloonhelp_control <state> | |
| 2583 # | |
| 2584 # Turns balloon help on/off for the entire application. | |
| 2585 # ---------------------------------------------------------------------- | |
| 2586 set bhInfo(active) 1 | |
| 2587 | |
| 2588 proc balloonhelp_control {state} { | |
| 2589 variable bhInfo | |
| 2590 | |
| 2591 if {$state} { | |
| 2592 set bhInfo(active) 1 | |
| 2593 } else { | |
| 2594 balloonhelp_cancel | |
| 2595 set bhInfo(active) 0 | |
| 2596 } | |
| 2597 } | |
| 2598 | |
| 2599 # ---------------------------------------------------------------------- | |
| 2600 # USAGE: balloonhelp_pending <win> | |
| 2601 # | |
| 2602 # Used internally to mark the point in time when a widget is first | |
| 2603 # touched. Sets up an "after" event so that balloon help will appear | |
| 2604 # if the mouse remains within the current window. | |
| 2605 # ---------------------------------------------------------------------- | |
| 2606 | |
| 2607 # BLV - the first argument identifies the window, the second the help | |
| 2608 # string. | |
| 2609 proc balloonhelp_pending {win id} { | |
| 2610 variable bhInfo | |
| 2611 | |
| 2612 balloonhelp_cancel | |
| 2613 set bhInfo(pending) [after 1500 [list pkgconf::efftcl::balloonhelp_show $win $id]] | |
| 2614 } | |
| 2615 | |
| 2616 # ---------------------------------------------------------------------- | |
| 2617 # USAGE: balloonhelp_cancel | |
| 2618 # | |
| 2619 # Used internally to mark the point in time when the mouse pointer | |
| 2620 # leaves a widget. Cancels any pending balloon help requested earlier | |
| 2621 # and hides the balloon help window, in case it is visible. | |
| 2622 # ---------------------------------------------------------------------- | |
| 2623 proc balloonhelp_cancel {} { | |
| 2624 variable bhInfo | |
| 2625 | |
| 2626 if {[info exists bhInfo(pending)]} { | |
| 2627 after cancel $bhInfo(pending) | |
| 2628 unset bhInfo(pending) | |
| 2629 } | |
| 2630 wm withdraw .balloonhelp | |
| 2631 } | |
| 2632 | |
| 2633 # ---------------------------------------------------------------------- | |
| 2634 # USAGE: balloonhelp_show <win> | |
| 2635 # | |
| 2636 # Used internally to display the balloon help window for the | |
| 2637 # specified <win>. | |
| 2638 # ---------------------------------------------------------------------- | |
| 2639 | |
| 2640 # BLV - the first argument identifies the window, the second the | |
| 2641 # help message. | |
| 2642 | |
| 2643 proc balloonhelp_show {win id} { | |
| 2644 variable bhInfo | |
| 2645 | |
| 2646 if {$bhInfo(active)} { | |
| 2647 .balloonhelp.info configure -text $bhInfo($id) | |
| 2648 | |
| 2649 # BLV: switched from using window-relative positions | |
| 2650 # to mouse relative position. | |
| 2651 if { 0 } { | |
| 2652 set x [expr [winfo rootx $win]+10] | |
| 2653 set y [expr [winfo rooty $win]+[winfo height $win]] | |
| 2654 } else { | |
| 2655 set coords [winfo pointerxy $win] | |
| 2656 set x [expr [lindex $coords 0] + 15] | |
| 2657 set y [expr [lindex $coords 1] + 15] | |
| 2658 } | |
| 2659 if { ($x >= 0) && ($y >= 0) } { | |
| 2660 wm geometry .balloonhelp +$x+$y | |
| 2661 wm deiconify .balloonhelp | |
| 2662 raise .balloonhelp | |
| 2663 } | |
| 2664 } | |
| 2665 unset bhInfo(pending) | |
| 2666 } | |
| 2667 | |
| 2668 } | |
| 2669 | |
| 2670 # }}} | |
| 2671 # {{{ standalone initialisation | |
| 2672 | |
| 2673 # ---------------------------------------------------------------------------- | |
| 2674 # GUI Start-up. It is necessary to work out a few things about the operating | |
| 2675 # environment. | |
| 2676 # | |
| 2677 # 1) is this script being run via tclsh or via wish ? If the former then only | |
| 2678 # command line operation is possible. If the latter then a GUI environment | |
| 2679 # can be provided as well. | |
| 2680 # | |
| 2681 # 2) if TK is present, has it been extended with Tix ? If so use the standard | |
| 2682 # TK color scheme etc., not the Tix variant. | |
| 2683 # | |
| 2684 # 3) if TK is present, get rid of the top-level window. | |
| 2685 # | |
| 2686 # If this command is not being run stand-alone then it is the responsibility | |
| 2687 # of the calling code to take appropriate action, e.g. to enable gui mode | |
| 2688 # and to set up the appropriate options. | |
| 2689 # | |
| 2690 | |
| 2691 proc pkgconf::gui_standalone_init { } { | |
| 2692 | |
| 2693 variable gui_possible | |
| 2694 | |
| 2695 if { [info command tk] == "tk" } { | |
| 2696 | |
| 2697 # TK is loaded. For now allow GUI mode, but the actual decision | |
| 2698 # depends on command line arguments. | |
| 2699 set gui_possible 1 | |
| 2700 | |
| 2701 # Get rid of the top-level window. Otherwise this might pop up if the | |
| 2702 # script performs a blocking operation too early. | |
| 2703 wm withdraw . | |
| 2704 | |
| 2705 # If TIX is also present, prevent the TIX color scheme etc. from taking | |
| 2706 # effect. | |
| 2707 if { [info command tix] == "tix" } { | |
| 2708 tix resetoptions TK TK | |
| 2709 } | |
| 2710 | |
| 2711 # It is probably not a good idea to accept "send" messages. However | |
| 2712 # setting the appname also affects option handling, which is more | |
| 2713 # useful. Note that the send command is not available in all versions | |
| 2714 # of Tcl. | |
| 2715 if { [info command send] == "send" } { | |
| 2716 rename send {} | |
| 2717 } | |
| 2718 tk appname pkgconf | |
| 2719 | |
| 2720 } else { | |
| 2721 | |
| 2722 # TK is not loaded, so gui mode is not possible. | |
| 2723 set gui_possible 0 | |
| 2724 } | |
| 2725 } | |
| 2726 | |
| 2727 # }}} | |
| 2728 # {{{ set toplevel window | |
| 2729 | |
| 2730 # ---------------------------------------------------------------------------- | |
| 2731 # Allow a containing program, if any, to specify the window in which | |
| 2732 # this script should do its funky stuff. It is not possible to change | |
| 2733 # this window while pkgconf is active, so if for any reason it is | |
| 2734 # necessary to change the toplevel window then the old one must be | |
| 2735 # destroyed first, the new name must be installed, and then there | |
| 2736 # must be a new call to pkgconf::gui to redraw the window. | |
| 2737 # | |
| 2738 | |
| 2739 proc pkgconf::set_toplevel_window { name } { | |
| 2740 variable toplevel | |
| 2741 set toplevel $name | |
| 2742 } | |
| 2743 | |
| 2744 # }}} | |
| 2745 # {{{ main GUI draw routine | |
| 2746 | |
| 2747 # ---------------------------------------------------------------------------- | |
| 2748 # The main GUI code. | |
| 2749 # | |
| 2750 # The routine pkgconf::gui is responsible for creating the various windows. | |
| 2751 # These are as follows: | |
| 2752 # | |
| 2753 # 1) a menu bar containing menus for File, Window and Help. Currently the only | |
| 2754 # entry in File is Exit, and the entries in Help are all disabled. The | |
| 2755 # Window menu allows the output window to be hidden or shown. | |
| 2756 # | |
| 2757 # 2) a notebook frame containing four pages: | |
| 2758 # | |
| 2759 # a) target hardware. This lists all known target architectures, | |
| 2760 # and allows the user to select the appropriate one using a | |
| 2761 # set of radio buttons. | |
| 2762 # | |
| 2763 # b) packages. This lists all known packages and the versions for | |
| 2764 # each package. Unfortunately neither radio buttons nor checkbuttons | |
| 2765 # provide entirely the right paradigm here, but checkbuttons are | |
| 2766 # good enough. | |
| 2767 # | |
| 2768 # c) an edit page. This allows the user to invoke a text editor for | |
| 2769 # any of the fine-grained configuration headers. | |
| 2770 # | |
| 2771 # d) a compiler flags page. This allows the user to manipulate the | |
| 2772 # compiler flags etc. | |
| 2773 # | |
| 2774 # e) a build page. This allows the user to create the build tree and to | |
| 2775 # invoke make, make tests, make clean, etc. There is also an entry | |
| 2776 # field to allow the install directory to be changed. | |
| 2777 # | |
| 2778 # 3) a label field along the bottom, which can be used by the various | |
| 2779 # frames to display warning messages. | |
| 2780 # | |
| 2781 # 4) a separate frame to hold the outputs of builds. This can be either | |
| 2782 # docked below the main frame, or it can be a separate toplevel window. | |
| 2783 # The build frame contains a number of buttons to allow the text | |
| 2784 # screen to be cleared, removed from the display, docked/undocked, | |
| 2785 # or saved to a file. | |
| 2786 # | |
| 2787 # 5) the options database is consulted to decide whether the output | |
| 2788 # window should be docked or not by default. | |
| 2789 # | |
| 2790 # 6) if there is a file ~/.pkgconfrc this file gets executed. It is | |
| 2791 # assumed to contain valid Tcl code. | |
| 2792 # | |
| 2793 # If this script is running inside a large application then there may be | |
| 2794 # a frame $toplevel_window already. If so this frame should be used. | |
| 2795 # Otherwise a separate toplevel window should be created, complete with | |
| 2796 # menu bar. | |
| 2797 # | |
| 2798 | |
| 2799 proc pkgconf::gui { } { | |
| 2800 | |
| 2801 variable toplevel | |
| 2802 if { [winfo exists $toplevel] == 0 } { | |
| 2803 create_toplevel_window | |
| 2804 } | |
| 2805 | |
| 2806 # Now create a notebook, and add four pages to it. The names of these | |
| 2807 # pages have to be stored in separate variables. | |
| 2808 variable target_frame | |
| 2809 variable packages_frame | |
| 2810 variable options_frame | |
| 2811 variable flags_frame | |
| 2812 variable build_frame | |
| 2813 | |
| 2814 efftcl::tabnotebook_create $toplevel.notebook | |
| 2815 set target_frame [efftcl::tabnotebook_page $toplevel.notebook "Target" \ | |
| 2816 pkgconf::nbpage_targets_enter pkgconf::nbpage_targets_leave \ | |
| 2817 "Select target hardware"] | |
| 2818 set packages_frame [efftcl::tabnotebook_page $toplevel.notebook "Packages" \ | |
| 2819 pkgconf::nbpage_packages_enter pkgconf::nbpage_packages_leave \ | |
| 2820 "Select desired packages"] | |
| 2821 set options_frame [efftcl::tabnotebook_page $toplevel.notebook "Options" \ | |
| 2822 pkgconf::nbpage_options_enter pkgconf::nbpage_options_leave \ | |
| 2823 "Edit configuration options"] | |
| 2824 set flags_frame [efftcl::tabnotebook_page $toplevel.notebook "Flags" \ | |
| 2825 pkgconf::nbpage_flags_enter pkgconf::nbpage_flags_leave \ | |
| 2826 "Edit compiler flags"] | |
| 2827 set build_frame [efftcl::tabnotebook_page $toplevel.notebook "Build" \ | |
| 2828 pkgconf::nbpage_build_enter pkgconf::nbpage_build_leave \ | |
| 2829 "Build this configuration"] | |
| 2830 | |
| 2831 # By default the notebook is the widget that expands. If a build output | |
| 2832 # window is present instead then it is the output window that expands. | |
| 2833 pack $toplevel.notebook -side top -fill both -expand 1 | |
| 2834 | |
| 2835 # Make sure that the message window exists, since some of the | |
| 2836 # notebook update routines refer to it. | |
| 2837 label $toplevel.message -text "" -anchor w -relief raised -borderwidth 2 | |
| 2838 pack $toplevel.message -side top -fill x | |
| 2839 | |
| 2840 # Now create the notebook pages. | |
| 2841 nbpage_targets_initialise $target_frame | |
| 2842 nbpage_packages_initialise $packages_frame | |
| 2843 nbpage_options_initialise $options_frame | |
| 2844 nbpage_flags_initialise $flags_frame | |
| 2845 nbpage_build_initialise $build_frame | |
| 2846 | |
| 2847 # Create the output window, but leave it hidden for now. | |
| 2848 frame $toplevel.output | |
| 2849 frame $toplevel.output.buttons | |
| 2850 button $toplevel.output.buttons.hide -text "Hide" -command pkgconf::output_hide_window | |
| 2851 button $toplevel.output.buttons.undock -text "Undock" -command pkgconf::output_undock_window | |
| 2852 button $toplevel.output.buttons.clear -text "Clear" -command pkgconf::output_clear_window | |
| 2853 button $toplevel.output.buttons.save -text "Save..." -command pkgconf::output_save | |
| 2854 pack $toplevel.output.buttons.hide \ | |
| 2855 $toplevel.output.buttons.undock \ | |
| 2856 $toplevel.output.buttons.clear \ | |
| 2857 $toplevel.output.buttons.save -side left -expand 1 | |
| 2858 pack $toplevel.output.buttons -side top -fill x | |
| 2859 text $toplevel.output.text -wrap word -state disabled -yscrollcommand [list $toplevel.output.scroll set] | |
| 2860 pack $toplevel.output.text -side left -fill both -expand 1 | |
| 2861 scrollbar $toplevel.output.scroll -orient vertical -command [list $toplevel.output.text yview] | |
| 2862 pack $toplevel.output.scroll -side right -fill y | |
| 2863 | |
| 2864 # Create a toplevel window matching the output frame, but leave it | |
| 2865 # hidden for now. Give it the same bindings as the toplevel window. | |
| 2866 toplevel .pkgconf_output -menu .menubar -class Pkgconf | |
| 2867 wm withdraw .pkgconf_output | |
| 2868 wm title .pkgconf_output "pkgconf build output" | |
| 2869 wm protocol .pkgconf_output WM_DELETE_WINDOW { pkgconf::handle_exit } | |
| 2870 | |
| 2871 bind .pkgconf_output <Alt-q> { pkgconf::handle_exit } | |
| 2872 bind .pkgconf_output <Alt-f><KeyPress-x> { pkgconf::handle_exit } | |
| 2873 | |
| 2874 frame .pkgconf_output.buttons | |
| 2875 button .pkgconf_output.buttons.hide -text "Hide" -command pkgconf::output_hide_window | |
| 2876 button .pkgconf_output.buttons.undock -text "Dock" -command pkgconf::output_undock_window | |
| 2877 button .pkgconf_output.buttons.clear -text "Clear" -command pkgconf::output_clear_window | |
| 2878 button .pkgconf_output.buttons.save -text "Save..." -command pkgconf::output_save | |
| 2879 pack .pkgconf_output.buttons.hide \ | |
| 2880 .pkgconf_output.buttons.undock \ | |
| 2881 .pkgconf_output.buttons.clear \ | |
| 2882 .pkgconf_output.buttons.save -side left -expand 1 | |
| 2883 pack .pkgconf_output.buttons -side top -fill x | |
| 2884 text .pkgconf_output.text -wrap word -state disabled -yscrollcommand { .pkgconf_output.scroll set } | |
| 2885 pack .pkgconf_output.text -side left -fill both -expand 1 | |
| 2886 scrollbar .pkgconf_output.scroll -orient vertical -command { .pkgconf_output.text yview } | |
| 2887 pack .pkgconf_output.scroll -side right -fill y | |
| 2888 | |
| 2889 efftcl::balloonhelp_for $toplevel.output.buttons.hide \ | |
| 2890 "Remove the build output window, until more output appears." | |
| 2891 efftcl::balloonhelp_for .pkgconf_output.buttons.hide \ | |
| 2892 "Remove the build output window, until more output appears." | |
| 2893 efftcl::balloonhelp_for $toplevel.output.buttons.undock \ | |
| 2894 "Make the build output appear in a separate window." | |
| 2895 efftcl::balloonhelp_for .pkgconf_output.buttons.undock \ | |
| 2896 "Attach the build output to the main pkgconf window." | |
| 2897 efftcl::balloonhelp_for $toplevel.output.buttons.clear \ | |
| 2898 "Remove all build output text." | |
| 2899 efftcl::balloonhelp_for .pkgconf_output.buttons.clear \ | |
| 2900 "Remove all build output text." | |
| 2901 efftcl::balloonhelp_for $toplevel.output.buttons.save \ | |
| 2902 "Save build output to a file." | |
| 2903 efftcl::balloonhelp_for .pkgconf_output.buttons.save \ | |
| 2904 "Save build output to a file." | |
| 2905 | |
| 2906 # Consult the options database. | |
| 2907 variable output_docked | |
| 2908 option add "*docked" 1 startupFile | |
| 2909 set output_docked [option get $toplevel docked Pkgconf] | |
| 2910 | |
| 2911 # Look for a file ~/.pkgconfrc and execute it. | |
| 2912 if { [file isfile [file join "~" ".pkgconfrc"]] } { | |
| 2913 if { [namespace eval :: { catch { source [file join "~" ".pkgconfrc"] } message } ] != 0 } { | |
| 2914 warning "The following error occurred while executing ~/.pkgconfrc: $message" | |
| 2915 } | |
| 2916 } | |
| 2917 } | |
| 2918 | |
| 2919 # ---------------------------------------------------------------------------- | |
| 2920 # This routine creates the toplevel window, if pkgconf is running | |
| 2921 # independently rather than inside a larger application. | |
| 2922 | |
| 2923 proc pkgconf::create_toplevel_window { } { | |
| 2924 | |
| 2925 variable toplevel | |
| 2926 | |
| 2927 # Start by creating the menubar. TK8's support for native menus is | |
| 2928 # used. | |
| 2929 menu .menubar -type menubar | |
| 2930 menu .menubar.config -tearoff 0 -type normal | |
| 2931 menu .menubar.edit -tearoff 0 -type normal | |
| 2932 menu .menubar.view -tearoff 0 -type normal | |
| 2933 menu .menubar.help -tearoff 0 -type normal | |
| 2934 | |
| 2935 .menubar.config add command -label "Exit" -command pkgconf::handle_exit -underline 1 \ | |
| 2936 -accelerator "Alt+Q" | |
| 2937 | |
| 2938 .menubar.edit add command -label "Undo" -state disabled | |
| 2939 .menubar.edit add command -label "Redo" -state disabled | |
| 2940 | |
| 2941 .menubar.view add checkbutton -label "Show output" \ | |
| 2942 -variable pkgconf::output_visible -onvalue 1 -offvalue 0 \ | |
| 2943 -command pkgconf::output_menu | |
| 2944 .menubar.view add checkbutton -label "Balloon help" \ | |
| 2945 -variable pkgconf::efftcl::bhInfo(active) -onvalue 1 -offvalue 0 | |
| 2946 | |
| 2947 .menubar.help add command -label "Help on pkgconf" -state disabled | |
| 2948 .menubar.help add command -label "Help on the system" -state disabled | |
| 2949 .menubar.help add command -label "Search" -state disabled | |
| 2950 .menubar.help add separator | |
| 2951 .menubar.help add command -label "About pkgconf" -state disabled | |
| 2952 | |
| 2953 .menubar add cascade -menu .menubar.config -label "Configuration" -underline 0 | |
| 2954 .menubar add cascade -menu .menubar.edit -label "Edit" -underline 0 | |
| 2955 .menubar add cascade -menu .menubar.view -label "View" -underline 0 | |
| 2956 .menubar add cascade -menu .menubar.help -label "Help" -underline 0 | |
| 2957 | |
| 2958 # Create the toplevel window, giving it a menubar and a name, | |
| 2959 # and establish the accelerator binding. | |
| 2960 toplevel $toplevel -menu .menubar -class Pkgconf | |
| 2961 wm title $toplevel pkgconf | |
| 2962 bind $toplevel <Alt-q> { pkgconf::handle_exit } | |
| 2963 wm protocol $toplevel WM_DELETE_WINDOW { pkgconf::handle_exit } | |
| 2964 | |
| 2965 # Although there is a Configuration menu instead of a file menu, it is | |
| 2966 # desirable to support alt-f-x as a reasonably standard way of exiting | |
| 2967 # the program. | |
| 2968 bind $toplevel <Alt-f><KeyPress-x> { pkgconf::handle_exit } | |
| 2969 } | |
| 2970 | |
| 2971 # ---------------------------------------------------------------------------- | |
| 2972 # This routine gets invoked for exit handling: when the user invokes the | |
| 2973 # exit entry on the file menu; or when the alt-q accelerator is used; or | |
| 2974 # when a window delete request is received. For now the code just exits, | |
| 2975 # but it might be an idea to offer to save configuration changes if any. | |
| 2976 # | |
| 2977 proc pkgconf::handle_exit { } { | |
| 2978 exit 0 | |
| 2979 } | |
| 2980 | |
| 2981 # }}} | |
| 2982 # {{{ Notebook pages | |
| 2983 | |
| 2984 # {{{ Targets page | |
| 2985 | |
| 2986 # ---------------------------------------------------------------------------- | |
| 2987 # The targets page. This allows the user to select the target architecture, | |
| 2988 # platform, and startup. The range of available target architectures cannot | |
| 2989 # change while the program is running, so this window is actually fixed. | |
| 2990 # | |
| 2991 | |
| 2992 proc pkgconf::nbpage_targets_initialise { win } { | |
| 2993 | |
| 2994 variable config_data | |
| 2995 variable known_targets | |
| 2996 variable target_data | |
| 2997 variable target_page_data | |
| 2998 | |
| 2999 # I need a variable that can be associated with the radiobuttons and | |
| 3000 # identifies the selected target uniquely. It is not really | |
| 3001 # possible to do this with the three variables in the config data | |
| 3002 # directly. | |
| 3003 set target_page_data(selection) [list $config_data(target) $config_data(platform) $config_data(startup)] | |
| 3004 | |
| 3005 # Conceivably the number of targets could be larger than can fit | |
| 3006 # conveniently on to one screen, so it is desirable use a scrollable | |
| 3007 # form. Start by creating a scrollbar, a canvas, and a frame within | |
| 3008 # that canvas, and set up a standard resize callback. The canvas | |
| 3009 # starts off small, but expands as necessary. The actual size will | |
| 3010 # therefore be determined by whichever page does not have a | |
| 3011 # vertical scrollbar, typically the build page. | |
| 3012 scrollbar $win.scrollbar -command "$win.viewport yview" -orient vertical | |
| 3013 pack $win.scrollbar -side right -fill y | |
| 3014 | |
| 3015 canvas $win.viewport -height 10m -yscrollcommand "$win.scrollbar set" | |
| 3016 pack $win.viewport -fill both -expand 1 -padx 20 -pady 20 | |
| 3017 | |
| 3018 frame $win.viewport.form | |
| 3019 $win.viewport create window 0 0 -anchor nw -window $win.viewport.form | |
| 3020 | |
| 3021 bind $win.viewport.form <Configure> "pkgconf::nbpage_form_resized $win" | |
| 3022 | |
| 3023 # Now fill in the form with details of all the targets. | |
| 3024 # These are arranged in a simple grid. | |
| 3025 set form $win.viewport.form | |
| 3026 set row 0 | |
| 3027 | |
| 3028 foreach target $known_targets { | |
| 3029 | |
| 3030 label $form.arch-$row -text "Target [get_target_alias $target]" -anchor w | |
| 3031 grid $form.arch-$row -row $row -column 0 -sticky w | |
| 3032 incr row | |
| 3033 | |
| 3034 foreach platform $target_data($target,known_platforms) { | |
| 3035 foreach startup $target_data($target,$platform,startup) { | |
| 3036 | |
| 3037 label $form.platform-$row -text " Platform [get_platform_alias $target $platform]," -anchor w | |
| 3038 grid $form.platform-$row -row $row -column 0 -sticky w | |
| 3039 label $form.startup-$row -text "$startup startup" -anchor w | |
| 3040 grid $form.startup-$row -row $row -column 1 -sticky w -ipadx 5 | |
| 3041 radiobutton $form.button-$row -variable pkgconf::target_page_data(selection) \ | |
| 3042 -value [list $target $platform $startup] \ | |
| 3043 -command pkgconf::clear_status_line | |
| 3044 grid $form.button-$row -row $row -column 2 -sticky w | |
| 3045 incr row | |
| 3046 } | |
| 3047 } | |
| 3048 } | |
| 3049 } | |
| 3050 | |
| 3051 # | |
| 3052 # The enter routine gets invoked when the user switches to the targets tab, | |
| 3053 # and also during start-up since the targets tab is the first one. It is | |
| 3054 # responsible for keeping track of the initial target selection, so that | |
| 3055 # when the user switches to a different tab it is possible to know whether | |
| 3056 # or not the target has actually changed. | |
| 3057 # | |
| 3058 # As a useful side effect, the routine updates the status line. | |
| 3059 # | |
| 3060 proc pkgconf::nbpage_targets_enter { win } { | |
| 3061 | |
| 3062 variable config_data | |
| 3063 variable target_page_data | |
| 3064 | |
| 3065 set target_page_data(initial_selection) $target_page_data(selection) | |
| 3066 | |
| 3067 if { ($config_data(target) == "") || ($config_data(platform) == "") || ($config_data(startup) == "") } { | |
| 3068 set_status_line "Please select a target system." | |
| 3069 } else { | |
| 3070 clear_status_line | |
| 3071 } | |
| 3072 } | |
| 3073 | |
| 3074 proc pkgconf::nbpage_targets_leave { win } { | |
| 3075 | |
| 3076 variable target_page_data | |
| 3077 | |
| 3078 if { $target_page_data(selection) != $target_page_data(initial_selection) } { | |
| 3079 variable config_data | |
| 3080 variable build_tree_needs_update | |
| 3081 | |
| 3082 set config_data(target) [lindex $target_page_data(selection) 0] | |
| 3083 set config_data(platform) [lindex $target_page_data(selection) 1] | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
3084 set config_data(base_platform) [get_base_platform $config_data(target) $config_data(platform)] |
| 0 | 3085 set config_data(startup) [lindex $target_page_data(selection) 2] |
| 3086 set build_tree_needs_update 1 | |
| 3087 | |
| 3088 # A change of target has implications for the compiler flags, which | |
| 3089 # must be handled immediately. The user may not go into the flags | |
| 3090 # tab so the changes cannot be done in the flags tab enter/leave | |
| 3091 # routines. | |
| 3092 update_compiler_flags | |
| 3093 } | |
| 3094 } | |
| 3095 | |
| 3096 # | |
| 3097 # This routine take care of resize operations. Whenever the size | |
| 3098 # of the form changes the canvas' scroll region needs to be adjusted. | |
| 3099 # | |
| 3100 # Note that this code is also used for the packages page. | |
| 3101 # | |
| 3102 proc pkgconf::nbpage_form_resized { win } { | |
| 3103 | |
| 3104 set bbox [$win.viewport bbox all] | |
| 3105 set old_bbox [$win.viewport cget -scrollregion] | |
| 3106 set width [winfo width $win.viewport.form] | |
| 3107 set old_width [$win.viewport cget -width] | |
| 3108 if { ("$bbox" != "$old_bbox") || ($width != $old_width) } { | |
| 3109 $win.viewport configure -width $width -scrollregion $bbox | |
| 3110 } | |
| 3111 } | |
| 3112 | |
| 3113 # }}} | |
| 3114 # {{{ Packages page | |
| 3115 | |
| 3116 # ---------------------------------------------------------------------------- | |
| 3117 # The packages page. This is mostly similar to the targets page. | |
| 3118 # It is necessary to provide a mechanism for disabling packages. | |
| 3119 # It is also necessary to worry about changes to the target architecture. | |
| 3120 # The initialise() routine takes care of most of these things. | |
| 3121 | |
| 3122 proc pkgconf::nbpage_packages_initialise { win } { | |
| 3123 | |
| 3124 variable config_data | |
| 3125 variable known_packages | |
| 3126 variable package_data | |
| 3127 variable target_data | |
| 3128 variable packages_page_data | |
| 3129 | |
| 3130 # Start by storing details of the target that is currently | |
| 3131 # being displayed. | |
| 3132 set packages_page_data(current_target) $config_data(target) | |
| 3133 set packages_page_data(current_platform) $config_data(platform) | |
| 3134 | |
| 3135 # Typically the number of packages will be larger than can fit | |
| 3136 # conveniently on to one screen, so it is desirable use a scrollable | |
| 3137 # form. Start by creating a scrollbar, a canvas, and a frame within | |
| 3138 # that canvas, and set up a standard resize callback. The canvas | |
| 3139 # starts of small, but expands as necessary. The actual size will | |
| 3140 # therefore be determined by whichever page does not have a | |
| 3141 # vertical scrollbar, typically the build page. | |
| 3142 scrollbar $win.scrollbar -command "$win.viewport yview" -orient vertical | |
| 3143 pack $win.scrollbar -side right -fill y | |
| 3144 | |
| 3145 canvas $win.viewport -height 10m -yscrollcommand "$win.scrollbar set" | |
| 3146 pack $win.viewport -fill both -expand 1 -padx 20 -pady 20 | |
| 3147 | |
| 3148 frame $win.viewport.form | |
| 3149 $win.viewport create window 0 0 -anchor nw -window $win.viewport.form | |
| 3150 | |
| 3151 bind $win.viewport.form <Configure> "pkgconf::nbpage_form_resized $win" | |
| 3152 | |
| 3153 # Now fill in the form with details of all the packages. | |
| 3154 # These are arranged in a simple grid. | |
| 3155 set form $win.viewport.form | |
| 3156 set row 0 | |
| 3157 | |
| 3158 # Now handle the packages themselves. Each package can be in one | |
| 3159 # of the following states: | |
| 3160 # | |
| 3161 # 1) a hardware package is enabled by default if it is specified | |
| 3162 # for the current target or platform, disabled otherwise. | |
| 3163 # However the user should be able to explicitly enable or | |
| 3164 # disable it. This is handled by config_data(enabled_packages) | |
| 3165 # and config_data(disabled_packages). | |
| 3166 # | |
| 3167 # 2) a non-hardware package may be enabled or disabled by default, | |
| 3168 # but the user can change this. Again this is handled by | |
| 3169 # enabled_packages and disabled_packages. | |
| 3170 # | |
| 3171 # It is convenient to cache the list of target and platform specific | |
| 3172 # packages. | |
| 3173 set target_packages "" | |
| 3174 set platform_packages "" | |
| 3175 if { $config_data(target) != "" } { | |
| 3176 set target_packages $target_data($config_data(target),packages) | |
| 3177 if { $config_data(platform) != "" } { | |
| 3178 set platform_packages $target_data($config_data(target),$config_data(platform),packages) | |
| 3179 } | |
| 3180 } | |
| 3181 foreach pkg $known_packages { | |
| 3182 | |
| 3183 # What is the current version of each package ? | |
| 3184 set current_version "" | |
| 3185 | |
| 3186 if { $package_data($pkg,hardware) != 0 } { | |
| 3187 if { ([lsearch -exact $target_packages $pkg] != -1) || ([lsearch -exact $platform_packages $pkg] != -1)} { | |
| 3188 set current_version $config_data($pkg,version) | |
| 3189 } | |
| 3190 } elseif { $package_data($pkg,default) != 0 } { | |
| 3191 set current_version $config_data($pkg,version) | |
| 3192 } | |
| 3193 | |
| 3194 if { [lsearch -exact $config_data(enabled_packages) $pkg] != -1 } { | |
| 3195 set current_version $config_data($pkg,version) | |
| 3196 } | |
| 3197 if { [lsearch -exact $config_data(disabled_packages) $pkg] != -1 } { | |
| 3198 set current_version "" | |
| 3199 } | |
| 3200 | |
| 3201 # Store the current version, so that it is easier to figure out what | |
| 3202 # has changed. | |
| 3203 set packages_page_data($pkg,version) $current_version | |
| 3204 | |
| 3205 label $form.label-$row -text "[get_package_alias $pkg]:" | |
| 3206 grid $form.label-$row -row $row -column 0 -sticky w | |
| 3207 foreach version $package_data($pkg,versions) { | |
| 3208 label $form.version-$row -text "Version $version" | |
| 3209 grid $form.version-$row -row $row -column 1 -sticky w -ipady 5 | |
| 3210 | |
| 3211 radiobutton $form.button-$row -variable pkgconf::packages_page_data($pkg,version) \ | |
| 3212 -value $version -command [list pkgconf::nbpage_packages_change $pkg] | |
| 3213 grid $form.button-$row -row $row -column 2 -sticky w | |
| 3214 incr row | |
| 3215 } | |
| 3216 label $form.version-$row -text "Disable" | |
| 3217 grid $form.version-$row -row $row -column 1 -sticky w | |
| 3218 radiobutton $form.button-$row -variable pkgconf::packages_page_data($pkg,version) \ | |
| 3219 -value "" -command [list pkgconf::nbpage_packages_change $pkg] | |
| 3220 grid $form.button-$row -row $row -column 2 -sticky w | |
| 3221 incr row | |
| 3222 } | |
| 3223 } | |
| 3224 | |
| 3225 # | |
| 3226 # This routine gets invoked whenever there is a change to one of the | |
| 3227 # packages. It sets a flag indicating that the build tree is out of data. | |
| 3228 # It will also update the appropriate config_data. | |
| 3229 # | |
| 3230 proc pkgconf::nbpage_packages_change { pkg } { | |
| 3231 | |
| 3232 variable build_tree_needs_update | |
| 3233 set build_tree_needs_update 1 | |
| 3234 | |
| 3235 variable packages_page_data | |
| 3236 variable config_data | |
| 3237 | |
| 3238 set version $packages_page_data($pkg,version) | |
| 3239 if { $version == "" } { | |
| 3240 | |
| 3241 # This package is being explicitly disabled. | |
| 3242 set index [lsearch -exact $config_data(enabled_packages) $pkg] | |
| 3243 if { $index != -1 } { | |
| 3244 set config_data(enabled_packages) [lreplace $config_data(enabled_packages) $index $index] | |
| 3245 } | |
| 3246 | |
| 3247 set index [lsearch -exact $config_data(disabled_packages) $pkg] | |
| 3248 if { $index == -1 } { | |
| 3249 lappend config_data(disabled_packages) $pkg | |
| 3250 } | |
| 3251 } else { | |
| 3252 | |
| 3253 # A package version is being changed, possibly causing it to | |
| 3254 # be enabled. | |
| 3255 set config_data($pkg,version) $version | |
| 3256 | |
| 3257 set index [lsearch -exact $config_data(disabled_packages) $pkg] | |
| 3258 if { $index != -1 } { | |
| 3259 set config_data(disabled_packages) [lreplace $config_data(disabled_packages) $index $index] | |
| 3260 } | |
| 3261 | |
| 3262 set index [lsearch -exact $config_data(enabled_packages) $pkg] | |
| 3263 if { $index == -1 } { | |
| 3264 lappend config_data(enabled_packages) $pkg | |
| 3265 } | |
| 3266 } | |
| 3267 } | |
| 3268 | |
| 3269 # | |
| 3270 # The packages page needs to be redrawn every time a different target is | |
| 3271 # selected, so that the user can select which version of the HAL packages | |
| 3272 # should be used. The redraw can be achieved by deleting the existing | |
| 3273 # contents of the window and re-invoking the initialise function. | |
| 3274 | |
| 3275 proc pkgconf::nbpage_packages_enter { win } { | |
| 3276 | |
| 3277 variable packages_page_data | |
| 3278 variable config_data | |
| 3279 | |
| 3280 if { ($packages_page_data(current_target) != $config_data(target)) || | |
| 3281 ($packages_page_data(current_platform) != $config_data(platform)) } { | |
| 3282 | |
| 3283 foreach subwin [winfo children $win] { | |
| 3284 destroy $subwin | |
| 3285 } | |
| 3286 nbpage_packages_initialise $win | |
| 3287 } | |
| 3288 | |
| 3289 # If the target architecture is not yet known, remind the user. | |
| 3290 if { ($config_data(target) == "") || ($config_data(platform) == "") || ($config_data(startup) == "") } { | |
| 3291 set_status_line "Please select a target system." | |
| 3292 } else { | |
| 3293 clear_status_line | |
| 3294 } | |
| 3295 } | |
| 3296 | |
| 3297 # | |
| 3298 # Currently this code does nothing, instead it is left to the | |
| 3299 # nbpage_packages_change routine above to update the appropriate | |
| 3300 # global information. This is unfortunate in that if the user | |
| 3301 # makes a mistake and undoes it pkgconf still thinks that the | |
| 3302 # build tree is out of date. | |
| 3303 | |
| 3304 proc pkgconf::nbpage_packages_leave { win } { | |
| 3305 } | |
| 3306 | |
| 3307 # }}} | |
| 3308 # {{{ Options page | |
| 3309 | |
| 3310 # ---------------------------------------------------------------------------- | |
| 3311 # The options page. This consists of two frame arranged vertically. | |
| 3312 # The top frame allows the user to select the editor to use, which is | |
| 3313 # initialised from the VISUAL environment variable. The bottom frame | |
| 3314 # is another scrollable canvas allowing the user to select a header | |
| 3315 # file to edit. | |
| 3316 # | |
| 3317 # A number of special cases have to be allowed for. If there is no | |
| 3318 # text editor then all the buttons to edit a text file have to | |
| 3319 # be disabled. If there is no pkgconf directory in the build tree | |
| 3320 # yet then there will be no files to edit. Even if there is an | |
| 3321 # an pkgconf directory it may not contain all the files it is | |
| 3322 # supposed to, especially if the build tree is not up to date. | |
| 3323 # | |
| 3324 | |
| 3325 proc pkgconf::nbpage_options_initialise { win } { | |
| 3326 | |
| 3327 # Start with the top frame. This contains a label, an entry field, | |
| 3328 # and a button that invokes a file selector. | |
| 3329 # NOTE: these borderwidths should not be hardwired. | |
| 3330 variable editor | |
| 3331 frame $win.top -relief raised -borderwidth 2 | |
| 3332 label $win.top.label -text "Editor:" | |
| 3333 entry $win.top.entry -relief sunken -borderwidth 2 -textvariable pkgconf::editor | |
| 3334 button $win.top.button -text "Browse..." -command pkgconf::nbpage_options_browse | |
| 3335 pack $win.top.button -side right | |
| 3336 pack $win.top.entry -side right -fill x -expand 1 | |
| 3337 pack $win.top.label -side left | |
| 3338 pack $win.top -side top -fill x | |
| 3339 | |
| 3340 efftcl::balloonhelp_for $win.top.entry "The text editor that should be used." | |
| 3341 efftcl::balloonhelp_for $win.top.button "Select the text editor that should be used." | |
| 3342 | |
| 3343 # The entry widget does not support a command callback when | |
| 3344 # a string has been typed in, so it is necessary to use the | |
| 3345 # trace facility instead to enable or disable the buttons. | |
| 3346 # Note that this routine may get invoked from the update routine, | |
| 3347 # so it is necessary to clean up the old trace. | |
| 3348 trace vdelete pkgconf::editor w pkgconf::nbpage_options_editor_changed | |
| 3349 trace variable pkgconf::editor w pkgconf::nbpage_options_editor_changed | |
| 3350 | |
| 3351 # At this point there are now button widgets in this page. The | |
| 3352 # nbpage_options_editor_changed routine used this list. | |
| 3353 variable options_page_data | |
| 3354 set options_page_data(buttons) "" | |
| 3355 | |
| 3356 # Now check for editable files in the pkgconf directory. | |
| 3357 # Three of the files, makefile, pkgconf.mak and system.h are generated | |
| 3358 # and should not be edited by users. There may also be various .stamp | |
| 3359 # files used by the build system. | |
| 3360 variable build_tree | |
| 3361 set files "" | |
| 3362 foreach filename [glob -nocomplain [file join $build_tree "pkgconf" "*"]] { | |
| 3363 set filename [file tail $filename] | |
| 3364 if { [string match {*.stamp} $filename] } continue | |
| 3365 if { ($filename == "makefile") || ($filename == "pkgconf.mak") || ($filename == "system.h") } continue | |
| 3366 lappend files $filename | |
| 3367 } | |
| 3368 | |
| 3369 if { $files == "" } { | |
| 3370 | |
| 3371 # OK, just display a message. There is likely to be an appropriate | |
| 3372 # warning in the message frame at the bottom of the window already. | |
| 3373 label $win.message -text "There are no configuration files to edit." | |
| 3374 pack $win.message -fill both -expand 1 | |
| 3375 | |
| 3376 # A valid configuration always has a makevars file to edit, so the | |
| 3377 # implication is that the build tree is out of date. It probably | |
| 3378 # makes sense to set the relevant flag here. | |
| 3379 variable build_tree_needs_update | |
| 3380 set build_tree_needs_update 1 | |
| 3381 return | |
| 3382 } | |
| 3383 | |
| 3384 # The editable files are displayed in a scrollable frame, just | |
| 3385 # like the targets and packages pages. | |
| 3386 scrollbar $win.scrollbar -command "$win.viewport yview" -orient vertical | |
| 3387 pack $win.scrollbar -side right -fill y | |
| 3388 | |
| 3389 canvas $win.viewport -height 10m -yscrollcommand "$win.scrollbar set" | |
| 3390 pack $win.viewport -fill both -expand 1 -padx 20 -pady 20 | |
| 3391 | |
| 3392 frame $win.viewport.form | |
| 3393 $win.viewport create window 0 0 -anchor nw -window $win.viewport.form | |
| 3394 | |
| 3395 bind $win.viewport.form <Configure> "pkgconf::nbpage_form_resized $win" | |
| 3396 | |
| 3397 # Now fill in the form with all the buttons. | |
| 3398 set form $win.viewport.form | |
| 3399 set row 0 | |
| 3400 | |
| 3401 foreach file $files { | |
| 3402 | |
| 3403 button $form.button-$row -text "<pkgconf/$file>" -anchor w \ | |
| 3404 -command [list pkgconf::nbpage_options_edit $file] | |
| 3405 grid $form.button-$row -row $row -column 0 -sticky we -padx 10 -pady 5 | |
| 3406 label $form.label-$row -anchor w -text "Edit [file join $build_tree pkgconf $file]" | |
| 3407 grid $form.label-$row -row $row -column 1 -sticky w | |
| 3408 | |
| 3409 efftcl::balloonhelp_for $form.button-$row "Edit this configuration file." | |
| 3410 lappend options_page_data(buttons) $form.button-$row | |
| 3411 if { $editor == "" } { | |
| 3412 $form.button-$row configure -state disabled | |
| 3413 } | |
| 3414 incr row | |
| 3415 } | |
| 3416 } | |
| 3417 | |
| 3418 # The options page needs to be redrawn every time the build tree is | |
| 3419 # regenerated, since this may result in a different set of editable | |
| 3420 # configuration header files. | |
| 3421 | |
| 3422 proc pkgconf::nbpage_options_enter { win } { | |
| 3423 | |
| 3424 variable options_page_needs_refresh | |
| 3425 | |
| 3426 if { $options_page_needs_refresh != 0 } { | |
| 3427 set options_page_needs_refresh 0 | |
| 3428 foreach subwin [winfo children $win] { destroy $subwin } | |
| 3429 nbpage_options_initialise $win | |
| 3430 } | |
| 3431 | |
| 3432 # It is also desirable to display some warnings. | |
| 3433 variable config_data | |
| 3434 variable build_tree_needs_update | |
| 3435 variable editor | |
| 3436 variable options_page_data | |
| 3437 | |
| 3438 set options_page_data(no_editor) 0 | |
| 3439 | |
| 3440 if { ($config_data(target) == "") || ($config_data(platform) == "") || ($config_data(startup) == "") } { | |
| 3441 set_status_line "The target hardware has not yet been selected." | |
| 3442 } elseif { $build_tree_needs_update } { | |
| 3443 set_status_line "The build tree needs updating." | |
| 3444 } elseif { $editor == "" } { | |
| 3445 set options_page_data(no_editor) 1 | |
| 3446 set_status_line "No text editor has been defined yet." | |
| 3447 } else { | |
| 3448 clear_status_line | |
| 3449 } | |
| 3450 } | |
| 3451 | |
| 3452 # | |
| 3453 # There are no obvious actions to be taken if the user switches to | |
| 3454 # a different tab. Even if the user has invoked the editor on a | |
| 3455 # configuration file there is no guarantee that anything has actually | |
| 3456 # changed. | |
| 3457 proc pkgconf::nbpage_options_leave { win } { | |
| 3458 } | |
| 3459 | |
| 3460 # | |
| 3461 # This procedure allows the user to select a text editor. It gets invoked | |
| 3462 # from the browse button. | |
| 3463 # | |
| 3464 # NOTE: on windows it might be desirable to specify a .exe extension as | |
| 3465 # the type, but even that is optional under NT. | |
| 3466 # | |
| 3467 proc pkgconf::nbpage_options_browse { } { | |
| 3468 | |
| 3469 variable editor | |
| 3470 variable build_tree | |
| 3471 variable toplevel | |
| 3472 | |
| 3473 set filename [tk_getOpenFile -initialdir $build_tree -parent $toplevel -title "Select text editor"] | |
| 3474 if { $filename == "" } { | |
| 3475 return | |
| 3476 } | |
| 3477 set editor $filename | |
| 3478 } | |
| 3479 | |
| 3480 # | |
| 3481 # This procedure is invoked whenever the editor variable is changed. | |
| 3482 # Its purpose is to enable or disable the buttons for the various | |
| 3483 # configuration headers. | |
| 3484 # | |
| 3485 # The code does not actually check whether the current editor value corresponds | |
| 3486 # to a valid executable. It is just about possible to check for an existing | |
| 3487 # file somewhere in the path, but that is expensive and there is still no | |
| 3488 # guarantee that the file is a valid executable. | |
| 3489 # | |
| 3490 | |
| 3491 proc pkgconf::nbpage_options_editor_changed { name1 name2 mode } { | |
| 3492 | |
| 3493 variable editor | |
| 3494 variable options_page_data | |
| 3495 variable toplevel | |
| 3496 | |
| 3497 if { $editor == "" } { | |
| 3498 | |
| 3499 foreach button $options_page_data(buttons) { | |
| 3500 $button configure -state disabled | |
| 3501 } | |
| 3502 } else { | |
| 3503 if { $options_page_data(no_editor) } { | |
| 3504 $toplevel.message configure -text "" | |
| 3505 set options_page_data(no_editor) 0 | |
| 3506 } | |
| 3507 foreach button $options_page_data(buttons) { | |
| 3508 $button configure -state normal | |
| 3509 } | |
| 3510 } | |
| 3511 } | |
| 3512 | |
| 3513 # This routine gets invoked to edit a header file. It simply | |
| 3514 # executes the current editor in the background. No attempt is | |
| 3515 # made to wait for command completion, to prevent a single file | |
| 3516 # from being edited multiple times, or anything like that. | |
| 3517 | |
| 3518 proc pkgconf::nbpage_options_edit { filename } { | |
| 3519 | |
| 3520 variable editor | |
| 3521 variable build_tree | |
| 3522 | |
| 3523 run_command pkgconf::nbpage_options_ignore $editor [file join $build_tree pkgconf $filename] | |
| 3524 } | |
| 3525 | |
| 3526 # This callback gets invoked from the run_command code whenever the | |
| 3527 # editor sends output. In the case of emacsclient such output | |
| 3528 # is the unfortunate string "Waiting for Emacs...Done". In the case | |
| 3529 # of xterm -e vi there is no output. | |
| 3530 # | |
| 3531 # On the whole it is better to ignore the output. This may mean | |
| 3532 # that warning or error messages get discared. | |
| 3533 | |
| 3534 proc pkgconf::nbpage_options_ignore { msg } { | |
| 3535 | |
| 3536 } | |
| 3537 | |
| 3538 # }}} | |
| 3539 # {{{ Flags page | |
| 3540 | |
| 3541 # ---------------------------------------------------------------------------- | |
| 3542 # The flags page. This consists of a big grid, arranged vertically into | |
| 3543 # five separate categories of flags. Within each category there is a | |
| 3544 # label identifying the category and four separate entry fields for the | |
| 3545 # various variables. | |
| 3546 # | |
| 3547 # The data for a given flag can come from two sources. The default value | |
| 3548 # comes from the targets file, and in most cases this will be an empty | |
| 3549 # string. Alternatively the user can overwrite it, e.g. as a command | |
| 3550 # line argument or in the GUI, in which case the changed information | |
| 3551 # gets saved in the pkgconf save file. | |
| 3552 # | |
| 3553 | |
| 3554 proc pkgconf::nbpage_flags_initialise { win } { | |
| 3555 | |
| 3556 variable flags_page_data | |
| 3557 variable known_compiler_flags | |
| 3558 variable config_data | |
| 3559 | |
| 3560 # Start by creating array entries for all the known compiler flags. | |
| 3561 if { ($config_data(target) != "") && ($config_data(platform) != "") } { | |
| 3562 foreach flag $known_compiler_flags { | |
| 3563 set flags_page_data($flag) [get_platform_cflags $config_data(target) $config_data(platform) $flag] | |
| 3564 } | |
| 3565 } else { | |
| 3566 foreach flag $known_compiler_flags { | |
| 3567 set flags_page_data($flag) "" | |
| 3568 } | |
| 3569 } | |
| 3570 | |
| 3571 # If the current configuration information contains any compiler flags, | |
| 3572 # update the appropriate variable. | |
| 3573 foreach flag $known_compiler_flags { | |
| 3574 if { [info exists config_data(cflags,$flag)] } { | |
| 3575 set flags_page_data($flag) $config_data(cflags,$flag) | |
| 3576 } | |
| 3577 } | |
| 3578 | |
| 3579 # Keep track of which target and platform the current settings correspond to. | |
| 3580 set flags_page_data(target) $config_data(target) | |
| 3581 set flags_page_data(platform) $config_data(platform) | |
| 3582 | |
| 3583 # Time to actually create the interface. | |
| 3584 # Again this tab uses a frame inside a scrolled canvas. | |
| 3585 scrollbar $win.scrollbar -command "$win.viewport yview" -orient vertical | |
| 3586 pack $win.scrollbar -side right -fill y | |
| 3587 | |
| 3588 canvas $win.viewport -height 10m -yscrollcommand "$win.scrollbar set" | |
| 3589 pack $win.viewport -fill both -expand 1 -padx 20 -pady 20 | |
| 3590 | |
| 3591 frame $win.viewport.form | |
| 3592 $win.viewport create window 0 0 -anchor nw -window $win.viewport.form | |
| 3593 | |
| 3594 bind $win.viewport.form <Configure> "pkgconf::nbpage_form_resized $win" | |
| 3595 | |
| 3596 # Now fill in the form with details of all the flags. | |
| 3597 # These are arranged in a simple grid. | |
| 3598 set form $win.viewport.form | |
| 3599 set row 0 | |
| 3600 | |
| 3601 grid columnconfigure $form 1 -weight 1 | |
| 3602 label $form.archflags -text "Architecture-related compiler flags" | |
| 3603 grid $form.archflags -row $row -column 0 -columnspan 2 -sticky w | |
| 3604 incr row | |
| 3605 foreach flag { ARCHFLAGS CARCHFLAGS CXXARCHFLAGS LDARCHFLAGS } { | |
| 3606 label $form.label-$flag -text $flag | |
| 3607 grid $form.label-$flag -row $row -column 0 -sticky w | |
| 3608 entry $form.entry-$flag -textvariable pkgconf::flags_page_data($flag) -width 60 | |
| 3609 grid $form.entry-$flag -row $row -column 1 -sticky we | |
| 3610 incr row | |
| 3611 } | |
| 3612 | |
| 3613 label $form.errflags -text "Warnings and errors" | |
| 3614 grid $form.errflags -row $row -column 0 -columnspan 2 -sticky w | |
| 3615 incr row | |
| 3616 foreach flag { ERRFLAGS CERRFLAGS CXXERRFLAGS LDERRFLAGS } { | |
| 3617 label $form.label-$flag -text $flag | |
| 3618 grid $form.label-$flag -row $row -column 0 -sticky w | |
| 3619 entry $form.entry-$flag -textvariable pkgconf::flags_page_data($flag) | |
| 3620 grid $form.entry-$flag -row $row -column 1 -sticky we | |
| 3621 incr row | |
| 3622 } | |
| 3623 | |
| 3624 label $form.dbgflags -text "Debugging and optimization levels" | |
| 3625 grid $form.dbgflags -row $row -column 0 -columnspan 2 -sticky w | |
| 3626 incr row | |
| 3627 foreach flag { DBGFLAGS CDBGFLAGS CXXDBGFLAGS LDDBGFLAGS } { | |
| 3628 label $form.label-$flag -text $flag | |
| 3629 grid $form.label-$flag -row $row -column 0 -sticky w | |
| 3630 entry $form.entry-$flag -textvariable pkgconf::flags_page_data($flag) | |
| 3631 grid $form.entry-$flag -row $row -column 1 -sticky we | |
| 3632 incr row | |
| 3633 } | |
| 3634 | |
| 3635 label $form.langflags -text "Language-related flags" | |
| 3636 grid $form.langflags -row $row -column 0 -columnspan 2 -sticky w | |
| 3637 incr row | |
| 3638 foreach flag { LANGFLAGS CLANGFLAGS CXXLANGFLAGS LDLANGFLAGS } { | |
| 3639 label $form.label-$flag -text $flag | |
| 3640 grid $form.label-$flag -row $row -column 0 -sticky w | |
| 3641 entry $form.entry-$flag -textvariable pkgconf::flags_page_data($flag) | |
| 3642 grid $form.entry-$flag -row $row -column 1 -sticky we | |
| 3643 incr row | |
| 3644 } | |
| 3645 | |
| 3646 label $form.extraflags -text "Miscellaneous" | |
| 3647 grid $form.extraflags -row $row -column 0 -columnspan 2 -sticky w | |
| 3648 incr row | |
| 3649 foreach flag { EXTRAFLAGS CEXTRAFLAGS CXXEXTRAFLAGS LDEXTRAFLAGS } { | |
| 3650 label $form.label-$flag -text $flag | |
| 3651 grid $form.label-$flag -row $row -column 0 -sticky w | |
| 3652 entry $form.entry-$flag -textvariable pkgconf::flags_page_data($flag) | |
| 3653 grid $form.entry-$flag -row $row -column 1 -sticky we | |
| 3654 incr row | |
| 3655 } | |
| 3656 } | |
| 3657 | |
| 3658 # | |
| 3659 # There is nothing to be done on entry to this tab. If the target architecture | |
| 3660 # has changed then there will have been a separate call to update_compiler_flags | |
| 3661 # below. This cannot be delayed until the enter call because there is no | |
| 3662 # guarantee that the user will switch to the flags tab after changing target | |
| 3663 # architecture. | |
| 3664 # | |
| 3665 proc pkgconf::nbpage_flags_enter { win } { | |
| 3666 } | |
| 3667 | |
| 3668 # | |
| 3669 # On leaving the page it is necessary to check for any flags that are | |
| 3670 # different from the default settings, and update the config_data | |
| 3671 # settings appropriately. | |
| 3672 # | |
| 3673 proc pkgconf::nbpage_flags_leave { win } { | |
| 3674 | |
| 3675 variable config_data | |
| 3676 variable flags_page_data | |
| 3677 variable known_compiler_flags | |
| 3678 | |
| 3679 if { ($config_data(target) == "") && ($config_data(platform) == "") } { | |
| 3680 | |
| 3681 # If no target has been defined then it is not possible to compare | |
| 3682 # with the default setting. All that can be done is set or clear | |
| 3683 # the current config setting. | |
| 3684 foreach flag $known_compiler_flags { | |
| 3685 if { $flags_page_data($flag) == "" } { | |
| 3686 if { [info exists config_data(cflags,$flag) ] } { | |
| 3687 unset config_data(cflags,$flag) | |
| 3688 } | |
| 3689 } else { | |
| 3690 set config_data(cflags,$flag) $flags_page_data($flag) | |
| 3691 } | |
| 3692 } | |
| 3693 } else { | |
| 3694 | |
| 3695 # For any flag which currently has default settings, | |
| 3696 # clear the appropriate config_data() entry. Otherwise store | |
| 3697 # the flag data. | |
| 3698 foreach flag $known_compiler_flags { | |
| 3699 | |
| 3700 if { $flags_page_data($flag) == [get_platform_cflags $config_data(target) $config_data(platform) $flag] } { | |
| 3701 if { [info exists config_data(cflags,$flag) ] } { | |
| 3702 unset config_data(cflags,$flag) | |
| 3703 } | |
| 3704 } else { | |
| 3705 set config_data(cflags,$flag) $flags_page_data($flag) | |
| 3706 } | |
| 3707 } | |
| 3708 } | |
| 3709 } | |
| 3710 | |
| 3711 # | |
| 3712 # When the target architecture changes it is necessary to update the compiler | |
| 3713 # flags appropriately. Basically any flag that was defined by the old target | |
| 3714 # has to be cleared, and then any flag defined for the new target has to be | |
| 3715 # installed. There is a risk that some user changes will be lost, but there | |
| 3716 # is no easy solution to this. | |
| 3717 # | |
| 3718 proc pkgconf::update_compiler_flags { } { | |
| 3719 | |
| 3720 variable config_data | |
| 3721 variable flags_page_data | |
| 3722 variable known_compiler_flags | |
| 3723 | |
| 3724 foreach flag $known_compiler_flags { | |
| 3725 | |
| 3726 if { ($flags_page_data(target) == "") || ($flags_page_data(platform) == "") } { | |
| 3727 set old_default_flag "" | |
| 3728 } else { | |
| 3729 set old_default_flag [get_platform_cflags $flags_page_data(target) $flags_page_data(platform) $flag] | |
| 3730 } | |
| 3731 set new_default_flag [get_platform_cflags $config_data(target) $config_data(platform) $flag] | |
| 3732 | |
| 3733 # If there is no change to the default flags leave things well alone. | |
| 3734 # That way user changes will not get overwritten. | |
| 3735 if { $old_default_flag == $new_default_flag } { | |
| 3736 continue | |
| 3737 } | |
| 3738 | |
| 3739 # Otherwise always install the new settings, which may mean eliminating | |
| 3740 # user changes. | |
| 3741 set flags_page_data($flag) $new_default_flag | |
| 3742 if { [info exists config_data(cflags,$flag)] } { | |
| 3743 unset config_data(cflags,$flag) | |
| 3744 } | |
| 3745 } | |
| 3746 | |
| 3747 set flags_page_data(target) $config_data(target) | |
| 3748 set flags_page_data(platform) $config_data(platform) | |
| 3749 } | |
| 3750 | |
| 3751 # }}} | |
| 3752 # {{{ Build page | |
| 3753 | |
| 3754 # ---------------------------------------------------------------------------- | |
| 3755 # The build page. This consists of the following buttons, gridded, | |
| 3756 # with explanatory text. | |
| 3757 # | |
| 3758 # 1) Update build tree | |
| 3759 # 2) Make | |
| 3760 # 3) Make tests | |
| 2 | 3761 # 4) Make misc |
| 3762 # 5) Make clean | |
| 0 | 3763 # |
| 3764 # The make buttons should be disabled if the build tree is out of date. | |
| 3765 # This is controlled by the variable build_tree_needs_update, which | |
| 3766 # may have got set during the options page creation. An additional | |
| 3767 # check that needs to be made here is whether or not the makefile | |
| 3768 # exists. If the current config data does not specify the target | |
| 3769 # then even the "Update tree" button must be disabled. | |
| 3770 # | |
| 3771 # Whenever a make is in progress all the buttons should be disabled. | |
| 3772 # | |
| 3773 | |
| 3774 proc pkgconf::nbpage_build_initialise { win } { | |
| 3775 | |
| 3776 # Update the variable build_tree_needs_update if there is no | |
| 3777 # makefile in the build tree. | |
| 3778 variable build_tree_needs_update | |
| 3779 variable component_repository | |
| 3780 variable build_tree | |
| 3781 variable config_data | |
| 3782 | |
| 3783 if { [file isfile [file join $build_tree makefile]] == 0 } { | |
| 3784 set build_tree_needs_update 1 | |
| 3785 } | |
| 3786 if { ($config_data(target) == "") || ($config_data(platform) == "") || ($config_data(startup) == "") } { | |
| 3787 set build_tree_needs_update 1 | |
| 3788 } | |
| 3789 | |
| 3790 # Create three labels identifying the various trees. | |
| 3791 frame $win.top | |
| 3792 label $win.top.source_label -anchor w -text "Component repository:" | |
| 3793 label $win.top.source_value -anchor w -text "$component_repository" | |
| 3794 label $win.top.build_label -anchor w -text "Current build tree:" | |
| 3795 label $win.top.build_value -anchor w -text "$build_tree" | |
| 3796 label $win.top.install_label -anchor w -text "Current install tree:" | |
| 3797 label $win.top.install_value -anchor w -text "$config_data(prefix)" | |
| 3798 grid $win.top.source_label -row 0 -column 0 -sticky w | |
| 3799 grid $win.top.source_value -row 0 -column 1 -sticky we | |
| 3800 grid $win.top.build_label -row 1 -column 0 -sticky w | |
| 3801 grid $win.top.build_value -row 1 -column 1 -sticky we | |
| 3802 grid $win.top.install_label -row 2 -column 0 -sticky w | |
| 3803 grid $win.top.install_value -row 2 -column 1 -sticky we | |
| 3804 grid columnconfigure $win.top 1 -weight 1 | |
| 3805 pack $win.top -side top -fill x -padx 5 -pady 5 | |
| 3806 | |
| 3807 # Create a grid with the four buttons and with explanatory | |
| 3808 # messages. | |
| 3809 frame $win.grid | |
| 3810 pack $win.grid -fill both -expand 1 | |
| 3811 set win $win.grid | |
| 3812 | |
| 3813 button $win.tree -text "Update tree" -command pkgconf::nbpage_build_update_tree | |
| 3814 button $win.make -text "Make" -command pkgconf::nbpage_build_make | |
| 3815 button $win.tests -text "Make tests" -command pkgconf::nbpage_build_tests | |
| 2 | 3816 button $win.misc -text "Make misc" -command pkgconf::nbpage_build_misc |
| 0 | 3817 button $win.clean -text "Make clean" -command pkgconf::nbpage_build_clean |
| 3818 | |
| 3819 if { ($config_data(target) == "" ) || ($config_data(platform) == "") || ($config_data(startup) == "") } { | |
| 3820 $win.tree configure -state disabled | |
| 3821 } | |
| 3822 if { $build_tree_needs_update } { | |
| 3823 $win.make configure -state disabled | |
| 3824 $win.tests configure -state disabled | |
| 2 | 3825 $win.misc configure -state disabled |
| 0 | 3826 $win.clean configure -state disabled |
| 3827 } | |
| 3828 grid $win.tree -row 0 -column 0 -sticky we -padx 5 -pady 5 | |
| 3829 grid $win.make -row 1 -column 0 -sticky we -padx 5 -pady 5 | |
| 3830 grid $win.tests -row 2 -column 0 -sticky we -padx 5 -pady 5 | |
| 2 | 3831 grid $win.misc -row 3 -column 0 -sticky we -padx 5 -pady 5 |
| 3832 grid $win.clean -row 4 -column 0 -sticky we -padx 5 -pady 5 | |
| 0 | 3833 |
| 3834 message $win.treemsg -anchor w -justify left -width 300 -text \ | |
| 3835 "Create or update the build and install trees." | |
| 3836 message $win.makemsg -anchor w -justify left -width 300 -text \ | |
| 3837 "Build the current configuration, leaving libraries and header files in the install tree." | |
| 3838 message $win.testsmsg -anchor w -justify left -width 300 -text \ | |
| 3839 "Build the test executables for the current configuration. These executables will be\ | |
| 3840 placed in the install tree." | |
| 2 | 3841 message $win.miscmsg -anchor w -justify left -width 300 -text \ |
| 3842 "Build the misc executables for the current configuration. These executables will be\ | |
| 3843 placed in the misc directory." | |
| 0 | 3844 message $win.cleanmsg -anchor w -justify left -width 300 -text \ |
| 3845 "Perform a clean-up operation in the build and install trees." | |
| 3846 grid $win.treemsg -row 0 -column 1 -sticky we | |
| 3847 grid $win.makemsg -row 1 -column 1 -sticky we | |
| 3848 grid $win.testsmsg -row 2 -column 1 -sticky we | |
| 2 | 3849 grid $win.miscmsg -row 3 -column 1 -sticky we |
| 3850 grid $win.cleanmsg -row 4 -column 1 -sticky we | |
| 0 | 3851 grid columnconfigure $win 1 -weight 1 |
| 3852 } | |
| 3853 | |
| 3854 # The build page needs refreshing every time that the user changes the | |
| 3855 # target or one of the packages. The important question is whether or | |
| 3856 # not the build tree needs to be updated before any builds can take place. | |
| 3857 # Of course the build tree can only be generated if the target architecture | |
| 3858 # is known. | |
| 3859 | |
| 3860 proc pkgconf::nbpage_build_enter { win } { | |
| 3861 | |
| 3862 variable build_tree_needs_update | |
| 3863 variable build_frame | |
| 3864 variable toplevel | |
| 3865 | |
| 3866 if { $build_tree_needs_update } { | |
| 3867 $build_frame.grid.make configure -state disabled | |
| 3868 $build_frame.grid.tests configure -state disabled | |
| 2 | 3869 $build_frame.grid.misc configure -state disabled |
| 0 | 3870 $build_frame.grid.clean configure -state disabled |
| 3871 | |
| 3872 set_status_line "The build tree must be updated before this configuration can be built." | |
| 3873 } else { | |
| 3874 clear_status_line | |
| 3875 } | |
| 3876 | |
| 3877 variable config_data | |
| 3878 if { ($config_data(target) == "") || ($config_data(platform) == "") || ($config_data(startup) == "") } { | |
| 3879 $build_frame.grid.tree configure -state disabled | |
| 3880 set_status_line "The target hardware has not yet been selected." | |
| 3881 } else { | |
| 3882 $build_frame.grid.tree configure -state normal | |
| 3883 } | |
| 3884 } | |
| 3885 | |
| 3886 # | |
| 3887 # There are no actual settings that can be changed in this tab, | |
| 3888 # so no updates are required. | |
| 3889 # | |
| 3890 proc pkgconf::nbpage_build_leave { win } { | |
| 3891 } | |
| 3892 | |
| 3893 # | |
| 3894 # This callback function is invoked during the various makes. | |
| 3895 # If it is passed an empty string then the command has finished and | |
| 3896 # all the buttons can be reenabled. Otherwise it is necessary to send | |
| 3897 # some text to the output window. | |
| 3898 | |
| 3899 proc pkgconf::nbpage_build_handle_output { mesg } { | |
| 3900 | |
| 3901 if { $mesg == "" } { | |
| 3902 output_add_text "Build has finished.\n" | |
| 3903 nbpage_build_control_buttons 1 | |
| 3904 } else { | |
| 3905 output_add_text "$mesg\n" | |
| 3906 } | |
| 3907 } | |
| 3908 | |
| 3909 | |
| 3910 # This utility is used to control all the buttons in the build frame. | |
| 3911 proc pkgconf::nbpage_build_control_buttons { on } { | |
| 3912 | |
| 3913 variable build_frame | |
| 3914 set buttons [grid slaves $build_frame.grid -column 0] | |
| 3915 foreach button $buttons { | |
| 3916 if { $on } { | |
| 3917 $button configure -state normal | |
| 3918 } else { | |
| 3919 $button configure -state disabled | |
| 3920 } | |
| 3921 } | |
| 3922 } | |
| 3923 | |
| 3924 # | |
| 3925 # These functions get invoked for the buttons in the build page. | |
| 3926 # | |
| 3927 proc pkgconf::nbpage_build_update_tree { } { | |
| 3928 | |
| 3929 variable toplevel | |
| 3930 variable options_page_needs_refresh | |
| 3931 variable build_tree_needs_update | |
| 3932 | |
| 3933 nbpage_build_control_buttons 0 | |
| 3934 produce_build_tree | |
| 3935 nbpage_build_control_buttons 1 | |
| 3936 $toplevel.message configure -text "" | |
| 3937 set options_page_needs_refresh 1 | |
| 3938 set build_tree_needs_update 0 | |
| 3939 } | |
| 3940 | |
| 3941 proc pkgconf::nbpage_build_make { } { | |
| 3942 | |
| 3943 variable build_tree | |
| 3944 variable config_data | |
| 3945 | |
| 3946 nbpage_build_control_buttons 0 | |
| 3947 output_add_text "Building current configuration.\nBuild tree is $build_tree.\nInstall tree is $config_data(prefix)\n" | |
| 3948 run_command pkgconf::nbpage_build_handle_output make -C $build_tree | |
| 3949 } | |
| 3950 | |
| 3951 proc pkgconf::nbpage_build_tests { } { | |
| 3952 | |
| 3953 variable build_tree | |
| 3954 variable config_data | |
| 3955 nbpage_build_control_buttons 0 | |
| 3956 output_add_text \ | |
| 3957 "Building test executables.\nBuild tree is $build_tree\nInstall tree is $config_data(prefix)\n" | |
| 3958 run_command pkgconf::nbpage_build_handle_output make -C $build_tree tests | |
| 3959 } | |
| 3960 | |
| 2 | 3961 proc pkgconf::nbpage_build_misc { } { |
| 3962 | |
| 3963 variable build_tree | |
| 3964 variable config_data | |
| 3965 nbpage_build_control_buttons 0 | |
| 3966 output_add_text \ | |
| 3967 "Building misc executables.\nBuild tree is $build_tree\nInstall tree is $config_data(prefix)\n" | |
| 3968 run_command pkgconf::nbpage_build_handle_output make -C $build_tree misc | |
| 3969 } | |
| 3970 | |
| 0 | 3971 proc pkgconf::nbpage_build_clean { } { |
| 3972 | |
| 3973 variable build_tree | |
| 3974 nbpage_build_control_buttons 0 | |
| 3975 output_add_text "Cleaning build tree $build_tree.\n" | |
| 3976 run_command pkgconf::nbpage_build_handle_output make -C $build_tree clean | |
| 3977 } | |
| 3978 | |
| 3979 # }}} | |
| 3980 | |
| 3981 # }}} | |
| 3982 # {{{ Output window | |
| 3983 | |
| 3984 # ---------------------------------------------------------------------------- | |
| 3985 # These routines take care of the output window. There are two variables | |
| 3986 # describing the current state of the window: output_docked and | |
| 3987 # output_visible. There are four commands which can be invoked from | |
| 3988 # buttons, and a further command which can be invoked from the windows | |
| 3989 # menu. There is also a routine which can be used to add text to | |
| 3990 # the current output window, making it visible if necessary. | |
| 3991 # | |
| 3992 # The packing of the main .pkgconf window has to be redone every time | |
| 3993 # the output window is displayed or hidden, if the output window is | |
| 3994 # currently docked. To avoid duplicating code there are auxiliary | |
| 3995 # routine output_make_visible and output_make_invisible. | |
| 3996 # | |
| 3997 | |
| 3998 # This routine is invoked from the View menu. Its purpose is to | |
| 3999 # hide or display the output window, depending on the value of | |
| 4000 # output_visible. Note that output_visible indicates the desired | |
| 4001 # state of affairs, not the actual state of affairs. | |
| 4002 # | |
| 4003 proc pkgconf::output_menu { } { | |
| 4004 | |
| 4005 variable output_visible | |
| 4006 | |
| 4007 if { $output_visible == 0 } { | |
| 4008 output_make_invisible | |
| 4009 } else { | |
| 4010 output_make_visible | |
| 4011 } | |
| 4012 } | |
| 4013 | |
| 4014 proc pkgconf::output_make_visible { } { | |
| 4015 | |
| 4016 variable output_docked | |
| 4017 variable toplevel | |
| 4018 | |
| 4019 if { $output_docked == 0 } { | |
| 4020 # The output is in a separate window. Deiconifying it should make | |
| 4021 # it visible. | |
| 4022 wm deiconify .pkgconf_output | |
| 4023 } else { | |
| 4024 # It is necessary to repack the main window. This time it is the | |
| 4025 # output frame that should expand. | |
| 4026 pack forget $toplevel.notebook $toplevel.message | |
| 4027 pack $toplevel.notebook -side top -fill x | |
| 4028 pack $toplevel.message -side top -fill x | |
| 4029 pack $toplevel.output -side top -fill both -expand 1 | |
| 4030 } | |
| 4031 } | |
| 4032 | |
| 4033 proc pkgconf::output_make_invisible { } { | |
| 4034 | |
| 4035 variable output_docked | |
| 4036 variable toplevel | |
| 4037 | |
| 4038 if { $output_docked == 0 } { | |
| 4039 # The output is in a separate window, just withdraw it. | |
| 4040 wm withdraw .pkgconf_output | |
| 4041 } else { | |
| 4042 # It is necessary to repack the .pkgconf window without | |
| 4043 # the output window. This time it is the notebook which | |
| 4044 # should expand to fit all available space. | |
| 4045 pack forget $toplevel.notebook $toplevel.message $toplevel.output | |
| 4046 pack $toplevel.notebook -side top -fill both -expand 1 | |
| 4047 pack $toplevel.message -side top -fill x | |
| 4048 } | |
| 4049 } | |
| 4050 | |
| 4051 # | |
| 4052 # This routine is invoked when the output window is already visible | |
| 4053 # and the user has pressed the button in that window to make it | |
| 4054 # invisible. | |
| 4055 # | |
| 4056 proc pkgconf::output_hide_window { } { | |
| 4057 | |
| 4058 variable output_visible | |
| 4059 variable toplevel | |
| 4060 ASSERT { $output_visible != 0 } | |
| 4061 | |
| 4062 output_make_invisible | |
| 4063 set output_visible 0 | |
| 4064 } | |
| 4065 | |
| 4066 # | |
| 4067 # Switch between a docked and an undocked window. The window must | |
| 4068 # currently be visible. Any text must be copied across from | |
| 4069 # one widget to the other. | |
| 4070 # | |
| 4071 proc pkgconf::output_undock_window { } { | |
| 4072 | |
| 4073 variable output_visible | |
| 4074 variable output_docked | |
| 4075 variable toplevel | |
| 4076 | |
| 4077 ASSERT { $output_visible != 0 } | |
| 4078 | |
| 4079 output_make_invisible | |
| 4080 | |
| 4081 $toplevel.output.text configure -state normal | |
| 4082 .pkgconf_output.text configure -state normal | |
| 4083 | |
| 4084 if { $output_docked == 0 } { | |
| 4085 $toplevel.output.text insert end [.pkgconf_output.text get 1.0 "end - 1 chars"] | |
| 4086 .pkgconf_output.text delete 1.0 end | |
| 4087 set output_docked 1 | |
| 4088 } else { | |
| 4089 .pkgconf_output.text insert end [$toplevel.output.text get 1.0 "end - 1 chars"] | |
| 4090 $toplevel.output.text delete 1.0 end | |
| 4091 set output_docked 0 | |
| 4092 } | |
| 4093 | |
| 4094 $toplevel.output.text configure -state disabled | |
| 4095 .pkgconf_output.text configure -state disabled | |
| 4096 | |
| 4097 output_make_visible | |
| 4098 } | |
| 4099 | |
| 4100 # | |
| 4101 # Clear the text window, which should currently be visible. | |
| 4102 # | |
| 4103 proc pkgconf::output_clear_window { } { | |
| 4104 | |
| 4105 variable output_visible | |
| 4106 variable output_docked | |
| 4107 variable toplevel | |
| 4108 | |
| 4109 ASSERT { $output_visible != 0 } | |
| 4110 if { $output_docked == 0 } { | |
| 4111 .pkgconf_output.text configure -state normal | |
| 4112 .pkgconf_output.text delete 1.0 end | |
| 4113 .pkgconf_output.text configure -state disabled | |
| 4114 } else { | |
| 4115 $toplevel.output.text configure -state normal | |
| 4116 $toplevel.output.text delete 1.0 end | |
| 4117 $toplevel.output.text configure -state disabled | |
| 4118 } | |
| 4119 } | |
| 4120 | |
| 4121 # | |
| 4122 # Save the current contents of the text window to a file. | |
| 4123 # | |
| 4124 proc pkgconf::output_save { } { | |
| 4125 | |
| 4126 variable build_tree | |
| 4127 variable output_docked | |
| 4128 variable toplevel | |
| 4129 | |
| 4130 set filename [tk_getSaveFile -initialdir $build_tree -initialfile pkgconf.log \ | |
| 4131 -parent [expr { $output_docked ? "$toplevel" : ".pkgconf_output" } ] ] | |
| 4132 | |
| 4133 if { $filename == "" } { | |
| 4134 return | |
| 4135 } | |
| 4136 | |
| 4137 if { [catch { | |
| 4138 set file [open $filename w] | |
| 4139 if { $output_docked == 0 } { | |
| 4140 puts $file [.pkgconf_output.text get 1.0 "end - 1 chars"] | |
| 4141 } else { | |
| 4142 puts $file [$toplevel.output.text get 1.0 "end - 1 chars"] | |
| 4143 } | |
| 4144 close $file | |
| 4145 } message] != 0 } { | |
| 4146 warning "Failed to save build output to $filename: $message" | |
| 4147 } | |
| 4148 } | |
| 4149 | |
| 4150 # | |
| 4151 # Output some text. This gets invoked mainly during builds, but also | |
| 4152 # by the report() function when generating a build tree. It is | |
| 4153 # necessary to make sure that the text widget is visible. | |
| 4154 # | |
| 4155 proc pkgconf::output_add_text { msg } { | |
| 4156 | |
| 4157 variable output_visible | |
| 4158 variable output_docked | |
| 4159 variable toplevel | |
| 4160 | |
| 4161 if { $output_visible == 0 } { | |
| 4162 output_make_visible | |
| 4163 set output_visible 1 | |
| 4164 } | |
| 4165 | |
| 4166 if { $output_docked == 0 } { | |
| 4167 .pkgconf_output.text configure -state normal | |
| 4168 .pkgconf_output.text insert end $msg | |
| 4169 .pkgconf_output.text configure -state disabled | |
| 4170 .pkgconf_output.text see end | |
| 4171 } else { | |
| 4172 $toplevel.output.text configure -state normal | |
| 4173 $toplevel.output.text insert end $msg | |
| 4174 $toplevel.output.text configure -state disabled | |
| 4175 $toplevel.output.text see end | |
| 4176 } | |
| 4177 } | |
| 4178 | |
| 4179 # }}} | |
| 4180 # {{{ Status line | |
| 4181 | |
| 4182 # ---------------------------------------------------------------------------- | |
| 4183 # Some utility routines to update the status line. | |
| 4184 | |
| 4185 proc pkgconf::set_status_line { text } { | |
| 4186 variable toplevel | |
| 4187 $toplevel.message configure -text $text | |
| 4188 } | |
| 4189 | |
| 4190 proc pkgconf::clear_status_line { } { | |
| 4191 variable toplevel | |
| 4192 $toplevel.message configure -text "" | |
| 4193 } | |
| 4194 | |
| 4195 # }}} | |
| 4196 # {{{ Diagnostics | |
| 4197 | |
| 4198 # ---------------------------------------------------------------------------- | |
| 4199 # GUI versions of the same routines. For now tk_messageBox will have | |
| 4200 # to suffice for fatal error | |
| 4201 # | |
| 4202 proc pkgconf::gui_fatal_error_handler { msg } { | |
| 4203 | |
| 4204 variable toplevel | |
| 4205 | |
| 4206 if { [winfo exists $toplevel] } { | |
| 4207 tk_messageBox -parent $toplevel -icon error -title "pkgconf: fatal error" -type ok -message $msg | |
| 4208 } else { | |
| 4209 tk_messageBox -icon error -title "pkgconf: fatal error" -type ok -message $msg | |
| 4210 } | |
| 4211 exit 1 | |
| 4212 } | |
| 4213 | |
| 4214 proc pkgconf::gui_warning_handler { msg } { | |
| 4215 | |
| 4216 variable toplevel | |
| 4217 | |
| 4218 if { [winfo exists $toplevel] } { | |
| 4219 tk_messageBox -parent $toplevel -icon error -title "pkgconf: fatal error" -type ok -message $msg | |
| 4220 } else { | |
| 4221 tk_messageBox -icon error -title "pkgconf: fatal error" -type ok -message $msg | |
| 4222 } | |
| 4223 } | |
| 4224 | |
| 4225 proc pkgconf::gui_report_handler { msg } { | |
| 4226 | |
| 4227 output_add_text "$msg\n" | |
| 4228 update | |
| 4229 } | |
| 4230 | |
| 4231 # }}} | |
| 4232 # {{{ Executing external commands | |
| 4233 | |
| 4234 # ---------------------------------------------------------------------------- | |
| 4235 # This code is responsible for executing external commands. The broken nature | |
| 4236 # of pipes under Windows makes this somewhat more difficult than it should be. | |
| 4237 | |
| 4238 proc pkgconf::run_command { callback command args } { | |
| 4239 | |
| 4240 # Start up the specified command. Actually the main command is run such that | |
| 4241 # both stdout and stderr are piped into cat, thus making sure that the | |
| 4242 # stderr output is not discarded. | |
| 4243 set result [catch { set pipe [open "|[concat $command $args] 2>@ stdout" "r"] } message] | |
| 4244 if { $result != 0 } { | |
| 4245 warning "Failed to execute $command: $message" | |
| 4246 return | |
| 4247 } | |
| 4248 | |
| 4249 # Now set the pipe to non-blocking, to prevent the whole GUI from | |
| 4250 # locking up by accident. | |
| 4251 fconfigure $pipe -blocking 0 | |
| 4252 | |
| 4253 # Set up an event handler to read back any output. | |
| 4254 fileevent $pipe readable [list pkgconf::handle_command_output $pipe $callback] | |
| 4255 } | |
| 4256 | |
| 4257 # | |
| 4258 # This routine gets invoked whenever there may be data waiting on the | |
| 4259 # pipe. | |
| 4260 # | |
| 4261 proc pkgconf::handle_command_output { pipe callback } { | |
| 4262 | |
| 4263 set data "" | |
| 4264 set count [gets $pipe data] | |
| 4265 if { $count > 0 } { | |
| 4266 $callback $data | |
| 4267 } elseif { [eof $pipe] } { | |
| 4268 catch { close $pipe } | |
| 4269 $callback "" | |
| 4270 } | |
| 4271 } | |
| 4272 | |
| 4273 # }}} | |
| 4274 | |
| 4275 # }}} | |
| 4276 # {{{ Produce build tree | |
| 4277 | |
| 4278 # {{{ Description | |
| 4279 | |
| 4280 # ---------------------------------------------------------------------------- | |
| 4281 # Producing the build tree. This requires the following information: | |
| 4282 # | |
| 4283 # 1) the location of the component repository. This should be known. | |
| 4284 # | |
| 4285 # 2) the location of the build tree. This should also be known. | |
| 4286 # | |
| 4287 # 3) full details of the target architecture. These may not have been supplied | |
| 4288 # yet, which would result in a fatal error. | |
| 4289 # | |
| 4290 # 4) details of which packages are explicitly enabled or disabled. | |
| 4291 # | |
| 4292 # 5) details of which version of each package should be used. | |
| 4293 # | |
| 4294 # 6) prefix information, i.e. where the system will be installed. | |
| 4295 # The default value "" indicates an install directory relative to the | |
| 4296 # build tree. | |
| 4297 # | |
| 4298 # This routine may be called for an empty build tree, or it | |
| 4299 # may be used to update an existing build tree. | |
| 4300 # | |
| 4301 # The steps that have to be taken are as follows: | |
| 4302 # | |
| 4303 # 1) create a pkgconf directory, which is where all the editable | |
| 4304 # header files will end up. A few other files will end up there | |
| 4305 # as well. | |
| 4306 # | |
| 4307 # 2) examine all packages, including the hal packages. For each package: | |
| 4308 # | |
| 4309 # a) if there is a src directory in the component repository, reproduce | |
| 4310 # this in the build tree. If this src directory has any | |
| 4311 # sub-directories, these have to be created as well. | |
| 4312 # | |
| 4313 # The src directory should contain a file PKGconf.mak. This has to be | |
| 4314 # copied across as makefile. There may also be PKGconf.mak files in | |
| 4315 # subdirectories which should also get copied across. Typically the | |
| 4316 # latter will be for internal development purposes. | |
| 4317 # | |
| 4318 # b) if there is an include directory in the component repository, | |
| 4319 # make a matching directory in the build tree. Ditto for any | |
| 4320 # subdirectories other than pkgconf. | |
| 4321 # | |
| 4322 # The purpose of this include directory is to allow users to make | |
| 4323 # editable copies of the header files in the build tree. A makefile | |
| 4324 # is generated in this directory which will take care of updating the | |
| 4325 # header files that actually get used for building, i.e. those in the | |
| 4326 # include directory. The header files are not actually copied across | |
| 4327 # at this point, that will happen during the first make. | |
| 4328 # | |
| 4329 # The pkgconf directory is handled differently. Every file in | |
| 4330 # pkgconf is copied across to the build tree's pkgconf directory, | |
| 4331 # unless there is already a matching file in the build tree. | |
| 4332 # This avoids overwriting edits made by the user in the build | |
| 4333 # tree. The disadvantage is that if the version in the component | |
| 4334 # repository is edited it will have to be copied by hand, or the | |
| 4335 # -force command line argument will have to be used. | |
| 4336 # | |
| 4337 # c) if there is a tests directory in the component repository, make | |
| 4338 # a matching directory in the build tree and copy | |
| 4339 # across PKGconf.mak. If this tests directory has any subdirectories | |
| 4340 # then these must be created as well. | |
| 4341 # | |
| 2 | 4342 # d) similarly for any 'misc' directories |
| 4343 # | |
| 0 | 4344 # 3) create the install directory tree, complete with lib, include, and tests |
| 4345 # directories, and the include/pkgconf sub-directory. Additional | |
| 4346 # sub-directories within include need not be generated at this point, | |
| 4347 # that happens as such sub-directories are encountered within the | |
| 4348 # component repository. | |
| 4349 # | |
| 4350 # 4) copy across the makevars file. | |
| 4351 # | |
| 4352 # 5) generate the files specific to this configuration. | |
| 4353 # | |
| 4354 # Note that subdirectories corresponding to old packages are not | |
| 4355 # deleted, they simply get ignored. Arguably this should change, | |
| 4356 # but then you run the risk of deleting user changes in a package | |
| 4357 # that has been disabled only temporarily. | |
| 4358 # | |
| 4359 | |
| 4360 # }}} | |
| 4361 # {{{ Check requirements | |
| 4362 | |
| 4363 # ---------------------------------------------------------------------------- | |
| 4364 # It is not possible to generate a build tree unless certain requirements | |
| 4365 # are satisfied. Most of these will have been checked elsewhere. | |
| 4366 # | |
| 4367 proc pkgconf::check_requirements { } { | |
| 4368 | |
| 4369 ASSERT { $pkgconf::build_tree != "" } | |
| 4370 ASSERT { $pkgconf::component_repository != "" } | |
| 4371 | |
| 4372 if { $pkgconf::component_repository == $pkgconf::build_tree } { | |
| 4373 report "Builds of eCos cannot happen in the same directory as the sources." | |
| 4374 report "Currently your build tree is $pkgconf::build_tree." | |
| 4375 report "This is the same directory as your component repository." | |
| 4376 fatal_error "Unable to proceed with builds in this directory." | |
| 4377 } | |
| 4378 | |
| 4379 if { $pkgconf::config_data(target) == "" } { | |
| 4380 fatal_error "No target architecture has been specified." | |
| 4381 } | |
| 4382 if { $pkgconf::config_data(platform) == "" } { | |
| 4383 fatal_error "No target platform has been specified." | |
| 4384 } | |
| 4385 if { $pkgconf::config_data(startup) == "" } { | |
| 4386 fatal_error "No target startup mechanism has been specified." | |
| 4387 } | |
| 4388 } | |
| 4389 | |
| 4390 # }}} | |
| 4391 # {{{ Directory and file utilities | |
| 4392 | |
| 4393 # ---------------------------------------------------------------------------- | |
| 4394 # Start with a number of utility routines to access all files in | |
| 4395 # a directory, stripping out well-known files such as makefile.am. | |
| 4396 # The routines take an optional pattern argument if only certain | |
| 4397 # files are of interest. | |
| 4398 # | |
| 4399 # Note that symbolic links are returned as well as files. | |
| 4400 # | |
| 4401 proc pkgconf::locate_files { dir { pattern "*"} } { | |
| 4402 | |
| 4403 ASSERT { $dir != "" } | |
| 4404 | |
| 4405 # Start by getting a list of all the files. | |
| 4406 set filelist [glob -nocomplain -- [file join $dir $pattern]] | |
| 4407 | |
| 4408 # Eliminate the pathnames from all of these files | |
| 4409 set filenames "" | |
| 4410 foreach file $filelist { | |
| 2 | 4411 if { [string range $file end end] != "~" } { |
| 4412 lappend filenames [file tail $file] | |
| 4413 } | |
| 0 | 4414 } |
| 4415 | |
| 4416 # Eliminate any obviously spurious entries. | |
| 4417 foreach file { CVS Makefile.am Makefile.in makefile acinclude.m4 aclocal.m4 configure.in configure } { | |
| 4418 set index [lsearch -exact $filenames $file] | |
| 4419 if { $index != -1 } { | |
| 4420 set filenames [lreplace $filenames $index $index] | |
| 4421 } | |
| 4422 } | |
| 4423 | |
| 4424 # Eliminate any subdirectories. | |
| 4425 set subdirs "" | |
| 4426 foreach name $filenames { | |
| 4427 if { [file isdir [file join $dir $name]] } { | |
| 4428 lappend subdirs $name | |
| 4429 } | |
| 4430 } | |
| 4431 foreach subdir $subdirs { | |
| 4432 set index [lsearch -exact $filenames $subdir] | |
| 4433 set filenames [lreplace $filenames $index $index] | |
| 4434 } | |
| 4435 | |
| 4436 return $filenames | |
| 4437 } | |
| 4438 | |
| 4439 # | |
| 4440 # This utility returns all sub-directories, as opposed to all files. | |
| 4441 # A variant glob pattern is used here. This version is not recursive. | |
| 4442 proc pkgconf::locate_subdirs { dir { pattern "*" }} { | |
| 4443 | |
| 4444 ASSERT { $dir != "" } | |
| 4445 | |
| 4446 set dirlist [glob -nocomplain -- [file join $dir $pattern "."]] | |
| 4447 | |
| 4448 # Eliminate the pathnames and the spurious /. at the end of each entry | |
| 4449 set dirnames "" | |
| 4450 foreach dir $dirlist { | |
| 4451 lappend dirnames [file tail [file dirname $dir]] | |
| 4452 } | |
| 4453 | |
| 4454 # Get rid of the CVS directory, if any | |
| 4455 set index [lsearch -exact $dirnames "CVS"] | |
| 4456 if { $index != -1 } { | |
| 4457 set dirnames [lreplace $dirnames $index $index] | |
| 4458 } | |
| 4459 | |
| 4460 # That should be it. | |
| 4461 return $dirnames | |
| 4462 } | |
| 4463 | |
| 4464 # | |
| 4465 # A variant which is recursive. This one does not support a pattern. | |
| 4466 # | |
| 4467 proc pkgconf::locate_all_subdirs { dir } { | |
| 4468 | |
| 4469 ASSERT { $dir != "" } | |
| 4470 | |
| 4471 set result "" | |
| 4472 foreach subdir [locate_subdirs $dir] { | |
| 4473 lappend result $subdir | |
| 4474 foreach x [locate_all_subdirs [file join $dir $subdir]] { | |
| 4475 lappend result [file join $subdir $x] | |
| 4476 } | |
| 4477 } | |
| 4478 return $result | |
| 4479 } | |
| 4480 | |
| 4481 # | |
| 4482 # This routine returns a list of all the files in a given directory and in | |
| 4483 # all subdirectories, preserving the subdirectory name. | |
| 4484 # | |
| 4485 proc pkgconf::locate_all_files { dir { pattern "*" } } { | |
| 4486 | |
| 4487 ASSERT { $dir != "" } | |
| 4488 | |
| 4489 set files [locate_files $dir $pattern] | |
| 4490 set subdirs [locate_subdirs $dir] | |
| 4491 | |
| 4492 foreach subdir $subdirs { | |
| 4493 set subfiles [locate_all_files [file join $dir $subdir] $pattern] | |
| 4494 foreach file $subfiles { | |
| 4495 lappend files [file join $subdir $file] | |
| 4496 } | |
| 4497 } | |
| 4498 | |
| 4499 return $files | |
| 4500 } | |
| 4501 | |
| 4502 # | |
| 4503 # Sometimes a directory may be empty, or contain just a CVS subdirectory, | |
| 4504 # in which case there is no point in copying it across. | |
| 4505 # | |
| 4506 proc pkgconf::is_empty_directory { dir } { | |
| 4507 | |
| 4508 ASSERT { $dir != "" } | |
| 4509 | |
| 4510 set contents [glob -nocomplain -- [file join $dir "*"]] | |
| 4511 if { [llength $contents] == 0 } { | |
| 4512 return 1 | |
| 4513 } | |
| 4514 if { ([llength $contents] == 1) && [string match {*CVS} $contents] } { | |
| 4515 return 1 | |
| 4516 } | |
| 4517 return 0 | |
| 4518 } | |
| 4519 | |
| 4520 # ---------------------------------------------------------------------------- | |
| 4521 # Given a pathname such as kernel/current/include, this routine returns | |
| 4522 # a string which points at the build tree's pkgconf directory | |
| 4523 # complete with the appropriate number of ..'s in the pathname | |
| 4524 # | |
| 4525 proc pkgconf::get_dotdots_pkgconf { dir } { | |
| 4526 | |
| 4527 set result ".." | |
| 4528 | |
| 4529 while { 1} { | |
| 4530 set dir [file dirname $dir] | |
| 4531 if { ($dir == ".") || ($dir == ":") } { | |
| 4532 break | |
| 4533 } | |
| 4534 set result [file join $result ".."] | |
| 4535 } | |
| 4536 | |
| 4537 set result [file join $result "pkgconf"] | |
| 4538 return $result | |
| 4539 } | |
| 4540 | |
| 4541 # ---------------------------------------------------------------------------- | |
| 4542 # Internally this script works using native path names. When outputting the | |
| 4543 # makefile information it is necessary to output the paths in a format that | |
| 4544 # is understood by GnuMake. | |
| 4545 # | |
| 4546 proc pkgconf::get_pathname_for_make { dir } { | |
| 4547 | |
| 4548 # First of all, handle directory separators. Under Unix this is a no-op. | |
| 4549 # Under Windows the current directory separator may be \ instead of /. | |
| 4550 # It is not entirely clear under what circumstances Tcl's "file nativename" | |
| 4551 # facility uses / vs. \, but converting all existing backslashes to | |
| 4552 # forward slashes should be harmless. | |
| 4553 if { $pkgconf::windows_host != 0 } { | |
| 4554 regsub -all -- {\\} $dir "/" dir | |
| 4555 } | |
| 4556 | |
| 4557 # Next cope with spaces in pathnames. GnuMake does not always cope | |
| 4558 # sensibly with these, even if backslash quoting is used - there | |
| 4559 # are known problems with VPATH and with the wildcard function. Under | |
| 4560 # Unix there is no simple solution, but it is unlikely that the problem | |
| 4561 # will arise in the first place. Under Windows it is quite likely that | |
| 4562 # the problem will arise, but it is possible to work around it | |
| 4563 # by using a short file name. | |
| 4564 | |
| 4565 set index [string first " " $dir] | |
| 4566 if { $index != -1 } { | |
| 4567 if { $pkgconf::windows_host != 0 } { | |
| 4568 | |
| 4569 # This call will only work if the specified object already exists. | |
| 4570 # This should not be a problem, as the pathnames are likely to | |
| 4571 # be relative to the component repository, the build tree, or the | |
| 4572 # install tree. The component repository must already exist. The | |
| 4573 # build tree must already exist, since this call will only be | |
| 4574 # invoked when generating makefiles inside the build tree. The | |
| 4575 # install tree will have been created before pkgconf/pkgconf.mak | |
| 4576 # is written out, and that is the only place that needs to refer | |
| 4577 # to it. | |
| 4578 | |
| 4579 set dir [file attribute $dir -shortname] | |
| 4580 } else { | |
| 4581 fatal_error "Cannot cope with pathname \"$pathname\".\nPathnames with spaces are not supported on this platform." | |
| 4582 } | |
| 4583 } | |
| 4584 | |
| 4585 # Other characters that have special meaning include: []*?()$^|&#<>"'`; | |
| 4586 # At least, that is the list used within vmake. $ has to be quoted as $$, | |
| 4587 # the others should be quoted with a single backslash. | |
| 4588 regsub -all -- {\$} $dir {$$} dir | |
| 4589 foreach char { {\[} {\]} {\*} {\?} {\(} {\)} {\^} {\|} {\&} {\#} {\<} {\>} {\"} {\'} {\`} {\;} } { | |
| 4590 regsub -all -- $char $dir "\\$char" dir | |
| 4591 } | |
| 4592 | |
| 4593 # Now cope with Windows drive names. | |
| 4594 # | |
| 4595 # First, volume-relative filenames. If the directory string begins with | |
| 4596 # c:xxx, as opposed to c:/xxx, it is necessary to figure out what the | |
| 4597 # current directory is on drive c: and use this as prefix for the rest | |
| 4598 # of the string. | |
| 4599 # | |
| 4600 # Once volume-relative filenames have been handled the directory may be | |
| 4601 # along the lines of c:/Cygnus/eCos/whatever. This is problematical for | |
| 4602 # GnuMake since the colon character has special meaning in various places, | |
| 4603 # e.g. to identify static pattern rules. cygwin32 uses //c/ as an alias | |
| 4604 # for c:/ wherever appropriate. | |
| 4605 if { $pkgconf::windows_host != 0 } { | |
| 4606 | |
| 4607 set dummy "" | |
| 4608 set match1 "" | |
| 4609 set match2 "" | |
| 4610 set match3 "" | |
| 4611 | |
| 4612 if { [regexp -- {^([a-zA-Z]:)(/)?(.*)} $dir dummy match1 match2 match3] == 1 } { | |
| 4613 if { $match2 == "" } { | |
| 4614 set result [catch { | |
| 4615 set current_dir [pwd] | |
| 4616 cd $match1 | |
| 4617 set dir [pwd] | |
| 4618 regsub -all -- {\\} $dir "/" dir | |
| 4619 set dir [file join $dir $match3] | |
| 4620 cd $current_dir | |
| 4621 } message] | |
| 4622 if { $result != 0 } { | |
| 4623 fatal_error "Failed to determine current directory on drive $match1" | |
| 4624 } | |
| 4625 } | |
| 4626 } | |
| 4627 | |
| 4628 if { [regexp -- {^([a-zA-Z]):} $dir dummy match1] == 1 } { | |
| 4629 set dir "//$match1[string range $dir 2 end]" | |
| 4630 } | |
| 4631 } | |
| 4632 | |
| 4633 return $dir | |
| 4634 } | |
| 4635 | |
| 4636 # ---------------------------------------------------------------------------- | |
| 4637 # Take a cygwin32 filename such as //d/tmp/pkgobj and turn it into something | |
| 4638 # acceptable to Tcl, i.e. d:/tmp/pkgobj. There are a few other complications... | |
| 4639 | |
| 4640 proc pkgconf::get_pathname_for_tcl { name } { | |
| 4641 | |
| 4642 if { $pkgconf::windows_host } { | |
| 4643 set dummy "" | |
| 4644 set match1 "" | |
| 4645 set match2 "" | |
| 4646 | |
| 4647 # If the pathname is relative to ~, expand it now. | |
| 4648 if { [regexp -- {^~(.*)$} $name dummy match1] } { | |
| 4649 set name [file nativename $name] | |
| 4650 } | |
| 4651 | |
| 4652 # For consistency, get rid of any backslashes in the pathname. | |
| 4653 # Especially since the file nativename command above may have | |
| 4654 # introduced some. | |
| 4655 regsub -all -- {\\} $name "/" name | |
| 4656 | |
| 4657 # And now replace //d/tmp/pkgobj with d:/tmp/pkgobj | |
| 4658 if { [regexp -- {^//([a-zA-Z])(/.*)$} $name dummy match1 match2] == 1 } { | |
| 4659 set name "$match1:$match2" | |
| 4660 } | |
| 4661 | |
| 4662 # If the pathname is relative to the cygwin root, get hold of the | |
| 4663 # drive name. | |
| 4664 if { ([regexp -- {^/(.*)$} $name dummy match1] == 1) && ([regexp -- {^//.*$} $name dummy] == 0) } { | |
| 4665 set saved_dir [pwd] | |
| 4666 cd / | |
| 4667 set name [file join [pwd] $match1] | |
| 4668 cd $saved_dir | |
| 4669 } | |
| 4670 } | |
| 4671 return $name | |
| 4672 } | |
| 4673 | |
| 4674 # ---------------------------------------------------------------------------- | |
| 4675 # Output a standard banner to a generated file. | |
| 4676 # | |
| 4677 | |
| 4678 proc pkgconf::output_banner { file name } { | |
| 4679 | |
| 4680 puts $file \ | |
| 4681 "# | |
| 4682 # File $name | |
| 4683 # | |
| 4684 # This file is generated automatically by the pkgconf program. | |
| 4685 # It should not be edited. Any changes made to this file may | |
| 4686 # be overwritten by pkgconf. | |
| 4687 #" | |
| 4688 } | |
| 4689 | |
| 4690 # ---------------------------------------------------------------------------- | |
| 4691 # Make sure that a newly created or copied file is writable. This operation | |
| 4692 # is platform-specific. Under Unix at most the current user is given | |
| 4693 # permission, since there does not seem to be any easy way to get hold | |
| 4694 # of the real umask. | |
| 4695 | |
| 4696 proc pkgconf::make_writable { name } { | |
| 4697 | |
| 4698 ASSERT { $name != "" } | |
| 4699 ASSERT { [file isfile $name] } | |
| 4700 | |
| 4701 if { [file writable $name] == 0 } { | |
| 4702 if { $pkgconf::windows_host != 0 } { | |
| 4703 file attributes $name -readonly 0 | |
| 4704 } else { | |
| 4705 set mask [file attributes $name -permissions] | |
| 4706 set mask [expr $mask | 0200] | |
| 4707 file attributes $name -permissions $mask | |
| 4708 } | |
| 4709 } | |
| 4710 } | |
| 4711 | |
| 4712 # }}} | |
| 4713 # {{{ Other utilities | |
| 4714 | |
| 4715 # ---------------------------------------------------------------------------- | |
| 4716 # This code works out what packages should go into the current configuration. | |
| 4717 # The rules are as follows: | |
| 4718 # | |
| 4719 # 1) all hardware-specific packages should be disabled, unless they are | |
| 4720 # mentioned explicitly in the targets file for the current target or | |
| 4721 # platform, or unless they are enabled explicitly by the user. | |
| 4722 # | |
| 4723 # 2) all other packages which are enabled by default should be included, | |
| 4724 # unless they are disabled explicitly by the user. | |
| 4725 # | |
| 4726 # 3) all non-hardware packages which are disabled by default should be | |
| 4727 # left out, unless they are enabled explicitly by the user. | |
| 4728 | |
| 4729 proc pkgconf::get_current_packages { } { | |
| 4730 | |
| 4731 ASSERT { $pkgconf::config_data(target) != "" } | |
| 4732 ASSERT { $pkgconf::config_data(platform) != "" } | |
| 4733 ASSERT { [info exists pkgconf::target_data($pkgconf::config_data(target),packages)] } | |
| 4734 ASSERT { [info exists pkgconf::target_data($pkgconf::config_data(target),$pkgconf::config_data(platform),packages)] } | |
| 4735 ASSERT { [info exists pkgconf::config_data(enabled_packages)] } | |
| 4736 ASSERT { [info exists pkgconf::config_data(disabled_packages)] } | |
| 4737 | |
| 4738 set result "" | |
| 4739 set target_packages $pkgconf::target_data($pkgconf::config_data(target),packages) | |
| 4740 set platform_packages $pkgconf::target_data($pkgconf::config_data(target),$pkgconf::config_data(platform),packages) | |
| 4741 set enabled_packages $pkgconf::config_data(enabled_packages) | |
| 4742 set disabled_packages $pkgconf::config_data(disabled_packages) | |
| 4743 | |
| 4744 foreach pkg $pkgconf::known_packages { | |
| 4745 | |
| 4746 ASSERT { [info exists pkgconf::package_data($pkg,hardware)] } | |
| 4747 | |
| 4748 if { $pkgconf::package_data($pkg,hardware) } { | |
| 4749 | |
| 4750 if { [lsearch -exact $disabled_packages $pkg] != -1 } { | |
| 4751 continue | |
| 4752 } elseif { [lsearch -exact $target_packages $pkg] != -1 } { | |
| 4753 lappend result $pkg | |
| 4754 } elseif { [lsearch -exact $platform_packages $pkg] != -1 } { | |
| 4755 lappend result $pkg | |
| 4756 } elseif { [lsearch -exact $enabled_packages $pkg] != -1 } { | |
| 4757 lappend result $pkg | |
| 4758 } | |
| 4759 | |
| 4760 } elseif { $pkgconf::package_data($pkg,default) != 0 } { | |
| 4761 if { [lsearch -exact $disabled_packages $pkg] == -1 } { | |
| 4762 lappend result $pkg | |
| 4763 } | |
| 4764 } else { | |
| 4765 if { [lsearch -exact $enabled_packages $pkg] != -1 } { | |
| 4766 lappend result $pkg | |
| 4767 } | |
| 4768 } | |
| 4769 } | |
| 4770 | |
| 4771 return $result | |
| 4772 } | |
| 4773 | |
| 4774 # ---------------------------------------------------------------------------- | |
| 4775 # A utility to determine whether or not a particular setting has changed relative to | |
| 4776 # what is currently in the build tree. Information about the latter comes from | |
| 4777 # the save file, but may not exist the first time that the build tree is generated. | |
| 4778 # The config_data array itself may be sparsely populated, especially when it comes | |
| 4779 # to compiler flags. | |
| 4780 | |
| 4781 proc pkgconf::value_has_changed { name } { | |
| 4782 | |
| 4783 ASSERT {$name != ""} | |
| 4784 | |
| 4785 if { [info exists pkgconf::config_data($name)] == 0 } { | |
| 4786 | |
| 4787 if { [info exists pkgconf::saved_data($name)] == 0 } { | |
| 4788 return 0 | |
| 4789 } else { | |
| 4790 return 1 | |
| 4791 } | |
| 4792 | |
| 4793 } else { | |
| 4794 | |
| 4795 if { [info exists pkgconf::saved_data($name)] == 0 } { | |
| 4796 return 1 | |
| 4797 } | |
| 4798 if { $pkgconf::saved_data($name) != $pkgconf::config_data($name) } { | |
| 4799 return 1 | |
| 4800 } | |
| 4801 return 0 | |
| 4802 } | |
| 4803 } | |
| 4804 | |
| 4805 # ---------------------------------------------------------------------------- | |
| 4806 # Has there been a change in the packages in the system, either which packages | |
| 4807 # are present or any of their versions ? If there has been a change in the | |
| 4808 # packages then the amount of work that has to be done inside pkgconf is | |
| 4809 # increased significantly. | |
| 4810 | |
| 4811 proc pkgconf::packages_have_changed { } { | |
| 4812 | |
| 4813 if { [value_has_changed "target"] || [value_has_changed "platform"] } { | |
| 4814 return 1 | |
| 4815 } | |
| 4816 if { [value_has_changed "enabled_packages"] || [value_has_changed "disabled_packages"] } { | |
| 4817 return 1 | |
| 4818 } | |
| 4819 foreach pkg $pkgconf::known_packages { | |
| 4820 if { [value_has_changed "$pkg,version"] } { | |
| 4821 return 1 | |
| 4822 } | |
| 4823 } | |
| 4824 | |
| 4825 return 0 | |
| 4826 } | |
| 4827 | |
| 4828 | |
| 4829 # ---------------------------------------------------------------------------- | |
| 4830 # Given the name of a package, e.g. CYGPKG_KERNEL, return something which is | |
| 4831 # more acceptable in the build tree. Creating directories and files with | |
| 4832 # names containing lots of upper case characters is unacceptable. | |
| 4833 | |
| 4834 proc pkgconf::get_build_alias { name } { | |
| 4835 | |
| 4836 ASSERT { $name != ""} | |
| 4837 | |
| 4838 set index [string first "_" $name] | |
| 4839 if { $index != -1 } { | |
| 4840 set new_name [string range $name [incr index] end] | |
| 4841 if { $new_name != "" } { | |
| 4842 set name $new_name | |
| 4843 } | |
| 4844 } | |
| 4845 set name [string tolower $name] | |
| 4846 return $name | |
| 4847 } | |
| 4848 | |
| 4849 # }}} | |
| 4850 # {{{ Process a package | |
| 4851 | |
| 4852 # ---------------------------------------------------------------------------- | |
| 4853 # Process an entire package. The header files, the src directory, and the | |
| 4854 # tests directory are all handled separately. | |
| 4855 | |
| 4856 proc pkgconf::process_package { name dir } { | |
| 4857 | |
| 4858 report "Processing package $dir" | |
| 4859 | |
| 4860 set incdir [file join $dir "include"] | |
| 4861 if { [file isdir [file join $pkgconf::component_repository $incdir]] } { | |
| 4862 lappend pkgconf::inc_dirs $incdir | |
| 4863 process_package_includes $name $incdir | |
| 4864 } | |
| 4865 | |
| 4866 set srcdir [file join $dir "src"] | |
| 4867 if { [file isdir [file join $pkgconf::component_repository $srcdir]] } { | |
| 4868 if { [file isfile [file join $pkgconf::component_repository $srcdir PKGconf.mak]] } { | |
| 4869 lappend pkgconf::src_dirs $srcdir | |
| 4870 process_package_src $srcdir | |
| 4871 } | |
| 4872 } | |
| 4873 | |
| 4874 set testsdir [file join $dir "tests"] | |
| 4875 if { [file isdir [file join $pkgconf::component_repository $testsdir]] } { | |
| 4876 if { [file isfile [file join $pkgconf::component_repository $testsdir PKGconf.mak]] } { | |
| 4877 lappend pkgconf::tests_dirs $testsdir | |
| 4878 process_package_tests $name $testsdir | |
| 4879 } | |
| 4880 } | |
| 2 | 4881 |
| 4882 set miscdir [file join $dir "misc"] | |
| 4883 if { [file isdir [file join $pkgconf::component_repository $miscdir]] } { | |
| 4884 if { [file isfile [file join $pkgconf::component_repository $miscdir PKGconf.mak]] } { | |
| 4885 lappend pkgconf::misc_dirs $miscdir | |
| 4886 process_package_misc $miscdir | |
| 4887 } | |
| 4888 } | |
| 0 | 4889 } |
| 4890 | |
| 4891 # ---------------------------------------------------------------------------- | |
| 4892 # Processing the header files is somewhat complicated. The include directories | |
| 4893 # and any subdirectories except pkgconf have to be created in the build tree. | |
| 4894 # Details of these subdirectories get stored in the variable header_subdirs. | |
| 4895 # A pro-forma makefile has to be generated in the build tree, using details | |
| 4896 # of all the header files. These header files must also be appended to the | |
| 4897 # variable header_files. Any files in pkgconf have to be copied across | |
| 4898 # to the pkgconf directory, but must not overwrite the files that are | |
| 4899 # already there. | |
| 4900 # | |
| 4901 # As an additional complication, each package may define its own header | |
| 4902 # file directory. For example a package xyz may specify that all of its | |
| 4903 # exported header files should go into the xyz subdirectory of the install | |
| 4904 # include tree, not at the top level. There are special cases for the HAL. | |
| 4905 # | |
| 4906 # Note that if there are any spurious directories already present, these | |
| 4907 # do not get deleted. However the generated makefile will not reference | |
| 4908 # them so it should be harmless. | |
| 4909 # | |
| 4910 | |
| 4911 proc pkgconf::process_package_includes { name dir } { | |
| 4912 | |
| 4913 # What subdirectory in the install tree should be used ? | |
| 4914 ASSERT { [info exists pkgconf::package_data($name,incdir)] } | |
| 4915 set pkg_incdir $pkgconf::package_data($name,incdir) | |
| 4916 | |
| 4917 # Get information about the package's include directory. | |
| 4918 set pkg_inc_dirs [locate_all_subdirs [file join $pkgconf::component_repository $dir]] | |
| 4919 set pkg_pkgconf_files [locate_files [file join $pkgconf::component_repository $dir "pkgconf"]] | |
| 4920 set pkg_inc_files [locate_all_files [file join $pkgconf::component_repository $dir]] | |
| 4921 | |
| 4922 # Remove all pkgconf headers from the all_headers list. pkgconf headers | |
| 4923 # are handled by a separate makefile in the pkgconf directory. | |
| 4924 foreach hdr $pkg_pkgconf_files { | |
| 4925 set index [lsearch -exact $pkg_inc_files [file join pkgconf $hdr]] | |
| 4926 ASSERT { $index != -1 } | |
| 4927 set pkg_inc_files [lreplace $pkg_inc_files $index $index] | |
| 4928 } | |
| 4929 | |
| 4930 # Remove all unwanted subdirectories. These include pkgconf (which is handled | |
| 4931 # specially) and any empty subdirectories. | |
| 4932 set tmp "" | |
| 4933 foreach subdir $pkg_inc_dirs { | |
| 4934 if { ($subdir == "pkgconf") } { | |
| 4935 continue | |
| 4936 } | |
| 4937 if { [is_empty_directory [file join $pkgconf::component_repository $dir $subdir] ] } { | |
| 4938 continue | |
| 4939 } | |
| 4940 lappend tmp $subdir | |
| 4941 } | |
| 4942 set pkg_inc_dirs $tmp | |
| 4943 | |
| 4944 # Create the include directory in the build tree, plus any subdirectories. | |
| 4945 # This directory tree must map the structure of the source tree, so there is | |
| 4946 # no need to worry about thispkg_incdir. | |
| 4947 file mkdir [file join $pkgconf::build_tree $dir] | |
| 4948 foreach subdir $pkg_inc_dirs { | |
| 4949 file mkdir [file join $pkgconf::build_tree $dir $subdir] | |
| 4950 } | |
| 4951 | |
| 4952 # Copy across the pkgconf files that are not already present. | |
| 4953 # Also keep track of this information globally. | |
| 4954 foreach hdr $pkg_pkgconf_files { | |
| 4955 if { [lsearch -exact $pkgconf::pkgconf_files $hdr] != -1 } { | |
| 4956 return -code error "Duplicate configuration header file $hdr" | |
| 4957 } | |
| 4958 lappend pkgconf::pkgconf_files $hdr | |
| 4959 | |
| 4960 set src [file join $pkgconf::component_repository $dir "pkgconf" $hdr] | |
| 4961 set dest [file join $pkgconf::build_tree "pkgconf" $hdr] | |
| 4962 if { (! [file isfile $dest]) || ($pkgconf::force_arg != 0) } { | |
| 4963 file copy -force -- $src $dest | |
| 4964 make_writable $dest | |
| 4965 } | |
| 4966 } | |
| 4967 | |
| 4968 # Keep track of all the subdirectories that should be generated | |
| 4969 # in the install tree. Note that packages may share these | |
| 4970 # subdirectories, e.g. the sys subdirectory will be used by | |
| 4971 # both the C library and by a POSIX compatibily layer. | |
| 4972 # | |
| 4973 # It is necessary to list pkg_incdir separately, and all | |
| 4974 # of its parent directories. Otherwise it is not possible to | |
| 4975 # clean up the install tree correctly when packages get removed. | |
| 4976 if { $pkg_incdir != "" } { | |
| 4977 set current_path "" | |
| 4978 foreach field [file split $pkg_incdir] { | |
| 4979 set current_path [file join $current_path $field] | |
| 4980 if { [lsearch -exact $pkgconf::install_inc_dirs $current_path] == -1 } { | |
| 4981 lappend pkgconf::install_inc_dirs $current_path | |
| 4982 } | |
| 4983 } | |
| 4984 } | |
| 4985 foreach subdir $pkg_inc_dirs { | |
| 4986 set dest [file join $pkg_incdir $subdir] | |
| 4987 if { [lsearch -exact $pkgconf::install_inc_dirs $dest] == -1 } { | |
| 4988 lappend pkgconf::install_inc_dirs $dest | |
| 4989 } | |
| 4990 } | |
| 4991 | |
| 4992 # Keep track of all header files, checking for duplicates. | |
| 4993 foreach hdr $pkg_inc_files { | |
| 4994 set dest [file join $pkg_incdir $hdr] | |
| 4995 if { [lsearch -exact $pkgconf::install_inc_files $dest] != -1 } { | |
| 4996 return -code error "Duplicate header file $dest" | |
| 4997 } | |
| 4998 lappend pkgconf::install_inc_files $dest | |
| 4999 } | |
| 5000 | |
| 5001 # Generate the makefile in the target directory. First set up | |
| 5002 # some variables to contain the right sort of data for a makefile. | |
| 5003 if { $pkg_incdir == "" } { | |
| 5004 set pkg_incdir "." | |
| 5005 } else { | |
| 5006 set pkg_incdir [get_pathname_for_make $pkg_incdir] | |
| 5007 } | |
| 5008 set tmp "" | |
| 5009 foreach file $pkg_inc_files { | |
| 5010 lappend tmp [get_pathname_for_make $file] | |
| 5011 } | |
| 5012 set pkg_inc_files $tmp | |
| 5013 | |
| 5014 set filename [file join $dir "makefile"] | |
| 5015 set makefile [open [file join $pkgconf::build_tree $filename] "w"] | |
| 5016 output_banner $makefile $filename | |
| 5017 puts $makefile \ | |
| 5018 " | |
| 5019 include [get_pathname_for_make [file join [get_dotdots_pkgconf $dir] "pkgconf.mak"]] | |
| 5020 | |
| 2 | 5021 include [get_pathname_for_make [file join [get_dotdots_pkgconf $dir] "system.mak"]] |
| 5022 | |
| 0 | 5023 HEADERS := $pkg_inc_files |
| 5024 TARGETS := \$(foreach hdr,\$(HEADERS),\$(PREFIX)/include/$pkg_incdir/\$(hdr)) | |
| 5025 .PHONY : build clean | |
| 5026 VPATH := . [file join \$(COMPONENT_REPOSITORY) $dir] | |
| 5027 | |
| 5028 build: \$(TARGETS) | |
| 5029 | |
| 5030 " | |
| 5031 foreach hdr $pkg_inc_files { | |
| 5032 puts $makefile "\$(PREFIX)/include/$pkg_incdir/$hdr : $hdr" | |
| 5033 if { $pkgconf::config_data(use_links) == 0 } { | |
| 5034 puts $makefile "\t@\$(CP) \$< \$@" | |
| 5035 } else { | |
| 5036 puts $makefile "\t@\$(RM) \$@; ln -s \$< \$@" | |
| 5037 } | |
| 5038 puts $makefile "" | |
| 5039 } | |
| 5040 | |
| 5041 puts $makefile "clean:" | |
| 5042 foreach hdr $pkg_inc_files { | |
| 5043 puts $makefile "\t@\$(RM) \$(PREFIX)/include/$pkg_incdir/$hdr" | |
| 5044 } | |
| 5045 puts $makefile "\n# End of $filename" | |
| 5046 close $makefile | |
| 5047 } | |
| 5048 | |
| 5049 # ---------------------------------------------------------------------------- | |
| 5050 # Processing the src directory is relatively straightforward. It is | |
| 5051 # necessary to create the src directory in the build tree, plus any | |
| 5052 # subdirectories. It is also necessary to copy across the PKGconf.mak | |
| 5053 # file from the component repository to the build tree, assuming the | |
| 5054 # destination file does not already exist, and do the same in any | |
| 5055 # subdirectories. | |
| 5056 # | |
| 5057 proc pkgconf::process_package_src { dir } { | |
| 5058 | |
| 5059 set srcdir [file join $pkgconf::component_repository $dir] | |
| 5060 set destdir [file join $pkgconf::build_tree $dir] | |
| 5061 | |
| 5062 file mkdir $destdir | |
| 5063 set subdirs [locate_all_subdirs $srcdir] | |
| 5064 foreach subdir $subdirs { | |
| 5065 if { [is_empty_directory [file join $srcdir $subdir] ] } { | |
| 5066 continue | |
| 5067 } | |
| 5068 file mkdir [file join $destdir $subdir] | |
| 5069 } | |
| 5070 | |
| 5071 set makefiles [locate_all_files $srcdir "PKGconf.mak"] | |
| 5072 foreach makefile $makefiles { | |
| 5073 set destname [file join $destdir [file dirname $makefile] "makefile"] | |
| 5074 | |
| 5075 if { ([file isfile $destname] == 0) || $pkgconf::force_arg } { | |
| 5076 file copy -force -- [file join $srcdir $makefile] $destname | |
| 5077 make_writable $destname | |
| 5078 } | |
| 5079 } | |
| 5080 } | |
| 5081 | |
| 5082 # ---------------------------------------------------------------------------- | |
| 5083 # Processing the tests directories is just the same as the source | |
| 5084 # directories, for now. There is one additional complication in that | |
| 5085 # the test executables have to get installed, so it is necessary to | |
| 5086 # keep track of which directories are needed in the install tree. | |
| 5087 | |
| 5088 proc pkgconf::process_package_tests { name dir } { | |
| 5089 | |
| 5090 set srcdir [file join $pkgconf::component_repository $dir] | |
| 5091 set destdir [file join $pkgconf::build_tree $dir] | |
| 5092 | |
| 5093 lappend pkgconf::install_test_dirs [get_build_alias $name] | |
| 5094 | |
| 5095 file mkdir $destdir | |
| 5096 set subdirs [locate_all_subdirs $srcdir] | |
| 5097 | |
| 5098 foreach subdir $subdirs { | |
| 5099 lappend pkgconf::install_test_dirs [file join [get_build_alias $name] $subdir] | |
| 5100 file mkdir [file join $destdir $subdir] | |
| 5101 } | |
| 5102 | |
| 5103 set makefiles [locate_all_files $srcdir "PKGconf.mak"] | |
| 5104 foreach makefile $makefiles { | |
| 5105 set destname [file join $destdir [file dirname $makefile] "makefile"] | |
| 5106 if { ([file isfile $destname] == 0) || $pkgconf::force_arg } { | |
| 5107 file copy -force -- [file join $srcdir $makefile] $destname | |
| 5108 make_writable $destname | |
| 5109 } | |
| 5110 } | |
| 5111 } | |
| 5112 | |
| 2 | 5113 # ---------------------------------------------------------------------------- |
| 5114 # Processing the misc directory is just like the src directory. | |
| 5115 # | |
| 5116 proc pkgconf::process_package_misc { dir } { | |
| 5117 | |
| 5118 set miscdir [file join $pkgconf::component_repository $dir] | |
| 5119 set destdir [file join $pkgconf::build_tree $dir] | |
| 5120 | |
| 5121 file mkdir $destdir | |
| 5122 set subdirs [locate_all_subdirs $miscdir] | |
| 5123 foreach subdir $subdirs { | |
| 5124 if { [is_empty_directory [file join $miscdir $subdir] ] } { | |
| 5125 continue | |
| 5126 } | |
| 5127 file mkdir [file join $destdir $subdir] | |
| 5128 } | |
| 5129 | |
| 5130 set makefiles [locate_all_files $miscdir "PKGconf.mak"] | |
| 5131 foreach makefile $makefiles { | |
| 5132 set destname [file join $destdir [file dirname $makefile] "makefile"] | |
| 5133 | |
| 5134 if { ([file isfile $destname] == 0) || $pkgconf::force_arg } { | |
| 5135 file copy -force -- [file join $miscdir $makefile] $destname | |
| 5136 make_writable $destname | |
| 5137 } | |
| 5138 } | |
| 5139 } | |
| 5140 | |
| 5141 # }}} | |
| 5142 # {{{ Package debug options | |
| 5143 | |
| 5144 # ---------------------------------------------------------------------- | |
| 5145 # Enable appropriate debug options in various packages. Currently the | |
| 5146 # only option that is affected is CYGPKG_INFRA_DEBUG in pkgconf/infra.h | |
| 5147 | |
| 5148 proc pkgconf::enable_package_debug_options { } { | |
| 5149 | |
| 5150 report "Enabling debug-related options" | |
| 5151 | |
| 5152 set fd [open [file join $pkgconf::build_tree "pkgconf" "infra.h"] "r"] | |
| 5153 set data [read $fd] | |
| 5154 close $fd | |
| 5155 | |
| 5156 if { [regexp -- {undef[ ]+CYGPKG_INFRA_DEBUG} $data] } { | |
| 5157 regsub -- {undef[ ]+CYGPKG_INFRA_DEBUG} $data {define CYGPKG_INFRA_DEBUG} data | |
| 5158 set fd [open [file join $pkgconf::build_tree "pkgconf" "infra.h"] "w"] | |
| 5159 puts $fd $data | |
| 5160 close $fd | |
| 5161 } | |
| 5162 } | |
| 5163 | |
| 5164 # Or the inverse. | |
| 5165 proc pkgconf::disable_package_debug_options { } { | |
| 5166 | |
| 5167 report "Disabling debug-related options" | |
| 5168 | |
| 5169 set fd [open [file join $pkgconf::build_tree "pkgconf" "infra.h"] "r"] | |
| 5170 set data [read $fd] | |
| 5171 close $fd | |
| 5172 | |
| 5173 if { [regexp -- {define[ ]+CYGPKG_INFRA_DEBUG} $data] } { | |
| 5174 regsub -- {define[ ]+CYGPKG_INFRA_DEBUG} $data {undef CYGPKG_INFRA_DEBUG} data | |
| 5175 set fd [open [file join $pkgconf::build_tree "pkgconf" "infra.h"] "w"] | |
| 5176 puts $fd $data | |
| 5177 close $fd | |
| 5178 } | |
| 5179 } | |
| 5180 | |
| 0 | 5181 # }}} |
| 5182 # {{{ Install tree | |
| 5183 | |
| 5184 # ---------------------------------------------------------------------------- | |
| 5185 # These routines take care of the install tree. The routine | |
| 5186 # produce_install_tree gets invoked after details of all the packages | |
| 5187 # are known, and hence after details of all the subdirectories | |
| 5188 # are known. | |
| 5189 # | |
| 5190 # Currently this routine will empty out the lib and tests directory | |
| 5191 # completely. It will also get rid of any files and subdirectories in | |
| 5192 # include which are no longer of interest. | |
| 5193 # | |
| 5194 # Clearing out libtarget.a and any similar libraries avoids problems | |
| 5195 # if the target architecture has changed. Such a change should cause | |
| 5196 # all source files to be rebuilt via a dependency on the makefile | |
| 5197 # auxiliary files. However it would result in an attempt to create | |
| 5198 # a library archive containing a mixture of architectures, which could | |
| 5199 # cause all sorts of problems. To make sure that the library gets | |
| 5200 # regenerated during the next build all the stamp files have to be | |
| 5201 # deleted. | |
| 5202 # | |
| 5203 # It is not a good idea to manipulate header files unnecessarily, | |
| 5204 # since changing these would result in application code being | |
| 5205 # recompiled as well as system code. However if the old and new | |
| 5206 # configurations involve a header file with the same name but coming | |
| 5207 # from different packages, (e.g. a standard HAL header if you switch | |
| 5208 # targets or platforms, or a package header if you change the version | |
| 5209 # of that package) then there are complications. | |
| 5210 # | |
| 5211 # For now the code is draconian and just deletes everything. This | |
| 5212 # needs to be optimised. | |
| 5213 # | |
| 5214 | |
| 5215 proc pkgconf::produce_install_tree { } { | |
| 5216 | |
| 5217 ASSERT { $pkgconf::build_tree != "" } | |
| 5218 | |
| 5219 if { $pkgconf::config_data(prefix) != "" } { | |
| 5220 set prefix $pkgconf::config_data(prefix) | |
| 5221 } else { | |
| 5222 set prefix [file join $pkgconf::build_tree "install"] | |
| 5223 } | |
| 5224 ASSERT { $prefix != "" } | |
| 5225 | |
| 5226 # There should be at least an include/pkgconf subdirectory | |
| 5227 ASSERT { $pkgconf::install_inc_dirs != "" } | |
| 5228 | |
| 5229 # In Tcl the mkdir call is a no-op if the directory already exists. | |
| 5230 report "Generating install directory $prefix" | |
| 5231 file mkdir $prefix | |
| 5232 file mkdir [file join $prefix "include"] | |
| 5233 file mkdir [file join $prefix "lib"] | |
| 5234 file mkdir [file join $prefix "tests"] | |
| 5235 | |
| 5236 foreach subdir $pkgconf::install_inc_dirs { | |
| 5237 file mkdir [file join $prefix "include" $subdir] | |
| 5238 } | |
| 5239 foreach subdir $pkgconf::install_test_dirs { | |
| 5240 file mkdir [file join $prefix "tests" $subdir] | |
| 5241 } | |
| 5242 | |
| 5243 if { 0 } { | |
| 5244 | |
| 5245 # BLV - this code does not work with the makefiles that are now | |
| 5246 # generated for the various include directories. If the old | |
| 5247 # configuration involved a header file xyz.h from package A and | |
| 5248 # the new configuration involves a header file xyz.h from a | |
| 5249 # different package (or a different version of the same package) | |
| 5250 # then the old header file would hang around. A temporary | |
| 5251 # work-around is to delete all header files. A proper fix is | |
| 5252 # rather more complicated. | |
| 5253 | |
| 5254 # Examine all the files currently in the include directory. If | |
| 5255 # any of them are not recognised then they should be deleted. | |
| 5256 # Typically this happens if a package is removed. | |
| 5257 # | |
| 5258 # There may be problems if users put the install tree under | |
| 5259 # source code control, in that files just disappear. However even if | |
| 5260 # the source code control system restores an old file this should be | |
| 5261 # harmless. The directory routines ignore CVS subdirectories and all | |
| 5262 # hidden files. | |
| 5263 # | |
| 5264 # Files in pkgconf have to be treated specially. These are listed | |
| 5265 # in pkgconf_files, not header_files. | |
| 5266 | |
| 5267 set existing_headers [locate_all_files [file join $prefix "include"]] | |
| 5268 set pkgconf_headers [locate_all_files [file join $prefix "include" pkgconf]] | |
| 5269 | |
| 5270 foreach file $pkgconf_headers { | |
| 5271 if { [lsearch -exact $pkgconf::pkgconf_files $file] == -1 } { | |
| 5272 set filename [file join $prefix "include" $file] | |
| 5273 report "Deleting unnecessary file $filename" | |
| 5274 file delete -- $filename | |
| 5275 } | |
| 5276 | |
| 5277 # Make sure that this file does not get processed again in the | |
| 5278 # next loop. | |
| 5279 set file [file join "pkgconf" $file] | |
| 5280 set index [lsearch -exact $existing_headers $file] | |
| 5281 ASSERT { $index != -1 } | |
| 5282 set existing_headers [lreplace $existing_headers $index $index] | |
| 5283 } | |
| 5284 | |
| 5285 foreach file $existing_headers { | |
| 5286 if { [lsearch -exact $pkgconf::install_inc_files $file] == -1 } { | |
| 5287 set filename [file join $prefix "include" $file] | |
| 5288 report "Deleting unnecessary file $filename" | |
| 5289 file delete -- $filename | |
| 5290 } | |
| 5291 } | |
| 5292 | |
| 5293 # If the user has switched from symbolic links to file copies then | |
| 5294 # it is also necessary to delete the old symbolic links. The reverse | |
| 5295 # also applies. | |
| 5296 set existing_headers [locate_all_files [file join $prefix "include"]] | |
| 5297 set files_removed 0 | |
| 5298 foreach file $existing_headers { | |
| 5299 | |
| 5300 set filename [file join $prefix "include" $file] | |
| 5301 set type [file type $filename] | |
| 5302 | |
| 5303 if { ($pkgconf::config_data(use_links) == 0 ) && ($type == "link") } { | |
| 5304 file delete -- $filename | |
| 5305 set files_removed 1 | |
| 5306 } elseif { ($pkgconf::config_data(use_links) == 1 ) && ($type == "file") } { | |
| 5307 file delete -- $filename | |
| 5308 set files_removed 1 | |
| 5309 } | |
| 5310 } | |
| 5311 if { $files_removed != 0 } { | |
| 5312 if { $pkgconf::config_data(use_links) == 0 } { | |
| 5313 report "Symbolic links in [file join $prefix include] deleted." | |
| 5314 } else { | |
| 5315 report "Header file copies in [file join $prefix include] deleted." | |
| 5316 } | |
| 5317 } | |
| 5318 | |
| 5319 # Now get rid of any unwanted subdirectories. | |
| 5320 set existing_subdirs [locate_all_subdirs [file join $prefix "include"]] | |
| 5321 foreach subdir $existing_subdirs { | |
| 5322 if { [lsearch -exact $pkgconf::install_inc_dirs $subdir] == -1 } { | |
| 5323 set dirname [file join $prefix "include" $subdir] | |
| 5324 report "Deleting unnecessary directory $dirname" | |
| 5325 file delete -force -- $dirname | |
| 5326 } | |
| 5327 } | |
| 5328 | |
| 5329 } else { | |
| 5330 | |
| 5331 # BLV - delete all header files for now. This is inefficient but safe. | |
| 5332 | |
| 5333 set existing_headers [locate_all_files [file join $prefix "include"]] | |
| 5334 foreach file $existing_headers { | |
| 5335 set filename [file join $prefix "include" $file] | |
| 5336 file delete -- $filename | |
| 5337 } | |
| 5338 | |
| 5339 # Now get rid of any unwanted subdirectories. | |
| 5340 set existing_subdirs [locate_all_subdirs [file join $prefix "include"]] | |
| 5341 foreach subdir $existing_subdirs { | |
| 5342 if { [lsearch -exact $pkgconf::install_inc_dirs $subdir] == -1 } { | |
| 5343 set dirname [file join $prefix "include" $subdir] | |
| 5344 report "Deleting unnecessary directory $dirname" | |
| 5345 file delete -force -- $dirname | |
| 5346 } | |
| 5347 } | |
| 5348 } | |
| 5349 | |
| 5350 # Get rid of all the files in lib. | |
| 5351 set lib_files [locate_files [file join $prefix "lib"]] | |
| 5352 if { $lib_files != "" } { | |
| 5353 report "Deleting old library files $lib_files" | |
| 5354 foreach file $lib_files { | |
| 5355 file delete -- [file join $prefix "lib" $file] | |
| 5356 } | |
| 5357 } | |
| 5358 | |
| 5359 # And get rid of any stamp files spread around the object tree | |
| 5360 foreach src_dir $pkgconf::src_dirs { | |
| 5361 set dirname [file join $pkgconf::build_tree $src_dir] | |
| 5362 set stamp_files [locate_files $dirname "*.stamp"] | |
| 5363 foreach file $stamp_files { | |
| 5364 file delete -- [file join $dirname $file] | |
| 5365 } | |
| 5366 } | |
| 5367 | |
| 5368 # Ditto for tests | |
| 5369 set test_files [locate_all_files [file join $prefix "tests"]] | |
| 5370 if { $test_files != "" } { | |
| 5371 report "Deleting old test executables." | |
| 5372 foreach file $test_files { | |
| 5373 file delete -- [file join $prefix "tests" $file] | |
| 5374 } | |
| 5375 } | |
| 5376 foreach test_dir $pkgconf::tests_dirs { | |
| 5377 set dirname [file join $pkgconf::build_tree $test_dir] | |
| 5378 set stamp_files [locate_files $dirname "*.stamp"] | |
| 5379 foreach file $stamp_files { | |
| 5380 file delete -- [file join $dirname $file] | |
| 5381 } | |
| 5382 } | |
| 5383 | |
| 5384 # If there has been a change in the packages in the system | |
| 5385 # then the various makefile.deps files currently in the | |
| 5386 # build tree may contain references to header files that | |
| 5387 # are no longer present. Therefore it is necessary to | |
| 5388 # get rid of the makefile.deps files. Any changes to the | |
| 5389 # packages will result in a new pkgconf/pkgconf.mak file | |
| 5390 # and all object files depend on this, so everything that | |
| 5391 # needs to be rebuilt will still be rebuilt and new | |
| 5392 # dependency files will be generated. | |
| 5393 # | |
| 5394 # If there has not been a change to the packages then the | |
| 5395 # makefile.deps files must not be deleted, or there would | |
| 5396 # be problems when just a header file is changed. | |
| 5397 if { [packages_have_changed] } { | |
| 5398 | |
| 5399 foreach src_dir $pkgconf::src_dirs { | |
| 5400 set dirname [file join $pkgconf::build_tree $src_dir] | |
| 5401 set dep_files [locate_files $dirname "makefile.deps"] | |
| 5402 foreach file $dep_files { | |
| 5403 file delete -- [file join $dirname $file] | |
| 5404 } | |
| 5405 } | |
| 5406 | |
| 5407 foreach test_dir $pkgconf::tests_dirs { | |
| 5408 set dirname [file join $pkgconf::build_tree $test_dir] | |
| 5409 set dep_files [locate_files $dirname "makefile.deps"] | |
| 5410 foreach file $dep_files { | |
| 5411 file delete -- [file join $dirname $file] | |
| 5412 } | |
| 5413 } | |
| 5414 } | |
| 5415 } | |
| 5416 | |
| 5417 # }}} | |
| 5418 # {{{ Produce misc. files | |
| 5419 | |
| 5420 # ---------------------------------------------------------------------------- | |
| 5421 # Three files have to be generated, and one additional file can be copied. | |
| 5422 # | |
| 5423 # 1) pkgconf/makevars has to be copied from the component repository. | |
| 5424 # 2) pkgconf/makevars relies on pkgconf/pkgconf.mak, which is generated | |
| 5425 # 3) pkgconf/system.h has to be generated. | |
| 5426 # 5) pkgconf/makefile has to be generated. | |
| 5427 # | |
| 5428 | |
| 5429 proc pkgconf::produce_misc_files { } { | |
| 5430 | |
| 5431 report "Generating miscellaneous files." | |
| 5432 | |
| 5433 # Start by copying across pkgconf/makevars unless these files | |
| 5434 # already exist in the build tree. Note that these files are | |
| 5435 # user-editable so they cannot be overwritten automatically. | |
| 5436 set destname [file join $pkgconf::build_tree "pkgconf" "makevars"] | |
| 5437 set sourcename [file join $pkgconf::component_repository "pkgconf" "makevars"] | |
| 5438 if { (![file isfile $destname]) || ($pkgconf::force_arg != 0) } { | |
| 5439 file copy -force -- $sourcename $destname | |
| 5440 make_writable $destname | |
| 5441 } | |
| 5442 | |
| 5443 # Next generate the file pkgconf.mak. This should only happen if any | |
| 5444 # of the data in the file is changed, because there are file-level | |
| 5445 # dependencies in the various makefiles. Additions to the packages | |
| 5446 # file will normally be caught by a missing version number. Other | |
| 5447 # changes to the packages or targets file may not be caught. | |
| 5448 | |
| 5449 set config_changed 0 | |
| 5450 if { [packages_have_changed] } { | |
| 5451 set config_changed 1 | |
| 5452 } | |
| 5453 if { [value_has_changed "prefix"] } { | |
| 5454 set config_changed 1 | |
| 5455 } | |
| 5456 foreach flag $pkgconf::known_compiler_flags { | |
| 5457 if { [value_has_changed "cflags,$flag"] } { | |
| 5458 set config_changed 1 | |
| 5459 break | |
| 5460 } | |
| 5461 } | |
| 5462 if { ![file isfile [file join $pkgconf::build_tree "pkgconf" "pkgconf.mak"]] } { | |
| 5463 set config_changed 1 | |
| 5464 } | |
| 5465 if { $pkgconf::force_arg != 0 } { | |
| 5466 set config_changed 1 | |
| 5467 } | |
| 5468 | |
| 5469 if { $config_changed != 0 } { | |
| 5470 | |
| 5471 set filename [file join "pkgconf" "pkgconf.mak"] | |
| 5472 set file [open [file join $pkgconf::build_tree $filename] "w"] | |
| 5473 output_banner $file $filename | |
| 5474 | |
| 5475 # All PKGconf.mak files should include the master pkgconf.mak | |
| 5476 # file ASAP. It is desirable to have a goal at the top of that | |
| 5477 # file. This is likely to be the first goal detected by make, | |
| 5478 # and hence the default. | |
| 5479 puts $file "\ndefault: build\n" | |
| 5480 | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5481 set platform $pkgconf::config_data(platform) |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5482 if [info exists pkgconf::target_data($pkgconf::config_data(target),$platform,prefix)] { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5483 set command_prefix $pkgconf::target_data($pkgconf::config_data(target),$platform,prefix) |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5484 } else { |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5485 set command_prefix $pkgconf::target_data($pkgconf::config_data(target),prefix) |
|
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5486 } |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5487 if {"" != $command_prefix} { |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5488 set command_prefix "${command_prefix}-" |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5489 } |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5490 |
| 0 | 5491 puts $file "" |
| 5492 puts $file "COMPONENT_REPOSITORY\t\t:= [get_pathname_for_make $pkgconf::component_repository]" | |
| 5493 puts $file "BUILD_TREE\t\t\t:= [get_pathname_for_make $pkgconf::build_tree]" | |
| 5494 | |
| 2 | 5495 # Provide details of target etc. so that packages can specify |
| 5496 # per-target files. | |
| 5497 puts $file "TARGET\t\t\t\t:= $pkgconf::config_data(target)" | |
| 5498 puts $file "PLATFORM\t\t\t:= $pkgconf::config_data(platform)" | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5499 puts $file "BASE_PLATFORM\t\t\t:= $pkgconf::config_data(base_platform)" |
| 2 | 5500 puts $file "STARTUP\t\t\t\t:= $pkgconf::config_data(startup)" |
| 5501 | |
| 0 | 5502 # The prefix (i.e. install directory) should default to somewhere |
| 5503 # relative to the build tree. | |
| 5504 set prefix $pkgconf::config_data(prefix) | |
| 5505 if { $prefix == "" } { | |
| 5506 set prefix [file join $pkgconf::build_tree "install"] | |
| 5507 } | |
| 5508 puts $file "PREFIX\t\t\t\t:= [get_pathname_for_make $prefix]" | |
| 5509 if { $pkgconf::windows_host != 0 } { | |
| 5510 puts $file "EXEEXT\t\t\t\t:= .exe" | |
| 5511 } | |
| 5512 puts $file "" | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5513 puts $file "PKGCONF_CC\t\t\t:= ${command_prefix}gcc" |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5514 puts $file "PKGCONF_CXX\t\t\t:= ${command_prefix}gcc" |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5515 puts $file "PKGCONF_AR\t\t\t:= ${command_prefix}ar" |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5516 puts $file "PKGCONF_LD\t\t\t:= ${command_prefix}ld" |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
14
diff
changeset
|
5517 puts $file "PKGCONF_OBJCOPY\t\t\t:= ${command_prefix}objcopy" |
| 0 | 5518 puts $file "" |
| 5519 | |
| 5520 foreach flag $pkgconf::known_compiler_flags { | |
| 5521 set value "" | |
| 5522 if { [info exists pkgconf::config_data(cflags,$flag)] != 0 } { | |
| 5523 set value $pkgconf::config_data(cflags,$flag) | |
| 5524 } else { | |
| 5525 set value [get_platform_cflags $pkgconf::config_data(target) $pkgconf::config_data(platform) $flag] | |
| 5526 } | |
| 5527 if { $value != "" } { | |
| 5528 puts $file "PKGCONF_[set flag]\t\t:= $value" | |
| 5529 } | |
| 5530 } | |
| 5531 puts $file "" | |
| 5532 | |
| 5533 foreach pkg [get_current_packages] { | |
| 5534 set varname "[get_build_alias $pkg]_DIR" | |
| 5535 set dirname [file join $pkgconf::package_data($pkg,dir) $pkgconf::config_data($pkg,version)] | |
| 5536 puts $file "$varname\t\t:= $dirname" | |
| 5537 } | |
| 5538 | |
| 5539 # There are several files containing information about make variables | |
| 5540 # rules. The current file, pkgconf.mak, contains information that | |
| 5541 # is known to the pkgconf script and should not be edited by users. | |
| 5542 # There may be a per-package file in the build tree's pkgconf | |
| 5543 # directory, containing per-package settings. And there is the | |
| 5544 # makevars file which users can edit to override anything else. | |
| 5545 # | |
| 5546 # The makefiles for the various packages should only | |
| 5547 # need to include one of these files, the rest can be handled | |
| 5548 # automatically. Since pkgconf.mak is generated it knows the | |
| 5549 # location of the build tree, making it a lot easier to find | |
| 5550 # the others. Therefore pkgconf.mak is included first, then | |
| 5551 # the per-package file, and finally the makevars file. | |
| 5552 | |
| 5553 puts $file " | |
| 5554 PACKAGE_RULES_FILE := \$(wildcard \$(BUILD_TREE)/pkgconf/\$(PACKAGE).mak) | |
|
46
797268ecc331
Merge from eCos master repository on 1999-10-19-18:55:31-BST
jlarmour
parents:
44
diff
changeset
|
5555 ifneq (\$(PACKAGE_RULES_FILE),) |
|
797268ecc331
Merge from eCos master repository on 1999-10-19-18:55:31-BST
jlarmour
parents:
44
diff
changeset
|
5556 include \$(PACKAGE_RULES_FILE) |
| 0 | 5557 endif" |
| 5558 | |
| 5559 puts $file "\ninclude \$(BUILD_TREE)/pkgconf/makevars" | |
| 5560 | |
| 5561 puts $file "\n# End of $filename" | |
| 5562 close $file | |
| 5563 } | |
| 5564 | |
| 5565 # And the file system.h | |
| 5566 # | |
| 5567 # Again, because of file-level dependencies this file should only | |
| 5568 # be written out if anything has actually changed. | |
| 5569 set config_changed 0 | |
| 5570 if { [packages_have_changed] || [value_has_changed "startup"] } { | |
| 5571 set config_changed 1 | |
| 5572 } | |
| 5573 if { ![file isfile [file join $pkgconf::build_tree "pkgconf" "system.h"]] } { | |
| 5574 set config_changed 1 | |
| 5575 } | |
| 5576 if { $pkgconf::force_arg != 0 } { | |
| 5577 set config_changed 1 | |
| 5578 } | |
| 5579 | |
| 5580 if { $config_changed != 0 } { | |
| 5581 | |
| 5582 set filename [file join "pkgconf" "system.h"] | |
| 5583 set file [open [file join $pkgconf::build_tree $filename] "w"] | |
| 5584 puts $file \ | |
| 5585 "#ifndef CYGONCE_PKGCONF_SYSTEM_H | |
| 5586 #define CYGONCE_PKGCONF_SYSTEM_H | |
| 5587 /* | |
| 5588 * File $filename | |
| 5589 * | |
| 5590 * This file is generated automatically by the pkgconf program. | |
| 5591 * It should not be edited. Any changes to this file may be | |
| 5592 * overwritten by pkgconf. | |
| 5593 */ | |
| 5594 " | |
| 5595 puts $file "#define CYG_HAL_[string toupper $pkgconf::config_data(target)]" | |
| 5596 puts $file \ | |
| 5597 "#define CYG_HAL_[string toupper $pkgconf::config_data(target)]_[string toupper $pkgconf::config_data(platform)]" | |
| 5598 puts $file "#define CYG_HAL_STARTUP_[string toupper $pkgconf::config_data(startup)]" | |
| 5599 puts $file "" | |
| 5600 set current_packages [get_current_packages] | |
| 5601 foreach pkg $pkgconf::known_packages { | |
| 5602 if { [lsearch -exact $current_packages $pkg] == -1 } { | |
| 5603 puts $file "#undef $pkg" | |
| 5604 } else { | |
| 5605 puts $file "#define $pkg" | |
| 5606 } | |
| 5607 } | |
| 5608 | |
| 2 | 5609 # Additions for the MLT |
| 5610 puts $file "\n" | |
|
14
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
12
diff
changeset
|
5611 puts $file "#define CYGHWR_MEMORY_LAYOUT_LDI <pkgconf/mlt_[set pkgconf::config_data(target)]_[set pkgconf::config_data(platform)]_[set pkgconf::config_data(startup)].ldi>" |
|
01ce82f3e11a
Merge from eCos master repository on 1999-06-11-17:05:41-BST
jlarmour
parents:
12
diff
changeset
|
5612 puts $file "#define CYGHWR_MEMORY_LAYOUT_H <pkgconf/mlt_[set pkgconf::config_data(target)]_[set pkgconf::config_data(platform)]_[set pkgconf::config_data(startup)].h>" |
|
4
1d7f19c9e4d1
Merge from eCos master repository on 1999-05-11-21:11:10-BST
jlarmour
parents:
2
diff
changeset
|
5613 |
|
1d7f19c9e4d1
Merge from eCos master repository on 1999-05-11-21:11:10-BST
jlarmour
parents:
2
diff
changeset
|
5614 # Also output details of the HAL header files that should be included |
|
1d7f19c9e4d1
Merge from eCos master repository on 1999-05-11-21:11:10-BST
jlarmour
parents:
2
diff
changeset
|
5615 puts $file "\n" |
|
1d7f19c9e4d1
Merge from eCos master repository on 1999-05-11-21:11:10-BST
jlarmour
parents:
2
diff
changeset
|
5616 puts $file "#define CYGBLD_HAL_TARGET_H <pkgconf/hal_[set pkgconf::config_data(target)].h>" |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5617 puts $file "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_[set pkgconf::config_data(target)]_[set pkgconf::config_data(base_platform)].h>" |
| 2 | 5618 |
| 0 | 5619 puts $file "\ |
| 5620 \n#endif /* CYGONCE_PKGCONF_SYSTEM_H */ | |
| 5621 /* EOF $filename */" | |
| 5622 close $file | |
| 5623 } | |
| 5624 | |
| 2 | 5625 # 'system.mak' has the same basic information, but in a form |
| 5626 # that can be used by makefile fragments. | |
| 5627 | |
| 5628 if { $config_changed != 0 } { | |
| 5629 | |
| 5630 set filename [file join "pkgconf" "system.mak"] | |
| 5631 set file [open [file join $pkgconf::build_tree $filename] "w"] | |
| 5632 puts $file \ | |
| 5633 "# | |
| 5634 # File $filename | |
| 5635 # | |
| 5636 # This file is generated automatically by the pkgconf program. | |
| 5637 # It should not be edited. Any changes to this file may be | |
| 5638 # overwritten by pkgconf. | |
| 5639 # | |
| 5640 " | |
| 5641 puts $file "CYG_HAL_[string toupper $pkgconf::config_data(target)]=1" | |
| 5642 puts $file \ | |
| 5643 "CYG_HAL_[string toupper $pkgconf::config_data(target)]_[string toupper $pkgconf::config_data(platform)]=1" | |
| 5644 puts $file "CYG_HAL_STARTUP_[string toupper $pkgconf::config_data(startup)]=1" | |
| 5645 puts $file "" | |
| 5646 set current_packages [get_current_packages] | |
| 5647 foreach pkg $pkgconf::known_packages { | |
| 5648 if { [lsearch -exact $current_packages $pkg] != -1 } { | |
| 5649 puts $file "$pkg=1" | |
| 5650 } | |
| 5651 } | |
| 5652 puts $file "\n# /* EOF $filename */" | |
| 5653 close $file | |
| 5654 } | |
| 5655 | |
| 0 | 5656 # Always output a makefile in the pkgconf directory. This is harmless |
| 5657 # because there should be no file-level dependencies on this file (just | |
| 5658 # like the toplevel makefile). | |
| 5659 set filename [file join "pkgconf" "makefile"] | |
| 5660 set makefile [open [file join $pkgconf::build_tree $filename] "w"] | |
| 5661 output_banner $makefile $filename | |
| 5662 | |
| 5663 puts $makefile \ | |
| 5664 "include pkgconf.mak | |
| 5665 | |
| 5666 .PHONY : build clean | |
| 5667 HEADERS := $pkgconf::pkgconf_files | |
| 5668 TARGETS := \$(foreach hdr,\$(HEADERS),\$(PREFIX)/include/pkgconf/\$(hdr)) | |
| 5669 | |
| 5670 build: \$(TARGETS) | |
| 5671 " | |
| 5672 | |
| 5673 foreach hdr $pkgconf::pkgconf_files { | |
| 5674 puts $makefile "\$(PREFIX)/include/pkgconf/$hdr : $hdr" | |
| 5675 if { $pkgconf::config_data(use_links) == 0 } { | |
| 5676 puts $makefile "\t@\$(CP) \$< \$@" | |
| 5677 } else { | |
| 5678 puts $makefile "\t@\$(RM) \$@; ln -s \$< \$@" | |
| 5679 } | |
| 5680 puts $makefile "" | |
| 5681 } | |
| 5682 | |
| 5683 puts $makefile "clean:" | |
| 5684 foreach hdr $pkgconf::pkgconf_files { | |
| 5685 puts $makefile "\t@\$(RM) \$(PREFIX)/include/pkgconf/$hdr" | |
| 5686 } | |
| 5687 puts $makefile "\n# End of $filename" | |
| 5688 close $makefile | |
| 5689 | |
| 5690 } | |
| 5691 | |
| 5692 # }}} | |
| 5693 # {{{ Produce the master makefile | |
| 5694 | |
| 5695 # ---------------------------------------------------------------------------- | |
| 5696 # This routine is responsible for generating the master makefile that | |
| 5697 # exists at the top of a build tree. This makefile supports three main | |
| 5698 # targets: default, tests and clean. There is a subsidiary target | |
| 5699 # "headers" which takes care of the header files. | |
| 5700 # | |
| 5701 | |
| 5702 proc pkgconf::produce_makefile { } { | |
| 5703 | |
| 5704 report "Generating toplevel makefile." | |
| 5705 | |
| 5706 ASSERT { $pkgconf::build_tree != "" } | |
| 5707 set filename [file join $pkgconf::build_tree "makefile"] | |
| 5708 set makefile [open $filename "w"] | |
| 5709 output_banner $makefile "makefile" | |
| 5710 | |
| 5711 puts $makefile \ | |
| 5712 " | |
| 5713 include pkgconf/pkgconf.mak | |
|
4
1d7f19c9e4d1
Merge from eCos master repository on 1999-05-11-21:11:10-BST
jlarmour
parents:
2
diff
changeset
|
5714 .PHONY: default build clean tests headers" |
| 2 | 5715 |
|
46
797268ecc331
Merge from eCos master repository on 1999-10-19-18:55:31-BST
jlarmour
parents:
44
diff
changeset
|
5716 puts $makefile "\nbuild: \$(PREFIX)/lib/extras.o" |
| 2 | 5717 puts $makefile "\t@echo Build finished." |
| 5718 | |
|
46
797268ecc331
Merge from eCos master repository on 1999-10-19-18:55:31-BST
jlarmour
parents:
44
diff
changeset
|
5719 puts $makefile "\n\$(PREFIX)/lib/extras.o: \$(PREFIX)/lib/libextras.a" |
|
797268ecc331
Merge from eCos master repository on 1999-10-19-18:55:31-BST
jlarmour
parents:
44
diff
changeset
|
5720 puts $makefile "\t\$(CC) \$(ARCHFLAGS) \$(LDARCHFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive \$(PREFIX)/lib/libextras.a -o \$(PREFIX)/lib/extras.o" |
| 2 | 5721 |
|
46
797268ecc331
Merge from eCos master repository on 1999-10-19-18:55:31-BST
jlarmour
parents:
44
diff
changeset
|
5722 puts $makefile "\n\$(PREFIX)/lib/libextras.a: headers" |
| 0 | 5723 foreach src_dir $pkgconf::src_dirs { |
| 5724 puts $makefile "\t\$(MAKE) -C $src_dir" | |
| 5725 } | |
| 5726 | |
| 5727 puts $makefile "\ntests: build" | |
| 5728 foreach tests_dir $pkgconf::tests_dirs { | |
| 5729 puts $makefile "\t\$(MAKE) -C $tests_dir" | |
| 5730 } | |
| 5731 puts $makefile "\t@echo Tests build finished." | |
| 5732 | |
| 2 | 5733 puts $makefile "\nmisc: build" |
| 5734 foreach misc_dir $pkgconf::misc_dirs { | |
| 5735 puts $makefile "\t\$(MAKE) -C $misc_dir" | |
| 5736 } | |
| 5737 puts $makefile "\t@echo Misc build finished." | |
| 5738 | |
| 0 | 5739 puts $makefile \ |
| 5740 "\nlibobjs := \$(wildcard \$(PREFIX)/lib/*) | |
| 5741 clean: | |
| 5742 ifneq (\$(libobjs),) | |
| 5743 \t\$(RM) \$(libobjs) | |
| 5744 endif | |
| 5745 \tmake -C pkgconf clean" | |
| 5746 foreach src_dir $pkgconf::src_dirs { | |
| 5747 puts $makefile "\t\$(MAKE) -C $src_dir clean" | |
| 5748 } | |
| 2 | 5749 foreach misc_dir $pkgconf::misc_dirs { |
| 5750 puts $makefile "\t\$(MAKE) -C $misc_dir clean" | |
| 5751 } | |
| 0 | 5752 foreach tests_dir $pkgconf::tests_dirs { |
| 5753 puts $makefile "\t\$(MAKE) -C $tests_dir clean" | |
| 5754 } | |
| 5755 foreach inc_dir $pkgconf::inc_dirs { | |
| 5756 puts $makefile "\t@\$(MAKE) -silent -C $inc_dir clean" | |
| 5757 } | |
| 5758 puts $makefile "\t@echo Clean finished." | |
| 5759 | |
| 5760 puts $makefile "\nheaders:" | |
| 5761 puts $makefile "\t@echo Checking header files." | |
| 5762 puts $makefile "\t@\$(MAKE) -silent -C pkgconf" | |
| 5763 foreach inc_dir $pkgconf::inc_dirs { | |
| 5764 puts $makefile "\t@\$(MAKE) -silent -C $inc_dir" | |
| 5765 } | |
| 5766 | |
| 5767 puts $makefile "" | |
| 5768 puts $makefile "# End of makefile" | |
| 5769 close $makefile | |
| 5770 } | |
| 5771 | |
| 5772 # }}} | |
| 5773 | |
| 5774 # {{{ Produce_build_tree | |
| 5775 | |
| 5776 proc pkgconf::produce_build_tree { } { | |
| 5777 | |
| 5778 # First, check that all the requirements have been satisfied. Normally | |
| 5779 # this will have been taken care of earlier. | |
| 5780 check_requirements | |
| 5781 | |
| 5782 # What is the install tree ? | |
| 5783 set prefix $pkgconf::config_data(prefix) | |
| 5784 if { $prefix == "" } { | |
| 5785 set prefix [file join $pkgconf::build_tree "install"] | |
| 5786 } | |
| 5787 set target $pkgconf::config_data(target) | |
| 5788 set platform $pkgconf::config_data(platform) | |
| 5789 set startup $pkgconf::config_data(startup) | |
| 5790 | |
| 5791 # Report the configuration that is being built. | |
| 5792 report "Generating build tree." | |
| 5793 report "Component repository is $pkgconf::component_repository" | |
| 5794 report "Build tree is $pkgconf::build_tree" | |
| 5795 report "Install directory is $prefix" | |
| 5796 report "Architecture $target, platform $platform, startup $startup." | |
| 5797 if { $pkgconf::config_data(use_links) != 0 } { | |
| 5798 report "Using symbolic links for the header files." | |
| 5799 } | |
| 5800 | |
| 5801 # Reset the list of all the header files that should be in the install | |
| 5802 # tree, and related variables. | |
| 5803 set pkgconf::inc_dirs "" | |
| 5804 set pkgconf::src_dirs "" | |
| 2 | 5805 set pkgconf::misc_dirs "" |
| 0 | 5806 set pkgconf::tests_dirs "" |
| 5807 set pkgconf::install_inc_dirs "pkgconf" | |
| 5808 set pkgconf::install_inc_files "" | |
| 5809 set pkgconf::pkgconf_files "makevars pkgconf.mak system.h" | |
| 5810 set pkgconf::install_test_dirs "" | |
| 5811 | |
| 5812 set status [catch { | |
| 5813 | |
| 5814 # Create the toplevel build tree directory, if necessary. | |
| 5815 if { ! [file exists $pkgconf::build_tree] } { | |
| 5816 report "Creating build tree $pkgconf::build_tree" | |
| 5817 file mkdir $pkgconf::build_tree | |
| 5818 } | |
| 5819 # Create the pkgconf subdirectory. A failure here indicates that | |
| 5820 # the build tree is not writable, and it is useful to detect this | |
| 5821 # before too much processing takes place. | |
| 5822 set dirname [file join $pkgconf::build_tree pkgconf] | |
| 5823 if { ! [file exists $dirname] } { | |
| 5824 report "Creating directory $dirname" | |
| 5825 file mkdir $dirname | |
| 5826 } | |
| 5827 | |
| 5828 # Process each package that is part of the current configuration | |
| 5829 foreach pkg [get_current_packages] { | |
| 5830 set dirname $pkgconf::package_data($pkg,dir) | |
| 5831 set dirname [file join $dirname $pkgconf::config_data($pkg,version)] | |
| 5832 process_package $pkg $dirname | |
| 5833 } | |
| 5834 | |
| 2 | 5835 # If this is a debug build (according to the --debug command line |
| 5836 # option), update the appropriate packages. | |
| 5837 if {$pkgconf::debug_arg != 0} { | |
| 5838 enable_package_debug_options | |
| 5839 } elseif {$pkgconf::nodebug_arg != 0} { | |
| 5840 disable_package_debug_options | |
| 5841 } | |
| 5842 | |
| 0 | 5843 # The install tree must exist before the misc files are generated. |
| 5844 # See get_pathname_for_make for details. | |
| 5845 produce_install_tree | |
| 5846 produce_misc_files | |
| 5847 produce_makefile | |
| 5848 | |
| 5849 report "Generating save file." | |
| 5850 write_save_file | |
| 5851 report "The Build tree is ready." | |
| 5852 | |
| 5853 } message] | |
| 5854 | |
| 5855 if { $status != 0 } { | |
| 5856 fatal_error "An unexpected error occurred while generating the build tree: $message" | |
| 5857 } | |
| 5858 } | |
| 5859 | |
| 5860 # }}} | |
| 5861 | |
| 5862 # }}} | |
| 5863 # {{{ main() | |
| 5864 | |
| 5865 # ---------------------------------------------------------------------------- | |
| 5866 # Initialise data. This routine is responsible for reading in the | |
| 5867 # packages file and the targets file, setting up the default data, | |
| 5868 # reading in the save file if any, and processing the command line | |
| 5869 # arguments if any. | |
| 5870 # | |
| 5871 | |
| 5872 proc pkgconf::initialise_data { } { | |
| 5873 | |
| 5874 # First, read the packages and targets files. These routines will | |
| 5875 # also deal with the --packages and --targets arguments, and | |
| 5876 # they will check for any invalid packages or targets that may | |
| 5877 # have been passed. The order of these two calls should not be | |
| 5878 # changed since read_targets needs to know about the available | |
| 5879 # packages for some of its validations. | |
| 5880 pkgconf::read_packages | |
| 5881 pkgconf::read_targets | |
| 5882 | |
| 5883 # If either or both of the --packages or --targets arguments | |
| 5884 # were used, do not go any further. The user was just asking | |
| 5885 # for information. Ditto for --pkgdata, which can be used by | |
| 5886 # other programs to get information about the various | |
| 5887 # packages in a format more appropriate for them. | |
| 5888 # | |
| 5889 # NOTE: the parsing code does not actually check that no | |
| 5890 # further arguments were passed, but it is unlikely that the | |
| 5891 # user would both ask for a list of packages and expect | |
| 5892 # something to happen. | |
| 5893 if { ( $pkgconf::list_packages_arg != 0 ) || | |
| 5894 ( $pkgconf::list_targets_arg != 0 ) || | |
| 5895 ( $pkgconf::list_pkgdata_arg != 0 ) } { | |
| 5896 exit 0 | |
| 5897 } | |
| 5898 | |
| 5899 # Set up default values for all options which are managed directly | |
| 5900 # by this program. | |
| 5901 pkgconf::setup_defaults | |
| 5902 | |
| 5903 # Check for a save file in the existing build tree. | |
| 5904 # If so read it in, updating the default values. | |
| 5905 pkgconf::read_save_file | |
| 5906 | |
| 5907 # Now process the command line arguments, which will again result | |
| 5908 # in updates to the default values. | |
| 5909 pkgconf::process_arguments | |
| 5910 | |
| 5911 # If the -flags argument was used, list the compiler flags currently | |
| 5912 # in use. This could not be done earlier since the compiler flags | |
| 5913 # may depend on the save file and on other command line arguments. | |
| 5914 if { $pkgconf::list_flags_arg != 0 } { | |
| 5915 foreach flag $pkgconf::known_compiler_flags { | |
| 5916 set value "" | |
| 5917 if { [info exists pkgconf::config_data(cflags,$flag)] != 0 } { | |
| 5918 set value $pkgconf::config_data(cflags,$flag) | |
| 5919 } else { | |
| 5920 set value [get_platform_cflags $pkgconf::config_data(target) $pkgconf::config_data(platform) $flag] | |
| 5921 } | |
| 5922 if { $value != "" } { | |
| 5923 puts "$flag\t\"$value\"" | |
| 5924 } | |
| 5925 } | |
| 5926 exit 0 | |
| 5927 } | |
| 5928 | |
| 5929 if { 0 } { | |
| 5930 puts "target: $pkgconf::config_data(target)" | |
| 5931 puts "platform: $pkgconf::config_data(platform)" | |
|
12
4cc3eff958ab
Merge from eCos master repository on 1999-06-04-22:24:56-BST
jlarmour
parents:
4
diff
changeset
|
5932 puts "base_platform: $pkgconf::config_data(base_platform)" |
| 0 | 5933 puts "startup: $pkgconf::config_data(startup)" |
| 5934 puts "prefix: $pkgconf::config_data(prefix)" | |
| 5935 puts "packages: $pkgconf::config_data(packages)" | |
| 5936 foreach pkg $pkgconf::config_data(packages) { | |
| 5937 puts "$pkg version $pkgconf::config_data($pkg,version)" | |
| 5938 } | |
| 5939 exit 0 | |
| 5940 } | |
| 5941 } | |
| 5942 | |
| 5943 # ---------------------------------------------------------------------------- | |
| 5944 # Main(). This code only runs if the script is being run stand-alone rather | |
| 5945 # than as part of a larger application. The controlling predicate is the | |
| 5946 # existence of the variable pkgconf_not_standalone which can be set by | |
| 5947 # the containing program if any. | |
| 5948 # | |
| 5949 | |
| 5950 if { ! [info exists pkgconf_not_standalone] } { | |
| 5951 | |
| 5952 # Do some necessary GUI initialisation such as hiding the main window | |
| 5953 # during startup. | |
| 5954 pkgconf::gui_standalone_init | |
| 5955 | |
| 5956 # Decide where warnings and fatal errors should go. | |
| 5957 pkgconf::initialise_error_handling | |
| 5958 | |
| 5959 # Parse the arguments and set the global variables appropriately. | |
| 5960 pkgconf::parse_arguments $argv0 $argv | |
| 5961 | |
| 5962 # Initialise all the data, e.g. by reading in the packages and | |
| 5963 # targets files. | |
| 5964 pkgconf::initialise_data | |
| 5965 | |
| 5966 # At this stage the code can do one of two things: run the GUI, | |
| 5967 # or build/update the build tree. | |
| 5968 # The GUI can be run if the necessary commands are available and | |
| 5969 # if the user did not pass -nw. | |
| 5970 if { $pkgconf::gui_possible && ! $pkgconf::no_windows_arg } { | |
| 5971 } else { | |
| 5972 set pkgconf::gui_mode 0 | |
| 5973 } | |
| 5974 | |
| 5975 # Reset error handling to the correct mode | |
| 5976 pkgconf::initialise_error_handling | |
| 5977 | |
| 5978 # Either enter GUI mode, or produce the build tree | |
| 5979 if { $pkgconf::gui_mode } { | |
| 5980 pkgconf::gui | |
| 5981 } else { | |
| 5982 pkgconf::produce_build_tree | |
| 5983 exit 0 | |
| 5984 } | |
| 5985 } | |
| 5986 | |
| 5987 # }}} | |
| 5988 | |
| 5989 |
