Trivial, but less noisy when reading, and nicer for new code. The code still adds the value[s] unconditionaly without checking for duplicates or spaces in values - both are bad, but next commit will.
Unified · Split
| @@ -70,6 +70,10 @@ assign_opt() { · 69 unmodified lines | ||
| 70 | 70 | eval ${1#--}=\$2 # no risk of IFS/glob in [OPT]NAME |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | +confvars_set() { | |
| 74 | + confvars="$confvars $*" | |
| 75 | +} | |
| 76 | + | |
| 73 | 77 | for opt do |
| 74 | 78 | eval opt=\"$opt\" |
| 75 | 79 | case "$opt" in |
| @@ -123,27 +127,27 @@ for opt do · 47 unmodified lines | ||
| 123 | 127 | ;; |
| 124 | 128 | --cpu=*) assign_opt "$opt" |
| 125 | 129 | ;; |
| 126 | − --dwarf=*) confvars="$confvars dwarf=${opt#*=}" | |
| 130 | + --dwarf=*) confvars_set "dwarf=${opt#*=}" | |
| 127 | 131 | ;; |
| 128 | − --enable-cross) confvars="$confvars cross" | |
| 132 | + --enable-cross) confvars_set cross | |
| 129 | 133 | ;; |
| 130 | − --disable-static) confvars="$confvars static=no" | |
| 134 | + --disable-static) confvars_set static=no | |
| 131 | 135 | ;; |
| 132 | − --enable-static) confvars="$confvars static" | |
| 136 | + --enable-static) confvars_set static | |
| 133 | 137 | ;; |
| 134 | − --disable-rpath) confvars="$confvars rpath=no" | |
| 138 | + --disable-rpath) confvars_set rpath=no | |
| 135 | 139 | ;; |
| 136 | − --debug) confvars="$confvars debug" | |
| 140 | + --debug) confvars_set debug | |
| 137 | 141 | ;; |
| 138 | − --with-libgcc) confvars="$confvars libgcc" | |
| 142 | + --with-libgcc) confvars_set libgcc | |
| 139 | 143 | ;; |
| 140 | − --with-selinux) confvars="$confvars selinux" | |
| 144 | + --with-selinux) confvars_set selinux | |
| 141 | 145 | ;; |
| 142 | 146 | --tcc-switches=*) assign_opt "$opt" tcc_switches |
| 143 | 147 | ;; |
| 144 | 148 | --config-mingw32*) mingw32=$(echo "$opt=yes" | cut -d '=' -f 2) |
| 145 | 149 | ;; |
| 146 | − --config-*) confvars="$confvars ${opt#--config-}"; suggest="no" | |
| 150 | + --config-*) confvars_set "${opt#--config-}"; suggest="no" | |
| 147 | 151 | ;; |
| 148 | 152 | --help|-h) show_help="yes" |
| 149 | 153 | ;; |
| @@ -219,7 +223,7 @@ default() # set variable unless already set and not empty · 69 unmodified lines | ||
| 219 | 223 | |
| 220 | 224 | default_conf() # add to confvars unless already present |
| 221 | 225 | { |
| 222 | − test "${confvars%${1%=*}*}" = "${confvars}" && confvars="$confvars $1" | |
| 226 | + test "${confvars%${1%=*}*}" = "${confvars}" && confvars_set "$1" | |
| 223 | 227 | } |
| 224 | 228 | |
| 225 | 229 | if test -z "${source_path#.}" ; then |
| @@ -326,7 +330,7 @@ esac · 100 unmodified lines | ||
| 326 | 330 | |
| 327 | 331 | case $targetos in |
| 328 | 332 | Darwin) |
| 329 | − confvars="$confvars OSX dwarf=4" | |
| 333 | + confvars_set OSX dwarf=4 | |
| 330 | 334 | default_conf "codesign" |
| 331 | 335 | DLLSUF=".dylib" |
| 332 | 336 | if test -z "$build_cross"; then |
| @@ -337,7 +341,7 @@ case $targetos in · 4 unmodified lines | ||
| 337 | 341 | # if new_macho was not specified and (known) ver <= 10, use old (=no) |
| 338 | 342 | osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z |
| 339 | 343 | osxver=${osxver%%.*} # major version (or empty on sw_vers error) |
| 340 | − [ "${osxver:-11}" -ge 11 ] || confvars="$confvars new_macho=no" | |
| 344 | + [ "${osxver:-11}" -ge 11 ] || confvars_set new_macho=no | |
| 341 | 345 | fi |
| 342 | 346 | fi |
| 343 | 347 | # on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely |
| @@ -347,7 +351,7 @@ case $targetos in · 3 unmodified lines | ||
| 347 | 351 | fi |
| 348 | 352 | ;; |
| 349 | 353 | DragonFly|OpenBSD|FreeBSD|NetBSD) |
| 350 | − confvars="$confvars BSD ldl=no" | |
| 354 | + confvars_set BSD ldl=no | |
| 351 | 355 | ;; |
| 352 | 356 | Android|Termux) |
| 353 | 357 | if test "$targetos" = "Termux"; then |
| @@ -357,8 +361,8 @@ case $targetos in · 3 unmodified lines | ||
| 357 | 361 | default sysroot "/usr" |
| 358 | 362 | fi |
| 359 | 363 | default prefix "${sysroot}" |
| 360 | − confvars="$confvars Android new_dtags rpath=no" | |
| 361 | − test "${cpu}" != "i386" && confvars="$confvars pie" | |
| 364 | + confvars_set Android new_dtags rpath=no | |
| 365 | + test "${cpu}" != "i386" && confvars_set pie | |
| 362 | 366 | default_conf "static=no" |
| 363 | 367 | if test "${cpu}" = "arm"; then |
| 364 | 368 | default triplet "arm-linux-androideabi" |
| @@ -375,7 +379,7 @@ case $targetos in · 10 unmodified lines | ||
| 375 | 379 | ;; |
| 376 | 380 | WIN32) |
| 377 | 381 | mingw32="yes" |
| 378 | − confvars="WIN32 $confvars" | |
| 382 | + confvars="WIN32 $confvars" # WIN32 intentionally first (commit 729918ef) | |
| 379 | 383 | default prefix "C:/Program Files/tcc" |
| 380 | 384 | default tccdir "${prefix}" |
| 381 | 385 | default bindir "${tccdir}" |
| @@ -464,21 +468,21 @@ else · 82 unmodified lines | ||
| 464 | 468 | fi |
| 465 | 469 | |
| 466 | 470 | if test "$bigendian" = "yes" ; then |
| 467 | − confvars="$confvars BIGENDIAN" | |
| 471 | + confvars_set BIGENDIAN | |
| 468 | 472 | fi |
| 469 | 473 | |
| 470 | 474 | if test "$cpu" = "arm"; then |
| 471 | 475 | if test "${triplet%eabihf}" != "$triplet" ; then |
| 472 | − confvars="$confvars arm_eabihf arm_vfp" | |
| 476 | + confvars_set arm_eabihf arm_vfp | |
| 473 | 477 | elif test "${triplet%eabi}" != "$triplet" ; then |
| 474 | − confvars="$confvars arm_eabi arm_vfp" | |
| 478 | + confvars_set arm_eabi arm_vfp | |
| 475 | 479 | elif test -z "$build_cross"; then |
| 476 | 480 | if test "${_triplet%eabihf}" != "$_triplet" ; then |
| 477 | − confvars="$confvars arm_eabihf arm_vfp" | |
| 481 | + confvars_set arm_eabihf arm_vfp | |
| 478 | 482 | elif test "${_triplet%eabi}" != "$_triplet" ; then |
| 479 | − confvars="$confvars arm_eabi arm_vfp" | |
| 483 | + confvars_set arm_eabi arm_vfp | |
| 480 | 484 | elif grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then |
| 481 | − confvars="$confvars arm_vfp" | |
| 485 | + confvars_set arm_vfp | |
| 482 | 486 | fi |
| 483 | 487 | fi |
| 484 | 488 | fi |