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