History

configure: avoid boilerplate: confvars="$confvars ..."

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.

Avi Halachmi (:avih) committed 1 year ago

Commit ab6e7501 parent 21272061 file · +26 −22Browse files

Unified · Split

configure+26−22
@@ -70,6 +70,10 @@ assign_opt() { · 69 unmodified lines
7070 eval ${1#--}=\$2 # no risk of IFS/glob in [OPT]NAME
7171 }
7272
73+confvars_set() {
74+ confvars="$confvars $*"
75+}
76+
7377 for opt do
7478 eval opt=\"$opt\"
7579 case "$opt" in
@@ -123,27 +127,27 @@ for opt do · 47 unmodified lines
123127 ;;
124128 --cpu=*) assign_opt "$opt"
125129 ;;
126− --dwarf=*) confvars="$confvars dwarf=${opt#*=}"
130+ --dwarf=*) confvars_set "dwarf=${opt#*=}"
127131 ;;
128− --enable-cross) confvars="$confvars cross"
132+ --enable-cross) confvars_set cross
129133 ;;
130− --disable-static) confvars="$confvars static=no"
134+ --disable-static) confvars_set static=no
131135 ;;
132− --enable-static) confvars="$confvars static"
136+ --enable-static) confvars_set static
133137 ;;
134− --disable-rpath) confvars="$confvars rpath=no"
138+ --disable-rpath) confvars_set rpath=no
135139 ;;
136− --debug) confvars="$confvars debug"
140+ --debug) confvars_set debug
137141 ;;
138− --with-libgcc) confvars="$confvars libgcc"
142+ --with-libgcc) confvars_set libgcc
139143 ;;
140− --with-selinux) confvars="$confvars selinux"
144+ --with-selinux) confvars_set selinux
141145 ;;
142146 --tcc-switches=*) assign_opt "$opt" tcc_switches
143147 ;;
144148 --config-mingw32*) mingw32=$(echo "$opt=yes" | cut -d '=' -f 2)
145149 ;;
146− --config-*) confvars="$confvars ${opt#--config-}"; suggest="no"
150+ --config-*) confvars_set "${opt#--config-}"; suggest="no"
147151 ;;
148152 --help|-h) show_help="yes"
149153 ;;
@@ -219,7 +223,7 @@ default() # set variable unless already set and not empty · 69 unmodified lines
219223
220224 default_conf() # add to confvars unless already present
221225 {
222− test "${confvars%${1%=*}*}" = "${confvars}" && confvars="$confvars $1"
226+ test "${confvars%${1%=*}*}" = "${confvars}" && confvars_set "$1"
223227 }
224228
225229 if test -z "${source_path#.}" ; then
@@ -326,7 +330,7 @@ esac · 100 unmodified lines
326330
327331 case $targetos in
328332 Darwin)
329− confvars="$confvars OSX dwarf=4"
333+ confvars_set OSX dwarf=4
330334 default_conf "codesign"
331335 DLLSUF=".dylib"
332336 if test -z "$build_cross"; then
@@ -337,7 +341,7 @@ case $targetos in · 4 unmodified lines
337341 # if new_macho was not specified and (known) ver <= 10, use old (=no)
338342 osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z
339343 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
341345 fi
342346 fi
343347 # 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
347351 fi
348352 ;;
349353 DragonFly|OpenBSD|FreeBSD|NetBSD)
350− confvars="$confvars BSD ldl=no"
354+ confvars_set BSD ldl=no
351355 ;;
352356 Android|Termux)
353357 if test "$targetos" = "Termux"; then
@@ -357,8 +361,8 @@ case $targetos in · 3 unmodified lines
357361 default sysroot "/usr"
358362 fi
359363 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
362366 default_conf "static=no"
363367 if test "${cpu}" = "arm"; then
364368 default triplet "arm-linux-androideabi"
@@ -375,7 +379,7 @@ case $targetos in · 10 unmodified lines
375379 ;;
376380 WIN32)
377381 mingw32="yes"
378− confvars="WIN32 $confvars"
382+ confvars="WIN32 $confvars" # WIN32 intentionally first (commit 729918ef)
379383 default prefix "C:/Program Files/tcc"
380384 default tccdir "${prefix}"
381385 default bindir "${tccdir}"
@@ -464,21 +468,21 @@ else · 82 unmodified lines
464468 fi
465469
466470 if test "$bigendian" = "yes" ; then
467− confvars="$confvars BIGENDIAN"
471+ confvars_set BIGENDIAN
468472 fi
469473
470474 if test "$cpu" = "arm"; then
471475 if test "${triplet%eabihf}" != "$triplet" ; then
472− confvars="$confvars arm_eabihf arm_vfp"
476+ confvars_set arm_eabihf arm_vfp
473477 elif test "${triplet%eabi}" != "$triplet" ; then
474− confvars="$confvars arm_eabi arm_vfp"
478+ confvars_set arm_eabi arm_vfp
475479 elif test -z "$build_cross"; then
476480 if test "${_triplet%eabihf}" != "$_triplet" ; then
477− confvars="$confvars arm_eabihf arm_vfp"
481+ confvars_set arm_eabihf arm_vfp
478482 elif test "${_triplet%eabi}" != "$_triplet" ; then
479− confvars="$confvars arm_eabi arm_vfp"
483+ confvars_set arm_eabi arm_vfp
480484 elif grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then
481− confvars="$confvars arm_vfp"
485+ confvars_set arm_vfp
482486 fi
483487 fi
484488 fi

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t