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