mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Avoid error with old Bison versions
`api.token.raw` is only defined starting with Bison 3.5 Since it's not essential, define it on the command-line iff the Bison version is sufficient.
This commit is contained in:
17
Makefile
17
Makefile
@@ -114,15 +114,22 @@ rgbgfx: ${rgbgfx_obj}
|
|||||||
|
|
||||||
# Rules to process files
|
# Rules to process files
|
||||||
|
|
||||||
# We want the Bison invocations to pass through our rules, not default ones
|
# We want the Bison invocation to pass through our rules, not default ones
|
||||||
.y.o:
|
.y.o:
|
||||||
|
|
||||||
# bison-generated C files have an accompanying header
|
# Bison-generated C files have an accompanying header
|
||||||
.c.h:
|
src/asm/parser.h: src/asm/parser.c
|
||||||
$Qtouch $@
|
$Qtouch $@
|
||||||
|
|
||||||
.y.c:
|
src/asm/parser.c: src/asm/parser.y
|
||||||
$Q${BISON} -d ${YFLAGS} -o $@ $<
|
$QDEFS=; \
|
||||||
|
add_flag(){ \
|
||||||
|
if src/check_bison_ver.sh $$1 $$2; then \
|
||||||
|
DEFS+=-D$$3; \
|
||||||
|
fi \
|
||||||
|
}; \
|
||||||
|
add_flag 3 5 api.token.raw=true; \
|
||||||
|
${BISON} -d $$DEFS ${YFLAGS} -o $@ $<
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$Q${CC} ${REALCFLAGS} ${PNGCFLAGS} -c -o $@ $<
|
$Q${CC} ${REALCFLAGS} ${PNGCFLAGS} -c -o $@ $<
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ set(common_src
|
|||||||
"version.c"
|
"version.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(BISON REQUIRED)
|
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
|
|
||||||
if(NOT PKG_CONFIG_FOUND)
|
if(NOT PKG_CONFIG_FOUND)
|
||||||
# fallback to find_package
|
# fallback to find_package
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
@@ -22,8 +20,15 @@ else()
|
|||||||
pkg_check_modules(LIBPNG REQUIRED libpng)
|
pkg_check_modules(LIBPNG REQUIRED libpng)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_package(BISON REQUIRED)
|
||||||
|
set(BISON_FLAGS "")
|
||||||
|
# Set sompe optimization flags on versions that support them
|
||||||
|
if(BISON_VERSION VERSION_GREATER_EQUAL "3.5")
|
||||||
|
set(BISON_FLAGS "${BISON_FLAGS} -Dapi.token.raw=true")
|
||||||
|
endif()
|
||||||
BISON_TARGET(PARSER "asm/parser.y"
|
BISON_TARGET(PARSER "asm/parser.y"
|
||||||
"${PROJECT_SOURCE_DIR}/src/asm/parser.c"
|
"${PROJECT_SOURCE_DIR}/src/asm/parser.c"
|
||||||
|
COMPILE_FLAGS "${BISON_FLAGS}"
|
||||||
DEFINES_FILE "${PROJECT_SOURCE_DIR}/src/asm/parser.h"
|
DEFINES_FILE "${PROJECT_SOURCE_DIR}/src/asm/parser.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -166,8 +166,6 @@ static inline void failAssertMsg(enum AssertionType type, char const *msg)
|
|||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%define api.token.raw true
|
|
||||||
|
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
char tzSym[MAXSYMLEN + 1];
|
char tzSym[MAXSYMLEN + 1];
|
||||||
|
|||||||
7
src/check_bison_ver.sh
Executable file
7
src/check_bison_ver.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
bison -V | awk '
|
||||||
|
/^bison.*[0-9]+(\.[0-9]+){1,2}$/ {
|
||||||
|
match($0, /[0-9]+(\.[0-9]+){1,2}$/);
|
||||||
|
split(substr($0, RSTART), ver, ".");
|
||||||
|
if (ver[1] == major && ver[2] >= minor) { exit 0 } else { exit 1 }
|
||||||
|
}' major="$1" minor="$2"
|
||||||
Reference in New Issue
Block a user