blob: d6967fb9f641f1a47397feb163e14905247fab98 [file] [log] [blame]
Reid Spencer6843e382004-10-08 05:33:35 +00001dnl Initialize autoconf
2AC_INIT([[LLVM]],[[1.4]],[llvmbugs@cs.uiuc.edu])
3
4dnl Place all of the extra autoconf files into the config subdirectory
5dnl Tell various tools where the m4 autoconf macros are
6dnl Have configure verify that the source directory is valid.
7AC_CONFIG_AUX_DIR([autoconf])
8
9dnl AC_CONFIG_MACRO_DIR(autoconf/m4)
10dnl Verify that the source directory is valid
11AC_CONFIG_SRCDIR(["lib/VMCore/Module.cpp"])
12
13dnl Check which host for which we're compiling. This will tell us which LLVM
14dnl compiler will be used for compiling SSA into object code.
15AC_CANONICAL_TARGET
16
17dnl Quit if the source directory has already been configured.
18dnl NOTE: This relies upon undocumented autoconf behavior.
19if test ${srcdir} != "." ; then
20 if test -f ${srcdir}/include/llvm/Config/config.h ; then
21 AC_MSG_ERROR([Already configured in ${srcdir}])
22 fi
23fi
24
25dnl Initialize automake
26AM_INIT_AUTOMAKE
27
28
29dnl Set the "OS" Makefile variable based on the system we are building on.
30dnl Configure all of the projects present in our source tree.
31for i in `ls ${srcdir}/projects`
32do
33 if test -d ${srcdir}/projects/${i} ; then
34 case ${i} in
35 "CVS") ;;
36 "sample") AC_CONFIG_SUBDIRS([projects/sample]) ;;
37 "Stacker") AC_CONFIG_SUBDIRS([projects/Stacker]) ;;
38 "llvm-test") AC_CONFIG_SUBDIRS([projects/llvm-test]) ;;
39 "llvm-reopt") AC_CONFIG_SUBDIRS([projects/llvm-reopt]);;
40 "llvm-gcc") AC_CONFIG_SUBDIRS([projects/llvm-gcc]) ;;
41 "Java") AC_CONFIG_SUBDIRS([projects/Java]) ;;
42 "llvm-tv") AC_CONFIG_SUBDIRS([projects/llvm-tv]) ;;
43 "llvm-fefw") AC_CONFIG_SUBDIRS([projects/llvm-fefw]) ;;
44 *)
45 AC_MSG_WARN([Unknown project (${i}) won't be configured automatically])
46 ;;
47 esac
48 fi
49done
50
51dnl Configure header files
52AC_CONFIG_HEADERS([include/llvm/Config/config.h])
53
54dnl Configure other output files
55AC_CONFIG_FILES([Makefile.config])
56AC_CONFIG_FILES([Makefile])
57AC_CONFIG_FILES([lib/Makefile])
58
59AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
60AC_CONFIG_HEADERS([include/llvm/ADT/hash_map])
61AC_CONFIG_HEADERS([include/llvm/ADT/hash_set])
62AC_CONFIG_HEADERS([include/llvm/Support/ThreadSupport.h])
63AC_CONFIG_HEADERS([include/llvm/ADT/iterator])
64
65dnl Do special configuration of Makefiles
66dnl AC_CONFIG_MAKEFILE(Makefile)
67dnl AC_CONFIG_MAKEFILE(Makefile.common)
68dnl AC_CONFIG_MAKEFILE(examples/Makefile)
69dnl AC_CONFIG_MAKEFILE(lib/Makefile)
70dnl AC_CONFIG_MAKEFILE(runtime/Makefile)
71dnl AC_CONFIG_MAKEFILE(test/Makefile)
72dnl AC_CONFIG_MAKEFILE(test/Makefile.tests)
73dnl AC_CONFIG_MAKEFILE(test/QMTest/llvm.py)
74dnl AC_CONFIG_MAKEFILE(test/QMTest/llvmdb.py)
75dnl AC_CONFIG_MAKEFILE(tools/Makefile)
76dnl AC_CONFIG_MAKEFILE(utils/Makefile)
77dnl AC_CONFIG_MAKEFILE(projects/Makefile)
78
79dnl Find the install program (needs to be done before canonical stuff)
80AC_PROG_INSTALL
81
82dnl We will use the build machine information to set some variables.
83
84AC_MSG_CHECKING([support for generic build operating system])
85case $build in
86 *-*-aix*)
87 AC_SUBST(OS,[AIX])
88 platform_type="AIX"
89 ;;
90 *-*-cygwin*)
91 AC_SUBST(OS,[Cygwin])
92 platform_type="Cygwin"
93 ;;
94 *-*-darwin*)
95 AC_SUBST(OS,[Darwin])
96 platform_type="Darwin"
97 ;;
98 *-*-freebsd*)
99 AC_SUBST(OS,[Linux])
100 platform_type="FreeBSD"
101 ;;
102 *-*-interix*)
103 AC_SUBST(OS,[SunOS])
104 platform_type="Interix"
105 ;;
106 *-*-linux*)
107 AC_SUBST(OS,[Linux])
108 platform_type="Linux"
109 if test -d /home/vadve/lattner/local/x86/llvm-gcc
110 then
111 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
112 fi
113 ;;
114 *-*-solaris*)
115 AC_SUBST(OS,[SunOS])
116 platform_type="SunOS"
117 if test -d /home/vadve/lattner/local/sparc/llvm-gcc
118 then
119 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
120 fi
121 ;;
122 *-*-win32*)
123 AC_SUBST(OS,[Win32])
124 platform_type="Win32"
125 ;;
126 *-*-mingw*)
127 AC_SUBST(OS,[Win32])
128 platform_type="Win32"
129 ;;
130 *)
131 AC_SUBST(OS,[Unknown])
132 platform_type="Unknown"
133 ;;
134esac
135
136dnl Make sure we aren't attempting to configure for an unknown system
137if test "$platform_type" = "Unknown" ; then
138 AC_MSG_ERROR([Platform is unknown, configure can't continue])
139fi
140
141dnl Make a link from lib/System/platform to lib/System/$platform_type
142dnl This helps the #inclusion of the system specific include files
143dnl for the operating system abstraction library
144AC_CONFIG_LINKS(lib/System/platform:lib/System/$platform_type)
145
146
147AC_MSG_CHECKING(target architecture)
148dnl If we are targetting a Sparc machine running Solaris, pretend that it is
149dnl V9, since that is all that we support at the moment, and autoconf will only
150dnl tell us we're a sparc.
151case $target in
152 sparc*-*-solaris*) AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
153 ;;
154esac
155
156dnl Determine what our target architecture is and configure accordingly.
157dnl This will allow Makefiles to make a distinction between the hardware and
158dnl the OS.
159case $target in
160 i*86-*)
161 ARCH="x86"
162 AC_SUBST(ARCH,[x86])
163 ;;
164 sparc*-*)
165 ARCH="Sparc"
166 AC_SUBST(ARCH,[Sparc])
167 ;;
168 powerpc*-*)
169 ARCH="PowerPC"
170 AC_SUBST(ARCH,[PowerPC])
171 ;;
172 *)
173 ARCH="Unknown"
174 AC_SUBST(ARCH,[Unknown])
175 ;;
176esac
177
178AC_MSG_RESULT($ARCH)
179
180dnl Check for compilation tools
181AC_PROG_CXX
182AC_PROG_CC(gcc)
183dnl Ensure that compilation tools are GCC; we use GCC specific extensions
184if test "$GCC" != "yes"
185then
186 AC_MSG_ERROR([gcc required but not found])
187fi
188AC_PROG_CPP
189dnl Ensure that compilation tools are GCC; we use GCC specific extensions
190if test "$GXX" != "yes"
191then
192 AC_MSG_ERROR([g++ required but not found])
193fi
194
195dnl Verify that GCC is version 3.0 or higher
196gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
197if test "$gccmajor" -lt "3"
198then
199 AC_MSG_ERROR([gcc 3.x required, but you have a lower version])
200fi
201
202dnl Check for GNU Make. We use its extensions too, so don't build without it
203AC_CHECK_GNU_MAKE
204if test -z "$_cv_gnu_make_command"
205then
206 AC_MSG_ERROR([GNU Make required but not found])
207fi
208
209dnl Checks for other tools
210AC_PROG_FLEX
211AC_PROG_BISON
212AC_PROG_LIBTOOL
213
214dnl Checks for tools we can get away with not having:
215AC_PATH_PROG(DOT,[dot],[true dot])
216AC_PATH_PROG(ETAGS,[etags],[true etags])
217dnl Check if we know how to tell etags we are using C++:
218etags_version=`$ETAGS --version 2>&1`
219case "$etags_version" in
220 *[Ee]xuberant*) ETAGSFLAGS="--language-force=c++" ;;
221 *GNU\ Emacs*) ETAGSFLAGS="-l c++" ;;
222 *) ETAGSFLAGS="" ;;
223esac
224AC_SUBST(ETAGSFLAGS,$ETAGSFLAGS)
225AC_PATH_PROG(PYTHON,[python],[true python])
226if test "$PYTHON" = "false"
227then
228 AC_MSG_WARN([Python is required for the test suite, but it was not found])
229fi
230AC_PATH_PROG(QMTEST,[qmtest],[true qmtest])
231if test "$QMTEST" = "false"
232then
233 AC_MSG_WARN([QMTest is required for the test suite, but it was not found])
234fi
235
236dnl Verify that the version of python available is high enough for qmtest
237pyversion=`$PYTHON -V 2>&1 | cut -d\ -f2`
238pymajor=`echo $pyversion | cut -d. -f1`
239pyminor=`echo $pyversion | cut -d. -f2`
240
241if test "$pymajor" -ge "2"
242then
243 if test "$pymajor" -eq "2"
244 then
245 if test "$pyminor" -lt "2"
246 then
247 AC_MSG_WARN([QMTest requires Python 2.2 or later])
248 fi
249 fi
250else
251 AC_MSG_WARN([QMTest requires Python 2.2 or later])
252fi
253
254dnl Checks for libraries:
255dnl libelf is for sparc only; we can ignore it if we don't have it
256AC_CHECK_LIB(elf, elf_begin)
257
258dnl Check for bzip2 and zlib compression libraries needed for archive reading/writing
259AC_CHECK_LIB(bz2,BZ2_bzCompressInit,[bzip2_found=1],[bzip2_found=0])
260AC_CHECK_HEADERS([bzlib.h],[bzlib_h_found=1],[bzlib_h_found=0],[])
261AC_CHECK_LIB(z,gzopen,[zlib_found=1],[zlib_found=0])
262AC_CHECK_HEADERS([zlib.h],[zlib_h_found=1],[zlib_h_found=0],[])
263if test $zlib_found -eq 1 -a $zlib_h_found -eq 1; then
264 AC_DEFINE([HAVE_ZLIB],[1],[Define if zlib library is available on this platform.])
265 AC_SUBST([HAVE_ZLIB],[1])
266else
267 AC_SUBST([HAVE_ZLIB],[0])
268fi
269if test $bzip2_found -eq 1 -a $bzlib_h_found -eq 1 ; then
270 AC_DEFINE([HAVE_BZIP2],[1],[Define if bzip2 library is available on this platform.])
271 AC_SUBST([HAVE_BZIP2],[1])
272else
273 AC_SUBST([HAVE_BZIP2],[0])
274fi
275dnl dlopen() is required for plugin support.
276AC_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]))
277
278dnl mallinfo is optional; the code can compile (minus features) without it
279AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
280
281dnl pthread locking functions are optional - but llvm will not be thread-safe
282dnl without locks.
283AC_SEARCH_LIBS(pthread_mutex_lock,pthread,AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],[Have pthread_mutex_lock]))
284dnl AC_SUBST(HAVE_PTHREAD_MUTEX_LOCK)
285
286dnl Checks for header files.
287dnl We don't check for ancient stuff or things that are guaranteed to be there
288dnl by the C++ standard. We always use the <cfoo> versions of <foo.h> C headers.
289AC_HEADER_STDC
290AC_HEADER_SYS_WAIT
291
292dnl Checks for POSIX and other various system-specific header files
293AC_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)
294
295dnl Check for things that need to be included in public headers, and so
296dnl for which we may not have access to a HAVE_* preprocessor #define.
297dnl (primarily used in DataTypes.h)
298AC_CHECK_HEADER([sys/types.h])
299AC_CHECK_HEADER([inttypes.h])
300AC_CHECK_HEADER([stdint.h])
301
302dnl Check for types
303AC_TYPE_PID_T
304AC_TYPE_SIZE_T
305AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
306AC_CHECK_TYPES([uint64_t],,
307 AC_CHECK_TYPES([u_int64_t],,
308 AC_MSG_ERROR([Type uint64_t or u_int64_t required but not found])))
309AC_HEADER_TIME
310AC_STRUCT_TM
311
312dnl Check for various C features
313AC_C_PRINTF_A
314
315dnl Check for the endianness of the target
316AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little]))
317
318dnl Check for C++ extensions
319AC_CXX_HAVE_HASH_MAP
320AC_CXX_HAVE_HASH_SET
321AC_CXX_HAVE_STD_ITERATOR
322AC_CXX_HAVE_BI_ITERATOR
323AC_CXX_HAVE_FWD_ITERATOR
324
325AC_FUNC_ISNAN
326AC_FUNC_ISINF
327
328dnl Checks for library functions.
329AC_FUNC_ALLOCA
330AC_FUNC_MMAP
331if test "$ac_cv_func_mmap_fixed_mapped" = "no"
332then
333 AC_MSG_WARN([mmap() required but not found])
334fi
335AC_FUNC_MMAP_FILE
336if test "$ac_cv_func_mmap_file" = "no"
337then
338 AC_MSG_WARN([mmap() of files required but not found])
339fi
340AC_HEADER_MMAP_ANONYMOUS
341AC_TYPE_SIGNAL
342AC_CHECK_FUNCS(getcwd gettimeofday strdup strtoq strtoll backtrace isatty mkstemp getrusage)
343AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
344
345dnl Determine if the linker supports the -R option.
346AC_LINK_USE_R
347
348dnl --enable/--with command-line options:
349dnl Check whether they want to do an optimized build:
350AC_ARG_ENABLE(optimized,AS_HELP_STRING(--enable-optimized,Compile with optimizations enabled (default is NO)),,enableval=no)
351if test ${enableval} = "no"
352then
353 AC_SUBST(ENABLE_OPTIMIZED,[[]])
354else
355 AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
356fi
357
358dnl JIT Option
359AC_ARG_ENABLE(jit,AS_HELP_STRING(--enable-jit,Enable Just In Time Compiling (default is YES)),,enableval=default)
360if test ${enableval} = "no"
361then
362 AC_SUBST(JIT,[[]])
363else
364 case $target in
365 *i*86*)
366 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
367 ;;
368 *sparc*)
369 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
370 ;;
371 *)
372 AC_SUBST(JIT,[[]])
373 ;;
374 esac
375fi
376
377dnl Find the LLVM GCC-based C/C++ front end
378AC_ARG_WITH(llvmgccdir,AS_HELP_STRING(--with-llvmgccdir,Location of LLVM GCC front-end),AC_SUBST(LLVMGCCDIR,[$withval]))
379AC_MSG_CHECKING([for llvm-gcc])
380LLVM_GCC_CHECK=no
381if test -d "$LLVMGCCDIR"
382then
383 if test -x "$LLVMGCCDIR/bin/gcc"
384 then
385 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
386 fi
387fi
388llvmgccwarn=no
389AC_MSG_RESULT($LLVM_GCC_CHECK)
390if test "$LLVM_GCC_CHECK" = "no"
391then
392 llvmgccwarn=yes
393fi
394AC_MSG_CHECKING([whether llvm-gcc is sane])
395LLVM_GCC_SANE=no
396if test -x "$LLVM_GCC_CHECK"
397then
398 cp /dev/null conftest.c
399 "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
400 if test $? -eq 0
401 then
402 LLVM_GCC_SANE=yes
403 fi
404 rm conftest.c
405 llvmcc1path=`"$LLVM_GCC_CHECK" --print-prog-name=cc1`
406 AC_SUBST(LLVMCC1,$llvmcc1path)
407 llvmcc1pluspath=`"$LLVM_GCC_CHECK" --print-prog-name=cc1plus`
408 AC_SUBST(LLVMCC1PLUS,$llvmcc1pluspath)
409fi
410AC_MSG_RESULT($LLVM_GCC_SANE)
411if test "$LLVM_GCC_SANE" = "no"
412then
413 llvmgccwarn=yes
414fi
415
416dnl Get libtool's idea of what the shared library suffix is.
417dnl (This is a hack; it relies on undocumented behavior.)
418AC_MSG_CHECKING([for shared library suffix])
419eval "SHLIBEXT=$shrext_cmds"
420AC_MSG_RESULT($SHLIBEXT)
421dnl Propagate it to the Makefiles and config.h (for gccld & bugpoint).
422AC_SUBST(SHLIBEXT,$SHLIBEXT)
423AC_DEFINE_UNQUOTED(SHLIBEXT,"$SHLIBEXT",
424 [Extension that shared libraries have, e.g., ".so".])
425
426# Translate the various configuration directories and other basic
427# information into substitutions that will end up in config.h.in so
428# that these configured values can be hard-wired into a program.
429eval LLVM_PREFIX="${prefix}";
430eval LLVM_BINDIR="${prefix}/bin";
431eval LLVM_LIBDIR="${prefix}/lib";
432eval LLVM_DATADIR="${prefix}/data";
433eval LLVM_DOCSDIR="${prefix}/docs";
434eval LLVM_ETCDIR="${prefix}/etc";
435eval LLVM_INCLUDEDIR="${prefix}/include";
436eval LLVM_INFODIR="${prefix}/info";
437eval LLVM_MANDIR="${prefix}/man";
438LLVM_CONFIGTIME=`date`
439AC_SUBST(LLVM_PREFIX)
440AC_SUBST(LLVM_BINDIR)
441AC_SUBST(LLVM_LIBDIR)
442AC_SUBST(LLVM_DATADIR)
443AC_SUBST(LLVM_DOCSDIR)
444AC_SUBST(LLVM_ETCDIR)
445AC_SUBST(LLVM_INCLUDEDIR)
446AC_SUBST(LLVM_INFODIR)
447AC_SUBST(LLVM_MANDIR)
448AC_SUBST(LLVM_CONFIGTIME)
449AC_DEFINE_UNQUOTED(LLVM_PREFIX,"$LLVM_PREFIX", [Installation prefix directory])
450AC_DEFINE_UNQUOTED(LLVM_BINDIR, "$LLVM_BINDIR", [Installation directory for binary executables])
451AC_DEFINE_UNQUOTED(LLVM_LIBDIR, "$LLVM_LIBDIR", [Installation directory for libraries])
452AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DATADIR", [Installation directory for data files])
453AC_DEFINE_UNQUOTED(LLVM_DATADIR, "$LLVM_DOCSDIR", [Installation directory for documentation])
454AC_DEFINE_UNQUOTED(LLVM_ETCDIR, "$LLVM_ETCDIR", [Installation directory for config files])
455AC_DEFINE_UNQUOTED(LLVM_INCLUDEDIR, "$LLVM_INCLUDEDIR", [Installation directory for include files])
456AC_DEFINE_UNQUOTED(LLVM_INFODIR, "$LLVM_INFODIR", [Installation directory for .info files])
457AC_DEFINE_UNQUOTED(LLVM_MANDIR, "$LLVM_MANDIR", [Installation directory for man pages])
458AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME", [Time at which LLVM was configured])
459
460dnl Create the output files
461AC_OUTPUT
462
463dnl Warn if we don't have a compression library
464if test $bzip2_found -ne 1 ; then
465 if test $zlib_found -ne 1 ; then
466 AC_MSG_WARN([*** Neither zlib nor bzip2 compression libraries were found.])
467 AC_MSG_WARN([*** Bytecode archives will not support compression!])
468 AC_MSG_WARN([*** To correct, install the libraries and and re-run configure.])
469 fi
470fi
471
472dnl Warn loudly if llvm-gcc was not obviously working
473if test $llvmgccwarn = yes
474then
475 AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
476 AC_MSG_WARN([***** appear to be working.])
477 AC_MSG_WARN([***** ])
478 AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
479 AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
480 AC_MSG_WARN([***** but you should be able to build the llvm tools.])
481fi
482