1 dnl Autoconf requirements
2 dnl AC_INIT(package, version, bug-report-address)
3 dnl information on the package
4 dnl checks for programs
5 dnl checks for libraries
6 dnl checks for header files
8 dnl checks for structures
9 dnl checks for compiler characteristics
10 dnl checks for library functions
11 dnl checks for system services
12 dnl AC_CONFIG_FILES([file...])
15 dnl **************************************************************************
17 dnl **************************************************************************
18 AC_INIT([[[LLVM]]],[[[1.0]]],[llvmbugs@cs.uiuc.edu])
20 dnl Place all of the extra autoconf files into the config subdirectory
21 AC_CONFIG_AUX_DIR([autoconf])
23 dnl Quit if the source directory has already been configured.
24 dnl NOTE: This relies upon undocumented autoconf behavior.
25 if test ${srcdir} != "."
27 if test -f ${srcdir}/include/Config/config.h
29 AC_MSG_ERROR([Already configured in ${srcdir}])
33 if test -d ${srcdir}/projects/sample
35 AC_CONFIG_SUBDIRS(projects/sample)
38 if test -d ${srcdir}/projects/reopt
40 AC_CONFIG_SUBDIRS(projects/reopt)
43 if test -d ${srcdir}/projects/poolalloc
45 AC_CONFIG_SUBDIRS(projects/poolalloc)
48 dnl Configure a header file
49 AC_CONFIG_HEADERS(include/Config/config.h)
50 AC_CONFIG_MAKEFILE(Makefile)
51 AC_CONFIG_MAKEFILE(Makefile.common)
52 AC_CONFIG_MAKEFILE(lib/Makefile)
53 AC_CONFIG_MAKEFILE(runtime/Makefile)
54 AC_CONFIG_MAKEFILE(test/Makefile)
55 AC_CONFIG_MAKEFILE(test/Makefile.tests)
56 AC_CONFIG_MAKEFILE(test/QMTest/llvm.py)
57 AC_CONFIG_MAKEFILE(test/QMTest/llvmdb.py)
58 AC_CONFIG_MAKEFILE(test/Programs/Makefile)
59 AC_CONFIG_MAKEFILE(test/Programs/Makefile.programs)
60 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.Makefile)
61 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.report)
62 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.report)
63 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.report)
64 AC_CONFIG_MAKEFILE(test/Programs/TEST.example.Makefile)
65 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.Makefile)
66 AC_CONFIG_MAKEFILE(test/Programs/TEST.buildrepo.Makefile)
67 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.Makefile)
68 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.report)
69 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.Makefile)
70 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.report)
71 AC_CONFIG_MAKEFILE(test/Programs/TEST.typesafe.Makefile)
72 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.gnuplot)
73 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.Makefile)
74 AC_CONFIG_MAKEFILE(test/Programs/External/Makefile)
75 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile)
76 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile.spec)
77 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile)
78 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile.multisrc)
79 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/analyzer/test.in)
80 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/Makefile)
81 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/test.in)
82 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/Makefile)
83 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/test.in)
84 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile)
85 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in)
86 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/Makefile)
87 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/test.in)
88 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/Makefile)
89 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/test.in)
90 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/Makefile)
91 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/test.in)
92 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile)
93 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile.singlesrc)
94 AC_CONFIG_MAKEFILE(tools/Makefile)
95 AC_CONFIG_MAKEFILE(utils/Makefile)
96 AC_CONFIG_MAKEFILE(projects/Makefile)
97 AC_CONFIG_MAKEFILE(projects/ModuleMaker/Makefile)
98 AC_CONFIG_MAKEFILE(projects/ModuleMaker/Makefile.common)
99 AC_CONFIG_MAKEFILE(projects/ModuleMaker/tools/Makefile)
100 AC_CONFIG_MAKEFILE(projects/ModuleMaker/tools/ModuleMaker/Makefile)
101 AC_CONFIG_MAKEFILE(projects/Stacker/Makefile)
102 AC_CONFIG_MAKEFILE(projects/Stacker/lib/Makefile)
103 AC_CONFIG_MAKEFILE(projects/Stacker/lib/compiler/Makefile)
104 AC_CONFIG_MAKEFILE(projects/Stacker/lib/runtime/Makefile)
105 AC_CONFIG_MAKEFILE(projects/Stacker/tools/Makefile)
106 AC_CONFIG_MAKEFILE(projects/Stacker/tools/stkrc/Makefile)
107 AC_CONFIG_MAKEFILE(projects/Stacker/test/Makefile)
108 AC_CONFIG_MAKEFILE(projects/Stacker/samples/Makefile)
110 dnl **************************************************************************
111 dnl * Determine which system we are building on
112 dnl **************************************************************************
114 dnl Check the install program (needs to be done before canonical stuff)
117 dnl Check which host for which we're compiling. This will tell us which LLVM
118 dnl compiler will be used for compiling SSA into object code.
121 dnl Set the "OS" Makefile variable based on the system we are building on.
122 dnl We will use the build machine information to set some variables.
126 if test -d /home/vadve/lattner/local/x86/llvm-gcc
128 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
134 if test -d /home/vadve/lattner/local/sparc/llvm-gcc
136 AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
141 AC_SUBST(OS,[Darwin])
144 *) AC_SUBST(OS,[Unknown])
148 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
149 dnl V9, since that is all that we support at the moment, and autoconf will only
150 dnl tell us we're a sparc.
152 sparc*-*-solaris*) AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
156 dnl Determine what our target architecture is and configure accordingly.
157 dnl This will allow Makefiles to make a distinction between the hardware and
160 i*86-*) AC_SUBST(ARCH,[x86])
162 sparc*-*) AC_SUBST(ARCH,[Sparc])
164 powerpc*-*) AC_SUBST(ARCH,[PowerPC])
166 *) AC_SUBST(ARCH,[Unknown])
170 dnl **************************************************************************
171 dnl * Check for programs.
172 dnl **************************************************************************
174 dnl Check for compilation tools
179 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
180 if test "$GCC" != "yes"
182 AC_MSG_ERROR([gcc required but not found])
185 if test "$GXX" != "yes"
187 AC_MSG_ERROR([g++ required but not found])
190 dnl Verify that GCC is version 3.0 or higher
191 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
192 if test "$gccmajor" -lt "3"
194 AC_MSG_ERROR([gcc 3.x required])
197 dnl Check for GNU Make. We use its extensions to, so don't build without it
199 if test -z "$_cv_gnu_make_command"
201 AC_MSG_ERROR([GNU Make required but not found])
204 dnl Check for compiler-compiler tools (reminds me of Little Caesar's Pizza)
208 dnl Check for libtool
211 dnl Check for our special programs
212 AC_PATH_PROG(RPWD,[pwd],[false])
213 if test ${RPWD} = "false"
215 AC_MSG_ERROR([pwd required but not found])
218 AC_PATH_PROG(AR,[ar],[false])
219 if test ${AR} = "false"
221 AC_MSG_ERROR([ar required but not found])
224 AC_PATH_PROG(SED,[sed],[false])
225 if test ${SED} = "false"
227 AC_MSG_ERROR([sed required but not found])
230 AC_PATH_PROG(RM,[rm],[false])
231 if test ${RM} = "false"
233 AC_MSG_ERROR([rm required but not found])
236 AC_PATH_PROG(ECHO,[echo],[false])
237 if test ${ECHO} = "false"
239 AC_MSG_ERROR([echo required but not found])
242 AC_PATH_PROG(MKDIR,[mkdir],[false])
243 if test ${MKDIR} = "false"
245 AC_MSG_ERROR([mkdir required but not found])
248 AC_PATH_PROG(DATE,[date],[false])
249 if test ${DATE} = "false"
251 AC_MSG_ERROR([date required but not found])
254 AC_PATH_PROG(MV,[mv],[false])
255 if test ${MV} = "false"
257 AC_MSG_ERROR([mv required but not found])
260 AC_PATH_PROG(DOT,[dot],[false])
262 AC_PATH_PROG(ETAGS,[etags],[false])
264 AC_PATH_PROG(PYTHON,[python],[false])
265 if test ${PYTHON} = "false"
267 AC_MSG_WARN([python required but not found])
270 AC_PATH_PROG(QMTEST,[qmtest],[false])
271 if test ${QMTEST} = "false"
273 AC_MSG_WARN([qmtest required but not found])
276 dnl Verify that the version of python available is high enough for qmtest
277 pyversion=`$PYTHON -V 2>&1 | cut -d\ -f2`
278 pymajor=`echo $pyversion | cut -d. -f1`
279 pyminor=`echo $pyversion | cut -d. -f2`
281 if test "$pymajor" -ge "2"
283 if test "$pymajor" -eq "2"
285 if test "$pyminor" -lt "2"
287 AC_MSG_WARN([Python 2.2 or greater required for qmtest])
291 AC_MSG_WARN([Python 2.2 or greater required for qmtest])
294 dnl Verify that the source directory is valid
295 AC_CONFIG_SRCDIR(["Makefile.config.in"])
297 dnl **************************************************************************
298 dnl * Check for libraries.
299 dnl **************************************************************************
301 dnl libelf is for sparc only; we can ignore it if we don't have it
302 AC_CHECK_LIB(elf, elf_begin)
304 dnl dlopen() is required for plugin support.
305 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]))
307 dnl mallinfo is optional; the code can compile (minus features) without it
308 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
311 dnl The math libraries are used by the test code, but not by the actual LLVM
314 dnl AC_CHECK_LIB(m, cos)
316 dnl **************************************************************************
317 dnl * Checks for header files.
318 dnl * Chances are, if the standard C or POSIX type header files are missing,
319 dnl * then LLVM just isn't going to compile. However, it is possible that
320 dnl * the necessary functions/macros will be included from other
321 dnl * (non-standard and non-obvious) header files.
323 dnl * So, we'll be gracious, give it a chance, and try to go on without
325 dnl **************************************************************************
329 dnl Check for ANSI C/POSIX header files
330 AC_CHECK_HEADERS(assert.h fcntl.h limits.h sys/time.h unistd.h errno.h signal.h math.h)
332 dnl Check for system specific header files
333 AC_CHECK_HEADERS(malloc.h sys/mman.h sys/resource.h)
335 dnl Check for header files associated with dlopen and friends
336 AC_CHECK_HEADERS(dlfcn.h link.h)
338 dnl **************************************************************************
339 dnl * Checks for typedefs, structures, and compiler characteristics.
340 dnl **************************************************************************
342 dnl Check for const and inline keywords
346 dnl Check for machine endian-ness
347 AC_C_BIGENDIAN(AC_DEFINE([ENDIAN_BIG],[],[Define if the machine is Big-Endian]),AC_DEFINE([ENDIAN_LITTLE],[],[Define if the machine is Little-Endian]))
352 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
353 AC_CHECK_TYPES([uint64_t],,AC_MSG_ERROR([Type uint64_t required but not found]))
357 dnl Check for various C features
360 dnl Check for C++ extensions
363 AC_CXX_HAVE_EXT_SLIST
364 AC_CXX_HAVE_STD_ITERATOR
365 AC_CXX_HAVE_BI_ITERATOR
366 AC_CXX_HAVE_FWD_ITERATOR
368 dnl **************************************************************************
369 dnl * Checks for library functions.
370 dnl **************************************************************************
372 AC_PROG_GCC_TRADITIONAL
376 if test ${ac_cv_func_mmap_file} = "no"
378 AC_MSG_ERROR([mmap() of files required but not found])
380 AC_HEADER_MMAP_ANONYMOUS
382 AC_CHECK_FUNCS(getcwd gettimeofday strcspn strdup strerror strspn strstr strtod strtol strtoq strtoll)
385 dnl Need to check mmap for MAP_PRIVATE, MAP_ANONYMOUS, MAP_ANON, MAP_FIXED
386 dnl MAP_FIXED is only needed for Sparc
387 dnl MAP_ANON is used for Sparc and BSD
388 dnl Everyone should have MAP_PRIVATE
391 dnl Check for certain functions (even if we've already found them) so that we
392 dnl can quit with an error if they are unavailable.
394 dnl As the code is made more portable (i.e. less reliant on these functions,
395 dnl these checks should go away.
396 AC_CHECK_FUNC(mmap,,AC_MSG_ERROR([Function mmap() required but not found]))
397 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
399 dnl Determine if the linker supports the -R option.
402 dnl **************************************************************************
403 dnl * Enable various compile-time options
404 dnl **************************************************************************
407 AC_ARG_ENABLE(purify,AC_HELP_STRING([--enable-purify],[Compile with purify (default is NO)]),,enableval="no")
408 if test ${enableval} = "no"
410 AC_SUBST(ENABLE_PURIFY,[[]])
412 AC_SUBST(ENABLE_PURIFY,[[ENABLE_PURIFY=1]])
416 AC_ARG_ENABLE(optimized,AC_HELP_STRING([--enable-optimized],[Compile with optimizations enabled (default is NO)]),,enableval=no)
417 if test ${enableval} = "no"
419 AC_SUBST(ENABLE_OPTIMIZED,[[]])
421 AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
425 AC_ARG_ENABLE(spec2000,AC_HELP_STRING([--enable-spec],[Compile SPEC 2000 benchmarks (default is NO)]),,enableval=no)
426 if test ${enableval} = "no"
428 if test -d /home/vadve/shared/benchmarks/speccpu2000/benchspec
430 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
431 AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
433 AC_SUBST(USE_SPEC,[[]])
434 AC_SUBST(SPEC_ROOT,[])
437 if test ${enableval} = ""
439 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
441 AC_SUBST(SPEC_ROOT,[${enableval}])
443 AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
446 dnl Precompiled Bytecode Option
447 AC_ARG_ENABLE(precompiled_bytecode,AC_HELP_STRING([--enable-precompiled_bytecode],[Use pre-compiled bytecode (default is NO)]),,enableval=no)
448 if test ${enableval} = "no"
452 AC_SUBST(UPB,[[USE_PRECOMPILED_BYTECODE=1]])
457 AC_ARG_ENABLE(llc_diffs,AC_HELP_STRING([--enable-llc_diffs],[Enable LLC Diffs when testing (default is YES)]),,enableval=yes)
458 if test ${enableval} = "no"
460 AC_SUBST(DISABLE_LLC_DIFFS,[DISABLE_LLC_DIFFS:=1])
462 AC_SUBST(DISABLE_LLC_DIFFS,[[]])
466 AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is YES)]),,enableval=default)
468 if test ${enableval} = "no"
474 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
477 AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
485 dnl **************************************************************************
486 dnl * Set the location of various third-party software packages
487 dnl **************************************************************************
489 dnl Location of the LLVM C front end
490 AC_ARG_WITH(llvmgccdir,AC_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),AC_SUBST(LLVMGCCDIR,[$withval]))
492 AC_MSG_CHECKING([for llvm-gcc])
494 if test -d "$LLVMGCCDIR"
496 if test -x "$LLVMGCCDIR/bin/gcc"
498 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
502 AC_MSG_RESULT($LLVM_GCC_CHECK)
503 if test "$LLVM_GCC_CHECK" = "no"
508 AC_MSG_CHECKING([whether llvm-gcc is sane])
510 if test -x "$LLVM_GCC_CHECK"
512 cp /dev/null conftest.c
513 "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
520 AC_MSG_RESULT($LLVM_GCC_SANE)
521 if test "$LLVM_GCC_SANE" = "no"
526 dnl Location of the bytecode repository
527 AC_ARG_WITH(bcrepos,AC_HELP_STRING([--with-bcrepos],[Location of Bytecode Repository]),AC_SUBST(BCR,[$withval]),AC_SUBST(BCR,[/home/vadve/lattner/LLVMPrograms]))
530 AC_ARG_WITH(papi,AC_HELP_STRING([--with-papi],[Location of PAPI]),AC_SUBST(PAPIDIR,[$withval]),AC_SUBST(PAPIDIR,[/home/vadve/shared/Sparc/papi-2.3.4.1]))
532 dnl Location of the purify program
533 AC_ARG_WITH(purify,AC_HELP_STRING([--with-purify],[Location of purify program]),AC_SUBST(PURIFY,[$withval]))
535 dnl **************************************************************************
536 dnl * Configure other software packages (via AC_CONFIG_SUBDIRS)
537 dnl **************************************************************************
539 dnl **************************************************************************
540 dnl * Create the output files
541 dnl **************************************************************************
542 AC_OUTPUT(Makefile.config)
544 if test $llvmgccwarn = yes
546 AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
547 AC_MSG_WARN([***** appear to be working.])
548 AC_MSG_WARN([***** ])
549 AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
550 AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
551 AC_MSG_WARN([***** but you should be able to build the llvm tools.])