From d6dc025fd27bf6d5aa669144c239e6773ff68246 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Wed, 23 Sep 2020 13:52:16 +1000 Subject: build: Update autosetup to 0.7.0 Signed-off-by: Steve Bennett --- autosetup/README.autosetup | 2 +- autosetup/autosetup | 161 +++++++++++++++++++++++------------------ autosetup/autosetup-find-tclsh | 2 +- autosetup/cc-db.tcl | 2 +- autosetup/cc-lib.tcl | 2 - autosetup/cc-shared.tcl | 2 +- autosetup/cc.tcl | 6 +- autosetup/pkg-config.tcl | 44 +++++++++-- autosetup/system.tcl | 4 +- autosetup/tmake.tcl | 2 +- 10 files changed, 138 insertions(+), 89 deletions(-) (limited to 'autosetup') diff --git a/autosetup/README.autosetup b/autosetup/README.autosetup index a6215e8..889026d 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.7.0 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 da3a835..958287e 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.7.0 # 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 @@ -204,10 +204,16 @@ proc main {argv} { autosetup_add_dep $autosetup(autodef) - define CONFIGURE_OPTS "" + # Add $argv to CONFIGURE_OPTS, but ignore duplicates and quote if needed + set configure_opts {} foreach arg $autosetup(argv) { - define-append CONFIGURE_OPTS [quote-if-needed $arg] + set quoted [quote-if-needed $arg] + # O(n^2), but n will be small + if {$quoted ni $configure_opts} { + lappend configure_opts $quoted + } } + define CONFIGURE_OPTS [join $configure_opts] define AUTOREMAKE [file-normalize $autosetup(exe)] define-append AUTOREMAKE [get-define CONFIGURE_OPTS] @@ -216,8 +222,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 @@ -342,8 +348,8 @@ proc opt-str {names varname args} { if {![info exists result]} { # No user-specified value. Has options-defaults been set? foreach opt $names { - if {[dict exists $::autosetup(options-defaults) $opt]} { - set result [dict get $autosetup(options-defaults) $opt] + if {[dict exists $::autosetup(optdefault) $opt]} { + set result [dict get $autosetup(optdefault) $opt] } } } @@ -375,7 +381,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 +397,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 @@ -453,8 +458,8 @@ proc options-add {opts {header ""}} { # String option. lappend autosetup(options) $name - if {$colon eq ":"} { - # Was ":name=default" given? + if {$equal ne "="} { + # Was the option given as "name:value=default"? # If so, set $value to the display name and $defaultvalue to the default # (This is the preferred way to set a default value for a string option) if {[regexp {^([^=]+)=(.*)$} $value -> value defaultvalue]} { @@ -468,9 +473,9 @@ proc options-add {opts {header ""}} { set defaultvalue [dict get $autosetup(options-defaults) $name] dict set autosetup(optdefault) $name $defaultvalue } elseif {![info exists defaultvalue]} { - # For backward compatibility, if ":name" was given, use name as both - # the display text and the default value, but only if the user - # specified the option without the value + # No default value was given by value=default or options-defaults + # so use the value as the default when the plain option with no + # value is given (.e.g. just --opt instead of --opt=value) set defaultvalue $value } @@ -509,13 +514,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 +523,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 +554,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 +577,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] @@ -610,12 +615,16 @@ proc options-show {} { # If 'name=1' is used to make the option enabled by default, the description should reflect # that with text like "Disable support for ...". # -# An argument option (one which takes a parameter) is of the form: +# An argument option (one which takes a parameter) is of one of the following forms: # -## name:[=]value => "Description of this option" +## name:value => "Description of this option" +## name:value=default => "Description of this option with a default value" +## name:=value => "Description of this option with an optional value" # # If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue'). -# If the 'name:=value' form is used, the value is optional and the given value is used as the default +# If the 'name:value=default' form is used, the option has the given default value even if not +# specified by the user. +# If the 'name:=value' form is used, the value is optional and the given value is used # if it is not provided. # # The description may contain '@default@', in which case it will be replaced with the default @@ -629,19 +638,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 +1185,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 +1207,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 +1220,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 +1249,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 +1455,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/autosetup-find-tclsh b/autosetup/autosetup-find-tclsh index dfe70f8..6309fe6 100755 --- a/autosetup/autosetup-find-tclsh +++ b/autosetup/autosetup-find-tclsh @@ -5,7 +5,7 @@ d=`dirname "$0"` { "$d/jimsh0" "$d/autosetup-test-tclsh"; } 2>/dev/null && exit 0 PATH="$PATH:$d"; export PATH -for tclsh in $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6; do +for tclsh in $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6 tclsh8.7; do { $tclsh "$d/autosetup-test-tclsh"; } 2>/dev/null && exit 0 done echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0" diff --git a/autosetup/cc-db.tcl b/autosetup/cc-db.tcl index 5dadbaf..12f1aed 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 80ee078..45a3b0d 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 0d6d522..cbe5680 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 585d259..750ce92 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 # @@ -680,11 +680,11 @@ if {[get-define CC] eq ""} { define CPP [get-env CPP "[get-define CC] -E"] # XXX: Could avoid looking for a C++ compiler until requested -# Note that if CXX isn't found, we just set it to "false". It might not be needed. +# If CXX isn't found, it is set to the empty string. if {[env-is-set CXX]} { define CXX [find-an-executable -required [get-env CXX ""]] } else { - define CXX [find-an-executable [get-define cross]c++ [get-define cross]g++ false] + define CXX [find-an-executable [get-define cross]c++ [get-define cross]g++] } # CXXFLAGS default to CFLAGS if not specified diff --git a/autosetup/pkg-config.tcl b/autosetup/pkg-config.tcl index 0883e4c..d096cab 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" } @@ -73,6 +73,9 @@ proc pkg-config-init {{required 1}} { # XXX: It's possible that these should be set only when invoking pkg-config global env set env(PKG_CONFIG_DIR) "" + # Supposedly setting PKG_CONFIG_LIBDIR means that PKG_CONFIG_PATH is ignored, + # but it doesn't seem to work that way in practice + set env(PKG_CONFIG_PATH) "" # Do we need to try /usr/local as well or instead? set env(PKG_CONFIG_LIBDIR) $sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig set env(PKG_CONFIG_SYSROOT_DIR) $sysroot @@ -108,18 +111,30 @@ proc pkg-config {module args} { return 0 } - if {[catch {exec [get-define PKG_CONFIG] --modversion "$module $args"} version]} { + set pkgconfig [get-define PKG_CONFIG] + + set ret [catch {exec $pkgconfig --modversion "$module $args"} version] + configlog "$pkgconfig --modversion $module $args: $version" + if {$ret} { msg-result "not found" - configlog "pkg-config --modversion $module $args: $version" + return 0 + } + # Sometimes --modversion succeeds but because of dependencies it isn't usable + # This seems to show up with --cflags + set ret [catch {exec $pkgconfig --cflags $module} cflags] + if {$ret} { + msg-result "unusable ($version - see config.log)" + configlog "$pkgconfig --cflags $module" + configlog $cflags return 0 } msg-result $version set prefix [feature-define-name $module PKG_] define HAVE_${prefix} define ${prefix}_VERSION $version - define ${prefix}_LIBS [exec pkg-config --libs-only-l $module] - define ${prefix}_LDFLAGS [exec pkg-config --libs-only-L $module] - define ${prefix}_CFLAGS [exec pkg-config --cflags $module] + define ${prefix}_CFLAGS $cflags + define ${prefix}_LIBS [exec $pkgconfig --libs-only-l $module] + define ${prefix}_LDFLAGS [exec $pkgconfig --libs-only-L $module] return 1 } @@ -133,3 +148,20 @@ proc pkg-config-get {module name} { set prefix [feature-define-name $module PKG_] get-define ${prefix}_${name} "" } + +# @pkg-config-get-var module variable +# +# Return the value of the given variable from the given pkg-config module. +# The module must already have been successfully detected with pkg-config. +# e.g. +# +## if {[pkg-config harfbuzz >= 2.5]} { +## define harfbuzz_libdir [pkg-config-get-var harfbuzz libdir] +## } +# +# Returns the empty string if the variable isn't defined. +proc pkg-config-get-var {module variable} { + set pkgconfig [get-define PKG_CONFIG] + set prefix [feature-define-name $module HAVE_PKG_] + exec $pkgconfig $module --variable $variable +} diff --git a/autosetup/system.tcl b/autosetup/system.tcl index b98b5c0..15ab017 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 a9d7219..3269193 100644 --- a/autosetup/tmake.tcl +++ b/autosetup/tmake.tcl @@ -11,7 +11,7 @@ use system -module-options {} +options {} define CONFIGURED -- cgit v1.1