| | @@ -1,11 +1,11 @@ |
| 1 | 1 | #!/bin/sh |
| 2 | 2 | # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/ |
| 3 | 3 | # All rights reserved |
| 4 | 4 | # vim:se syntax=tcl: |
| 5 | 5 | # \ |
| 6 | | -dir=`dirname "$0"`; exec `"$dir/find-tclsh" || echo false` "$0" "$@" |
| 6 | +dir=`dirname "$0"`; exec "`$dir/find-tclsh`" "$0" "$@" |
| 7 | 7 | |
| 8 | 8 | set autosetup(version) 0.6.2 |
| 9 | 9 | |
| 10 | 10 | # Can be set to 1 to debug early-init problems |
| 11 | 11 | set autosetup(debug) 0 |
| | @@ -182,11 +182,11 @@ |
| 182 | 182 | |
| 183 | 183 | # @opt-bool option ... |
| 184 | 184 | # |
| 185 | 185 | # Check each of the named, boolean options and return 1 if any of them have |
| 186 | 186 | # been set by the user. |
| 187 | | -# |
| 187 | +# |
| 188 | 188 | proc opt-bool {args} { |
| 189 | 189 | option-check-names {*}$args |
| 190 | 190 | opt_bool ::useropts {*}$args |
| 191 | 191 | } |
| 192 | 192 | |
| | @@ -198,11 +198,11 @@ |
| 198 | 198 | # If only a single value is required, use something like: |
| 199 | 199 | # |
| 200 | 200 | ## lindex [opt-val $names] end |
| 201 | 201 | # |
| 202 | 202 | # If no options were set, $default is returned (exactly, not as a list). |
| 203 | | -# |
| 203 | +# |
| 204 | 204 | proc opt-val {names {default ""}} { |
| 205 | 205 | option-check-names {*}$names |
| 206 | 206 | join [opt_val ::useropts $names $default] |
| 207 | 207 | } |
| 208 | 208 | |
| | @@ -396,11 +396,11 @@ |
| 396 | 396 | # These options are not displayed with --help and can be useful for internal options or as aliases. |
| 397 | 397 | # |
| 398 | 398 | # For example, --disable-lfs is an alias for --disable=largefile: |
| 399 | 399 | # |
| 400 | 400 | ## lfs=1 largefile=1 => "Disable large file support" |
| 401 | | -# |
| 401 | +# |
| 402 | 402 | proc options {optlist} { |
| 403 | 403 | # Allow options as a list or args |
| 404 | 404 | options-add $optlist "Local Options:" |
| 405 | 405 | |
| 406 | 406 | if {$::autosetup(showhelp)} { |
| | @@ -434,11 +434,11 @@ |
| 434 | 434 | return $alias |
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | # @define name ?value=1? |
| 439 | | -# |
| 439 | +# |
| 440 | 440 | # Defines the named variable to the given value. |
| 441 | 441 | # These (name, value) pairs represent the results of the configuration check |
| 442 | 442 | # and are available to be checked, modified and substituted. |
| 443 | 443 | # |
| 444 | 444 | proc define {name {value 1}} { |
| | @@ -564,10 +564,40 @@ |
| 564 | 564 | foreach arg $argv { |
| 565 | 565 | lappend args [quote-if-needed $arg] |
| 566 | 566 | } |
| 567 | 567 | join $args |
| 568 | 568 | } |
| 569 | + |
| 570 | +# @suffix suf list |
| 571 | +# |
| 572 | +# Takes a list and returns a new list with $suf appended |
| 573 | +# to each element |
| 574 | +# |
| 575 | +## suffix .c {a b c} => {a.c b.c c.c} |
| 576 | +# |
| 577 | +proc suffix {suf list} { |
| 578 | + set result {} |
| 579 | + foreach p $list { |
| 580 | + lappend result $p$suf |
| 581 | + } |
| 582 | + return $result |
| 583 | +} |
| 584 | + |
| 585 | +# @prefix pre list |
| 586 | +# |
| 587 | +# Takes a list and returns a new list with $pre prepended |
| 588 | +# to each element |
| 589 | +# |
| 590 | +## prefix jim- {a.c b.c} => {jim-a.c jim-b.c} |
| 591 | +# |
| 592 | +proc prefix {pre list} { |
| 593 | + set result {} |
| 594 | + foreach p $list { |
| 595 | + lappend result $pre$p |
| 596 | + } |
| 597 | + return $result |
| 598 | +} |
| 569 | 599 | |
| 570 | 600 | # @find-executable name |
| 571 | 601 | # |
| 572 | 602 | # Searches the path for an executable with the given name. |
| 573 | 603 | # Note that the name may include some parameters, e.g. "cc -mbig-endian", |
| | @@ -999,21 +1029,24 @@ |
| 999 | 1029 | |
| 1000 | 1030 | # Simple getopt module |
| 1001 | 1031 | |
| 1002 | 1032 | # Parse everything out of the argv list which looks like an option |
| 1003 | 1033 | # Knows about --enable-thing and --disable-thing as alternatives for --thing=0 or --thing=1 |
| 1034 | +# Everything which doesn't look like an option, or is after --, is left unchanged |
| 1004 | 1035 | proc getopt {argvname} { |
| 1005 | 1036 | upvar $argvname argv |
| 1037 | + set nargv {} |
| 1006 | 1038 | |
| 1007 | 1039 | for {set i 0} {$i < [llength $argv]} {incr i} { |
| 1008 | 1040 | set arg [lindex $argv $i] |
| 1009 | 1041 | |
| 1010 | 1042 | #dputs arg=$arg |
| 1011 | 1043 | |
| 1012 | 1044 | if {$arg eq "--"} { |
| 1013 | 1045 | # End of options |
| 1014 | 1046 | incr i |
| 1047 | + lappend nargv {*}[lrange $argv $i end] |
| 1015 | 1048 | break |
| 1016 | 1049 | } |
| 1017 | 1050 | |
| 1018 | 1051 | if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} { |
| 1019 | 1052 | lappend opts($name) $value |
| | @@ -1023,18 +1056,18 @@ |
| 1023 | 1056 | } else { |
| 1024 | 1057 | set value 1 |
| 1025 | 1058 | } |
| 1026 | 1059 | lappend opts($name) $value |
| 1027 | 1060 | } else { |
| 1028 | | - break |
| 1061 | + lappend nargv $arg |
| 1029 | 1062 | } |
| 1030 | 1063 | } |
| 1031 | 1064 | |
| 1032 | | - #puts "getopt: argv=[join $argv] => [join [lrange $argv $i end]]" |
| 1065 | + #puts "getopt: argv=[join $argv] => [join $nargv]" |
| 1033 | 1066 | #parray opts |
| 1034 | 1067 | |
| 1035 | | - set argv [lrange $argv $i end] |
| 1068 | + set argv $nargv |
| 1036 | 1069 | |
| 1037 | 1070 | return [array get opts] |
| 1038 | 1071 | } |
| 1039 | 1072 | |
| 1040 | 1073 | proc opt_val {optarrayname options {default {}}} { |
| | @@ -1264,11 +1297,11 @@ |
| 1264 | 1297 | writefile configure "#!/bin/sh\nWRAPPER=\"\$0\" exec $::autosetup(dir)/autosetup \"\$@\"\n" |
| 1265 | 1298 | } else { |
| 1266 | 1299 | writefile configure \ |
| 1267 | 1300 | {#!/bin/sh |
| 1268 | 1301 | dir="`dirname "$0"`/autosetup" |
| 1269 | | -WRAPPER="$0" exec `"$dir/find-tclsh" || echo false` "$dir/autosetup" "$@" |
| 1302 | +WRAPPER="$0" exec "`$dir/find-tclsh`" "$dir/autosetup" "$@" |
| 1270 | 1303 | } |
| 1271 | 1304 | } |
| 1272 | 1305 | catch {exec chmod 755 configure} |
| 1273 | 1306 | } |
| 1274 | 1307 | if {![file exists auto.def]} { |
| | @@ -1279,11 +1312,11 @@ |
| 1279 | 1312 | |
| 1280 | 1313 | # Add any user options here |
| 1281 | 1314 | options { |
| 1282 | 1315 | } |
| 1283 | 1316 | |
| 1284 | | -make-autoconf-h config.h |
| 1317 | +make-config-header config.h |
| 1285 | 1318 | make-template Makefile.in |
| 1286 | 1319 | } |
| 1287 | 1320 | } |
| 1288 | 1321 | if {![file exists Makefile.in]} { |
| 1289 | 1322 | puts "Note: I don't see Makefile.in. You will probably need to create one." |
| | @@ -1511,11 +1544,11 @@ |
| 1511 | 1544 | string map {\\ /} [env $name {*}$args] |
| 1512 | 1545 | } |
| 1513 | 1546 | # Jim uses system() for exec under mingw, so |
| 1514 | 1547 | # we need to fetch the output ourselves |
| 1515 | 1548 | proc exec-with-stderr {args} { |
| 1516 | | - set tmpfile /tmp/autosetup.[format %05x [rand 10000]].tmp |
| 1549 | + set tmpfile auto[format %04x [rand 10000]].tmp |
| 1517 | 1550 | set rc [catch [list exec {*}$args >$tmpfile 2>&1] result] |
| 1518 | 1551 | set result [readfile $tmpfile] |
| 1519 | 1552 | file delete $tmpfile |
| 1520 | 1553 | return -code $rc $result |
| 1521 | 1554 | } |
| 1522 | 1555 | |