1#	Process this file with autoconf to produce a configure script.
2
3#
4#	Initialize autoconf stuff.
5#
6AC_INIT(Maude, 2.7.1, [maude-bugs@lists.cs.illinois.edu])
7#
8#	Allow directory names that look like macros.
9#
10m4_pattern_allow([AU_Persistent])
11m4_pattern_allow([AU_Theory])
12#
13#	Figure out system we are building for and set $host shell variable.
14#
15AC_CANONICAL_HOST
16#
17#	Initialize automake stuff.
18#
19AM_INIT_AUTOMAKE
20#
21#	Cause defines to be put in a header file rather than passed as
22#	compiler flags.
23#
24AC_CONFIG_HEADER(config.h)
25#
26#	If the user set CFLAGS or CXXFLAGS we leave them alone.
27#	Otherwise we set them to -g -Wall to stop AC_PROG_CC and
28#	AC_PROG_CXX from setting them.
29#
30USER_SET_CFLAGS=yes
31if (test -z "$CFLAGS") then
32  USER_SET_CFLAGS=no
33  CFLAGS="-g -Wall"
34fi
35USER_SET_CXXFLAGS=yes
36if (test -z "$CXXFLAGS") then
37  USER_SET_CXXFLAGS=no
38  CXXFLAGS="-g -Wall"
39fi
40#
41#	*** PROGRAMS ***
42#
43AC_PROG_CC
44AC_PROG_CXX
45if (test "$GXX" = yes) then
46  AC_MSG_CHECKING([g++ compiler version])
47  GXX_VERSION=`$CXX -dumpversion`
48  AC_MSG_RESULT($GXX_VERSION)
49fi
50AC_PROG_RANLIB
51if (test -z "$BISON") then
52  BISON="bison"
53fi
54AC_SUBST(BISON)
55if (test -z "$FLEX") then
56  FLEX="flex"
57fi
58AC_SUBST(FLEX)
59#
60#	*** LIBRARIES ***
61#
62#
63#	Figure out what libraries need to be linked in to use sockets.
64#
65AC_CHECK_LIB(nsl, inet_addr)
66AC_CHECK_LIB(socket, socket)
67#
68#	Check if user set particular Buddy library to use and if
69#	not set default.
70#
71if (test -z "$BUDDY_LIB") then
72  BUDDY_LIB="-lbdd"
73fi
74AC_SUBST(BUDDY_LIB)
75#
76#	Check to see if we should use CVC4 for SMT solving.
77#
78AC_ARG_WITH(cvc4,
79	    AC_HELP_STRING([--with-cvc4],
80                           [use CVC4 SMT solver library [default=yes]]),
81			   [WITH_CVC4=$withval],
82			   [WITH_CVC4=yes])
83if (test $WITH_CVC4 = yes) then
84#
85#	Check if user set a particular CVC4 library to use and if
86#	not set default.
87#
88  AC_DEFINE([USE_CVC4], [], [use CVC4 SMT solver library])
89  if (test -z "$CVC4_LIB") then
90    CVC4_LIB="-lcvc4"
91  fi
92  AC_SUBST(CVC4_LIB)
93#
94#	CVC4 needs the clock_gettime() function from the POSIX Realtime Extensions library.
95#
96  AC_CHECK_LIB(rt, clock_gettime)
97else
98  CVC4_LIB=""
99fi
100#
101#	Check to see if we should use Tecla for command line editing.
102#
103AC_ARG_WITH(tecla,
104	    AC_HELP_STRING([--with-tecla],
105                           [use Tecla command line editing library [default=yes]]),
106			   [WITH_TECLA=$withval],
107			   [WITH_TECLA=yes])
108if (test $WITH_TECLA = yes) then
109#
110#	Check if user set particular Tecla libraries to use and if
111#	not set defaults.
112#
113  AC_DEFINE([USE_TECLA], [], [use Tecla command line editing library])
114  if (test -z "$TECLA_LIBS") then
115    TECLA_LIBS="-ltecla -lncurses"
116  fi
117else
118  TECLA_LIBS=""
119fi
120AC_SUBST(TECLA_LIBS)
121#
122#	Check to see if we should use libsigsegv to handle segmentation faults.
123#
124AC_ARG_WITH(libsigsegv,
125	    AC_HELP_STRING([--with-libsigsegv],
126                           [use libsigsegv to handle segmentation faults [default=yes]]),
127			   [WITH_LIBSIGSEGV=$withval],
128			   [WITH_LIBSIGSEGV=yes])
129if (test $WITH_LIBSIGSEGV = yes) then
130#
131#	Check if user set particular libsigsegv to use and if
132#	not set default.
133#
134  AC_DEFINE([USE_LIBSIGSEGV], [], [use libsigsegv to handle segmentation faults])
135  if (test -z "$LIBSIGSEGV_LIB") then
136    LIBSIGSEGV_LIB="-lsigsegv"
137  fi
138else
139  LIBSIGSEGV_LIB=""
140fi
141AC_SUBST(LIBSIGSEGV_LIB)
142#
143#	Check if user set particular GMP libraries to use and if
144#	not set defaults.
145#
146if (test -z "$GMP_LIBS") then
147  GMP_LIBS="-lgmpxx -lgmp"
148fi
149AC_SUBST(GMP_LIBS)
150#
151#	Check if the user set particular GCC libraries to use - otherwise
152#	let the compiler pick.
153#
154if (test -z "$GCC_LIBS") then
155  GCC_LIBS=""
156fi
157AC_SUBST(GCC_LIBS)
158#
159#	*** HEADERS ***
160#
161AC_LANG(C++)
162AC_HEADER_TIME
163AC_CHECK_HEADERS(sys/time.h)
164AC_CHECK_HEADERS(math.h)
165AC_CHECK_HEADERS(ieeefp.h)
166AC_CHECK_HEADERS(sys/termios.h)
167AC_CHECK_HEADERS(stddef.h)
168AC_CHECK_HEADERS(limits.h)
169AC_CHECK_HEADERS(stdlib.h)
170AC_CHECK_HEADERS(stdio.h)
171AC_CHECK_HEADERS(ctype.h)
172AC_CHECK_HEADERS(unistd.h)
173AC_CHECK_HEADERS(ostream)
174AC_CHECK_HEADERS(ostream.h)
175#
176#	*** SIZES ***
177#
178AC_CHECK_SIZEOF(short)
179AC_CHECK_SIZEOF(int)
180AC_CHECK_SIZEOF(long)
181AC_CHECK_SIZEOF(unsigned long)
182AC_CHECK_SIZEOF(void *)
183#
184#	Check to see if we are debugging.
185#	If we are not debugging, assume we are optimizing.
186#
187AC_ARG_ENABLE(debug,
188	      AC_HELP_STRING([--enable-debug],
189                             [no optimization, runtime checks, dump routines [default=no]]),
190	      [DEBUGGING=$enableval],
191	      [DEBUGGING=no])
192
193if (test "$DEBUGGING" = yes) then
194  AC_DEFINE([DUMP], [], [include dump code])
195else
196  AC_DEFINE([NO_ASSERT], [], [don't do runtime checks])
197  AC_DEFINE([LOCAL_INLINES], [], [inline and discard selected local functions])
198#
199#	Set compiler optimization flags if user didn't set CXXFLAGS.
200#
201  if (test "$GXX" = yes) then
202    OFLAGS="-O2 -fomit-frame-pointer -fforce-addr"
203    case $GXX_VERSION in
204    3.*)
205      OFLAGS="$OFLAGS -finline-limit=10000"
206      ;;
207    4.*)
208      OFLAGS="$OFLAGS -finline-limit=10000"
209      ;;
210    esac
211  else
212    OFLAGS="-O"
213  fi
214  if (test $USER_SET_CFLAGS = no) then
215    CFLAGS="$CFLAGS $OFLAGS"
216  fi
217  if (test $USER_SET_CXXFLAGS = no) then
218    CXXFLAGS="$CXXFLAGS $OFLAGS"
219  fi
220#
221#	Performance tweaks for known hosts.
222#
223  TWEAKFLAGS=""
224
225  case $host in
226
227  sparc-*)
228#
229#	We assume the v8 instruction set as a baseline in order to
230#	have multiplication and division instructions (gcc defaults
231#	to v7 which does not) but schedule for a more recent v9
232#	implementation.
233#
234    TWEAKFLAGS="-march=v8 -mtune=ultrasparc"
235    ;;
236
237  *-darwin*)
238#
239#	Changing the stack boundary causes problems on x86 Macs.
240#
241    ;;
242#
243#	For the Intel x86 family we select the smallest stack alignment
244#	in order to trade speed for memory on deeply recursive calls.
245#	The Pentium Pro and later have conditional move instructions,
246#	which out-perform various bit twiddling tricks, but gcc will
247#	only use them if given -march=i686.
248#
249  i386-*)
250    TWEAKFLAGS="-march=i386 -mpreferred-stack-boundary=2"
251    ;;
252
253  i486-*)
254    TWEAKFLAGS="-march=i486 -mpreferred-stack-boundary=2"
255    ;;
256
257  i586-*)
258    TWEAKFLAGS="-march=i586 -mpreferred-stack-boundary=2"
259    ;;
260
261  i686-*)
262    TWEAKFLAGS="-march=i686 -mpreferred-stack-boundary=2"
263    if (test $USER_SET_CXXFLAGS = no) then
264      AC_DEFINE([HAVE_CMOV], [], [have conditional move instruction])
265    fi
266    ;;
267#
268#	The x86-64 supports conditional moves and gcc will use
269#	them without being given additional flags. Smallest legal
270#	stack alignment is 4.
271#
272  x86_64-*)
273    TWEAKFLAGS="-mpreferred-stack-boundary=4"
274    AC_DEFINE([HAVE_CMOV], [], [have conditional move instruction])
275    ;;
276#
277#	The DEC Alpha supports conditional moves and gcc will use
278#	them without being given additional flags.
279#
280  alpha*)
281    AC_DEFINE([HAVE_CMOV], [], [have conditional move instruction])
282    ;;
283
284  esac
285
286  if (test $USER_SET_CFLAGS = no) && (test $GCC = yes) then
287    CFLAGS="$CFLAGS $TWEAKFLAGS"
288  fi
289  if (test $USER_SET_CXXFLAGS = no) && (test $GXX = yes) then
290    CXXFLAGS="$CXXFLAGS $TWEAKFLAGS"
291  fi
292fi
293#
294#	Fixes for known hosts.
295#
296FIXFLAGS=""
297case $host in
298
299#
300#	Needed to handle +/- infinity and underflow without
301#	causing a SIGFPE.
302#
303  alpha*)
304    FIXFLAGS="-mieee"
305    ;;
306#
307#	(no longer deal with dlmalloc)
308#
309  x86_64-*-linux-*)
310    ;;
311#
312#	(no longer deal with dlmalloc)
313#
314  *-darwin*)
315    AC_DEFINE([DARWIN], [], [enable Darwin specific fixes])
316    ;;
317
318esac
319
320if (test $USER_SET_CFLAGS = no) && (test $GCC = yes) then
321  CFLAGS="$CFLAGS $FIXFLAGS"
322fi
323if (test $USER_SET_CXXFLAGS = no) && (test $GXX = yes) then
324  CXXFLAGS="$CXXFLAGS $FIXFLAGS"
325fi
326
327#
328#	Needed defines.
329#
330AC_DEFINE([SCP], [], [use MSCP10 calling conventions])
331AC_DEFINE([BUBBLES], [], [support bubbles when parsing])
332#
333#	Check to see if we should build the compiler.
334#
335AC_ARG_ENABLE(compiler,
336	      AC_HELP_STRING([--enable-compiler],
337                             [build the experimental integrated compiler [default=no]]),
338	      [COMPILER=$enableval],
339	      [COMPILER=no])
340if (test "$COMPILER" = yes) then
341  AC_DEFINE([COMPILER], [], [build the experimental integrated compiler])
342  AC_DEFINE([ANNOTATED], [], [annotate comiler output])
343fi
344#
345#	Check to see if we should support MOS oracles.
346#
347AC_ARG_ENABLE(mos,
348	      AC_HELP_STRING([--enable-mos],
349                             [support MOS oracles (DO NOT USE!) [default=no]]),
350	      [MOS=$enableval],
351	      [MOS=no])
352if (test "$MOS" = yes) then
353  AC_DEFINE([MOS], [], [support MOS oracles])
354fi
355#
356#	Conditional compilation and linking.
357#
358AM_CONDITIONAL(BUILD_COMPILER, test $COMPILER = yes)
359
360AC_CONFIG_FILES([Makefile
361	         src/Makefile
362		 src/3rdParty/Makefile
363		 src/Utility/Makefile
364		 src/Temporal/Makefile
365		 src/Interface/Makefile
366		 src/Core/Makefile
367		 src/Variable/Makefile
368		 src/NA_Theory/Makefile
369		 src/ACU_Persistent/Makefile
370		 src/ACU_Theory/Makefile
371		 src/AU_Persistent/Makefile
372		 src/AU_Theory/Makefile
373		 src/CUI_Theory/Makefile
374		 src/S_Theory/Makefile
375		 src/FreeTheory/Makefile
376		 src/Higher/Makefile
377		 src/BuiltIn/Makefile
378		 src/IO_Stuff/Makefile
379		 src/ObjectSystem/Makefile
380		 src/Meta/Makefile
381		 src/FullCompiler/Makefile
382		 src/MSCP10/Makefile
383		 src/StrategyLanguage/Makefile
384		 src/Mixfix/Makefile
385		 src/SMT/Makefile
386		 src/Main/Makefile
387		 tests/Makefile
388		 tests/BuiltIn/Makefile
389		 tests/Meta/Makefile
390		 tests/Misc/Makefile
391		 tests/ResolvedBugs/Makefile
392])
393
394AC_OUTPUT
395