If you call abort(), #include <cstdlib>
[oota-llvm.git] / autoconf / configure.ac
1 dnl Initialize autoconf
2 AC_INIT([[[LLVM]]],[[[1.1]]],[llvmbugs@cs.uiuc.edu])
3
4 dnl Place all of the extra autoconf files into the config subdirectory
5 AC_CONFIG_AUX_DIR([autoconf])
6
7 dnl Quit if the source directory has already been configured.
8 dnl NOTE: This relies upon undocumented autoconf behavior.
9 if test ${srcdir} != "."
10 then
11         if test -f ${srcdir}/include/Config/config.h
12         then
13                 AC_MSG_ERROR([Already configured in ${srcdir}])
14         fi
15 fi
16
17 dnl Configure all of the projects present in our source tree.
18 for i in `ls ${srcdir}/projects`
19 do
20   if test ${i} != "CVS"
21   then
22     if test -f ${srcdir}/projects/${i}/configure
23     then
24       AC_CONFIG_SUBDIRS(projects/${i})
25     fi
26   fi
27 done
28
29 dnl Configure a header file
30 AC_CONFIG_HEADERS(include/Config/config.h)
31 AC_CONFIG_MAKEFILE(Makefile)
32 AC_CONFIG_MAKEFILE(Makefile.common)
33 AC_CONFIG_MAKEFILE(lib/Makefile)
34 AC_CONFIG_MAKEFILE(runtime/Makefile)
35 AC_CONFIG_MAKEFILE(test/Makefile)
36 AC_CONFIG_MAKEFILE(test/Makefile.tests)
37 AC_CONFIG_MAKEFILE(test/QMTest/llvm.py)
38 AC_CONFIG_MAKEFILE(test/QMTest/llvmdb.py)
39 AC_CONFIG_MAKEFILE(test/Programs/Makefile)
40 AC_CONFIG_MAKEFILE(test/Programs/Makefile.programs)
41 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.Makefile)
42 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.report)
43 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.report)
44 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.report)
45 AC_CONFIG_MAKEFILE(test/Programs/TEST.example.Makefile)
46 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.Makefile)
47 AC_CONFIG_MAKEFILE(test/Programs/TEST.buildrepo.Makefile)
48 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.Makefile)
49 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.report)
50 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.Makefile)
51 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.report)
52 AC_CONFIG_MAKEFILE(test/Programs/TEST.typesafe.Makefile)
53 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.gnuplot)
54 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.Makefile)
55 AC_CONFIG_MAKEFILE(test/Programs/External/Makefile)
56 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile)
57 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile.spec)
58 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile)
59 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile.multisrc)
60 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/analyzer/test.in)
61 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/Makefile)
62 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/test.in)
63 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/Makefile)
64 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/test.in)
65 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile)
66 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in)
67 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/Makefile)
68 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/test.in)
69 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/Makefile)
70 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/test.in)
71 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/Makefile)
72 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/test.in)
73 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile)
74 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile.singlesrc)
75 AC_CONFIG_MAKEFILE(tools/Makefile)
76 AC_CONFIG_MAKEFILE(utils/Makefile)
77 AC_CONFIG_MAKEFILE(projects/Makefile)
78
79 dnl Find the install program (needs to be done before canonical stuff)
80 AC_PROG_INSTALL
81
82 dnl Check which host for which we're compiling.  This will tell us which LLVM
83 dnl compiler will be used for compiling SSA into object code.
84 AC_CANONICAL_TARGET
85
86 dnl Set the "OS" Makefile variable based on the system we are building on.
87 dnl We will use the build machine information to set some variables.
88 case $build in
89         *-*-linux*)
90              AC_SUBST(OS,[Linux])
91                          if test -d /home/vadve/lattner/local/x86/llvm-gcc
92                          then
93                            AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
94                          fi
95                  ;;
96
97         *-*-solaris*)
98              AC_SUBST(OS,[SunOS])
99                          if test -d /home/vadve/lattner/local/sparc/llvm-gcc
100                          then
101                    AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
102                          fi
103                  ;;
104
105         *-*-darwin*)
106              AC_SUBST(OS,[Darwin])
107                  ;;
108
109         *)       AC_SUBST(OS,[Unknown])
110                  ;;
111 esac
112
113 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
114 dnl V9, since that is all that we support at the moment, and autoconf will only
115 dnl tell us we're a sparc.
116 case $target in
117         sparc*-*-solaris*)  AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
118                             ;;
119 esac
120
121 dnl Determine what our target architecture is and configure accordingly.
122 dnl This will allow Makefiles to make a distinction between the hardware and
123 dnl the OS.
124 case $target in
125         i*86-*)           AC_SUBST(ARCH,[x86])
126                           ;;
127         sparc*-*)         AC_SUBST(ARCH,[Sparc])
128                           ;;
129         powerpc*-*)       AC_SUBST(ARCH,[PowerPC])
130                           ;;
131         *)                AC_SUBST(ARCH,[Unknown])
132                           ;;
133 esac
134
135 dnl Check for compilation tools
136 AC_PROG_CXX
137 AC_PROG_CC(gcc)
138 AC_PROG_CPP
139
140 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
141 if test "$GCC" != "yes"
142 then
143         AC_MSG_ERROR([gcc required but not found])
144 fi
145 if test "$GXX" != "yes"
146 then
147         AC_MSG_ERROR([g++ required but not found])
148 fi
149
150 dnl Verify that GCC is version 3.0 or higher
151 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
152 if test "$gccmajor" -lt "3"
153 then
154         AC_MSG_ERROR([gcc 3.x required, but you have a lower version])
155 fi
156
157 dnl Check for GNU Make.  We use its extensions too, so don't build without it
158 CHECK_GNU_MAKE
159 if test -z "$_cv_gnu_make_command"
160 then
161         AC_MSG_ERROR([GNU Make required but not found])
162 fi
163
164 dnl Checks for other tools
165 AC_PROG_FLEX
166 AC_PROG_BISON
167 AC_PROG_LIBTOOL
168
169 dnl Checks for tools we can get away with not having:
170 AC_PATH_PROG(DOT,[dot],[true dot])
171 AC_PATH_PROG(ETAGS,[etags],[true etags])
172 AC_PATH_PROG(PYTHON,[python],[true python])
173 if test "$PYTHON" = "false"
174 then
175         AC_MSG_WARN([Python is required for the test suite, but it was not found])
176 fi
177 AC_PATH_PROG(QMTEST,[qmtest],[true qmtest])
178 if test "$QMTEST" = "false"
179 then
180         AC_MSG_WARN([QMTest is required for the test suite, but it was not found])
181 fi
182
183 dnl Verify that the version of python available is high enough for qmtest
184 pyversion=`$PYTHON -V 2>&1 | cut -d\  -f2`
185 pymajor=`echo $pyversion | cut -d. -f1`
186 pyminor=`echo $pyversion | cut -d. -f2`
187
188 if test "$pymajor" -ge "2"
189 then
190         if test "$pymajor" -eq "2"
191         then
192                 if test "$pyminor" -lt "2"
193                 then
194                         AC_MSG_WARN([QMTest requires Python 2.2 or later])
195                 fi
196         fi
197 else
198         AC_MSG_WARN([QMTest requires Python 2.2 or later])
199 fi
200
201 dnl Verify that the source directory is valid
202 AC_CONFIG_SRCDIR(["Makefile.config.in"])
203
204 dnl Checks for libraries:
205 dnl libelf is for sparc only; we can ignore it if we don't have it
206 AC_CHECK_LIB(elf, elf_begin)
207
208 dnl dlopen() is required for plugin support.
209 AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1],[Define if dlopen() is available on this platform.]),AC_MSG_WARN([dlopen() not found - disabling plugin support]))
210
211 dnl mallinfo is optional; the code can compile (minus features) without it
212 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
213
214 dnl pthread locking functions are optional - but llvm will not be thread-safe
215 dnl without locks.
216 AC_SEARCH_LIBS(pthread_mutex_lock,pthread,AC_DEFINE(HAVE_PTHREAD_MUTEX_LOCK,1,[Define if PThread mutexes (e.g., pthread_mutex_lock) are available in the system's thread library.]))
217
218 dnl Checks for header files.
219 dnl We don't check for ancient stuff or things that are guaranteed to be there
220 dnl by the C++ standard. We always use the <cfoo> versions of <foo.h> C headers.
221 AC_HEADER_STDC
222 AC_HEADER_SYS_WAIT
223
224 dnl Checks for POSIX and other various system-specific header files
225 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h malloc.h sys/mman.h sys/resource.h dlfcn.h link.h)
226
227 dnl Check for types
228 AC_TYPE_PID_T
229 AC_TYPE_SIZE_T
230 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
231 AC_CHECK_TYPES([uint64_t],,AC_MSG_ERROR([Type uint64_t required but not found]))
232 AC_HEADER_TIME
233 AC_STRUCT_TM
234
235 dnl Check for various C features
236 AC_C_PRINTF_A
237
238 dnl Check for C++ extensions
239 AC_CXX_HAVE_HASH_MAP
240 AC_CXX_HAVE_HASH_SET
241 AC_CXX_HAVE_EXT_SLIST
242 AC_CXX_HAVE_STD_ITERATOR
243 AC_CXX_HAVE_BI_ITERATOR
244 AC_CXX_HAVE_FWD_ITERATOR
245
246 dnl Checks for library functions.
247 AC_FUNC_ALLOCA
248 AC_FUNC_MMAP
249 if test "$ac_cv_func_mmap_fixed_mapped" = "no"
250 then
251         AC_MSG_ERROR([mmap() required but not found])
252 fi
253 AC_FUNC_MMAP_FILE
254 if test "$ac_cv_func_mmap_file" = "no"
255 then
256         AC_MSG_ERROR([mmap() of files required but not found])
257 fi
258 AC_HEADER_MMAP_ANONYMOUS
259 AC_TYPE_SIGNAL
260 AC_CHECK_FUNCS(getcwd gettimeofday strdup strtoq strtoll)
261 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
262
263 dnl Determine if the linker supports the -R option.
264 AC_LINK_USE_R
265
266 dnl --enable/--with command-line options:
267 dnl Check whether they want to do an optimized build:
268 AC_ARG_ENABLE(optimized,AC_HELP_STRING([--enable-optimized],[Compile with optimizations enabled (default is NO)]),,enableval=no)
269 if test ${enableval} = "no"
270 then
271         AC_SUBST(ENABLE_OPTIMIZED,[[]])
272 else
273         AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
274 fi
275
276 dnl Spec Benchmarks
277 AC_ARG_ENABLE(spec2000,AC_HELP_STRING([--enable-spec2000],[Compile SPEC 2000 benchmarks (default is NO)]),,enableval=no)
278 if test ${enableval} = "no"
279 then
280         if test -d /home/vadve/shared/benchmarks/speccpu2000/benchspec
281         then
282                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
283                 AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
284         else
285                 AC_SUBST(USE_SPEC,[[]])
286                 AC_SUBST(SPEC_ROOT,[])
287         fi
288 else
289         if test ${enableval} = ""
290         then
291                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
292         else
293                 AC_SUBST(SPEC_ROOT,[${enableval}])
294         fi
295         AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
296 fi
297
298 dnl Precompiled Bytecode Option
299 AC_ARG_ENABLE(precompiled_bytecode,AC_HELP_STRING([--enable-precompiled_bytecode],[Use pre-compiled bytecode (default is NO)]),,enableval=no)
300 if test ${enableval} = "no"
301 then
302         AC_SUBST(UPB,[[]])
303 else
304         AC_SUBST(UPB,[[USE_PRECOMPILED_BYTECODE=1]])
305 fi
306
307 dnl LLC Diff Option
308 AC_ARG_ENABLE(llc_diffs,AC_HELP_STRING([--enable-llc_diffs],[Enable LLC Diffs when testing (default is YES)]),,enableval=yes)
309 if test ${enableval} = "no"
310 then
311         AC_SUBST(DISABLE_LLC_DIFFS,[DISABLE_LLC_DIFFS:=1])
312 else
313         AC_SUBST(DISABLE_LLC_DIFFS,[[]])
314 fi
315
316 dnl JIT Option
317 AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is YES)]),,enableval=default)
318 if test ${enableval} = "no"
319 then
320         AC_SUBST(JIT,[[]])
321 else
322         case $target in
323                 *i*86*)
324                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
325                         ;;
326                 *sparc*)
327                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
328                         ;;
329                 *)
330                         AC_SUBST(JIT,[[]])
331                         ;;
332         esac
333 fi
334
335 dnl Find the LLVM GCC-based C/C++ front end
336 AC_ARG_WITH(llvmgccdir,AC_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),AC_SUBST(LLVMGCCDIR,[$withval]))
337 AC_MSG_CHECKING([for llvm-gcc])
338 LLVM_GCC_CHECK=no
339 if test -d "$LLVMGCCDIR"
340 then
341         if test -x "$LLVMGCCDIR/bin/gcc"
342         then
343                 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
344         fi
345 fi
346 llvmgccwarn=no
347 AC_MSG_RESULT($LLVM_GCC_CHECK)
348 if test "$LLVM_GCC_CHECK" = "no"
349 then
350     llvmgccwarn=yes
351 fi
352 AC_MSG_CHECKING([whether llvm-gcc is sane])
353 LLVM_GCC_SANE=no
354 if test -x "$LLVM_GCC_CHECK"
355 then
356         cp /dev/null conftest.c
357     "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
358         if test $? -eq 0
359         then
360                 LLVM_GCC_SANE=yes
361         fi
362         rm conftest.c
363         llvmcc1path=`"$LLVM_GCC_CHECK" --print-prog-name=cc1`
364         AC_SUBST(LLVMCC1,$llvmcc1path)
365         llvmcc1pluspath=`"$LLVM_GCC_CHECK" --print-prog-name=cc1plus`
366         AC_SUBST(LLVMCC1PLUS,$llvmcc1pluspath)
367 fi
368 AC_MSG_RESULT($LLVM_GCC_SANE)
369 if test "$LLVM_GCC_SANE" = "no"
370 then
371         llvmgccwarn=yes
372 fi
373
374 dnl Location of the bytecode repository
375 AC_ARG_WITH(bcrepos,AC_HELP_STRING([--with-bcrepos],[Location of Bytecode Repository]),AC_SUBST(BCR,[$withval]),AC_SUBST(BCR,[/home/vadve/lattner/LLVMPrograms]))
376
377 dnl Location of PAPI
378 AC_ARG_WITH(papi,AC_HELP_STRING([--with-papi],[Location of PAPI]),AC_SUBST(PAPIDIR,[$withval]),AC_SUBST(PAPIDIR,[/home/vadve/shared/Sparc/papi-2.3.4.1]))
379
380 dnl Get libtool's idea of what the shared library suffix is.
381 dnl (This is a hack; it relies on undocumented behavior.)
382 AC_MSG_CHECKING([for shared library suffix])
383 eval "SHLIBEXT=$shrext"
384 AC_MSG_RESULT($SHLIBEXT)
385 dnl Propagate it to the Makefiles and config.h (for gccld & bugpoint).
386 AC_SUBST(SHLIBEXT,$SHLIBEXT)
387 AC_DEFINE_UNQUOTED(SHLIBEXT,"$SHLIBEXT",
388                    [Extension that shared libraries have, e.g., ".so".])
389
390 dnl Create the output files
391 AC_OUTPUT(Makefile.config)
392
393 dnl Warn loudly if llvm-gcc was not obviously working
394 if test $llvmgccwarn = yes
395 then
396         AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
397         AC_MSG_WARN([***** appear to be working.])
398         AC_MSG_WARN([***** ])
399         AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
400         AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
401         AC_MSG_WARN([***** but you should be able to build the llvm tools.])
402 fi
403