Finegrainify namespacification
[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 dnl
34 dnl Configure all of the projects present in our source tree.
35 dnl
36 for i in `ls ${srcdir}/projects`
37 do
38   if test ${i} != "CVS"
39   then
40     if test -d ${srcdir}/projects/${i}
41     then
42       AC_CONFIG_SUBDIRS(projects/${i})
43     fi
44   fi
45 done
46
47 dnl Configure a header file
48 AC_CONFIG_HEADERS(include/Config/config.h)
49 AC_CONFIG_MAKEFILE(Makefile)
50 AC_CONFIG_MAKEFILE(Makefile.common)
51 AC_CONFIG_MAKEFILE(lib/Makefile)
52 AC_CONFIG_MAKEFILE(runtime/Makefile)
53 AC_CONFIG_MAKEFILE(test/Makefile)
54 AC_CONFIG_MAKEFILE(test/Makefile.tests)
55 AC_CONFIG_MAKEFILE(test/QMTest/llvm.py)
56 AC_CONFIG_MAKEFILE(test/QMTest/llvmdb.py)
57 AC_CONFIG_MAKEFILE(test/Programs/Makefile)
58 AC_CONFIG_MAKEFILE(test/Programs/Makefile.programs)
59 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.Makefile)
60 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.report)
61 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.report)
62 AC_CONFIG_MAKEFILE(test/Programs/TEST.aa.report)
63 AC_CONFIG_MAKEFILE(test/Programs/TEST.example.Makefile)
64 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.Makefile)
65 AC_CONFIG_MAKEFILE(test/Programs/TEST.buildrepo.Makefile)
66 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.Makefile)
67 AC_CONFIG_MAKEFILE(test/Programs/TEST.nightly.report)
68 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.Makefile)
69 AC_CONFIG_MAKEFILE(test/Programs/TEST.jit.report)
70 AC_CONFIG_MAKEFILE(test/Programs/TEST.typesafe.Makefile)
71 AC_CONFIG_MAKEFILE(test/Programs/TEST.dsgraph.gnuplot)
72 AC_CONFIG_MAKEFILE(test/Programs/TEST.micro.Makefile)
73 AC_CONFIG_MAKEFILE(test/Programs/External/Makefile)
74 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile)
75 AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile.spec)
76 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile)
77 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile.multisrc)
78 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/analyzer/test.in)
79 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/Makefile)
80 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/distray/test.in)
81 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/Makefile)
82 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/fourinarow/test.in)
83 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile)
84 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in)
85 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/Makefile)
86 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/neural/test.in)
87 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/Makefile)
88 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pcompress2/test.in)
89 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/Makefile)
90 AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/pifft/test.in)
91 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile)
92 AC_CONFIG_MAKEFILE(test/Programs/SingleSource/Makefile.singlesrc)
93 AC_CONFIG_MAKEFILE(tools/Makefile)
94 AC_CONFIG_MAKEFILE(utils/Makefile)
95 AC_CONFIG_MAKEFILE(projects/Makefile)
96
97 dnl **************************************************************************
98 dnl * Determine which system we are building on
99 dnl **************************************************************************
100
101 dnl Check the install program (needs to be done before canonical stuff)
102 AC_PROG_INSTALL
103
104 dnl Check which host for which we're compiling.  This will tell us which LLVM
105 dnl compiler will be used for compiling SSA into object code.
106 AC_CANONICAL_TARGET
107
108 dnl Set the "OS" Makefile variable based on the system we are building on.
109 dnl We will use the build machine information to set some variables.
110 case $build in
111         *-*-linux*)
112              AC_SUBST(OS,[Linux])
113                          if test -d /home/vadve/lattner/local/x86/llvm-gcc
114                          then
115                            AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
116                          fi
117                  ;;
118
119         *-*-solaris*)
120              AC_SUBST(OS,[SunOS])
121                          if test -d /home/vadve/lattner/local/sparc/llvm-gcc
122                          then
123                    AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
124                          fi
125                  ;;
126
127         *-*-darwin*)
128              AC_SUBST(OS,[Darwin])
129                  ;;
130
131         *)       AC_SUBST(OS,[Unknown])
132                  ;;
133 esac
134
135 dnl If we are targetting a Sparc machine running Solaris, pretend that it is
136 dnl V9, since that is all that we support at the moment, and autoconf will only
137 dnl tell us we're a sparc.
138 case $target in
139         sparc*-*-solaris*)  AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
140                             ;;
141 esac
142
143 dnl Determine what our target architecture is and configure accordingly.
144 dnl This will allow Makefiles to make a distinction between the hardware and
145 dnl the OS.
146 case $target in
147         i*86-*)           AC_SUBST(ARCH,[x86])
148                           ;;
149         sparc*-*)         AC_SUBST(ARCH,[Sparc])
150                           ;;
151         powerpc*-*)       AC_SUBST(ARCH,[PowerPC])
152                           ;;
153         *)                AC_SUBST(ARCH,[Unknown])
154                           ;;
155 esac
156
157 dnl **************************************************************************
158 dnl * Check for programs.
159 dnl **************************************************************************
160
161 dnl Check for compilation tools
162 AC_PROG_CXX
163 AC_PROG_CC(gcc)
164 AC_PROG_CPP
165
166 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
167 if test "$GCC" != "yes"
168 then
169         AC_MSG_ERROR([gcc required but not found])
170 fi
171
172 if test "$GXX" != "yes"
173 then
174         AC_MSG_ERROR([g++ required but not found])
175 fi
176
177 dnl Verify that GCC is version 3.0 or higher
178 gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
179 if test "$gccmajor" -lt "3"
180 then
181         AC_MSG_ERROR([gcc 3.x required])
182 fi
183
184 dnl Check for GNU Make.  We use its extensions to, so don't build without it
185 CHECK_GNU_MAKE
186 if test -z "$_cv_gnu_make_command"
187 then
188         AC_MSG_ERROR([GNU Make required but not found])
189 fi
190
191 dnl Check for compiler-compiler tools (reminds me of Little Caesar's Pizza)
192 AC_PROG_FLEX
193 AC_PROG_BISON
194
195 dnl Check for libtool
196 AC_PROG_LIBTOOL
197
198 dnl Check for our special programs
199 AC_PATH_PROG(RPWD,[pwd],[false])
200 if test ${RPWD} = "false"
201 then
202         AC_MSG_ERROR([pwd required but not found])
203 fi
204
205 AC_PATH_PROG(AR,[ar],[false])
206 if test ${AR} = "false"
207 then
208         AC_MSG_ERROR([ar required but not found])
209 fi
210
211 AC_PATH_PROG(SED,[sed],[false])
212 if test ${SED} = "false"
213 then
214         AC_MSG_ERROR([sed required but not found])
215 fi
216
217 AC_PATH_PROG(RM,[rm],[false])
218 if test ${RM} = "false"
219 then
220         AC_MSG_ERROR([rm required but not found])
221 fi
222
223 AC_PATH_PROG(ECHO,[echo],[false])
224 if test ${ECHO} = "false"
225 then
226         AC_MSG_ERROR([echo required but not found])
227 fi
228
229 AC_PATH_PROG(MKDIR,[mkdir],[false])
230 if test ${MKDIR} = "false"
231 then
232         AC_MSG_ERROR([mkdir required but not found])
233 fi
234
235 AC_PATH_PROG(DATE,[date],[false])
236 if test ${DATE} = "false"
237 then
238         AC_MSG_ERROR([date required but not found])
239 fi
240
241 AC_PATH_PROG(MV,[mv],[false])
242 if test ${MV} = "false"
243 then
244         AC_MSG_ERROR([mv required but not found])
245 fi
246
247 AC_PATH_PROG(DOT,[dot],[false])
248
249 AC_PATH_PROG(ETAGS,[etags],[false])
250
251 AC_PATH_PROG(PYTHON,[python],[false])
252 if test ${PYTHON} = "false"
253 then
254         AC_MSG_WARN([python required but not found])
255 fi
256
257 AC_PATH_PROG(QMTEST,[qmtest],[false])
258 if test ${QMTEST} = "false"
259 then
260         AC_MSG_WARN([qmtest required but not found])
261 fi
262
263 dnl Verify that the version of python available is high enough for qmtest
264 pyversion=`$PYTHON -V 2>&1 | cut -d\  -f2`
265 pymajor=`echo $pyversion | cut -d. -f1`
266 pyminor=`echo $pyversion | cut -d. -f2`
267
268 if test "$pymajor" -ge "2"
269 then
270         if test "$pymajor" -eq "2"
271         then
272                 if test "$pyminor" -lt "2"
273                 then
274                         AC_MSG_WARN([Python 2.2 or greater required for qmtest])
275                 fi
276         fi
277 else
278         AC_MSG_WARN([Python 2.2 or greater required for qmtest])
279 fi
280
281 dnl Verify that the source directory is valid
282 AC_CONFIG_SRCDIR(["Makefile.config.in"])
283
284 dnl **************************************************************************
285 dnl * Check for libraries.
286 dnl **************************************************************************
287
288 dnl libelf is for sparc only; we can ignore it if we don't have it
289 AC_CHECK_LIB(elf, elf_begin)
290
291 dnl dlopen() is required for plugin support.
292 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]))
293
294 dnl mallinfo is optional; the code can compile (minus features) without it
295 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.]))
296
297 dnl
298 dnl The math libraries are used by the test code, but not by the actual LLVM
299 dnl code.
300 dnl
301 dnl AC_CHECK_LIB(m, cos)
302
303 dnl **************************************************************************
304 dnl * Checks for header files.
305 dnl *   Chances are, if the standard C or POSIX type header files are missing,
306 dnl *   then LLVM just isn't going to compile.  However, it is possible that
307 dnl *   the necessary functions/macros will be included from other
308 dnl *   (non-standard and non-obvious) header files.
309 dnl *
310 dnl *   So, we'll be gracious, give it a chance, and try to go on without
311 dnl *   them.
312 dnl **************************************************************************
313 AC_HEADER_STDC
314 AC_HEADER_SYS_WAIT
315
316 dnl Check for ANSI C/POSIX header files
317 AC_CHECK_HEADERS(assert.h fcntl.h limits.h sys/time.h unistd.h errno.h signal.h math.h)
318
319 dnl Check for system specific header files
320 AC_CHECK_HEADERS(malloc.h sys/mman.h sys/resource.h)
321
322 dnl Check for header files associated with dlopen and friends
323 AC_CHECK_HEADERS(dlfcn.h link.h)
324
325 dnl **************************************************************************
326 dnl * Checks for typedefs, structures, and compiler characteristics.
327 dnl **************************************************************************
328
329 dnl Check for const and inline keywords
330 AC_C_CONST
331 AC_C_INLINE
332
333 dnl Check for machine endian-ness
334 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]))
335
336 dnl Check for types
337 AC_TYPE_PID_T
338 AC_TYPE_SIZE_T
339 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
340 AC_CHECK_TYPES([uint64_t],,AC_MSG_ERROR([Type uint64_t required but not found]))
341 AC_HEADER_TIME
342 AC_STRUCT_TM
343
344 dnl Check for various C features
345 AC_C_PRINTF_A
346
347 dnl Check for C++ extensions
348 AC_CXX_HAVE_HASH_MAP
349 AC_CXX_HAVE_HASH_SET
350 AC_CXX_HAVE_EXT_SLIST
351 AC_CXX_HAVE_STD_ITERATOR
352 AC_CXX_HAVE_BI_ITERATOR
353 AC_CXX_HAVE_FWD_ITERATOR
354
355 dnl **************************************************************************
356 dnl * Checks for library functions.
357 dnl **************************************************************************
358 AC_FUNC_ALLOCA
359 AC_PROG_GCC_TRADITIONAL
360 AC_FUNC_MEMCMP
361 AC_FUNC_MMAP
362 AC_FUNC_MMAP_FILE
363 if test ${ac_cv_func_mmap_file} = "no"
364 then
365         AC_MSG_ERROR([mmap() of files required but not found])
366 fi
367 AC_HEADER_MMAP_ANONYMOUS
368 AC_TYPE_SIGNAL
369 AC_CHECK_FUNCS(getcwd gettimeofday strcspn strdup strerror strspn strstr strtod strtol strtoq strtoll)
370
371 dnl
372 dnl Need to check mmap for MAP_PRIVATE, MAP_ANONYMOUS, MAP_ANON, MAP_FIXED
373 dnl MAP_FIXED is only needed for Sparc
374 dnl MAP_ANON is used for Sparc and BSD
375 dnl Everyone should have MAP_PRIVATE
376 dnl
377
378 dnl Check for certain functions (even if we've already found them) so that we
379 dnl can quit with an error if they are unavailable.
380 dnl
381 dnl As the code is made more portable (i.e. less reliant on these functions,
382 dnl these checks should go away.
383 AC_CHECK_FUNC(mmap,,AC_MSG_ERROR([Function mmap() required but not found]))
384 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
385
386 dnl Determine if the linker supports the -R option.
387 AC_LINK_USE_R()
388
389 dnl **************************************************************************
390 dnl * Enable various compile-time options
391 dnl **************************************************************************
392
393 dnl Purify Option
394 AC_ARG_ENABLE(purify,AC_HELP_STRING([--enable-purify],[Compile with purify (default is NO)]),,enableval="no")
395 if test ${enableval} = "no"
396 then
397         AC_SUBST(ENABLE_PURIFY,[[]])
398 else
399         AC_SUBST(ENABLE_PURIFY,[[ENABLE_PURIFY=1]])
400 fi
401
402 dnl Optimized Option
403 AC_ARG_ENABLE(optimized,AC_HELP_STRING([--enable-optimized],[Compile with optimizations enabled (default is NO)]),,enableval=no)
404 if test ${enableval} = "no"
405 then
406         AC_SUBST(ENABLE_OPTIMIZED,[[]])
407 else
408         AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]])
409 fi
410
411 dnl Spec Benchmarks
412 AC_ARG_ENABLE(spec2000,AC_HELP_STRING([--enable-spec],[Compile SPEC 2000 benchmarks (default is NO)]),,enableval=no)
413 if test ${enableval} = "no"
414 then
415         if test -d /home/vadve/shared/benchmarks/speccpu2000/benchspec
416         then
417                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
418                 AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
419         else
420                 AC_SUBST(USE_SPEC,[[]])
421                 AC_SUBST(SPEC_ROOT,[])
422         fi
423 else
424         if test ${enableval} = ""
425         then
426                 AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec])
427         else
428                 AC_SUBST(SPEC_ROOT,[${enableval}])
429         fi
430         AC_SUBST(USE_SPEC,[[USE_SPEC=1]])
431 fi
432
433 dnl Precompiled Bytecode Option
434 AC_ARG_ENABLE(precompiled_bytecode,AC_HELP_STRING([--enable-precompiled_bytecode],[Use pre-compiled bytecode (default is NO)]),,enableval=no)
435 if test ${enableval} = "no"
436 then
437         AC_SUBST(UPB,[[]])
438 else
439         AC_SUBST(UPB,[[USE_PRECOMPILED_BYTECODE=1]])
440 fi
441
442
443 dnl LLC Diff Option
444 AC_ARG_ENABLE(llc_diffs,AC_HELP_STRING([--enable-llc_diffs],[Enable LLC Diffs when testing (default is YES)]),,enableval=yes)
445 if test ${enableval} = "no"
446 then
447         AC_SUBST(DISABLE_LLC_DIFFS,[DISABLE_LLC_DIFFS:=1])
448 else
449         AC_SUBST(DISABLE_LLC_DIFFS,[[]])
450 fi
451
452 dnl JIT Option
453 AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is YES)]),,enableval=default)
454
455 if test ${enableval} = "no"
456 then
457         AC_SUBST(JIT,[[]])
458 else
459         case $target in
460                 *i*86*)
461                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
462                         ;;
463                 *sparc*)
464                         AC_SUBST(JIT,[[TARGET_HAS_JIT=1]])
465                         ;;
466                 *)
467                         AC_SUBST(JIT,[[]])
468                         ;;
469         esac
470 fi
471
472 dnl **************************************************************************
473 dnl * Set the location of various third-party software packages
474 dnl **************************************************************************
475
476 dnl Location of the LLVM C front end
477 AC_ARG_WITH(llvmgccdir,AC_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),AC_SUBST(LLVMGCCDIR,[$withval]))
478
479 AC_MSG_CHECKING([for llvm-gcc])
480 LLVM_GCC_CHECK=no
481 if test -d "$LLVMGCCDIR"
482 then
483         if test -x "$LLVMGCCDIR/bin/gcc"
484         then
485                 LLVM_GCC_CHECK="$LLVMGCCDIR/bin/gcc"
486         fi
487 fi
488 llvmgccwarn=no
489 AC_MSG_RESULT($LLVM_GCC_CHECK)
490 if test "$LLVM_GCC_CHECK" = "no"
491 then
492     llvmgccwarn=yes
493 fi
494
495 AC_MSG_CHECKING([whether llvm-gcc is sane])
496 LLVM_GCC_SANE=no
497 if test -x "$LLVM_GCC_CHECK"
498 then
499         cp /dev/null conftest.c
500     "$LLVM_GCC_CHECK" -S -o - conftest.c | grep implementation > /dev/null 2>&1
501         if test $? -eq 0
502         then
503                 LLVM_GCC_SANE=yes
504         fi
505         rm conftest.c
506 fi
507 AC_MSG_RESULT($LLVM_GCC_SANE)
508 if test "$LLVM_GCC_SANE" = "no"
509 then
510         llvmgccwarn=yes
511 fi
512
513 dnl Location of the bytecode repository
514 AC_ARG_WITH(bcrepos,AC_HELP_STRING([--with-bcrepos],[Location of Bytecode Repository]),AC_SUBST(BCR,[$withval]),AC_SUBST(BCR,[/home/vadve/lattner/LLVMPrograms]))
515
516 dnl Location of PAPI
517 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]))
518
519 dnl Location of the purify program
520 AC_ARG_WITH(purify,AC_HELP_STRING([--with-purify],[Location of purify program]),AC_SUBST(PURIFY,[$withval]))
521
522 dnl **************************************************************************
523 dnl * Configure other software packages (via AC_CONFIG_SUBDIRS)
524 dnl **************************************************************************
525
526 dnl **************************************************************************
527 dnl * Create the output files
528 dnl **************************************************************************
529 AC_OUTPUT(Makefile.config)
530
531 if test $llvmgccwarn = yes
532 then
533         AC_MSG_WARN([***** llvm C/C++ front end was not found, or does not])
534         AC_MSG_WARN([***** appear to be working.])
535         AC_MSG_WARN([***** ])
536         AC_MSG_WARN([***** Please check configure's --with-llvmgccdir option.])
537         AC_MSG_WARN([***** Runtime libraries (in llvm/runtime) will not be built,])
538         AC_MSG_WARN([***** but you should be able to build the llvm tools.])
539 fi