From be11fae39055f213586058ec9129d1276f724b0e Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Wed, 1 Nov 2017 09:42:15 -0700 Subject: [PATCH] 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. --- contrib/Makefile.am | 2 +- contrib/get-antlr-3.4 | 27 ++++++++++++++----- contrib/{win-build => get-win-dependencies} | 29 ++++++++++++++------- 3 files changed, 42 insertions(+), 16 deletions(-) rename contrib/{win-build => get-win-dependencies} (78%) 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/win-build b/contrib/get-win-dependencies similarity index 78% rename from contrib/win-build rename to contrib/get-win-dependencies index 9a1a257a0..2342a09ff 100755 --- a/contrib/win-build +++ b/contrib/get-win-dependencies @@ -5,12 +5,23 @@ # 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 +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 @@ -60,7 +71,7 @@ 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=' +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 ============================================================================= @@ -76,8 +87,8 @@ echo 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 && + ./configure --host=$HOST --prefix="$gmpprefix" --enable-cxx ${BUILD_TYPE} && + make CFLAGS="${MAKE_CFLAGS}" CXXFLAGS="${MAKE_CXXFLAGS}" LDFLAGS="${MAKE_LDFLAGS}" && make install ) || exit 1 echo -- 2.30.2