get-authors: Exclude common source code patterns. (#2900)
[cvc5.git] / contrib / get-win-dependencies
1 #!/bin/bash
2 #
3 # win32-build script
4 # Morgan Deters <mdeters@cs.nyu.edu>
5 # Tue, 15 Jan 2013 11:11:24 -0500
6 #
7
8 export WINDOWS_BUILD=yes
9 export MAKE_CFLAGS=
10 export MAKE_CXXFLAGS=
11 export MAKE_LDFLAGS=
12 export BUILD_TYPE="--disable-shared --enable-static"
13 while getopts ":s" opt; do
14 case ${opt} in
15 s )
16 MAKE_CFLAGS="-static-libgcc -static-libstdc++"
17 MAKE_CXXFLAGS="-static-libgcc -static-libstdc++"
18 # CVC4 uses some internal symbols of ANTLR, so all symbols need to be
19 # exported
20 MAKE_LDFLAGS="-no-undefined -Wl,--export-all-symbols"
21 BUILD_TYPE="--enable-shared --disable-static"
22 ;;
23 esac
24 done
25
26 if [ -z "$HOST" ]; then
27 HOST=x86_64-w64-mingw32
28 echo "WARNING:"
29 echo "WARNING: Using default HOST value: $HOST"
30 echo "WARNING: You should probably run this script like this:"
31 echo "WARNING:"
32 echo "WARNING: HOST=i686-w64-mingw32 win-build"
33 echo "WARNING:"
34 echo "WARNING: (replacing the i686-w64-mingw32 with your build host)"
35 echo "WARNING: to ensure the script builds correctly."
36 echo "WARNING:"
37 fi
38
39 GMPVERSION=6.1.2
40 BOOSTVERSION=1.55.0
41 BOOSTBASE=boost_1_55_0
42
43 function reporterror {
44 echo
45 echo =============================================================================
46 echo
47 echo "There was an error setting up the prerequisites. Look above for details."
48 echo
49 exit 1
50 }
51
52 function webget {
53 if which curl &>/dev/null; then
54 curl -L "$1" >"$2"
55 elif which wget &>/dev/null; then
56 wget -c -O "$2" "$1"
57 else
58 echo "Can't figure out how to download from web. Please install wget or curl." >&2
59 exit 1
60 fi
61 }
62
63 for dir in antlr-3.4 gmp-$GMPVERSION boost-$BOOSTVERSION; do
64 if [ -e "$dir" ]; then
65 echo "error: $dir directory exists; please move it out of the way." >&2
66 exit 1
67 fi
68 done
69
70 echo =============================================================================
71 echo
72 echo "Setting up ANTLR 3.4..."
73 echo
74 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='
75 [ ${PIPESTATUS[0]} -eq 0 ] || reporterror
76 echo
77
78 # Setup GMP
79 HOST="$HOST" \
80 BUILD_TYPE="$BUILD_TYPE" \
81 MAKE_CFLAGS="$MAKE_CFLAGS" \
82 MAKE_CXXFLAGS="$MAKE_CXXFLAGS" \
83 MAKE_LDFLAGS="$MAKE_LDFLAGS" \
84 GMPVERSION="$GMPVERSION" \
85 contrib/get-gmp || reporterror
86
87 echo
88 echo =============================================================================
89 echo
90 echo "Setting up Boost..."
91 echo
92 ( mkdir boost-$BOOSTVERSION &&
93 cd boost-$BOOSTVERSION &&
94 webget https://sourceforge.net/projects/boost/files/boost/$BOOSTVERSION/$BOOSTBASE.tar.gz/download $BOOSTBASE.tar.gz &&
95 tar xfz $BOOSTBASE.tar.gz &&
96 cd $BOOSTBASE &&
97 ./bootstrap.sh --with-toolset=gcc --prefix=`pwd`/.. --with-libraries=thread &&
98 echo "using gcc : mingw32 : $HOST-gcc ;" >> project-config.jam &&
99 cp tools/build/v2/tools/gcc.jam tools/build/v2/tools/gcc.jam.orig &&
100 sed 's,option = -pthread ; libs = rt ;,,' tools/build/v2/tools/gcc.jam.orig > tools/build/v2/tools/gcc.jam &&
101 ./b2 gcc-mingw32 threadapi=win32 link=static install ) || exit 1
102 echo
103 echo =============================================================================
104 echo
105 echo 'Now just run:'
106 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\""
107 echo ' make'
108 echo
109 echo =============================================================================