Only default to the llvm-gcc in ~lattner if that directory exists.
[oota-llvm.git] / autoconf / configure.ac
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
7 dnl checks for types
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...])
13 dnl AC_OUTPUT
14
15 dnl **************************************************************************
16 dnl * Initialize
17 dnl **************************************************************************
18 AC_INIT([[[LLVM]]],[[[1.0]]],[llvmbugs@cs.uiuc.edu])
19
20 dnl Place all of the extra autoconf files into the config subdirectory
21 AC_CONFIG_AUX_DIR([autoconf])
22
23 dnl Quit if the source directory has already been configured.
24 dnl NOTE: This relies upon undocumented autoconf behavior.
25 if test ${srcdir} != "."
26 then
27         if test -f ${srcdir}/include/Config/config.h
28         then
29                 AC_MSG_ERROR([Already configured in ${srcdir}])
30         fi
31 fi
32
33 if test -d ${srcdir}/projects/sample
34 then
35   AC_CONFIG_SUBDIRS(projects/sample)
36 fi
37
38 if test -d ${srcdir}/projects/reopt
39 then
40   AC_CONFIG_SUBDIRS(projects/reopt)
41 fi
42
43 if test -d ${srcdir}/projects/poolalloc
44 then
45   AC_CONFIG_SUBDIRS(projects/poolalloc)
46 fi
47
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(Makefile.rules)
53 AC_CONFIG_MAKEFILE(lib/Makefile)
54 AC_CONFIG_MAKEFILE(lib/Analysis/Makefile)
55 AC_CONFIG_MAKEFILE(lib/Analysis/DataStructure/Makefile)
56 AC_CONFIG_MAKEFILE(lib/Analysis/IPA/Makefile)
57 AC_CONFIG_MAKEFILE(lib/Analysis/LiveVar/Makefile)
58 AC_CONFIG_MAKEFILE(lib/AsmParser/Makefile)
59 AC_CONFIG_MAKEFILE(lib/Bytecode/Makefile)
60 AC_CONFIG_MAKEFILE(lib/Bytecode/Reader/Makefile)
61 AC_CONFIG_MAKEFILE(lib/Bytecode/Writer/Makefile)
62 AC_CONFIG_MAKEFILE(lib/CWriter/Makefile)
63 AC_CONFIG_MAKEFILE(lib/CodeGen/Makefile)
64 AC_CONFIG_MAKEFILE(lib/CodeGen/InstrSched/Makefile)
65 AC_CONFIG_MAKEFILE(lib/CodeGen/InstrSelection/Makefile)
66 AC_CONFIG_MAKEFILE(lib/CodeGen/ModuloScheduling/Makefile)
67 AC_CONFIG_MAKEFILE(lib/CodeGen/RegAlloc/Makefile)
68 AC_CONFIG_MAKEFILE(lib/CodeGen/SelectionDAG/Makefile)
69 AC_CONFIG_MAKEFILE(lib/ExecutionEngine/Makefile)
70 AC_CONFIG_MAKEFILE(lib/ExecutionEngine/Interpreter/Makefile)
71 AC_CONFIG_MAKEFILE(lib/ExecutionEngine/JIT/Makefile)
72 AC_CONFIG_MAKEFILE(lib/Support/Makefile)
73 AC_CONFIG_MAKEFILE(lib/Target/Makefile)
74 AC_CONFIG_MAKEFILE(lib/Target/Sparc/Makefile)
75 AC_CONFIG_MAKEFILE(lib/Target/X86/Makefile)
76 AC_CONFIG_MAKEFILE(lib/Transforms/Makefile)
77 AC_CONFIG_MAKEFILE(lib/Transforms/Hello/Makefile)
78 AC_CONFIG_MAKEFILE(lib/Transforms/IPO/Makefile)
79 AC_CONFIG_MAKEFILE(lib/Transforms/Instrumentation/Makefile)
80 AC_CONFIG_MAKEFILE(lib/Transforms/Instrumentation/ProfilePaths/Makefile)
81 AC_CONFIG_MAKEFILE(lib/Transforms/Scalar/Makefile)
82 AC_CONFIG_MAKEFILE(lib/Transforms/Utils/Makefile)
83 AC_CONFIG_MAKEFILE(lib/VMCore/Makefile)
84 AC_CONFIG_MAKEFILE(runtime/Makefile)
85 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/Makefile)
86 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/crtend/Makefile)
87 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libc/Makefile)
88 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libcurses/Makefile)
89 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libg/Makefile)
90 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libgcc/Makefile)
91 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libm/Makefile)
92 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libmalloc/Makefile)
93 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libtermcap/Makefile)
94 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libucb/Makefile)
95 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libutempter/Makefile)
96 AC_CONFIG_MAKEFILE(runtime/GCCLibraries/libutil/Makefile)
97 AC_CONFIG_MAKEFILE(runtime/libdummy/Makefile)
98 AC_CONFIG_MAKEFILE(runtime/libtrace/Makefile)
99 AC_CONFIG_MAKEFILE(runtime/libprofile/Makefile)
100 AC_CONFIG_MAKEFILE(test/Makefile)
101 AC_CONFIG_MAKEFILE(test/Makefile.tests)
102 AC_CONFIG_MAKEFILE(test/QMTest/llvm.py)
103 AC_CONFIG_MAKEFILE(test/QMTest/llvmdb.py)
104 AC_CONFIG_MAKEFILE(test/Programs/Makefile)
105 AC_CONFIG_MAKEFILE(test/Programs/Makefile.programs)
106 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.Makefile)
107 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.report)
108 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.report)
109 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.report)
110 AC_CONFIG_MAKEFILE(test/Programs/TEST.example.Makefile)
111 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.Makefile)
112 AC_CONFIG_MAKEFILE(test/Programs/TEST.buildrepo.Makefile)
113 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.Makefile)
114 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.report)
115 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.Makefile)
116 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.report)
117 AC_CONFIG_MAKEFILE(test/Programs/TEST.typesafe.Makefile)
118 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.gnuplot)
119 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.Makefile)
120 AC_CONFIG_MAKEFILE(test/Programs/External/Makefile)
121 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile)
122 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile.spec)
123 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CFP2000/Makefile)
124 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CFP2000/177.mesa/Makefile)
125 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CFP2000/179.art/Makefile)
126 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CFP2000/183.equake/Makefile)
127 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CFP2000/188.ammp/Makefile)
128 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/Makefile)
129 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/164.gzip/Makefile)
130 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/175.vpr/Makefile)
131 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/176.gcc/Makefile)
132 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/181.mcf/Makefile)
133 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/186.crafty/Makefile)
134 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/197.parser/Makefile)
135 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/252.eon/Makefile)
136 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/253.perlbmk/Makefile)
137 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/254.gap/Makefile)
138 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/255.vortex/Makefile)
139 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/256.bzip2/Makefile)
140 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/CINT2000/300.twolf/Makefile)
141 AC_CONFIG_MAKEFILE(test/Programs/LLVMSource/Makefile)
142 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile)
143 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile.multisrc)
144 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Applications/Makefile)
145 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Applications/Burg/Makefile)
146 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Applications/aha/Makefile)
147 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Applications/sgefa/Makefile)
148 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Makefile)
149 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Fhourstones/Makefile)
150 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/Makefile)
151 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/analyzer/Makefile)
152 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/analyzer/test.in)
153 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/Makefile)
154 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/test.in)
155 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/Makefile)
156 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/test.in)
157 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile)
158 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in)
159 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/Makefile)
160 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/test.in)
161 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/Makefile)
162 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/test.in)
163 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/Makefile)
164 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/test.in)
165 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/Makefile)
166 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/01-qbsort/Makefile)
167 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/03-testtrie/Makefile)
168 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/04-bisect/Makefile)
169 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/05-eks/Makefile)
170 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/08-main/Makefile)
171 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/09-vor/Makefile)
172 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/12-IOtest/Makefile)
173 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/15-trie/Makefile)
174 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/17-bintr/Makefile)
175 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/McCat/18-imp/Makefile)
176 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/Makefile)
177 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/bh/Makefile)
178 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/bisort/Makefile)
179 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/em3d/Makefile)
180 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/health/Makefile)
181 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/mst/Makefile)
182 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/perimeter/Makefile)
183 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/power/Makefile)
184 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/treeadd/Makefile)
185 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/tsp/Makefile)
186 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Olden/voronoi/Makefile)
187 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/OptimizerEval/Makefile)
188 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Ptrdist/Makefile)
189 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Ptrdist/anagram/Makefile)
190 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Ptrdist/bc/Makefile)
191 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Ptrdist/ft/Makefile)
192 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Ptrdist/ks/Makefile)
193 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/Ptrdist/yacr2/Makefile)
194 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/llubenchmark/Makefile)
195 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/sim/Makefile)
196 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile)
197 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile.singlesrc)
198 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Gizmos/Makefile)
199 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Benchmarks/Makefile)
200 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Benchmarks/Dhrystone/Makefile)
201 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Benchmarks/Shootout/Makefile)
202 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Benchmarks/Stanford/Makefile)
203 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Benchmarks/Misc/Makefile)
204 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/CustomChecked/Makefile)
205 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/UnitTests/Makefile)
206 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile)
207 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Regression/Makefile)
208 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Regression/C/Makefile)
209 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Regression/C++/Makefile)
210 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Regression/C++/EH/Makefile)
211 AC_CONFIG_MAKEFILE(tools/Makefile)
212 AC_CONFIG_MAKEFILE(tools/analyze/Makefile)
213 AC_CONFIG_MAKEFILE(tools/bugpoint/Makefile)
214 AC_CONFIG_MAKEFILE(tools/extract/Makefile)
215 AC_CONFIG_MAKEFILE(tools/gccas/Makefile)
216 AC_CONFIG_MAKEFILE(tools/gccld/Makefile)
217 AC_CONFIG_MAKEFILE(tools/llc/Makefile)
218 AC_CONFIG_MAKEFILE(tools/llee/Makefile)
219 AC_CONFIG_MAKEFILE(tools/lli/Makefile)
220 AC_CONFIG_MAKEFILE(tools/llvm-ar/Makefile)
221 AC_CONFIG_MAKEFILE(tools/llvm-as/Makefile)
222 AC_CONFIG_MAKEFILE(tools/llvm-dis/Makefile)
223 AC_CONFIG_MAKEFILE(tools/llvm-link/Makefile)
224 AC_CONFIG_MAKEFILE(tools/llvm-nm/Makefile)
225 AC_CONFIG_MAKEFILE(tools/llvm-prof/Makefile)
226 AC_CONFIG_MAKEFILE(tools/opt/Makefile)
227 AC_CONFIG_MAKEFILE(utils/Makefile)
228 AC_CONFIG_MAKEFILE(utils/Burg/Makefile)
229 AC_CONFIG_MAKEFILE(utils/Burg/Doc/Makefile)
230 AC_CONFIG_MAKEFILE(utils/TableGen/Makefile)
231 AC_CONFIG_MAKEFILE(projects/Makefile)
232 AC_CONFIG_MAKEFILE(projects/ModuleMaker/Makefile)
233 AC_CONFIG_MAKEFILE(projects/ModuleMaker/Makefile.common)
234 AC_CONFIG_MAKEFILE(projects/ModuleMaker/tools/Makefile)
235 AC_CONFIG_MAKEFILE(projects/ModuleMaker/tools/ModuleMaker/Makefile)
236
237 dnl **************************************************************************
238 dnl * Determine which system we are building on
239 dnl **************************************************************************
240
241 dnl Check the install program (needs to be done before canonical stuff)
242 AC_PROG_INSTALL
243
244 dnl Check which host for which we're compiling.  This will tell us which LLVM
245 dnl compiler will be used for compiling SSA into object code.
246 AC_CANONICAL_TARGET
247
248 dnl
249 dnl Now, for some of our own magic:
250 dnl We will use the build machine information to set some variables.
251 dnl
252 case $build in
253         *i*86*)  AC_SUBST(OS,[Linux])
254                          if test -d /home/vadve/lattner/local/x86/llvm-gcc
255                          then
256                            AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
257                          fi
258                  ;;
259
260         *sparc*) AC_SUBST(OS,[SunOS])
261                          if test -d /home/vadve/lattner/local/sparc/llvm-gcc
262                          then
263                    AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
264                          fi
265                  ;;
266
267         *)       AC_SUBST(OS,[Unknown])
268                  ;;
269 esac
270
271 dnl
272 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
273 dnl V9, since that is all that we support at the moment, and autoconf will only
274 dnl tell us we're a sparc.
275 dnl
276 case $target in
277         *sparc*solaris*)  AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
278                           ;;
279 esac
280
281 dnl
282 dnl Determine what our target architecture is and configure accordingly.
283 dnl This will allow Makefiles to make a distinction between the hardware and
284 dnl the OS.
285 dnl
286 case $target in
287         *i*86*)           AC_SUBST(ARCH,[x86])
288                           ;;
289         *sparc*solaris*)  AC_SUBST(ARCH,[Sparc])
290                           ;;
291 esac
292
293 dnl **************************************************************************
294 dnl * Check for programs.
295 dnl **************************************************************************
296
297 dnl Check for compilation tools
298 AC_PROG_CXX
299 AC_PROG_CC(gcc)
300 AC_PROG_CPP
301
302 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
303 if test "$GCC" != "yes"
304 then
305         AC_MSG_ERROR([gcc required but not found])
306 fi
307
308 if test "$GXX" != "yes"
309 then
310         AC_MSG_ERROR([g++ required but not found])
311 fi
312
313 dnl Verify that GCC is version 3.0 or higher
314 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
315 if test "$gccmajor" -lt "3"
316 then
317         AC_MSG_ERROR([gcc 3.x required])
318 fi
319
320 dnl Check for GNU Make.  We use its extensions to, so don't build without it
321 CHECK_GNU_MAKE
322 if test -z "$_cv_gnu_make_command"
323 then
324         AC_MSG_ERROR([GNU Make required but not found])
325 fi
326
327 dnl Check for compiler-compiler tools (reminds me of Little Caesar's Pizza)
328 AC_PROG_FLEX
329 AC_PROG_BISON
330
331 dnl Check for libtool
332 AC_PROG_LIBTOOL
333
334 dnl Check for our special programs
335 AC_PATH_PROG(RPWD,[pwd],[false])
336 if test ${RPWD} = "false"
337 then
338         AC_MSG_ERROR([pwd required but not found])
339 fi
340
341 AC_PATH_PROG(AR,[ar],[false])
342 if test ${AR} = "false"
343 then
344         AC_MSG_ERROR([ar required but not found])
345 fi
346
347 AC_PATH_PROG(SED,[sed],[false])
348 if test ${SED} = "false"
349 then
350         AC_MSG_ERROR([sed required but not found])
351 fi
352
353 AC_PATH_PROG(RM,[rm],[false])
354 if test ${RM} = "false"
355 then
356         AC_MSG_ERROR([rm required but not found])
357 fi
358
359 AC_PATH_PROG(ECHO,[echo],[false])
360 if test ${ECHO} = "false"
361 then
362         AC_MSG_ERROR([echo required but not found])
363 fi
364
365 AC_PATH_PROG(MKDIR,[mkdir],[false])
366 if test ${MKDIR} = "false"
367 then
368         AC_MSG_ERROR([mkdir required but not found])
369 fi
370
371 AC_PATH_PROG(DATE,[date],[false])
372 if test ${DATE} = "false"
373 then
374         AC_MSG_ERROR([date required but not found])
375 fi
376
377 AC_PATH_PROG(MV,[mv],[false])
378 if test ${MV} = "false"
379 then
380         AC_MSG_ERROR([mv required but not found])
381 fi
382
383 AC_PATH_PROG(DOT,[dot],[false])
384
385 AC_PATH_PROG(ETAGS,[etags],[false])
386
387 AC_PATH_PROG(PYTHON,[python],[false])
388 if test ${PYTHON} = "false"
389 then
390         AC_MSG_WARN([python required but not found])
391 fi
392
393 AC_PATH_PROG(QMTEST,[qmtest],[false])
394 if test ${QMTEST} = "false"
395 then
396         AC_MSG_WARN([qmtest required but not found])
397 fi
398
399 dnl Verify that the version of python available is high enough for qmtest
400 pyversion=`$PYTHON -V 2>&1 | cut -d\  -f2`
401 pymajor=`echo $pyversion | cut -d. -f1`
402 pyminor=`echo $pyversion | cut -d. -f2`
403
404 if test "$pymajor" -ge "2"
405 then
406         if test "$pymajor" -eq "2"
407         then
408                 if test "$pyminor" -lt "2"
409                 then
410                         AC_MSG_WARN([Python 2.2 or greater required for qmtest])
411                 fi
412         fi
413 else
414         AC_MSG_WARN([Python 2.2 or greater required for qmtest])
415 fi
416
417 dnl Verify that the source directory is valid
418 AC_CONFIG_SRCDIR(["Makefile.config.in"])
419
420 dnl **************************************************************************
421 dnl * Check for libraries.
422 dnl **************************************************************************
423
424 dnl libelf is for sparc only; we can ignore it if we don't have it
425 AC_CHECK_LIB(elf, elf_begin)
426
427 dnl dlopen() is required for plugin support.
428 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]))
429
430 dnl mallinfo is optional; the code can compile (minus features) without it
431 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
432
433 dnl
434 dnl The math libraries are used by the test code, but not by the actual LLVM
435 dnl code.
436 dnl
437 dnl AC_CHECK_LIB(m, cos)
438
439 dnl **************************************************************************
440 dnl * Checks for header files.
441 dnl *   Chances are, if the standard C or POSIX type header files are missing,
442 dnl *   then LLVM just isn't going to compile.  However, it is possible that
443 dnl *   the necessary functions/macros will be included from other
444 dnl *   (non-standard and non-obvious) header files.
445 dnl *
446 dnl *   So, we'll be gracious, give it a chance, and try to go on without
447 dnl *   them.
448 dnl **************************************************************************
449 AC_HEADER_STDC
450 AC_HEADER_SYS_WAIT
451
452 dnl Check for ANSI C/POSIX header files
453 AC_CHECK_HEADERS(assert.h fcntl.h limits.h sys/time.h unistd.h errno.h signal.h math.h)
454
455 dnl Check for system specific header files
456 AC_CHECK_HEADERS(malloc.h sys/mman.h sys/resource.h)
457
458 dnl Check for header files associated with dlopen and friends
459 AC_CHECK_HEADERS(dlfcn.h link.h)
460
461 dnl **************************************************************************
462 dnl * Checks for typedefs, structures, and compiler characteristics.
463 dnl **************************************************************************
464
465 dnl Check for const and inline keywords
466 AC_C_CONST
467 AC_C_INLINE
468
469 dnl Check for machine endian-ness
470 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]))
471
472 dnl Check for types
473 AC_TYPE_PID_T
474 AC_TYPE_SIZE_T
475 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
476 AC_CHECK_TYPES([uint64_t],,AC_MSG_ERROR([Type uint64_t required but not found]))
477 AC_HEADER_TIME
478 AC_STRUCT_TM
479
480 dnl Check for various C features
481 AC_C_PRINTF_A
482
483 dnl Check for C++ extensions
484 AC_CXX_HAVE_HASH_MAP
485 AC_CXX_HAVE_HASH_SET
486 AC_CXX_HAVE_EXT_SLIST
487 AC_CXX_HAVE_STD_ITERATOR
488 AC_CXX_HAVE_BI_ITERATOR
489 AC_CXX_HAVE_FWD_ITERATOR
490
491 dnl **************************************************************************
492 dnl * Checks for library functions.
493 dnl **************************************************************************
494 AC_FUNC_ALLOCA
495 AC_PROG_GCC_TRADITIONAL
496 AC_FUNC_MEMCMP
497 AC_FUNC_MMAP
498 AC_FUNC_MMAP_FILE
499 if test ${ac_cv_func_mmap_file} = "no"
500 then
501         AC_MSG_ERROR([mmap() of files required but not found])
502 fi
503 AC_HEADER_MMAP_ANONYMOUS
504 AC_TYPE_SIGNAL
505 AC_CHECK_FUNCS(getcwd gettimeofday strcspn strdup strerror strspn strstr strtod strtol strtoq strtoll)
506
507 dnl
508 dnl Need to check mmap for MAP_PRIVATE, MAP_ANONYMOUS, MAP_ANON, MAP_FIXED
509 dnl MAP_FIXED is only needed for Sparc
510 dnl MAP_ANON is used for Sparc and BSD
511 dnl Everyone should have MAP_PRIVATE
512 dnl
513
514 dnl Check for certain functions (even if we've already found them) so that we
515 dnl can quit with an error if they are unavailable.
516 dnl
517 dnl As the code is made more portable (i.e. less reliant on these functions,
518 dnl these checks should go away.
519 AC_CHECK_FUNC(mmap,,AC_MSG_ERROR([Function mmap() required but not found]))
520 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
521
522 dnl **************************************************************************
523 dnl * Enable various compile-time options
524 dnl **************************************************************************
525
526 dnl Purify Option
527 AC_ARG_ENABLE(purify,AC_HELP_STRING([--enable-purify],[Compile with purify (default is NO)]),,enableval="no")
528 if test ${enableval} = "no"
529 then
530         AC_SUBST(ENABLE_PURIFY,[[]])
531 else
532         AC_SUBST(ENABLE_PURIFY,[[ENABLE_PURIFY=1]])
533 fi
534
535 dnl Optimized Option
536 AC_ARG_ENABLE(optimized,AC_HELP_STRING([--enable-optimized],[Compile with optimizations enabled (default is NO)]),,enableval=no)
537 if test ${enableval} = "no"
538 then
539         AC_SUBST(ENABLE_OPTIMIZED,[[]])
540 else
541         AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
542 fi
543
544 dnl Spec Benchmarks
545 AC_ARG_ENABLE(spec2000,AC_HELP_STRING([--enable-spec],[Compile SPEC 2000 benchmarks (default is NO)]),,enableval=no)
546 if test ${enableval} = "no"
547 then
548         if test -d /home/vadve/shared/benchmarks/speccpu2000/benchspec
549         then
550                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
551                 AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
552         else
553                 AC_SUBST(USE_SPEC,[[]])
554                 AC_SUBST(SPEC_ROOT,[])
555         fi
556 else
557         if test ${enableval} = ""
558         then
559                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
560         else
561                 AC_SUBST(SPEC_ROOT,[${enableval}])
562         fi
563         AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
564 fi
565
566 dnl Precompiled Bytecode Option
567 AC_ARG_ENABLE(precompiled_bytecode,AC_HELP_STRING([--enable-precompiled_bytecode],[Use pre-compiled bytecode (default is NO)]),,enableval=no)
568 if test ${enableval} = "no"
569 then
570         AC_SUBST(UPB,[[]])
571 else
572         AC_SUBST(UPB,[[USE_PRECOMPILED_BYTECODE=1]])
573 fi
574
575
576 dnl LLC Diff Option
577 AC_ARG_ENABLE(llc_diffs,AC_HELP_STRING([--enable-llc_diffs],[Enable LLC Diffs when testing (default is YES)]),,enableval=yes)
578 if test ${enableval} = "no"
579 then
580         AC_SUBST(DISABLE_LLC_DIFFS,[DISABLE_LLC_DIFFS:=1])
581 else
582         AC_SUBST(DISABLE_LLC_DIFFS,[[]])
583 fi
584
585 dnl JIT Option
586 AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is YES)]),,enableval=default)
587
588 if test ${enableval} = "no"
589 then
590         AC_SUBST(JIT,[[]])
591 else
592         case $target in
593                 *i*86*)
594                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
595                         ;;
596                 *sparc*)
597                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
598                         ;;
599                 *)
600                         AC_SUBST(JIT,[[]])
601                         ;;
602         esac
603 fi
604
605 dnl **************************************************************************
606 dnl * Set the location of various third-party software packages
607 dnl **************************************************************************
608
609 dnl Location of the LLVM C front end
610 AC_ARG_WITH(llvmgccdir,AC_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),AC_SUBST(LLVMGCCDIR,[$withval]))
611
612 AC_MSG_CHECKING([for llvm-gcc])
613 LLVM_GCC_CHECK=no
614 if test -d "$LLVMGCCDIR"
615 then
616         if test -x "$LLVMGCCDIR/bin/gcc"
617         then
618                 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
619         fi
620 fi
621 llvmgccwarn=no
622 AC_MSG_RESULT($LLVM_GCC_CHECK)
623 if test "$LLVM_GCC_CHECK" = "no"
624 then
625     llvmgccwarn=yes
626 fi
627
628 AC_MSG_CHECKING([whether llvm-gcc is sane])
629 LLVM_GCC_SANE=no
630 if test -x "$LLVM_GCC_CHECK"
631 then
632         cp /dev/null conftest.c
633     "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
634         if test $? -eq 0
635         then
636                 LLVM_GCC_SANE=yes
637         fi
638         rm conftest.c
639 fi
640 AC_MSG_RESULT($LLVM_GCC_SANE)
641 if test "$LLVM_GCC_SANE" = "no"
642 then
643         llvmgccwarn=yes
644 fi
645
646 dnl Location of the bytecode repository
647 AC_ARG_WITH(bcrepos,AC_HELP_STRING([--with-bcrepos],[Location of Bytecode Repository]),AC_SUBST(BCR,[$withval]),AC_SUBST(BCR,[/home/vadve/lattner/LLVMPrograms]))
648
649 dnl Location of PAPI
650 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]))
651
652 dnl Location of the purify program
653 AC_ARG_WITH(purify,AC_HELP_STRING([--with-purify],[Location of purify program]),AC_SUBST(PURIFY,[$withval]))
654
655 dnl **************************************************************************
656 dnl * Configure other software packages (via AC_CONFIG_SUBDIRS)
657 dnl **************************************************************************
658
659 dnl **************************************************************************
660 dnl * Create the output files
661 dnl **************************************************************************
662 AC_OUTPUT(Makefile.config)
663
664 if test $llvmgccwarn = yes
665 then
666         AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
667         AC_MSG_WARN([***** appear to be working.])
668         AC_MSG_WARN([***** ])
669         AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
670         AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
671         AC_MSG_WARN([***** but you should be able to build the llvm tools.])
672 fi