#!/bin/bash # set -e cd "$(dirname "$0")/.." if ! [ -e src/parser/cvc/Cvc.g ]; then echo "$(basename $0): I expect to be in the contrib/ of a CVC4 source tree," >&2 echo "but apparently:" >&2 echo >&2 echo " $(pwd)" >&2 echo >&2 echo "is not a CVC4 source tree ?!" >&2 exit 1 fi function webget { if which wget &>/dev/null; then wget -c -O "$2" "$1" elif which curl &>/dev/null; then curl "$1" >"$2" else echo "Can't figure out how to download from web. Please install wget or curl." >&2 exit 1 fi } if [ -z "${MACHINE_TYPE}" ]; then # get first nibble from config.guess (x86_64, i686, ...) MACHINE_TYPE=`config/config.guess | sed 's,-.*,,'` fi set -x mkdir -p antlr-3.4/share/java mkdir -p antlr-3.4/bin mkdir -p antlr-3.4/src cd antlr-3.4 webget http://antlr3.org/download/antlr-3.4-complete.jar share/java/antlr-3.4-complete.jar webget http://antlr3.org/download/C/libantlr3c-3.4.tar.gz src/libantlr3c-3.4.tar.gz tee bin/antlr3 < Makefile make make install cd ../.. mv lib/libantlr3c.a lib/libantlr3c-static.a cd src/libantlr3c-3.4 make clean if [ ${MACHINE_TYPE} == 'x86_64' ]; then # 64-bit stuff here ./configure --enable-64bit --with-pic --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS else # 32-bit stuff here ./configure --with-pic --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS fi cp Makefile Makefile.orig sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile make make install cd ../.. mv lib/libantlr3c.la lib/libantlr3c.la.orig awk '/^old_library=/ {print "old_library='\''libantlr3c-static.a'\''"} /^library_names=/ {print "library_names='\''libantlr3c.a'\''"} !/^old_library=/ && !/^library_names=/ {print}' < lib/libantlr3c.la.orig > lib/libantlr3c.la set +x cd .. # echo # echo Invalidating generated parsers.. # touch src/parser/*/*.g if [ ${MACHINE_TYPE} == 'x86_64' ]; then # 64-bit stuff here echo ============== WARNING ==================== echo The script guessed that this machine is 64 bit. echo If antlr should be built as 32 bit \(i.e. -m32\), echo please rerun the script as echo MACHINE_TYPE=\"x86\" ./get-antlr3.4 else # 32-bit stuff here echo ============== WARNING ==================== echo The script guessed that this machine is 32 bit. echo If antlr should be built as 64 bit \(i.e. -m64\), echo please rerun the script as echo MACHINE_TYPE=\"x86_64\" ./get-antlr3.4 fi echo echo ===================== Now configure CVC4 with ===================== echo ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3