-
Notifications
You must be signed in to change notification settings - Fork 32
/
configure.ac
219 lines (175 loc) · 6.16 KB
/
configure.ac
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Owned and copyright BitBlaze, 2007. All rights reserved.
# Do not copy, disclose, or distribute without explicit written
# permission.
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(Bap, 0.8, [email protected])
AC_CONFIG_SRCDIR([libasmir/src/asm_program.c])
AC_CONFIG_HEADER([libasmir/config.h])
AM_INIT_AUTOMAKE
m4_include([./m4/ac_ocaml.m4])
m4_include([./m4/ac_prog_latex.m4])
m4_include([./m4/ax_compare_version.m4])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_OCAML([3.12.0])
AC_PROG_CAMLP4
AC_PROG_OCAMLFIND
AC_PROG_CAMLIDL
#AC_PROG_LIBTOOL
# Check for Z3
AC_ARG_WITH([z3],
[AS_HELP_STRING([--with-z3],
[location of Z3 library])],
[with_z3=$withval],
[with_z3=no])
# Save pre-z3 ldflags
OLDLDFLAGS=$LDFLAGS
AS_IF([test "x$with_z3" != "xno"],
[
LDFLAGS="$OLDLDFLAGS -L$with_z3/lib"
AC_CHECK_LIB([z3], [Z3_mk_bvadd],
[
z3_dir=$with_z3
with_z3=yes
AC_DEFINE([HAVE_Z3_BINDINGS], [1], [Define to use Z3 bindings])
],
[AC_MSG_FAILURE([z3 library not found])],
[-lgmp -lgomp]
)])
# Restore
LDFLAGS=$OLDLDFLAGS
rm -f solvers/makefile.inc
if `test "x$with_z3" = "xyes"`; then
cat >>solvers/makefile.inc <<"EOF"
SOLVER_PPFLAGS=-D WITH_Z3_BINDINGS
SOLVER_CLIBS = z3stubs z3
EOF
echo "SOLVER_SOURCES = $z3_dir/ocaml/z3.ml" >>solvers/makefile.inc
echo "SOLVER_LIBDIRS = $z3_dir/lib" >>solvers/makefile.inc
echo "SOLVER_LDFLAGS = -fopenmp -Wl,-rpath=$z3_dir/lib" >> solvers/makefile.inc
else
touch solvers/makefile.inc
fi
# Check for PIN
PIN_ROOT=${PIN_ROOT:=$(pwd)/pin}
AC_CHECK_FILE([$PIN_ROOT],
[HAVE_PIN=true],
[HAVE_PIN=false; AC_MSG_WARN([Pin not found. BAP pintraces will be unavailable.])])
AC_SUBST(PIN_ROOT)
AM_CONDITIONAL([HAVE_PIN], [test x$HAVE_PIN = xtrue])
# Conditionally build llvm
AC_MSG_CHECKING([llvm ocaml libraries])
AC_ARG_WITH([llvm],
[AS_HELP_STRING([[--with-llvm=[=ARG]]], [use OCaml llvm package named ARG])],
LIBLLVM="$withval",
LIBLLVM="check")
AS_IF([test x$LIBLLVM = xno],
[LLVM_PACKAGE=""],
[AS_IF([test x$LIBLLVM = xyes -o x$LIBLLVM = xcheck],
[AS_IF([ocamlfind query llvm >/dev/null 2>&1],
[LLVM_PACKAGE="llvm"],
[AS_IF([ocamlfind query llvm-3_1 >/dev/null 2>&1],
[LLVM_PACKAGE="llvm-3_1"],
[LLVM_PACKAGE=""])])],
[AS_IF([ocamlfind query $LIBLLVM >/dev/null 2>&1],
[LLVM_PACKAGE="$LIBLLVM"],
[])])])
AS_IF([test \( x$LIBLLVM != xno -a x$LIBLLVM != xcheck \) -a x$LLVM_PACKAGE = x],
[AC_MSG_FAILURE([--with-llvm specified but llvm was not found])],
[])
AC_SUBST(LLVM_PACKAGE)
AS_IF([test x$LLVM_PACKAGE != x], [HAVE_LLVM_AC=yes], [HAVE_LLVM_AC=no])
AS_IF([test x$HAVE_LLVM_AC = xyes],
[AC_MSG_RESULT([$HAVE_LLVM_AC ($LLVM_PACKAGE)])],
[AC_MSG_RESULT([$HAVE_LLVM_AC])])
AC_SUBST(HAVE_LLVM_AC)
AS_IF([test "x$HAVE_LLVM_AC" = "xyes"],
[LLVM_PPFLAGS="-D WITH_LLVM"],
[])
AC_SUBST(LLVM_PPFLAGS)
LLVM_VERSION=`ocamlfind query $LLVM_PACKAGE -format %v`
AX_COMPARE_VERSION([$LLVM_VERSION], [ge], [3.2],
[LLVM_NEW_API=true; LLVM_PPFLAGS="$LLVM_PPFLAGS -D LLVM_NEW_API"],
[LLVM_NEW_API=false])
AC_SUBST(LLVM_NEW_API)
# Check for etags
AS_IF([which etags >/dev/null 2>&1],
[HAVE_ETAGS=true],
[HAVE_ETAGS=false; AC_MSG_WARN([ETAGS not found. BAP will not build tags.])])
AM_CONDITIONAL([HAVE_ETAGS], [test x$HAVE_ETAGS = xtrue])
# Checks for ocaml libraries
AC_MSG_CHECKING([for camomile])
ocamlfind query camomile >/dev/null 2>&1
if test $? != 0; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([camomile ocaml package not found])
fi
AC_MSG_RESULT([yes])
# Checks for libraries.
AC_CHECK_LIB([bfd], [bfd_init], , AC_MSG_ERROR([BFD library not found]))
AC_CHECK_LIB([iberty], [xmalloc], , AC_MSG_ERROR([Iberty library not found]))
AC_CHECK_LIB([pcre], [pcre_config], , AC_MSG_ERROR([PCRE library not found]))
# zlib is apparently needed by bfd
AC_CHECK_LIB([z], [inflate], , AC_MSG_ERROR([zlib library not found]))
AC_SUBST(INCDIRS)
rm -f libasmir/makefile.inc
echo "LIBASMIR_CXXFLAGS=-I`pwd`/src/include $CXXFLAGS" >> libasmir/makefile.inc
echo "LIBASMIR_LDFLAGS=-L`pwd`/src $LDFLAGS" >> libasmir/makefile.inc
echo "LIBASMIR_LIBS=-lasmir -lbfd -ldl -liberty -lz" >> libasmir/makefile.inc
echo "CLIBS=asmir opcodes bfd z iberty stdc++" >> libasmir/makefile.inc
AC_SUBST(ASMIR_DIR)
ASMIR_DIR="`pwd`/libasmir"
AC_SUBST(BAP_DIR)
BAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set options for 32/64-bit compilation
# XXX: Rename me
AC_CANONICAL_HOST
AC_SUBST(ARCH_X64)
case "${host}" in
x86_64*) ARCH_X64="true" ;;
*) ARCH_X64="false" ;;
esac
# Build libtrace 32 dir iff we are x86-64 and have pin
AC_SUBST(BUILD_LIBTRACE32)
AS_IF([test x$HAVE_PIN = xtrue -a x$ARCH_X64 = xtrue],
[BUILD_LIBTRACE32="true"],
[BUILD_LIBTRACE32="false"])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h], ,
AC_MSG_ERROR([Standard headers missing]))
AC_CHECK_HEADER([bfd.h], ,
AC_MSG_ERROR([You need BFD headers (e.g., libbfd-dev)]))
AC_CHECK_HEADER([pcre.h], ,
AC_MSG_ERROR([You need libpcre headers (e.g., libpcre3-dev)]))
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(bfd_vma, [], [#include <bfd.h>])
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_CHECK_FUNCS([bzero memset strstr strtoul])
# Check for library function versions
AC_CONFIG_FILES([Makefile
libasmir/Makefile
libasmir/src/Makefile
libtracewrap/Makefile
pintraces/Makefile
ocaml/Makefile
utils/Makefile
tests/Makefile
tests/C/Makefile])
# Configure ocamlgraph and zarith
AC_CONFIG_SUBDIRS([ocamlgraph])
# Configure zarith
(cd zarith && ./configure)
AC_OUTPUT
# Force libtracewrap to reconfigure
rm -f libtracewrap/CONFIGURED