summaryrefslogtreecommitdiff
path: root/contrib/get-antlr-3.4
blob: 87d6ea450e2c10524d124b7461f69728765151b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
#
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
  echo >&2
  echo "  $(pwd)" >&2
  echo >&2
  echo "is not a CVC4 source tree ?!" >&2
  exit 1
fi

function webget {
  if which curl &>/dev/null; then
    curl "$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
}

if [ -z "${MACHINE_TYPE}" ]; then
  if ! [ -e config/config.guess ]; then
    # Attempt to download once
    webget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' config/config.guess
   if [ -e config/config.guess ]; then
     chmod +x config/config.guess
        else
     echo "$(basename $0): I need the file config/config.guess to tell MACHINE_TYPE" >&2
     echo "Try running ./autogen.sh, or set the MACHINE_TYPE environment variable" >&2
     echo "(e.g., \"export MACHINE_TYPE=x86_64\")." >&2
     exit 1
    fi
  fi
  # 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://www.antlr3.org/download/antlr-3.4-complete.jar share/java/antlr-3.4-complete.jar 
webget http://www.antlr3.org/download/C/libantlr3c-3.4.tar.gz src/libantlr3c-3.4.tar.gz
tee bin/antlr3 <<EOF
#!/bin/bash
export CLASSPATH=`pwd`/share/java/antlr-3.4-complete.jar:\$CLASSPATH
exec java org.antlr.Tool "\$@"
EOF
chmod a+x bin/antlr3
cd src
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-antlrdebug --prefix="${PREFIX}" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE
else
  # 32-bit stuff here
  ./configure --disable-antlrdebug --prefix="${PREFIX}" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE
fi

cp Makefile Makefile.orig
sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile
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

cd src/libantlr3c-3.4
make clean

if [ ${MACHINE_TYPE} == 'x86_64' ]; then
  # 64-bit stuff here
  ./configure --enable-64bit --with-pic --disable-antlrdebug --prefix="${PREFIX}" $ANTLR_CONFIGURE_ARGS $BUILD_TYPE
else
  # 32-bit stuff here
  ./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 CFLAGS="${MAKE_CFLAGS}" CXXFLAGS="${MAKE_CXXFLAGS}" LDFLAGS="${MAKE_LDFLAGS}"
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
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback