From: Andres Noetzli Date: Wed, 1 Nov 2017 16:42:15 +0000 (-0700) Subject: Add option to build shared Windows dependencies (#1282) X-Git-Tag: cvc5-1.0.0~5518 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=be11fae39055f213586058ec9129d1276f724b0e;p=cvc5.git Add option to build shared Windows dependencies (#1282) This commit adds an option to the contrib/get-win-dependencies script (-s) to build shared library versions of ANTLR and GMP, which enables building the shared versions of the CVC4 libraries needed for language bindings. --- diff --git a/contrib/Makefile.am b/contrib/Makefile.am index ff12eb7e7..f65019882 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -11,8 +11,8 @@ EXTRA_DIST = \ configure-in-place \ depgraph \ get-antlr-3.4 \ + get-win-dependencies \ mac-build \ - win-build \ run-script-smtcomp2014 \ run-script-cascj7-fnt \ run-script-cascj7-fof \ diff --git a/contrib/get-antlr-3.4 b/contrib/get-antlr-3.4 index 6a36681cb..87d6ea450 100755 --- a/contrib/get-antlr-3.4 +++ b/contrib/get-antlr-3.4 @@ -4,6 +4,10 @@ set -e cd "$(dirname "$0")/.." +if [ -z "${BUILD_TYPE}" ]; then + BUILD_TYPE="--disable-shared --enable-static" +fi + 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 @@ -60,18 +64,29 @@ gunzip -f libantlr3c-3.4.tar.gz tar xfv libantlr3c-3.4.tar cd libantlr3c-3.4 +# Use an absolute path for the installation directory to avoid spurious libtool +# warnings about the ANTLR library having moved +PREFIX=$(realpath `pwd`/../..) + +# Make antlr3debughandlers.c empty to avoid unreferenced symbols +rm -rf src/antlr3debughandlers.c && touch src/antlr3debughandlers.c if [ ${MACHINE_TYPE} == 'x86_64' ]; then # 64-bit stuff here - ./configure --enable-64bit --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS + ./configure --enable-64bit --disable-antlrdebug --prefix="${PREFIX}" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE else # 32-bit stuff here - ./configure --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS + ./configure --disable-antlrdebug --prefix="${PREFIX}" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE fi cp Makefile Makefile.orig sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile -make +make CFLAGS="${MAKE_CFLAGS}" CXXFLAGS="${MAKE_CXXFLAGS}" LDFLAGS="${MAKE_LDFLAGS}" make install + +if [[ $WINDOWS_BUILD == "yes" ]]; then + exit 0 +fi + cd ../.. mv lib/libantlr3c.a lib/libantlr3c-static.a @@ -80,15 +95,15 @@ 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 + ./configure --enable-64bit --with-pic --disable-antlrdebug --prefix="${PREFIX}" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE else # 32-bit stuff here - ./configure --with-pic --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS + ./configure --with-pic --disable-antlrdebug --prefix="${PREFIX}" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE fi cp Makefile Makefile.orig sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile -make +make CFLAGS="${MAKE_CFLAGS}" CXXFLAGS="${MAKE_CXXFLAGS}" LDFLAGS="${MAKE_LDFLAGS}" make install cd ../.. mv lib/libantlr3c.la lib/libantlr3c.la.orig diff --git a/contrib/get-win-dependencies b/contrib/get-win-dependencies new file mode 100755 index 000000000..2342a09ff --- /dev/null +++ b/contrib/get-win-dependencies @@ -0,0 +1,116 @@ +#!/bin/bash +# +# win32-build script +# Morgan Deters +# Tue, 15 Jan 2013 11:11:24 -0500 +# + +export WINDOWS_BUILD=yes +export MAKE_CFLAGS= +export MAKE_CXXFLAGS= +export MAKE_LDFLAGS= +export BUILD_TYPE="--disable-shared --enable-static" +while getopts ":s" opt; do + case ${opt} in + s ) + MAKE_CFLAGS="-static-libgcc -static-libstdc++" + MAKE_CXXFLAGS="-static-libgcc -static-libstdc++" + # CVC4 uses some internal symbols of ANTLR, so all symbols need to be + # exported + MAKE_LDFLAGS="-no-undefined -Wl,--export-all-symbols" + BUILD_TYPE="--enable-shared --disable-static" + ;; + esac +done + +if [ -z "$HOST" ]; then + HOST=i686-w64-mingw32 + echo "WARNING:" + echo "WARNING: Using default HOST value: $HOST" + echo "WARNING: You should probably run this script like this:" + echo "WARNING:" + echo "WARNING: HOST=i686-w64-mingw32 win-build" + echo "WARNING:" + echo "WARNING: (replacing the i686-w64-mingw32 with your build host)" + echo "WARNING: to ensure the script builds correctly." + echo "WARNING:" +fi + +GMPVERSION=5.1.0 +BOOSTVERSION=1.55.0 +BOOSTBASE=boost_1_55_0 + +function reporterror { + echo + echo ============================================================================= + echo + echo "There was an error setting up the prerequisites. Look above for details." + echo + exit 1 +} + +function webget { + if which curl &>/dev/null; then + curl -L "$1" >"$2" + elif which wget &>/dev/null; then + wget -c -O "$2" "$1" + else + echo "Can't figure out how to download from web. Please install wget or curl." >&2 + exit 1 + fi +} + +for dir in antlr-3.4 gmp-$GMPVERSION boost-$BOOSTVERSION; do + if [ -e "$dir" ]; then + echo "error: $dir directory exists; please move it out of the way." >&2 + exit 1 + fi +done + +echo ============================================================================= +echo +echo "Setting up ANTLR 3.4..." +echo +MACHINE_TYPE="x86_64" ANTLR_CONFIGURE_ARGS="--host=$HOST" contrib/get-antlr-3.4 | grep -v 'Now configure CVC4 with' | grep -v '\./configure --with-antlr-dir=' +[ ${PIPESTATUS[0]} -eq 0 ] || reporterror +echo +echo ============================================================================= +echo +echo "Setting up GMP $GMPVERSION..." +echo +( set -ex + mkdir gmp-$GMPVERSION + cd gmp-$GMPVERSION + gmpprefix=`pwd` && + mkdir src && + cd src && + webget ftp://ftp.gmplib.org/pub/gmp-$GMPVERSION/gmp-$GMPVERSION.tar.bz2 gmp-$GMPVERSION.tar.bz2 && + tar xfj gmp-$GMPVERSION.tar.bz2 && + cd gmp-$GMPVERSION && + ./configure --host=$HOST --prefix="$gmpprefix" --enable-cxx ${BUILD_TYPE} && + make CFLAGS="${MAKE_CFLAGS}" CXXFLAGS="${MAKE_CXXFLAGS}" LDFLAGS="${MAKE_LDFLAGS}" && + make install +) || exit 1 +echo +echo ============================================================================= +echo +echo "Setting up Boost..." +echo +( mkdir boost-$BOOSTVERSION && + cd boost-$BOOSTVERSION && + webget http://downloads.sourceforge.net/project/boost/boost/$BOOSTVERSION/$BOOSTBASE.tar.gz $BOOSTBASE.tar.gz && + tar xfz $BOOSTBASE.tar.gz && + cd $BOOSTBASE && + ./bootstrap.sh --with-toolset=gcc --prefix=`pwd`/.. --with-libraries=thread && + echo "using gcc : mingw32 : $HOST-gcc ;" >> project-config.jam && + cp tools/build/v2/tools/gcc.jam tools/build/v2/tools/gcc.jam.orig && + sed 's,option = -pthread ; libs = rt ;,,' tools/build/v2/tools/gcc.jam.orig > tools/build/v2/tools/gcc.jam && + ./b2 gcc-mingw32 threadapi=win32 link=static install ) || exit 1 +echo +echo ============================================================================= +echo +echo 'Now just run:' +echo " ./configure --enable-static-binary --disable-shared --host=$HOST LDFLAGS=\"-L`pwd`/gmp-$GMPVERSION/lib -L`pwd`/antlr-3.4/lib -L`pwd`/boost-$BOOSTVERSION/lib\" CPPFLAGS=\"-I`pwd`/gmp-$GMPVERSION/include -I`pwd`/antlr-3.4/include -I`pwd`/boost-$BOOSTVERSION/include\" --with-antlr-dir=\"`pwd`/antlr-3.4\" ANTLR=\"`pwd`/antlr-3.4/bin/antlr3\"" +echo ' make' +echo +echo ============================================================================= diff --git a/contrib/win-build b/contrib/win-build deleted file mode 100755 index 9a1a257a0..000000000 --- a/contrib/win-build +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -# -# win32-build script -# Morgan Deters -# Tue, 15 Jan 2013 11:11:24 -0500 -# - -if [ $# -ne 0 ]; then - echo "usage: `basename $0`" >&2 - echo >&2 - echo "This script attempts to build CVC4 for Win32/64 using mingw-w64." >&2 - exit 1 -fi - -if [ -z "$HOST" ]; then - HOST=i686-w64-mingw32 - echo "WARNING:" - echo "WARNING: Using default HOST value: $HOST" - echo "WARNING: You should probably run this script like this:" - echo "WARNING:" - echo "WARNING: HOST=i686-w64-mingw32 win-build" - echo "WARNING:" - echo "WARNING: (replacing the i686-w64-mingw32 with your build host)" - echo "WARNING: to ensure the script builds correctly." - echo "WARNING:" -fi - -GMPVERSION=5.1.0 -BOOSTVERSION=1.55.0 -BOOSTBASE=boost_1_55_0 - -function reporterror { - echo - echo ============================================================================= - echo - echo "There was an error setting up the prerequisites. Look above for details." - echo - exit 1 -} - -function webget { - if which curl &>/dev/null; then - curl -L "$1" >"$2" - elif which wget &>/dev/null; then - wget -c -O "$2" "$1" - else - echo "Can't figure out how to download from web. Please install wget or curl." >&2 - exit 1 - fi -} - -for dir in antlr-3.4 gmp-$GMPVERSION boost-$BOOSTVERSION; do - if [ -e "$dir" ]; then - echo "error: $dir directory exists; please move it out of the way." >&2 - exit 1 - fi -done - -echo ============================================================================= -echo -echo "Setting up ANTLR 3.4..." -echo -MACHINE_TYPE=x86 ANTLR_CONFIGURE_ARGS=--host=$HOST contrib/get-antlr-3.4 | grep -v 'Now configure CVC4 with' | grep -v '\./configure --with-antlr-dir=' -[ ${PIPESTATUS[0]} -eq 0 ] || reporterror -echo -echo ============================================================================= -echo -echo "Setting up GMP $GMPVERSION..." -echo -( set -ex - mkdir gmp-$GMPVERSION - cd gmp-$GMPVERSION - gmpprefix=`pwd` && - mkdir src && - cd src && - webget ftp://ftp.gmplib.org/pub/gmp-$GMPVERSION/gmp-$GMPVERSION.tar.bz2 gmp-$GMPVERSION.tar.bz2 && - tar xfj gmp-$GMPVERSION.tar.bz2 && - cd gmp-$GMPVERSION && - ./configure --host=$HOST --prefix="$gmpprefix" --enable-cxx && - make && - make install -) || exit 1 -echo -echo ============================================================================= -echo -echo "Setting up Boost..." -echo -( mkdir boost-$BOOSTVERSION && - cd boost-$BOOSTVERSION && - webget http://downloads.sourceforge.net/project/boost/boost/$BOOSTVERSION/$BOOSTBASE.tar.gz $BOOSTBASE.tar.gz && - tar xfz $BOOSTBASE.tar.gz && - cd $BOOSTBASE && - ./bootstrap.sh --with-toolset=gcc --prefix=`pwd`/.. --with-libraries=thread && - echo "using gcc : mingw32 : $HOST-gcc ;" >> project-config.jam && - cp tools/build/v2/tools/gcc.jam tools/build/v2/tools/gcc.jam.orig && - sed 's,option = -pthread ; libs = rt ;,,' tools/build/v2/tools/gcc.jam.orig > tools/build/v2/tools/gcc.jam && - ./b2 gcc-mingw32 threadapi=win32 link=static install ) || exit 1 -echo -echo ============================================================================= -echo -echo 'Now just run:' -echo " ./configure --enable-static-binary --disable-shared --host=$HOST LDFLAGS=\"-L`pwd`/gmp-$GMPVERSION/lib -L`pwd`/antlr-3.4/lib -L`pwd`/boost-$BOOSTVERSION/lib\" CPPFLAGS=\"-I`pwd`/gmp-$GMPVERSION/include -I`pwd`/antlr-3.4/include -I`pwd`/boost-$BOOSTVERSION/include\" --with-antlr-dir=\"`pwd`/antlr-3.4\" ANTLR=\"`pwd`/antlr-3.4/bin/antlr3\"" -echo ' make' -echo -echo =============================================================================