Ok, really, for the last time, llvm-gcc is dead Jim.
[oota-llvm.git] / autoconf / configure.ac
1 dnl === configure.ac --------------------------------------------------------===
2 dnl                     The LLVM Compiler Infrastructure
3 dnl
4 dnl This file is distributed under the University of Illinois Open Source
5 dnl License. See LICENSE.TXT for details.
6 dnl
7 dnl===-----------------------------------------------------------------------===
8 dnl This is the LLVM configuration script. It is processed by the autoconf
9 dnl program to produce a script named configure. This script contains the
10 dnl configuration checks that LLVM needs in order to support multiple platforms.
11 dnl This file is composed of 10 sections per the recommended organization of
12 dnl autoconf input defined in the autoconf documentation. As this file evolves,
13 dnl please keep the various types of checks within their sections. The sections
14 dnl are as follows:
15 dnl
16 dnl SECTION 1: Initialization & Setup
17 dnl SECTION 2: Architecture, target, and host checks
18 dnl SECTION 3: Command line arguments for the configure script.
19 dnl SECTION 4: Check for programs we need and that they are the right version
20 dnl SECTION 5: Check for libraries
21 dnl SECTION 6: Check for header files
22 dnl SECTION 7: Check for types and structures
23 dnl SECTION 8: Check for specific functions needed
24 dnl SECTION 9: Additional checks, variables, etc.
25 dnl SECTION 10: Specify the output files and generate it
26 dnl
27 dnl===-----------------------------------------------------------------------===
28 dnl===
29 dnl=== SECTION 1: Initialization & Setup
30 dnl===
31 dnl===-----------------------------------------------------------------------===
32 dnl Initialize autoconf and define the package name, version number and
33 dnl address for reporting bugs.
34 AC_INIT([LLVM],[3.5svn],[http://llvm.org/bugs/])
35 AC_DEFINE([LLVM_VERSION_MAJOR], [3], [Major version of the LLVM API])
36 AC_DEFINE([LLVM_VERSION_MINOR], [5], [Minor version of the LLVM API])
37
38 dnl Provide a copyright substitution and ensure the copyright notice is included
39 dnl in the output of --version option of the generated configure script.
40 AC_SUBST(LLVM_COPYRIGHT,["Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign."])
41 AC_COPYRIGHT([Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign.])
42
43 dnl Indicate that we require autoconf 2.60 or later.
44 AC_PREREQ(2.60)
45
46 dnl Verify that the source directory is valid. This makes sure that we are
47 dnl configuring LLVM and not some other package (it validates --srcdir argument)
48 AC_CONFIG_SRCDIR([lib/IR/Module.cpp])
49
50 dnl Place all of the extra autoconf files into the config subdirectory. Tell
51 dnl various tools where the m4 autoconf macros are.
52 AC_CONFIG_AUX_DIR([autoconf])
53
54 dnl Quit if the source directory has already been configured.
55 dnl NOTE: This relies upon undocumented autoconf behavior.
56 if test ${srcdir} != "." ; then
57   if test -f ${srcdir}/include/llvm/Config/config.h ; then
58     AC_MSG_ERROR([Already configured in ${srcdir}])
59   fi
60 fi
61
62 dnl Default to empty (i.e. assigning the null string to) CFLAGS and CXXFLAGS,
63 dnl instead of the autoconf default (for example, '-g -O2' for CC=gcc).
64 : ${CFLAGS=}
65 : ${CXXFLAGS=}
66
67 dnl We need to check for the compiler up here to avoid anything else
68 dnl starting with a different one.
69 AC_PROG_CC(clang gcc)
70 AC_PROG_CXX(clang++ g++)
71 AC_PROG_CPP
72
73 dnl If CXX is Clang, check that it can find and parse C++ standard library
74 dnl headers.
75 if test "$CXX" = "clang++" ; then
76   AC_MSG_CHECKING([whether clang works])
77   AC_LANG_PUSH([C++])
78   dnl Note that space between 'include' and '(' is required.  There's a broken
79   dnl regex in aclocal that otherwise will think that we call m4's include
80   dnl builtin.
81   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <limits>
82 #if __has_include (<cxxabi.h>)
83 #include <cxxabi.h>
84 #endif
85 #if __has_include (<unwind.h>)
86 #include <unwind.h>
87 #endif
88 ]])],
89 [
90   AC_MSG_RESULT([yes])
91 ],
92 [
93   AC_MSG_RESULT([no])
94   AC_MSG_ERROR([Selected compiler could not find or parse C++ standard library headers.  Rerun with CC=c-compiler CXX=c++-compiler ./configure ...])
95 ])
96   AC_LANG_POP([C++])
97 fi
98
99 dnl Configure all of the projects present in our source tree. While we could
100 dnl just AC_CONFIG_SUBDIRS on the set of directories in projects that have a
101 dnl configure script, that usage of the AC_CONFIG_SUBDIRS macro is deprecated.
102 dnl Instead we match on the known projects.
103
104 dnl
105 dnl One tricky part of doing this is that some projects depend upon other
106 dnl projects.  For example, several projects rely upon the LLVM test suite.
107 dnl We want to configure those projects first so that their object trees are
108 dnl created before running the configure scripts of projects that depend upon
109 dnl them.
110 dnl
111
112 dnl Several projects use the LLVM test suite, so configure it next.
113 if test -d ${srcdir}/projects/test-suite ; then
114   AC_CONFIG_SUBDIRS([projects/test-suite])
115 fi
116
117 dnl llvm-test is the old name of the test-suite, kept here for backwards
118 dnl compatibility
119 if test -d ${srcdir}/projects/llvm-test ; then
120   AC_CONFIG_SUBDIRS([projects/llvm-test])
121 fi
122
123 dnl Some projects use poolalloc; configure that next
124 if test -d ${srcdir}/projects/poolalloc ; then
125   AC_CONFIG_SUBDIRS([projects/poolalloc])
126 fi
127
128 if test -d ${srcdir}/projects/llvm-poolalloc ; then
129   AC_CONFIG_SUBDIRS([projects/llvm-poolalloc])
130 fi
131
132 dnl Check for all other projects
133 for i in `ls ${srcdir}/projects`
134 do
135   if test -d ${srcdir}/projects/${i} ; then
136     case ${i} in
137       sample)       AC_CONFIG_SUBDIRS([projects/sample])    ;;
138       privbracket)  AC_CONFIG_SUBDIRS([projects/privbracket]) ;;
139       safecode)     AC_CONFIG_SUBDIRS([projects/safecode]) ;;
140       compiler-rt)       ;;
141       test-suite)     ;;
142       llvm-test)      ;;
143       poolalloc)      ;;
144       llvm-poolalloc) ;;
145       *)
146         AC_MSG_WARN([Unknown project (${i}) won't be configured automatically])
147         ;;
148     esac
149   fi
150 done
151
152 dnl Disable the build of polly, even if it is checked out into tools/polly.
153 AC_ARG_ENABLE(polly,
154               AS_HELP_STRING([--enable-polly],
155                              [Use polly if available (default is YES)]),,
156                              enableval=default)
157 case "$enableval" in
158   yes) AC_SUBST(ENABLE_POLLY,[1]) ;;
159   no)  AC_SUBST(ENABLE_POLLY,[0]) ;;
160   default) AC_SUBST(ENABLE_POLLY,[1]) ;;
161   *) AC_MSG_ERROR([Invalid setting for --enable-polly. Use "yes" or "no"]) ;;
162 esac
163
164
165 dnl Check if polly is checked out into tools/polly and configure it if
166 dnl available.
167 if (test -d ${srcdir}/tools/polly) && (test $ENABLE_POLLY -eq 1) ; then
168   AC_SUBST(LLVM_HAS_POLLY,1)
169   AC_CONFIG_SUBDIRS([tools/polly])
170 fi
171
172 dnl===-----------------------------------------------------------------------===
173 dnl===
174 dnl=== SECTION 2: Architecture, target, and host checks
175 dnl===
176 dnl===-----------------------------------------------------------------------===
177
178 dnl Check the target for which we're compiling and the host that will do the
179 dnl compilations. This will tell us which LLVM compiler will be used for
180 dnl compiling SSA into object code. This needs to be done early because
181 dnl following tests depend on it.
182 AC_CANONICAL_TARGET
183
184 dnl Determine the platform type and cache its value. This helps us configure
185 dnl the System library to the correct build platform.
186 AC_CACHE_CHECK([type of operating system we're going to host on],
187                [llvm_cv_os_type],
188 [case $host in
189   *-*-aix*)
190     llvm_cv_link_all_option="-Wl,--whole-archive"
191     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
192     llvm_cv_os_type="AIX"
193     llvm_cv_platform_type="Unix" ;;
194   *-*-irix*)
195     llvm_cv_link_all_option="-Wl,--whole-archive"
196     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
197     llvm_cv_os_type="IRIX"
198     llvm_cv_platform_type="Unix" ;;
199   *-*-cygwin*)
200     llvm_cv_link_all_option="-Wl,--whole-archive"
201     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
202     llvm_cv_os_type="Cygwin"
203     llvm_cv_platform_type="Unix" ;;
204   *-*-darwin*)
205     llvm_cv_link_all_option="-Wl,-all_load"
206     llvm_cv_no_link_all_option="-Wl,-noall_load"
207     llvm_cv_os_type="Darwin"
208     llvm_cv_platform_type="Unix" ;;
209   *-*-minix*)
210     llvm_cv_link_all_option="-Wl,-all_load"
211     llvm_cv_no_link_all_option="-Wl,-noall_load"
212     llvm_cv_os_type="Minix"
213     llvm_cv_platform_type="Unix" ;;
214   *-*-freebsd*)
215     llvm_cv_link_all_option="-Wl,--whole-archive"
216     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
217     llvm_cv_os_type="FreeBSD"
218     llvm_cv_platform_type="Unix" ;;
219   *-*-kfreebsd-gnu)
220     llvm_cv_link_all_option="-Wl,--whole-archive"
221     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
222     llvm_cv_os_type="GNU/kFreeBSD"
223     llvm_cv_platform_type="Unix" ;;
224   *-*-openbsd*)
225     llvm_cv_link_all_option="-Wl,--whole-archive"
226     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
227     llvm_cv_os_type="OpenBSD"
228     llvm_cv_platform_type="Unix" ;;
229   *-*-netbsd*)
230     llvm_cv_link_all_option="-Wl,--whole-archive"
231     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
232     llvm_cv_os_type="NetBSD"
233     llvm_cv_platform_type="Unix" ;;
234   *-*-dragonfly*)
235     llvm_cv_link_all_option="-Wl,--whole-archive"
236     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
237     llvm_cv_os_type="DragonFly"
238     llvm_cv_platform_type="Unix" ;;
239   *-*-hpux*)
240     llvm_cv_link_all_option="-Wl,--whole-archive"
241     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
242     llvm_cv_os_type="HP-UX"
243     llvm_cv_platform_type="Unix" ;;
244   *-*-interix*)
245     llvm_cv_link_all_option="-Wl,--whole-archive"
246     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
247     llvm_cv_os_type="Interix"
248     llvm_cv_platform_type="Unix" ;;
249   *-*-linux*)
250     llvm_cv_link_all_option="-Wl,--whole-archive"
251     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
252     llvm_cv_os_type="Linux"
253     llvm_cv_platform_type="Unix" ;;
254   *-*-gnu*)
255     llvm_cv_link_all_option="-Wl,--whole-archive"
256     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
257     llvm_cv_os_type="GNU"
258     llvm_cv_platform_type="Unix" ;;
259   *-*-solaris*)
260     llvm_cv_link_all_option="-Wl,-z,allextract"
261     llvm_cv_no_link_all_option="-Wl,-z,defaultextract"
262     llvm_cv_os_type="SunOS"
263     llvm_cv_platform_type="Unix" ;;
264   *-*-auroraux*)
265     llvm_cv_link_all_option="-Wl,-z,allextract"
266     llvm_cv_link_all_option="-Wl,-z,defaultextract"
267     llvm_cv_os_type="AuroraUX"
268     llvm_cv_platform_type="Unix" ;;
269   *-*-win32*)
270     llvm_cv_link_all_option="-Wl,--whole-archive"
271     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
272     llvm_cv_os_type="Win32"
273     llvm_cv_platform_type="Win32" ;;
274   *-*-mingw*)
275     llvm_cv_link_all_option="-Wl,--whole-archive"
276     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
277     llvm_cv_os_type="MingW"
278     llvm_cv_platform_type="Win32" ;;
279   *-*-haiku*)
280     llvm_cv_link_all_option="-Wl,--whole-archive"
281     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
282     llvm_cv_os_type="Haiku"
283     llvm_cv_platform_type="Unix" ;;
284   *-unknown-eabi*)
285     llvm_cv_link_all_option="-Wl,--whole-archive"
286     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
287     llvm_cv_os_type="Freestanding"
288     llvm_cv_platform_type="Unix" ;;
289   *-unknown-elf*)
290     llvm_cv_link_all_option="-Wl,--whole-archive"
291     llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
292     llvm_cv_os_type="Freestanding"
293     llvm_cv_platform_type="Unix" ;;
294   *)
295     llvm_cv_link_all_option=""
296     llvm_cv_no_link_all_option=""
297     llvm_cv_os_type="Unknown"
298     llvm_cv_platform_type="Unknown" ;;
299 esac])
300
301 AC_CACHE_CHECK([type of operating system we're going to target],
302                [llvm_cv_target_os_type],
303 [case $target in
304   *-*-aix*)
305     llvm_cv_target_os_type="AIX" ;;
306   *-*-irix*)
307     llvm_cv_target_os_type="IRIX" ;;
308   *-*-cygwin*)
309     llvm_cv_target_os_type="Cygwin" ;;
310   *-*-darwin*)
311     llvm_cv_target_os_type="Darwin" ;;
312   *-*-minix*)
313     llvm_cv_target_os_type="Minix" ;;
314   *-*-freebsd*)
315     llvm_cv_target_os_type="FreeBSD" ;;
316   *-*-kfreebsd-gnu)
317     llvm_cv_target_os_type="GNU/kFreeBSD" ;;
318   *-*-openbsd*)
319     llvm_cv_target_os_type="OpenBSD" ;;
320   *-*-netbsd*)
321     llvm_cv_target_os_type="NetBSD" ;;
322   *-*-dragonfly*)
323     llvm_cv_target_os_type="DragonFly" ;;
324   *-*-hpux*)
325     llvm_cv_target_os_type="HP-UX" ;;
326   *-*-interix*)
327     llvm_cv_target_os_type="Interix" ;;
328   *-*-linux*)
329     llvm_cv_target_os_type="Linux" ;;
330   *-*-gnu*)
331     llvm_cv_target_os_type="GNU" ;;
332   *-*-solaris*)
333     llvm_cv_target_os_type="SunOS" ;;
334   *-*-auroraux*)
335     llvm_cv_target_os_type="AuroraUX" ;;
336   *-*-win32*)
337     llvm_cv_target_os_type="Win32" ;;
338   *-*-mingw*)
339     llvm_cv_target_os_type="MingW" ;;
340   *-*-haiku*)
341     llvm_cv_target_os_type="Haiku" ;;
342   *-*-rtems*)
343     llvm_cv_target_os_type="RTEMS" ;;
344   *-*-nacl*)
345     llvm_cv_target_os_type="NativeClient" ;;
346   *-unknown-eabi*)
347     llvm_cv_target_os_type="Freestanding" ;;
348   *)
349     llvm_cv_target_os_type="Unknown" ;;
350 esac])
351
352 dnl Make sure we aren't attempting to configure for an unknown system
353 if test "$llvm_cv_os_type" = "Unknown" ; then
354   AC_MSG_ERROR([Operating system is unknown, configure can't continue])
355 fi
356
357 dnl Set the "OS" Makefile variable based on the platform type so the
358 dnl makefile can configure itself to specific build hosts
359 AC_SUBST(OS,$llvm_cv_os_type)
360 AC_SUBST(HOST_OS,$llvm_cv_os_type)
361 AC_SUBST(TARGET_OS,$llvm_cv_target_os_type)
362
363 dnl Set the LINKALL and NOLINKALL Makefile variables based on the platform
364 AC_SUBST(LINKALL,$llvm_cv_link_all_option)
365 AC_SUBST(NOLINKALL,$llvm_cv_no_link_all_option)
366
367 dnl Set the "LLVM_ON_*" variables based on llvm_cv_platform_type
368 dnl This is used by lib/Support to determine the basic kind of implementation
369 dnl to use.
370 case $llvm_cv_platform_type in
371   Unix)
372     AC_DEFINE([LLVM_ON_UNIX],[1],[Define if this is Unixish platform])
373     AC_SUBST(LLVM_ON_UNIX,[1])
374     AC_SUBST(LLVM_ON_WIN32,[0])
375     ;;
376   Win32)
377     AC_DEFINE([LLVM_ON_WIN32],[1],[Define if this is Win32ish platform])
378     AC_SUBST(LLVM_ON_UNIX,[0])
379     AC_SUBST(LLVM_ON_WIN32,[1])
380     ;;
381 esac
382
383 dnl Determine what our target architecture is and configure accordingly.
384 dnl This will allow Makefiles to make a distinction between the hardware and
385 dnl the OS.
386 AC_CACHE_CHECK([target architecture],[llvm_cv_target_arch],
387 [case $target in
388   i?86-*)                 llvm_cv_target_arch="x86" ;;
389   amd64-* | x86_64-*)     llvm_cv_target_arch="x86_64" ;;
390   sparc*-*)               llvm_cv_target_arch="Sparc" ;;
391   powerpc*-*)             llvm_cv_target_arch="PowerPC" ;;
392   arm*-*)                 llvm_cv_target_arch="ARM" ;;
393   aarch64*-*)             llvm_cv_target_arch="AArch64" ;;
394   mips-* | mips64-*)      llvm_cv_target_arch="Mips" ;;
395   mipsel-* | mips64el-*)  llvm_cv_target_arch="Mips" ;;
396   xcore-*)                llvm_cv_target_arch="XCore" ;;
397   msp430-*)               llvm_cv_target_arch="MSP430" ;;
398   hexagon-*)              llvm_cv_target_arch="Hexagon" ;;
399   nvptx-*)                llvm_cv_target_arch="NVPTX" ;;
400   s390x-*)                llvm_cv_target_arch="SystemZ" ;;
401   *)                      llvm_cv_target_arch="Unknown" ;;
402 esac])
403
404 if test "$llvm_cv_target_arch" = "Unknown" ; then
405   AC_MSG_WARN([Configuring LLVM for an unknown target archicture])
406 fi
407
408 dnl Determine the LLVM native architecture for the target
409 case "$llvm_cv_target_arch" in
410     x86)     LLVM_NATIVE_ARCH="X86" ;;
411     x86_64)  LLVM_NATIVE_ARCH="X86" ;;
412     *)       LLVM_NATIVE_ARCH="$llvm_cv_target_arch" ;;
413 esac
414
415 dnl Define a substitution, ARCH, for the target architecture
416 AC_SUBST(ARCH,$llvm_cv_target_arch)
417
418 dnl Determine what our host architecture.
419 dnl This will allow MCJIT regress tests runs only for supported
420 dnl platforms.
421 case $host in
422   i?86-*)                 host_arch="x86" ;;
423   amd64-* | x86_64-*)     host_arch="x86_64" ;;
424   sparc*-*)               host_arch="Sparc" ;;
425   powerpc*-*)             host_arch="PowerPC" ;;
426   arm*-*)                 host_arch="ARM" ;;
427   aarch64*-*)             host_arch="AArch64" ;;
428   mips-* | mips64-*)      host_arch="Mips" ;;
429   mipsel-* | mips64el-*)  host_arch="Mips" ;;
430   xcore-*)                host_arch="XCore" ;;
431   msp430-*)               host_arch="MSP430" ;;
432   hexagon-*)              host_arch="Hexagon" ;;
433   s390x-*)                host_arch="SystemZ" ;;
434   *)                      host_arch="Unknown" ;;
435 esac
436
437 if test "$host_arch" = "Unknown" ; then
438   AC_MSG_WARN([Configuring LLVM for an unknown host archicture])
439 fi
440
441 AC_SUBST(HOST_ARCH,$host_arch)
442
443 dnl Check for build platform executable suffix if we're cross-compiling
444 if test "$cross_compiling" = yes; then
445   AC_SUBST(LLVM_CROSS_COMPILING, [1])
446   AC_BUILD_EXEEXT
447   ac_build_prefix=${build_alias}-
448   AC_CHECK_PROG(BUILD_CXX, ${ac_build_prefix}g++, ${ac_build_prefix}g++)
449   if test -z "$BUILD_CXX"; then
450      AC_CHECK_PROG(BUILD_CXX, g++, g++)
451      if test -z "$BUILD_CXX"; then
452        AC_CHECK_PROG(BUILD_CXX, c++, c++, , , /usr/ucb/c++)
453      fi
454   fi
455 else
456   AC_SUBST(LLVM_CROSS_COMPILING, [0])
457 fi
458
459 dnl Check to see if there's a .svn or .git directory indicating that this
460 dnl build is being done from a checkout. This sets up several defaults for
461 dnl the command line switches. When we build with a checkout directory,
462 dnl we get a debug with assertions turned on. Without, we assume a source
463 dnl release and we get an optimized build without assertions.
464 dnl See --enable-optimized and --enable-assertions below
465 if test -d ".svn" -o -d "${srcdir}/.svn" -o -d ".git" -o -d "${srcdir}/.git"; then
466   cvsbuild="yes"
467   optimize="no"
468   AC_SUBST(CVSBUILD,[[CVSBUILD=1]])
469 else
470   cvsbuild="no"
471   optimize="yes"
472 fi
473
474 dnl===-----------------------------------------------------------------------===
475 dnl===
476 dnl=== SECTION 3: Command line arguments for the configure script.
477 dnl===
478 dnl===-----------------------------------------------------------------------===
479
480 dnl --enable-libcpp : check whether or not to use libc++ on the command line
481 AC_ARG_ENABLE(libcpp,
482               AS_HELP_STRING([--enable-libcpp],
483                              [Use libc++ if available (default is NO)]),,
484                              enableval=default)
485 case "$enableval" in
486   yes) AC_SUBST(ENABLE_LIBCPP,[1]) ;;
487   no)  AC_SUBST(ENABLE_LIBCPP,[0]) ;;
488   default) AC_SUBST(ENABLE_LIBCPP,[0]);;
489   *) AC_MSG_ERROR([Invalid setting for --enable-libcpp. Use "yes" or "no"]) ;;
490 esac
491
492 dnl --enable-cxx11 : check whether or not to use -std=c++11 on the command line
493 AC_ARG_ENABLE(cxx11,
494               AS_HELP_STRING([--enable-cxx11],
495                              [Use c++11 if available (default is NO)]),,
496                              enableval=default)
497 case "$enableval" in
498   yes) AC_SUBST(ENABLE_CXX11,[1]) ;;
499   no)  AC_SUBST(ENABLE_CXX11,[0]) ;;
500   default) AC_SUBST(ENABLE_CXX11,[0]);;
501   *) AC_MSG_ERROR([Invalid setting for --enable-cxx11. Use "yes" or "no"]) ;;
502 esac
503
504 dnl --enable-fission : check whether or not to use -gsplit-dwarf on the command
505 dnl line
506 AC_ARG_ENABLE(split-dwarf,
507               AS_HELP_STRING([--enable-split-dwarf],
508                              [Use split-dwarf if available (default is NO)]),,
509                              enableval=default)
510 case "$enableval" in
511   yes) AC_SUBST(ENABLE_SPLIT_DWARF,[1]) ;;
512   no)  AC_SUBST(ENABLE_SPLIT_DWARF,[0]) ;;
513   default) AC_SUBST(ENABLE_SPLIT_DWARF,[0]);;
514   *) AC_MSG_ERROR([Invalid setting for --enable-split-dwarf. Use "yes" or "no"]) ;;
515 esac
516
517 dnl --enable-clang-arcmt: check whether to enable clang arcmt
518 clang_arcmt="yes"
519 AC_ARG_ENABLE(clang-arcmt,
520               AS_HELP_STRING([--enable-clang-arcmt],
521                              [Enable building of clang ARCMT (default is YES)]),
522                              clang_arcmt="$enableval",
523                              enableval="yes")
524 case "$enableval" in
525   yes) AC_SUBST(ENABLE_CLANG_ARCMT,[1]) ;;
526   no)  AC_SUBST(ENABLE_CLANG_ARCMT,[0]) ;;
527   default) AC_SUBST(ENABLE_CLANG_ARCMT,[1]);;
528   *) AC_MSG_ERROR([Invalid setting for --enable-clang-arcmt. Use "yes" or "no"]) ;;
529 esac
530
531 dnl --enable-clang-static-analyzer: check whether to enable static-analyzer
532 clang_static_analyzer="yes"
533 AC_ARG_ENABLE(clang-static-analyzer,
534               AS_HELP_STRING([--enable-clang-static-analyzer],
535                              [Enable building of clang Static Analyzer (default is YES)]),
536                              clang_static_analyzer="$enableval",
537                              enableval="yes")
538 case "$enableval" in
539   yes) AC_SUBST(ENABLE_CLANG_STATIC_ANALYZER,[1]) ;;
540   no)  
541     if test ${clang_arcmt} != "no" ; then
542       AC_MSG_ERROR([Cannot enable clang ARC Migration Tool while disabling static analyzer.])
543     fi
544     AC_SUBST(ENABLE_CLANG_STATIC_ANALYZER,[0]) 
545     ;;
546   default) AC_SUBST(ENABLE_CLANG_STATIC_ANALYZER,[1]);;
547   *) AC_MSG_ERROR([Invalid setting for --enable-clang-static-analyzer. Use "yes" or "no"]) ;;
548 esac
549
550 dnl --enable-clang-rewriter: check whether to enable clang rewriter
551 AC_ARG_ENABLE(clang-rewriter,
552               AS_HELP_STRING([--enable-clang-rewriter],
553                              [Enable building of clang rewriter (default is YES)]),,
554                              enableval="yes")
555 case "$enableval" in
556   yes) AC_SUBST(ENABLE_CLANG_REWRITER,[1]) ;;
557   no)  
558     if test ${clang_arcmt} != "no" ; then
559       AC_MSG_ERROR([Cannot enable clang ARC Migration Tool while disabling rewriter.])
560     fi
561     if test ${clang_static_analyzer} != "no" ; then
562       AC_MSG_ERROR([Cannot enable clang static analyzer while disabling rewriter.])
563     fi
564     AC_SUBST(ENABLE_CLANG_REWRITER,[0]) 
565     ;;
566   default) AC_SUBST(ENABLE_CLANG_REWRITER,[1]);;
567   *) AC_MSG_ERROR([Invalid setting for --enable-clang-rewriter. Use "yes" or "no"]) ;;
568 esac
569
570 dnl --enable-optimized : check whether they want to do an optimized build:
571 AC_ARG_ENABLE(optimized, AS_HELP_STRING(
572  --enable-optimized,[Compile with optimizations enabled (default is NO)]),,enableval=$optimize)
573 if test ${enableval} = "no" ; then
574   AC_SUBST(ENABLE_OPTIMIZED,[[]])
575 else
576   AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
577 fi
578
579 dnl --enable-profiling : check whether they want to do a profile build:
580 AC_ARG_ENABLE(profiling, AS_HELP_STRING(
581  --enable-profiling,[Compile with profiling enabled (default is NO)]),,enableval="no")
582 if test ${enableval} = "no" ; then
583   AC_SUBST(ENABLE_PROFILING,[[]])
584 else
585   AC_SUBST(ENABLE_PROFILING,[[ENABLE_PROFILING=1]])
586 fi
587
588 dnl --enable-assertions : check whether they want to turn on assertions or not:
589 AC_ARG_ENABLE(assertions,AS_HELP_STRING(
590   --enable-assertions,[Compile with assertion checks enabled (default is YES)]),, enableval="yes")
591 if test ${enableval} = "yes" ; then
592   AC_SUBST(DISABLE_ASSERTIONS,[[]])
593 else
594   AC_SUBST(DISABLE_ASSERTIONS,[[DISABLE_ASSERTIONS=1]])
595 fi
596
597 dnl --enable-werror : check whether we want Werror on by default
598 AC_ARG_ENABLE(werror,AS_HELP_STRING(
599   --enable-werror,[Compile with -Werror enabled (default is NO)]),, enableval="no")
600 case "$enableval" in
601   yes) AC_SUBST(ENABLE_WERROR,[1]) ;;
602   no)  AC_SUBST(ENABLE_WERROR,[0]) ;;
603   default) AC_SUBST(ENABLE_WERROR,[0]);;
604   *) AC_MSG_ERROR([Invalid setting for --enable-werror. Use "yes" or "no"]) ;;
605 esac
606
607 dnl --enable-expensive-checks : check whether they want to turn on expensive debug checks:
608 AC_ARG_ENABLE(expensive-checks,AS_HELP_STRING(
609   --enable-expensive-checks,[Compile with expensive debug checks enabled (default is NO)]),, enableval="no")
610 if test ${enableval} = "yes" ; then
611   AC_SUBST(ENABLE_EXPENSIVE_CHECKS,[[ENABLE_EXPENSIVE_CHECKS=1]])
612   AC_SUBST(EXPENSIVE_CHECKS,[[yes]])
613 else
614   AC_SUBST(ENABLE_EXPENSIVE_CHECKS,[[]])
615   AC_SUBST(EXPENSIVE_CHECKS,[[no]])
616 fi
617
618 dnl --enable-debug-runtime : should runtime libraries have debug symbols?
619 AC_ARG_ENABLE(debug-runtime,
620    AS_HELP_STRING(--enable-debug-runtime,[Build runtime libs with debug symbols (default is NO)]),,enableval=no)
621 if test ${enableval} = "no" ; then
622   AC_SUBST(DEBUG_RUNTIME,[[]])
623 else
624   AC_SUBST(DEBUG_RUNTIME,[[DEBUG_RUNTIME=1]])
625 fi
626
627 dnl --enable-debug-symbols : should even optimized compiler libraries
628 dnl have debug symbols?
629 AC_ARG_ENABLE(debug-symbols,
630    AS_HELP_STRING(--enable-debug-symbols,[Build compiler with debug symbols (default is NO if optimization is on and YES if it's off)]),,enableval=no)
631 if test ${enableval} = "no" ; then
632   AC_SUBST(DEBUG_SYMBOLS,[[]])
633 else
634   AC_SUBST(DEBUG_SYMBOLS,[[DEBUG_SYMBOLS=1]])
635 fi
636
637 dnl --enable-keep-symbols : do not strip installed executables
638 AC_ARG_ENABLE(keep-symbols,
639    AS_HELP_STRING(--enable-keep-symbols,[Do not strip installed executables)]),,enableval=no)
640 if test ${enableval} = "no" ; then
641   AC_SUBST(KEEP_SYMBOLS,[[]])
642 else
643   AC_SUBST(KEEP_SYMBOLS,[[KEEP_SYMBOLS=1]])
644 fi
645
646 dnl --enable-jit: check whether they want to enable the jit
647 AC_ARG_ENABLE(jit,
648   AS_HELP_STRING(--enable-jit,
649                  [Enable Just In Time Compiling (default is YES)]),,
650   enableval=default)
651 if test ${enableval} = "no"
652 then
653   AC_SUBST(JIT,[[]])
654 else
655   case "$llvm_cv_target_arch" in
656     x86)         AC_SUBST(TARGET_HAS_JIT,1) ;;
657     Sparc)       AC_SUBST(TARGET_HAS_JIT,0) ;;
658     PowerPC)     AC_SUBST(TARGET_HAS_JIT,1) ;;
659     x86_64)      AC_SUBST(TARGET_HAS_JIT,1) ;;
660     ARM)         AC_SUBST(TARGET_HAS_JIT,1) ;;
661     AArch64)     AC_SUBST(TARGET_HAS_JIT,0) ;;
662     Mips)        AC_SUBST(TARGET_HAS_JIT,1) ;;
663     XCore)       AC_SUBST(TARGET_HAS_JIT,0) ;;
664     MSP430)      AC_SUBST(TARGET_HAS_JIT,0) ;;
665     Hexagon)     AC_SUBST(TARGET_HAS_JIT,0) ;;
666     NVPTX)       AC_SUBST(TARGET_HAS_JIT,0) ;;
667     SystemZ)     AC_SUBST(TARGET_HAS_JIT,1) ;;
668     *)           AC_SUBST(TARGET_HAS_JIT,0) ;;
669   esac
670 fi
671
672 dnl Allow enablement of building and installing docs
673 AC_ARG_ENABLE(docs,
674               AS_HELP_STRING([--enable-docs],
675                              [Build documents (default is YES)]),,
676                              enableval=default)
677 case "$enableval" in
678   yes) AC_SUBST(ENABLE_DOCS,[1]) ;;
679   no)  AC_SUBST(ENABLE_DOCS,[0]) ;;
680   default) AC_SUBST(ENABLE_DOCS,[1]) ;;
681   *) AC_MSG_ERROR([Invalid setting for --enable-docs. Use "yes" or "no"]) ;;
682 esac
683
684 dnl Allow enablement of doxygen generated documentation
685 AC_ARG_ENABLE(doxygen,
686               AS_HELP_STRING([--enable-doxygen],
687                              [Build doxygen documentation (default is NO)]),,
688                              enableval=default)
689 case "$enableval" in
690   yes) AC_SUBST(ENABLE_DOXYGEN,[1]) ;;
691   no)  AC_SUBST(ENABLE_DOXYGEN,[0]) ;;
692   default) AC_SUBST(ENABLE_DOXYGEN,[0]) ;;
693   *) AC_MSG_ERROR([Invalid setting for --enable-doxygen. Use "yes" or "no"]) ;;
694 esac
695
696 dnl Allow disablement of threads
697 AC_ARG_ENABLE(threads,
698               AS_HELP_STRING([--enable-threads],
699                              [Use threads if available (default is YES)]),,
700                              enableval=default)
701 case "$enableval" in
702   yes) AC_SUBST(LLVM_ENABLE_THREADS,[1]) ;;
703   no)  AC_SUBST(LLVM_ENABLE_THREADS,[0]) ;;
704   default) AC_SUBST(LLVM_ENABLE_THREADS,[1]) ;;
705   *) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;;
706 esac
707 AC_DEFINE_UNQUOTED([LLVM_ENABLE_THREADS],$LLVM_ENABLE_THREADS,
708                    [Define if threads enabled])
709
710 dnl Allow disablement of pthread.h
711 AC_ARG_ENABLE(pthreads,
712               AS_HELP_STRING([--enable-pthreads],
713                              [Use pthreads if available (default is YES)]),,
714                              enableval=default)
715 case "$enableval" in
716   yes) AC_SUBST(ENABLE_PTHREADS,[1]) ;;
717   no)  AC_SUBST(ENABLE_PTHREADS,[0]) ;;
718   default) AC_SUBST(ENABLE_PTHREADS,[1]) ;;
719   *) AC_MSG_ERROR([Invalid setting for --enable-pthreads. Use "yes" or "no"]) ;;
720 esac
721
722 dnl Allow disablement of zlib
723 AC_ARG_ENABLE(zlib,
724               AS_HELP_STRING([--enable-zlib],
725                              [Use zlib for compression/decompression if
726                               available (default is YES)]),,
727                               enableval=default)
728 case "$enableval" in
729   yes) AC_SUBST(LLVM_ENABLE_ZLIB,[1]) ;;
730   no)  AC_SUBST(LLVM_ENABLE_ZLIB,[0]) ;;
731   default) AC_SUBST(LLVM_ENABLE_ZLIB,[1]) ;;
732   *) AC_MSG_ERROR([Invalid setting for --enable-zlib. Use "yes" or "no"]) ;;
733 esac
734 AC_DEFINE_UNQUOTED([LLVM_ENABLE_ZLIB],$LLVM_ENABLE_ZLIB,
735                    [Define if zlib is enabled])
736
737 dnl Allow building without position independent code
738 AC_ARG_ENABLE(pic,
739   AS_HELP_STRING([--enable-pic],
740                  [Build LLVM with Position Independent Code (default is YES)]),,
741                  enableval=default)
742 case "$enableval" in
743   yes) AC_SUBST(ENABLE_PIC,[1]) ;;
744   no)  AC_SUBST(ENABLE_PIC,[0]) ;;
745   default) AC_SUBST(ENABLE_PIC,[1]) ;;
746   *) AC_MSG_ERROR([Invalid setting for --enable-pic. Use "yes" or "no"]) ;;
747 esac
748 AC_DEFINE_UNQUOTED([ENABLE_PIC],$ENABLE_PIC,
749                    [Define if position independent code is enabled])
750
751 dnl Allow building a shared library and linking tools against it.
752 AC_ARG_ENABLE(shared,
753   AS_HELP_STRING([--enable-shared],
754                  [Build a shared library and link tools against it (default is NO)]),,
755                  enableval=default)
756 case "$enableval" in
757   yes) AC_SUBST(ENABLE_SHARED,[1]) ;;
758   no)  AC_SUBST(ENABLE_SHARED,[0]) ;;
759   default) AC_SUBST(ENABLE_SHARED,[0]) ;;
760   *) AC_MSG_ERROR([Invalid setting for --enable-shared. Use "yes" or "no"]) ;;
761 esac
762
763 dnl Allow libstdc++ is embedded in LLVM.dll.
764 AC_ARG_ENABLE(embed-stdcxx,
765   AS_HELP_STRING([--enable-embed-stdcxx],
766                  [Build a shared library with embedded libstdc++ for Win32 DLL (default is NO)]),,
767                  enableval=default)
768 case "$enableval" in
769   yes) AC_SUBST(ENABLE_EMBED_STDCXX,[1]) ;;
770   no)  AC_SUBST(ENABLE_EMBED_STDCXX,[0]) ;;
771   default) AC_SUBST(ENABLE_EMBED_STDCXX,[0]) ;;
772   *) AC_MSG_ERROR([Invalid setting for --enable-embed-stdcxx. Use "yes" or "no"]) ;;
773 esac
774
775 dnl Enable embedding timestamp information into build.
776 AC_ARG_ENABLE(timestamps,
777   AS_HELP_STRING([--enable-timestamps],
778                  [Enable embedding timestamp information in build (default is YES)]),,
779                  enableval=default)
780 case "$enableval" in
781   yes) AC_SUBST(ENABLE_TIMESTAMPS,[1]) ;;
782   no)  AC_SUBST(ENABLE_TIMESTAMPS,[0]) ;;
783   default) AC_SUBST(ENABLE_TIMESTAMPS,[1]) ;;
784   *) AC_MSG_ERROR([Invalid setting for --enable-timestamps. Use "yes" or "no"]) ;;
785 esac
786 AC_DEFINE_UNQUOTED([ENABLE_TIMESTAMPS],$ENABLE_TIMESTAMPS,
787                    [Define if timestamp information (e.g., __DATE__) is allowed])
788
789 dnl Enable support for showing backtraces.
790 AC_ARG_ENABLE(backtraces, AS_HELP_STRING(
791   [--enable-backtraces],
792   [Enable embedding backtraces on crash (default is YES)]),
793   [case "$enableval" in
794     yes) llvm_cv_enable_backtraces="yes" ;;
795     no)  llvm_cv_enable_backtraces="no"  ;;
796     *) AC_MSG_ERROR([Invalid setting for --enable-backtraces. Use "yes" or "no"]) ;;
797   esac],
798   llvm_cv_enable_backtraces="yes")
799 if test "$llvm_cv_enable_backtraces" = "yes" ; then
800   AC_DEFINE([ENABLE_BACKTRACES],[1],
801             [Define if you want backtraces on crash])
802 fi
803
804 dnl Enable installing platform specific signal handling overrides, for improved
805 dnl CrashRecovery support or interaction with crash reporting software. This
806 dnl support may be inappropriate for some clients embedding LLVM as a library.
807 AC_ARG_ENABLE(crash-overrides, AS_HELP_STRING(
808   [--enable-crash-overrides],
809   [Enable crash handling overrides (default is YES)]),
810   [case "$enableval" in
811     yes) llvm_cv_enable_crash_overrides="yes" ;;
812     no)  llvm_cv_enable_crash_overrides="no"  ;;
813     *) AC_MSG_ERROR([Invalid setting for --enable-crash-overrides. Use "yes" or "no"]) ;;
814   esac],
815   llvm_cv_enable_crash_overrides="yes")
816 if test "$llvm_cv_enable_crash_overrides" = "yes" ; then
817   AC_DEFINE([ENABLE_CRASH_OVERRIDES],[1],
818             [Define to enable crash handling overrides])
819 fi
820
821 dnl Allow specific targets to be specified for building (or not)
822 TARGETS_TO_BUILD=""
823 AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
824     [Build specific host targets: all or target1,target2,... Valid targets are:
825      host, x86, x86_64, sparc, powerpc, arm, aarch64, mips, hexagon,
826      xcore, msp430, nvptx, systemz, r600, and cpp (default=all)]),,
827     enableval=all)
828 if test "$enableval" = host-only ; then
829   enableval=host
830 fi
831 case "$enableval" in
832   all) TARGETS_TO_BUILD="X86 Sparc PowerPC AArch64 ARM Mips XCore MSP430 CppBackend NVPTX Hexagon SystemZ R600" ;;
833   *)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do
834       case "$a_target" in
835         x86)      TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
836         x86_64)   TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
837         sparc)    TARGETS_TO_BUILD="Sparc $TARGETS_TO_BUILD" ;;
838         powerpc)  TARGETS_TO_BUILD="PowerPC $TARGETS_TO_BUILD" ;;
839         aarch64)  TARGETS_TO_BUILD="AArch64 $TARGETS_TO_BUILD" ;;
840         arm)      TARGETS_TO_BUILD="ARM $TARGETS_TO_BUILD" ;;
841         mips)     TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
842         mipsel)   TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
843         mips64)   TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
844         mips64el) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
845         xcore)    TARGETS_TO_BUILD="XCore $TARGETS_TO_BUILD" ;;
846         msp430)   TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;;
847         cpp)      TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;;
848         hexagon)  TARGETS_TO_BUILD="Hexagon $TARGETS_TO_BUILD" ;;
849         nvptx)    TARGETS_TO_BUILD="NVPTX $TARGETS_TO_BUILD" ;;
850         systemz)  TARGETS_TO_BUILD="SystemZ $TARGETS_TO_BUILD" ;;
851         r600)     TARGETS_TO_BUILD="R600 $TARGETS_TO_BUILD" ;;
852         host) case "$llvm_cv_target_arch" in
853             x86)         TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
854             x86_64)      TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
855             Sparc)       TARGETS_TO_BUILD="Sparc $TARGETS_TO_BUILD" ;;
856             PowerPC)     TARGETS_TO_BUILD="PowerPC $TARGETS_TO_BUILD" ;;
857             AArch64)     TARGETS_TO_BUILD="AArch64 $TARGETS_TO_BUILD" ;;
858             ARM)         TARGETS_TO_BUILD="ARM $TARGETS_TO_BUILD" ;;
859             Mips)        TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
860             XCore)       TARGETS_TO_BUILD="XCore $TARGETS_TO_BUILD" ;;
861             MSP430)      TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;;
862             Hexagon)     TARGETS_TO_BUILD="Hexagon $TARGETS_TO_BUILD" ;;
863             NVPTX)       TARGETS_TO_BUILD="NVPTX $TARGETS_TO_BUILD" ;;
864             SystemZ)     TARGETS_TO_BUILD="SystemZ $TARGETS_TO_BUILD" ;;
865             *)       AC_MSG_ERROR([Can not set target to build]) ;;
866           esac ;;
867         *) AC_MSG_ERROR([Unrecognized target $a_target]) ;;
868       esac
869   done
870   ;;
871 esac
872
873 AC_ARG_ENABLE([experimental-targets],AS_HELP_STRING([--enable-experimental-targets],
874     [Build experimental host targets: disable or target1,target2,...
875      (default=disable)]),,
876     enableval=disable)
877
878 if test ${enableval} != "disable"
879 then
880   TARGETS_TO_BUILD="$enableval $TARGETS_TO_BUILD"
881 fi
882
883 AC_SUBST(TARGETS_TO_BUILD,$TARGETS_TO_BUILD)
884
885 dnl Determine whether we are building LLVM support for the native architecture.
886 dnl If so, define LLVM_NATIVE_ARCH to that LLVM target.
887 for a_target in $TARGETS_TO_BUILD; do
888   if test "$a_target" = "$LLVM_NATIVE_ARCH"; then
889     AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCH, $LLVM_NATIVE_ARCH,
890       [LLVM architecture name for the native architecture, if available])
891     LLVM_NATIVE_TARGET="LLVMInitialize${LLVM_NATIVE_ARCH}Target"
892     LLVM_NATIVE_TARGETINFO="LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo"
893     LLVM_NATIVE_TARGETMC="LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC"
894     LLVM_NATIVE_ASMPRINTER="LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter"
895     if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/Makefile ; then
896       LLVM_NATIVE_ASMPARSER="LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser"
897     fi
898     if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/Makefile ; then
899       LLVM_NATIVE_DISASSEMBLER="LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler"
900     fi
901     AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGET, $LLVM_NATIVE_TARGET,
902       [LLVM name for the native Target init function, if available])
903     AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGETINFO, $LLVM_NATIVE_TARGETINFO,
904       [LLVM name for the native TargetInfo init function, if available])
905     AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGETMC, $LLVM_NATIVE_TARGETMC,
906       [LLVM name for the native target MC init function, if available])
907     AC_DEFINE_UNQUOTED(LLVM_NATIVE_ASMPRINTER, $LLVM_NATIVE_ASMPRINTER,
908       [LLVM name for the native AsmPrinter init function, if available])
909     if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/Makefile ; then
910       AC_DEFINE_UNQUOTED(LLVM_NATIVE_ASMPARSER, $LLVM_NATIVE_ASMPARSER,
911        [LLVM name for the native AsmParser init function, if available])
912     fi
913     if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/Makefile ; then
914       AC_DEFINE_UNQUOTED(LLVM_NATIVE_DISASSEMBLER, $LLVM_NATIVE_DISASSEMBLER,
915        [LLVM name for the native Disassembler init function, if available])
916     fi
917   fi
918 done
919
920 dnl Build the LLVM_TARGET and LLVM_... macros for Targets.def and the individual
921 dnl target feature def files.
922 LLVM_ENUM_TARGETS=""
923 LLVM_ENUM_ASM_PRINTERS=""
924 LLVM_ENUM_ASM_PARSERS=""
925 LLVM_ENUM_DISASSEMBLERS=""
926 for target_to_build in $TARGETS_TO_BUILD; do
927   LLVM_ENUM_TARGETS="LLVM_TARGET($target_to_build) $LLVM_ENUM_TARGETS"
928   if test -f ${srcdir}/lib/Target/${target_to_build}/*AsmPrinter.cpp ; then
929     LLVM_ENUM_ASM_PRINTERS="LLVM_ASM_PRINTER($target_to_build) $LLVM_ENUM_ASM_PRINTERS";
930   fi
931   if test -f ${srcdir}/lib/Target/${target_to_build}/AsmParser/Makefile ; then
932     LLVM_ENUM_ASM_PARSERS="LLVM_ASM_PARSER($target_to_build) $LLVM_ENUM_ASM_PARSERS";
933   fi
934   if test -f ${srcdir}/lib/Target/${target_to_build}/Disassembler/Makefile ; then
935     LLVM_ENUM_DISASSEMBLERS="LLVM_DISASSEMBLER($target_to_build) $LLVM_ENUM_DISASSEMBLERS";
936   fi
937 done
938 AC_SUBST(LLVM_ENUM_TARGETS)
939 AC_SUBST(LLVM_ENUM_ASM_PRINTERS)
940 AC_SUBST(LLVM_ENUM_ASM_PARSERS)
941 AC_SUBST(LLVM_ENUM_DISASSEMBLERS)
942
943 dnl Override the option to use for optimized builds.
944 AC_ARG_WITH(optimize-option,
945   AS_HELP_STRING([--with-optimize-option],
946                  [Select the compiler options to use for optimized builds]),,
947                  withval=default)
948 AC_MSG_CHECKING([optimization flags])
949 case "$withval" in
950   default)
951     case "$llvm_cv_os_type" in
952     FreeBSD) optimize_option=-O2 ;;
953     MingW) optimize_option=-O2 ;;
954     *)     optimize_option=-O3 ;;
955     esac ;;
956   *) optimize_option="$withval" ;;
957 esac
958 AC_SUBST(OPTIMIZE_OPTION,$optimize_option)
959 AC_MSG_RESULT([$optimize_option])
960
961 dnl Specify extra build options
962 AC_ARG_WITH(extra-options,
963   AS_HELP_STRING([--with-extra-options],
964                  [Specify additional options to compile LLVM with]),,
965                  withval=default)
966 case "$withval" in
967   default) EXTRA_OPTIONS= ;;
968   *) EXTRA_OPTIONS=$withval ;;
969 esac
970 AC_SUBST(EXTRA_OPTIONS,$EXTRA_OPTIONS)
971
972 dnl Specify extra linker build options
973 AC_ARG_WITH(extra-ld-options,
974   AS_HELP_STRING([--with-extra-ld-options],
975                  [Specify additional options to link LLVM with]),,
976                  withval=default)
977 case "$withval" in
978   default) EXTRA_LD_OPTIONS= ;;
979   *) EXTRA_LD_OPTIONS=$withval ;;
980 esac
981 AC_SUBST(EXTRA_LD_OPTIONS,$EXTRA_LD_OPTIONS)
982
983 dnl Allow specific bindings to be specified for building (or not)
984 AC_ARG_ENABLE([bindings],AS_HELP_STRING([--enable-bindings],
985     [Build specific language bindings: all,auto,none,{binding-name} (default=auto)]),,
986     enableval=default)
987 BINDINGS_TO_BUILD=""
988 case "$enableval" in
989   yes | default | auto) BINDINGS_TO_BUILD="auto" ;;
990   all ) BINDINGS_TO_BUILD="ocaml" ;;
991   none | no) BINDINGS_TO_BUILD="" ;;
992   *)for a_binding in `echo $enableval|sed -e 's/,/ /g' ` ; do
993       case "$a_binding" in
994         ocaml) BINDINGS_TO_BUILD="ocaml $BINDINGS_TO_BUILD" ;;
995         *) AC_MSG_ERROR([Unrecognized binding $a_binding]) ;;
996       esac
997   done
998   ;;
999 esac
1000
1001 dnl Allow the ocaml libdir to be overridden. This could go in a configure
1002 dnl script for bindings/ocaml/configure, except that its auto value depends on
1003 dnl OCAMLC, which is found here to support tests.
1004 AC_ARG_WITH([ocaml-libdir],
1005   [AS_HELP_STRING([--with-ocaml-libdir],
1006     [Specify install location for ocaml bindings (default is stdlib)])],
1007   [],
1008   [withval=auto])
1009 case "$withval" in
1010   auto) with_ocaml_libdir="$withval" ;;
1011   /* | [[A-Za-z]]:[[\\/]]*) with_ocaml_libdir="$withval" ;;
1012   *) AC_MSG_ERROR([Invalid path for --with-ocaml-libdir. Provide full path]) ;;
1013 esac
1014
1015 AC_ARG_WITH(clang-srcdir,
1016   AS_HELP_STRING([--with-clang-srcdir],
1017     [Directory to the out-of-tree Clang source]),,
1018     withval="-")
1019 case "$withval" in
1020   -) clang_src_root="" ;;
1021   /* | [[A-Za-z]]:[[\\/]]*) clang_src_root="$withval" ;;
1022   *) clang_src_root="$ac_pwd/$withval" ;;
1023 esac
1024 AC_SUBST(CLANG_SRC_ROOT,[$clang_src_root])
1025
1026 AC_ARG_WITH(clang-resource-dir,
1027   AS_HELP_STRING([--with-clang-resource-dir],
1028     [Relative directory from the Clang binary for resource files]),,
1029     withval="")
1030 AC_DEFINE_UNQUOTED(CLANG_RESOURCE_DIR,"$withval",
1031                    [Relative directory for resource files])
1032
1033 AC_ARG_WITH(c-include-dirs,
1034   AS_HELP_STRING([--with-c-include-dirs],
1035     [Colon separated list of directories clang will search for headers]),,
1036     withval="")
1037 AC_DEFINE_UNQUOTED(C_INCLUDE_DIRS,"$withval",
1038                    [Directories clang will search for headers])
1039
1040 # Clang normally uses the system c++ headers and libraries. With this option,
1041 # clang will use the ones provided by a gcc installation instead. This option should
1042 # be passed the same value that was used with --prefix when configuring gcc.
1043 AC_ARG_WITH(gcc-toolchain,
1044   AS_HELP_STRING([--with-gcc-toolchain],
1045     [Directory where gcc is installed.]),,
1046     withval="")
1047 AC_DEFINE_UNQUOTED(GCC_INSTALL_PREFIX,"$withval",
1048                    [Directory where gcc is installed.])
1049
1050 AC_ARG_WITH(default-sysroot,
1051   AS_HELP_STRING([--with-default-sysroot],
1052     [Add --sysroot=<path> to all compiler invocations.]),,
1053     withval="")
1054 AC_DEFINE_UNQUOTED(DEFAULT_SYSROOT,"$withval",
1055                    [Default <path> to all compiler invocations for --sysroot=<path>.])
1056
1057 dnl Allow linking of LLVM with GPLv3 binutils code.
1058 AC_ARG_WITH(binutils-include,
1059   AS_HELP_STRING([--with-binutils-include],
1060     [Specify path to binutils/include/ containing plugin-api.h file for gold plugin.]),,
1061   withval=default)
1062 case "$withval" in
1063   default) WITH_BINUTILS_INCDIR=default ;;
1064   /* | [[A-Za-z]]:[[\\/]]*)      WITH_BINUTILS_INCDIR=$withval ;;
1065   *) AC_MSG_ERROR([Invalid path for --with-binutils-include. Provide full path]) ;;
1066 esac
1067 if test "x$WITH_BINUTILS_INCDIR" != xdefault ; then
1068   AC_SUBST(BINUTILS_INCDIR,$WITH_BINUTILS_INCDIR)
1069   if test ! -f "$WITH_BINUTILS_INCDIR/plugin-api.h"; then
1070      echo "$WITH_BINUTILS_INCDIR/plugin-api.h"
1071      AC_MSG_ERROR([Invalid path to directory containing plugin-api.h.]);
1072   fi
1073 fi
1074
1075 dnl Specify the URL where bug reports should be submitted.
1076 AC_ARG_WITH(bug-report-url,
1077   AS_HELP_STRING([--with-bug-report-url],
1078     [Specify the URL where bug reports should be submitted (default=http://llvm.org/bugs/)]),,
1079     withval="http://llvm.org/bugs/")
1080 AC_DEFINE_UNQUOTED(BUG_REPORT_URL,"$withval",
1081                    [Bug report URL.])
1082
1083 dnl --enable-terminfo: check whether the user wants to control use of terminfo:
1084 AC_ARG_ENABLE(terminfo,AS_HELP_STRING(
1085   [--enable-terminfo],
1086   [Query the terminfo database if available (default is YES)]),
1087   [case "$enableval" in
1088     yes) llvm_cv_enable_terminfo="yes" ;;
1089     no)  llvm_cv_enable_terminfo="no"  ;;
1090     *) AC_MSG_ERROR([Invalid setting for --enable-terminfo. Use "yes" or "no"]) ;;
1091   esac],
1092   llvm_cv_enable_terminfo="yes")
1093
1094 dnl --enable-libffi : check whether the user wants to turn off libffi:
1095 AC_ARG_ENABLE(libffi,AS_HELP_STRING(
1096   --enable-libffi,[Check for the presence of libffi (default is NO)]),
1097   [case "$enableval" in
1098     yes) llvm_cv_enable_libffi="yes" ;;
1099     no)  llvm_cv_enable_libffi="no"  ;;
1100     *) AC_MSG_ERROR([Invalid setting for --enable-libffi. Use "yes" or "no"]) ;;
1101   esac],
1102   llvm_cv_enable_libffi=no)
1103
1104 AC_ARG_WITH(internal-prefix,
1105   AS_HELP_STRING([--with-internal-prefix],
1106     [Installation directory for internal files]),,
1107     withval="")
1108 AC_SUBST(INTERNAL_PREFIX,[$withval])
1109
1110 dnl===-----------------------------------------------------------------------===
1111 dnl===
1112 dnl=== SECTION 4: Check for programs we need and that they are the right version
1113 dnl===
1114 dnl===-----------------------------------------------------------------------===
1115
1116 AC_PROG_NM
1117 AC_SUBST(NM)
1118
1119 dnl Check for the tools that the makefiles require
1120 AC_CHECK_GNU_MAKE
1121 AC_PROG_LN_S
1122 AC_PATH_PROG(CMP, [cmp], [cmp])
1123 AC_PATH_PROG(CP, [cp], [cp])
1124 AC_PATH_PROG(DATE, [date], [date])
1125 AC_PATH_PROG(FIND, [find], [find])
1126 AC_PATH_PROG(GREP, [grep], [grep])
1127 AC_PATH_PROG(MKDIR,[mkdir],[mkdir])
1128 AC_PATH_PROG(MV,   [mv],   [mv])
1129 AC_PROG_RANLIB
1130 AC_CHECK_TOOL(AR, ar, false)
1131 AC_PATH_PROG(RM,   [rm],   [rm])
1132 AC_PATH_PROG(SED,  [sed],  [sed])
1133 AC_PATH_PROG(TAR,  [tar],  [gtar])
1134 AC_PATH_PROG(BINPWD,[pwd],  [pwd])
1135
1136 dnl Looking for misc. graph plotting software
1137 AC_PATH_PROG(GRAPHVIZ, [Graphviz], [echo Graphviz])
1138 if test "$GRAPHVIZ" != "echo Graphviz" ; then
1139   AC_DEFINE([HAVE_GRAPHVIZ],[1],[Define if the Graphviz program is available])
1140   dnl If we're targeting for mingw we should emit windows paths, not msys
1141   if test "$llvm_cv_os_type" = "MingW" ; then
1142     GRAPHVIZ=`echo $GRAPHVIZ | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1143   fi
1144   AC_DEFINE_UNQUOTED([LLVM_PATH_GRAPHVIZ],"$GRAPHVIZ${EXEEXT}",
1145    [Define to path to Graphviz program if found or 'echo Graphviz' otherwise])
1146 fi
1147 AC_PATH_PROG(DOT, [dot], [echo dot])
1148 if test "$DOT" != "echo dot" ; then
1149   AC_DEFINE([HAVE_DOT],[1],[Define if the dot program is available])
1150   dnl If we're targeting for mingw we should emit windows paths, not msys
1151   if test "$llvm_cv_os_type" = "MingW" ; then
1152     DOT=`echo $DOT | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1153   fi
1154   AC_DEFINE_UNQUOTED([LLVM_PATH_DOT],"$DOT${EXEEXT}",
1155    [Define to path to dot program if found or 'echo dot' otherwise])
1156 fi
1157 AC_PATH_PROG(FDP, [fdp], [echo fdp])
1158 if test "$FDP" != "echo fdp" ; then
1159   AC_DEFINE([HAVE_FDP],[1],[Define if the neat program is available])
1160   dnl If we're targeting for mingw we should emit windows paths, not msys
1161   if test "$llvm_cv_os_type" = "MingW" ; then
1162     FDP=`echo $FDP | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1163   fi
1164   AC_DEFINE_UNQUOTED([LLVM_PATH_FDP],"$FDP${EXEEXT}",
1165    [Define to path to fdp program if found or 'echo fdp' otherwise])
1166 fi
1167 AC_PATH_PROG(NEATO, [neato], [echo neato])
1168 if test "$NEATO" != "echo neato" ; then
1169   AC_DEFINE([HAVE_NEATO],[1],[Define if the neat program is available])
1170   dnl If we're targeting for mingw we should emit windows paths, not msys
1171   if test "$llvm_cv_os_type" = "MingW" ; then
1172     NEATO=`echo $NEATO | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1173   fi
1174   AC_DEFINE_UNQUOTED([LLVM_PATH_NEATO],"$NEATO${EXEEXT}",
1175    [Define to path to neato program if found or 'echo neato' otherwise])
1176 fi
1177 AC_PATH_PROG(TWOPI, [twopi], [echo twopi])
1178 if test "$TWOPI" != "echo twopi" ; then
1179   AC_DEFINE([HAVE_TWOPI],[1],[Define if the neat program is available])
1180   dnl If we're targeting for mingw we should emit windows paths, not msys
1181   if test "$llvm_cv_os_type" = "MingW" ; then
1182     TWOPI=`echo $TWOPI | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1183   fi
1184   AC_DEFINE_UNQUOTED([LLVM_PATH_TWOPI],"$TWOPI${EXEEXT}",
1185    [Define to path to twopi program if found or 'echo twopi' otherwise])
1186 fi
1187 AC_PATH_PROG(CIRCO, [circo], [echo circo])
1188 if test "$CIRCO" != "echo circo" ; then
1189   AC_DEFINE([HAVE_CIRCO],[1],[Define if the neat program is available])
1190   dnl If we're targeting for mingw we should emit windows paths, not msys
1191   if test "$llvm_cv_os_type" = "MingW" ; then
1192     CIRCO=`echo $CIRCO | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1193   fi
1194   AC_DEFINE_UNQUOTED([LLVM_PATH_CIRCO],"$CIRCO${EXEEXT}",
1195    [Define to path to circo program if found or 'echo circo' otherwise])
1196 fi
1197 AC_PATH_PROGS(GV, [gv gsview32], [echo gv])
1198 if test "$GV" != "echo gv" ; then
1199   AC_DEFINE([HAVE_GV],[1],[Define if the gv program is available])
1200   dnl If we're targeting for mingw we should emit windows paths, not msys
1201   if test "$llvm_cv_os_type" = "MingW" ; then
1202     GV=`echo $GV | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1203   fi
1204   AC_DEFINE_UNQUOTED([LLVM_PATH_GV],"$GV${EXEEXT}",
1205    [Define to path to gv program if found or 'echo gv' otherwise])
1206 fi
1207 AC_PATH_PROG(DOTTY, [dotty], [echo dotty])
1208 if test "$DOTTY" != "echo dotty" ; then
1209   AC_DEFINE([HAVE_DOTTY],[1],[Define if the dotty program is available])
1210   dnl If we're targeting for mingw we should emit windows paths, not msys
1211   if test "$llvm_cv_os_type" = "MingW" ; then
1212     DOTTY=`echo $DOTTY | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1213   fi
1214   AC_DEFINE_UNQUOTED([LLVM_PATH_DOTTY],"$DOTTY${EXEEXT}",
1215    [Define to path to dotty program if found or 'echo dotty' otherwise])
1216 fi
1217 AC_PATH_PROGS(XDOT, [xdot xdot.py], [echo xdot])
1218 if test "$XDOT" != "echo xdot" ; then
1219   AC_DEFINE([HAVE_XDOT],[1],[Define if the xdot program is available])
1220   dnl If we're targeting for mingw we should emit windows paths, not msys
1221   if test "$llvm_cv_os_type" = "MingW" ; then
1222     XDOT=`echo $XDOT | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1223   fi
1224   AC_DEFINE_UNQUOTED([LLVM_PATH_XDOT],"$XDOT${EXEEXT}",
1225    [Define to path to xdot program if found or 'echo xdot' otherwise])
1226 fi
1227
1228 dnl Find the install program
1229 AC_PROG_INSTALL
1230 dnl Prepend src dir to install path dir if it's a relative path
1231 dnl This is a hack for installs that take place in something other
1232 dnl than the top level.
1233 case "$INSTALL" in
1234  [[\\/$]]* | ?:[[\\/]]* ) ;;
1235  *)  INSTALL="\\\$(TOPSRCDIR)/$INSTALL" ;;
1236 esac
1237
1238 dnl Checks for documentation and testing tools that we can do without. If these
1239 dnl are not found then they are set to "true" which always succeeds but does
1240 dnl nothing. This just lets the build output show that we could have done
1241 dnl something if the tool was available.
1242 AC_PATH_PROG(BZIP2, [bzip2])
1243 AC_PATH_PROG(CAT, [cat])
1244 AC_PATH_PROG(DOXYGEN, [doxygen])
1245 AC_PATH_PROG(GROFF, [groff])
1246 AC_PATH_PROG(GZIPBIN, [gzip])
1247 AC_PATH_PROG(PDFROFF, [pdfroff])
1248 AC_PATH_PROG(ZIP, [zip])
1249 AC_PATH_PROGS(OCAMLC, [ocamlc])
1250 AC_PATH_PROGS(OCAMLOPT, [ocamlopt])
1251 AC_PATH_PROGS(OCAMLDEP, [ocamldep])
1252 AC_PATH_PROGS(OCAMLDOC, [ocamldoc])
1253 AC_PATH_PROGS(GAS, [gas as])
1254
1255 dnl Get the version of the linker in use.
1256 AC_LINK_GET_VERSION
1257
1258 dnl Determine whether the linker supports the -R option.
1259 AC_LINK_USE_R
1260
1261 dnl Determine whether the compiler supports the -rdynamic option.
1262 AC_LINK_EXPORT_DYNAMIC
1263
1264 dnl Determine whether the linker supports the --version-script option.
1265 AC_LINK_VERSION_SCRIPT
1266
1267 dnl Check for libtool and the library that has dlopen function (which must come
1268 dnl before the AC_PROG_LIBTOOL check in order to enable dlopening libraries with
1269 dnl libtool).
1270 AC_LIBTOOL_DLOPEN
1271 AC_LIB_LTDL
1272
1273 AC_MSG_CHECKING([tool compatibility])
1274
1275 dnl Ensure that compilation tools are GCC or a GNU compatible compiler such as
1276 dnl ICC; we use GCC specific options in the makefiles so the compiler needs
1277 dnl to support those options.
1278 dnl "icc" emits gcc signatures
1279 dnl "icc -no-gcc" emits no gcc signature BUT is still compatible
1280 ICC=no
1281 IXX=no
1282 case $CC in
1283   icc*|icpc*)
1284     ICC=yes
1285     IXX=yes
1286     ;;
1287    *)
1288     ;;
1289 esac
1290
1291 if test "$GCC" != "yes" && test "$ICC" != "yes"
1292 then
1293   AC_MSG_ERROR([gcc|icc required but not found])
1294 fi
1295
1296 dnl Ensure that compilation tools are compatible with GCC extensions
1297 if test "$GXX" != "yes" && test "$IXX" != "yes"
1298 then
1299   AC_MSG_ERROR([g++|clang++|icc required but not found])
1300 fi
1301
1302 dnl Verify that GCC is version 3.0 or higher
1303 if test "$GCC" = "yes"
1304 then
1305   AC_COMPILE_IFELSE(
1306 [
1307   AC_LANG_SOURCE([[
1308     #if !defined(__GNUC__) || __GNUC__ < 3
1309     #error Unsupported GCC version
1310     #endif
1311   ]])
1312 ],
1313 [], [AC_MSG_ERROR([gcc 3.x required, but you have a lower version])])
1314 fi
1315
1316 dnl Check for GNU Make.  We use its extensions, so don't build without it
1317 if test -z "$llvm_cv_gnu_make_command"
1318 then
1319   AC_MSG_ERROR([GNU Make required but not found])
1320 fi
1321
1322 dnl Tool compatibility is okay if we make it here.
1323 AC_MSG_RESULT([ok])
1324
1325 dnl Check optional compiler flags.
1326 AC_MSG_CHECKING([optional compiler flags])
1327 CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
1328 CXX_FLAG_CHECK(NO_MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers])
1329 CXX_FLAG_CHECK(COVERED_SWITCH_DEFAULT, [-Wcovered-switch-default])
1330
1331 dnl GCC's potential uninitialized use analysis is weak and presents lots of
1332 dnl false positives, so disable it.
1333 NO_UNINITIALIZED=
1334 NO_MAYBE_UNINITIALIZED=
1335 if test "$GXX" = "yes"
1336 then
1337   CXX_FLAG_CHECK(NO_MAYBE_UNINITIALIZED, [-Wno-maybe-uninitialized])
1338   dnl gcc 4.7 introduced -Wmaybe-uninitialized to distinguish cases which are
1339   dnl known to be uninitialized from cases which might be uninitialized.  We
1340   dnl still want to catch the first kind of errors.
1341   if test -z "$NO_MAYBE_UNINITIALIZED"
1342   then
1343     CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
1344   fi
1345 fi
1346 AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED])
1347
1348 AC_ARG_WITH([python],
1349             [AS_HELP_STRING([--with-python], [path to python])],
1350             [PYTHON="$withval"])
1351
1352 if test -n "$PYTHON" && test -x "$PYTHON" ; then
1353   AC_MSG_CHECKING([for python])
1354   AC_MSG_RESULT([user defined: $with_python])
1355 else
1356   if test -n "$PYTHON" ; then
1357     AC_MSG_WARN([specified python ($PYTHON) is not usable, searching path])
1358   fi
1359
1360   AC_PATH_PROG([PYTHON], [python python2 python26],
1361                [AC_MSG_RESULT([not found])
1362                 AC_MSG_ERROR([could not find python 2.5 or higher])])
1363 fi
1364
1365 AC_MSG_CHECKING([for python >= 2.5])
1366 ac_python_version=`$PYTHON -V 2>&1 | cut -d' ' -f2`
1367 ac_python_version_major=`echo $ac_python_version | cut -d'.' -f1`
1368 ac_python_version_minor=`echo $ac_python_version | cut -d'.' -f2`
1369 ac_python_version_patch=`echo $ac_python_version | cut -d'.' -f3`
1370 if test "$ac_python_version_major" -gt "2" || \
1371    (test "$ac_python_version_major" -eq "2" && \
1372     test "$ac_python_version_minor" -ge "5") ; then
1373   AC_MSG_RESULT([$PYTHON ($ac_python_version)])
1374 else
1375   AC_MSG_RESULT([not found])
1376   AC_MSG_FAILURE([found python $ac_python_version ($PYTHON); required >= 2.5])
1377 fi
1378
1379 dnl===-----------------------------------------------------------------------===
1380 dnl===
1381 dnl=== SECTION 5: Check for libraries
1382 dnl===
1383 dnl===-----------------------------------------------------------------------===
1384
1385 AC_CHECK_LIB(m,sin)
1386 if test "$llvm_cv_os_type" = "MingW" ; then
1387   AC_CHECK_LIB(imagehlp, main)
1388   AC_CHECK_LIB(psapi, main)
1389   AC_CHECK_LIB(shell32, main)
1390 fi
1391
1392 dnl dlopen() is required for plugin support.
1393 AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1],
1394                [Define if dlopen() is available on this platform.]),
1395                AC_MSG_WARN([dlopen() not found - disabling plugin support]))
1396
1397 dnl Search for the clock_gettime() function. Note that we rely on the POSIX
1398 dnl macros to detect whether clock_gettime is available, this just finds the
1399 dnl right libraries to link with.
1400 AC_SEARCH_LIBS(clock_gettime,rt)
1401
1402 dnl The curses library is optional; used for querying terminal info
1403 if test "$llvm_cv_enable_terminfo" = "yes" ; then
1404   dnl We need the has_color functionality in curses for it to be useful.
1405   AC_SEARCH_LIBS(setupterm,tinfo terminfo curses ncurses ncursesw,
1406                  AC_DEFINE([HAVE_TERMINFO],[1],
1407                            [Define if the setupterm() function is supported this platform.]))
1408 fi
1409
1410 dnl libffi is optional; used to call external functions from the interpreter
1411 if test "$llvm_cv_enable_libffi" = "yes" ; then
1412   AC_SEARCH_LIBS(ffi_call,ffi,AC_DEFINE([HAVE_FFI_CALL],[1],
1413                  [Define if libffi is available on this platform.]),
1414                  AC_MSG_ERROR([libffi not found - configure without --enable-libffi to compile without it]))
1415 fi
1416
1417 dnl mallinfo is optional; the code can compile (minus features) without it
1418 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],
1419                [Define if mallinfo() is available on this platform.]))
1420
1421 dnl pthread locking functions are optional - but llvm will not be thread-safe
1422 dnl without locks.
1423 if test "$LLVM_ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
1424   AC_CHECK_LIB(pthread, pthread_mutex_init)
1425   AC_SEARCH_LIBS(pthread_mutex_lock,pthread,
1426                  AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],
1427                            [Have pthread_mutex_lock]))
1428   AC_SEARCH_LIBS(pthread_rwlock_init,pthread,
1429                  AC_DEFINE([HAVE_PTHREAD_RWLOCK_INIT],[1],
1430                  [Have pthread_rwlock_init]))
1431   AC_SEARCH_LIBS(pthread_getspecific,pthread,
1432                  AC_DEFINE([HAVE_PTHREAD_GETSPECIFIC],[1],
1433                  [Have pthread_getspecific]))
1434 fi
1435
1436 dnl zlib is optional; used for compression/uncompression
1437 if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
1438   AC_CHECK_LIB(z, compress2)
1439 fi
1440
1441 dnl Allow extra x86-disassembler library
1442 AC_ARG_WITH(udis86,
1443   AS_HELP_STRING([--with-udis86=<path>],
1444     [Use udis86 external x86 disassembler library]),
1445     [
1446       AC_SUBST(USE_UDIS86, [1])
1447       case "$withval" in
1448         /usr/lib|yes) ;;
1449         *) LDFLAGS="$LDFLAGS -L${withval}" ;;
1450       esac
1451       AC_CHECK_LIB(udis86, ud_init, [], [
1452         echo "Error! You need to have libudis86 around."
1453         exit -1
1454       ])
1455     ],
1456     AC_SUBST(USE_UDIS86, [0]))
1457 AC_DEFINE_UNQUOTED([USE_UDIS86],$USE_UDIS86,
1458                    [Define if use udis86 library])
1459
1460 dnl Allow OProfile support for JIT output.
1461 AC_ARG_WITH(oprofile,
1462   AS_HELP_STRING([--with-oprofile=<prefix>],
1463     [Tell OProfile >= 0.9.4 how to symbolize JIT output]),
1464     [
1465       AC_SUBST(USE_OPROFILE, [1])
1466       case "$withval" in
1467         /usr|yes) llvm_cv_oppath=/usr/lib/oprofile ;;
1468         no) llvm_cv_oppath=
1469             AC_SUBST(USE_OPROFILE, [0]) ;;
1470         *) llvm_cv_oppath="${withval}/lib/oprofile"
1471            CPPFLAGS="-I${withval}/include";;
1472       esac
1473       case $llvm_cv_os_type in
1474         Linux)
1475           if test -n "$llvm_cv_oppath" ; then
1476             LIBS="$LIBS -lopagent -L${llvm_cv_oppath} -Wl,-rpath,${llvm_cv_oppath}"
1477             dnl Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=537744:
1478             dnl libbfd is not included properly in libopagent in some Debian
1479             dnl versions.  If libbfd isn't found at all, we assume opagent works
1480             dnl anyway.
1481             AC_SEARCH_LIBS(bfd_init, bfd, [], [])
1482             AC_SEARCH_LIBS(op_open_agent, opagent, [], [
1483               echo "Error! You need to have libopagent around."
1484               exit -1
1485             ])
1486             AC_CHECK_HEADER([opagent.h], [], [
1487               echo "Error! You need to have opagent.h around."
1488               exit -1
1489               ])
1490           fi ;;
1491         *)
1492           AC_MSG_ERROR([OProfile support is available on Linux only.]) ;;
1493       esac 
1494     ],
1495     [
1496       AC_SUBST(USE_OPROFILE, [0])
1497     ])
1498 AC_DEFINE_UNQUOTED([LLVM_USE_OPROFILE],$USE_OPROFILE,
1499                    [Define if we have the oprofile JIT-support library])
1500
1501 dnl Enable support for Intel JIT Events API.
1502 AC_ARG_WITH(intel-jitevents,
1503   AS_HELP_STRING([--with-intel-jitevents  Notify Intel JIT profiling API of generated code]),
1504     [
1505        case "$withval" in
1506           yes) AC_SUBST(USE_INTEL_JITEVENTS,[1]);;
1507           no)  AC_SUBST(USE_INTEL_JITEVENTS,[0]);;
1508           *) AC_MSG_ERROR([Invalid setting for --with-intel-jitevents. Use "yes" or "no"]);;
1509        esac
1510
1511       case $llvm_cv_os_type in
1512         Linux|Win32|Cygwin|MingW) ;;
1513         *) AC_MSG_ERROR([Intel JIT API support is available on Linux and Windows only.]);;
1514       esac
1515
1516       case "$llvm_cv_target_arch" in
1517         x86|x86_64) ;;
1518         *) AC_MSG_ERROR([Target architecture $llvm_cv_target_arch does not support Intel JIT Events API.]);;
1519       esac
1520     ],
1521     [
1522       AC_SUBST(USE_INTEL_JITEVENTS, [0])
1523     ])
1524 AC_DEFINE_UNQUOTED([LLVM_USE_INTEL_JITEVENTS],$USE_INTEL_JITEVENTS,
1525                    [Define if we have the Intel JIT API runtime support library])
1526
1527 dnl Check for libxml2
1528 dnl Right now we're just checking for the existence, we could also check for a
1529 dnl particular version via --version on xml2-config
1530 AC_CHECK_PROGS(XML2CONFIG, xml2-config)
1531
1532 AC_MSG_CHECKING(for libxml2 includes)
1533 if test "x$XML2CONFIG" = "x"; then
1534  AC_MSG_RESULT(xml2-config not found)
1535 else
1536  LIBXML2_INC=`$XML2CONFIG --cflags`
1537  AC_MSG_RESULT($LIBXML2_INC)
1538  AC_CHECK_LIB(xml2, xmlReadFile,[AC_DEFINE([CLANG_HAVE_LIBXML],1,[Define if we have libxml2])
1539                                 LIBXML2_LIBS="-lxml2"])
1540 fi
1541 AC_SUBST(LIBXML2_LIBS)
1542 AC_SUBST(LIBXML2_INC)
1543
1544 dnl===-----------------------------------------------------------------------===
1545 dnl===
1546 dnl=== SECTION 6: Check for header files
1547 dnl===
1548 dnl===-----------------------------------------------------------------------===
1549
1550 dnl First, use autoconf provided macros for specific headers that we need
1551 dnl We don't check for ancient stuff or things that are guaranteed to be there
1552 dnl by the C++ standard. We always use the <cfoo> versions of <foo.h> C headers.
1553 dnl Generally we're looking for POSIX headers.
1554 AC_HEADER_DIRENT
1555 AC_HEADER_MMAP_ANONYMOUS
1556 AC_HEADER_STAT
1557 AC_HEADER_SYS_WAIT
1558 AC_HEADER_TIME
1559
1560 AC_LANG_PUSH([C++])
1561 AC_CHECK_HEADERS([cxxabi.h])
1562 AC_LANG_POP([C++])
1563 AC_CHECK_HEADERS([dlfcn.h execinfo.h fcntl.h inttypes.h link.h])
1564 AC_CHECK_HEADERS([malloc.h setjmp.h signal.h stdint.h termios.h unistd.h])
1565 AC_CHECK_HEADERS([utime.h])
1566 AC_CHECK_HEADERS([sys/mman.h sys/param.h sys/resource.h sys/time.h sys/uio.h])
1567 AC_CHECK_HEADERS([sys/ioctl.h malloc/malloc.h mach/mach.h])
1568 AC_CHECK_HEADERS([valgrind/valgrind.h])
1569 AC_CHECK_HEADERS([fenv.h])
1570 AC_CHECK_DECLS([FE_ALL_EXCEPT, FE_INEXACT], [], [], [[#include <fenv.h>]])
1571 if test "$LLVM_ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
1572   AC_CHECK_HEADERS(pthread.h,
1573                    AC_SUBST(HAVE_PTHREAD, 1),
1574                    AC_SUBST(HAVE_PTHREAD, 0))
1575 else
1576   AC_SUBST(HAVE_PTHREAD, 0)
1577 fi
1578 if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
1579   AC_CHECK_HEADERS(zlib.h,
1580                    AC_SUBST(HAVE_LIBZ, 1),
1581                    AC_SUBST(HAVE_LIBZ, 0))
1582 else
1583   AC_SUBST(HAVE_LIBZ, 0)
1584 fi
1585
1586 dnl Try to find ffi.h.
1587 if test "$llvm_cv_enable_libffi" = "yes" ; then
1588   AC_CHECK_HEADERS([ffi.h ffi/ffi.h])
1589 fi
1590
1591 dnl Try to find Darwin specific crash reporting libraries.
1592 AC_CHECK_HEADERS([CrashReporterClient.h])
1593
1594 dnl Try to find Darwin specific crash reporting global.
1595 AC_MSG_CHECKING([__crashreporter_info__])
1596 AC_LINK_IFELSE(
1597 [
1598   AC_LANG_SOURCE([[
1599     extern const char *__crashreporter_info__;
1600     int main() {
1601       __crashreporter_info__ = "test";
1602       return 0;
1603     }
1604   ]])
1605 ],
1606 [
1607   AC_MSG_RESULT([yes])
1608   AC_DEFINE([HAVE_CRASHREPORTER_INFO], [1], [can use __crashreporter_info__])
1609 ],
1610 [
1611   AC_MSG_RESULT([no])
1612   AC_DEFINE([HAVE_CRASHREPORTER_INFO], [0], [can use __crashreporter_info__])
1613 ])
1614
1615 dnl===-----------------------------------------------------------------------===
1616 dnl===
1617 dnl=== SECTION 7: Check for types and structures
1618 dnl===
1619 dnl===-----------------------------------------------------------------------===
1620
1621 AC_HUGE_VAL_CHECK
1622 AC_TYPE_PID_T
1623 AC_TYPE_SIZE_T
1624 AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[Define as the return type of signal handlers (`int' or `void').])
1625 AC_STRUCT_TM
1626 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
1627 AC_CHECK_TYPES([uint64_t],,
1628          AC_CHECK_TYPES([u_int64_t],,
1629          AC_MSG_ERROR([Type uint64_t or u_int64_t required but not found])))
1630
1631 dnl===-----------------------------------------------------------------------===
1632 dnl===
1633 dnl=== SECTION 8: Check for specific functions needed
1634 dnl===
1635 dnl===-----------------------------------------------------------------------===
1636
1637 AC_CHECK_FUNCS([backtrace ceilf floorf roundf rintf nearbyintf getcwd ])
1638 AC_CHECK_FUNCS([powf fmodf strtof round ])
1639 AC_CHECK_FUNCS([log log2 log10 exp exp2])
1640 AC_CHECK_FUNCS([getpagesize getrusage getrlimit setrlimit gettimeofday ])
1641 AC_CHECK_FUNCS([isatty mkdtemp mkstemp ])
1642 AC_CHECK_FUNCS([mktemp posix_spawn pread realpath sbrk setrlimit ])
1643 AC_CHECK_FUNCS([strerror strerror_r setenv arc4random ])
1644 AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
1645 AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp writev])
1646 AC_CHECK_FUNCS([futimes futimens])
1647 AC_C_PRINTF_A
1648 AC_FUNC_RAND48
1649
1650 dnl Check the declaration "Secure API" on Windows environments.
1651 AC_CHECK_DECLS([strerror_s])
1652
1653 dnl Check symbols in libgcc.a for JIT on Mingw.
1654 if test "$llvm_cv_os_type" = "MingW" ; then
1655   AC_CHECK_LIB(gcc,_alloca,AC_DEFINE([HAVE__ALLOCA],[1],[Have host's _alloca]))
1656   AC_CHECK_LIB(gcc,__alloca,AC_DEFINE([HAVE___ALLOCA],[1],[Have host's __alloca]))
1657   AC_CHECK_LIB(gcc,__chkstk,AC_DEFINE([HAVE___CHKSTK],[1],[Have host's __chkstk]))
1658   AC_CHECK_LIB(gcc,___chkstk,AC_DEFINE([HAVE____CHKSTK],[1],[Have host's ___chkstk]))
1659
1660   AC_CHECK_LIB(gcc,__ashldi3,AC_DEFINE([HAVE___ASHLDI3],[1],[Have host's __ashldi3]))
1661   AC_CHECK_LIB(gcc,__ashrdi3,AC_DEFINE([HAVE___ASHRDI3],[1],[Have host's __ashrdi3]))
1662   AC_CHECK_LIB(gcc,__divdi3,AC_DEFINE([HAVE___DIVDI3],[1],[Have host's __divdi3]))
1663   AC_CHECK_LIB(gcc,__fixdfdi,AC_DEFINE([HAVE___FIXDFDI],[1],[Have host's __fixdfdi]))
1664   AC_CHECK_LIB(gcc,__fixsfdi,AC_DEFINE([HAVE___FIXSFDI],[1],[Have host's __fixsfdi]))
1665   AC_CHECK_LIB(gcc,__floatdidf,AC_DEFINE([HAVE___FLOATDIDF],[1],[Have host's __floatdidf]))
1666   AC_CHECK_LIB(gcc,__lshrdi3,AC_DEFINE([HAVE___LSHRDI3],[1],[Have host's __lshrdi3]))
1667   AC_CHECK_LIB(gcc,__moddi3,AC_DEFINE([HAVE___MODDI3],[1],[Have host's __moddi3]))
1668   AC_CHECK_LIB(gcc,__udivdi3,AC_DEFINE([HAVE___UDIVDI3],[1],[Have host's __udivdi3]))
1669   AC_CHECK_LIB(gcc,__umoddi3,AC_DEFINE([HAVE___UMODDI3],[1],[Have host's __umoddi3]))
1670
1671   AC_CHECK_LIB(gcc,__main,AC_DEFINE([HAVE___MAIN],[1],[Have host's __main]))
1672   AC_CHECK_LIB(gcc,__cmpdi2,AC_DEFINE([HAVE___CMPDI2],[1],[Have host's __cmpdi2]))
1673 fi
1674
1675 dnl Check Win32 API EnumerateLoadedModules.
1676 if test "$llvm_cv_os_type" = "MingW" ; then
1677   AC_MSG_CHECKING([whether EnumerateLoadedModules() accepts new decl])
1678   AC_COMPILE_IFELSE(
1679 [
1680   AC_LANG_SOURCE([[
1681     #include <windows.h>
1682     #include <imagehlp.h>
1683     extern void foo(PENUMLOADED_MODULES_CALLBACK);
1684     extern void foo(BOOL(CALLBACK*)(PCSTR,ULONG_PTR,ULONG,PVOID));
1685   ]])
1686 ],
1687 [
1688   AC_MSG_RESULT([yes])
1689   llvm_cv_win32_elmcb_pcstr="PCSTR"
1690 ],
1691 [
1692   AC_MSG_RESULT([no])
1693   llvm_cv_win32_elmcb_pcstr="PSTR"
1694 ])
1695   AC_DEFINE_UNQUOTED([WIN32_ELMCB_PCSTR],$llvm_cv_win32_elmcb_pcstr,[Type of 1st arg on ELM Callback])
1696 fi
1697
1698 dnl Check for variations in the Standard C++ library and STL. These macros are
1699 dnl provided by LLVM in the autoconf/m4 directory.
1700 AC_FUNC_ISNAN
1701 AC_FUNC_ISINF
1702
1703 dnl Check for mmap support.We also need to know if /dev/zero is required to
1704 dnl be opened for allocating RWX memory.
1705 dnl Make sure we aren't attempting to configure for an unknown system
1706 if test "$llvm_cv_platform_type" = "Unix" ; then
1707   AC_FUNC_MMAP
1708   AC_FUNC_MMAP_FILE
1709   AC_NEED_DEV_ZERO_FOR_MMAP
1710
1711   if test "$ac_cv_func_mmap_fixed_mapped" = "no"
1712   then
1713     AC_MSG_WARN([mmap() of a fixed address required but not supported])
1714   fi
1715   if test "$ac_cv_func_mmap_file" = "no"
1716   then
1717     AC_MSG_WARN([mmap() of files required but not found])
1718   fi
1719 fi
1720
1721 dnl atomic builtins are required for threading support.
1722 AC_MSG_CHECKING(for GCC atomic builtins)
1723 dnl Since we'll be using these atomic builtins in C++ files we should test
1724 dnl the C++ compiler.
1725 AC_LANG_PUSH([C++])
1726 AC_LINK_IFELSE(
1727 [
1728   AC_LANG_SOURCE([[
1729     int main() {
1730       volatile unsigned long val = 1;
1731       __sync_synchronize();
1732       __sync_val_compare_and_swap(&val, 1, 0);
1733       __sync_add_and_fetch(&val, 1);
1734       __sync_sub_and_fetch(&val, 1);
1735       return 0;
1736     }
1737   ]])
1738 ],
1739 [
1740   AC_MSG_RESULT([yes])
1741   AC_DEFINE([LLVM_HAS_ATOMICS], [1], [Has gcc/MSVC atomic intrinsics])
1742 ],
1743 [
1744   AC_MSG_RESULT([no])
1745   AC_DEFINE([LLVM_HAS_ATOMICS], [0], [Has gcc/MSVC atomic intrinsics])
1746   AC_MSG_WARN([LLVM will be built thread-unsafe because atomic builtins are missing])
1747 ])
1748 AC_LANG_POP([C++])
1749
1750 dnl===-----------------------------------------------------------------------===
1751 dnl===
1752 dnl=== SECTION 9: Additional checks, variables, etc.
1753 dnl===
1754 dnl===-----------------------------------------------------------------------===
1755
1756 dnl Handle 32-bit linux systems running a 64-bit kernel.
1757 dnl This has to come after section 4 because it invokes the compiler.
1758 if test "$llvm_cv_os_type" = "Linux" -a "$llvm_cv_target_arch" = "x86_64" ; then
1759   AC_IS_LINUX_MIXED
1760   if test "$llvm_cv_linux_mixed" = "yes"; then
1761     llvm_cv_target_arch="x86"
1762     ARCH="x86"
1763   fi
1764 fi
1765
1766 dnl Check whether __dso_handle is present
1767 AC_CHECK_FUNCS([__dso_handle])
1768
1769 dnl Propagate the shared library extension that the libltdl checks did to
1770 dnl the Makefiles so we can use it there too
1771 AC_SUBST(SHLIBEXT,$libltdl_cv_shlibext)
1772
1773 dnl Propagate the run-time library path variable that the libltdl
1774 dnl checks found to the Makefiles so we can use it there too
1775 AC_SUBST(SHLIBPATH_VAR,$libltdl_cv_shlibpath_var)
1776
1777 dnl Translate the various configuration directories and other basic
1778 dnl information into substitutions that will end up in Makefile.config.in
1779 dnl that these configured values can be used by the makefiles
1780 if test "${prefix}" = "NONE" ; then
1781   prefix="/usr/local"
1782 fi
1783 eval LLVM_PREFIX="${prefix}";
1784 eval LLVM_BINDIR="${prefix}/bin";
1785 eval LLVM_DATADIR="${prefix}/share/llvm";
1786 eval LLVM_DOCSDIR="${prefix}/share/doc/llvm";
1787 eval LLVM_ETCDIR="${prefix}/etc/llvm";
1788 eval LLVM_INCLUDEDIR="${prefix}/include";
1789 eval LLVM_INFODIR="${prefix}/info";
1790 eval LLVM_MANDIR="${prefix}/man";
1791 LLVM_CONFIGTIME=`date`
1792 AC_SUBST(LLVM_PREFIX)
1793 AC_SUBST(LLVM_BINDIR)
1794 AC_SUBST(LLVM_DATADIR)
1795 AC_SUBST(LLVM_DOCSDIR)
1796 AC_SUBST(LLVM_ETCDIR)
1797 AC_SUBST(LLVM_INCLUDEDIR)
1798 AC_SUBST(LLVM_INFODIR)
1799 AC_SUBST(LLVM_MANDIR)
1800 AC_SUBST(LLVM_CONFIGTIME)
1801
1802 dnl Disable embedding timestamps in the build directory, with ENABLE_TIMESTAMPS.
1803 if test "${ENABLE_TIMESTAMPS}" = "0"; then
1804   LLVM_CONFIGTIME="(timestamp not enabled)"
1805 fi
1806
1807 dnl Place the various directories into the config.h file as #defines so that we
1808 dnl can know about the installation paths within LLVM.
1809 AC_DEFINE_UNQUOTED(LLVM_PREFIX,"$LLVM_PREFIX",
1810                    [Installation prefix directory])
1811 AC_DEFINE_UNQUOTED(LLVM_BINDIR, "$LLVM_BINDIR",
1812                    [Installation directory for binary executables])
1813 AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DATADIR",
1814                    [Installation directory for data files])
1815 AC_DEFINE_UNQUOTED(LLVM_DOCSDIR, "$LLVM_DOCSDIR",
1816                    [Installation directory for documentation])
1817 AC_DEFINE_UNQUOTED(LLVM_ETCDIR, "$LLVM_ETCDIR",
1818                    [Installation directory for config files])
1819 AC_DEFINE_UNQUOTED(LLVM_INCLUDEDIR, "$LLVM_INCLUDEDIR",
1820                    [Installation directory for include files])
1821 AC_DEFINE_UNQUOTED(LLVM_INFODIR, "$LLVM_INFODIR",
1822                    [Installation directory for .info files])
1823 AC_DEFINE_UNQUOTED(LLVM_MANDIR, "$LLVM_MANDIR",
1824                    [Installation directory for man pages])
1825 AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME",
1826                    [Time at which LLVM was configured])
1827 AC_DEFINE_UNQUOTED(LLVM_HOST_TRIPLE, "$host",
1828                    [Host triple LLVM will be executed on])
1829 AC_DEFINE_UNQUOTED(LLVM_DEFAULT_TARGET_TRIPLE, "$target",
1830                    [Target triple LLVM will generate code for by default])
1831
1832 dnl Determine which bindings to build.
1833 if test "$BINDINGS_TO_BUILD" = auto ; then
1834   BINDINGS_TO_BUILD=""
1835   if test "x$OCAMLC" != x -a "x$OCAMLDEP" != x ; then
1836     BINDINGS_TO_BUILD="ocaml $BINDINGS_TO_BUILD"
1837   fi
1838 fi
1839 AC_SUBST(BINDINGS_TO_BUILD,$BINDINGS_TO_BUILD)
1840
1841 dnl This isn't really configurey, but it avoids having to repeat the list in
1842 dnl other files.
1843 AC_SUBST(ALL_BINDINGS,ocaml)
1844
1845 dnl Do any work necessary to ensure that bindings have what they need.
1846 binding_prereqs_failed=0
1847 for a_binding in $BINDINGS_TO_BUILD ; do
1848   case "$a_binding" in
1849   ocaml)
1850     if test "x$OCAMLC" = x ; then
1851       AC_MSG_WARN([--enable-bindings=ocaml specified, but ocamlc not found. Try configure OCAMLC=/path/to/ocamlc])
1852       binding_prereqs_failed=1
1853     fi
1854     if test "x$OCAMLDEP" = x ; then
1855       AC_MSG_WARN([--enable-bindings=ocaml specified, but ocamldep not found. Try configure OCAMLDEP=/path/to/ocamldep])
1856       binding_prereqs_failed=1
1857     fi
1858     if test "x$OCAMLOPT" = x ; then
1859       AC_MSG_WARN([--enable-bindings=ocaml specified, but ocamlopt not found. Try configure OCAMLOPT=/path/to/ocamlopt])
1860       dnl ocamlopt is optional!
1861     fi
1862     if test "x$with_ocaml_libdir" != xauto ; then
1863       AC_SUBST(OCAML_LIBDIR,$with_ocaml_libdir)
1864     else
1865       ocaml_stdlib="`"$OCAMLC" -where`"
1866       if test "$LLVM_PREFIX" '<' "$ocaml_stdlib" -a "$ocaml_stdlib" '<' "$LLVM_PREFIX~"
1867       then
1868         # ocaml stdlib is beneath our prefix; use stdlib
1869         AC_SUBST(OCAML_LIBDIR,$ocaml_stdlib)
1870       else
1871         # ocaml stdlib is outside our prefix; use libdir/ocaml
1872         AC_SUBST(OCAML_LIBDIR,${prefix}/lib/ocaml)
1873       fi
1874     fi
1875     ;;
1876   esac
1877 done
1878 if test "$binding_prereqs_failed" = 1 ; then
1879   AC_MSG_ERROR([Prequisites for bindings not satisfied. Fix them or use configure --disable-bindings.])
1880 fi
1881
1882 dnl Determine whether the compiler supports -fvisibility-inlines-hidden.
1883 AC_CXX_USE_VISIBILITY_INLINES_HIDDEN
1884
1885 dnl Determine linker rpath flag
1886 if test "$llvm_cv_link_use_r" = "yes" ; then
1887   RPATH="-Wl,-R"
1888 else
1889   RPATH="-Wl,-rpath"
1890 fi
1891 AC_SUBST(RPATH)
1892
1893 dnl Determine linker rdynamic flag
1894 if test "$llvm_cv_link_use_export_dynamic" = "yes" ; then
1895   RDYNAMIC="-rdynamic"
1896 else
1897   RDYNAMIC=""
1898 fi
1899 AC_SUBST(RDYNAMIC)
1900
1901 dnl===-----------------------------------------------------------------------===
1902 dnl===
1903 dnl=== SECTION 10: Specify the output files and generate it
1904 dnl===
1905 dnl===-----------------------------------------------------------------------===
1906
1907 dnl Configure header files
1908 dnl WARNING: dnl If you add or remove any of the following config headers, then
1909 dnl you MUST also update Makefile so that the variable FilesToConfig
1910 dnl contains the same list of files as AC_CONFIG_HEADERS below. This ensures the
1911 dnl files can be updated automatically when their *.in sources change.
1912 AC_CONFIG_HEADERS([include/llvm/Config/config.h include/llvm/Config/llvm-config.h])
1913 AH_TOP([#ifndef CONFIG_H
1914 #define CONFIG_H])
1915 AH_BOTTOM([#endif])
1916
1917 AC_CONFIG_FILES([include/llvm/Config/Targets.def])
1918 AC_CONFIG_FILES([include/llvm/Config/AsmPrinters.def])
1919 AC_CONFIG_FILES([include/llvm/Config/AsmParsers.def])
1920 AC_CONFIG_FILES([include/llvm/Config/Disassemblers.def])
1921 AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
1922
1923 dnl Configure the makefile's configuration data
1924 AC_CONFIG_FILES([Makefile.config])
1925
1926 dnl Configure the RPM spec file for LLVM
1927 AC_CONFIG_FILES([llvm.spec])
1928
1929 dnl Configure doxygen's configuration file
1930 AC_CONFIG_FILES([docs/doxygen.cfg])
1931
1932 dnl Configure clang, if present
1933 if test "${clang_src_root}" = ""; then
1934   clang_src_root="$srcdir/tools/clang"
1935 fi
1936 if test -f ${clang_src_root}/README.txt; then
1937   dnl Use variables to stay under 80 columns.
1938   configh="include/clang/Config/config.h"
1939   doxy="docs/doxygen.cfg"
1940   AC_CONFIG_HEADERS([tools/clang/${configh}:${clang_src_root}/${configh}.in])
1941   AC_CONFIG_FILES([tools/clang/${doxy}:${clang_src_root}/${doxy}.in])
1942 fi
1943
1944 dnl OCaml findlib META file
1945 AC_CONFIG_FILES([bindings/ocaml/llvm/META.llvm])
1946
1947 dnl Add --program-prefix value to Makefile.rules. Already an ARG variable.
1948 test "x$program_prefix" = "xNONE" && program_prefix=""
1949 AC_SUBST([program_prefix])
1950
1951
1952 dnl Do special configuration of Makefiles
1953 AC_CONFIG_COMMANDS([setup],,[llvm_src="${srcdir}"])
1954 AC_CONFIG_MAKEFILE(Makefile)
1955 AC_CONFIG_MAKEFILE(Makefile.common)
1956 AC_CONFIG_MAKEFILE(examples/Makefile)
1957 AC_CONFIG_MAKEFILE(lib/Makefile)
1958 AC_CONFIG_MAKEFILE(test/Makefile)
1959 AC_CONFIG_MAKEFILE(test/Makefile.tests)
1960 AC_CONFIG_MAKEFILE(unittests/Makefile)
1961 AC_CONFIG_MAKEFILE(tools/Makefile)
1962 AC_CONFIG_MAKEFILE(utils/Makefile)
1963 AC_CONFIG_MAKEFILE(projects/Makefile)
1964 AC_CONFIG_MAKEFILE(bindings/Makefile)
1965 AC_CONFIG_MAKEFILE(bindings/ocaml/Makefile.ocaml)
1966
1967 dnl Finally, crank out the output
1968 AC_OUTPUT