Commit f454e879 authored by Mans Rullgard's avatar Mans Rullgard

configure: rewrite print_config() function using awk

This is much faster with slow shells and noticeably faster even
with bash on a fast Linux system.
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent 02e63642
......@@ -566,31 +566,29 @@ check_deps(){
done
}
print_config_h(){
enabled $1 && v=1 || v=0
echo "#define $2 $v"
}
print_config_mak(){
enabled $1 && v= || v=!
echo "$v$2=yes"
}
print_config_asm(){
enabled $1 && v=1 || v=0
echo "%define $2 $v"
}
print_config(){
pfx=$1
files=$2
shift 2
for cfg; do
ucname="$(toupper $cfg)"
for f in $files; do
"print_config_${f##*.}" $cfg ${pfx}${ucname} >>$f
done
done
map 'eval echo "$v \${$v:-no}"' "$@" |
awk "BEGIN { split(\"$files\", files) }
{
c = \"$pfx\" toupper(\$1);
v = \$2;
sub(/yes/, 1, v);
sub(/no/, 0, v);
for (f in files) {
file = files[f];
if (file ~ /\\.h\$/) {
printf(\"#define %s %d\\n\", c, v) >>file;
} else if (file ~ /\\.asm\$/) {
printf(\"%%define %s %d\\n\", c, v) >>file;
} else if (file ~ /\\.mak\$/) {
n = +v ? \"\" : \"!\";
printf(\"%s%s=yes\\n\", n, c) >>file;
}
}
}"
}
print_enabled(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment