blob: 4919e84de2578a5503cab08be39601ae95de9632 [file] [log] [blame]
Reid Spencer0241e382004-11-25 04:51:04 +00001dnl === configure.ac --------------------------------------------------------===
2dnl The LLVM Compiler Infrastructure
3dnl
Chris Lattner6787a452007-12-29 22:59:10 +00004dnl This file is distributed under the University of Illinois Open Source
5dnl License. See LICENSE.TXT for details.
Eric Christophere62b4412007-12-01 00:34:39 +00006dnl
Reid Spencer0241e382004-11-25 04:51:04 +00007dnl===-----------------------------------------------------------------------===
8dnl This is the LLVM configuration script. It is processed by the autoconf
Eric Christophere62b4412007-12-01 00:34:39 +00009dnl program to produce a script named configure. This script contains the
Reid Spencer0241e382004-11-25 04:51:04 +000010dnl configuration checks that LLVM needs in order to support multiple platforms.
11dnl This file is composed of 10 sections per the recommended organization of
12dnl autoconf input defined in the autoconf documentation. As this file evolves,
13dnl please keep the various types of checks within their sections. The sections
14dnl are as follows:
15dnl
16dnl SECTION 1: Initialization & Setup
17dnl SECTION 2: Architecture, target, and host checks
18dnl SECTION 3: Command line arguments for the configure script.
19dnl SECTION 4: Check for programs we need and that they are the right version
20dnl SECTION 5: Check for libraries
21dnl SECTION 6: Check for header files
22dnl SECTION 7: Check for types and structures
23dnl SECTION 8: Check for specific functions needed
24dnl SECTION 9: Additional checks, variables, etc.
25dnl SECTION 10: Specify the output files and generate it
26dnl
27dnl===-----------------------------------------------------------------------===
28dnl===
29dnl=== SECTION 1: Initialization & Setup
30dnl===
31dnl===-----------------------------------------------------------------------===
32dnl Initialize autoconf and define the package name, version number and
Dylan Noblesmith67c49702011-12-18 18:50:16 +000033dnl address for reporting bugs.
Tom Stellarde6ba81d2014-03-03 15:22:00 +000034
Hans Wennborgd94a5f02015-01-14 17:38:03 +000035AC_INIT([LLVM],[3.7.0svn],[http://llvm.org/bugs/])
Tom Stellarde6ba81d2014-03-03 15:22:00 +000036
37LLVM_VERSION_MAJOR=3
Hans Wennborgd94a5f02015-01-14 17:38:03 +000038LLVM_VERSION_MINOR=7
Tom Stellarde6ba81d2014-03-03 15:22:00 +000039LLVM_VERSION_PATCH=0
40LLVM_VERSION_SUFFIX=svn
41
42AC_DEFINE_UNQUOTED([LLVM_VERSION_MAJOR], $LLVM_VERSION_MAJOR, [Major version of the LLVM API])
43AC_DEFINE_UNQUOTED([LLVM_VERSION_MINOR], $LLVM_VERSION_MINOR, [Minor version of the LLVM API])
44AC_DEFINE_UNQUOTED([LLVM_VERSION_PATCH], $LLVM_VERSION_PATCH, [Patch version of the LLVM API])
Peter Collingbournea8ed79a2014-11-19 03:34:17 +000045AC_DEFINE_UNQUOTED([LLVM_VERSION_STRING], "$PACKAGE_VERSION", [LLVM version string])
Tom Stellarde6ba81d2014-03-03 15:22:00 +000046
47AC_SUBST([LLVM_VERSION_MAJOR])
48AC_SUBST([LLVM_VERSION_MINOR])
49AC_SUBST([LLVM_VERSION_PATCH])
50AC_SUBST([LLVM_VERSION_SUFFIX])
John Criswell7a3334d2003-07-22 19:13:20 +000051
Reid Spencer0241e382004-11-25 04:51:04 +000052dnl Provide a copyright substitution and ensure the copyright notice is included
53dnl in the output of --version option of the generated configure script.
Eric Christophera1bafae2015-03-12 01:25:29 +000054AC_SUBST(LLVM_COPYRIGHT,["Copyright (c) 2003-2015 University of Illinois at Urbana-Champaign."])
55AC_COPYRIGHT([Copyright (c) 2003-2015 University of Illinois at Urbana-Champaign.])
Reid Spencer0241e382004-11-25 04:51:04 +000056
Eric Christopherb9a11322011-09-23 00:53:10 +000057dnl Indicate that we require autoconf 2.60 or later.
58AC_PREREQ(2.60)
Reid Spencer0241e382004-11-25 04:51:04 +000059
60dnl Verify that the source directory is valid. This makes sure that we are
61dnl configuring LLVM and not some other package (it validates --srcdir argument)
Chandler Carruthfbdae1f2013-01-02 09:22:59 +000062AC_CONFIG_SRCDIR([lib/IR/Module.cpp])
Reid Spencer0241e382004-11-25 04:51:04 +000063
Eric Christophere62b4412007-12-01 00:34:39 +000064dnl Place all of the extra autoconf files into the config subdirectory. Tell
65dnl various tools where the m4 autoconf macros are.
John Criswell7a3334d2003-07-22 19:13:20 +000066AC_CONFIG_AUX_DIR([autoconf])
67
John Criswell22107a72003-09-15 17:04:06 +000068dnl Quit if the source directory has already been configured.
John Criswellf6778b62003-09-15 17:19:42 +000069dnl NOTE: This relies upon undocumented autoconf behavior.
Reid Spencer2024d0e2004-09-19 23:43:52 +000070if test ${srcdir} != "." ; then
Reid Spencer0241e382004-11-25 04:51:04 +000071 if test -f ${srcdir}/include/llvm/Config/config.h ; then
72 AC_MSG_ERROR([Already configured in ${srcdir}])
73 fi
John Criswell22107a72003-09-15 17:04:06 +000074fi
75
Jonathan Roelofs949d55d2015-05-04 02:04:54 +000076dnl Quit if it is an in-source build
77if test ${srcdir} == "." ; then
Jonathan Roelofs0e9ff692015-07-01 18:09:21 +000078 AC_MSG_ERROR([In-source builds are not allowed. Please configure from a separate build directory!])
Jonathan Roelofs949d55d2015-05-04 02:04:54 +000079fi
80
Patrik Hagglundd91ae4d2013-02-04 08:15:53 +000081dnl Default to empty (i.e. assigning the null string to) CFLAGS and CXXFLAGS,
82dnl instead of the autoconf default (for example, '-g -O2' for CC=gcc).
Patrik Hagglund98578472013-09-24 11:38:45 +000083: ${CFLAGS=}
84: ${CXXFLAGS=}
Patrik Hagglundd91ae4d2013-02-04 08:15:53 +000085
Eric Christopher58839712011-09-16 20:36:25 +000086dnl We need to check for the compiler up here to avoid anything else
87dnl starting with a different one.
Chandler Carruthb4dd3c62014-01-14 03:46:00 +000088AC_PROG_CC(clang gcc)
89AC_PROG_CXX(clang++ g++)
Eric Christopher58839712011-09-16 20:36:25 +000090AC_PROG_CPP
91
Dmitri Gribenko06358bd2013-01-09 15:25:30 +000092dnl If CXX is Clang, check that it can find and parse C++ standard library
93dnl headers.
94if 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])
Jonathan Roelofscf1ba1d2015-04-29 20:06:41 +0000113 AC_MSG_ERROR([Selected compiler could not find or parse C++ standard library headers. Rerun with CC=c-compiler CXX=c++-compiler LLVM_SRC_DIR/configure ...])
Dmitri Gribenko06358bd2013-01-09 15:25:30 +0000114])
115 AC_LANG_POP([C++])
116fi
117
Chandler Carruth75a65452014-01-14 05:02:38 +0000118dnl Set up variables that track whether the host compiler is GCC or Clang where
119dnl we can effectively sanity check them. We don't try to sanity check all the
120dnl other possible compilers.
121AC_MSG_CHECKING([whether GCC or Clang is our host compiler])
122AC_LANG_PUSH([C++])
123llvm_cv_cxx_compiler=unknown
Chandler Carruthf8c6ccf2014-01-15 10:31:15 +0000124AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __clang__
125 #error
126 #endif
127 ]])],
Chandler Carruth75a65452014-01-14 05:02:38 +0000128 llvm_cv_cxx_compiler=clang,
Chandler Carruthf8c6ccf2014-01-15 10:31:15 +0000129 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __GNUC__
130 #error
131 #endif
132 ]])],
Chandler Carruth75a65452014-01-14 05:02:38 +0000133 llvm_cv_cxx_compiler=gcc, [])])
134AC_LANG_POP([C++])
135AC_MSG_RESULT([${llvm_cv_cxx_compiler}])
136
Reid Spencer0241e382004-11-25 04:51:04 +0000137dnl Configure all of the projects present in our source tree. While we could
138dnl just AC_CONFIG_SUBDIRS on the set of directories in projects that have a
139dnl configure script, that usage of the AC_CONFIG_SUBDIRS macro is deprecated.
140dnl Instead we match on the known projects.
John Criswellf369e772010-03-19 21:31:39 +0000141
142dnl
143dnl One tricky part of doing this is that some projects depend upon other
144dnl projects. For example, several projects rely upon the LLVM test suite.
145dnl We want to configure those projects first so that their object trees are
146dnl created before running the configure scripts of projects that depend upon
147dnl them.
148dnl
149
John Criswellf369e772010-03-19 21:31:39 +0000150dnl Several projects use the LLVM test suite, so configure it next.
151if test -d ${srcdir}/projects/test-suite ; then
152 AC_CONFIG_SUBDIRS([projects/test-suite])
153fi
154
155dnl llvm-test is the old name of the test-suite, kept here for backwards
156dnl compatibility
157if test -d ${srcdir}/projects/llvm-test ; then
158 AC_CONFIG_SUBDIRS([projects/llvm-test])
159fi
160
161dnl Some projects use poolalloc; configure that next
162if test -d ${srcdir}/projects/poolalloc ; then
163 AC_CONFIG_SUBDIRS([projects/poolalloc])
164fi
165
166if test -d ${srcdir}/projects/llvm-poolalloc ; then
167 AC_CONFIG_SUBDIRS([projects/llvm-poolalloc])
168fi
169
170dnl Check for all other projects
John Criswell297baed2003-11-25 20:36:46 +0000171for i in `ls ${srcdir}/projects`
172do
Reid Spencer90de7fb2004-09-07 16:26:18 +0000173 if test -d ${srcdir}/projects/${i} ; then
174 case ${i} in
John Criswell4d377d82010-02-25 22:57:19 +0000175 safecode) AC_CONFIG_SUBDIRS([projects/safecode]) ;;
Daniel Dunbar7ce849d2011-12-07 22:07:03 +0000176 compiler-rt) ;;
John Criswell4e61b252010-03-25 13:59:09 +0000177 test-suite) ;;
178 llvm-test) ;;
179 poolalloc) ;;
180 llvm-poolalloc) ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000181 *)
Alkis Evlogimenos26227282004-09-27 07:35:19 +0000182 AC_MSG_WARN([Unknown project (${i}) won't be configured automatically])
Reid Spencerc6f9e0f2004-09-21 17:12:35 +0000183 ;;
Reid Spencer90de7fb2004-09-07 16:26:18 +0000184 esac
John Criswell297baed2003-11-25 20:36:46 +0000185 fi
186done
John Criswellee7ebdc2003-09-30 16:31:48 +0000187
Tobias Grosserea9dca42010-10-30 00:54:26 +0000188dnl Disable the build of polly, even if it is checked out into tools/polly.
189AC_ARG_ENABLE(polly,
190 AS_HELP_STRING([--enable-polly],
191 [Use polly if available (default is YES)]),,
192 enableval=default)
193case "$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"]) ;;
198esac
199
200
201dnl Check if polly is checked out into tools/polly and configure it if
202dnl available.
203if (test -d ${srcdir}/tools/polly) && (test $ENABLE_POLLY -eq 1) ; then
204 AC_SUBST(LLVM_HAS_POLLY,1)
205 AC_CONFIG_SUBDIRS([tools/polly])
206fi
207
Reid Spencer0241e382004-11-25 04:51:04 +0000208dnl===-----------------------------------------------------------------------===
209dnl===
210dnl=== SECTION 2: Architecture, target, and host checks
211dnl===
212dnl===-----------------------------------------------------------------------===
John Criswell9537b042004-07-23 15:40:57 +0000213
Reid Spencer0241e382004-11-25 04:51:04 +0000214dnl Check the target for which we're compiling and the host that will do the
Eric Christophere62b4412007-12-01 00:34:39 +0000215dnl compilations. This will tell us which LLVM compiler will be used for
216dnl compiling SSA into object code. This needs to be done early because
Reid Spencer0241e382004-11-25 04:51:04 +0000217dnl following tests depend on it.
John Criswell7a3334d2003-07-22 19:13:20 +0000218AC_CANONICAL_TARGET
219
Reid Spencer0241e382004-11-25 04:51:04 +0000220dnl Determine the platform type and cache its value. This helps us configure
221dnl the System library to the correct build platform.
Reid Spencer0aa9d002006-07-26 21:14:56 +0000222AC_CACHE_CHECK([type of operating system we're going to host on],
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000223 [llvm_cv_os_type],
Reid Spencer0aa9d002006-07-26 21:14:56 +0000224[case $host in
Eric Christophere62b4412007-12-01 00:34:39 +0000225 *-*-aix*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000226 llvm_cv_link_all_option="-Wl,--whole-archive"
227 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000228 llvm_cv_os_type="AIX"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000229 llvm_cv_platform_type="Unix" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000230 *-*-irix*)
Reid Spencere9a40562006-08-22 22:21:38 +0000231 llvm_cv_link_all_option="-Wl,--whole-archive"
232 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000233 llvm_cv_os_type="IRIX"
Reid Spencere9a40562006-08-22 22:21:38 +0000234 llvm_cv_platform_type="Unix" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000235 *-*-cygwin*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000236 llvm_cv_link_all_option="-Wl,--whole-archive"
237 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000238 llvm_cv_os_type="Cygwin"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000239 llvm_cv_platform_type="Unix" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000240 *-*-darwin*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000241 llvm_cv_link_all_option="-Wl,-all_load"
Chris Lattner42e35d42008-02-05 19:43:40 +0000242 llvm_cv_no_link_all_option="-Wl,-noall_load"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000243 llvm_cv_os_type="Darwin"
244 llvm_cv_platform_type="Unix" ;;
Chris Lattnerc86cdc72010-04-09 20:45:04 +0000245 *-*-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" ;;
Sylvestre Ledru93a491b2013-07-01 08:07:52 +0000250 *-*-freebsd*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000251 llvm_cv_link_all_option="-Wl,--whole-archive"
252 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000253 llvm_cv_os_type="FreeBSD"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000254 llvm_cv_platform_type="Unix" ;;
Sylvestre Ledru93a491b2013-07-01 08:07:52 +0000255 *-*-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" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000260 *-*-openbsd*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000261 llvm_cv_link_all_option="-Wl,--whole-archive"
262 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000263 llvm_cv_os_type="OpenBSD"
Reid Spencer48b92032006-04-19 23:47:16 +0000264 llvm_cv_platform_type="Unix" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000265 *-*-netbsd*)
Reid Spencer78adb9d2007-01-20 20:43:35 +0000266 llvm_cv_link_all_option="-Wl,--whole-archive"
267 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000268 llvm_cv_os_type="NetBSD"
Reid Spencer78adb9d2007-01-20 20:43:35 +0000269 llvm_cv_platform_type="Unix" ;;
Matthijs Kooijmanf61fd542008-06-26 10:36:58 +0000270 *-*-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" ;;
Eric Christopher83f88242015-02-26 19:46:32 +0000275 *-*-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" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000280 *-*-hpux*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000281 llvm_cv_link_all_option="-Wl,--whole-archive"
282 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000283 llvm_cv_os_type="HP-UX"
Duraid Madina5ea2ba82005-05-16 05:39:00 +0000284 llvm_cv_platform_type="Unix" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000285 *-*-interix*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000286 llvm_cv_link_all_option="-Wl,--whole-archive"
287 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000288 llvm_cv_os_type="Interix"
289 llvm_cv_platform_type="Unix" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000290 *-*-linux*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000291 llvm_cv_link_all_option="-Wl,--whole-archive"
292 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000293 llvm_cv_os_type="Linux"
294 llvm_cv_platform_type="Unix" ;;
Rafael Espindola4977edd2011-12-22 14:01:18 +0000295 *-*-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" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000300 *-*-solaris*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000301 llvm_cv_link_all_option="-Wl,-z,allextract"
302 llvm_cv_no_link_all_option="-Wl,-z,defaultextract"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000303 llvm_cv_os_type="SunOS"
304 llvm_cv_platform_type="Unix" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000305 *-*-win32*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000306 llvm_cv_link_all_option="-Wl,--whole-archive"
307 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000308 llvm_cv_os_type="Win32"
309 llvm_cv_platform_type="Win32" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000310 *-*-mingw*)
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000311 llvm_cv_link_all_option="-Wl,--whole-archive"
312 llvm_cv_no_link_all_option="-Wl,--no-whole-archive"
Eric Christophere62b4412007-12-01 00:34:39 +0000313 llvm_cv_os_type="MingW"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000314 llvm_cv_platform_type="Win32" ;;
Edward O'Callaghan8227b052009-10-12 04:57:20 +0000315 *-*-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"
Eric Christopherb3762a02010-03-02 05:17:21 +0000319 llvm_cv_platform_type="Unix" ;;
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000320 *-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" ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000330 *)
331 llvm_cv_link_all_option=""
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000332 llvm_cv_no_link_all_option=""
Eric Christophere62b4412007-12-01 00:34:39 +0000333 llvm_cv_os_type="Unknown"
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000334 llvm_cv_platform_type="Unknown" ;;
Reid Spencer0241e382004-11-25 04:51:04 +0000335esac])
John Criswell7a3334d2003-07-22 19:13:20 +0000336
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000337AC_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" ;;
Chris Lattnerc86cdc72010-04-09 20:45:04 +0000348 *-*-minix*)
349 llvm_cv_target_os_type="Minix" ;;
Sylvestre Ledru93a491b2013-07-01 08:07:52 +0000350 *-*-freebsd*)
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000351 llvm_cv_target_os_type="FreeBSD" ;;
Sylvestre Ledru93a491b2013-07-01 08:07:52 +0000352 *-*-kfreebsd-gnu)
353 llvm_cv_target_os_type="GNU/kFreeBSD" ;;
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000354 *-*-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" ;;
Eric Christopher83f88242015-02-26 19:46:32 +0000360 *-*-bitrig*)
361 llvm_cv_target_os_type="Bitrig" ;;
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000362 *-*-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" ;;
Sylvestre Ledrue8235fe2012-04-05 19:34:15 +0000368 *-*-gnu*)
369 llvm_cv_target_os_type="GNU" ;;
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000370 *-*-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" ;;
Edward O'Callaghan8227b052009-10-12 04:57:20 +0000376 *-*-haiku*)
Eric Christopherb3762a02010-03-02 05:17:21 +0000377 llvm_cv_target_os_type="Haiku" ;;
Douglas Gregorde3c9262011-07-01 22:41:06 +0000378 *-*-rtems*)
379 llvm_cv_target_os_type="RTEMS" ;;
Ivan Krasin44306e22011-08-18 22:54:21 +0000380 *-*-nacl*)
381 llvm_cv_target_os_type="NativeClient" ;;
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000382 *-unknown-eabi*)
383 llvm_cv_target_os_type="Freestanding" ;;
Alex Rosenberg93460672015-01-26 15:25:05 +0000384 *-*-ps4)
385 llvm_cv_target_os_type="PS4" ;;
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000386 *)
387 llvm_cv_target_os_type="Unknown" ;;
388esac])
389
Reid Spencer1daffa52004-08-31 01:34:10 +0000390dnl Make sure we aren't attempting to configure for an unknown system
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000391if test "$llvm_cv_os_type" = "Unknown" ; then
392 AC_MSG_ERROR([Operating system is unknown, configure can't continue])
Reid Spencer1daffa52004-08-31 01:34:10 +0000393fi
394
Reid Spencer0241e382004-11-25 04:51:04 +0000395dnl Set the "OS" Makefile variable based on the platform type so the
396dnl makefile can configure itself to specific build hosts
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000397AC_SUBST(OS,$llvm_cv_os_type)
Anton Korobeynikov90e17e72009-08-18 00:40:33 +0000398AC_SUBST(HOST_OS,$llvm_cv_os_type)
399AC_SUBST(TARGET_OS,$llvm_cv_target_os_type)
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000400
Reid Spencer0b52e2f2006-08-04 18:18:08 +0000401dnl Set the LINKALL and NOLINKALL Makefile variables based on the platform
402AC_SUBST(LINKALL,$llvm_cv_link_all_option)
403AC_SUBST(NOLINKALL,$llvm_cv_no_link_all_option)
404
Dan Gohmana3ed0712010-08-04 16:48:36 +0000405dnl Set the "LLVM_ON_*" variables based on llvm_cv_platform_type
Michael J. Spencer447762d2010-11-29 18:16:10 +0000406dnl This is used by lib/Support to determine the basic kind of implementation
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000407dnl to use.
408case $llvm_cv_platform_type in
Eric Christophere62b4412007-12-01 00:34:39 +0000409 Unix)
410 AC_DEFINE([LLVM_ON_UNIX],[1],[Define if this is Unixish platform])
Reid Spencerd7287e02004-12-31 22:54:28 +0000411 AC_SUBST(LLVM_ON_UNIX,[1])
412 AC_SUBST(LLVM_ON_WIN32,[0])
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000413 ;;
Eric Christophere62b4412007-12-01 00:34:39 +0000414 Win32)
415 AC_DEFINE([LLVM_ON_WIN32],[1],[Define if this is Win32ish platform])
Reid Spencerd7287e02004-12-31 22:54:28 +0000416 AC_SUBST(LLVM_ON_UNIX,[0])
417 AC_SUBST(LLVM_ON_WIN32,[1])
Reid Spencerd3d6d9d2004-12-24 06:29:05 +0000418 ;;
419esac
Reid Spencer0241e382004-11-25 04:51:04 +0000420
John Criswell7a3334d2003-07-22 19:13:20 +0000421dnl Determine what our target architecture is and configure accordingly.
422dnl This will allow Makefiles to make a distinction between the hardware and
423dnl the OS.
Reid Spencer0241e382004-11-25 04:51:04 +0000424AC_CACHE_CHECK([target architecture],[llvm_cv_target_arch],
425[case $target in
Reid Spencer0a54a582004-12-23 21:08:52 +0000426 i?86-*) llvm_cv_target_arch="x86" ;;
Reid Spencer78d9e872004-12-28 07:56:14 +0000427 amd64-* | x86_64-*) llvm_cv_target_arch="x86_64" ;;
Reid Spencer0a54a582004-12-23 21:08:52 +0000428 sparc*-*) llvm_cv_target_arch="Sparc" ;;
429 powerpc*-*) llvm_cv_target_arch="PowerPC" ;;
Tim Northover3b0846e2014-05-24 12:50:23 +0000430 arm64*-*) llvm_cv_target_arch="AArch64" ;;
Nick Lewycky13590cb2009-04-18 18:11:26 +0000431 arm*-*) llvm_cv_target_arch="ARM" ;;
Tim Northover3b0846e2014-05-24 12:50:23 +0000432 aarch64*-*) llvm_cv_target_arch="AArch64" ;;
Simon Atanasyanc2cccd72012-10-29 19:49:45 +0000433 mips-* | mips64-*) llvm_cv_target_arch="Mips" ;;
434 mipsel-* | mips64el-*) llvm_cv_target_arch="Mips" ;;
Richard Osborneca08e062008-11-07 10:59:00 +0000435 xcore-*) llvm_cv_target_arch="XCore" ;;
Anton Korobeynikov10138002009-05-03 12:57:15 +0000436 msp430-*) llvm_cv_target_arch="MSP430" ;;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000437 hexagon-*) llvm_cv_target_arch="Hexagon" ;;
Justin Holewinskiae556d32012-05-04 20:18:50 +0000438 nvptx-*) llvm_cv_target_arch="NVPTX" ;;
Ulrich Weigand1ceebf62013-05-06 16:22:34 +0000439 s390x-*) llvm_cv_target_arch="SystemZ" ;;
Dan Gohman10e730a2015-06-29 23:51:55 +0000440 wasm*-*) llvm_cv_target_arch="WebAssembly" ;;
Reid Spencer0a54a582004-12-23 21:08:52 +0000441 *) llvm_cv_target_arch="Unknown" ;;
Reid Spencer0241e382004-11-25 04:51:04 +0000442esac])
John Criswell7a3334d2003-07-22 19:13:20 +0000443
Reid Spencer0241e382004-11-25 04:51:04 +0000444if test "$llvm_cv_target_arch" = "Unknown" ; then
445 AC_MSG_WARN([Configuring LLVM for an unknown target archicture])
446fi
447
Gabor Greife0d58d32012-01-26 10:28:58 +0000448dnl Determine the LLVM native architecture for the target
Douglas Gregor7cbf8162009-06-17 00:42:33 +0000449case "$llvm_cv_target_arch" in
450 x86) LLVM_NATIVE_ARCH="X86" ;;
451 x86_64) LLVM_NATIVE_ARCH="X86" ;;
452 *) LLVM_NATIVE_ARCH="$llvm_cv_target_arch" ;;
453esac
Mikhail Glushenkovd871cbc2009-07-03 03:52:07 +0000454
Reid Spencer0241e382004-11-25 04:51:04 +0000455dnl Define a substitution, ARCH, for the target architecture
456AC_SUBST(ARCH,$llvm_cv_target_arch)
NAKAMURA Takumi84e85302014-02-09 16:36:42 +0000457AC_SUBST(LLVM_NATIVE_ARCH,$LLVM_NATIVE_ARCH)
Reid Spencer0241e382004-11-25 04:51:04 +0000458
Danil Malyshev7c5db452012-05-17 21:07:47 +0000459dnl Determine what our host architecture.
460dnl This will allow MCJIT regress tests runs only for supported
461dnl platforms.
462case $host in
463 i?86-*) host_arch="x86" ;;
464 amd64-* | x86_64-*) host_arch="x86_64" ;;
465 sparc*-*) host_arch="Sparc" ;;
466 powerpc*-*) host_arch="PowerPC" ;;
Tim Northover3b0846e2014-05-24 12:50:23 +0000467 arm64*-*) host_arch="AArch64" ;;
Danil Malyshev7c5db452012-05-17 21:07:47 +0000468 arm*-*) host_arch="ARM" ;;
Tim Northover3b0846e2014-05-24 12:50:23 +0000469 aarch64*-*) host_arch="AArch64" ;;
Simon Atanasyanc2cccd72012-10-29 19:49:45 +0000470 mips-* | mips64-*) host_arch="Mips" ;;
471 mipsel-* | mips64el-*) host_arch="Mips" ;;
Danil Malyshev7c5db452012-05-17 21:07:47 +0000472 xcore-*) host_arch="XCore" ;;
473 msp430-*) host_arch="MSP430" ;;
474 hexagon-*) host_arch="Hexagon" ;;
Ulrich Weigand1ceebf62013-05-06 16:22:34 +0000475 s390x-*) host_arch="SystemZ" ;;
Dan Gohman10e730a2015-06-29 23:51:55 +0000476 wasm*-*) host_arch="WebAssembly" ;;
Danil Malyshev7c5db452012-05-17 21:07:47 +0000477 *) host_arch="Unknown" ;;
478esac
479
480if test "$host_arch" = "Unknown" ; then
481 AC_MSG_WARN([Configuring LLVM for an unknown host archicture])
482fi
483
484AC_SUBST(HOST_ARCH,$host_arch)
485
Gabor Greife0d58d32012-01-26 10:28:58 +0000486dnl Check for build platform executable suffix if we're cross-compiling
Reid Spencer0aa9d002006-07-26 21:14:56 +0000487if test "$cross_compiling" = yes; then
Eric Christophere62b4412007-12-01 00:34:39 +0000488 AC_SUBST(LLVM_CROSS_COMPILING, [1])
Reid Spencer0aa9d002006-07-26 21:14:56 +0000489 AC_BUILD_EXEEXT
Jim Grosbach009db892008-10-02 22:56:44 +0000490 ac_build_prefix=${build_alias}-
491 AC_CHECK_PROG(BUILD_CXX, ${ac_build_prefix}g++, ${ac_build_prefix}g++)
492 if test -z "$BUILD_CXX"; then
493 AC_CHECK_PROG(BUILD_CXX, g++, g++)
494 if test -z "$BUILD_CXX"; then
495 AC_CHECK_PROG(BUILD_CXX, c++, c++, , , /usr/ucb/c++)
496 fi
497 fi
Reid Spencer0aa9d002006-07-26 21:14:56 +0000498else
499 AC_SUBST(LLVM_CROSS_COMPILING, [0])
500fi
501
Dan Gohmande75469c2010-08-04 16:25:01 +0000502dnl Check to see if there's a .svn or .git directory indicating that this
503dnl build is being done from a checkout. This sets up several defaults for
504dnl the command line switches. When we build with a checkout directory,
Nick Lewycky9a196c02009-04-01 04:39:25 +0000505dnl we get a debug with assertions turned on. Without, we assume a source
506dnl release and we get an optimized build without assertions.
507dnl See --enable-optimized and --enable-assertions below
Dan Gohmande75469c2010-08-04 16:25:01 +0000508if test -d ".svn" -o -d "${srcdir}/.svn" -o -d ".git" -o -d "${srcdir}/.git"; then
Reid Spencerb65ade82006-04-07 16:01:51 +0000509 cvsbuild="yes"
510 optimize="no"
Reid Spencerb65ade82006-04-07 16:01:51 +0000511 AC_SUBST(CVSBUILD,[[CVSBUILD=1]])
512else
513 cvsbuild="no"
514 optimize="yes"
Reid Spencerb65ade82006-04-07 16:01:51 +0000515fi
516
Reid Spencer0241e382004-11-25 04:51:04 +0000517dnl===-----------------------------------------------------------------------===
518dnl===
519dnl=== SECTION 3: Command line arguments for the configure script.
520dnl===
521dnl===-----------------------------------------------------------------------===
522
Eric Christopher1094ded2011-11-11 22:51:42 +0000523dnl --enable-libcpp : check whether or not to use libc++ on the command line
524AC_ARG_ENABLE(libcpp,
525 AS_HELP_STRING([--enable-libcpp],
526 [Use libc++ if available (default is NO)]),,
527 enableval=default)
528case "$enableval" in
529 yes) AC_SUBST(ENABLE_LIBCPP,[1]) ;;
530 no) AC_SUBST(ENABLE_LIBCPP,[0]) ;;
531 default) AC_SUBST(ENABLE_LIBCPP,[0]);;
532 *) AC_MSG_ERROR([Invalid setting for --enable-libcpp. Use "yes" or "no"]) ;;
533esac
534
Chandler Carruth7206eae2014-01-15 19:19:13 +0000535dnl Check both GCC and Clang for sufficiently modern versions. These checks can
536dnl be bypassed by passing a flag if necessary on a platform. We have to do
537dnl these checks here so that we have the configuration of the standard C++
538dnl library finished.
539AC_ARG_ENABLE(compiler-version-checks,
540 AS_HELP_STRING([--enable-compiler-version-checks],
541 [Check the version of the host compiler (default is YES)]),,
542 enableval=default)
543case "$enableval" in
544 no)
545 ;;
546 yes|default)
547 AC_LANG_PUSH([C++])
548 case "$llvm_cv_cxx_compiler" in
549 clang)
550 AC_MSG_CHECKING([whether Clang is new enough])
551 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
552#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
553#error This version of Clang is too old to build LLVM
554#endif
555]])],
556 [AC_MSG_RESULT([yes])],
557 [AC_MSG_RESULT([no])
558 AC_MSG_ERROR([
559The selected Clang compiler is not new enough to build LLVM. Please upgrade to
560Clang 3.1. You may pass --disable-compiler-version-checks to configure to
561bypass these sanity checks.])])
562
563 dnl Note that libstdc++4.6 is known broken for C++11 builds. The errors
564 dnl are sometimes deeply confusing though. Here we test for an obvious
565 dnl incomplete feature in 4.6's standard library that was completed in
Chandler Carrutheba44ea2014-01-15 21:21:48 +0000566 dnl 4.7's. We also have to disable this test if 'ENABLE_LIBCPP' is set
567 dnl because the enable flags don't actually fix CXXFLAGS, they rely on
568 dnl that happening in the Makefile.
569 if test "$ENABLE_LIBCPP" -eq 0 ; then
570 AC_MSG_CHECKING([whether Clang will select a modern C++ standard library])
571 llvm_cv_old_cxxflags="$CXXFLAGS"
572 CXXFLAGS="$CXXFLAGS -std=c++0x"
573 AC_LINK_IFELSE([AC_LANG_SOURCE([[
Chandler Carruth7206eae2014-01-15 19:19:13 +0000574#include <atomic>
575std::atomic<float> x(0.0f);
576int main() { return (float)x; }
577]])],
Chandler Carrutheba44ea2014-01-15 21:21:48 +0000578 [AC_MSG_RESULT([yes])],
579 [AC_MSG_RESULT([no])
580 AC_MSG_ERROR([
Chandler Carruth7206eae2014-01-15 19:19:13 +0000581We detected a missing feature in the standard C++ library that was known to be
582missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous
583C++11 problems with 4.6's library, and we don't support GCCs or libstdc++ older
584than 4.7. You will need to update your system and ensure Clang uses the newer
585standard library.
586
587If this error is incorrect or you need to force things to work, you may pass
588'--disable-compiler-version-checks' to configure to bypass this test.])])
Chandler Carrutheba44ea2014-01-15 21:21:48 +0000589 CXXFLAGS="$llvm_cv_old_cxxflags"
590 fi
Chandler Carruth7206eae2014-01-15 19:19:13 +0000591 ;;
592 gcc)
593 AC_MSG_CHECKING([whether GCC is new enough])
594 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
595#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
596#error This version of GCC is too old to build LLVM
597#endif
598]])],
599 [AC_MSG_RESULT([yes])],
600 [AC_MSG_RESULT([no])
601 AC_MSG_ERROR([
602The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
603to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
604bypass these sanity checks.])])
605 ;;
606 unknown)
607 ;;
608 esac
609 AC_LANG_POP([C++])
610 ;;
611 *)
612 AC_MSG_ERROR([Invalid setting for --enable-compiler-version-checks. Use "yes" or "no"])
613 ;;
614esac
615
Chandler Carruthbbae5122014-03-01 03:33:08 +0000616dnl --enable-cxx1y : check whether or not to use -std=c++1y on the command line
617AC_ARG_ENABLE(cxx1y,
618 AS_HELP_STRING([--enable-cxx1y],
619 [Use c++1y if available (default is NO)]),,
Eric Christopher04e35972012-08-03 19:47:14 +0000620 enableval=default)
621case "$enableval" in
Chandler Carruthbbae5122014-03-01 03:33:08 +0000622 yes) AC_SUBST(ENABLE_CXX1Y,[1]) ;;
623 no) AC_SUBST(ENABLE_CXX1Y,[0]) ;;
624 default) AC_SUBST(ENABLE_CXX1Y,[0]);;
625 *) AC_MSG_ERROR([Invalid setting for --enable-cxx1y. Use "yes" or "no"]) ;;
Eric Christopher04e35972012-08-03 19:47:14 +0000626esac
627
Eric Christopherc64a54e2014-03-05 00:43:38 +0000628dnl --enable-split-dwarf : check whether or not to use -gsplit-dwarf on the command
Eric Christopherf1bd7702013-06-25 01:12:25 +0000629dnl line
630AC_ARG_ENABLE(split-dwarf,
631 AS_HELP_STRING([--enable-split-dwarf],
632 [Use split-dwarf if available (default is NO)]),,
633 enableval=default)
634case "$enableval" in
635 yes) AC_SUBST(ENABLE_SPLIT_DWARF,[1]) ;;
636 no) AC_SUBST(ENABLE_SPLIT_DWARF,[0]) ;;
637 default) AC_SUBST(ENABLE_SPLIT_DWARF,[0]);;
638 *) AC_MSG_ERROR([Invalid setting for --enable-split-dwarf. Use "yes" or "no"]) ;;
639esac
640
Roman Divackyf2bb66b2012-12-13 16:07:19 +0000641dnl --enable-clang-arcmt: check whether to enable clang arcmt
642clang_arcmt="yes"
643AC_ARG_ENABLE(clang-arcmt,
644 AS_HELP_STRING([--enable-clang-arcmt],
645 [Enable building of clang ARCMT (default is YES)]),
646 clang_arcmt="$enableval",
647 enableval="yes")
648case "$enableval" in
649 yes) AC_SUBST(ENABLE_CLANG_ARCMT,[1]) ;;
650 no) AC_SUBST(ENABLE_CLANG_ARCMT,[0]) ;;
651 default) AC_SUBST(ENABLE_CLANG_ARCMT,[1]);;
652 *) AC_MSG_ERROR([Invalid setting for --enable-clang-arcmt. Use "yes" or "no"]) ;;
653esac
654
Rafael Espindolae33f06c2014-03-10 16:58:35 +0000655dnl --enable-clang-plugin-support: check whether to enable plugins in clang
656clang_plugin_support="yes"
657AC_ARG_ENABLE(clang-plugin-support,
658 AS_HELP_STRING([--enable-clang-plugin-support],
659 [Enable plugin support in clang (default is YES)]),
660 clang_plugin_support="$enableval",
661 enableval="yes")
662case "$enableval" in
663 yes) AC_SUBST(CLANG_PLUGIN_SUPPORT,[1]) ;;
664 no) AC_SUBST(CLANG_PLUGIN_SUPPORT,[0]) ;;
665 default) AC_SUBST(CLANG_PLUGIN_SUPPORT,[1]);;
666 *) AC_MSG_ERROR([Invalid setting for --enable-clang-plugin-support. Use "yes" or "no"]) ;;
667esac
668
Roman Divackyf2bb66b2012-12-13 16:07:19 +0000669dnl --enable-clang-static-analyzer: check whether to enable static-analyzer
670clang_static_analyzer="yes"
671AC_ARG_ENABLE(clang-static-analyzer,
672 AS_HELP_STRING([--enable-clang-static-analyzer],
673 [Enable building of clang Static Analyzer (default is YES)]),
674 clang_static_analyzer="$enableval",
675 enableval="yes")
676case "$enableval" in
677 yes) AC_SUBST(ENABLE_CLANG_STATIC_ANALYZER,[1]) ;;
Peter Zotov668f9672014-10-30 08:29:45 +0000678 no)
Jordan Rose23fc6f32013-08-22 15:49:53 +0000679 if test ${clang_arcmt} != "no" ; then
680 AC_MSG_ERROR([Cannot enable clang ARC Migration Tool while disabling static analyzer.])
681 fi
Peter Zotov668f9672014-10-30 08:29:45 +0000682 AC_SUBST(ENABLE_CLANG_STATIC_ANALYZER,[0])
Jordan Rose23fc6f32013-08-22 15:49:53 +0000683 ;;
Roman Divackyf2bb66b2012-12-13 16:07:19 +0000684 default) AC_SUBST(ENABLE_CLANG_STATIC_ANALYZER,[1]);;
685 *) AC_MSG_ERROR([Invalid setting for --enable-clang-static-analyzer. Use "yes" or "no"]) ;;
686esac
687
Reid Spencer0241e382004-11-25 04:51:04 +0000688dnl --enable-optimized : check whether they want to do an optimized build:
Reid Spencerb65ade82006-04-07 16:01:51 +0000689AC_ARG_ENABLE(optimized, AS_HELP_STRING(
Nick Lewycky9ab256ac2009-06-06 06:24:44 +0000690 --enable-optimized,[Compile with optimizations enabled (default is NO)]),,enableval=$optimize)
Reid Spencer0241e382004-11-25 04:51:04 +0000691if test ${enableval} = "no" ; then
692 AC_SUBST(ENABLE_OPTIMIZED,[[]])
693else
694 AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
695fi
696
David Greene80f48bd2009-04-17 14:49:22 +0000697dnl --enable-profiling : check whether they want to do a profile build:
698AC_ARG_ENABLE(profiling, AS_HELP_STRING(
Nick Lewycky9ab256ac2009-06-06 06:24:44 +0000699 --enable-profiling,[Compile with profiling enabled (default is NO)]),,enableval="no")
David Greene80f48bd2009-04-17 14:49:22 +0000700if test ${enableval} = "no" ; then
701 AC_SUBST(ENABLE_PROFILING,[[]])
702else
703 AC_SUBST(ENABLE_PROFILING,[[ENABLE_PROFILING=1]])
704fi
705
Reid Spencerb65ade82006-04-07 16:01:51 +0000706dnl --enable-assertions : check whether they want to turn on assertions or not:
707AC_ARG_ENABLE(assertions,AS_HELP_STRING(
Nick Lewycky9ab256ac2009-06-06 06:24:44 +0000708 --enable-assertions,[Compile with assertion checks enabled (default is YES)]),, enableval="yes")
Reid Spencerfa423e92006-04-09 20:42:14 +0000709if test ${enableval} = "yes" ; then
710 AC_SUBST(DISABLE_ASSERTIONS,[[]])
Sanjoy Das8ce64992015-03-26 19:25:01 +0000711 assertions_enabled="yes"
Reid Spencerb65ade82006-04-07 16:01:51 +0000712else
Reid Spencerfa423e92006-04-09 20:42:14 +0000713 AC_SUBST(DISABLE_ASSERTIONS,[[DISABLE_ASSERTIONS=1]])
Sanjoy Das8ce64992015-03-26 19:25:01 +0000714 assertions_enabled="no"
Reid Spencerb65ade82006-04-07 16:01:51 +0000715fi
716
Eric Christopher84864012012-08-03 19:58:20 +0000717dnl --enable-werror : check whether we want Werror on by default
718AC_ARG_ENABLE(werror,AS_HELP_STRING(
719 --enable-werror,[Compile with -Werror enabled (default is NO)]),, enableval="no")
720case "$enableval" in
721 yes) AC_SUBST(ENABLE_WERROR,[1]) ;;
722 no) AC_SUBST(ENABLE_WERROR,[0]) ;;
723 default) AC_SUBST(ENABLE_WERROR,[0]);;
724 *) AC_MSG_ERROR([Invalid setting for --enable-werror. Use "yes" or "no"]) ;;
725esac
726
David Greenecbc8ddf2007-06-28 19:36:08 +0000727dnl --enable-expensive-checks : check whether they want to turn on expensive debug checks:
728AC_ARG_ENABLE(expensive-checks,AS_HELP_STRING(
Nick Lewycky9ab256ac2009-06-06 06:24:44 +0000729 --enable-expensive-checks,[Compile with expensive debug checks enabled (default is NO)]),, enableval="no")
David Greenecbc8ddf2007-06-28 19:36:08 +0000730if test ${enableval} = "yes" ; then
731 AC_SUBST(ENABLE_EXPENSIVE_CHECKS,[[ENABLE_EXPENSIVE_CHECKS=1]])
732 AC_SUBST(EXPENSIVE_CHECKS,[[yes]])
733else
734 AC_SUBST(ENABLE_EXPENSIVE_CHECKS,[[]])
735 AC_SUBST(EXPENSIVE_CHECKS,[[no]])
736fi
737
Sanjoy Das8ce64992015-03-26 19:25:01 +0000738dnl --enable-abi-breaking-checks : decide whether we should compile in asserts and
739dnl checks that make the build ABI incompatible with an llvm built without these
740dnl checks enabled.
741AC_ARG_ENABLE(abi-breaking-checks,AS_HELP_STRING(
742 --enable-abi-breaking-checks,[Compile with abi-breaking asserts support (default is with-asserts)]),, enableval="with-asserts")
743case "$enableval" in
744 with-asserts) if test ${assertions_enabled} = "yes" ; then
745 AC_DEFINE([LLVM_ENABLE_ABI_BREAKING_CHECKS],[1],[Define to enable checks that alter the LLVM C++ ABI])
NAKAMURA Takumic063c472015-04-01 11:46:15 +0000746 AC_SUBST(ENABLE_ABI_BREAKING_CHECKS,[1])
747 else
748 AC_SUBST(ENABLE_ABI_BREAKING_CHECKS,[0])
Sanjoy Das8ce64992015-03-26 19:25:01 +0000749 fi ;;
NAKAMURA Takumic063c472015-04-01 11:46:15 +0000750 yes)
751 AC_DEFINE([LLVM_ENABLE_ABI_BREAKING_CHECKS],[1],[Define to enable checks that alter the LLVM C++ ABI])
752 AC_SUBST(ENABLE_ABI_BREAKING_CHECKS,[1])
753 ;;
754 no)
755 AC_SUBST(ENABLE_ABI_BREAKING_CHECKS,[0])
756 ;;
Sanjoy Das8ce64992015-03-26 19:25:01 +0000757 *) AC_MSG_ERROR([Invalid setting for --enable-abi-breaking-checks. Use "with-asserts", "yes" or "no"])
758esac
759
Reid Spencer4b8067f2006-11-17 03:32:33 +0000760dnl --enable-debug-runtime : should runtime libraries have debug symbols?
761AC_ARG_ENABLE(debug-runtime,
Nick Lewycky9ab256ac2009-06-06 06:24:44 +0000762 AS_HELP_STRING(--enable-debug-runtime,[Build runtime libs with debug symbols (default is NO)]),,enableval=no)
Reid Spencer4b8067f2006-11-17 03:32:33 +0000763if test ${enableval} = "no" ; then
764 AC_SUBST(DEBUG_RUNTIME,[[]])
765else
766 AC_SUBST(DEBUG_RUNTIME,[[DEBUG_RUNTIME=1]])
767fi
768
Jeffrey Yasskinc3273dc2009-09-27 17:47:29 +0000769dnl --enable-debug-symbols : should even optimized compiler libraries
770dnl have debug symbols?
771AC_ARG_ENABLE(debug-symbols,
772 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)
773if test ${enableval} = "no" ; then
774 AC_SUBST(DEBUG_SYMBOLS,[[]])
775else
776 AC_SUBST(DEBUG_SYMBOLS,[[DEBUG_SYMBOLS=1]])
777fi
778
Daniel Dunbarc9e4ff62012-08-14 18:14:20 +0000779dnl --enable-keep-symbols : do not strip installed executables
780AC_ARG_ENABLE(keep-symbols,
781 AS_HELP_STRING(--enable-keep-symbols,[Do not strip installed executables)]),,enableval=no)
782if test ${enableval} = "no" ; then
783 AC_SUBST(KEEP_SYMBOLS,[[]])
784else
785 AC_SUBST(KEEP_SYMBOLS,[[KEEP_SYMBOLS=1]])
786fi
787
Reid Spencer0241e382004-11-25 04:51:04 +0000788dnl --enable-jit: check whether they want to enable the jit
789AC_ARG_ENABLE(jit,
790 AS_HELP_STRING(--enable-jit,
791 [Enable Just In Time Compiling (default is YES)]),,
792 enableval=default)
793if test ${enableval} = "no"
794then
795 AC_SUBST(JIT,[[]])
796else
Reid Spencer9dc4ba52004-11-25 07:28:19 +0000797 case "$llvm_cv_target_arch" in
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +0000798 x86) AC_SUBST(TARGET_HAS_JIT,1) ;;
799 Sparc) AC_SUBST(TARGET_HAS_JIT,0) ;;
800 PowerPC) AC_SUBST(TARGET_HAS_JIT,1) ;;
801 x86_64) AC_SUBST(TARGET_HAS_JIT,1) ;;
Eric Christopherd8530f32009-09-14 16:38:49 +0000802 ARM) AC_SUBST(TARGET_HAS_JIT,1) ;;
Bruno Cardoso Lopesd1d9c782011-07-21 16:28:51 +0000803 Mips) AC_SUBST(TARGET_HAS_JIT,1) ;;
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +0000804 XCore) AC_SUBST(TARGET_HAS_JIT,0) ;;
805 MSP430) AC_SUBST(TARGET_HAS_JIT,0) ;;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000806 Hexagon) AC_SUBST(TARGET_HAS_JIT,0) ;;
Justin Holewinskiae556d32012-05-04 20:18:50 +0000807 NVPTX) AC_SUBST(TARGET_HAS_JIT,0) ;;
Ulrich Weigand1ceebf62013-05-06 16:22:34 +0000808 SystemZ) AC_SUBST(TARGET_HAS_JIT,1) ;;
Dan Gohman10e730a2015-06-29 23:51:55 +0000809 WebAssembly) AC_SUBST(TARGET_HAS_JIT,0) ;;
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +0000810 *) AC_SUBST(TARGET_HAS_JIT,0) ;;
Reid Spencer0241e382004-11-25 04:51:04 +0000811 esac
812fi
813
Tim Northover3b0846e2014-05-24 12:50:23 +0000814TARGETS_WITH_JIT="ARM AArch64 Mips PowerPC SystemZ X86"
NAKAMURA Takumi84e85302014-02-09 16:36:42 +0000815AC_SUBST(TARGETS_WITH_JIT,$TARGETS_WITH_JIT)
816
Rafael Espindola7ac506d2010-11-12 19:24:06 +0000817dnl Allow enablement of building and installing docs
818AC_ARG_ENABLE(docs,
819 AS_HELP_STRING([--enable-docs],
820 [Build documents (default is YES)]),,
821 enableval=default)
822case "$enableval" in
823 yes) AC_SUBST(ENABLE_DOCS,[1]) ;;
824 no) AC_SUBST(ENABLE_DOCS,[0]) ;;
825 default) AC_SUBST(ENABLE_DOCS,[1]) ;;
826 *) AC_MSG_ERROR([Invalid setting for --enable-docs. Use "yes" or "no"]) ;;
827esac
828
Reid Spencer0194c9a2004-11-29 04:56:35 +0000829dnl Allow enablement of doxygen generated documentation
830AC_ARG_ENABLE(doxygen,
831 AS_HELP_STRING([--enable-doxygen],
832 [Build doxygen documentation (default is NO)]),,
833 enableval=default)
834case "$enableval" in
835 yes) AC_SUBST(ENABLE_DOXYGEN,[1]) ;;
Logan Chien26c9f2f2015-03-12 17:25:01 +0000836 no|default) AC_SUBST(ENABLE_DOXYGEN,[0]) ;;
Reid Spencer0194c9a2004-11-29 04:56:35 +0000837 *) AC_MSG_ERROR([Invalid setting for --enable-doxygen. Use "yes" or "no"]) ;;
838esac
839
Logan Chien26c9f2f2015-03-12 17:25:01 +0000840dnl Allow enablement of doxygen search engine
841AC_ARG_ENABLE(doxygen-search,
842 AS_HELP_STRING([--enable-doxygen-search],
843 [Enable doxygen search support (default is NO)]),,
844 enableval=default)
845ENABLE_DOXYGEN_SEARCH="$enableval"
846
847case "$enableval" in
848 yes|no|default) ;;
849 *) AC_MSG_ERROR([Invalid setting for --enable-doxygen-search. Use "yes" or "no"]) ;;
850esac
851
852AC_ARG_ENABLE(doxygen-external-search,
853 AS_HELP_STRING([--enable-doxygen-external-search],
854 [Enable doxygen exteranl search (default is NO)]),,
855 enableval=default)
856ENABLE_DOXYGEN_EXTERNAL_SEARCH="$enableval"
857
858case "$enableval" in
859 yes)
860 dnl To match with the CMake behavior, enable doxygen when
861 dnl --enable-doxygen-external-search is enabled.
862 case "$ENABLE_DOXYGEN_SEARCH" in
863 yes|default) ENABLE_DOXYGEN_SEARCH="yes" ;;
864 no) AC_MSG_ERROR([The option --enable-doxygen-external-search requires --enable-doxygen-search]) ;;
865 esac
866 ;;
867 no|default) ;;
868 *) AC_MSG_ERROR([Invalid setting for --enable-doxygen-external-search. Use "yes" or "no"]) ;;
869esac
870
871AC_ARG_WITH(doxygen-search-engine-url,
872 AS_HELP_STRING([--with-doxygen-search-engine-url],
873 [Specify the external search engine for doxygen]),,)
874WITH_DOXYGEN_SEARCH_ENGINE_URL="$withval"
875
876AC_ARG_WITH(doxygen-search-mappings,
877 AS_HELP_STRING([--with-doxygen-search-mappings],
878 [Specify the extra search mapping for doxygen]),,)
879WITH_DOXYGEN_SEARCH_MAPPINGS="$withval"
880
881case "$ENABLE_DOXYGEN_SEARCH" in
882 yes)
883 if test "$ENABLE_DOXYGEN" = "0" ; then
884 AC_MSG_ERROR([The option --enable-doxygen-search requires --enable-doxygen.])
885 fi
886
887 AC_SUBST(enable_searchengine,[YES])
888
889 case "$ENABLE_DOXYGEN_EXTERNAL_SEARCH" in
890 yes)
891 AC_SUBST(enable_external_search,[YES])
892 AC_SUBST(enable_server_based_search,[YES])
Logan Chien6203f9e2015-03-12 19:56:25 +0000893 AC_SUBST(searchengine_url,["$WITH_DOXYGEN_SEARCH_ENGINE_URL"])
894 AC_SUBST(extra_search_mappings,["$WITH_DOXYGEN_SEARCH_MAPPINGS"])
Logan Chien26c9f2f2015-03-12 17:25:01 +0000895 ;;
896
897 no|default)
898 AC_SUBST(enable_external_search,[NO])
899 AC_SUBST(enable_server_based_search,[NO])
900 AC_SUBST(searchengine_url,[])
901 AC_SUBST(extra_search_mappings,[])
902 ;;
903 esac
904 ;;
905
906 no|default)
907 AC_SUBST(enable_searchengine,[NO])
908 AC_SUBST(searchengine_url,[])
909 AC_SUBST(enable_server_based_search,[NO])
910 AC_SUBST(enable_external_search,[NO])
911 AC_SUBST(extra_search_mappings,[])
912 ;;
913
914 *)
915 AC_MSG_ERROR([Invalid setting for --enable-doxygen-search. Use "yes" or "no"])
916 ;;
917esac
918
919dnl Allow enablement of doxygen generated Qt help files
920AC_ARG_ENABLE(doxygen-qt-help,
921 AS_HELP_STRING([--enable-doxygen-qt-help],
922 [Build Qt help files (default is NO)]),,
923 enableval=default)
924case "$enableval" in
925 yes)
926 if test "$ENABLE_DOXYGEN" = "0" ; then
927 AC_MSG_ERROR([The option --enable-doxygen-qt-help requires --enable-doxygen.])
928 fi
929
930 AC_PATH_PROG(QHELPGENERATOR, [qhelpgenerator], [qhelpgenerator])
931
932 dnl Qt help file for llvm doxygen documentation
933 AC_SUBST(llvm_doxygen_generate_qhp,[YES])
934 AC_SUBST(llvm_doxygen_qch_filename,[org.llvm.qch])
935 AC_SUBST(llvm_doxygen_qhp_namespace,[org.llvm])
Logan Chien6203f9e2015-03-12 19:56:25 +0000936 AC_SUBST(llvm_doxygen_qhelpgenerator_path,["$QHELPGENERATOR"])
937 AC_SUBST(llvm_doxygen_qhp_cust_filter_name,["$PACKAGE_STRING"])
938 AC_SUBST(llvm_doxygen_qhp_cust_filter_attrs,["$PACKAGE_NAME,$PACKAGE_VERSION"])
Logan Chien26c9f2f2015-03-12 17:25:01 +0000939
940 dnl Qt help file for clang doxygen documentation
941 AC_SUBST(clang_doxygen_generate_qhp,[YES])
942 AC_SUBST(clang_doxygen_qch_filename,[org.llvm.clang.qch])
943 AC_SUBST(clang_doxygen_qhp_namespace,[org.llvm.clang])
Logan Chien6203f9e2015-03-12 19:56:25 +0000944 AC_SUBST(clang_doxygen_qhelpgenerator_path,["$QHELPGENERATOR"])
945 AC_SUBST(clang_doxygen_qhp_cust_filter_name,["Clang $PACKAGE_VERSION"])
946 AC_SUBST(clang_doxygen_qhp_cust_filter_attrs,["Clang,$PACKAGE_VERSION"])
Logan Chien26c9f2f2015-03-12 17:25:01 +0000947 ;;
948
949 no|default)
950 AC_SUBST(llvm_doxygen_generate_qhp,[NO])
951 AC_SUBST(llvm_doxygen_qch_filename,[])
952 AC_SUBST(llvm_doxygen_qhp_namespace,[])
953 AC_SUBST(llvm_doxygen_qhelpgenerator_path,[])
954 AC_SUBST(llvm_doxygen_qhp_cust_filter_name,[])
955 AC_SUBST(llvm_doxygen_qhp_cust_filter_attrs,[])
956
957 AC_SUBST(clang_doxygen_generate_qhp,[NO])
958 AC_SUBST(clang_doxygen_qch_filename,[])
959 AC_SUBST(clang_doxygen_qhp_namespace,[])
960 AC_SUBST(clang_doxygen_qhelpgenerator_path,[])
Logan Chien6203f9e2015-03-12 19:56:25 +0000961 AC_SUBST(clang_doxygen_qhp_cust_filter_name,["Clang $PACKAGE_VERSION"])
962 AC_SUBST(clang_doxygen_qhp_cust_filter_attrs,["Clang,$PACKAGE_VERSION"])
Logan Chien26c9f2f2015-03-12 17:25:01 +0000963 ;;
964
965 *)
966 AC_MSG_ERROR([Invalid setting for --enable-doxygen-qt-help. Use "yes" or "no"]) ;;
967esac
968
Reid Spencerf85fabeb2005-08-24 10:07:20 +0000969dnl Allow disablement of threads
970AC_ARG_ENABLE(threads,
971 AS_HELP_STRING([--enable-threads],
972 [Use threads if available (default is YES)]),,
Reid Spencerd549edc2006-11-05 17:08:18 +0000973 enableval=default)
Reid Spencerf85fabeb2005-08-24 10:07:20 +0000974case "$enableval" in
Dylan Noblesmithefddf202011-11-28 00:48:58 +0000975 yes) AC_SUBST(LLVM_ENABLE_THREADS,[1]) ;;
976 no) AC_SUBST(LLVM_ENABLE_THREADS,[0]) ;;
977 default) AC_SUBST(LLVM_ENABLE_THREADS,[1]) ;;
Reid Spencerf85fabeb2005-08-24 10:07:20 +0000978 *) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;;
979esac
Dylan Noblesmithefddf202011-11-28 00:48:58 +0000980AC_DEFINE_UNQUOTED([LLVM_ENABLE_THREADS],$LLVM_ENABLE_THREADS,
981 [Define if threads enabled])
Reid Spencerf85fabeb2005-08-24 10:07:20 +0000982
NAKAMURA Takumic6fce172010-12-29 03:59:03 +0000983dnl Allow disablement of pthread.h
984AC_ARG_ENABLE(pthreads,
985 AS_HELP_STRING([--enable-pthreads],
986 [Use pthreads if available (default is YES)]),,
987 enableval=default)
988case "$enableval" in
989 yes) AC_SUBST(ENABLE_PTHREADS,[1]) ;;
990 no) AC_SUBST(ENABLE_PTHREADS,[0]) ;;
991 default) AC_SUBST(ENABLE_PTHREADS,[1]) ;;
992 *) AC_MSG_ERROR([Invalid setting for --enable-pthreads. Use "yes" or "no"]) ;;
993esac
994
Alexey Samsonov2fb337e2013-04-23 08:28:39 +0000995dnl Allow disablement of zlib
996AC_ARG_ENABLE(zlib,
997 AS_HELP_STRING([--enable-zlib],
998 [Use zlib for compression/decompression if
999 available (default is YES)]),,
1000 enableval=default)
1001case "$enableval" in
1002 yes) AC_SUBST(LLVM_ENABLE_ZLIB,[1]) ;;
1003 no) AC_SUBST(LLVM_ENABLE_ZLIB,[0]) ;;
1004 default) AC_SUBST(LLVM_ENABLE_ZLIB,[1]) ;;
1005 *) AC_MSG_ERROR([Invalid setting for --enable-zlib. Use "yes" or "no"]) ;;
1006esac
1007AC_DEFINE_UNQUOTED([LLVM_ENABLE_ZLIB],$LLVM_ENABLE_ZLIB,
1008 [Define if zlib is enabled])
1009
Nick Lewycky7db7eb62009-02-19 06:18:24 +00001010dnl Allow building without position independent code
Reid Spencer05a1fe52006-12-16 22:07:52 +00001011AC_ARG_ENABLE(pic,
1012 AS_HELP_STRING([--enable-pic],
Nick Lewycky7db7eb62009-02-19 06:18:24 +00001013 [Build LLVM with Position Independent Code (default is YES)]),,
Reid Spencer05a1fe52006-12-16 22:07:52 +00001014 enableval=default)
1015case "$enableval" in
1016 yes) AC_SUBST(ENABLE_PIC,[1]) ;;
1017 no) AC_SUBST(ENABLE_PIC,[0]) ;;
Nick Lewycky7db7eb62009-02-19 06:18:24 +00001018 default) AC_SUBST(ENABLE_PIC,[1]) ;;
Reid Spencer05a1fe52006-12-16 22:07:52 +00001019 *) AC_MSG_ERROR([Invalid setting for --enable-pic. Use "yes" or "no"]) ;;
1020esac
1021AC_DEFINE_UNQUOTED([ENABLE_PIC],$ENABLE_PIC,
1022 [Define if position independent code is enabled])
1023
Jeffrey Yasskin6b718f72010-02-25 06:34:33 +00001024dnl Allow building a shared library and linking tools against it.
1025AC_ARG_ENABLE(shared,
1026 AS_HELP_STRING([--enable-shared],
1027 [Build a shared library and link tools against it (default is NO)]),,
1028 enableval=default)
1029case "$enableval" in
1030 yes) AC_SUBST(ENABLE_SHARED,[1]) ;;
1031 no) AC_SUBST(ENABLE_SHARED,[0]) ;;
1032 default) AC_SUBST(ENABLE_SHARED,[0]) ;;
1033 *) AC_MSG_ERROR([Invalid setting for --enable-shared. Use "yes" or "no"]) ;;
1034esac
1035
NAKAMURA Takumi495afdf2010-12-29 03:59:14 +00001036dnl Allow libstdc++ is embedded in LLVM.dll.
1037AC_ARG_ENABLE(embed-stdcxx,
1038 AS_HELP_STRING([--enable-embed-stdcxx],
NAKAMURA Takumid5a9a3a2011-10-13 18:04:52 +00001039 [Build a shared library with embedded libstdc++ for Win32 DLL (default is NO)]),,
NAKAMURA Takumi495afdf2010-12-29 03:59:14 +00001040 enableval=default)
1041case "$enableval" in
1042 yes) AC_SUBST(ENABLE_EMBED_STDCXX,[1]) ;;
1043 no) AC_SUBST(ENABLE_EMBED_STDCXX,[0]) ;;
NAKAMURA Takumid5a9a3a2011-10-13 18:04:52 +00001044 default) AC_SUBST(ENABLE_EMBED_STDCXX,[0]) ;;
NAKAMURA Takumi495afdf2010-12-29 03:59:14 +00001045 *) AC_MSG_ERROR([Invalid setting for --enable-embed-stdcxx. Use "yes" or "no"]) ;;
1046esac
1047
Daniel Dunbardac18242010-05-10 20:11:56 +00001048dnl Enable embedding timestamp information into build.
1049AC_ARG_ENABLE(timestamps,
1050 AS_HELP_STRING([--enable-timestamps],
1051 [Enable embedding timestamp information in build (default is YES)]),,
1052 enableval=default)
1053case "$enableval" in
1054 yes) AC_SUBST(ENABLE_TIMESTAMPS,[1]) ;;
1055 no) AC_SUBST(ENABLE_TIMESTAMPS,[0]) ;;
1056 default) AC_SUBST(ENABLE_TIMESTAMPS,[1]) ;;
1057 *) AC_MSG_ERROR([Invalid setting for --enable-timestamps. Use "yes" or "no"]) ;;
1058esac
1059AC_DEFINE_UNQUOTED([ENABLE_TIMESTAMPS],$ENABLE_TIMESTAMPS,
Gabor Greif1e718962012-07-12 13:05:12 +00001060 [Define if timestamp information (e.g., __DATE__) is allowed])
Daniel Dunbardac18242010-05-10 20:11:56 +00001061
Daniel Dunbareb6c7082013-08-30 20:39:21 +00001062dnl Enable support for showing backtraces.
1063AC_ARG_ENABLE(backtraces, AS_HELP_STRING(
1064 [--enable-backtraces],
1065 [Enable embedding backtraces on crash (default is YES)]),
1066 [case "$enableval" in
1067 yes) llvm_cv_enable_backtraces="yes" ;;
1068 no) llvm_cv_enable_backtraces="no" ;;
1069 *) AC_MSG_ERROR([Invalid setting for --enable-backtraces. Use "yes" or "no"]) ;;
1070 esac],
1071 llvm_cv_enable_backtraces="yes")
1072if test "$llvm_cv_enable_backtraces" = "yes" ; then
1073 AC_DEFINE([ENABLE_BACKTRACES],[1],
1074 [Define if you want backtraces on crash])
1075fi
Eric Christopher9fafe072012-09-21 23:03:29 +00001076
Daniel Dunbareb6c7082013-08-30 20:39:21 +00001077dnl Enable installing platform specific signal handling overrides, for improved
1078dnl CrashRecovery support or interaction with crash reporting software. This
1079dnl support may be inappropriate for some clients embedding LLVM as a library.
1080AC_ARG_ENABLE(crash-overrides, AS_HELP_STRING(
1081 [--enable-crash-overrides],
1082 [Enable crash handling overrides (default is YES)]),
1083 [case "$enableval" in
1084 yes) llvm_cv_enable_crash_overrides="yes" ;;
1085 no) llvm_cv_enable_crash_overrides="no" ;;
1086 *) AC_MSG_ERROR([Invalid setting for --enable-crash-overrides. Use "yes" or "no"]) ;;
1087 esac],
1088 llvm_cv_enable_crash_overrides="yes")
1089if test "$llvm_cv_enable_crash_overrides" = "yes" ; then
1090 AC_DEFINE([ENABLE_CRASH_OVERRIDES],[1],
1091 [Define to enable crash handling overrides])
1092fi
Eric Christopher9fafe072012-09-21 23:03:29 +00001093
NAKAMURA Takumi84e85302014-02-09 16:36:42 +00001094dnl List all possible targets
Tom Stellard45bb48e2015-06-13 03:28:10 +00001095ALL_TARGETS="X86 Sparc PowerPC ARM AArch64 Mips XCore MSP430 CppBackend NVPTX Hexagon SystemZ AMDGPU BPF"
NAKAMURA Takumi84e85302014-02-09 16:36:42 +00001096AC_SUBST(ALL_TARGETS,$ALL_TARGETS)
1097
Reid Spencer47428042005-04-22 07:27:28 +00001098dnl Allow specific targets to be specified for building (or not)
1099TARGETS_TO_BUILD=""
Evan Cheng5df72aa2006-07-06 07:46:33 +00001100AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
Jeffrey Yasskin42a49df2009-09-23 17:05:42 +00001101 [Build specific host targets: all or target1,target2,... Valid targets are:
Tim Northover00ed9962014-03-29 10:18:08 +00001102 host, x86, x86_64, sparc, powerpc, arm64, arm, aarch64, mips, hexagon,
Dan Gohman10e730a2015-06-29 23:51:55 +00001103 xcore, msp430, nvptx, systemz, r600, bpf, wasm, and cpp (default=all)]),,
Reid Spencere482ca82005-04-22 17:02:18 +00001104 enableval=all)
Jeffrey Yasskin42a49df2009-09-23 17:05:42 +00001105if test "$enableval" = host-only ; then
1106 enableval=host
1107fi
Reid Spencere482ca82005-04-22 17:02:18 +00001108case "$enableval" in
NAKAMURA Takumi84e85302014-02-09 16:36:42 +00001109 all) TARGETS_TO_BUILD="$ALL_TARGETS" ;;
Reid Spencere482ca82005-04-22 17:02:18 +00001110 *)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do
1111 case "$a_target" in
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +00001112 x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
1113 x86_64) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
1114 sparc) TARGETS_TO_BUILD="Sparc $TARGETS_TO_BUILD" ;;
1115 powerpc) TARGETS_TO_BUILD="PowerPC $TARGETS_TO_BUILD" ;;
Tim Northover3b0846e2014-05-24 12:50:23 +00001116 aarch64) TARGETS_TO_BUILD="AArch64 $TARGETS_TO_BUILD" ;;
1117 arm64) TARGETS_TO_BUILD="AArch64 $TARGETS_TO_BUILD" ;;
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +00001118 arm) TARGETS_TO_BUILD="ARM $TARGETS_TO_BUILD" ;;
Alexei Starovoitov7fef2f52015-06-09 18:53:30 +00001119 bpf) TARGETS_TO_BUILD="BPF $TARGETS_TO_BUILD" ;;
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +00001120 mips) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
Rafael Espindolae46f0962011-12-28 17:08:00 +00001121 mipsel) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
Simon Atanasyanc2cccd72012-10-29 19:49:45 +00001122 mips64) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
1123 mips64el) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +00001124 xcore) TARGETS_TO_BUILD="XCore $TARGETS_TO_BUILD" ;;
1125 msp430) TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;;
Jakob Stoklund Olesen526e8032009-08-02 17:32:37 +00001126 cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;;
Tony Linthicum1213a7a2011-12-12 21:14:40 +00001127 hexagon) TARGETS_TO_BUILD="Hexagon $TARGETS_TO_BUILD" ;;
Justin Holewinskiae556d32012-05-04 20:18:50 +00001128 nvptx) TARGETS_TO_BUILD="NVPTX $TARGETS_TO_BUILD" ;;
Ulrich Weigand1ceebf62013-05-06 16:22:34 +00001129 systemz) TARGETS_TO_BUILD="SystemZ $TARGETS_TO_BUILD" ;;
Tom Stellard3e79bb72015-06-13 03:46:48 +00001130 amdgpu) TARGETS_TO_BUILD="AMDGPU $TARGETS_TO_BUILD" ;;
Tom Stellard45bb48e2015-06-13 03:28:10 +00001131 r600) TARGETS_TO_BUILD="AMDGPU $TARGETS_TO_BUILD" ;;
Dan Gohman10e730a2015-06-29 23:51:55 +00001132 wasm) TARGETS_TO_BUILD="WebAssembly $TARGETS_TO_BUILD" ;;
Jeffrey Yasskin42a49df2009-09-23 17:05:42 +00001133 host) case "$llvm_cv_target_arch" in
1134 x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
1135 x86_64) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
1136 Sparc) TARGETS_TO_BUILD="Sparc $TARGETS_TO_BUILD" ;;
1137 PowerPC) TARGETS_TO_BUILD="PowerPC $TARGETS_TO_BUILD" ;;
Tim Northover3b0846e2014-05-24 12:50:23 +00001138 AArch64) TARGETS_TO_BUILD="AArch64 $TARGETS_TO_BUILD" ;;
Jeffrey Yasskin42a49df2009-09-23 17:05:42 +00001139 ARM) TARGETS_TO_BUILD="ARM $TARGETS_TO_BUILD" ;;
1140 Mips) TARGETS_TO_BUILD="Mips $TARGETS_TO_BUILD" ;;
Jeffrey Yasskin42a49df2009-09-23 17:05:42 +00001141 XCore) TARGETS_TO_BUILD="XCore $TARGETS_TO_BUILD" ;;
1142 MSP430) TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;;
Tony Linthicum1213a7a2011-12-12 21:14:40 +00001143 Hexagon) TARGETS_TO_BUILD="Hexagon $TARGETS_TO_BUILD" ;;
Justin Holewinskiae556d32012-05-04 20:18:50 +00001144 NVPTX) TARGETS_TO_BUILD="NVPTX $TARGETS_TO_BUILD" ;;
Ulrich Weigand1ceebf62013-05-06 16:22:34 +00001145 SystemZ) TARGETS_TO_BUILD="SystemZ $TARGETS_TO_BUILD" ;;
Dan Gohman10e730a2015-06-29 23:51:55 +00001146 WebAssembly) TARGETS_TO_BUILD="WebAssembly $TARGETS_TO_BUILD" ;;
Jeffrey Yasskin42a49df2009-09-23 17:05:42 +00001147 *) AC_MSG_ERROR([Can not set target to build]) ;;
1148 esac ;;
Reid Spencere482ca82005-04-22 17:02:18 +00001149 *) AC_MSG_ERROR([Unrecognized target $a_target]) ;;
1150 esac
Eric Christophere62b4412007-12-01 00:34:39 +00001151 done
Reid Spencere482ca82005-04-22 17:02:18 +00001152 ;;
1153esac
Victor Oliveira9d4b8f52012-08-09 01:13:59 +00001154
1155AC_ARG_ENABLE([experimental-targets],AS_HELP_STRING([--enable-experimental-targets],
1156 [Build experimental host targets: disable or target1,target2,...
1157 (default=disable)]),,
1158 enableval=disable)
1159
1160if test ${enableval} != "disable"
1161then
1162 TARGETS_TO_BUILD="$enableval $TARGETS_TO_BUILD"
1163fi
1164
Reid Spencer47428042005-04-22 07:27:28 +00001165AC_SUBST(TARGETS_TO_BUILD,$TARGETS_TO_BUILD)
1166
Gabor Greife0d58d32012-01-26 10:28:58 +00001167dnl Determine whether we are building LLVM support for the native architecture.
1168dnl If so, define LLVM_NATIVE_ARCH to that LLVM target.
Douglas Gregor7cbf8162009-06-17 00:42:33 +00001169for a_target in $TARGETS_TO_BUILD; do
1170 if test "$a_target" = "$LLVM_NATIVE_ARCH"; then
Eric Christophere7a9db12010-08-30 18:34:48 +00001171 AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCH, $LLVM_NATIVE_ARCH,
Douglas Gregor7cbf8162009-06-17 00:42:33 +00001172 [LLVM architecture name for the native architecture, if available])
Eric Christophere7a9db12010-08-30 18:34:48 +00001173 LLVM_NATIVE_TARGET="LLVMInitialize${LLVM_NATIVE_ARCH}Target"
1174 LLVM_NATIVE_TARGETINFO="LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo"
Evan Cheng8c886a42011-07-22 21:58:54 +00001175 LLVM_NATIVE_TARGETMC="LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC"
Eric Christophere7a9db12010-08-30 18:34:48 +00001176 LLVM_NATIVE_ASMPRINTER="LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter"
Jan Sjödinc9a16d52011-03-14 22:12:35 +00001177 if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/Makefile ; then
1178 LLVM_NATIVE_ASMPARSER="LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser"
1179 fi
Eric Christopher56079c12012-03-26 21:56:56 +00001180 if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/Makefile ; then
1181 LLVM_NATIVE_DISASSEMBLER="LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler"
1182 fi
Eric Christophere7a9db12010-08-30 18:34:48 +00001183 AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGET, $LLVM_NATIVE_TARGET,
1184 [LLVM name for the native Target init function, if available])
1185 AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGETINFO, $LLVM_NATIVE_TARGETINFO,
1186 [LLVM name for the native TargetInfo init function, if available])
Evan Cheng8c886a42011-07-22 21:58:54 +00001187 AC_DEFINE_UNQUOTED(LLVM_NATIVE_TARGETMC, $LLVM_NATIVE_TARGETMC,
1188 [LLVM name for the native target MC init function, if available])
Eric Christophere7a9db12010-08-30 18:34:48 +00001189 AC_DEFINE_UNQUOTED(LLVM_NATIVE_ASMPRINTER, $LLVM_NATIVE_ASMPRINTER,
1190 [LLVM name for the native AsmPrinter init function, if available])
Jan Sjödinc9a16d52011-03-14 22:12:35 +00001191 if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/AsmParser/Makefile ; then
1192 AC_DEFINE_UNQUOTED(LLVM_NATIVE_ASMPARSER, $LLVM_NATIVE_ASMPARSER,
1193 [LLVM name for the native AsmParser init function, if available])
1194 fi
Eric Christopher56079c12012-03-26 21:56:56 +00001195 if test -f ${srcdir}/lib/Target/${LLVM_NATIVE_ARCH}/Disassembler/Makefile ; then
1196 AC_DEFINE_UNQUOTED(LLVM_NATIVE_DISASSEMBLER, $LLVM_NATIVE_DISASSEMBLER,
1197 [LLVM name for the native Disassembler init function, if available])
1198 fi
Douglas Gregor7cbf8162009-06-17 00:42:33 +00001199 fi
1200done
1201
Gabor Greife0d58d32012-01-26 10:28:58 +00001202dnl Build the LLVM_TARGET and LLVM_... macros for Targets.def and the individual
1203dnl target feature def files.
Douglas Gregor1b731d52009-06-16 20:12:29 +00001204LLVM_ENUM_TARGETS=""
1205LLVM_ENUM_ASM_PRINTERS=""
Daniel Dunbar71475772009-07-17 20:42:00 +00001206LLVM_ENUM_ASM_PARSERS=""
Daniel Dunbarf4721292009-11-25 04:30:13 +00001207LLVM_ENUM_DISASSEMBLERS=""
Douglas Gregor1b731d52009-06-16 20:12:29 +00001208for target_to_build in $TARGETS_TO_BUILD; do
1209 LLVM_ENUM_TARGETS="LLVM_TARGET($target_to_build) $LLVM_ENUM_TARGETS"
Chris Lattner28776602010-11-14 19:10:47 +00001210 if test -f ${srcdir}/lib/Target/${target_to_build}/*AsmPrinter.cpp ; then
Eric Christopheref917742010-10-12 02:42:05 +00001211 LLVM_ENUM_ASM_PRINTERS="LLVM_ASM_PRINTER($target_to_build) $LLVM_ENUM_ASM_PRINTERS";
1212 fi
Daniel Dunbar71475772009-07-17 20:42:00 +00001213 if test -f ${srcdir}/lib/Target/${target_to_build}/AsmParser/Makefile ; then
1214 LLVM_ENUM_ASM_PARSERS="LLVM_ASM_PARSER($target_to_build) $LLVM_ENUM_ASM_PARSERS";
1215 fi
Daniel Dunbarf4721292009-11-25 04:30:13 +00001216 if test -f ${srcdir}/lib/Target/${target_to_build}/Disassembler/Makefile ; then
1217 LLVM_ENUM_DISASSEMBLERS="LLVM_DISASSEMBLER($target_to_build) $LLVM_ENUM_DISASSEMBLERS";
1218 fi
Douglas Gregor1b731d52009-06-16 20:12:29 +00001219done
1220AC_SUBST(LLVM_ENUM_TARGETS)
1221AC_SUBST(LLVM_ENUM_ASM_PRINTERS)
Daniel Dunbar71475772009-07-17 20:42:00 +00001222AC_SUBST(LLVM_ENUM_ASM_PARSERS)
Daniel Dunbarf4721292009-11-25 04:30:13 +00001223AC_SUBST(LLVM_ENUM_DISASSEMBLERS)
Douglas Gregor1b731d52009-06-16 20:12:29 +00001224
Daniel Dunbarb4a289c2009-11-04 04:32:50 +00001225dnl Override the option to use for optimized builds.
1226AC_ARG_WITH(optimize-option,
1227 AS_HELP_STRING([--with-optimize-option],
1228 [Select the compiler options to use for optimized builds]),,
1229 withval=default)
1230AC_MSG_CHECKING([optimization flags])
1231case "$withval" in
1232 default)
1233 case "$llvm_cv_os_type" in
Daniel Dunbare96fcbb2010-04-30 17:12:23 +00001234 FreeBSD) optimize_option=-O2 ;;
Daniel Dunbar4e06a5b2010-04-10 18:56:24 +00001235 MingW) optimize_option=-O2 ;;
1236 *) optimize_option=-O3 ;;
Daniel Dunbarb4a289c2009-11-04 04:32:50 +00001237 esac ;;
1238 *) optimize_option="$withval" ;;
1239esac
1240AC_SUBST(OPTIMIZE_OPTION,$optimize_option)
1241AC_MSG_RESULT([$optimize_option])
1242
Evan Chenga7bd00b2006-06-20 22:16:32 +00001243dnl Specify extra build options
1244AC_ARG_WITH(extra-options,
1245 AS_HELP_STRING([--with-extra-options],
Duncan Sandsef8c8ec2009-05-13 13:13:18 +00001246 [Specify additional options to compile LLVM with]),,
Reid Spencer84749ed2006-07-28 22:50:07 +00001247 withval=default)
1248case "$withval" in
Evan Chenga7bd00b2006-06-20 22:16:32 +00001249 default) EXTRA_OPTIONS= ;;
Reid Spencer84749ed2006-07-28 22:50:07 +00001250 *) EXTRA_OPTIONS=$withval ;;
Evan Chenga7bd00b2006-06-20 22:16:32 +00001251esac
1252AC_SUBST(EXTRA_OPTIONS,$EXTRA_OPTIONS)
Reid Spencer47428042005-04-22 07:27:28 +00001253
Daniel Dunbar0315d4a2011-06-16 22:30:38 +00001254dnl Specify extra linker build options
1255AC_ARG_WITH(extra-ld-options,
1256 AS_HELP_STRING([--with-extra-ld-options],
1257 [Specify additional options to link LLVM with]),,
1258 withval=default)
1259case "$withval" in
1260 default) EXTRA_LD_OPTIONS= ;;
1261 *) EXTRA_LD_OPTIONS=$withval ;;
1262esac
1263AC_SUBST(EXTRA_LD_OPTIONS,$EXTRA_LD_OPTIONS)
1264
Gordon Henriksend48f4592007-10-02 09:50:18 +00001265dnl Allow specific bindings to be specified for building (or not)
1266AC_ARG_ENABLE([bindings],AS_HELP_STRING([--enable-bindings],
1267 [Build specific language bindings: all,auto,none,{binding-name} (default=auto)]),,
1268 enableval=default)
1269BINDINGS_TO_BUILD=""
1270case "$enableval" in
Gordon Henriksen61400d12007-10-02 10:14:32 +00001271 yes | default | auto) BINDINGS_TO_BUILD="auto" ;;
Gordon Henriksend48f4592007-10-02 09:50:18 +00001272 all ) BINDINGS_TO_BUILD="ocaml" ;;
1273 none | no) BINDINGS_TO_BUILD="" ;;
1274 *)for a_binding in `echo $enableval|sed -e 's/,/ /g' ` ; do
1275 case "$a_binding" in
1276 ocaml) BINDINGS_TO_BUILD="ocaml $BINDINGS_TO_BUILD" ;;
1277 *) AC_MSG_ERROR([Unrecognized binding $a_binding]) ;;
1278 esac
Eric Christophere62b4412007-12-01 00:34:39 +00001279 done
Gordon Henriksend48f4592007-10-02 09:50:18 +00001280 ;;
1281esac
1282
Gordon Henriksen3be1f102007-10-02 16:42:10 +00001283dnl Allow the ocaml libdir to be overridden. This could go in a configure
1284dnl script for bindings/ocaml/configure, except that its auto value depends on
1285dnl OCAMLC, which is found here to support tests.
1286AC_ARG_WITH([ocaml-libdir],
1287 [AS_HELP_STRING([--with-ocaml-libdir],
1288 [Specify install location for ocaml bindings (default is stdlib)])],
1289 [],
1290 [withval=auto])
1291case "$withval" in
1292 auto) with_ocaml_libdir="$withval" ;;
1293 /* | [[A-Za-z]]:[[\\/]]*) with_ocaml_libdir="$withval" ;;
1294 *) AC_MSG_ERROR([Invalid path for --with-ocaml-libdir. Provide full path]) ;;
1295esac
1296
NAKAMURA Takumi914f1922011-10-16 02:54:26 +00001297AC_ARG_WITH(clang-srcdir,
1298 AS_HELP_STRING([--with-clang-srcdir],
1299 [Directory to the out-of-tree Clang source]),,
1300 withval="-")
1301case "$withval" in
Dylan Noblesmithb5190ab2012-02-02 00:17:33 +00001302 -) clang_src_root="" ;;
NAKAMURA Takumi914f1922011-10-16 02:54:26 +00001303 /* | [[A-Za-z]]:[[\\/]]*) clang_src_root="$withval" ;;
1304 *) clang_src_root="$ac_pwd/$withval" ;;
1305esac
1306AC_SUBST(CLANG_SRC_ROOT,[$clang_src_root])
1307
Chandler Carruthffae4a62010-10-19 08:21:25 +00001308AC_ARG_WITH(clang-resource-dir,
1309 AS_HELP_STRING([--with-clang-resource-dir],
1310 [Relative directory from the Clang binary for resource files]),,
1311 withval="")
1312AC_DEFINE_UNQUOTED(CLANG_RESOURCE_DIR,"$withval",
1313 [Relative directory for resource files])
1314
Rafael Espindola662908c2009-12-07 00:27:35 +00001315AC_ARG_WITH(c-include-dirs,
Rafael Espindolad95960b2009-11-12 05:46:09 +00001316 AS_HELP_STRING([--with-c-include-dirs],
1317 [Colon separated list of directories clang will search for headers]),,
1318 withval="")
1319AC_DEFINE_UNQUOTED(C_INCLUDE_DIRS,"$withval",
1320 [Directories clang will search for headers])
1321
Rafael Espindolaec217f62012-02-03 00:59:30 +00001322# Clang normally uses the system c++ headers and libraries. With this option,
1323# clang will use the ones provided by a gcc installation instead. This option should
1324# be passed the same value that was used with --prefix when configuring gcc.
1325AC_ARG_WITH(gcc-toolchain,
1326 AS_HELP_STRING([--with-gcc-toolchain],
1327 [Directory where gcc is installed.]),,
Rafael Espindola65e9be6d2009-11-16 19:46:55 +00001328 withval="")
Rafael Espindolaec217f62012-02-03 00:59:30 +00001329AC_DEFINE_UNQUOTED(GCC_INSTALL_PREFIX,"$withval",
1330 [Directory where gcc is installed.])
Rafael Espindola65e9be6d2009-11-16 19:46:55 +00001331
Sebastian Pope29a6c72012-04-30 20:06:58 +00001332AC_ARG_WITH(default-sysroot,
Sebastian Pop5c9e1842012-04-16 04:11:45 +00001333 AS_HELP_STRING([--with-default-sysroot],
1334 [Add --sysroot=<path> to all compiler invocations.]),,
1335 withval="")
1336AC_DEFINE_UNQUOTED(DEFAULT_SYSROOT,"$withval",
1337 [Default <path> to all compiler invocations for --sysroot=<path>.])
1338
Chandler Carruthcc83ce42015-05-28 01:47:22 +00001339AC_ARG_WITH(clang-default-openmp-runtime,
1340 AS_HELP_STRING([--with-clang-default-openmp-runtime],
1341 [The default OpenMP runtime for Clang.]),,
Chandler Carruth9b0a5612015-05-28 02:17:15 +00001342 withval="libgomp")
Chandler Carruthcc83ce42015-05-28 01:47:22 +00001343AC_DEFINE_UNQUOTED(CLANG_DEFAULT_OPENMP_RUNTIME,"$withval",
1344 [Default OpenMP runtime used by -fopenmp.])
1345
Nick Lewyckyedd8946b2009-02-03 07:10:08 +00001346dnl Allow linking of LLVM with GPLv3 binutils code.
1347AC_ARG_WITH(binutils-include,
1348 AS_HELP_STRING([--with-binutils-include],
1349 [Specify path to binutils/include/ containing plugin-api.h file for gold plugin.]),,
1350 withval=default)
1351case "$withval" in
1352 default) WITH_BINUTILS_INCDIR=default ;;
1353 /* | [[A-Za-z]]:[[\\/]]*) WITH_BINUTILS_INCDIR=$withval ;;
1354 *) AC_MSG_ERROR([Invalid path for --with-binutils-include. Provide full path]) ;;
1355esac
1356if test "x$WITH_BINUTILS_INCDIR" != xdefault ; then
1357 AC_SUBST(BINUTILS_INCDIR,$WITH_BINUTILS_INCDIR)
1358 if test ! -f "$WITH_BINUTILS_INCDIR/plugin-api.h"; then
1359 echo "$WITH_BINUTILS_INCDIR/plugin-api.h"
1360 AC_MSG_ERROR([Invalid path to directory containing plugin-api.h.]);
1361 fi
1362fi
1363
Chad Rosier445d39b2011-07-15 00:37:26 +00001364dnl Specify the URL where bug reports should be submitted.
1365AC_ARG_WITH(bug-report-url,
1366 AS_HELP_STRING([--with-bug-report-url],
Chad Rosier8c9d9b22011-08-02 20:53:43 +00001367 [Specify the URL where bug reports should be submitted (default=http://llvm.org/bugs/)]),,
1368 withval="http://llvm.org/bugs/")
Chad Rosier445d39b2011-07-15 00:37:26 +00001369AC_DEFINE_UNQUOTED(BUG_REPORT_URL,"$withval",
1370 [Bug report URL.])
1371
Chandler Carruthf11f1e42013-08-12 09:49:17 +00001372dnl --enable-terminfo: check whether the user wants to control use of terminfo:
1373AC_ARG_ENABLE(terminfo,AS_HELP_STRING(
1374 [--enable-terminfo],
1375 [Query the terminfo database if available (default is YES)]),
Chandler Carruthcad7e5e2013-08-07 08:47:36 +00001376 [case "$enableval" in
Chandler Carruthf11f1e42013-08-12 09:49:17 +00001377 yes) llvm_cv_enable_terminfo="yes" ;;
1378 no) llvm_cv_enable_terminfo="no" ;;
1379 *) AC_MSG_ERROR([Invalid setting for --enable-terminfo. Use "yes" or "no"]) ;;
Chandler Carruthcad7e5e2013-08-07 08:47:36 +00001380 esac],
Chandler Carruthf11f1e42013-08-12 09:49:17 +00001381 llvm_cv_enable_terminfo="yes")
NAKAMURA Takumi84e85302014-02-09 16:36:42 +00001382case "$llvm_cv_enable_terminfo" in
1383 yes) AC_SUBST(ENABLE_TERMINFO,[1]) ;;
1384 no) AC_SUBST(ENABLE_TERMINFO,[0]) ;;
1385esac
Chandler Carruthcad7e5e2013-08-07 08:47:36 +00001386
Peter Collingbournec7d437c2014-01-31 23:46:14 +00001387dnl --enable-libedit: check whether the user wants to turn off libedit.
1388AC_ARG_ENABLE(libedit,AS_HELP_STRING(
1389 [--enable-libedit],
1390 [Use libedit if available (default is YES)]),
1391 [case "$enableval" in
1392 yes) llvm_cv_enable_libedit="yes" ;;
1393 no) llvm_cv_enable_libedit="no" ;;
1394 *) AC_MSG_ERROR([Invalid setting for --enable-libedit. Use "yes" or "no"]) ;;
1395 esac],
1396 llvm_cv_enable_libedit="yes")
1397
Nick Lewycky9ab256ac2009-06-06 06:24:44 +00001398dnl --enable-libffi : check whether the user wants to turn off libffi:
1399AC_ARG_ENABLE(libffi,AS_HELP_STRING(
Jeffrey Yasskin914050b2010-02-09 23:03:44 +00001400 --enable-libffi,[Check for the presence of libffi (default is NO)]),
1401 [case "$enableval" in
1402 yes) llvm_cv_enable_libffi="yes" ;;
1403 no) llvm_cv_enable_libffi="no" ;;
1404 *) AC_MSG_ERROR([Invalid setting for --enable-libffi. Use "yes" or "no"]) ;;
1405 esac],
1406 llvm_cv_enable_libffi=no)
Nick Lewycky9ab256ac2009-06-06 06:24:44 +00001407
Bob Wilson3f354702011-11-28 07:59:52 +00001408AC_ARG_WITH(internal-prefix,
1409 AS_HELP_STRING([--with-internal-prefix],
1410 [Installation directory for internal files]),,
1411 withval="")
1412AC_SUBST(INTERNAL_PREFIX,[$withval])
1413
Reid Spencer0241e382004-11-25 04:51:04 +00001414dnl===-----------------------------------------------------------------------===
1415dnl===
1416dnl=== SECTION 4: Check for programs we need and that they are the right version
1417dnl===
1418dnl===-----------------------------------------------------------------------===
Reid Spencer67be17a2004-08-31 14:20:36 +00001419
Reid Spencer0241e382004-11-25 04:51:04 +00001420dnl Check for the tools that the makefiles require
1421AC_CHECK_GNU_MAKE
1422AC_PROG_LN_S
Rafael Espindolafd1355a2014-02-28 18:17:54 +00001423AC_PATH_PROG(NM, [nm], [nm])
Reid Spencerd42d5d42004-12-16 17:48:14 +00001424AC_PATH_PROG(CMP, [cmp], [cmp])
1425AC_PATH_PROG(CP, [cp], [cp])
Reid Spencer0194c9a2004-11-29 04:56:35 +00001426AC_PATH_PROG(DATE, [date], [date])
Reid Spencer0241e382004-11-25 04:51:04 +00001427AC_PATH_PROG(FIND, [find], [find])
1428AC_PATH_PROG(GREP, [grep], [grep])
1429AC_PATH_PROG(MKDIR,[mkdir],[mkdir])
Reid Spencer0194c9a2004-11-29 04:56:35 +00001430AC_PATH_PROG(MV, [mv], [mv])
Reid Spencer0241e382004-11-25 04:51:04 +00001431AC_PROG_RANLIB
Torok Edwin1e86bc52010-01-26 08:48:04 +00001432AC_CHECK_TOOL(AR, ar, false)
Reid Spencer0194c9a2004-11-29 04:56:35 +00001433AC_PATH_PROG(RM, [rm], [rm])
1434AC_PATH_PROG(SED, [sed], [sed])
1435AC_PATH_PROG(TAR, [tar], [gtar])
Reid Spencer9372247e2006-07-28 05:05:00 +00001436AC_PATH_PROG(BINPWD,[pwd], [pwd])
Reid Spencer432b3152006-06-02 23:13:18 +00001437
1438dnl Looking for misc. graph plotting software
Reid Spencer627023a2006-06-05 15:54:38 +00001439AC_PATH_PROG(DOT, [dot], [echo dot])
1440if test "$DOT" != "echo dot" ; then
1441 AC_DEFINE([HAVE_DOT],[1],[Define if the dot program is available])
1442 dnl If we're targeting for mingw we should emit windows paths, not msys
Jeff Cohenc5e5b272007-01-12 18:22:38 +00001443 if test "$llvm_cv_os_type" = "MingW" ; then
Reid Spencer627023a2006-06-05 15:54:38 +00001444 DOT=`echo $DOT | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
1445 fi
1446 AC_DEFINE_UNQUOTED([LLVM_PATH_DOT],"$DOT${EXEEXT}",
1447 [Define to path to dot program if found or 'echo dot' otherwise])
1448fi
Reid Spencer0241e382004-11-25 04:51:04 +00001449
1450dnl Find the install program
1451AC_PROG_INSTALL
Eric Christopherc7289b62010-07-22 21:13:40 +00001452dnl Prepend src dir to install path dir if it's a relative path
1453dnl This is a hack for installs that take place in something other
1454dnl than the top level.
1455case "$INSTALL" in
1456 [[\\/$]]* | ?:[[\\/]]* ) ;;
1457 *) INSTALL="\\\$(TOPSRCDIR)/$INSTALL" ;;
1458esac
John Criswell7a3334d2003-07-22 19:13:20 +00001459
Reid Spencer0194c9a2004-11-29 04:56:35 +00001460dnl Checks for documentation and testing tools that we can do without. If these
1461dnl are not found then they are set to "true" which always succeeds but does
Eric Christophere62b4412007-12-01 00:34:39 +00001462dnl nothing. This just lets the build output show that we could have done
1463dnl something if the tool was available.
Bill Wendling5ddd03d2008-03-05 09:28:02 +00001464AC_PATH_PROG(BZIP2, [bzip2])
mike-me08af302010-05-06 23:45:43 +00001465AC_PATH_PROG(CAT, [cat])
Bill Wendling5ddd03d2008-03-05 09:28:02 +00001466AC_PATH_PROG(DOXYGEN, [doxygen])
Daniel Dunbard1888822012-05-08 18:26:07 +00001467AC_PATH_PROG(GROFF, [groff])
Eric Christopher77560892010-12-10 01:31:51 +00001468AC_PATH_PROG(GZIPBIN, [gzip])
Daniel Dunbard1888822012-05-08 18:26:07 +00001469AC_PATH_PROG(PDFROFF, [pdfroff])
Bill Wendling5ddd03d2008-03-05 09:28:02 +00001470AC_PATH_PROG(ZIP, [zip])
Peter Collingbourne82e3e372014-10-16 22:48:02 +00001471AC_PATH_PROG(GO, [go])
Peter Zotov668f9672014-10-30 08:29:45 +00001472AC_PATH_PROGS(OCAMLFIND, [ocamlfind])
Daniel Dunbard1888822012-05-08 18:26:07 +00001473AC_PATH_PROGS(GAS, [gas as])
Reid Spencer0241e382004-11-25 04:51:04 +00001474
Daniel Dunbarb524afb2010-08-11 23:53:59 +00001475dnl Get the version of the linker in use.
1476AC_LINK_GET_VERSION
1477
Nick Lewycky16aac992009-03-05 08:20:21 +00001478dnl Determine whether the linker supports the -R option.
Reid Spencer0241e382004-11-25 04:51:04 +00001479AC_LINK_USE_R
1480
Bob Wilson8658b912013-08-02 22:51:06 +00001481dnl Determine whether the compiler supports the -rdynamic option.
Nick Lewycky16aac992009-03-05 08:20:21 +00001482AC_LINK_EXPORT_DYNAMIC
1483
Dan Gohmanb7edb422010-06-01 14:56:56 +00001484dnl Determine whether the linker supports the --version-script option.
1485AC_LINK_VERSION_SCRIPT
Dan Gohman91f8ad72010-04-16 22:58:15 +00001486
Rafael Espindolafd1355a2014-02-28 18:17:54 +00001487AC_CHECK_HEADERS([errno.h])
1488
1489case "$llvm_cv_os_type" in
1490 Cygwin|MingW|Win32) llvm_shlib_ext=.dll ;;
1491 Darwin) llvm_shlib_ext=.dylib ;;
1492 *) llvm_shlib_ext=.so ;;
1493esac
1494
1495AC_DEFINE_UNQUOTED([LTDL_SHLIB_EXT], ["$llvm_shlib_ext"], [The shared library extension])
Mikhail Glushenkov2c332fe2009-04-21 19:46:10 +00001496
Reid Spencer0241e382004-11-25 04:51:04 +00001497AC_MSG_CHECKING([tool compatibility])
1498
Reid Spencerca06c8e2004-12-08 23:07:27 +00001499dnl Ensure that compilation tools are GCC or a GNU compatible compiler such as
1500dnl ICC; we use GCC specific options in the makefiles so the compiler needs
1501dnl to support those options.
1502dnl "icc" emits gcc signatures
1503dnl "icc -no-gcc" emits no gcc signature BUT is still compatible
1504ICC=no
1505IXX=no
1506case $CC in
Eric Christophere62b4412007-12-01 00:34:39 +00001507 icc*|icpc*)
Reid Spencerca06c8e2004-12-08 23:07:27 +00001508 ICC=yes
1509 IXX=yes
1510 ;;
1511 *)
1512 ;;
1513esac
1514
Duraid Madina8604de82006-02-15 07:57:42 +00001515if test "$GCC" != "yes" && test "$ICC" != "yes"
1516then
1517 AC_MSG_ERROR([gcc|icc required but not found])
1518fi
1519
Daniel Dunbar00e7a842010-12-08 01:48:03 +00001520dnl Ensure that compilation tools are compatible with GCC extensions
Duraid Madina8604de82006-02-15 07:57:42 +00001521if test "$GXX" != "yes" && test "$IXX" != "yes"
1522then
Daniel Dunbar00e7a842010-12-08 01:48:03 +00001523 AC_MSG_ERROR([g++|clang++|icc required but not found])
Duraid Madina8604de82006-02-15 07:57:42 +00001524fi
1525
Reid Spencer0241e382004-11-25 04:51:04 +00001526dnl Verify that GCC is version 3.0 or higher
Reid Spencerca06c8e2004-12-08 23:07:27 +00001527if test "$GCC" = "yes"
Reid Spencer0241e382004-11-25 04:51:04 +00001528then
NAKAMURA Takumie5bc87c2013-01-30 01:37:55 +00001529 AC_COMPILE_IFELSE(
1530[
1531 AC_LANG_SOURCE([[
1532 #if !defined(__GNUC__) || __GNUC__ < 3
1533 #error Unsupported GCC version
1534 #endif
1535 ]])
1536],
1537[], [AC_MSG_ERROR([gcc 3.x required, but you have a lower version])])
Reid Spencer0241e382004-11-25 04:51:04 +00001538fi
1539
1540dnl Check for GNU Make. We use its extensions, so don't build without it
1541if test -z "$llvm_cv_gnu_make_command"
1542then
1543 AC_MSG_ERROR([GNU Make required but not found])
1544fi
1545
1546dnl Tool compatibility is okay if we make it here.
1547AC_MSG_RESULT([ok])
1548
Eric Christopherb3762a02010-03-02 05:17:21 +00001549dnl Check optional compiler flags.
Julien Lerougee4492f62009-10-26 19:58:44 +00001550AC_MSG_CHECKING([optional compiler flags])
1551CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
1552CXX_FLAG_CHECK(NO_MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers])
Rafael Espindola42e94d12012-02-28 23:32:06 +00001553CXX_FLAG_CHECK(COVERED_SWITCH_DEFAULT, [-Wcovered-switch-default])
Dmitri Gribenkob5e23ef2013-02-13 21:19:39 +00001554
David Greene9ff8d472013-01-09 22:11:13 +00001555dnl GCC's potential uninitialized use analysis is weak and presents lots of
1556dnl false positives, so disable it.
Dmitri Gribenkob5e23ef2013-02-13 21:19:39 +00001557NO_UNINITIALIZED=
1558NO_MAYBE_UNINITIALIZED=
David Greene9ff8d472013-01-09 22:11:13 +00001559if test "$GXX" = "yes"
1560then
1561 CXX_FLAG_CHECK(NO_MAYBE_UNINITIALIZED, [-Wno-maybe-uninitialized])
1562 dnl gcc 4.7 introduced -Wmaybe-uninitialized to distinguish cases which are
Dmitri Gribenkob5e23ef2013-02-13 21:19:39 +00001563 dnl known to be uninitialized from cases which might be uninitialized. We
David Greene9ff8d472013-01-09 22:11:13 +00001564 dnl still want to catch the first kind of errors.
Dmitri Gribenkob5e23ef2013-02-13 21:19:39 +00001565 if test -z "$NO_MAYBE_UNINITIALIZED"
David Greene9ff8d472013-01-09 22:11:13 +00001566 then
1567 CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
David Greene9ff8d472013-01-09 22:11:13 +00001568 fi
David Greene9ff8d472013-01-09 22:11:13 +00001569fi
Eric Christopher65ec83b2014-11-05 00:35:15 +00001570
1571dnl Check for misbehaving -Wcomment (gcc-4.7 has this) and maybe add
1572dnl -Wno-comment to the flags.
1573no_comment=
1574llvm_cv_old_cxxflags="$CXXFLAGS"
1575CXXFLAGS="$CXXFLAGS -Wcomment -Werror"
1576AC_COMPILE_IFELSE(
1577[
1578 AC_LANG_SOURCE([[// Comment \o\
1579// Another comment
1580int main() { return 0; }
1581 ]])
1582],
1583[
1584 no_comment=-Wno-comment
1585],
1586[])
1587AC_SUBST(NO_COMMENT, [$no_comment])
1588CXXFLAGS="$llvm_cv_old_cxxflags"
1589
1590AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT])
David Greene9ff8d472013-01-09 22:11:13 +00001591
Saleem Abdulrasool26127bd2013-01-30 04:07:37 +00001592AC_ARG_WITH([python],
1593 [AS_HELP_STRING([--with-python], [path to python])],
1594 [PYTHON="$withval"])
1595
1596if test -n "$PYTHON" && test -x "$PYTHON" ; then
1597 AC_MSG_CHECKING([for python])
1598 AC_MSG_RESULT([user defined: $with_python])
1599else
1600 if test -n "$PYTHON" ; then
1601 AC_MSG_WARN([specified python ($PYTHON) is not usable, searching path])
1602 fi
1603
Rafael Espindola21a400852014-12-12 15:29:31 +00001604 AC_PATH_PROG([PYTHON], [python python2 python27],
Saleem Abdulrasool26127bd2013-01-30 04:07:37 +00001605 [AC_MSG_RESULT([not found])
Rafael Espindola21a400852014-12-12 15:29:31 +00001606 AC_MSG_ERROR([could not find python 2.7 or higher])])
Saleem Abdulrasool26127bd2013-01-30 04:07:37 +00001607fi
1608
Rafael Espindola21a400852014-12-12 15:29:31 +00001609AC_MSG_CHECKING([for python >= 2.7])
Bill Wendling58463e4e82013-10-12 08:42:59 +00001610ac_python_version=`$PYTHON -V 2>&1 | cut -d' ' -f2`
Saleem Abdulrasool26127bd2013-01-30 04:07:37 +00001611ac_python_version_major=`echo $ac_python_version | cut -d'.' -f1`
1612ac_python_version_minor=`echo $ac_python_version | cut -d'.' -f2`
1613ac_python_version_patch=`echo $ac_python_version | cut -d'.' -f3`
Bill Wendling58463e4e82013-10-12 08:42:59 +00001614if test "$ac_python_version_major" -gt "2" || \
1615 (test "$ac_python_version_major" -eq "2" && \
Rafael Espindola21a400852014-12-12 15:29:31 +00001616 test "$ac_python_version_minor" -ge "7") ; then
Saleem Abdulrasool26127bd2013-01-30 04:07:37 +00001617 AC_MSG_RESULT([$PYTHON ($ac_python_version)])
1618else
1619 AC_MSG_RESULT([not found])
Rafael Espindola21a400852014-12-12 15:29:31 +00001620 AC_MSG_FAILURE([found python $ac_python_version ($PYTHON); required >= 2.7])
Saleem Abdulrasool26127bd2013-01-30 04:07:37 +00001621fi
Julien Lerougee4492f62009-10-26 19:58:44 +00001622
Reid Spencer0241e382004-11-25 04:51:04 +00001623dnl===-----------------------------------------------------------------------===
1624dnl===
1625dnl=== SECTION 5: Check for libraries
1626dnl===
1627dnl===-----------------------------------------------------------------------===
1628
Reid Spencerec4a7f522006-01-19 08:31:08 +00001629AC_CHECK_LIB(m,sin)
Jeff Cohenc5e5b272007-01-12 18:22:38 +00001630if test "$llvm_cv_os_type" = "MingW" ; then
Reid Spencer187b4ad2006-06-01 19:03:21 +00001631 AC_CHECK_LIB(imagehlp, main)
NAKAMURA Takumid55d7f52015-06-18 04:16:05 +00001632 AC_CHECK_LIB(ole32, main)
Reid Spencer187b4ad2006-06-01 19:03:21 +00001633 AC_CHECK_LIB(psapi, main)
David Majnemer61eae2e2013-10-07 01:00:07 +00001634 AC_CHECK_LIB(shell32, main)
Reid Spencera16b9862006-06-01 16:55:59 +00001635fi
Reid Spencercd59fb72005-07-12 07:19:13 +00001636
Brian Gaeke25f2a372003-10-07 05:03:36 +00001637dnl dlopen() is required for plugin support.
NAKAMURA Takumi84e85302014-02-09 16:36:42 +00001638AC_SEARCH_LIBS(dlopen,dl,LLVM_DEFINE_SUBST([HAVE_DLOPEN],[1],
Reid Spencer0241e382004-11-25 04:51:04 +00001639 [Define if dlopen() is available on this platform.]),
1640 AC_MSG_WARN([dlopen() not found - disabling plugin support]))
John Criswell7a3334d2003-07-22 19:13:20 +00001641
Chandler Carruthd121a7b2013-01-05 00:29:06 +00001642dnl Search for the clock_gettime() function. Note that we rely on the POSIX
Chandler Carruth4a778632013-01-05 00:34:40 +00001643dnl macros to detect whether clock_gettime is available, this just finds the
1644dnl right libraries to link with.
Chandler Carruthd121a7b2013-01-05 00:29:06 +00001645AC_SEARCH_LIBS(clock_gettime,rt)
Chandler Carruthef7f9682013-01-04 23:19:55 +00001646
Chandler Carruthcad7e5e2013-08-07 08:47:36 +00001647dnl The curses library is optional; used for querying terminal info
Chandler Carruthf11f1e42013-08-12 09:49:17 +00001648if test "$llvm_cv_enable_terminfo" = "yes" ; then
Chandler Carruthcad7e5e2013-08-07 08:47:36 +00001649 dnl We need the has_color functionality in curses for it to be useful.
Joerg Sonnenberger4e5a3992013-08-17 11:06:00 +00001650 AC_SEARCH_LIBS(setupterm,tinfo terminfo curses ncurses ncursesw,
NAKAMURA Takumi84e85302014-02-09 16:36:42 +00001651 LLVM_DEFINE_SUBST([HAVE_TERMINFO],[1],
1652 [Define if the setupterm() function is supported this platform.]))
Chandler Carruthcad7e5e2013-08-07 08:47:36 +00001653fi
1654
Peter Collingbournec7d437c2014-01-31 23:46:14 +00001655dnl The libedit library is optional; used by lib/LineEditor
1656if test "$llvm_cv_enable_libedit" = "yes" ; then
1657 AC_SEARCH_LIBS(el_init,edit,
1658 AC_DEFINE([HAVE_LIBEDIT],[1],
1659 [Define if libedit is available on this platform.]))
1660fi
1661
Nick Lewyckya89ec992009-02-04 06:26:47 +00001662dnl libffi is optional; used to call external functions from the interpreter
Nick Lewycky9ab256ac2009-06-06 06:24:44 +00001663if test "$llvm_cv_enable_libffi" = "yes" ; then
1664 AC_SEARCH_LIBS(ffi_call,ffi,AC_DEFINE([HAVE_FFI_CALL],[1],
1665 [Define if libffi is available on this platform.]),
Jeffrey Yasskin914050b2010-02-09 23:03:44 +00001666 AC_MSG_ERROR([libffi not found - configure without --enable-libffi to compile without it]))
Nick Lewycky9ab256ac2009-06-06 06:24:44 +00001667fi
Nick Lewyckya89ec992009-02-04 06:26:47 +00001668
John Criswell7a3334d2003-07-22 19:13:20 +00001669dnl mallinfo is optional; the code can compile (minus features) without it
Reid Spencer0241e382004-11-25 04:51:04 +00001670AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],
1671 [Define if mallinfo() is available on this platform.]))
John Criswell7a3334d2003-07-22 19:13:20 +00001672
Brian Gaeke7ee7b402003-12-05 19:29:01 +00001673dnl pthread locking functions are optional - but llvm will not be thread-safe
1674dnl without locks.
Dylan Noblesmithefddf202011-11-28 00:48:58 +00001675if test "$LLVM_ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
Edward O'Callaghanedea3262009-10-14 11:12:33 +00001676 AC_CHECK_LIB(pthread, pthread_mutex_init)
Reid Spencerf85fabeb2005-08-24 10:07:20 +00001677 AC_SEARCH_LIBS(pthread_mutex_lock,pthread,
1678 AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],
1679 [Have pthread_mutex_lock]))
Owen Andersona149e222009-06-16 18:20:20 +00001680 AC_SEARCH_LIBS(pthread_rwlock_init,pthread,
1681 AC_DEFINE([HAVE_PTHREAD_RWLOCK_INIT],[1],
1682 [Have pthread_rwlock_init]))
Owen Anderson11549832009-06-25 23:10:26 +00001683 AC_SEARCH_LIBS(pthread_getspecific,pthread,
1684 AC_DEFINE([HAVE_PTHREAD_GETSPECIFIC],[1],
1685 [Have pthread_getspecific]))
Reid Spencerf85fabeb2005-08-24 10:07:20 +00001686fi
Brian Gaeke7ee7b402003-12-05 19:29:01 +00001687
Alexey Samsonov2fb337e2013-04-23 08:28:39 +00001688dnl zlib is optional; used for compression/uncompression
1689if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
1690 AC_CHECK_LIB(z, compress2)
1691fi
1692
Jeffrey Yasskinbf3d6ba2009-07-10 21:08:20 +00001693dnl Allow OProfile support for JIT output.
1694AC_ARG_WITH(oprofile,
1695 AS_HELP_STRING([--with-oprofile=<prefix>],
1696 [Tell OProfile >= 0.9.4 how to symbolize JIT output]),
1697 [
1698 AC_SUBST(USE_OPROFILE, [1])
1699 case "$withval" in
1700 /usr|yes) llvm_cv_oppath=/usr/lib/oprofile ;;
Jeffrey Yasskin2da72312009-10-07 23:22:42 +00001701 no) llvm_cv_oppath=
1702 AC_SUBST(USE_OPROFILE, [0]) ;;
Jeffrey Yasskinbf3d6ba2009-07-10 21:08:20 +00001703 *) llvm_cv_oppath="${withval}/lib/oprofile"
Eric Christopher46342fe2012-08-03 17:45:31 +00001704 CPPFLAGS="-I${withval}/include";;
Jeffrey Yasskinbf3d6ba2009-07-10 21:08:20 +00001705 esac
Eli Bendersky5262ad22012-03-13 08:33:15 +00001706 case $llvm_cv_os_type in
1707 Linux)
1708 if test -n "$llvm_cv_oppath" ; then
1709 LIBS="$LIBS -lopagent -L${llvm_cv_oppath} -Wl,-rpath,${llvm_cv_oppath}"
1710 dnl Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=537744:
1711 dnl libbfd is not included properly in libopagent in some Debian
1712 dnl versions. If libbfd isn't found at all, we assume opagent works
1713 dnl anyway.
1714 AC_SEARCH_LIBS(bfd_init, bfd, [], [])
1715 AC_SEARCH_LIBS(op_open_agent, opagent, [], [
1716 echo "Error! You need to have libopagent around."
Sylvestre Ledru1b3961c2015-02-01 14:55:43 +00001717 exit 1
Eli Bendersky5262ad22012-03-13 08:33:15 +00001718 ])
1719 AC_CHECK_HEADER([opagent.h], [], [
1720 echo "Error! You need to have opagent.h around."
Sylvestre Ledru1b3961c2015-02-01 14:55:43 +00001721 exit 1
Eli Bendersky5262ad22012-03-13 08:33:15 +00001722 ])
1723 fi ;;
1724 *)
1725 AC_MSG_ERROR([OProfile support is available on Linux only.]) ;;
Peter Zotov668f9672014-10-30 08:29:45 +00001726 esac
Jeffrey Yasskinbf3d6ba2009-07-10 21:08:20 +00001727 ],
1728 [
Jeffrey Yasskin2da72312009-10-07 23:22:42 +00001729 AC_SUBST(USE_OPROFILE, [0])
Jeffrey Yasskinbf3d6ba2009-07-10 21:08:20 +00001730 ])
Eli Bendersky5262ad22012-03-13 08:33:15 +00001731AC_DEFINE_UNQUOTED([LLVM_USE_OPROFILE],$USE_OPROFILE,
Jeffrey Yasskinbf3d6ba2009-07-10 21:08:20 +00001732 [Define if we have the oprofile JIT-support library])
1733
Eli Bendersky5262ad22012-03-13 08:33:15 +00001734dnl Enable support for Intel JIT Events API.
1735AC_ARG_WITH(intel-jitevents,
Andrew Kaylor5808c7d2012-09-28 17:35:20 +00001736 AS_HELP_STRING([--with-intel-jitevents Notify Intel JIT profiling API of generated code]),
Eli Bendersky5262ad22012-03-13 08:33:15 +00001737 [
Andrew Kaylor5808c7d2012-09-28 17:35:20 +00001738 case "$withval" in
1739 yes) AC_SUBST(USE_INTEL_JITEVENTS,[1]);;
1740 no) AC_SUBST(USE_INTEL_JITEVENTS,[0]);;
1741 *) AC_MSG_ERROR([Invalid setting for --with-intel-jitevents. Use "yes" or "no"]);;
1742 esac
1743
Eli Bendersky5262ad22012-03-13 08:33:15 +00001744 case $llvm_cv_os_type in
1745 Linux|Win32|Cygwin|MingW) ;;
Andrew Kaylor5808c7d2012-09-28 17:35:20 +00001746 *) AC_MSG_ERROR([Intel JIT API support is available on Linux and Windows only.]);;
Eli Bendersky5262ad22012-03-13 08:33:15 +00001747 esac
1748
Eli Bendersky5262ad22012-03-13 08:33:15 +00001749 case "$llvm_cv_target_arch" in
Andrew Kaylor5808c7d2012-09-28 17:35:20 +00001750 x86|x86_64) ;;
1751 *) AC_MSG_ERROR([Target architecture $llvm_cv_target_arch does not support Intel JIT Events API.]);;
Eli Bendersky5262ad22012-03-13 08:33:15 +00001752 esac
Eli Bendersky5262ad22012-03-13 08:33:15 +00001753 ],
1754 [
1755 AC_SUBST(USE_INTEL_JITEVENTS, [0])
1756 ])
1757AC_DEFINE_UNQUOTED([LLVM_USE_INTEL_JITEVENTS],$USE_INTEL_JITEVENTS,
1758 [Define if we have the Intel JIT API runtime support library])
1759
Eric Christopherc807c532012-08-03 19:47:19 +00001760dnl Check for libxml2
1761dnl Right now we're just checking for the existence, we could also check for a
1762dnl particular version via --version on xml2-config
1763AC_CHECK_PROGS(XML2CONFIG, xml2-config)
1764
1765AC_MSG_CHECKING(for libxml2 includes)
1766if test "x$XML2CONFIG" = "x"; then
1767 AC_MSG_RESULT(xml2-config not found)
1768else
1769 LIBXML2_INC=`$XML2CONFIG --cflags`
1770 AC_MSG_RESULT($LIBXML2_INC)
1771 AC_CHECK_LIB(xml2, xmlReadFile,[AC_DEFINE([CLANG_HAVE_LIBXML],1,[Define if we have libxml2])
1772 LIBXML2_LIBS="-lxml2"])
1773fi
1774AC_SUBST(LIBXML2_LIBS)
1775AC_SUBST(LIBXML2_INC)
1776
Reid Spencer0241e382004-11-25 04:51:04 +00001777dnl===-----------------------------------------------------------------------===
1778dnl===
1779dnl=== SECTION 6: Check for header files
1780dnl===
1781dnl===-----------------------------------------------------------------------===
1782
Reid Spencer8bc110c2004-12-25 07:31:29 +00001783dnl First, use autoconf provided macros for specific headers that we need
Brian Gaeke2abe7ae2004-01-13 06:43:16 +00001784dnl We don't check for ancient stuff or things that are guaranteed to be there
1785dnl by the C++ standard. We always use the <cfoo> versions of <foo.h> C headers.
Reid Spencer8bc110c2004-12-25 07:31:29 +00001786dnl Generally we're looking for POSIX headers.
1787AC_HEADER_DIRENT
Reid Spencer0241e382004-11-25 04:51:04 +00001788AC_HEADER_MMAP_ANONYMOUS
Reid Spencer8bc110c2004-12-25 07:31:29 +00001789AC_HEADER_STAT
Reid Spencer8bc110c2004-12-25 07:31:29 +00001790AC_HEADER_SYS_WAIT
1791AC_HEADER_TIME
John Criswell7a3334d2003-07-22 19:13:20 +00001792
Benjamin Kramer00622f72013-05-03 15:55:06 +00001793AC_LANG_PUSH([C++])
Rui Ueyama292fb6d2014-10-27 08:16:18 +00001794dnl size_t must be defined before including cxxabi.h on FreeBSD 10.0.
1795AC_CHECK_HEADERS([cxxabi.h], [], [],
1796[#include <stddef.h>
1797])
Benjamin Kramer00622f72013-05-03 15:55:06 +00001798AC_LANG_POP([C++])
Rui Ueyama292fb6d2014-10-27 08:16:18 +00001799
Reid Kleckner37f69de2013-07-26 16:54:23 +00001800AC_CHECK_HEADERS([dlfcn.h execinfo.h fcntl.h inttypes.h link.h])
Douglas Gregorb81294d2009-05-18 17:21:34 +00001801AC_CHECK_HEADERS([malloc.h setjmp.h signal.h stdint.h termios.h unistd.h])
Reid Kleckner37f69de2013-07-26 16:54:23 +00001802AC_CHECK_HEADERS([utime.h])
Daniel Dunbar80da3fb2011-02-03 02:39:58 +00001803AC_CHECK_HEADERS([sys/mman.h sys/param.h sys/resource.h sys/time.h sys/uio.h])
Reid Kleckner37f69de2013-07-26 16:54:23 +00001804AC_CHECK_HEADERS([sys/ioctl.h malloc/malloc.h mach/mach.h])
Jeffrey Yasskin3ddd88f2010-03-15 04:57:55 +00001805AC_CHECK_HEADERS([valgrind/valgrind.h])
Dan Gohmanb48f9042010-09-17 20:06:27 +00001806AC_CHECK_HEADERS([fenv.h])
Joerg Sonnenberger8a1177f2013-03-25 13:13:33 +00001807AC_CHECK_DECLS([FE_ALL_EXCEPT, FE_INEXACT], [], [], [[#include <fenv.h>]])
Dylan Noblesmithefddf202011-11-28 00:48:58 +00001808if test "$LLVM_ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
Reid Spencer83bcd762007-08-17 05:44:59 +00001809 AC_CHECK_HEADERS(pthread.h,
Nick Lewyckya89ec992009-02-04 06:26:47 +00001810 AC_SUBST(HAVE_PTHREAD, 1),
1811 AC_SUBST(HAVE_PTHREAD, 0))
Reid Spencerd4399922006-12-01 00:37:14 +00001812else
1813 AC_SUBST(HAVE_PTHREAD, 0)
Reid Spencerf85fabeb2005-08-24 10:07:20 +00001814fi
Alexey Samsonov2fb337e2013-04-23 08:28:39 +00001815if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
1816 AC_CHECK_HEADERS(zlib.h,
1817 AC_SUBST(HAVE_LIBZ, 1),
1818 AC_SUBST(HAVE_LIBZ, 0))
1819else
1820 AC_SUBST(HAVE_LIBZ, 0)
1821fi
Brian Gaeke090ed132004-02-23 22:07:01 +00001822
Nick Lewyckye54da992009-04-13 04:26:06 +00001823dnl Try to find ffi.h.
Nick Lewycky9ab256ac2009-06-06 06:24:44 +00001824if test "$llvm_cv_enable_libffi" = "yes" ; then
1825 AC_CHECK_HEADERS([ffi.h ffi/ffi.h])
1826fi
Nick Lewyckya89ec992009-02-04 06:26:47 +00001827
Eric Christopherca466732010-12-03 07:45:22 +00001828dnl Try to find Darwin specific crash reporting libraries.
Eric Christophere9c1bb62010-06-22 21:01:04 +00001829AC_CHECK_HEADERS([CrashReporterClient.h])
1830
Eric Christopherca466732010-12-03 07:45:22 +00001831dnl Try to find Darwin specific crash reporting global.
Eric Christopherba4f7722010-12-07 02:05:42 +00001832AC_MSG_CHECKING([__crashreporter_info__])
1833AC_LINK_IFELSE(
NAKAMURA Takumie5bc87c2013-01-30 01:37:55 +00001834[
1835 AC_LANG_SOURCE([[
1836 extern const char *__crashreporter_info__;
1837 int main() {
1838 __crashreporter_info__ = "test";
1839 return 0;
1840 }
1841 ]])
1842],
1843[
1844 AC_MSG_RESULT([yes])
NAKAMURA Takumi58da26b2013-01-30 01:38:03 +00001845 AC_DEFINE([HAVE_CRASHREPORTER_INFO], [1], [can use __crashreporter_info__])
NAKAMURA Takumie5bc87c2013-01-30 01:37:55 +00001846],
1847[
1848 AC_MSG_RESULT([no])
NAKAMURA Takumi58da26b2013-01-30 01:38:03 +00001849 AC_DEFINE([HAVE_CRASHREPORTER_INFO], [0], [can use __crashreporter_info__])
NAKAMURA Takumie5bc87c2013-01-30 01:37:55 +00001850])
Eric Christopherba4f7722010-12-07 02:05:42 +00001851
Reid Spencer0241e382004-11-25 04:51:04 +00001852dnl===-----------------------------------------------------------------------===
1853dnl===
1854dnl=== SECTION 7: Check for types and structures
1855dnl===
1856dnl===-----------------------------------------------------------------------===
1857
Reid Spencer128ae102006-11-03 18:04:08 +00001858AC_HUGE_VAL_CHECK
John Criswell7a3334d2003-07-22 19:13:20 +00001859AC_TYPE_PID_T
1860AC_TYPE_SIZE_T
Torok Edwin1e86bc52010-01-26 08:48:04 +00001861AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[Define as the return type of signal handlers (`int' or `void').])
Reid Spencer0241e382004-11-25 04:51:04 +00001862AC_STRUCT_TM
John Criswell7a3334d2003-07-22 19:13:20 +00001863AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
Reid Spencerab2228a2004-09-02 21:38:24 +00001864AC_CHECK_TYPES([uint64_t],,
Reid Spencer0241e382004-11-25 04:51:04 +00001865 AC_CHECK_TYPES([u_int64_t],,
1866 AC_MSG_ERROR([Type uint64_t or u_int64_t required but not found])))
John Criswell7a3334d2003-07-22 19:13:20 +00001867
Reid Spencer0241e382004-11-25 04:51:04 +00001868dnl===-----------------------------------------------------------------------===
1869dnl===
1870dnl=== SECTION 8: Check for specific functions needed
1871dnl===
1872dnl===-----------------------------------------------------------------------===
1873
Benjamin Kramer37dce442015-03-09 18:35:18 +00001874AC_CHECK_FUNCS([backtrace getcwd ])
Gabor Greiff307d942007-07-13 09:48:29 +00001875AC_CHECK_FUNCS([getpagesize getrusage getrlimit setrlimit gettimeofday ])
Anton Korobeynikovd01defe2007-02-16 19:11:07 +00001876AC_CHECK_FUNCS([isatty mkdtemp mkstemp ])
Reid Kleckner37f69de2013-07-26 16:54:23 +00001877AC_CHECK_FUNCS([mktemp posix_spawn pread realpath sbrk setrlimit ])
Todd Fiala4ccfe392014-02-05 05:04:36 +00001878AC_CHECK_FUNCS([strerror strerror_r setenv ])
Chris Lattner58cee552005-11-14 07:24:17 +00001879AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
Daniel Dunbar80da3fb2011-02-03 02:39:58 +00001880AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp writev])
Eric Christophera24dc7f2013-07-04 01:10:38 +00001881AC_CHECK_FUNCS([futimes futimens])
John Criswell42859552003-10-13 16:22:01 +00001882AC_C_PRINTF_A
Reid Spencer0241e382004-11-25 04:51:04 +00001883AC_FUNC_RAND48
John Criswell42859552003-10-13 16:22:01 +00001884
Todd Fiala4ccfe392014-02-05 05:04:36 +00001885dnl Check for arc4random accessible via AC_INCLUDES_DEFAULT.
1886AC_CHECK_DECLS([arc4random])
1887
NAKAMURA Takumi189111802011-02-09 04:18:48 +00001888dnl Check the declaration "Secure API" on Windows environments.
1889AC_CHECK_DECLS([strerror_s])
1890
NAKAMURA Takumi03a541f2011-02-05 15:11:53 +00001891dnl Check symbols in libgcc.a for JIT on Mingw.
1892if test "$llvm_cv_os_type" = "MingW" ; then
1893 AC_CHECK_LIB(gcc,_alloca,AC_DEFINE([HAVE__ALLOCA],[1],[Have host's _alloca]))
1894 AC_CHECK_LIB(gcc,__alloca,AC_DEFINE([HAVE___ALLOCA],[1],[Have host's __alloca]))
1895 AC_CHECK_LIB(gcc,__chkstk,AC_DEFINE([HAVE___CHKSTK],[1],[Have host's __chkstk]))
NAKAMURA Takumi78855072015-01-30 13:01:19 +00001896 AC_CHECK_LIB(gcc,__chkstk_ms,AC_DEFINE([HAVE___CHKSTK_MS],[1],[Have host's __chkstk_ms]))
NAKAMURA Takumi03a541f2011-02-05 15:11:53 +00001897 AC_CHECK_LIB(gcc,___chkstk,AC_DEFINE([HAVE____CHKSTK],[1],[Have host's ___chkstk]))
NAKAMURA Takumi78855072015-01-30 13:01:19 +00001898 AC_CHECK_LIB(gcc,___chkstk_ms,AC_DEFINE([HAVE____CHKSTK_MS],[1],[Have host's ___chkstk_ms]))
NAKAMURA Takumi03a541f2011-02-05 15:11:53 +00001899
1900 AC_CHECK_LIB(gcc,__ashldi3,AC_DEFINE([HAVE___ASHLDI3],[1],[Have host's __ashldi3]))
1901 AC_CHECK_LIB(gcc,__ashrdi3,AC_DEFINE([HAVE___ASHRDI3],[1],[Have host's __ashrdi3]))
1902 AC_CHECK_LIB(gcc,__divdi3,AC_DEFINE([HAVE___DIVDI3],[1],[Have host's __divdi3]))
1903 AC_CHECK_LIB(gcc,__fixdfdi,AC_DEFINE([HAVE___FIXDFDI],[1],[Have host's __fixdfdi]))
1904 AC_CHECK_LIB(gcc,__fixsfdi,AC_DEFINE([HAVE___FIXSFDI],[1],[Have host's __fixsfdi]))
1905 AC_CHECK_LIB(gcc,__floatdidf,AC_DEFINE([HAVE___FLOATDIDF],[1],[Have host's __floatdidf]))
1906 AC_CHECK_LIB(gcc,__lshrdi3,AC_DEFINE([HAVE___LSHRDI3],[1],[Have host's __lshrdi3]))
1907 AC_CHECK_LIB(gcc,__moddi3,AC_DEFINE([HAVE___MODDI3],[1],[Have host's __moddi3]))
1908 AC_CHECK_LIB(gcc,__udivdi3,AC_DEFINE([HAVE___UDIVDI3],[1],[Have host's __udivdi3]))
1909 AC_CHECK_LIB(gcc,__umoddi3,AC_DEFINE([HAVE___UMODDI3],[1],[Have host's __umoddi3]))
1910
1911 AC_CHECK_LIB(gcc,__main,AC_DEFINE([HAVE___MAIN],[1],[Have host's __main]))
1912 AC_CHECK_LIB(gcc,__cmpdi2,AC_DEFINE([HAVE___CMPDI2],[1],[Have host's __cmpdi2]))
1913fi
1914
NAKAMURA Takumi4471f822011-05-01 13:29:49 +00001915dnl Check Win32 API EnumerateLoadedModules.
1916if test "$llvm_cv_os_type" = "MingW" ; then
1917 AC_MSG_CHECKING([whether EnumerateLoadedModules() accepts new decl])
NAKAMURA Takumie5bc87c2013-01-30 01:37:55 +00001918 AC_COMPILE_IFELSE(
1919[
1920 AC_LANG_SOURCE([[
1921 #include <windows.h>
1922 #include <imagehlp.h>
1923 extern void foo(PENUMLOADED_MODULES_CALLBACK);
1924 extern void foo(BOOL(CALLBACK*)(PCSTR,ULONG_PTR,ULONG,PVOID));
1925 ]])
1926],
NAKAMURA Takumi4471f822011-05-01 13:29:49 +00001927[
1928 AC_MSG_RESULT([yes])
1929 llvm_cv_win32_elmcb_pcstr="PCSTR"
1930],
1931[
1932 AC_MSG_RESULT([no])
1933 llvm_cv_win32_elmcb_pcstr="PSTR"
1934])
1935 AC_DEFINE_UNQUOTED([WIN32_ELMCB_PCSTR],$llvm_cv_win32_elmcb_pcstr,[Type of 1st arg on ELM Callback])
1936fi
1937
Eric Christophere62b4412007-12-01 00:34:39 +00001938dnl Check for mmap support.We also need to know if /dev/zero is required to
1939dnl be opened for allocating RWX memory.
Anton Korobeynikov4480ec32007-01-20 07:40:26 +00001940dnl Make sure we aren't attempting to configure for an unknown system
1941if test "$llvm_cv_platform_type" = "Unix" ; then
Eric Christophere62b4412007-12-01 00:34:39 +00001942 AC_FUNC_MMAP
Anton Korobeynikov4480ec32007-01-20 07:40:26 +00001943 AC_FUNC_MMAP_FILE
1944 AC_NEED_DEV_ZERO_FOR_MMAP
Reid Spencer0241e382004-11-25 04:51:04 +00001945
Anton Korobeynikov4480ec32007-01-20 07:40:26 +00001946 if test "$ac_cv_func_mmap_fixed_mapped" = "no"
1947 then
1948 AC_MSG_WARN([mmap() of a fixed address required but not supported])
1949 fi
1950 if test "$ac_cv_func_mmap_file" = "no"
1951 then
1952 AC_MSG_WARN([mmap() of files required but not found])
1953 fi
John Criswell5ec24d82003-07-22 20:59:52 +00001954fi
1955
Owen Andersonb9509c52009-05-18 23:58:51 +00001956dnl atomic builtins are required for threading support.
Owen Andersonaf5db832009-05-19 22:18:56 +00001957AC_MSG_CHECKING(for GCC atomic builtins)
Eric Christopher84c95cc2010-07-28 20:26:34 +00001958dnl Since we'll be using these atomic builtins in C++ files we should test
1959dnl the C++ compiler.
1960AC_LANG_PUSH([C++])
Owen Andersonaf5db832009-05-19 22:18:56 +00001961AC_LINK_IFELSE(
NAKAMURA Takumie5bc87c2013-01-30 01:37:55 +00001962[
1963 AC_LANG_SOURCE([[
1964 int main() {
1965 volatile unsigned long val = 1;
1966 __sync_synchronize();
1967 __sync_val_compare_and_swap(&val, 1, 0);
1968 __sync_add_and_fetch(&val, 1);
1969 __sync_sub_and_fetch(&val, 1);
1970 return 0;
1971 }
1972 ]])
1973],
1974[
1975 AC_MSG_RESULT([yes])
1976 AC_DEFINE([LLVM_HAS_ATOMICS], [1], [Has gcc/MSVC atomic intrinsics])
1977],
1978[
1979 AC_MSG_RESULT([no])
1980 AC_DEFINE([LLVM_HAS_ATOMICS], [0], [Has gcc/MSVC atomic intrinsics])
1981 AC_MSG_WARN([LLVM will be built thread-unsafe because atomic builtins are missing])
1982])
1983AC_LANG_POP([C++])
Owen Andersonb9509c52009-05-18 23:58:51 +00001984
Reid Spencer0241e382004-11-25 04:51:04 +00001985dnl===-----------------------------------------------------------------------===
1986dnl===
1987dnl=== SECTION 9: Additional checks, variables, etc.
1988dnl===
1989dnl===-----------------------------------------------------------------------===
John Criswell7a3334d2003-07-22 19:13:20 +00001990
Nick Lewyckyfa4c2d32009-09-29 06:18:00 +00001991dnl Handle 32-bit linux systems running a 64-bit kernel.
1992dnl This has to come after section 4 because it invokes the compiler.
1993if test "$llvm_cv_os_type" = "Linux" -a "$llvm_cv_target_arch" = "x86_64" ; then
1994 AC_IS_LINUX_MIXED
1995 if test "$llvm_cv_linux_mixed" = "yes"; then
1996 llvm_cv_target_arch="x86"
1997 ARCH="x86"
1998 fi
1999fi
2000
Eric Christopher81858452011-09-20 22:26:35 +00002001dnl Check whether __dso_handle is present
Anton Korobeynikov7ac25212007-07-30 20:02:02 +00002002AC_CHECK_FUNCS([__dso_handle])
2003
Eric Christophere62b4412007-12-01 00:34:39 +00002004dnl Propagate the shared library extension that the libltdl checks did to
Reid Spencera40c6872004-11-29 12:29:58 +00002005dnl the Makefiles so we can use it there too
Rafael Espindolafd1355a2014-02-28 18:17:54 +00002006AC_SUBST(SHLIBEXT,$llvm_shlib_ext)
Brian Gaekecc3676b2004-01-21 19:38:56 +00002007
Gabor Greife0d58d32012-01-26 10:28:58 +00002008dnl Translate the various configuration directories and other basic
2009dnl information into substitutions that will end up in Makefile.config.in
2010dnl that these configured values can be used by the makefiles
Jeff Cohenc5e5b272007-01-12 18:22:38 +00002011if test "${prefix}" = "NONE" ; then
Reid Spencer40f1b132006-05-16 08:53:32 +00002012 prefix="/usr/local"
2013fi
Reid Spencercf05c122004-08-20 09:03:12 +00002014eval LLVM_PREFIX="${prefix}";
2015eval LLVM_BINDIR="${prefix}/bin";
Reid Spencer0194c9a2004-11-29 04:56:35 +00002016eval LLVM_DATADIR="${prefix}/share/llvm";
Eric Christopherb3762a02010-03-02 05:17:21 +00002017eval LLVM_DOCSDIR="${prefix}/share/doc/llvm";
Reid Spencer0194c9a2004-11-29 04:56:35 +00002018eval LLVM_ETCDIR="${prefix}/etc/llvm";
Reid Spencercf05c122004-08-20 09:03:12 +00002019eval LLVM_INCLUDEDIR="${prefix}/include";
2020eval LLVM_INFODIR="${prefix}/info";
2021eval LLVM_MANDIR="${prefix}/man";
2022LLVM_CONFIGTIME=`date`
2023AC_SUBST(LLVM_PREFIX)
2024AC_SUBST(LLVM_BINDIR)
Reid Spencercf05c122004-08-20 09:03:12 +00002025AC_SUBST(LLVM_DATADIR)
2026AC_SUBST(LLVM_DOCSDIR)
2027AC_SUBST(LLVM_ETCDIR)
2028AC_SUBST(LLVM_INCLUDEDIR)
2029AC_SUBST(LLVM_INFODIR)
2030AC_SUBST(LLVM_MANDIR)
2031AC_SUBST(LLVM_CONFIGTIME)
Reid Spencercf05c122004-08-20 09:03:12 +00002032
Daniel Dunbar9370ecf2012-03-02 16:24:21 +00002033dnl Disable embedding timestamps in the build directory, with ENABLE_TIMESTAMPS.
2034if test "${ENABLE_TIMESTAMPS}" = "0"; then
2035 LLVM_CONFIGTIME="(timestamp not enabled)"
2036fi
2037
Gabor Greife0d58d32012-01-26 10:28:58 +00002038dnl Place the various directories into the config.h file as #defines so that we
2039dnl can know about the installation paths within LLVM.
Eric Christophere62b4412007-12-01 00:34:39 +00002040AC_DEFINE_UNQUOTED(LLVM_PREFIX,"$LLVM_PREFIX",
Reid Spencer0241e382004-11-25 04:51:04 +00002041 [Installation prefix directory])
Eric Christophere62b4412007-12-01 00:34:39 +00002042AC_DEFINE_UNQUOTED(LLVM_BINDIR, "$LLVM_BINDIR",
Reid Spencer0241e382004-11-25 04:51:04 +00002043 [Installation directory for binary executables])
Eric Christophere62b4412007-12-01 00:34:39 +00002044AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DATADIR",
Reid Spencer0241e382004-11-25 04:51:04 +00002045 [Installation directory for data files])
Eric Christophere62b4412007-12-01 00:34:39 +00002046AC_DEFINE_UNQUOTED(LLVM_DOCSDIR, "$LLVM_DOCSDIR",
Reid Spencer0241e382004-11-25 04:51:04 +00002047 [Installation directory for documentation])
Eric Christophere62b4412007-12-01 00:34:39 +00002048AC_DEFINE_UNQUOTED(LLVM_ETCDIR, "$LLVM_ETCDIR",
Reid Spencer0241e382004-11-25 04:51:04 +00002049 [Installation directory for config files])
Eric Christophere62b4412007-12-01 00:34:39 +00002050AC_DEFINE_UNQUOTED(LLVM_INCLUDEDIR, "$LLVM_INCLUDEDIR",
Reid Spencer0241e382004-11-25 04:51:04 +00002051 [Installation directory for include files])
Eric Christophere62b4412007-12-01 00:34:39 +00002052AC_DEFINE_UNQUOTED(LLVM_INFODIR, "$LLVM_INFODIR",
Reid Spencer0241e382004-11-25 04:51:04 +00002053 [Installation directory for .info files])
Eric Christophere62b4412007-12-01 00:34:39 +00002054AC_DEFINE_UNQUOTED(LLVM_MANDIR, "$LLVM_MANDIR",
Reid Spencer0241e382004-11-25 04:51:04 +00002055 [Installation directory for man pages])
Eric Christophere62b4412007-12-01 00:34:39 +00002056AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME",
Reid Spencer0241e382004-11-25 04:51:04 +00002057 [Time at which LLVM was configured])
Tim Northoverfee13d12013-05-04 07:36:23 +00002058AC_DEFINE_UNQUOTED(LLVM_HOST_TRIPLE, "$host",
NAKAMURA Takumi43652ae2012-07-22 03:04:52 +00002059 [Host triple LLVM will be executed on])
Sebastian Popec2fb222011-11-01 21:31:44 +00002060AC_DEFINE_UNQUOTED(LLVM_DEFAULT_TARGET_TRIPLE, "$target",
2061 [Target triple LLVM will generate code for by default])
Reid Spencer0241e382004-11-25 04:51:04 +00002062
Gabor Greife0d58d32012-01-26 10:28:58 +00002063dnl Determine which bindings to build.
Gordon Henriksend48f4592007-10-02 09:50:18 +00002064if test "$BINDINGS_TO_BUILD" = auto ; then
2065 BINDINGS_TO_BUILD=""
Peter Zotov668f9672014-10-30 08:29:45 +00002066 if test "x$OCAMLFIND" != x ; then
Gordon Henriksend48f4592007-10-02 09:50:18 +00002067 BINDINGS_TO_BUILD="ocaml $BINDINGS_TO_BUILD"
2068 fi
Peter Collingbourne82e3e372014-10-16 22:48:02 +00002069 if test "x$GO" != x ; then
2070 if $GO run ${srcdir}/bindings/go/conftest.go ; then
2071 BINDINGS_TO_BUILD="go $BINDINGS_TO_BUILD"
2072 fi
2073 fi
Gordon Henriksend48f4592007-10-02 09:50:18 +00002074fi
2075AC_SUBST(BINDINGS_TO_BUILD,$BINDINGS_TO_BUILD)
2076
Gabor Greife0d58d32012-01-26 10:28:58 +00002077dnl Do any work necessary to ensure that bindings have what they need.
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002078binding_prereqs_failed=0
2079for a_binding in $BINDINGS_TO_BUILD ; do
2080 case "$a_binding" in
2081 ocaml)
Peter Zotov668f9672014-10-30 08:29:45 +00002082 if test "x$OCAMLFIND" = x ; then
2083 AC_MSG_WARN([--enable-bindings=ocaml specified, but ocamlfind not found. Try configure OCAMLFIND=/path/to/ocamlfind])
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002084 binding_prereqs_failed=1
2085 fi
Peter Zotov668f9672014-10-30 08:29:45 +00002086
2087 if $OCAMLFIND opt -version >/dev/null 2>/dev/null ; then
2088 HAVE_OCAMLOPT=1
2089 else
2090 HAVE_OCAMLOPT=0
2091 fi
2092 AC_SUBST(HAVE_OCAMLOPT)
2093
2094 if ! $OCAMLFIND query ctypes >/dev/null 2>/dev/null; then
2095 AC_MSG_WARN([--enable-bindings=ocaml specified, but ctypes is not installed])
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002096 binding_prereqs_failed=1
2097 fi
Peter Zotov668f9672014-10-30 08:29:45 +00002098
2099 if $OCAMLFIND query oUnit >/dev/null 2>/dev/null; then
2100 HAVE_OCAML_OUNIT=1
2101 else
2102 HAVE_OCAML_OUNIT=0
2103 AC_MSG_WARN([--enable-bindings=ocaml specified, but OUnit 2 is not installed. Tests will not run])
2104 dnl oUnit is optional!
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002105 fi
Peter Zotov668f9672014-10-30 08:29:45 +00002106 AC_SUBST(HAVE_OCAML_OUNIT)
2107
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002108 if test "x$with_ocaml_libdir" != xauto ; then
2109 AC_SUBST(OCAML_LIBDIR,$with_ocaml_libdir)
2110 else
Peter Zotov668f9672014-10-30 08:29:45 +00002111 ocaml_stdlib="`"$OCAMLFIND" ocamlc -where`"
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002112 if test "$LLVM_PREFIX" '<' "$ocaml_stdlib" -a "$ocaml_stdlib" '<' "$LLVM_PREFIX~"
2113 then
2114 # ocaml stdlib is beneath our prefix; use stdlib
2115 AC_SUBST(OCAML_LIBDIR,$ocaml_stdlib)
2116 else
2117 # ocaml stdlib is outside our prefix; use libdir/ocaml
Rafael Espindolab58973f2013-06-11 18:52:11 +00002118 AC_SUBST(OCAML_LIBDIR,${prefix}/lib/ocaml)
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002119 fi
2120 fi
2121 ;;
Peter Collingbourne82e3e372014-10-16 22:48:02 +00002122 go)
2123 if test "x$GO" = x ; then
2124 AC_MSG_WARN([--enable-bindings=go specified, but go not found. Try configure GO=/path/to/go])
2125 binding_prereqs_failed=1
2126 else
2127 if $GO run ${srcdir}/bindings/go/conftest.go ; then
2128 :
2129 else
2130 AC_MSG_WARN([--enable-bindings=go specified, but need at least Go 1.2. Try configure GO=/path/to/go])
2131 binding_prereqs_failed=1
2132 fi
2133 fi
2134 ;;
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002135 esac
2136done
2137if test "$binding_prereqs_failed" = 1 ; then
2138 AC_MSG_ERROR([Prequisites for bindings not satisfied. Fix them or use configure --disable-bindings.])
2139fi
2140
Nick Lewycky16aac992009-03-05 08:20:21 +00002141dnl Determine whether the compiler supports -fvisibility-inlines-hidden.
Daniel Dunbar61e0a822008-09-02 17:35:16 +00002142AC_CXX_USE_VISIBILITY_INLINES_HIDDEN
Gordon Henriksen3be1f102007-10-02 16:42:10 +00002143
Nick Lewycky7d01e392009-03-03 04:55:15 +00002144dnl Determine linker rpath flag
Nick Lewycky16aac992009-03-05 08:20:21 +00002145if test "$llvm_cv_link_use_r" = "yes" ; then
2146 RPATH="-Wl,-R"
2147else
2148 RPATH="-Wl,-rpath"
2149fi
Nick Lewycky7d01e392009-03-03 04:55:15 +00002150AC_SUBST(RPATH)
2151
Nick Lewycky16aac992009-03-05 08:20:21 +00002152dnl Determine linker rdynamic flag
2153if test "$llvm_cv_link_use_export_dynamic" = "yes" ; then
Bob Wilson8658b912013-08-02 22:51:06 +00002154 RDYNAMIC="-rdynamic"
Nick Lewycky16aac992009-03-05 08:20:21 +00002155else
2156 RDYNAMIC=""
2157fi
2158AC_SUBST(RDYNAMIC)
2159
Reid Spencer0241e382004-11-25 04:51:04 +00002160dnl===-----------------------------------------------------------------------===
2161dnl===
2162dnl=== SECTION 10: Specify the output files and generate it
2163dnl===
2164dnl===-----------------------------------------------------------------------===
2165
2166dnl Configure header files
Reid Spencerb48e3f82005-08-24 10:43:10 +00002167dnl WARNING: dnl If you add or remove any of the following config headers, then
Dylan Noblesmithc1209572012-01-17 02:56:49 +00002168dnl you MUST also update Makefile so that the variable FilesToConfig
Reid Spencerb48e3f82005-08-24 10:43:10 +00002169dnl contains the same list of files as AC_CONFIG_HEADERS below. This ensures the
2170dnl files can be updated automatically when their *.in sources change.
Eric Christopherf24446d2010-08-08 02:44:17 +00002171AC_CONFIG_HEADERS([include/llvm/Config/config.h include/llvm/Config/llvm-config.h])
Eric Christophere8f47dd2010-08-08 09:18:29 +00002172AH_TOP([#ifndef CONFIG_H
NAKAMURA Takumi6534e482015-06-18 04:08:20 +00002173#define CONFIG_H
2174
2175/* Exported configuration */
2176#include "llvm/Config/llvm-config.h"])
Eric Christophere8f47dd2010-08-08 09:18:29 +00002177AH_BOTTOM([#endif])
2178
Douglas Gregor1b731d52009-06-16 20:12:29 +00002179AC_CONFIG_FILES([include/llvm/Config/Targets.def])
2180AC_CONFIG_FILES([include/llvm/Config/AsmPrinters.def])
Daniel Dunbarce77aa02009-07-17 20:56:18 +00002181AC_CONFIG_FILES([include/llvm/Config/AsmParsers.def])
Daniel Dunbarf4721292009-11-25 04:30:13 +00002182AC_CONFIG_FILES([include/llvm/Config/Disassemblers.def])
Michael J. Spencer447762d2010-11-29 18:16:10 +00002183AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
Reid Spencer0241e382004-11-25 04:51:04 +00002184
2185dnl Configure the makefile's configuration data
2186AC_CONFIG_FILES([Makefile.config])
2187
Reid Spencer1277ba22006-08-16 00:45:38 +00002188dnl Configure the RPM spec file for LLVM
2189AC_CONFIG_FILES([llvm.spec])
2190
Peter Collingbourne5ac59df2011-05-13 03:27:56 +00002191dnl Configure doxygen's configuration file
2192AC_CONFIG_FILES([docs/doxygen.cfg])
Dylan Noblesmith57f439c2012-02-01 14:06:21 +00002193
2194dnl Configure clang, if present
Dylan Noblesmithe21a3b22012-02-04 02:41:36 +00002195if test "${clang_src_root}" = ""; then
Dylan Noblesmitha3670222012-02-02 00:54:18 +00002196 clang_src_root="$srcdir/tools/clang"
Dylan Noblesmithb5190ab2012-02-02 00:17:33 +00002197fi
Dylan Noblesmith2badba52012-02-02 00:11:14 +00002198if test -f ${clang_src_root}/README.txt; then
Chandler Carruth9db2b522014-12-29 11:58:17 +00002199 dnl Clang supports build systems which use the multilib libdir suffix.
2200 dnl The autoconf system doesn't support this so stub out that variable.
2201 AC_DEFINE_UNQUOTED(CLANG_LIBDIR_SUFFIX,"",
2202 [Multilib suffix for libdir.])
2203
Dylan Noblesmitha7a29c172012-02-04 03:00:50 +00002204 dnl Use variables to stay under 80 columns.
2205 configh="include/clang/Config/config.h"
2206 doxy="docs/doxygen.cfg"
2207 AC_CONFIG_HEADERS([tools/clang/${configh}:${clang_src_root}/${configh}.in])
2208 AC_CONFIG_FILES([tools/clang/${doxy}:${clang_src_root}/${doxy}.in])
Peter Collingbourne5ac59df2011-05-13 03:27:56 +00002209fi
2210
Torok Edwin229f8d72011-10-14 20:38:02 +00002211dnl OCaml findlib META file
2212AC_CONFIG_FILES([bindings/ocaml/llvm/META.llvm])
2213
Jordan Rose3c837ab2012-10-01 18:40:32 +00002214dnl Add --program-prefix value to Makefile.rules. Already an ARG variable.
2215test "x$program_prefix" = "xNONE" && program_prefix=""
2216AC_SUBST([program_prefix])
2217
2218
Reid Spencer0241e382004-11-25 04:51:04 +00002219dnl Do special configuration of Makefiles
Reid Spencerf3102c22005-02-24 18:31:27 +00002220AC_CONFIG_COMMANDS([setup],,[llvm_src="${srcdir}"])
Reid Spencer0241e382004-11-25 04:51:04 +00002221AC_CONFIG_MAKEFILE(Makefile)
2222AC_CONFIG_MAKEFILE(Makefile.common)
2223AC_CONFIG_MAKEFILE(examples/Makefile)
2224AC_CONFIG_MAKEFILE(lib/Makefile)
Reid Spencer0241e382004-11-25 04:51:04 +00002225AC_CONFIG_MAKEFILE(test/Makefile)
2226AC_CONFIG_MAKEFILE(test/Makefile.tests)
Bill Wendling8790e322009-01-04 23:12:21 +00002227AC_CONFIG_MAKEFILE(unittests/Makefile)
Reid Spencer0241e382004-11-25 04:51:04 +00002228AC_CONFIG_MAKEFILE(tools/Makefile)
Reid Spencer0241e382004-11-25 04:51:04 +00002229AC_CONFIG_MAKEFILE(utils/Makefile)
2230AC_CONFIG_MAKEFILE(projects/Makefile)
Gordon Henriksen54fd7572007-09-22 21:36:22 +00002231AC_CONFIG_MAKEFILE(bindings/Makefile)
2232AC_CONFIG_MAKEFILE(bindings/ocaml/Makefile.ocaml)
Reid Spencer0241e382004-11-25 04:51:04 +00002233
2234dnl Finally, crank out the output
Reid Spencer2024d0e2004-09-19 23:43:52 +00002235AC_OUTPUT