1 dnl Initialize autoconf
2 AC_INIT([[LLVM]],[[1.4]],[llvmbugs@cs.uiuc.edu])
4 dnl Place all of the extra autoconf files into the config subdirectory
5 dnl Tell various tools where the m4 autoconf macros are
6 dnl Have configure verify that the source directory is valid.
7 AC_CONFIG_AUX_DIR([autoconf])
8 dnl AC_CONFIG_MACRO_DIR(autoconf/m4)
9 dnl Verify that the source directory is valid
10 AC_CONFIG_SRCDIR(["Makefile.config.in"])
12 dnl Quit if the source directory has already been configured.
13 dnl NOTE: This relies upon undocumented autoconf behavior.
14 if test ${srcdir} != "." ; then
15 if test -f ${srcdir}/include/llvm/Config/config.h ; then
16 AC_MSG_ERROR([Already configured in ${srcdir}])
20 dnl Configure all of the projects present in our source tree.
21 for i in `ls ${srcdir}/projects`
23 if test -d ${srcdir}/projects/${i} ; then
26 "sample") AC_CONFIG_SUBDIRS([projects/sample]) ;;
27 "Stacker") AC_CONFIG_SUBDIRS([projects/Stacker]) ;;
28 "llvm-test") AC_CONFIG_SUBDIRS([projects/llvm-test]) ;;
29 "llvm-reopt") AC_CONFIG_SUBDIRS([projects/llvm-reopt]);;
30 "llvm-gcc") AC_CONFIG_SUBDIRS([projects/llvm-gcc]) ;;
31 "Java") AC_CONFIG_SUBDIRS([projects/Java]) ;;
32 "llvm-tv") AC_CONFIG_SUBDIRS([projects/llvm-tv]) ;;
33 "llvm-fefw") AC_CONFIG_SUBDIRS([projects/llvm-fefw]) ;;
35 AC_MSG_WARN([Unknown projects (${i})won't be configured automatically])
41 dnl Configure header files
42 AC_CONFIG_HEADERS(include/llvm/Config/config.h)
44 dnl Configure other output file
45 AC_CONFIG_FILES(Makefile.config
46 include/llvm/Support/ThreadSupport.h
47 include/llvm/ADT/hash_map
48 include/llvm/ADT/hash_set
49 include/llvm/ADT/iterator)
50 AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
52 dnl Do special configuration of Makefiles
53 AC_CONFIG_MAKEFILE(Makefile)
54 AC_CONFIG_MAKEFILE(Makefile.common)
55 AC_CONFIG_MAKEFILE(examples/Makefile)
56 AC_CONFIG_MAKEFILE(lib/Makefile)
57 AC_CONFIG_MAKEFILE(runtime/Makefile)
58 AC_CONFIG_MAKEFILE(test/Makefile)
59 AC_CONFIG_MAKEFILE(test/Makefile.tests)
60 AC_CONFIG_MAKEFILE(test/QMTest/llvm.py)
61 AC_CONFIG_MAKEFILE(test/QMTest/llvmdb.py)
62 AC_CONFIG_MAKEFILE(tools/Makefile)
63 AC_CONFIG_MAKEFILE(utils/Makefile)
64 AC_CONFIG_MAKEFILE(projects/Makefile)
66 dnl Find the install program (needs to be done before canonical stuff)
69 dnl Check which host for which we're compiling. This will tell us which LLVM
70 dnl compiler will be used for compiling SSA into object code.
73 dnl Set the "OS" Makefile variable based on the system we are building on.
74 dnl We will use the build machine information to set some variables.
76 AC_MSG_CHECKING([support for generic build operating system])
84 platform_type="Cygwin"
88 platform_type="Darwin"
92 platform_type="FreeBSD"
96 platform_type="Interix"
100 platform_type="Linux"
101 if test -d /home/vadve/lattner/local/x86/llvm-gcc
103 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
108 platform_type="SunOS"
109 if test -d /home/vadve/lattner/local/sparc/llvm-gcc
111 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
116 platform_type="Win32"
120 platform_type="Win32"
123 AC_SUBST(OS,[Unknown])
124 platform_type="Unknown"
128 dnl Make sure we aren't attempting to configure for an unknown system
129 if test "$platform_type" = "Unknown" ; then
130 AC_MSG_ERROR([Platform is unknown, configure can't continue])
133 dnl Make a link from lib/System/platform to lib/System/$platform_type
134 dnl This helps the #inclusion of the system specific include files
135 dnl for the operating system abstraction library
136 AC_CONFIG_LINKS(lib/System/platform:lib/System/$platform_type)
139 AC_MSG_CHECKING(target architecture)
140 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
141 dnl V9, since that is all that we support at the moment, and autoconf will only
142 dnl tell us we're a sparc.
144 sparc*-*-solaris*) AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
148 dnl Determine what our target architecture is and configure accordingly.
149 dnl This will allow Makefiles to make a distinction between the hardware and
158 AC_SUBST(ARCH,[Sparc])
162 AC_SUBST(ARCH,[PowerPC])
166 AC_SUBST(ARCH,[Unknown])
172 dnl Check for compilation tools
175 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
176 if test "$GCC" != "yes"
178 AC_MSG_ERROR([gcc required but not found])
181 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
182 if test "$GXX" != "yes"
184 AC_MSG_ERROR([g++ required but not found])
187 dnl Verify that GCC is version 3.0 or higher
188 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
189 if test "$gccmajor" -lt "3"
191 AC_MSG_ERROR([gcc 3.x required, but you have a lower version])
194 dnl Check for GNU Make. We use its extensions too, so don't build without it
196 if test -z "$_cv_gnu_make_command"
198 AC_MSG_ERROR([GNU Make required but not found])
201 dnl Checks for other tools
206 dnl Checks for tools we can get away with not having:
207 AC_PATH_PROG(DOT,[dot],[true dot])
208 AC_PATH_PROG(ETAGS,[etags],[true etags])
209 dnl Check if we know how to tell etags we are using C++:
210 etags_version=`$ETAGS --version 2>&1`
211 case "$etags_version" in
212 *[Ee]xuberant*) ETAGSFLAGS="--language-force=c++" ;;
213 *GNU\ Emacs*) ETAGSFLAGS="-l c++" ;;
216 AC_SUBST(ETAGSFLAGS,$ETAGSFLAGS)
217 AC_PATH_PROG(PYTHON,[python],[true python])
218 if test "$PYTHON" = "false"
220 AC_MSG_WARN([Python is required for the test suite, but it was not found])
222 AC_PATH_PROG(QMTEST,[qmtest],[true qmtest])
223 if test "$QMTEST" = "false"
225 AC_MSG_WARN([QMTest is required for the test suite, but it was not found])
228 dnl Verify that the version of python available is high enough for qmtest
229 pyversion=`$PYTHON -V 2>&1 | cut -d\ -f2`
230 pymajor=`echo $pyversion | cut -d. -f1`
231 pyminor=`echo $pyversion | cut -d. -f2`
233 if test "$pymajor" -ge "2"
235 if test "$pymajor" -eq "2"
237 if test "$pyminor" -lt "2"
239 AC_MSG_WARN([QMTest requires Python 2.2 or later])
243 AC_MSG_WARN([QMTest requires Python 2.2 or later])
246 dnl Checks for libraries:
247 dnl libelf is for sparc only; we can ignore it if we don't have it
248 AC_CHECK_LIB(elf, elf_begin)
250 dnl dlopen() is required for plugin support.
251 AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1],[Define if dlopen() is available on this platform.]),AC_MSG_WARN([dlopen() not found - disabling plugin support]))
253 dnl mallinfo is optional; the code can compile (minus features) without it
254 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
256 dnl pthread locking functions are optional - but llvm will not be thread-safe
258 AC_SEARCH_LIBS(pthread_mutex_lock,pthread,HAVE_PTHREAD_MUTEX_LOCK=1,HAVE_PTHREAD_MUTEX_LOCK=0)
259 AC_SUBST(HAVE_PTHREAD_MUTEX_LOCK)
261 dnl Checks for header files.
262 dnl We don't check for ancient stuff or things that are guaranteed to be there
263 dnl by the C++ standard. We always use the <cfoo> versions of <foo.h> C headers.
267 dnl Checks for POSIX and other various system-specific header files
268 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h malloc.h sys/mman.h sys/resource.h dlfcn.h link.h execinfo.h windows.h)
270 dnl Check for things that need to be included in public headers, and so
271 dnl for which we may not have access to a HAVE_* preprocessor #define.
272 dnl (primarily used in DataTypes.h)
273 AC_CHECK_HEADER([sys/types.h])
274 AC_CHECK_HEADER([inttypes.h])
275 AC_CHECK_HEADER([stdint.h])
280 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
281 AC_CHECK_TYPES([uint64_t],,
282 AC_CHECK_TYPES([u_int64_t],,
283 AC_MSG_ERROR([Type uint64_t or u_int64_t required but not found])))
287 dnl Check for various C features
290 dnl Check for the endianness of the target
291 AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little]))
293 dnl Check for C++ extensions
296 AC_CXX_HAVE_STD_ITERATOR
297 AC_CXX_HAVE_BI_ITERATOR
298 AC_CXX_HAVE_FWD_ITERATOR
303 dnl Checks for library functions.
306 if test "$ac_cv_func_mmap_fixed_mapped" = "no"
308 AC_MSG_WARN([mmap() required but not found])
311 if test "$ac_cv_func_mmap_file" = "no"
313 AC_MSG_WARN([mmap() of files required but not found])
315 AC_HEADER_MMAP_ANONYMOUS
317 AC_CHECK_FUNCS(getcwd gettimeofday strdup strtoq strtoll backtrace isatty mkstemp getrusage)
318 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
320 dnl Determine if the linker supports the -R option.
323 dnl --enable/--with command-line options:
324 dnl Check whether they want to do an optimized build:
325 AC_ARG_ENABLE(optimized,AS_HELP_STRING(--enable-optimized,Compile with optimizations enabled (default is NO)),,enableval=no)
326 if test ${enableval} = "no"
328 AC_SUBST(ENABLE_OPTIMIZED,[[]])
330 AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
334 AC_ARG_ENABLE(jit,AS_HELP_STRING(--enable-jit,Enable Just In Time Compiling (default is YES)),,enableval=default)
335 if test ${enableval} = "no"
341 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
344 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
352 dnl Find the LLVM GCC-based C/C++ front end
353 AC_ARG_WITH(llvmgccdir,AS_HELP_STRING(--with-llvmgccdir,Location of LLVM GCC front-end),AC_SUBST(LLVMGCCDIR,[$withval]))
354 AC_MSG_CHECKING([for llvm-gcc])
356 if test -d "$LLVMGCCDIR"
358 if test -x "$LLVMGCCDIR/bin/gcc"
360 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
364 AC_MSG_RESULT($LLVM_GCC_CHECK)
365 if test "$LLVM_GCC_CHECK" = "no"
369 AC_MSG_CHECKING([whether llvm-gcc is sane])
371 if test -x "$LLVM_GCC_CHECK"
373 cp /dev/null conftest.c
374 "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
380 llvmcc1path=`"$LLVM_GCC_CHECK" --print-prog-name=cc1`
381 AC_SUBST(LLVMCC1,$llvmcc1path)
382 llvmcc1pluspath=`"$LLVM_GCC_CHECK" --print-prog-name=cc1plus`
383 AC_SUBST(LLVMCC1PLUS,$llvmcc1pluspath)
385 AC_MSG_RESULT($LLVM_GCC_SANE)
386 if test "$LLVM_GCC_SANE" = "no"
391 dnl Get libtool's idea of what the shared library suffix is.
392 dnl (This is a hack; it relies on undocumented behavior.)
393 AC_MSG_CHECKING([for shared library suffix])
394 eval "SHLIBEXT=$shrext_cmds"
395 AC_MSG_RESULT($SHLIBEXT)
396 dnl Propagate it to the Makefiles and config.h (for gccld & bugpoint).
397 AC_SUBST(SHLIBEXT,$SHLIBEXT)
398 AC_DEFINE_UNQUOTED(SHLIBEXT,"$SHLIBEXT",
399 [Extension that shared libraries have, e.g., ".so".])
401 # Translate the various configuration directories and other basic
402 # information into substitutions that will end up in config.h.in so
403 # that these configured values can be hard-wired into a program.
404 eval LLVM_PREFIX="${prefix}";
405 eval LLVM_BINDIR="${prefix}/bin";
406 eval LLVM_LIBDIR="${prefix}/lib";
407 eval LLVM_DATADIR="${prefix}/data";
408 eval LLVM_DOCSDIR="${prefix}/docs";
409 eval LLVM_ETCDIR="${prefix}/etc";
410 eval LLVM_INCLUDEDIR="${prefix}/include";
411 eval LLVM_INFODIR="${prefix}/info";
412 eval LLVM_MANDIR="${prefix}/man";
413 LLVM_CONFIGTIME=`date`
414 AC_SUBST(LLVM_PREFIX)
415 AC_SUBST(LLVM_BINDIR)
416 AC_SUBST(LLVM_LIBDIR)
417 AC_SUBST(LLVM_DATADIR)
418 AC_SUBST(LLVM_DOCSDIR)
419 AC_SUBST(LLVM_ETCDIR)
420 AC_SUBST(LLVM_INCLUDEDIR)
421 AC_SUBST(LLVM_INFODIR)
422 AC_SUBST(LLVM_MANDIR)
423 AC_SUBST(LLVM_CONFIGTIME)
424 AC_DEFINE_UNQUOTED(LLVM_PREFIX,"$LLVM_PREFIX", [Installation prefix directory])
425 AC_DEFINE_UNQUOTED(LLVM_BINDIR, "$LLVM_BINDIR", [Installation directory for binary executables])
426 AC_DEFINE_UNQUOTED(LLVM_LIBDIR, "$LLVM_LIBDIR", [Installation directory for libraries])
427 AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DATADIR", [Installation directory for data files])
428 AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DOCSDIR", [Installation directory for documentation])
429 AC_DEFINE_UNQUOTED(LLVM_ETCDIR, "$LLVM_ETCDIR", [Installation directory for config files])
430 AC_DEFINE_UNQUOTED(LLVM_INCLUDEDIR, "$LLVM_INCLUDEDIR", [Installation directory for include files])
431 AC_DEFINE_UNQUOTED(LLVM_INFODIR, "$LLVM_INFODIR", [Installation directory for .info files])
432 AC_DEFINE_UNQUOTED(LLVM_MANDIR, "$LLVM_MANDIR", [Installation directory for man pages])
433 AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME", [Time at which LLVM was configured])
435 dnl Create the output files
438 dnl Warn loudly if llvm-gcc was not obviously working
439 if test $llvmgccwarn = yes
441 AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
442 AC_MSG_WARN([***** appear to be working.])
443 AC_MSG_WARN([***** ])
444 AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
445 AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
446 AC_MSG_WARN([***** but you should be able to build the llvm tools.])