Merged in autoconf branch. This provides configuration via the autoconf
[oota-llvm.git] / 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 * Configure a header file
21 AC_CONFIG_HEADERS(include/Config/config.h)
22
23 dnl **************************************************************************
24 dnl * Determine which system we are building on
25 dnl **************************************************************************
26
27 dnl Check the install program (needs to be done before canonical stuff)
28 AC_PROG_INSTALL
29
30 dnl Check which host for which we're compiling.  This will tell us which LLVM
31 dnl compiler will be used for compiling SSA into object code.
32 AC_CANONICAL_TARGET
33
34 dnl
35 dnl Now, for some of our own magic:
36 dnl We will use the build machine information to set some variables.
37 dnl
38 case $build in
39         *i*86*)  AC_SUBST(OS,[Linux])
40                  AC_SUBST(DISABLE_LLC_DIFFS,[[DISABLE_LLC_DIFFS:=1]])
41                  AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/x86/llvm-gcc/])
42                  ;;
43
44         *sparc*) AC_SUBST(OS,[SunOS])
45                  AC_SUBST(LLVMGCCDIR,[/home/vadve/lattner/local/sparc/llvm-gcc/])
46                  ;;
47
48         *)       AC_SUBST(OS,[Unknown])
49                  ;;
50 esac
51
52 dnl
53 dnl If we are on a Solaris machine, pretend that it is V9, since that is all
54 dnl that we support at the moment, and autoconf will only tell us we're a
55 dnl sparc.
56 dnl
57 case $target in
58         *sparc*solaris*)  AC_SUBST(target,[[sparcv9-sun-solaris2.8]])
59                           ;;
60 esac
61
62 dnl **************************************************************************
63 dnl * Check for programs.
64 dnl **************************************************************************
65
66 dnl Check for compilation tools
67 AC_PROG_CXX
68 AC_PROG_CC(gcc)
69 AC_PROG_CPP
70
71 dnl Ensure that compilation tools are GCC; we use GCC specific extensions
72 if test "$GCC" != "yes"
73 then
74         AC_MSG_ERROR([gcc required but not found])
75 fi
76
77 if test "$GXX" != "yes"
78 then
79         AC_MSG_ERROR([g++ required but not found])
80 fi
81
82 dnl Check for GNU Make.  We use its extensions to, so don't build without it
83 CHECK_GNU_MAKE
84 if test -z "$_cv_gnu_make_command"
85 then
86         AC_MSG_ERROR([GNU Make required but not found])
87 fi
88
89 dnl Check for compiler-compiler tools (reminds me of Little Caesar's Pizza)
90 AC_PROG_FLEX
91 AC_PROG_BISON
92
93 dnl Check for libtool
94 AC_PROG_LIBTOOL
95
96 dnl Check for our special programs
97 AC_PATH_PROG(AR,[ar])
98 AC_PATH_PROG(SED,[sed])
99 AC_PATH_PROG(RM,[rm])
100 AC_PATH_PROG(ECHO,[echo])
101 AC_PATH_PROG(MKDIR,[mkdir])
102 AC_PATH_PROG(DATE,[date])
103 AC_PATH_PROG(MV,[mv])
104 AC_PATH_PROG(DOT,[dot])
105 AC_PATH_PROG(ETAGS,[etags])
106 AC_PATH_PROG(PURIFY,[purify])
107
108 dnl Verify that the source directory is valid
109 AC_CONFIG_SRCDIR(["Makefile.config.in"])
110
111 dnl **************************************************************************
112 dnl * Check for libraries.
113 dnl **************************************************************************
114
115 dnl libelf is for sparc only; we can ignore it if we don't have it
116 AC_CHECK_LIB(elf, elf_begin)
117
118 dnl dlopen() is required.  If we don't find it, quit.
119 AC_SEARCH_LIBS(dlopen,dl,,AC_MSG_ERROR([dlopen() required but not found]))
120
121 dnl mallinfo is optional; the code can compile (minus features) without it
122 AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1]))
123
124 dnl
125 dnl The math libraries are used by the test code, but not by the actual LLVM
126 dnl code.
127 dnl
128 dnl AC_CHECK_LIB(m, cos)
129
130 dnl **************************************************************************
131 dnl * Checks for header files.
132 dnl *   Chances are, if the standard C or POSIX type header files are missing,
133 dnl *   then LLVM just isn't going to compile.  However, it is possible that
134 dnl *   the necessary functions/macros will be included from other
135 dnl *   (non-standard and non-obvious) header files.
136 dnl *
137 dnl *   So, we'll be gracious, give it a chance, and try to go on without
138 dnl *   them.
139 dnl **************************************************************************
140 AC_HEADER_STDC
141 AC_HEADER_SYS_WAIT
142
143 dnl Check for ANSI C/POSIX header files
144 AC_CHECK_HEADERS(assert.h fcntl.h limits.h sys/time.h unistd.h errno.h signal.h math.h)
145
146 dnl Check for system specific header files
147 AC_CHECK_HEADERS(malloc.h strings.h sys/mman.h sys/resource.h)
148
149 dnl Check for header files associated with dlopen and friends
150 AC_CHECK_HEADERS(dlfcn.h link.h)
151
152 dnl **************************************************************************
153 dnl * Checks for typedefs, structures, and compiler characteristics.
154 dnl **************************************************************************
155
156 dnl Check for const and inline keywords
157 AC_C_CONST
158 AC_C_INLINE
159
160 dnl Check for machine endian-ness
161 AC_C_BIGENDIAN(AC_DEFINE([ENDIAN_BIG]),AC_DEFINE(ENDIAN_LITTLE))
162
163 dnl Check for types
164 AC_TYPE_PID_T
165 AC_TYPE_SIZE_T
166 AC_CHECK_TYPES([int64_t],,AC_MSG_ERROR([Type int64_t required but not found]))
167 AC_CHECK_TYPES([uint64_t],,AC_MSG_ERROR([Type uint64_t required but not found]))
168 AC_HEADER_TIME
169 AC_STRUCT_TM
170
171 dnl Check for C++ extensions
172 AC_CXX_HAVE_EXT_HASH_MAP
173 AC_CXX_HAVE_EXT_HASH_SET
174 AC_CXX_HAVE_EXT_SLIST
175 AC_CXX_HAVE_STD_ITERATOR
176 AC_CXX_HAVE_BI_ITERATOR
177 AC_CXX_HAVE_FWD_ITERATOR
178
179 dnl **************************************************************************
180 dnl * Checks for library functions.
181 dnl **************************************************************************
182 AC_FUNC_ALLOCA
183 AC_PROG_GCC_TRADITIONAL
184 AC_FUNC_MEMCMP
185 AC_FUNC_MMAP
186 AC_FUNC_MMAP_FILE
187 if test ${ac_cv_func_mmap_file} = "no"
188 then
189         AC_MSG_ERROR([mmap() of files required but not found])
190 fi
191 AC_HEADER_MMAP_ANONYMOUS
192 AC_TYPE_SIGNAL
193 AC_CHECK_FUNCS(getcwd gettimeofday strcspn strdup strerror strspn strstr strtod strtol)
194
195 dnl
196 dnl Need to check mmap for MAP_PRIVATE, MAP_ANONYMOUS, MAP_ANON, MAP_FIXED
197 dnl MAP_FIXED is only needed for Sparc
198 dnl MAP_ANON is used for Sparc and BSD
199 dnl Everyone should have MAP_PRIVATE
200 dnl
201
202 dnl Check for certain functions (even if we've already found them) so that we
203 dnl can quit with an error if they are unavailable.
204 dnl
205 dnl As the code is made more portable (i.e. less reliant on these functions,
206 dnl these checks should go away.
207 AC_CHECK_FUNC(mmap,,AC_MSG_ERROR([Function mmap() required but not found]))
208 AC_CHECK_FUNC(mprotect,,AC_MSG_ERROR([Function mprotect() required but not found]))
209
210 dnl **************************************************************************
211 dnl * Enable various compile-time options
212 dnl **************************************************************************
213 AC_ARG_ENABLE(purify,AC_HELP_STRING([--enable-purify],[Compile with purify (default is NO)]), AC_SUBST(ENABLE_PURIFY,[[ENABLE_PURIFY=1]]), AC_SUBST(ENABLE_PURIFY,[[]]))
214 AC_ARG_ENABLE(verbose,AC_HELP_STRING([--enable-verbose],[Enable verbose compilation messages (default is NO)]), AC_SUBST(ENABLE_VERBOSE,[[VERBOSE=1]]), AC_SUBST(ENABLE_VERBOSE,[[]]))
215 AC_ARG_ENABLE(profiling,AC_HELP_STRING([--enable-profiling],[Compile with profiling information (default is NO)]), AC_SUBST(ENABLE_PROFILING,[[ENABLE_PROFILING=1]]), AC_SUBST(ENABLE_PROFILING,[[]]))
216 AC_ARG_ENABLE(optimized,AC_HELP_STRING([--enable-optimized],[Compile with optimizations enabled (default is NO)]), AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]]), AC_SUBST(ENABLE_OPTIMIZED,[[]]))
217 AC_ARG_ENABLE(spec,AC_HELP_STRING([--enable-spec],[Compile SPEC benchmarks (default is NO)]), AC_SUBST(USE_SPEC,[[USE_SPEC=1]]), AC_SUBST(USE_SPEC,[[]]))
218 AC_ARG_ENABLE(precompiled_bytecode,AC_HELP_STRING([--enable-precompiled_bytecode],[Use pre-compiled bytecode (default is NO)]), AC_SUBST(UPB,[[USE_PRECOMPILED_BYTECODE=1]]), AC_SUBST(UPB,[[]]))
219 case $build in
220         *i*86*)  AC_ARG_ENABLE(jit,AC_HELP_STRING([--enable-jit],[Enable Just In Time Compiling (default is NO)]), AC_SUBST(JIT,[[TARGET_HAS_JIT=1]]), AC_SUBST(JIT,[[]]))
221                  ;;
222         *)
223                  ;;
224 esac
225
226 dnl **************************************************************************
227 dnl * Set the location of various third-party software packages
228 dnl **************************************************************************
229 AC_ARG_WITH(spec,AC_HELP_STRING([--with-spec],[Location of SPEC benchmarks]),AC_SUBST(SPEC_ROOT,[$withval]),AC_SUBST(SPEC_ROOT,[/home/vadve/shared/benchmarks/speccpu2000/benchspec]))
230 AC_ARG_WITH(llvmgccdir,AC_HELP_STRING([--with-llvmgccdir],[Location of LLVM GCC front-end]),AC_SUBST(LLVMGCCDIR,[$withval]))
231 AC_ARG_WITH(bcrepos,AC_HELP_STRING([--with-bcrepos],[Location of Bytecode Repository]),AC_SUBST(BCR,[$withval]),AC_SUBST(BCR,[/home/vadve/lattner/LLVMPrograms]))
232 AC_ARG_WITH(papi,AC_HELP_STRING([--with-papi],[Location of PAPI]),AC_SUBST(PAPIDIR,[$withval]),AC_SUBST(PAPIDIR,[/home/vadve/shared/papi-2.3.4.1]))
233 AC_ARG_WITH(objroot,AC_HELP_STRING([--with-objroot],[Location where object files should be placed (default is .)]),AC_SUBST(OBJROOT,[$withval]),AC_SUBST(OBJROOT,[.]))
234 AC_ARG_WITH(purify,AC_HELP_STRING([--with-purify],[Location of purify program]),AC_SUBST(PURIFY,[$withval]))
235
236 AC_OUTPUT(Makefile.config)