From aa27e714d4e8c9aee15d220dd9f207cfd2524bba Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Tue, 29 Dec 2020 22:29:25 +0100 Subject: [PATCH] Make Bison version detection more portable - POSIX sh actually does NOT support `+=`, but Bash does even in compatibility mode - `mawk` does not fully support POSIX EREs (regexes), so work around its lack of brace support Fixes building on Debian, apparently. --- Makefile | 2 +- src/check_bison_ver.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 4b3c232d..f405c874 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ src/asm/parser.c: src/asm/parser.y $QDEFS=; \ add_flag(){ \ if src/check_bison_ver.sh $$1 $$2; then \ - DEFS+=-D$$3; \ + DEFS="$$DEFS -D$$3"; \ fi \ }; \ add_flag 3 5 api.token.raw=true; \ diff --git a/src/check_bison_ver.sh b/src/check_bison_ver.sh index 935724bd..691d15df 100755 --- a/src/check_bison_ver.sh +++ b/src/check_bison_ver.sh @@ -1,7 +1,7 @@ #!/bin/sh -bison -V | awk ' -/^bison.*[0-9]+(\.[0-9]+){1,2}$/ { - match($0, /[0-9]+(\.[0-9]+){1,2}$/); +bison -V | awk -v major="$1" -v minor="$2" ' +/^bison.*[0-9]+(\.[0-9]+)(\.[0-9]+)?$/ { + match($0, /[0-9]+(\.[0-9]+)(\.[0-9]+)?$/); split(substr($0, RSTART), ver, "."); if (ver[1] == major && ver[2] >= minor) { exit 0 } else { exit 1 } -}' major="$1" minor="$2" +}'