reran update-copyright.pl to get new contributors and add new header comments to...
[cvc5.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 m4_define(_CVC4_MAJOR, 0 ) dnl version (major)
5 m4_define(_CVC4_MINOR, 0 ) dnl version (minor)
6 m4_define(_CVC4_RELEASE, 0 ) dnl version (alpha)
7 m4_define(_CVC4_RELEASE_STRING, [prerelease]) dnl version string
8
9 dnl Preprocess CL args. Defined in config/cvc4.m4
10 CVC4_AC_INIT
11
12 AC_PREREQ(2.61)
13 AC_INIT([cvc4], _CVC4_RELEASE_STRING)
14 AC_CONFIG_SRCDIR([src/include/cvc4_public.h])
15 AC_CONFIG_AUX_DIR([config])
16 AC_CONFIG_MACRO_DIR([config])
17
18 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
19
20 CVC4_MAJOR=_CVC4_MAJOR
21 CVC4_MINOR=_CVC4_MINOR
22 CVC4_RELEASE=_CVC4_RELEASE
23 CVC4_RELEASE_STRING=_CVC4_RELEASE_STRING
24
25 # Libtool version numbers for libraries
26 # Version numbers are in the form current:revision:age
27 #
28 # current -
29 # increment if interfaces have been added, removed or changed
30 # revision -
31 # increment if source code has changed
32 # set to zero if current is incremented
33 # age -
34 # increment if interfaces have been added
35 # set to zero if interfaces have been removed
36 # or changed
37 #
38 # For more information, see:
39 # http://www.gnu.org/software/libtool/manual/libtool.html#Versioning
40 # For guidance on when to change the version number, refer to the
41 # developer's guide.
42
43 CVC4_LIBRARY_VERSION=$CVC4_MAJOR:$CVC4_MINOR:$CVC4_RELEASE
44 CVC4_PARSER_LIBRARY_VERSION=$CVC4_MAJOR:$CVC4_MINOR:$CVC4_RELEASE
45
46 # Using the AC_CANONICAL_* macros destroy the command line you get
47 # from $@, which we want later for determining the build profile. So
48 # we save it. (We can't do our build profile stuff here, or it's not
49 # included in the output... autoconf overrides us on the orderings of
50 # some things.)
51 config_cmdline="$@"
52
53 # turn off static lib building by default
54 AC_ENABLE_SHARED
55 AC_DISABLE_STATIC
56
57 AC_CANONICAL_BUILD
58 AC_CANONICAL_HOST
59 AC_CANONICAL_TARGET
60
61 # Features requested by the user
62 AC_MSG_CHECKING([for requested build profile])
63 AC_ARG_WITH([build],
64 [AS_HELP_STRING([--with-build=profile],
65 [for profile in {production,debug,default,competition}])])
66
67 if test -z "${with_build+set}" -o "$with_build" = default; then
68 with_build=default
69 fi
70 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
71 custom_build_profile=no
72 else
73 custom_build_profile=yes
74 fi
75 btargs=
76 if test -n "${enable_optimized+set}"; then
77 if test "$enable_optimized" = yes; then
78 btargs="$btargs optimized"
79 else
80 btargs="$btargs nooptimized"
81 fi
82 fi
83 if test -n "${enable_debug_symbols+set}"; then
84 if test "$enable_debug_symbols" = yes; then
85 btargs="$btargs debugsymbols"
86 else
87 btargs="$btargs nodebugsymbols"
88 fi
89 fi
90 if test -n "${enable_assertions+set}"; then
91 if test "$enable_assertions" = yes; then
92 btargs="$btargs assertions"
93 else
94 btargs="$btargs noassertions"
95 fi
96 fi
97 if test -n "${enable_tracing+set}"; then
98 if test "$enable_tracing" = yes; then
99 btargs="$btargs tracing"
100 else
101 btargs="$btargs notracing"
102 fi
103 fi
104 if test -n "${enable_muzzle+set}"; then
105 if test "$enable_muzzle" = yes; then
106 btargs="$btargs muzzle"
107 else
108 btargs="$btargs nomuzzle"
109 fi
110 fi
111 if test -n "${enable_coverage+set}"; then
112 if test "$enable_coverage" = yes; then
113 btargs="$btargs coverage"
114 else
115 btargs="$btargs nocoverage"
116 fi
117 fi
118 if test -n "${enable_profiling+set}"; then
119 if test "$enable_profiling" = yes; then
120 btargs="$btargs profiling"
121 else
122 btargs="$btargs noprofiling"
123 fi
124 fi
125 AC_MSG_RESULT([$with_build])
126
127 AC_MSG_CHECKING([for appropriate build string])
128 build_type=`$ac_confdir/config/build-type $with_build $btargs`
129 if test "$custom_build_profile" = yes; then
130 if test "$with_build" = default; then
131 build_type=`$ac_confdir/config/build-type custom $btargs`
132 fi
133 fi
134 AC_MSG_RESULT($build_type)
135
136 # Require building in target and build-specific build directory:
137 #
138 # If the configure script is invoked from the top-level source
139 # directory, it creates a suitable build directory (based on the build
140 # architecture and build profile from $build_type), changes into it,
141 # and reinvokes itself. CVC4_CONFIGURE_IN_BUILDS is an envariable
142 # that breaks any possibility of infinite recursion in this process.
143 AC_MSG_CHECKING([what dir to configure])
144 if test "$CVC4_CONFIGURE_IN_BUILDS" = yes; then
145 AC_MSG_RESULT([this one (in builds/)])
146 elif test -e src/include/cvc4_public.h; then
147 AC_MSG_RESULT([builds/$target/$build_type])
148 echo
149 if test -z "$ac_srcdir"; then
150 mkbuilddir=./config/mkbuilddir
151 else
152 mkbuilddir=$ac_srcdir/config/mkbuilddir
153 fi
154 echo $mkbuilddir "$target" "$build_type"
155 $mkbuilddir "$target" "$build_type"
156 echo cd "builds/$target/$build_type"
157 cd "builds/$target/$build_type"
158 CVC4_CONFIGURE_IN_BUILDS=yes; export CVC4_CONFIGURE_IN_BUILDS
159 echo ../../../configure $config_cmdline
160 exec ../../../configure $config_cmdline
161 else
162 AC_MSG_RESULT([this one (user-specified)])
163 fi
164
165 # Unpack standard build types. Any particular options can be overriden with
166 # --enable/disable-X options
167 if test -z "${OPTLEVEL+set}"; then OPTLEVEL=3; fi
168 # our defaults for CXXFLAGS are better than autoconf's
169 if test -z "${CXXFLAGS+set}"; then CXXFLAGS=; fi
170 case "$with_build" in
171 production) # highly optimized, no assertions, no tracing
172 CVC4CPPFLAGS=
173 CVC4CXXFLAGS=
174 CVC4CFLAGS=
175 CVC4LDFLAGS=
176 if test -z "${OPTLEVEL+set}" ; then OPTLEVEL=3 ; fi
177 if test -z "${enable_optimized+set}" ; then enable_optimized=yes ; fi
178 if test -z "${enable_debug_symbols+set}"; then enable_debug_symbols=yes ; fi
179 if test -z "${enable_assertions+set}" ; then enable_assertions=no ; fi
180 if test -z "${enable_tracing+set}" ; then enable_tracing=no ; fi
181 if test -z "${enable_muzzle+set}" ; then enable_muzzle=no ; fi
182 ;;
183 debug) # unoptimized, debug symbols, assertions, tracing
184 CVC4CPPFLAGS=-DCVC4_DEBUG
185 CVC4CXXFLAGS='-fno-inline'
186 CVC4CFLAGS='-fno-inline'
187 CVC4LDFLAGS=
188 if test -z "${enable_optimized+set}" ; then enable_optimized=no ; fi
189 if test -z "${enable_debug_symbols+set}"; then enable_debug_symbols=yes ; fi
190 if test -z "${enable_assertions+set}" ; then enable_assertions=yes ; fi
191 if test -z "${enable_tracing+set}" ; then enable_tracing=yes ; fi
192 if test -z "${enable_muzzle+set}" ; then enable_muzzle=no ; fi
193 ;;
194 default) # moderately optimized, assertions, tracing
195 CVC4CPPFLAGS=
196 CVC4CXXFLAGS=
197 CVC4CFLAGS=
198 CVC4LDFLAGS=
199 if test -z "${OPTLEVEL+set}" ; then OPTLEVEL=2 ; fi
200 if test -z "${enable_optimized+set}" ; then enable_optimized=yes ; fi
201 if test -z "${enable_debug_symbols+set}"; then enable_debug_symbols=yes ; fi
202 if test -z "${enable_assertions+set}" ; then enable_assertions=yes ; fi
203 if test -z "${enable_tracing+set}" ; then enable_tracing=yes ; fi
204 if test -z "${enable_muzzle+set}" ; then enable_muzzle=no ; fi
205 ;;
206 competition) # maximally optimized, no assertions, no tracing, muzzled
207 CVC4CPPFLAGS=
208 CVC4CXXFLAGS='-funroll-all-loops -fexpensive-optimizations -fno-enforce-eh-specs'
209 CVC4CFLAGS='-funroll-all-loops -fexpensive-optimizations -fno-enforce-eh-specs'
210 CVC4LDFLAGS=
211 if test -z "${OPTLEVEL+set}" ; then OPTLEVEL=9 ; fi
212 if test -z "${enable_optimized+set}" ; then enable_optimized=yes ; fi
213 if test -z "${enable_debug_symbols+set}"; then enable_debug_symbols=no ; fi
214 if test -z "${enable_assertions+set}" ; then enable_assertions=no ; fi
215 if test -z "${enable_tracing+set}" ; then enable_tracing=no ; fi
216 if test -z "${enable_muzzle+set}" ; then enable_muzzle=yes ; fi
217 ;;
218 *)
219 AC_MSG_FAILURE([unknown build profile: $with_build])
220 ;;
221 esac
222
223 # permit a static binary
224 AC_MSG_CHECKING([whether to build a static binary])
225 AC_ARG_ENABLE([static-binary],
226 [AS_HELP_STRING([--enable-static-binary],
227 [build a statically-linked binary [default=no]])])
228 if test -z "${enable_static_binary+set}"; then
229 enable_static_binary=no
230 fi
231 AC_MSG_RESULT([$enable_static_binary])
232 if test "${enable_static_binary}" = yes -a "${enable_static}" != yes; then
233 enable_static=yes
234 AC_MSG_WARN([forcing static-library building, --enable-static-binary given])
235 fi
236
237 AC_MSG_CHECKING([whether to optimize libcvc4])
238
239 AC_ARG_ENABLE([optimized],
240 [AS_HELP_STRING([--enable-optimized],
241 [optimize the build])])
242
243 if test -z "${enable_optimized+set}"; then
244 enable_optimized=no
245 fi
246
247 AC_MSG_RESULT([$enable_optimized])
248
249 if test "$enable_optimized" = yes; then
250 CVC4CXXFLAGS="$CVC4CXXFLAGS -O$OPTLEVEL"
251 CVC4CFLAGS="$CVC4CFLAGS -O$OPTLEVEL"
252 else
253 CVC4CXXFLAGS="$CVC4CXXFLAGS -O0"
254 CVC4CFLAGS="$CVC4CFLAGS -O0"
255 fi
256
257 AC_MSG_CHECKING([whether to include debugging symbols in libcvc4])
258
259 AC_ARG_ENABLE([debug-symbols],
260 [AS_HELP_STRING([--disable-debug-symbols],
261 [do not include debug symbols in libcvc4])])
262
263 if test -z "${enable_debug_symbols+set}"; then
264 enable_debug_symbols=yes
265 fi
266
267 AC_MSG_RESULT([$enable_debug_symbols])
268
269 if test "$enable_debug_symbols" = yes; then
270 CVC4CXXFLAGS="$CVC4CXXFLAGS -ggdb3"
271 CVC4CFLAGS="$CVC4CFLAGS -ggdb3"
272 fi
273
274 AC_MSG_CHECKING([whether to include assertions in build])
275
276 AC_ARG_ENABLE([assertions],
277 [AS_HELP_STRING([--disable-assertions],
278 [turn off assertions in build])])
279
280 if test -z "${enable_assertions+set}"; then
281 enable_assertions=yes
282 fi
283
284 AC_MSG_RESULT([$enable_assertions])
285
286 if test "$enable_assertions" = yes; then
287 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_ASSERTIONS"
288 fi
289
290 AC_MSG_CHECKING([whether to do a traceable build of CVC4])
291 AC_ARG_ENABLE([tracing],
292 [AS_HELP_STRING([--disable-tracing],
293 [remove all tracing code from CVC4])])
294
295 if test -z "${enable_tracing+set}"; then
296 enable_tracing=yes
297 fi
298
299 AC_MSG_RESULT([$enable_tracing])
300
301 if test "$enable_tracing" = yes; then
302 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_TRACING"
303 fi
304
305 AC_MSG_CHECKING([whether to do a muzzled build of CVC4])
306 AC_ARG_ENABLE([muzzle],
307 [AS_HELP_STRING([--enable-muzzle],
308 [completely silence CVC4; remove ALL non-result output from build])])
309
310 if test -z "${enable_muzzle+set}"; then
311 enable_muzzle=no
312 fi
313
314 AC_MSG_RESULT([$enable_muzzle])
315
316 if test "$enable_muzzle" = yes; then
317 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_MUZZLE"
318 fi
319
320 AC_MSG_CHECKING([whether to do a gcov-enabled build of CVC4])
321 AC_ARG_ENABLE([coverage],
322 [AS_HELP_STRING([--enable-coverage],
323 [build with support for gcov coverage testing])])
324
325 if test -z "${enable_coverage+set}"; then
326 enable_coverage=no
327 fi
328
329 AC_MSG_RESULT([$enable_coverage])
330
331 if test "$enable_coverage" = yes; then
332 dnl TODO: Is there someway to detect if enable_shared is set by default,
333 dnl so that we can automatically disable shared and enable static?
334 if test "$enable_shared" = yes; then
335 AC_MSG_ERROR([Gcov requires static libraries. Use --disable-shared.])
336 fi
337
338 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_COVERAGE"
339 CVC4CXXFLAGS="$CVC4CXXFLAGS --coverage"
340 CVC4CFLAGS="$CVC4CFLAGS --coverage"
341 CVC4LDFLAGS="$CVC4LDFLAGS --coverage"
342 fi
343
344 AC_MSG_CHECKING([whether to do a profiling-enabled build of CVC4])
345
346 AC_ARG_ENABLE([profiling],
347 [AS_HELP_STRING([--enable-profiling],
348 [build with support for gprof profiling])])
349
350 if test -z "${enable_profiling+set}"; then
351 enable_profiling=no
352 fi
353
354 AC_MSG_RESULT([$enable_profiling])
355
356 if test "$enable_profiling" = yes; then
357 CVC4CPPFLAGS="$CVC4CPPFLAGS -DCVC4_PROFILING"
358 CVC4CXXFLAGS="$CVC4CXXFLAGS -pg"
359 CVC4CFLAGS="$CVC4CFLAGS -pg"
360 CVC4LDFLAGS="$CVC4LDFLAGS -pg"
361 fi
362
363 AM_INIT_AUTOMAKE([1.11 no-define])
364 AC_CONFIG_HEADERS([cvc4autoconfig.h])
365
366 # Initialize libtool's configuration options.
367 _LT_SET_OPTION([LT_INIT],[win32-dll])
368 LT_INIT
369
370 # Checks for programs.
371 AC_PROG_CC
372 AC_PROG_CXX
373 AC_PROG_INSTALL
374 # Check for ANTLR runantlr script (defined in config/antlr.m4)
375 AC_PROG_ANTLR
376
377 DX_PDF_FEATURE(OFF)
378 DX_PS_FEATURE(OFF)
379 DX_DOT_FEATURE(OFF)
380 DX_INIT_DOXYGEN($PACKAGE_NAME, config/doxygen.cfg, $srcdir/doc)
381
382 AC_ARG_VAR(CXXTEST, [path to CxxTest installation])
383
384 AC_SUBST([CXXTEST])
385
386 AC_ARG_WITH([cxxtest-dir],
387 [AS_HELP_STRING([--with-cxxtest-dir=DIR], [path to CxxTest installation])],
388 [CXXTEST="$withval"])
389
390 # In the case of "./configure --with-cxxtest-dir=../cxxtest" (or other
391 # relative path) and having switched the configure directory (see above),
392 # search with respect to the top source dir, not the build dir
393 if test "$CVC4_CONFIGURE_IN_BUILDS" = yes; then
394 case "$CXXTEST" in
395 /*) ;;
396 *) CXXTEST="$srcdir/$CXXTEST" ;;
397 esac
398 fi
399
400 CXXTESTGEN=
401 AC_PATH_PROG(CXXTESTGEN, cxxtestgen.pl, [], [$CXXTEST:$PATH])
402 if test -z "$CXXTESTGEN"; then
403 AC_MSG_NOTICE([unit tests disabled, cxxtestgen.pl not found.])
404 elif test -z "$CXXTEST"; then
405 CXXTEST=$(dirname "$CXXTESTGEN")
406 AC_MSG_CHECKING([for location of CxxTest headers])
407 if test -e "$CXXTEST/cxxtest/TestRunner.h"; then
408 AC_MSG_RESULT([$CXXTEST])
409 else
410 AC_MSG_RESULT([not found])
411 AC_MSG_WARN([unit tests disabled, CxxTest headers not found.])
412 CXXTESTGEN=
413 CXXTEST=
414 fi
415 fi
416
417 AM_CONDITIONAL([HAVE_CXXTESTGEN], [test -n "$CXXTESTGEN"])
418
419 AC_ARG_VAR(TEST_CPPFLAGS, [CPPFLAGS to use when testing (default=$CPPFLAGS)])
420 AC_ARG_VAR(TEST_CXXFLAGS, [CXXFLAGS to use when testing (default=$CXXFLAGS)])
421 AC_ARG_VAR(TEST_LDFLAGS, [LDFLAGS to use when testing (default=$LDFLAGS)])
422
423 AC_ARG_VAR(PERL, [PERL interpreter (used when testing)])
424
425 if test -n "$CXXTEST"; then
426 if test -z "$PERL"; then
427 AC_CHECK_PROGS(PERL, perl, perl, [])
428 else
429 AC_CHECK_PROG(PERL, "$PERL", "$PERL", [])
430 fi
431
432 if test -z "$PERL"; then
433 AC_MSG_WARN([unit tests disabled, perl not found.])
434 CXXTESTGEN=
435 CXXTEST=
436 fi
437 fi
438
439 # Checks for libraries.
440 AC_CHECK_LIB(gmp, __gmpz_init, , [AC_MSG_ERROR([GNU MP (libgmp) not found, see http://gmplib.org/])])
441 AC_CHECK_LIB(gmpxx, __gmpz_init, , [AC_MSG_ERROR([GNU MP C++ library (libgmpxx) not found, see http://gmplib.org/])])
442
443 # Check for antlr C++ runtime (defined in config/antlr.m4)
444 AC_LIB_ANTLR
445
446 # Checks for header files.
447 AC_CHECK_HEADERS([getopt.h unistd.h])
448
449 # Checks for typedefs, structures, and compiler characteristics.
450 #AC_HEADER_STDBOOL
451 AC_TYPE_UINT16_T
452 AC_TYPE_UINT32_T
453 AC_TYPE_UINT64_T
454 AC_TYPE_SIZE_T
455
456 # Checks for library functions.
457 # (empty)
458
459 # Some definitions for config.h
460 # (empty)
461
462 # Prepare configure output
463
464 if test "$enable_shared" = yes; then BUILDING_SHARED=1; fi
465 if test "$enable_static" = yes; then BUILDING_STATIC=1; fi
466 AC_SUBST(BUILDING_SHARED)
467 AC_SUBST(BUILDING_STATIC)
468 AM_CONDITIONAL([STATIC_BINARY], [test "$enable_static_binary" = yes])
469
470 AC_SUBST(CVC4_LIBRARY_VERSION)
471 AC_SUBST(CVC4_PARSER_LIBRARY_VERSION)
472
473 AC_DEFINE_UNQUOTED(CVC4_MAJOR, ${CVC4_MAJOR}, [Major component of the version of CVC4.])
474 AC_DEFINE_UNQUOTED(CVC4_MINOR, ${CVC4_MINOR}, [Minor component of the version of CVC4.])
475 AC_DEFINE_UNQUOTED(CVC4_RELEASE, ${CVC4_RELEASE}, [Release component of the version of CVC4.])
476 AC_DEFINE_UNQUOTED(CVC4_RELEASE_STRING, ["${CVC4_RELEASE_STRING}"], [Full release string for CVC4.])
477
478 CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }$CVC4CPPFLAGS"
479 CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$CVC4CXXFLAGS -Wno-deprecated"
480 CFLAGS="${CFLAGS:+$CFLAGS }$CVC4CFLAGS -Wno-deprecated"
481 LDFLAGS="${LDFLAGS:+$LDFLAGS }$CVC4LDFLAGS"
482
483 # mk_include
484 #
485 # When automake scans Makefiles, it complains about non-standard make
486 # features (including GNU extensions), and breaks GNU Make's
487 # "if/endif" construct, replacing the "if" with AM_CONDITIONAL if
488 # constructs. automake even follows "include" and messes with
489 # included Makefiles.
490 #
491 # CVC4 assumes GNU Make and we want to use GNU Make if/endifs, so we
492 # have to hide some included Makefiles with GNU extensions. We do
493 # this by defining mk_include as an autoconf substitution and then
494 # using "@mk_include@ other_makefile" in Makefile.am to include
495 # makefiles with GNU extensions; this hides them from automake.
496 mk_include=include
497 AC_SUBST(mk_include)
498
499 # CVC4_FALSE
500 #
501 # This is used to _always_ comment out rules in automake makefiles, but
502 # still trigger certain automake behavior; see test/unit/Makefile.am.
503 AM_CONDITIONAL([CVC4_FALSE], [false])
504
505 AC_CONFIG_FILES([
506 Makefile.builds
507 Makefile]
508 m4_esyscmd([find contrib/ src/ test/ -name Makefile.am | sort | sed 's,\.am$,,'])
509 )
510
511 AC_OUTPUT
512
513 # Final information to the user
514
515 if test "$custom_build_profile" = yes; then
516 if test "$with_build" = default; then
517 with_build=custom
518 else
519 AC_MSG_WARN([])
520 AC_MSG_WARN([This is a customized $with_build build profile.])
521 AC_MSG_WARN([])
522 with_build="$with_build-custom"
523 fi
524 fi
525
526 support_unit_tests='cxxtest not found; unit tests not supported'
527 if test -n "$CXXTEST"; then
528 support_unit_tests='unit testing infrastructure enabled in build directory'
529 fi
530
531 if test "$enable_optimized" = yes; then
532 optimized="yes, at level $OPTLEVEL"
533 else
534 optimized="no"
535 fi
536
537 cat <<EOF
538
539 CVC4 $VERSION
540
541 Build profile: $with_build
542 Build ID : $build_type
543 Optimized : $optimized
544 Debug symbols: $enable_debug_symbols
545 Assertions : $enable_assertions
546 Tracing : $enable_tracing
547 Muzzle : $enable_muzzle
548 gcov support : $enable_coverage
549 gprof support: $enable_profiling
550 unit tests : $support_unit_tests
551
552 static libs : $enable_static
553 shared libs : $enable_shared
554 static binary: $enable_static_binary
555
556 CPPFLAGS : $CPPFLAGS
557 CXXFLAGS : $CXXFLAGS
558 CFLAGS : $CFLAGS
559 LDFLAGS : $LDFLAGS
560
561 libcvc4 version : $CVC4_LIBRARY_VERSION
562 libcvc4parser version: $CVC4_PARSER_LIBRARY_VERSION
563
564 Now just type make, followed by make check or make install, as you like.
565
566 EOF