From 5baaf0b8c4bad4e761c0cc517f7fe7fc97f0bb91 Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Mon, 9 Sep 2019 10:38:40 +0000 Subject: [PATCH] Update autosetup --- autosetup/README.autosetup | 2 +- autosetup/autosetup | 127 ++++++++++++++++++++----------------- autosetup/cc-db.tcl | 2 +- autosetup/cc-lib.tcl | 2 - autosetup/cc-shared.tcl | 2 +- autosetup/cc.tcl | 2 +- autosetup/pkg-config.tcl | 2 +- autosetup/system.tcl | 4 +- autosetup/tmake.tcl | 2 +- 9 files changed, 76 insertions(+), 69 deletions(-) diff --git a/autosetup/README.autosetup b/autosetup/README.autosetup index a6215e80a..a848c3f88 100644 --- a/autosetup/README.autosetup +++ b/autosetup/README.autosetup @@ -1,4 +1,4 @@ -README.autosetup created by autosetup v0.6.9 +README.autosetup created by autosetup v0.6.9+ This is the autosetup directory for a local install of autosetup. It contains autosetup, support files and loadable modules. diff --git a/autosetup/autosetup b/autosetup/autosetup index da3a83573..0ea1219f7 100755 --- a/autosetup/autosetup +++ b/autosetup/autosetup @@ -6,7 +6,7 @@ dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@" # Note that the version has a trailing + on unreleased versions -set autosetup(version) 0.6.9 +set autosetup(version) 0.6.9+ # Can be set to 1 to debug early-init problems set autosetup(debug) [expr {"--debug" in $argv}] @@ -93,13 +93,13 @@ proc main {argv} { #"=Core Options:" options-add { - help:=local => "display help and options. Optionally specify a module name, such as --help=system" + help:=all => "display help and options. Optional: module name, such as --help=system" licence license => "display the autosetup license" - version => "display the version of autosetup" + version => "display the version of autosetup" ref:=text manual:=text reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'" - debug => "display debugging output as autosetup runs" - install:=. => "install autosetup to the current or given directory" + debug => "display debugging output as autosetup runs" + install:=. => "install autosetup to the current or given directory" } if {$autosetup(installed)} { # hidden options so we can produce a nice error @@ -216,8 +216,8 @@ proc main {argv} { configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]" configlog "Tclsh: [info nameofexecutable]" - # Note that auto.def is *not* loaded in the global scope - source $autosetup(autodef) + # Load auto.def as module "auto.def" + autosetup_load_module auto.def source $autosetup(autodef) # Could warn here if options {} was not specified @@ -375,7 +375,7 @@ proc option-check-names {args} { # Parse the option definition in $opts and update # ::autosetup(setoptions) and ::autosetup(optionhelp) appropriately # -proc options-add {opts {header ""}} { +proc options-add {opts} { global autosetup # First weed out comment lines @@ -391,8 +391,7 @@ proc options-add {opts {header ""}} { set opt [lindex $opts $i] if {[string match =* $opt]} { # This is a special heading - lappend autosetup(optionhelp) $opt "" - set header {} + lappend autosetup(optionhelp) [list $opt $autosetup(module)] continue } unset -nocomplain defaultvalue equal value @@ -509,13 +508,8 @@ proc options-add {opts {header ""}} { if {[info exists defaultvalue]} { set desc [string map [list @default@ $defaultvalue] $desc] } - #string match \n* $desc - if {$header ne ""} { - lappend autosetup(optionhelp) $header "" - set header "" - } # A multi-line description - lappend autosetup(optionhelp) $opthelp $desc + lappend autosetup(optionhelp) [list $opthelp $autosetup(module) $desc] incr i 2 } } @@ -523,21 +517,9 @@ proc options-add {opts {header ""}} { # @module-options optionlist # -# Like 'options', but used within a module. +# Deprecated. Simply use 'options' from within a module. proc module-options {opts} { - set header "" - if {$::autosetup(showhelp) > 1 && [llength $opts]} { - set header "Module Options:" - } - options-add $opts $header - - if {$::autosetup(showhelp)} { - # Ensure that the module isn't executed on --help - # We are running under eval or source, so use break - # to prevent further execution - #return -code break -level 2 - return -code break - } + options $opts } proc max {a b} { @@ -566,10 +548,17 @@ proc options-wrap-desc {text length firstprefix nextprefix initial} { } } -proc options-show {} { +# Display options (from $autosetup(optionhelp)) for modules that match +# glob pattern $what +proc options-show {what} { + set local 0 # Determine the max option width set max 0 - foreach {opt desc} $::autosetup(optionhelp) { + foreach help $::autosetup(optionhelp) { + lassign $help opt module desc + if {![string match $what $module]} { + continue + } if {[string match =* $opt] || [string match \n* $desc]} { continue } @@ -582,13 +571,23 @@ proc options-show {} { } incr cols -1 # Now output - foreach {opt desc} $::autosetup(optionhelp) { + foreach help $::autosetup(optionhelp) { + lassign $help opt module desc + if {![string match $what $module]} { + continue + } + if {$local == 0 && $module eq "auto.def"} { + puts "Local Options:" + incr local + } if {[string match =* $opt]} { + # Output a special heading line" puts [string range $opt 1 end] continue } puts -nonewline " [format %-${max}s $opt]" if {[string match \n* $desc]} { + # Output a pre-formatted help description as-is puts $desc } else { options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2] @@ -629,19 +628,22 @@ proc options-show {} { ## lfs=1 largefile=1 => "Disable large file support" # proc options {optlist} { - # Allow options as a list or args - options-add $optlist "Local Options:" + global autosetup - if {$::autosetup(showhelp)} { - options-show - exit 0 + options-add $optlist + + if {$autosetup(showhelp)} { + # If --help, stop now to show help + return -code break } - # Check for invalid options - if {[opt-bool option-checking]} { - foreach o [dict keys $::autosetup(getopt)] { - if {$o ni $::autosetup(options)} { - user-error "Unknown option --$o" + if {$autosetup(module) eq "auto.def"} { + # Check for invalid options + if {[opt-bool option-checking]} { + foreach o [dict keys $::autosetup(getopt)] { + if {$o ni $::autosetup(options)} { + user-error "Unknown option --$o" + } } } } @@ -1173,8 +1175,9 @@ proc use {args} { continue } set libmodule($m) 1 + if {[info exists modsource(${m}.tcl)]} { - automf_load eval $modsource(${m}.tcl) + autosetup_load_module $m eval $modsource(${m}.tcl) } else { set locs [list ${m}.tcl ${m}/init.tcl] set found 0 @@ -1194,7 +1197,7 @@ proc use {args} { # For the convenience of the "use" source, point to the directory # it is being loaded from set ::usedir [file dirname $source] - automf_load source $source + autosetup_load_module $m source $source autosetup_add_dep $source } else { autosetup-error "use: No such module: $m" @@ -1207,19 +1210,24 @@ proc autosetup_load_auto_modules {} { global autosetup modsource # First load any embedded auto modules foreach mod [array names modsource *.auto] { - automf_load eval $modsource($mod) + autosetup_load_module $mod eval $modsource($mod) } # Now any external auto modules foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] { - automf_load source $file + autosetup_load_module [file tail $file] source $file } } # Load module source in the global scope by executing the given command -proc automf_load {args} { +proc autosetup_load_module {module args} { + global autosetup + set prev $autosetup(module) + set autosetup(module) $module + if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} { autosetup-full-error [error-dump $msg $opts $::autosetup(debug)] } + set autosetup(module) $prev } # Initial settings @@ -1231,6 +1239,7 @@ set autosetup(sysinstall) 0 set autosetup(msg-checking) 0 set autosetup(msg-quiet) 0 set autosetup(inittypes) {} +set autosetup(module) autosetup # Embedded modules are inserted below here set autosetup(installed) 1 @@ -1436,22 +1445,22 @@ proc autosetup_help {what} { puts "This is [autosetup_version], a build environment \"autoconfigurator\"" puts "See the documentation online at http://msteveb.github.com/autosetup/\n" - if {$what eq "local"} { + if {$what in {all local}} { + # Need to load auto.def now if {[file exists $::autosetup(autodef)]} { - # This relies on auto.def having a call to 'options' - # which will display options and quit - source $::autosetup(autodef) - } else { - options-show + # Load auto.def as module "auto.def" + autosetup_load_module auto.def source $::autosetup(autodef) } - } else { - incr ::autosetup(showhelp) - if {[catch {use $what}]} { - user-error "Unknown module: $what" + if {$what eq "all"} { + set what * } else { - options-show + set what auto.def } + } else { + use $what + puts "Options for module $what:" } + options-show $what exit 0 } diff --git a/autosetup/cc-db.tcl b/autosetup/cc-db.tcl index 5dadbafa3..12f1aed2c 100644 --- a/autosetup/cc-db.tcl +++ b/autosetup/cc-db.tcl @@ -8,7 +8,7 @@ use cc -module-options {} +options {} # openbsd needs sys/types.h to detect some system headers cc-include-needs sys/socket.h sys/types.h diff --git a/autosetup/cc-lib.tcl b/autosetup/cc-lib.tcl index 80ee0788a..45a3b0d3c 100644 --- a/autosetup/cc-lib.tcl +++ b/autosetup/cc-lib.tcl @@ -7,8 +7,6 @@ use cc -module-options {} - # @cc-check-lfs # # The equivalent of the 'AC_SYS_LARGEFILE' macro. diff --git a/autosetup/cc-shared.tcl b/autosetup/cc-shared.tcl index 0d6d52218..cbe568018 100644 --- a/autosetup/cc-shared.tcl +++ b/autosetup/cc-shared.tcl @@ -20,7 +20,7 @@ ## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries ## STRIPLIBFLAGS Arguments to strip a dynamic library -module-options {} +options {} # Defaults: gcc on unix define SHOBJ_CFLAGS -fPIC diff --git a/autosetup/cc.tcl b/autosetup/cc.tcl index 585d25986..7bbdb0013 100644 --- a/autosetup/cc.tcl +++ b/autosetup/cc.tcl @@ -29,7 +29,7 @@ use system -module-options {} +options {} # Checks for the existence of the given function by linking # diff --git a/autosetup/pkg-config.tcl b/autosetup/pkg-config.tcl index 0883e4c32..31debcac2 100644 --- a/autosetup/pkg-config.tcl +++ b/autosetup/pkg-config.tcl @@ -15,7 +15,7 @@ use cc -module-options { +options { sysroot:dir => "Override compiler sysroot for pkg-config search path" } diff --git a/autosetup/system.tcl b/autosetup/system.tcl index b98b5c083..15ab017a0 100644 --- a/autosetup/system.tcl +++ b/autosetup/system.tcl @@ -27,7 +27,7 @@ if {[is-defined defaultprefix]} { options-defaults [list prefix [get-define defaultprefix]] } -module-options [subst -noc -nob { +options { host:host-alias => {a complete or partial cpu-vendor-opsys for the system where the application will run (defaults to the same value as --build)} build:build-alias => {a complete or partial cpu-vendor-opsys for the system @@ -52,7 +52,7 @@ module-options [subst -noc -nob { maintainer-mode=0 dependency-tracking=0 silent-rules=0 -}] +} # @check-feature name { script } # diff --git a/autosetup/tmake.tcl b/autosetup/tmake.tcl index a9d721975..3269193aa 100644 --- a/autosetup/tmake.tcl +++ b/autosetup/tmake.tcl @@ -11,7 +11,7 @@ use system -module-options {} +options {} define CONFIGURED -- 2.40.0