f8d091ea9612887f3fbded286e6dde2edad2ad9e
[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/External/SPEC/Makefile.spec95)
59 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile)
60 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile.multisrc)
61 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/analyzer/test.in)
62 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/Makefile)
63 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/test.in)
64 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/Makefile)
65 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/test.in)
66 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile)
67 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in)
68 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/Makefile)
69 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/test.in)
70 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/Makefile)
71 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/test.in)
72 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/Makefile)
73 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/test.in)
74 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile)
75 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile.singlesrc)
76 AC_CONFIG_MAKEFILE(tools/Makefile)
77 AC_CONFIG_MAKEFILE(utils/Makefile)
78 AC_CONFIG_MAKEFILE(projects/Makefile)
79
80 dnl Find the install program (needs to be done before canonical stuff)
81 AC_PROG_INSTALL
82
83 dnl Check which host for which we're compiling.  This will tell us which LLVM
84 dnl compiler will be used for compiling SSA into object code.
85 AC_CANONICAL_TARGET
86
87 dnl Set the "OS" Makefile variable based on the system we are building on.
88 dnl We will use the build machine information to set some variables.
89 case $build in
90         *-*-linux*)
91              AC_SUBST(OS,[Linux])
92                          if test -d /home/vadve/lattner/local/x86/llvm-gcc
93                          then
94                            AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
95                          fi
96                  ;;
97
98         *-*-solaris*)
99              AC_SUBST(OS,[SunOS])
100                          if test -d /home/vadve/lattner/local/sparc/llvm-gcc
101                          then
102                    AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
103                          fi
104                  ;;
105
106         *-*-darwin*)
107              AC_SUBST(OS,[Darwin])
108                  ;;
109
110         *)       AC_SUBST(OS,[Unknown])
111                  ;;
112 esac
113
114 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
115 dnl V9, since that is all that we support at the moment, and autoconf will only
116 dnl tell us we're a sparc.
117 case $target in
118         sparc*-*-solaris*)  AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
119                             ;;
120 esac
121
122 dnl Determine what our target architecture is and configure accordingly.
123 dnl This will allow Makefiles to make a distinction between the hardware and
124 dnl the OS.
125 case $target in
126         i*86-*)           AC_SUBST(ARCH,[x86])
127                           ;;
128         sparc*-*)         AC_SUBST(ARCH,[Sparc])
129                           ;;
130         powerpc*-*)       AC_SUBST(ARCH,[PowerPC])
131                           ;;
132         *)                AC_SUBST(ARCH,[Unknown])
133                           ;;
134 esac
135
136 dnl Check for compilation tools
137 AC_PROG_CXX
138 AC_PROG_CC(gcc)
139 AC_PROG_CPP
140
141 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
142 if test "$GCC" != "yes"
143 then
144         AC_MSG_ERROR([gcc required but not found])
145 fi
146 if test "$GXX" != "yes"
147 then
148         AC_MSG_ERROR([g++ required but not found])
149 fi
150
151 dnl Verify that GCC is version 3.0 or higher
152 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
153 if test "$gccmajor" -lt "3"
154 then
155         AC_MSG_ERROR([gcc 3.x required, but you have a lower version])
156 fi
157
158 dnl Check for GNU Make.  We use its extensions too, so don't build without it
159 CHECK_GNU_MAKE
160 if test -z "$_cv_gnu_make_command"
161 then
162         AC_MSG_ERROR([GNU Make required but not found])
163 fi
164
165 dnl Checks for other tools
166 AC_PROG_FLEX
167 AC_PROG_BISON
168 AC_PROG_LIBTOOL
169
170 dnl Checks for tools we can get away with not having:
171 AC_PATH_PROG(DOT,[dot],[true dot])
172 AC_PATH_PROG(ETAGS,[etags],[true etags])
173 dnl Check if we know how to tell etags we are using C++:
174 etags_version=`$ETAGS --version 2>&1`
175 case "$etags_version" in
176         *[Ee]xuberant*) ETAGSFLAGS="--language-force=c++" ;;
177         *GNU\ Emacs*) ETAGSFLAGS="-l c++" ;;
178         *) ETAGSFLAGS="" ;;
179 esac
180 AC_SUBST(ETAGSFLAGS,$ETAGSFLAGS)
181 AC_PATH_PROG(PYTHON,[python],[true python])
182 if test "$PYTHON" = "false"
183 then
184         AC_MSG_WARN([Python is required for the test suite, but it was not found])
185 fi
186 AC_PATH_PROG(QMTEST,[qmtest],[true qmtest])
187 if test "$QMTEST" = "false"
188 then
189         AC_MSG_WARN([QMTest is required for the test suite, but it was not found])
190 fi
191
192 dnl Verify that the version of python available is high enough for qmtest
193 pyversion=`$PYTHON -V 2>&1 | cut -d\  -f2`
194 pymajor=`echo $pyversion | cut -d. -f1`
195 pyminor=`echo $pyversion | cut -d. -f2`
196
197 if test "$pymajor" -ge "2"
198 then
199         if test "$pymajor" -eq "2"
200         then
201                 if test "$pyminor" -lt "2"
202                 then
203                         AC_MSG_WARN([QMTest requires Python 2.2 or later])
204                 fi
205         fi
206 else
207         AC_MSG_WARN([QMTest requires Python 2.2 or later])
208 fi
209
210 dnl Verify that the source directory is valid
211 AC_CONFIG_SRCDIR(["Makefile.config.in"])
212
213 dnl Checks for libraries:
214 dnl libelf is for sparc only; we can ignore it if we don't have it
215 AC_CHECK_LIB(elf, elf_begin)
216
217 dnl dlopen() is required for plugin support.
218 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]))
219
220 dnl mallinfo is optional; the code can compile (minus features) without it
221 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
222
223 dnl pthread locking functions are optional - but llvm will not be thread-safe
224 dnl without locks.
225 AC_SEARCH_LIBS(pthread_mutex_lock,pthread,HAVE_PTHREAD_MUTEX_LOCK=1,HAVE_PTHREAD_MUTEX_LOCK=0)
226 AC_SUBST(HAVE_PTHREAD_MUTEX_LOCK)
227
228 dnl Checks for header files.
229 dnl We don't check for ancient stuff or things that are guaranteed to be there
230 dnl by the C++ standard. We always use the <cfoo> versions of <foo.h> C headers.
231 AC_HEADER_STDC
232 AC_HEADER_SYS_WAIT
233
234 dnl Checks for POSIX and other various system-specific header files
235 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h malloc.h sys/mman.h sys/resource.h dlfcn.h link.h execinfo.h)
236
237 dnl Check for types
238 AC_TYPE_PID_T
239 AC_TYPE_SIZE_T
240 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
241 AC_CHECK_TYPES([uint64_t],,AC_MSG_ERROR([Type uint64_t required but not found]))
242 AC_HEADER_TIME
243 AC_STRUCT_TM
244
245 dnl Check for various C features
246 AC_C_PRINTF_A
247
248 dnl Check for the endianness of the target
249 AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little]))
250
251 dnl Check for C++ extensions
252 AC_CXX_HAVE_HASH_MAP
253 AC_CXX_HAVE_HASH_SET
254 AC_CXX_HAVE_STD_ITERATOR
255 AC_CXX_HAVE_BI_ITERATOR
256 AC_CXX_HAVE_FWD_ITERATOR
257
258 dnl Checks for library functions.
259 AC_FUNC_ALLOCA
260 AC_FUNC_MMAP
261 if test "$ac_cv_func_mmap_fixed_mapped" = "no"
262 then
263         AC_MSG_ERROR([mmap() required but not found])
264 fi
265 AC_FUNC_MMAP_FILE
266 if test "$ac_cv_func_mmap_file" = "no"
267 then
268         AC_MSG_ERROR([mmap() of files required but not found])
269 fi
270 AC_HEADER_MMAP_ANONYMOUS
271 AC_TYPE_SIGNAL
272 AC_CHECK_FUNCS(getcwd gettimeofday strdup strtoq strtoll backtrace)
273 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
274
275 dnl Determine if the linker supports the -R option.
276 AC_LINK_USE_R
277
278 dnl --enable/--with command-line options:
279 dnl Check whether they want to do an optimized build:
280 AC_ARG_ENABLE(optimized,AC_HELP_STRING([--enable-optimized],[Compile with optimizations enabled (default is NO)]),,enableval=no)
281 if test ${enableval} = "no"
282 then
283         AC_SUBST(ENABLE_OPTIMIZED,[[]])
284 else
285         AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
286 fi
287
288 dnl Spec 2000 Benchmarks
289 AC_ARG_ENABLE(spec2000,AC_HELP_STRING([--enable-spec2000],[Compile SPEC 2000 benchmarks (default is NO)]),,enableval=no)
290 if test ${enableval} = "no"
291 then
292         if test -d /home/vadve/shared/benchmarks/speccpu2000/benchspec
293         then
294                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
295                 AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
296         else
297                 AC_SUBST(USE_SPEC,[[]])
298                 AC_SUBST(SPEC_ROOT,[])
299         fi
300 else
301         if test ${enableval} = ""
302         then
303                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
304         else
305                 AC_SUBST(SPEC_ROOT,[${enableval}])
306         fi
307         AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
308 fi
309
310 dnl Spec 95 Benchmarks
311 AC_ARG_ENABLE(spec95,AC_HELP_STRING([--enable-spec95],[Compile SPEC 95 benchmarks (default is NO)]),,enableval=no)
312 if test ${enableval} = "no"
313 then
314         if test -d /home/vadve/shared/benchmarks/spec95/benchspec
315         then
316                 AC_SUBST(SPEC95_ROOT,[/home/vadve/shared/benchmarks/spec95/benchspec])
317                 AC_SUBST(USE_SPEC95,[[USE_SPEC95=1]])
318         else
319                 AC_SUBST(USE_SPEC95,[[]])
320                 AC_SUBST(SPEC95_ROOT,[])
321         fi
322 else
323         if test ${enableval} = ""
324         then
325                 AC_SUBST(SPEC95_ROOT,[/home/vadve/shared/benchmarks/spec95/benchspec])
326         else
327                 AC_SUBST(SPEC95_ROOT,[${enableval}])
328         fi
329         AC_SUBST(USE_SPEC95,[[USE_SPEC95=1]])
330 fi
331
332 dnl Povray External Benchmark
333 AC_ARG_ENABLE(povray,AC_HELP_STRING([--enable-povray],[Compile Povray benchmark (default is NO)]),,enableval=no)
334 if test ${enableval} = "no"
335 then
336         if test -d /home/vadve/criswell/Downloads/povray-3.50c
337         then
338                 AC_SUBST(POVRAY_ROOT,[/home/vadve/criswell/Downloads/povray-3.50c])
339                 AC_SUBST(USE_POVRAY,[[USE_POVRAY=1]])
340         else
341                 AC_SUBST(USE_POVRAY,[[]])
342                 AC_SUBST(POVRAY_ROOT,[])
343         fi
344 else
345         if test ${enableval} = ""
346         then
347                 AC_SUBST(POVRAY_ROOT,[/home/vadve/criswell/Downloads/povray-3.50c])
348         else
349                 AC_SUBST(POVRAY_ROOT,[${enableval}])
350         fi
351         AC_SUBST(USE_POVRAY,[[USE_POVRAY=1]])
352 fi
353
354
355 dnl Precompiled Bytecode Option
356 AC_ARG_ENABLE(precompiled_bytecode,AC_HELP_STRING([--enable-precompiled_bytecode],[Use pre-compiled bytecode (default is NO)]),,enableval=no)
357 if test ${enableval} = "no"
358 then
359         AC_SUBST(UPB,[[]])
360 else
361         AC_SUBST(UPB,[[USE_PRECOMPILED_BYTECODE=1]])
362 fi
363
364 dnl LLC Diff Option
365 AC_ARG_ENABLE(llc_diffs,AC_HELP_STRING([--enable-llc_diffs],[Enable LLC Diffs when testing (default is YES)]),,enableval=yes)
366 if test ${enableval} = "no"
367 then
368         AC_SUBST(DISABLE_LLC_DIFFS,[DISABLE_LLC_DIFFS:=1])
369 else
370         AC_SUBST(DISABLE_LLC_DIFFS,[[]])
371 fi
372
373 dnl JIT Option
374 AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is YES)]),,enableval=default)
375 if test ${enableval} = "no"
376 then
377         AC_SUBST(JIT,[[]])
378 else
379         case $target in
380                 *i*86*)
381                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
382                         ;;
383                 *sparc*)
384                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
385                         ;;
386                 *)
387                         AC_SUBST(JIT,[[]])
388                         ;;
389         esac
390 fi
391
392 dnl Find the LLVM GCC-based C/C++ front end
393 AC_ARG_WITH(llvmgccdir,AC_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),AC_SUBST(LLVMGCCDIR,[$withval]))
394 AC_MSG_CHECKING([for llvm-gcc])
395 LLVM_GCC_CHECK=no
396 if test -d "$LLVMGCCDIR"
397 then
398         if test -x "$LLVMGCCDIR/bin/gcc"
399         then
400                 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
401         fi
402 fi
403 llvmgccwarn=no
404 AC_MSG_RESULT($LLVM_GCC_CHECK)
405 if test "$LLVM_GCC_CHECK" = "no"
406 then
407     llvmgccwarn=yes
408 fi
409 AC_MSG_CHECKING([whether llvm-gcc is sane])
410 LLVM_GCC_SANE=no
411 if test -x "$LLVM_GCC_CHECK"
412 then
413         cp /dev/null conftest.c
414     "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
415         if test $? -eq 0
416         then
417                 LLVM_GCC_SANE=yes
418         fi
419         rm conftest.c
420         llvmcc1path=`"$LLVM_GCC_CHECK" --print-prog-name=cc1`
421         AC_SUBST(LLVMCC1,$llvmcc1path)
422         llvmcc1pluspath=`"$LLVM_GCC_CHECK" --print-prog-name=cc1plus`
423         AC_SUBST(LLVMCC1PLUS,$llvmcc1pluspath)
424 fi
425 AC_MSG_RESULT($LLVM_GCC_SANE)
426 if test "$LLVM_GCC_SANE" = "no"
427 then
428         llvmgccwarn=yes
429 fi
430
431 dnl Location of the bytecode repository
432 AC_ARG_WITH(bcrepos,AC_HELP_STRING([--with-bcrepos],[Location of Bytecode Repository]),AC_SUBST(BCR,[$withval]),AC_SUBST(BCR,[/home/vadve/lattner/LLVMPrograms]))
433
434 dnl Location of PAPI
435 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]))
436
437 dnl Get libtool's idea of what the shared library suffix is.
438 dnl (This is a hack; it relies on undocumented behavior.)
439 AC_MSG_CHECKING([for shared library suffix])
440 eval "SHLIBEXT=$shrext"
441 AC_MSG_RESULT($SHLIBEXT)
442 dnl Propagate it to the Makefiles and config.h (for gccld & bugpoint).
443 AC_SUBST(SHLIBEXT,$SHLIBEXT)
444 AC_DEFINE_UNQUOTED(SHLIBEXT,"$SHLIBEXT",
445                    [Extension that shared libraries have, e.g., ".so".])
446
447 dnl Create the output files
448 AC_OUTPUT(Makefile.config
449  include/Support/iterator
450  include/Support/hash_map
451  include/Support/hash_set
452  include/Support/ThreadSupport.h)
453
454 dnl Warn loudly if llvm-gcc was not obviously working
455 if test $llvmgccwarn = yes
456 then
457         AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
458         AC_MSG_WARN([***** appear to be working.])
459         AC_MSG_WARN([***** ])
460         AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
461         AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
462         AC_MSG_WARN([***** but you should be able to build the llvm tools.])
463 fi
464