Update experimental scripts. Support top-level non-terminals in sygus grammars....
[cvc5.git] / contrib / get-antlr-3.4
1 #!/bin/bash
2 #
3 set -e
4
5 cd "$(dirname "$0")/.."
6
7 if ! [ -e src/parser/cvc/Cvc.g ]; then
8 echo "$(basename $0): I expect to be in the contrib/ of a CVC4 source tree," >&2
9 echo "but apparently:" >&2
10 echo >&2
11 echo " $(pwd)" >&2
12 echo >&2
13 echo "is not a CVC4 source tree ?!" >&2
14 exit 1
15 fi
16
17 function webget {
18 if which curl &>/dev/null; then
19 curl "$1" >"$2"
20 elif which wget &>/dev/null; then
21 wget -c -O "$2" "$1"
22 else
23 echo "Can't figure out how to download from web. Please install wget or curl." >&2
24 exit 1
25 fi
26 }
27
28 if [ -z "${MACHINE_TYPE}" ]; then
29 if ! [ -e config/config.guess ]; then
30 echo "$(basename $0): I need the file config/config.guess to tell MACHINE_TYPE" >&2
31 echo "Try running ./autogen.sh, or set the MACHINE_TYPE environment variable." >&2
32 exit 1
33 fi
34
35 # get first nibble from config.guess (x86_64, i686, ...)
36 MACHINE_TYPE=`config/config.guess | sed 's,-.*,,'`
37 fi
38
39 set -x
40 mkdir -p antlr-3.4/share/java
41 mkdir -p antlr-3.4/bin
42 mkdir -p antlr-3.4/src
43 cd antlr-3.4
44 webget http://www.antlr3.org/download/antlr-3.4-complete.jar share/java/antlr-3.4-complete.jar
45 webget http://www.antlr3.org/download/C/libantlr3c-3.4.tar.gz src/libantlr3c-3.4.tar.gz
46 tee bin/antlr3 <<EOF
47 #!/bin/bash
48 export CLASSPATH=`pwd`/share/java/antlr-3.4-complete.jar:\$CLASSPATH
49 exec java org.antlr.Tool "\$@"
50 EOF
51 chmod a+x bin/antlr3
52 cd src
53 gunzip -f libantlr3c-3.4.tar.gz
54 tar xfv libantlr3c-3.4.tar
55 cd libantlr3c-3.4
56
57 if [ ${MACHINE_TYPE} == 'x86_64' ]; then
58 # 64-bit stuff here
59 ./configure --enable-64bit --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS
60 else
61 # 32-bit stuff here
62 ./configure --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS
63 fi
64
65 cp Makefile Makefile.orig
66 sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile
67 make
68 make install
69 cd ../..
70 mv lib/libantlr3c.a lib/libantlr3c-static.a
71
72 cd src/libantlr3c-3.4
73 make clean
74
75 if [ ${MACHINE_TYPE} == 'x86_64' ]; then
76 # 64-bit stuff here
77 ./configure --enable-64bit --with-pic --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS
78 else
79 # 32-bit stuff here
80 ./configure --with-pic --disable-shared --disable-antlrdebug --prefix=`pwd`/../.. $ANTLR_CONFIGURE_ARGS
81 fi
82
83 cp Makefile Makefile.orig
84 sed 's,^\(CFLAGS = .*\),\1 -fexceptions,' Makefile.orig > Makefile
85 make
86 make install
87 cd ../..
88 mv lib/libantlr3c.la lib/libantlr3c.la.orig
89 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
90 set +x
91 cd ..
92
93 # echo
94 # echo Invalidating generated parsers..
95 # touch src/parser/*/*.g
96
97 if [ ${MACHINE_TYPE} == 'x86_64' ]; then
98 # 64-bit stuff here
99 echo ============== WARNING ====================
100 echo The script guessed that this machine is 64 bit.
101 echo If antlr should be built as 32 bit \(i.e. -m32\),
102 echo please rerun the script as
103 echo MACHINE_TYPE=\"x86\" ./get-antlr3.4
104
105 else
106 # 32-bit stuff here
107 echo ============== WARNING ====================
108 echo The script guessed that this machine is 32 bit.
109 echo If antlr should be built as 64 bit \(i.e. -m64\),
110 echo please rerun the script as
111 echo MACHINE_TYPE=\"x86_64\" ./get-antlr3.4
112 fi
113
114 echo
115 echo ===================== Now configure CVC4 with =====================
116 echo ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3