diff options
author | Steve Bennett <steveb@workware.net.au> | 2017-11-26 17:02:57 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2017-11-26 17:43:33 +1000 |
commit | d612ca3874b33ed8205fb951979eaa5f2a33dd81 (patch) | |
tree | 5d012c2af9b43741a3c7ebeab72f08884253897e /autosetup | |
parent | e7b954c4742f9ce3bf36a33a7a9f5a08d581d6cd (diff) | |
download | jimtcl-d612ca3874b33ed8205fb951979eaa5f2a33dd81.zip jimtcl-d612ca3874b33ed8205fb951979eaa5f2a33dd81.tar.gz jimtcl-d612ca3874b33ed8205fb951979eaa5f2a33dd81.tar.bz2 |
Update autosetup to v0.6.7-17-gb5a0e85
Mostly for --{enable,disable}-silent-rules
Use new opt-str where appropriate
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'autosetup')
-rw-r--r--[-rwxr-xr-x] | autosetup/LICENSE | 0 | ||||
-rw-r--r-- | autosetup/README.autosetup | 2 | ||||
-rwxr-xr-x | autosetup/autosetup | 273 | ||||
-rwxr-xr-x | autosetup/autosetup-find-tclsh | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | autosetup/autosetup-test-tclsh | 0 | ||||
-rw-r--r-- | autosetup/cc.tcl | 39 | ||||
-rw-r--r--[-rwxr-xr-x] | autosetup/jimsh0.c | 0 | ||||
-rw-r--r-- | autosetup/pkg-config.tcl | 4 | ||||
-rw-r--r-- | autosetup/system.tcl | 61 | ||||
-rw-r--r-- | autosetup/tmake.auto | 33 |
10 files changed, 310 insertions, 105 deletions
diff --git a/autosetup/LICENSE b/autosetup/LICENSE index 4fe636c..4fe636c 100755..100644 --- a/autosetup/LICENSE +++ b/autosetup/LICENSE diff --git a/autosetup/README.autosetup b/autosetup/README.autosetup index 590842d..2e077b8 100644 --- a/autosetup/README.autosetup +++ b/autosetup/README.autosetup @@ -1,4 +1,4 @@ -README.autosetup created by autosetup v0.6.7 +README.autosetup created by autosetup v0.6.8 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 2fba5c8..ef742d0 100755 --- a/autosetup/autosetup +++ b/autosetup/autosetup @@ -5,7 +5,7 @@ # \ dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@" -set autosetup(version) 0.6.7 +set autosetup(version) 0.6.8 # Can be set to 1 to debug early-init problems set autosetup(debug) [expr {"--debug" in $argv}] @@ -74,8 +74,10 @@ proc main {argv} { set autosetup(options) {} # optset is a dictionary of option values set by the user based on getopt set autosetup(optset) {} - # optdefault is a dictionary of default values for options + # optdefault is a dictionary of default values set autosetup(optdefault) {} + # options-defaults is a dictionary of overrides for default values for options + set autosetup(options-defaults) {} set autosetup(optionhelp) {} set autosetup(showhelp) 0 @@ -94,8 +96,19 @@ proc main {argv} { ref:=text manual:=text reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'" debug => "display debugging output as autosetup runs" - sysinstall: => "install standalone autosetup to the given directory (e.g.: /usr/local)" install:=. => "install autosetup to the current or given directory" + } + if {$autosetup(installed)} { + # hidden options so we can produce a nice error + options-add { + sysinstall:path + } + } else { + options-add { + sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)" + } + } + options-add { force init:=help => "create initial auto.def, etc. Use --init=help for known types" # Undocumented options option-checking=1 @@ -111,8 +124,8 @@ proc main {argv} { } # autosetup --conf=alternate-auto.def - if {[opt-val conf] ne ""} { - set autosetup(autodef) [lindex [opt-val conf] end] + if {[opt-str conf o]} { + set autosetup(autodef) $o } # Debugging output (set this early) @@ -130,10 +143,10 @@ proc main {argv} { # Now any auto-load modules autosetup_load_auto_modules - if {[opt-val help] ne ""} { + if {[opt-str help o]} { incr autosetup(showhelp) use help - autosetup_help [lindex [opt-val help] end] + autosetup_help $o } if {[opt-bool licence license]} { @@ -142,31 +155,31 @@ proc main {argv} { exit 0 } - if {[opt-val {manual ref reference}] ne ""} { + if {[opt-str {manual ref reference} o]} { use help - autosetup_reference [lindex [opt-val {manual ref reference}] end] + autosetup_reference $o } # Allow combining --install and --init set earlyexit 0 - if {[opt-val install] ne ""} { + if {[opt-str install o]} { use install - autosetup_install [lindex [opt-val install] end] + autosetup_install $o incr earlyexit } - if {[opt-val init] ne ""} { + if {[opt-str init o]} { use init - autosetup_init [lindex [opt-val init] end] + autosetup_init $o incr earlyexit } if {$earlyexit} { exit 0 } - if {[opt-val sysinstall] ne ""} { + if {[opt-str sysinstall o]} { use install - autosetup_install [lindex [opt-val sysinstall] end] 1 + autosetup_install $o 1 exit 0 } @@ -255,12 +268,11 @@ proc opt-bool {args} { # Returns a list containing all the values given for the non-boolean options in '$optionlist'. # There will be one entry in the list for each option given by the user, including if the # same option was used multiple times. -# If only a single value is required, use something like: -# -## lindex [opt-val $names] end # # If no options were set, '$default' is returned (exactly, not as a list). # +# Note: For most use cases, 'opt-str' should be preferred. +# proc opt-val {names {default ""}} { option-check-names {*}$names @@ -275,6 +287,79 @@ proc opt-val {names {default ""}} { return $default } +# @opt-str optionlist varname ?default? +# +# Sets '$varname' in the callers scope to the value for one of the given options. +# +# For the list of options given in '$optionlist', if any value is set for any option, +# the option value is taken to be the *last* value of the last option (in the order given). +# +# If no option was given, and a default was specified with 'options-defaults', +# that value is used. +# +# If no 'options-defaults' value was given and '$default' was given, it is used. +# +# If none of the above provided a value, no value is set. +# +# The return value depends on whether '$default' was specified. +# If it was, the option value is returned. +# If it was not, 1 is returns if a value was set, or 0 if not. +# +# Typical usage is as follows: +# +## if {[opt-str {myopt altname} o]} { +## do something with $o +## } +# +# Or: +## define myname [opt-str {myopt altname} o "/usr/local"] +# +proc opt-str {names varname args} { + global autosetup + + option-check-names {*}$names + upvar $varname value + + if {[llength $args]} { + # A default was given, so always return the string value of the option + set default [lindex $args 0] + set retopt 1 + } else { + # No default, so return 0 or 1 to indicate if a value was found + set retopt 0 + } + + foreach opt $names { + if {[dict exists $::autosetup(optset) $opt]} { + set result [lindex [dict get $::autosetup(optset) $opt] end] + } + } + + 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 {[info exists result]} { + set value $result + if {$retopt} { + return $value + } + return 1 + } + + if {$retopt} { + set value $default + return $value + } + + return 0 +} + proc option-check-names {args} { foreach o $args { if {$o ni $::autosetup(options)} { @@ -306,6 +391,7 @@ proc options-add {opts {header ""}} { set header {} continue } + unset -nocomplain defaultvalue equal value #puts "i=$i, opt=$opt" regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value @@ -324,6 +410,12 @@ proc options-add {opts {header ""}} { # Boolean option lappend autosetup(options) $name + # Check for override + if {[dict exists $autosetup(options-defaults) $name]} { + # A default was specified with options-defaults, so use it + set value [dict get $autosetup(options-defaults) $name] + } + if {$value eq "1"} { set opthelp "--disable-$name" } else { @@ -334,7 +426,8 @@ proc options-add {opts {header ""}} { if {$value eq ""} { set value 0 } - dict set autosetup(optdefault) $name $value + set defaultvalue $value + dict set autosetup(optdefault) $name $defaultvalue if {[dict exists $autosetup(getopt) $name]} { # The option was specified by the user. Look at the last value. @@ -356,6 +449,27 @@ proc options-add {opts {header ""}} { # String option. lappend autosetup(options) $name + if {$colon eq ":"} { + # Was ":name=default" given? + # 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]} { + dict set autosetup(optdefault) $name $defaultvalue + } + } + + # Maybe override the default value + if {[dict exists $autosetup(options-defaults) $name]} { + # A default was specified with options-defaults, so use it + set defaultvalue [dict get $autosetup(options-defaults) $name] + dict set autosetup(optdefault) $name $defaultvalue + } elseif {![info exists defaultvalue]} { + # For backward compatiblity, 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 + set defaultvalue $value + } + if {$equal eq "="} { # String option with optional value set opthelp "--$name?=$value?" @@ -363,7 +477,6 @@ proc options-add {opts {header ""}} { # String option with required value set opthelp "--$name=$value" } - dict set autosetup(optdefault) $name $value # Get the values specified by the user if {[dict exists $autosetup(getopt) $name]} { @@ -376,7 +489,7 @@ proc options-add {opts {header ""}} { user-error "Option --$name requires a value" } # If given as a boolean, use the default value - set setvalue $value + set setvalue $defaultvalue } lappend listvalue $setvalue } @@ -389,6 +502,9 @@ proc options-add {opts {header ""}} { # Now create the help for this option if appropriate if {[lindex $opts $i+1] eq "=>"} { set desc [lindex $opts $i+2] + if {[info exists defaultvalue]} { + set desc [string map [list @default@ $defaultvalue] $desc] + } #string match \n* $desc if {$header ne ""} { lappend autosetup(optionhelp) $header "" @@ -479,7 +595,7 @@ proc options-show {} { # @options optionspec # # Specifies configuration-time options which may be selected by the user -# and checked with 'opt-val' and 'opt-bool'. '$optionspec' contains a series +# and checked with 'opt-str' and 'opt-bool'. '$optionspec' contains a series # of options specifications separated by newlines, as follows: # # A boolean option is of the form: @@ -498,6 +614,9 @@ proc options-show {} { # If the 'name:=value' form is used, the value is optional and the given value is used as the default # if it is not provided. # +# The description may contain '@default@', in which case it will be replaced with the default +# value for the option (taking into account defaults specified with 'options-defaults'. +# # Undocumented options are also supported by omitting the '=> description'. # These options are not displayed with '--help' and can be useful for internal options or as aliases. # @@ -524,6 +643,17 @@ proc options {optlist} { } } +# @options-defaults dictionary +# +# Specifies a dictionary of options and a new default value for each of those options. +# Use before any 'use' statements in 'auto.def' to change the defaults for +# subsequently included modules. +proc options-defaults {dict} { + foreach {n v} $dict { + dict set ::autosetup(options-defaults) $n $v + } +} + proc config_guess {} { if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} { if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} { @@ -575,9 +705,15 @@ proc undefine {name} { # proc define-append {name args} { if {[get-define $name ""] ne ""} { - # Make a token attempt to avoid duplicates + # Avoid duplicates foreach arg $args { - if {[string first $arg $::define($name)] == -1} { + set found 0 + foreach str [split $::define($name) " "] { + if {$str eq $arg} { + incr found + } + } + if {!$found} { append ::define($name) " " $arg } } @@ -690,29 +826,56 @@ proc quote-argv {argv} { join $args } -# @find-executable name +# @list-non-empty list +# +# Returns a copy of the given list with empty elements removed +proc list-non-empty {list} { + set result {} + foreach p $list { + if {$p ne ""} { + lappend result $p + } + } + return $result +} + +# @find-executable-path name # # Searches the path for an executable with the given name. # Note that the name may include some parameters, e.g. 'cc -mbig-endian', # in which case the parameters are ignored. +# The full path to the executable if found, or "" if not found. # Returns 1 if found, or 0 if not. # -proc find-executable {name} { +proc find-executable-path {name} { # Ignore any parameters set name [lindex $name 0] - if {$name eq ""} { - # The empty string is never a valid executable - return 0 - } - foreach p [split-path] { - dputs "Looking for $name in $p" - set exec [file join $p $name] - if {[file-isexec $exec]} { - dputs "Found $name -> $exec" - return 1 + # The empty string is never a valid executable + if {$name ne ""} { + foreach p [split-path] { + dputs "Looking for $name in $p" + set exec [file join $p $name] + if {[file-isexec $exec]} { + dputs "Found $name -> $exec" + return $exec + } } } - return 0 + return {} +} + +# @find-executable name +# +# Searches the path for an executable with the given name. +# Note that the name may include some parameters, e.g. 'cc -mbig-endian', +# in which case the parameters are ignored. +# Returns 1 if found, or 0 if not. +# +proc find-executable {name} { + if {[find-executable-path $name] eq {}} { + return 0 + } + return 1 } # @find-an-executable ?-required? name ... @@ -1191,8 +1354,8 @@ set modsource(getopt.tcl) { # Parse everything out of the argv list which looks like an option # Everything which doesn't look like an option, or is after --, is left unchanged -# Understands --enable-xxx and --with-xxx as synonyms for --xxx to enable the boolean option xxx. -# Understands --disable-xxx and --without-xxx to disable the boolean option xxx. +# Understands --enable-xxx as a synonym for --xxx to enable the boolean option xxx. +# Understands --disable-xxx to disable the boolean option xxx. # # The returned value is a dictionary keyed by option name # Each value is a list of {type value} ... where type is "bool" or "str". @@ -1218,8 +1381,8 @@ proc getopt {argvname} { if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} { # --name=value dict lappend opts $name [list str $value] - } elseif {[regexp {^--(enable-|disable-|with-|without-)?([^=]*)$} $arg -> prefix name]} { - if {$prefix in {enable- with- ""}} { + } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} { + if {$prefix in {enable- ""}} { set value 1 } else { set value 0 @@ -1527,11 +1690,16 @@ set modsource(install.tcl) { # shared=1 means that we are trying to do a sysinstall. This is only possible from the development source. proc autosetup_install {dir {shared 0}} { - if {$shared && $::autosetup(installed)} { - user-error "Can only --sysinstall from development sources" + global autosetup + if {$shared} { + if {$autosetup(installed) || $autosetup(sysinstall)} { + user-error "Can only --sysinstall from development sources" + } + } elseif {$autosetup(installed) && !$autosetup(sysinstall)} { + user-error "Can't --install from project install" } - if {$::autosetup(sysinstall)} { + if {$autosetup(sysinstall)} { # This is the sysinstall version, so install just uses references cd $dir @@ -1565,7 +1733,7 @@ proc autosetup_install {dir {shared 0}} { set publicmodules {} # First the main script, but only up until "CUT HERE" - set in [open $::autosetup(dir)/autosetup] + set in [open $autosetup(dir)/autosetup] while {[gets $in buf] >= 0} { if {$buf ne "##-- CUT HERE --##"} { puts $f $buf @@ -1577,7 +1745,7 @@ proc autosetup_install {dir {shared 0}} { # All modules are inserted if $shared is set puts $f "set autosetup(installed) 1" puts $f "set autosetup(sysinstall) $shared" - foreach file [lsort [glob $::autosetup(libdir)/*.{tcl,auto}]] { + foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] { set modname [file tail $file] set ext [file ext $modname] set buf [readfile $file] @@ -1594,8 +1762,8 @@ proc autosetup_install {dir {shared 0}} { puts $f "\}\n" } if {$shared} { - foreach {srcname destname} [list $::autosetup(libdir)/README.autosetup-lib README.autosetup \ - $::autosetup(srcdir)/LICENSE LICENSE] { + foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \ + $autosetup(srcdir)/LICENSE LICENSE] { dputs "install: importing $srcname as $destname" puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n" } @@ -1603,7 +1771,7 @@ proc autosetup_install {dir {shared 0}} { } close $in close $f - exec chmod 755 $target + catch {exec chmod 755 $target} set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh} set removefiles {} @@ -1630,8 +1798,7 @@ proc autosetup_install {dir {shared 0}} { lassign $fileinfo source set dest $source } - autosetup_install_file $::autosetup(dir)/$source $targetdir/$dest - exec chmod 755 $targetdir/$dest + autosetup_install_file $autosetup(dir)/$source $targetdir/$dest } # Remove obsolete files @@ -1701,6 +1868,10 @@ proc autosetup_install_file {source target} { error "Missing installation file '$source'" } writefile $target [readfile $source]\n + # If possible, copy the file mode + file stat $source stat + set mode [format %o [expr {$stat(mode) & 0x1ff}]] + catch {exec chmod $mode $target} } proc autosetup_install_readme {target sysinstall} { diff --git a/autosetup/autosetup-find-tclsh b/autosetup/autosetup-find-tclsh index 12d76af..dfe70f8 100755 --- a/autosetup/autosetup-find-tclsh +++ b/autosetup/autosetup-find-tclsh @@ -1,10 +1,11 @@ #!/bin/sh # Looks for a suitable tclsh or jimsh in the PATH # If not found, builds a bootstrap jimsh from source +# Prefer $autosetup_tclsh if is set in the environment d=`dirname "$0"` { "$d/jimsh0" "$d/autosetup-test-tclsh"; } 2>/dev/null && exit 0 PATH="$PATH:$d"; export PATH -for tclsh in jimsh tclsh tclsh8.5 tclsh8.6; do +for tclsh in $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6; 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/autosetup-test-tclsh b/autosetup/autosetup-test-tclsh index 75126d2..75126d2 100755..100644 --- a/autosetup/autosetup-test-tclsh +++ b/autosetup/autosetup-test-tclsh diff --git a/autosetup/cc.tcl b/autosetup/cc.tcl index 5f066b5..50a2d44 100644 --- a/autosetup/cc.tcl +++ b/autosetup/cc.tcl @@ -30,11 +30,6 @@ use system module-options {} -# Note that the return code is not meaningful -proc cc-check-something {name code} { - uplevel 1 $code -} - # Checks for the existence of the given function by linking # proc cctest_function {function} { @@ -155,7 +150,7 @@ proc cc-check-types {args} { # @cc-check-defines define ... # -# Checks that the given preprocessor symbol is defined. +# Checks that the given preprocessor symbols are defined. proc cc-check-defines {args} { cc-check-some-feature $args { cctest_define $each @@ -242,9 +237,8 @@ proc cc-check-function-in-lib {function libs {otherlibs {}}} { } } } - if {$found} { - define [feature-define-name $function] - } else { + define-feature $function $found + if {!$found} { msg-result "no" } return $found @@ -309,6 +303,29 @@ proc cc-check-progs {args} { expr {!$failed} } +# @cc-path-progs prog ... +# +# Like cc-check-progs, but sets the define to the full path rather +# than just the program name. +# +proc cc-path-progs {args} { + set failed 0 + foreach prog $args { + set PROG [string toupper $prog] + msg-checking "Checking for $prog..." + set path [find-executable-path $prog] + if {$path eq ""} { + msg-result no + define $PROG false + incr failed + } else { + msg-result $path + define $PROG $path + } + } + expr {!$failed} +} + # Adds the given settings to $::autosetup(ccsettings) and # returns the old settings. # @@ -328,14 +345,14 @@ proc cc-add-settings {settings} { switch -exact -- $name { -cflags - -includes { # These are given as lists - lappend new($name) {*}$value + lappend new($name) {*}[list-non-empty $value] } -declare { lappend new($name) $value } -libs { # Note that new libraries are added before previous libraries - set new($name) [list {*}$value {*}$new($name)] + set new($name) [list {*}[list-non-empty $value] {*}$new($name)] } -link - -lang - -nooutput { set new($name) $value diff --git a/autosetup/jimsh0.c b/autosetup/jimsh0.c index fc2133f..fc2133f 100755..100644 --- a/autosetup/jimsh0.c +++ b/autosetup/jimsh0.c diff --git a/autosetup/pkg-config.tcl b/autosetup/pkg-config.tcl index 6ef78fe..0883e4c 100644 --- a/autosetup/pkg-config.tcl +++ b/autosetup/pkg-config.tcl @@ -49,8 +49,8 @@ proc pkg-config-init {{required 1}} { set found 1 - if {[opt-val sysroot] ne ""} { - define SYSROOT [file-normalize [lindex [opt-val sysroot] end]] + if {[opt-str sysroot o]} { + define SYSROOT [file-normalize $o] msg-result "Using specified sysroot [get-define SYSROOT]" } elseif {[get-define build] ne [get-define host]} { if {[catch {exec-with-stderr [get-define CC] -print-sysroot} result errinfo] == 0} { diff --git a/autosetup/system.tcl b/autosetup/system.tcl index 1414cb3..56054b4 100644 --- a/autosetup/system.tcl +++ b/autosetup/system.tcl @@ -22,7 +22,10 @@ # If '--prefix' is not supplied, it defaults to '/usr/local' unless 'defaultprefix' is defined *before* # including the 'system' module. -set defaultprefix [get-define defaultprefix /usr/local] +if {[is-defined defaultprefix]} { + user-notice "Note: defaultprefix is deprecated. Use options-defaults to set default options" + options-defaults [list prefix [get-define defaultprefix]] +} module-options [subst -noc -nob { host:host-alias => {a complete or partial cpu-vendor-opsys for the system where @@ -30,7 +33,7 @@ module-options [subst -noc -nob { build:build-alias => {a complete or partial cpu-vendor-opsys for the system where the application will be built (defaults to the result of running config.guess)} - prefix:dir => {the target directory for the build (defaults to '$defaultprefix')} + prefix:dir=/usr/local => {the target directory for the build (default: '@default@')} # These (hidden) options are supported for autoconf/automake compatibility exec-prefix: @@ -47,6 +50,7 @@ module-options [subst -noc -nob { localstatedir: maintainer-mode=0 dependency-tracking=0 + silent-rules=0 }] # @check-feature name { script } @@ -130,7 +134,8 @@ proc write-if-changed {file buf {script {}}} { # @make-template template ?outfile? # -# Reads the input file '<srcdir>/$template' and writes the output file '$outfile'. +# Reads the input file '<srcdir>/$template' and writes the output file '$outfile' +# (unless unchanged). # If '$outfile' is blank/omitted, '$template' should end with '.in' which # is removed to create the output file name. # @@ -222,13 +227,13 @@ proc make-template {template {out {}}} { } lappend result $line } - writefile $out [string map $mapping [join $result \n]]\n - - msg-result "Created [relative-path $out] from [relative-path $template]" + write-if-changed $out [string map $mapping [join $result \n]] { + msg-result "Created [relative-path $out] from [relative-path $template]" + } } # build/host tuples and cross-compilation prefix -set build [lindex [opt-val build] end] +opt-str build build "" define build_alias $build if {$build eq ""} { define build [config_guess] @@ -236,7 +241,7 @@ if {$build eq ""} { define build [config_sub $build] } -set host [lindex [opt-val host] end] +opt-str host host "" define host_alias $host if {$host eq ""} { define host [get-define build] @@ -247,41 +252,63 @@ if {$host eq ""} { } define cross [get-env CROSS $cross] -set prefix [lindex [opt-val prefix $defaultprefix] end] +# build/host _cpu, _vendor and _os +foreach type {build host} { + set v [get-define $type] + if {![regexp {^([^-]+)-([^-]+)-(.*)$} $v -> cpu vendor os]} { + user-error "Invalid canonical $type: $v" + } + define ${type}_cpu $cpu + define ${type}_vendor $vendor + define ${type}_os $os +} + +opt-str prefix prefix /usr/local # These are for compatibility with autoconf define target [get-define host] define prefix $prefix define builddir $autosetup(builddir) define srcdir $autosetup(srcdir) -# Allow this to come from the environment -define top_srcdir [get-env top_srcdir [get-define srcdir]] +define top_srcdir $autosetup(srcdir) +define abs_top_srcdir [file-normalize $autosetup(srcdir)] +define abs_top_builddir [file-normalize $autosetup(builddir)] # autoconf supports all of these -set exec_prefix [lindex [opt-val exec-prefix $prefix] end] -define exec_prefix $exec_prefix +define exec_prefix [opt-str exec-prefix exec_prefix $prefix] foreach {name defpath} { bindir /bin sbindir /sbin libexecdir /libexec libdir /lib } { - define $name [lindex [opt-val $name $exec_prefix$defpath] end] + define $name [opt-str $name o $exec_prefix$defpath] } foreach {name defpath} { datadir /share - sysconfdir /etc sharedstatedir /com - localstatedir /var infodir /share/info mandir /share/man includedir /include } { - define $name [lindex [opt-val $name $prefix$defpath] end] + define $name [opt-str $name o $prefix$defpath] +} +if {$prefix ne {/usr}} { + opt-str sysconfdir sysconfdir $prefix/etc +} else { + opt-str sysconfdir sysconfdir /etc } +define sysconfdir $sysconfdir + +define localstatedir [opt-str localstatedir o /var] define SHELL [get-env SHELL [find-an-executable sh bash ksh]] +# These could be used to generate Makefiles following some automake conventions +define AM_SILENT_RULES [opt-bool silent-rules] +define AM_MAINTAINER_MODE [opt-bool maintainer-mode] +define AM_DEPENDENCY_TRACKING [opt-bool dependency-tracking] + # Windows vs. non-Windows switch -glob -- [get-define host] { *-*-ming* - *-*-cygwin - *-*-msys { diff --git a/autosetup/tmake.auto b/autosetup/tmake.auto index 75813c3..64a5712 100644 --- a/autosetup/tmake.auto +++ b/autosetup/tmake.auto @@ -23,41 +23,30 @@ cc-check-tools ar ranlib set objdir [get-env BUILDDIR objdir] make-config-header $objdir/include/autoconf.h -make-tmake-settings $objdir/settings.conf {[A-Z]*} +make-tmake-settings $objdir/settings.conf {[A-Z]*} *dir lib_* } autosetup_check_create project.spec \ {# Initial project.spec created by 'autosetup --init=tmake' +tmake-require-version 0.7.3 + # vim:set syntax=tcl: define? DESTDIR _install # XXX If configure creates additional/different files than include/autoconf.h # that should be reflected here +Autosetup include/autoconf.h -# We use [set AUTOREMAKE] here to avoid rebuilding settings.conf -# if the AUTOREMAKE command changes -Depends {settings.conf include/autoconf.h} auto.def -msg {note Configuring...} -do { - run [set AUTOREMAKE] >$build/config.out -} -onerror {puts [readfile $build/config.out]} -fatal -Clean config.out -DistClean --source config.log -DistClean settings.conf include/autoconf.h - -# If not configured, configure with default options -# Note that it is expected that configure will normally be run -# separately. This is just a convenience for a host build -define? AUTOREMAKE configure TOPBUILDDIR=$TOPBUILDDIR --conf=auto.def - -Load settings.conf - -# e.g. for up autoconf.h +# e.g. for autoconf.h IncludePaths include -ifconfig CONFIGURED - -# Hmmm, but should we turn off AutoSubDirs? -#AutoSubDirs off +ifconfig !CONFIGURED { + # Not configured, so don't process subdirs + AutoSubDirs off + # And don't process this file any further + ifconfig false +} } if {![file exists build.spec]} { |