diff options
-rw-r--r-- | INSTALL.html | 10 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rwxr-xr-x | scripts/install-bison3.sh | 72 | ||||
-rw-r--r-- | src/parsedate.y | 2 | ||||
-rw-r--r-- | src/turtle_common.c | 1 | ||||
-rw-r--r-- | src/turtle_common.h | 4 | ||||
-rw-r--r-- | src/turtle_lexer.l | 1 | ||||
-rw-r--r-- | src/turtle_parser.y | 15 |
8 files changed, 72 insertions, 39 deletions
diff --git a/INSTALL.html b/INSTALL.html index 0dd812e9..c33ec4f6 100644 --- a/INSTALL.html +++ b/INSTALL.html @@ -131,12 +131,12 @@ version 1.11), autoconf 2.65 (minimum version 2.62) and libtool 2.2.10 GIT sources. autogen.sh enforces the requirements. </p> -<p>Raptor also requires -<a href="http://flex.sourceforge.net/">flex</a> version 2.5.31 or newer -(2.5.4 will not work) and +<p>Raptor also requires specific versions of +<a href="http://flex.sourceforge.net/">flex</a> and <a href="http://www.gnu.org/software/bison/bison.html">GNU Bison</a> -to build lexers and parsers. -These are only required when building from GIT. +to build lexers and parsers. configure will warn or fail if they +are missing or the installed versions are too old. +These are <b>only</b> required when building from GIT. </p> diff --git a/configure.ac b/configure.ac index 95a8bdac..926cf805 100644 --- a/configure.ac +++ b/configure.ac @@ -134,7 +134,8 @@ fi AC_DEFINE_UNQUOTED(FLEX_VERSION_DECIMAL, $FLEX_VERSION_DEC, [Flex version as a decimal]) -BISON_MIN_VERSION=3.0.0 +BISON_MIN_VERSION=3.4.0 +BISON_REC_VERSION=3.7.2 AC_CHECK_PROGS(BISON, bison3 bison) if test "$USE_MAINTAINER_MODE" = yes; then AC_MSG_CHECKING(for GNU bison) @@ -154,8 +155,7 @@ changequote([, ])dnl AC_MSG_RESULT($BISON_VERSION - OK) else AC_MSG_RESULT(version $BISON_VERSION is too old) - AC_MSG_WARN(Please get GNU Bison from http://www.gnu.org/software/bison/) - AC_MSG_WARN(version $BISON_MIN_VERSION or newer) + AC_MSG_WARN(Please get GNU Bison version $BISON_MIN_VERSION or newer (${BISON_REC_VERSION} recommended) from http://www.gnu.org/software/bison/) AC_MSG_FAILURE(GNU Bison too old) fi else diff --git a/scripts/install-bison3.sh b/scripts/install-bison3.sh index 3f2f133a..9eaebb2b 100755 --- a/scripts/install-bison3.sh +++ b/scripts/install-bison3.sh @@ -1,36 +1,64 @@ #!/bin/sh -# Helper script to install bison 3 (primarily for travis CI) +# Helper script to install bison 3 into system via SUDO +# +# This is primarily for travis CI set -x -PACKAGE=bison -MIN_VERSION=3.0.0 -INSTALL_VERSION=3.0.5 -# Bison requires that CC is a C compiler -CC=cc -export CC +# Binary that is installed that should be checked for version +program_name=${BISON:-bison} +# Name of package - will be tarball prefix +package_name=${PACKAGE:-bison} + + +########### Should be generic for any GNU package below here ######## + +package_ucname=$(echo "${package_name}" | tr '[:lower:]' '[:upper:]') +package_min_version=$(awk -F= "/^${package_ucname}_MIN_VERSION/ {print \$2}" configure.ac) +package_rec_version=$(awk -F= "/^${package_ucname}_REC_VERSION/ {print \$2}" configure.ac) + + +# Package specific overrides +case "$package_name" in + bison) + # Bison requires that CC is a C compiler + CC=cc + export CC + ;; + *) + ;; +esac AWK=${AWK:-awk} -BISON=${BISON:-bison} CURL=${CURL:-curl} WGET=${WGET:-wget} - -FILE="$PACKAGE-$INSTALL_VERSION.tar.gz" -URL="http://ftp.gnu.org/gnu/bison/$PACKAGE-$INSTALL_VERSION.tar.gz" +DESTDIR=${DESTDIR:-/usr} ROOT_DIR=${TMPDIR:-/tmp} -BUILD_DIR="$ROOT_DIR/build-$PACKAGE" +BUILD_DIR="$ROOT_DIR/build-${package_name}" -installed_version=`$BISON --version 2>&1 | sed -ne 's/^.*GNU Bison[^0-9]*//p'` -installed_version_dec=`echo $installed_version | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` -min_version_dec=`echo $MIN_VERSION | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'` -if test $installed_version_dec -ge $min_version_dec; then - echo "$PACKAGE $installed_version is new enough" +installed_version=$(${program_name} --version 2>&1 | $AWK "/^${package_name}.*[.0-9]\$/ { print \$NF}") +# shellcheck disable=SC2016 +installed_version_dec=$(echo "$installed_version" | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};') +# shellcheck disable=SC2016 +min_version_dec=$(echo "$package_min_version" | $AWK -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};') + +if test "$installed_version_dec" -ge "$min_version_dec"; then + echo "${package_name} $installed_version is new enough" else - mkdir $BUILD_DIR && cd $BUILD_DIR - $WGET -O $FILE $URL || $CURL -o $FILE $URL - tar -x -z -f $FILE && rm $FILE - cd $PACKAGE-$INSTALL_VERSION && ./configure --prefix=/usr && make && sudo make install - cd / && rm -rf $BUILD_DIR + echo "Building and installing ${package_rec_version} from source into ${DESTDIR}" + mkdir "$BUILD_DIR" && cd "$BUILD_DIR" || exit 1 + package_dir="${package_name}-${package_rec_version}" + tarball_file="${package_dir}.tar.gz" + package_url="http://ftp.gnu.org/gnu/${package_name}/${tarball_file}" + + $WGET -O "$tarball_file" "$package_url" || \ + $CURL -o "$tarball_file" "$package_url" + tar -x -z -f "$tarball_file" && rm "$tarball_file" + cd "${package_dir}" && \ + ./configure "--prefix=${DESTDIR}" && \ + make && \ + sudo make install + cd / && rm -rf "$BUILD_DIR" fi diff --git a/src/parsedate.y b/src/parsedate.y index fc569654..d4c0fde7 100644 --- a/src/parsedate.y +++ b/src/parsedate.y @@ -164,7 +164,7 @@ static int LookupWord (YYSTYPE *lvalp, char *buff); %file-prefix "parsedate" /* Symbol prefix (bison -d : deprecated) */ -%name-prefix "raptor_parsedate_" +%define api.prefix {raptor_parsedate_} /* Write parser header file with macros (bison -d) */ %defines diff --git a/src/turtle_common.c b/src/turtle_common.c index a75f3059..adb68e63 100644 --- a/src/turtle_common.c +++ b/src/turtle_common.c @@ -43,6 +43,7 @@ #include <turtle_parser.h> #define YY_NO_UNISTD_H 1 +#define YYSTYPE TURTLE_PARSER_STYPE #include <turtle_lexer.h> #include <turtle_common.h> diff --git a/src/turtle_common.h b/src/turtle_common.h index e905f934..b869eba3 100644 --- a/src/turtle_common.h +++ b/src/turtle_common.h @@ -36,7 +36,7 @@ RAPTOR_INTERNAL_API raptor_uri* turtle_qname_to_uri(raptor_parser *rdf_parser, u RAPTOR_INTERNAL_API size_t raptor_turtle_expand_qname_escapes(unsigned char *name, size_t len, raptor_simple_message_handler error_handler, void *error_data); /* turtle_lexer.l */ -extern void turtle_token_free(raptor_world* world, int token, YYSTYPE *lval); +extern void turtle_token_free(raptor_world* world, int token, TURTLE_PARSER_STYPE *lval); /* @@ -52,7 +52,7 @@ struct raptor_turtle_parser_s { raptor_namespace_stack namespaces; /* static */ /* for lexer to store result in */ - YYSTYPE lval; + TURTLE_PARSER_STYPE lval; /* STATIC lexer */ yyscan_t scanner; diff --git a/src/turtle_lexer.l b/src/turtle_lexer.l index e3e6b763..8d0c53e8 100644 --- a/src/turtle_lexer.l +++ b/src/turtle_lexer.l @@ -109,6 +109,7 @@ #include <turtle_parser.h> #include <turtle_common.h> +#define YYSTYPE TURTLE_PARSER_STYPE /* Prototypes */ static unsigned char *turtle_copy_token(unsigned char *text, size_t len); diff --git a/src/turtle_parser.y b/src/turtle_parser.y index d2673cc6..7b7087f0 100644 --- a/src/turtle_parser.y +++ b/src/turtle_parser.y @@ -81,7 +81,8 @@ #endif #ifdef RAPTOR_DEBUG -const char * turtle_token_print(raptor_world* world, int token, YYSTYPE *lval); +const char * turtle_token_print(raptor_world* world, int token, + TURTLE_PARSER_STYPE *lval); #endif @@ -112,11 +113,13 @@ static void raptor_turtle_handle_statement(raptor_parser *parser, raptor_stateme %require "3.0" -/* File prefix (bison -b) */ +/* File prefix (-b) */ %file-prefix "turtle_parser" -/* Symbol prefix (bison -d : deprecated) */ -%name-prefix "turtle_parser_" +/* Bison 2.6+ : Symbol prefix */ +%define api.prefix {turtle_parser_} +/* Bison 3.4+ : Generated header file */ +%define api.header.include {<turtle_parser.h>} /* Write parser header file with macros (bison -d) */ %defines @@ -1432,10 +1435,10 @@ turtle_push_parse(raptor_parser *rdf_parser, return 1; do { - YYSTYPE lval; + TURTLE_PARSER_YYSTYPE lval; int token; - memset(&lval, 0, sizeof(YYSTYPE)); + memset(&lval, 0, sizeof(TURTLE_PARSER_YYSTYPE)); token = turtle_lexer_lex(&lval, turtle_parser->scanner); |