more build system work
[cvc5.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.59])
5 AC_INIT([src/include/cvc4.h])
6 AC_CONFIG_AUX_DIR([config])
7 #AC_CONFIG_LIBOBJ_DIR([lib])
8 AC_CONFIG_MACRO_DIR([config])
9
10 CVC4_RELEASE=prerelease
11 CVC4_LIBRARY_RELEASE_CODE=0:0:0
12 CVC4_LIBRARY_VERSION=0:0:0
13 CVC4_PARSER_LIBRARY_VERSION=0:0:0
14
15 # really irritating: AC_CANONICAL_* bash $@
16 config_cmdline="$@"
17
18 AC_CANONICAL_BUILD
19 AC_CANONICAL_HOST
20 AC_CANONICAL_TARGET
21
22 # Features requested by the user
23 AC_MSG_CHECKING([for requested build profile])
24 AC_ARG_WITH([build], [AS_HELP_STRING([--with-build=profile], [for profile in {production,debug,default,competition}])])
25 if test -z "${with_build+set}" -o "$with_build" = default; then
26 with_build=default
27 fi
28 if test -z "${enable_optimized+set}" -a -z "${enable_debug_symbols+set}" -a -z "${enable_assertions+set}" -a -z "${enable_tracing+set}" -a -z "${enable_muzzle+set}" -a -z "${enable_coverage+set}" -a -z "${enable_profiling+set}"; then
29 non_standard_build_profile=no
30 else
31 non_standard_build_profile=yes
32 fi
33 build_type_suffix=
34 if test -n "${enable_optimized+set}"; then
35 if test "$enable_optimized" = no; then
36 build_type_suffix=$build_type_suffix-noopt
37 else
38 build_type_suffix=$build_type_suffix-opt
39 fi
40 fi
41 if test -n "${enable_debug_symbols+set}"; then
42 if test "$enable_debug_symbols" = no; then
43 build_type_suffix=$build_type_suffix-nodsy
44 else
45 build_type_suffix=$build_type_suffix-dsy
46 fi
47 fi
48 if test -n "${enable_assertions+set}"; then
49 if test "$enable_assertions" = no; then
50 build_type_suffix=$build_type_suffix-noass
51 else
52 build_type_suffix=$build_type_suffix-ass
53 fi
54 fi
55 if test -n "${enable_tracing+set}"; then
56 if test "$enable_tracing" = no; then
57 build_type_suffix=$build_type_suffix-notrc
58 else
59 build_type_suffix=$build_type_suffix-trc
60 fi
61 fi
62 if test -n "${enable_muzzle+set}"; then
63 if test "$enable_muzzle" = no; then
64 build_type_suffix=$build_type_suffix-nomzl
65 else
66 build_type_suffix=$build_type_suffix-mzl
67 fi
68 fi
69 if test -n "${enable_coverage+set}"; then
70 if test "$enable_coverage" = no; then
71 build_type_suffix=$build_type_suffix-nocvg
72 else
73 build_type_suffix=$build_type_suffix-cvg
74 fi
75 fi
76 if test -n "${enable_profiling+set}"; then
77 if test "$enable_profiling" = no; then
78 build_type_suffix=$build_type_suffix-noprf
79 else
80 build_type_suffix=$build_type_suffix-prf
81 fi
82 fi
83 AC_MSG_RESULT([$with_build])
84
85 AC_MSG_CHECKING([for appropriate build string])
86 build_type=$with_build$build_type_suffix
87 if test "$non_standard_build_profile" = yes; then
88 if test "$with_build" = default; then
89 build_type=custom$build_type_suffix
90 fi
91 fi
92 AC_MSG_RESULT($build_type)
93
94 # require building in target and build-specific build directory
95 AC_MSG_CHECKING([what dir to configure])
96 if test "$CVC4_CONFIGURE_IN_BUILDS" = yes; then
97 AC_MSG_RESULT([this one (in builds/)])
98 elif test -e src/include/cvc4.h; then
99 AC_MSG_RESULT([builds/$target/$build_type])
100 echo
101 echo Setting up "builds/$target/$build_type"...
102 rm -fv config.log config.status confdefs.h
103 mkdir -pv "builds/$target/$build_type"
104 test -e builds/Makefile || ln -sfv "$target/$build_type/Makefile.builds" builds/Makefile
105 echo Creating builds/current...
106 (echo "# This is the most-recently-configured CVC4 build"; \
107 echo "# 'make' in the top-level source directory applies to this build"; \
108 echo "CURRENT_BUILD = $target/$build_type") > builds/current
109 echo cd "builds/$target/$build_type"
110 cd "builds/$target/$build_type"
111 CVC4_CONFIGURE_IN_BUILDS=yes; export CVC4_CONFIGURE_IN_BUILDS
112 echo ../../../configure $config_cmdline
113 exec ../../../configure $config_cmdline
114 else
115 AC_MSG_RESULT([this one (user-specified)])
116 fi
117
118 case "$with_build" in
119 production)
120 CVC4CPPFLAGS=
121 CVC4CXXFLAGS=-O3
122 CVC4LDFLAGS=
123 if test -z "${enable_assertions+set}"; then enable_assertions=no ; fi
124 if test -z "${enable_tracing+set}" ; then enable_tracing=no ; fi
125 if test -z "${enable_muzzle+set}" ; then enable_muzzle=no ; fi
126 ;;
127 debug)
128 CVC4CPPFLAGS=-DCVC4_DEBUG
129 CVC4CXXFLAGS='-O0 -fno-inline -ggdb3'
130 CVC4LDFLAGS=
131 if test -z "${enable_assertions+set}"; then enable_assertions=yes ; fi
132 if test -z "${enable_tracing+set}" ; then enable_tracing=yes ; fi
133 if test -z "${enable_muzzle+set}" ; then enable_muzzle=no ; fi
134 ;;
135 default)
136 CVC4CPPFLAGS=
137 CVC4CXXFLAGS=-O2
138 CVC4LDFLAGS=
139 if test -z "${enable_assertions+set}"; then enable_assertions=yes ; fi
140 if test -z "${enable_tracing+set}" ; then enable_tracing=yes ; fi
141 if test -z "${enable_muzzle+set}" ; then enable_muzzle=no ; fi
142 ;;
143 competition)
144 CVC4CPPFLAGS=
145 CVC4CXXFLAGS='-O9 -funroll-all-loops -fexpensive-optimizations -fno-enforce-eh-specs'
146 CVC4LDFLAGS=
147 if test -z "${enable_assertions+set}"; then enable_assertions=no ; fi
148 if test -z "${enable_tracing+set}" ; then enable_tracing=no ; fi
149 if test -z "${enable_muzzle+set}" ; then enable_muzzle=yes ; fi
150 ;;
151 *)
152 AC_MSG_FAILURE([unknown build profile: $with_build])
153 ;;
154 esac
155
156 AC_MSG_CHECKING([whether to optimize libcvc4])
157 AC_ARG_ENABLE([optimized], [AS_HELP_STRING([--enable-optimized], [optimize the build])])
158 if test -z "${enable_optimized+set}"; then
159 enable_optimized=no
160 fi
161 AC_MSG_RESULT([$enable_optimized])
162 if test "$enable_optimized" = yes; then
163 CVC4CXXFLAGS="$CVC4CXXFLAGS -O3"
164 fi
165
166 AC_MSG_CHECKING([whether to include debugging symbols in libcvc4])
167 AC_ARG_ENABLE([debug-symbols], [AS_HELP_STRING([--disable-debug-symbols], [do not include debug symbols in libcvc4])])
168 if test -z "${enable_debug_symbols+set}"; then
169 enable_debug_symbols=yes
170 fi
171 AC_MSG_RESULT([$enable_debug_symbols])
172 if test "$enable_debug_symbols" = yes; then
173 CVC4CXXFLAGS="$CVC4CXXFLAGS -ggdb3"
174 fi
175
176 AC_MSG_CHECKING([whether to include assertions in build])
177 AC_ARG_ENABLE([assertions], [AS_HELP_STRING([--disable-assertions], [turn off assertions in build])])
178 if test -z "${enable_assertions+set}"; then
179 enable_assertions=yes
180 fi
181 AC_MSG_RESULT([$enable_assertions])
182 if test "$enable_assertions" = yes; then
183 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_ASSERTIONS"
184 fi
185
186 AC_MSG_CHECKING([whether to do a traceable build of CVC4])
187 AC_ARG_ENABLE([tracing], [AS_HELP_STRING([--disable-tracing], [remove all tracing code from CVC4])])
188 if test -z "${enable_tracing+set}"; then
189 enable_tracing=yes
190 fi
191 AC_MSG_RESULT([$enable_tracing])
192 if test "$enable_tracing" = yes; then
193 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_TRACING"
194 fi
195
196 AC_MSG_CHECKING([whether to do a muzzled build of CVC4])
197 AC_ARG_ENABLE([muzzle], [AS_HELP_STRING([--enable-muzzle], [completely silence CVC4; remove ALL non-result output from build])])
198 if test -z "${enable_muzzle+set}"; then
199 enable_muzzle=no
200 fi
201 AC_MSG_RESULT([$enable_muzzle])
202 if test "$enable_muzzle" = yes; then
203 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_MUZZLE"
204 fi
205
206 AC_MSG_CHECKING([whether to do a gcov-enabled build of CVC4])
207 AC_ARG_ENABLE([coverage], [AS_HELP_STRING([--enable-coverage], [build with support for gcov coverage testing])])
208 if test -z "${enable_coverage+set}"; then
209 enable_coverage=no
210 fi
211 AC_MSG_RESULT([$enable_coverage])
212 if test "$enable_coverage" = yes; then
213 CVC4CXXFLAGS="$CVC4CXXFLAGS --coverage"
214 CVC4LDFLAGS="$CVC4LDFLAGS --coverage"
215 fi
216
217 AC_MSG_CHECKING([whether to do a profiling-enabled build of CVC4])
218 AC_ARG_ENABLE([profiling], [AS_HELP_STRING([--enable-profiling], [build with support for gprof profiling])])
219 if test -z "${enable_profiling+set}"; then
220 enable_profiling=no
221 fi
222 AC_MSG_RESULT([$enable_profiling])
223 if test "$enable_profiling" = yes; then
224 CVC4CXXFLAGS="$CVC4CXXFLAGS -pg"
225 CVC4LDFLAGS="$CVC4LDFLAGS -pg"
226 fi
227
228 AM_INIT_AUTOMAKE(cvc4, $CVC4_RELEASE)
229 AC_CONFIG_HEADERS([config.h])
230
231 # keep track of whether the user set these (check here, because
232 # autoconf might set a default later)
233 AC_MSG_CHECKING([for user CPPFLAGS])
234 if test -z "${CPPFLAGS+set}"; then user_cppflags=no; else user_cppflags=yes; fi
235 AC_MSG_RESULT([${CPPFLAGS-none}])
236 AC_MSG_CHECKING([for user CXXFLAGS])
237 if test -z "${CXXFLAGS+set}"; then user_cxxflags=no; else user_cxxflags=yes; fi
238 AC_MSG_RESULT([${CXXFLAGS-none}])
239 AC_MSG_CHECKING([for user LDFLAGS])
240 if test -z "${LDFLAGS+set}" ; then user_ldflags=no ; else user_ldflags=yes ; fi
241 AC_MSG_RESULT([${LDFLAGS-none}])
242
243 LT_INIT
244
245 AC_LIBTOOL_WIN32_DLL
246
247
248
249
250
251 # Checks for programs.
252 AC_PROG_CC
253 AC_PROG_CXX
254 AC_PROG_INSTALL
255 AC_PROG_LIBTOOL
256 AM_PROG_LEX
257 AC_PROG_YACC
258
259 # Check for ANTLR runantlr script (defined in config/antlr.m4)
260 AC_ARG_ENABLE(antlr, AS_HELP_STRING([--enable-antlr],[use Dejan's ANTLR parsers]))
261 AC_MSG_CHECKING([whether you want to use the ANTLR parsers])
262 if test -z "${enable_antlr+set}"; then
263 enable_antlr=no
264 fi
265 AC_MSG_RESULT([$enable_antlr])
266 AM_CONDITIONAL(USE_ANTLR, test "$enable_antlr" = yes)
267 if test "$enable_antlr" = yes; then
268 AC_PROG_ANTLR
269 AC_DEFINE(ANTLR_PARSERS, [], [whether we're using ANTLR parsers])
270 fi
271
272 AC_CHECK_PROG(DOXYGEN, doxygen, doxygen, [])
273 if test -z "$DOXYGEN"; then
274 AC_MSG_WARN([documentation targets require doxygen. Set your PATH appropriately or set DOXYGEN to point to a valid doxygen binary.])
275 fi
276 AC_ARG_VAR(DOXYGEN, [location of doxygen binary])
277
278 CXXTESTGEN=
279 AC_PATH_PROG(CXXTESTGEN, cxxtestgen.pl, [], [$CXXTEST:$PATH])
280 if test -z "$CXXTESTGEN"; then
281 AC_MSG_NOTICE([unit tests disabled, cxxtestgen.pl not found.])
282 elif test -z "$CXXTEST"; then
283 CXXTEST=$(dirname "$CXXTESTGEN")
284 AC_MSG_CHECKING([for location of CxxTest headers])
285 if test -e "$CXXTEST/cxxtest/TestRunner.h"; then
286 AC_MSG_RESULT([$CXXTEST])
287 else
288 AC_MSG_RESULT([not found])
289 AC_MSG_WARN([unit tests disabled, CxxTest headers not found.])
290 CXXTESTGEN=
291 CXXTEST=
292 fi
293 fi
294 AC_ARG_VAR(CXXTEST, [path to CxxTest installation])
295 AM_CONDITIONAL([HAVE_CXXTESTGEN], [test -n "$CXXTESTGEN"])
296
297 AC_ARG_VAR(TEST_CPPFLAGS, [CXXFLAGS to use when testing (default=$CPPFLAGS)])
298 AC_ARG_VAR(TEST_CXXFLAGS, [CXXFLAGS to use when testing (default=$CXXFLAGS)])
299 AC_ARG_VAR(TEST_LDFLAGS, [LDFLAGS to use when testing (default=$LDFLAGS)])
300
301 if test -n "$CXXTEST"; then
302 AC_CHECK_PROG(PERL, perl, perl, [])
303 if test -z "$PERL"; then
304 AC_MSG_WARN([unit tests disabled, perl not found.])
305 CXXTESTGEN=
306 CXXTEST=
307 fi
308 fi
309
310 # Checks for libraries.
311 AC_CHECK_LIB(gmp, __gmpz_init, , [AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
312 # Check for antlr C++ runtime (defined in config/antlr.m4)
313 if test "$enable_antlr" = yes; then
314 AC_LIB_ANTLR
315 fi
316
317 # Checks for header files.
318 AC_CHECK_HEADERS([getopt.h unistd.h])
319
320 # Checks for typedefs, structures, and compiler characteristics.
321 AC_HEADER_STDBOOL
322 AC_TYPE_UINT16_T
323 AC_TYPE_UINT32_T
324 AC_TYPE_UINT64_T
325 AC_TYPE_SIZE_T
326
327 # Checks for library functions.
328
329 # Some definitions for config.h
330
331 # Prepare configure output
332
333 AC_SUBST(CVC4_LIBRARY_RELEASE_CODE)
334 AC_SUBST(CVC4_LIBRARY_VERSION)
335 AC_SUBST(CVC4_PARSER_LIBRARY_VERSION)
336 if test "$user_cppflags" = no; then
337 CPPFLAGS="$CVC4CPPFLAGS"
338 fi
339 if test "$user_cxxflags" = no; then
340 CXXFLAGS="$CVC4CXXFLAGS"
341 fi
342 if test "$user_ldflags" = no; then
343 LDFLAGS="$CVC4LDFLAGS"
344 fi
345
346 AC_CONFIG_FILES([
347 Makefile.builds
348 Makefile
349 contrib/Makefile
350 doc/Makefile
351 src/Makefile
352 src/expr/Makefile
353 src/smt/Makefile
354 src/main/Makefile
355 src/prop/minisat/Makefile
356 src/prop/Makefile
357 src/util/Makefile
358 src/context/Makefile
359 src/parser/Makefile
360 src/parser/smt/Makefile
361 src/theory/Makefile
362 test/Makefile
363 test/regress/Makefile
364 test/unit/Makefile
365 ])
366
367 AC_OUTPUT
368
369 # Final information to the user
370
371 non_standard=
372 if test "$non_standard_build_profile" = yes; then
373 if test "$with_build" = default; then
374 with_build=custom
375 else
376 AC_MSG_WARN([])
377 AC_MSG_WARN([This is a non-standard $with_build build profile.])
378 AC_MSG_WARN([])
379 non_standard=-custom
380 fi
381 fi
382
383 cat <<EOF
384
385 CVC4 $VERSION
386
387 Build profile: $with_build$non_standard
388 Build ID : $build_type
389 Optimized : $enable_optimized
390 Debug symbols: $enable_debug_symbols
391 Assertions : $enable_assertions
392 Tracing : $enable_tracing
393 Muzzle : $enable_muzzle
394 gcov support : $enable_coverage
395 gprof support: $enable_profiling
396
397 CPPFLAGS : $CPPFLAGS
398 CXXFLAGS : $CXXFLAGS
399 LDFLAGS : $LDFLAGS
400
401 Using ANTLR parsers : $enable_antlr
402 Library releases : $CVC4_LIBRARY_RELEASE_CODE
403 libcvc4 version : $CVC4_LIBRARY_VERSION
404 libcvc4parser version: $CVC4_PARSER_LIBRARY_VERSION
405
406 Now just type make, followed by make check or make install, as you like.
407
408 You can use 'make <build_profile>' to reconfig/build a different profile.
409 Build profiles: production optimized default competition
410
411 EOF
412
413 if test "$user_cppflags" = yes; then
414 AC_MSG_WARN([])
415 AC_MSG_WARN([I won't override your CPPFLAGS setting. But some of your build options to configure may not be honored.])
416 AC_MSG_WARN([To support your options to configure, I would like to set CPPFLAGS to:])
417 AC_MSG_WARN([ $CVC4CPPFLAGS])
418 AC_MSG_WARN([])
419 fi
420 if test "$user_cxxflags" = yes; then
421 AC_MSG_WARN([])
422 AC_MSG_WARN([I won't override your CXXFLAGS setting. But some of your build options to configure may not be honored.])
423 AC_MSG_WARN([To support your options to configure, I would like to set CXXFLAGS to:])
424 AC_MSG_WARN([ $CVC4CXXFLAGS])
425 AC_MSG_WARN([])
426 fi
427 if test "$user_ldflags" = yes; then
428 AC_MSG_WARN([])
429 AC_MSG_WARN([I won't override your LDFLAGS setting. But some of your build options to configure may not be honored.])
430 AC_MSG_WARN([To support your options to configure, I would like to set LDFLAGS to:])
431 AC_MSG_WARN([ $CVC4LDFLAGS])
432 AC_MSG_WARN([])
433 fi
434
435 if test "$non_standard_build_profile" = yes; then
436 if test "$with_build" = default; then :; else
437 AC_MSG_WARN([])
438 AC_MSG_WARN([This is a non-standard $with_build build profile.])
439 AC_MSG_WARN([])
440 fi
441 fi