Added firm_config.h creation
[libfirm] / configure.in
1 dnl
2 dnl Project:     libFIRM
3 dnl File name:   configure.in
4 dnl Purpose:
5 dnl Author:      Till Riedel (??)
6 dnl Modified by:
7 dnl Created:
8 dnl CVS-ID:      $Id$
9 dnl Copyright:   (c) 2002-2003 Universität Karlsruhe
10 dnl Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11 dnl
12
13
14 AC_REVISION($Id$)
15
16
17
18 AC_INIT(libfirm,0.3.0)
19 AC_PREREQ(2.50)
20 dnl if other files should be generated just add them to ac_output_files
21 ac_output_file="Makefile MakeRules ir/Makefile ir/adt/Makefile ir/debug/Makefile \
22                 ir/tv/Makefile ir/common/Makefile ir/ident/Makefile ir/ir/Makefile \
23                 ir/ana/Makefile ir/tr/Makefile ir/ana2/Makefile ir/stat/Makefile \
24                 ir/opt/Makefile ir/external/Makefile \
25                 testprograms/Makefile firmjni/Makefile firmjni/testprograms/Makefile \
26                 libfirm.doxygen"
27
28 dnl generate the config header file
29 AC_CONFIG_HEADER(config.h)
30
31 dnl keep track of the environment set by the user
32 libfirm_conf_env="${CC+CC='$CC'} ${CFLAGS+CFLAGS='$CFLAGS'} ${CPP+CPP='$CPP'} ${CPPFLAGS+CPPFLAGS='$CPPFLAGS'} ${LDFLAGS+LDFLAGS='$LDFLAGS'} ${LIBS+LIBS='$LIBS'}"
33 AC_SUBST(libfirm_conf_env)
34
35 dnl check for additional include dirs
36 AC_ARG_WITH(includedir, [  --with-includedir=add colon seperated list of directories to include search path],
37     CPPFLAGS=$CPPFLAGS" -I"`echo $withval|sed 's;\:; -I;g'`, T_FLAG="")
38
39 dnl check for additional library dirs
40 AC_ARG_WITH(libdir, [  --with-libdir=add colon seperated list of directories to linker search path],
41     LDFLAGS=$LDFLAGS" -L"`echo $withval|sed 's;\:; -L;g'`, T_FLAG="")
42
43 dnl Package options
44 dnl ===============
45
46 dnl set debugging
47 dnl -------------
48 AC_ARG_ENABLE(debug,
49 [  --enable-debug          enable assertions and additional debugging routines],
50 [if test "$enableval" = yes; then
51   AC_DEFINE(DEBUG_libfirm)
52 else
53   AC_DEFINE(NDEBUG)
54 fi])
55 AC_SUBST(enable_debug_libfirm)
56
57 dnl disable inlining
58 dnl ----------------
59 AC_ARG_ENABLE(inlining,
60 [  --disable-inlining      disable inline C-extension],
61 [if test "$enableval" = yes; then
62   AC_DEFINE(USE_INLINING)
63 fi],
64 AC_DEFINE(USE_INLINING)
65 )
66
67 dnl set profiling
68 dnl -------------
69 AC_ARG_ENABLE(profile,
70 [  --enable-profile        enable profiling],
71 [if test "$enableval"=yes; then
72   enable_profile_libfirm=yes
73 fi],
74 [enable_profile_libfirm=no])
75 AC_SUBST(enable_profile_libfirm)
76
77 dnl set auto documentation
78 dnl ----------------------
79 AC_ARG_ENABLE(autodoc,
80 [  --enable-autodoc        enable auto documentation],
81 [if test "$enableval"=yes; then
82   enable_auto_documentation=yes
83 fi],
84 [enable_auto_documentation=no])
85 AC_SUBST(enable_auto_documentation)
86
87
88 dnl set firm jni
89 dnl ------------
90 AC_ARG_ENABLE(firmjni,
91 [  --enable-firmjni        check for tools necesarry to construct a java native interface for Firm],
92 [if test "$enableval"=yes; then
93   enable_firm_jni=yes
94 fi],
95 [enable_firm_jni=no])
96 AC_SUBST(enable_firm_jni)
97
98 dnl set heap analyses support
99 dnl -------------------------
100 AC_ARG_ENABLE(heapanalysis, [  --enable-heapanalysis       Compile with heap analysis.],
101         [enable_heapanalysis=$enableval], [enable_heapanalysis="no"])
102 if test "$enable_heapanalysis" = "no"; then
103   AC_MSG_RESULT([heapanalysis disabled])
104 else
105   AC_DEFINE(DO_HEAPANALYSIS)
106   AC_MSG_RESULT([heapanalysis enabled])
107 fi
108 AC_SUBST(enable_heapanalysis)
109
110 dnl disable linking of libiberty parts (xmalloc, xprintf, obstack, ...)
111 dnl ----------------------
112 AC_ARG_ENABLE(libiberty,
113 [  --disable-libiberty     disable own libiberty parts],
114 [if test "$enableval"=yes; then
115   disable_libiberty_=yes
116 fi],
117 [disable_libiberty=no])
118 AC_SUBST(disable_libiberty)
119
120 dnl enable Firm statistics
121 dnl -------------
122 AC_ARG_ENABLE(statistics,
123 [  --enable-statistics     enable Firm statistics],
124 [if test "$enableval"=yes; then
125   AC_DEFINE(FIRM_STATISTICS)
126 fi])
127 AC_SUBST(enable_statistics)
128
129 dnl Checks for programs.
130 dnl ====================
131
132 dnl check for a C compiler
133 dnl ----------------------
134 AC_PROG_CC
135
136 dnl check for prelinkable linker
137 dnl ----------------------------
138 LIBFIRM_PROG_LD_R
139 if test "$libfirm_cv_prog_ld_r" != "yes"; then
140   AC_MSG_ERROR(need a prelinkcapable linker)
141 fi
142
143 dnl check for ar
144 dnl ------------
145 AC_CHECK_PROG(AR, ar, "ar", "")
146 if test "$AR" != "ar"; then
147   AC_MSG_ERROR(need ar for creating archives)
148 fi
149
150 dnl check for tar
151 dnl -------------
152 AC_CHECK_PROG(TAR, tar, "tar", "")
153 if test "$TAR" != "tar"; then
154   AC_MSG_ERROR(need tar for creating archives in distribution)
155 fi
156
157 dnl check whether ar can handle option -s
158 dnl if not then ranlib is needed
159 dnl for simpliticity we use ranlib every time
160
161 AC_PROG_RANLIB
162
163 AC_PROG_INSTALL
164
165 touch tmp-install.a tmp-install.b
166 if eval "$INSTALL -C tmp-install.a tmp-install.b" ; then
167     INSTALL="$INSTALL -C"
168 fi
169 rm tmp-install.a tmp-install.b
170
171
172 AC_PROG_LN_S
173
174 dnl check for doxygen if enabled
175 dnl ----------------------------
176 if test "$enable_auto_documentation" = yes; then
177   AC_CHECK_PROG(DOXYGEN, doxygen, "doxygen", "")
178   if test "$DOXYGEN" != "doxygen"; then
179     AC_MSG_ERROR(need doxygen for auto documentation)
180   fi
181   AC_CHECK_PROG(DOT, dot, "dot", "")
182   if test "$DOT" != "dot"; then
183     AC_MSG_ERROR(need dot for doxygen documentation (for class graphs) (IPD: module add Graphviz))
184   fi
185 fi
186
187 dnl check for availability of a jdk
188 dnl -------------------------------
189 if test "$enable_firm_jni" = yes; then
190   AC_CHECK_PROG(JAVAC, javac, "javac", "")
191   if test "$JAVAC" != "javac"; then
192     AC_MSG_ERROR(need java compiler javac to generate jni (IPD: module add jdk-1.3.1-sun))
193   fi
194   AC_CHECK_PROG(JAVAH, javah, "javah", "")
195   if test "$JAVAH" != "javah"; then
196     AC_MSG_ERROR(need javah to generate jni headers (IPD: module add jdk-1.3.1-sun))
197   fi
198 fi
199
200
201 dnl Checks for header files.
202 dnl ========================
203
204 AC_HEADER_STDC
205
206 dnl check for the math header file
207
208 AC_CHECK_HEADERS(math.h, ac_math_headers="yes", ac_math_headers="no")
209 if test "$ac_math_headers" != yes; then
210   dnl math header not found.
211   AC_MSG_ERROR("math header file not found")
212 fi
213
214
215 #dnl check for the gnu multiprecission (gmp) header file
216
217 #AC_CHECK_HEADERS(gmp.h, ac_gmp_headers="yes", ac_gmp_headers="no")
218 #if test "$ac_gmp_headers" != yes; then
219 #  dnl gmp header not found.
220 #  AC_MSG_ERROR("GNU multiprecission gmp header file not found")
221 #fi
222
223
224 dnl check for the obstack header file
225 dnl does not work with:
226 dnl  - cygwin
227 dnl  - MacOSX
228 #AC_FUNC_OBSTACK
229
230 AC_CHECK_HEADERS(obstack.h, ac_obstack_headers="yes", ac_obstack_headers="no")
231 if test "$ac_obstack_headers" != yes; then
232   dnl obstack header not found.
233   AC_MSG_ERROR("obstack.h not found")
234 fi
235
236
237 AC_CHECK_HEADERS(alloca.h, ac_alloca_headers="yes", ac_alloca_headers="no")
238 if test "$ac_alloca_headers" = "yes"; then
239     AC_DEFINE(HAVE_ALLOCA_H)
240 else
241   if test "$ac_cv_header_stdc" = "no"; then
242     AC_MSG_ERROR("alloca.h and stdlib.h not found")
243   fi
244 fi
245
246
247 dnl check for jni header files
248
249 if test "$enable_firm_jni" = yes; then
250   AC_CHECK_HEADERS(jni.h, ac_jni_headers="yes", ac_jni_headers="no")
251   if test "$ac_jni_headers" != yes; then
252     AC_MSG_ERROR(jni header file not found. (IPD: add --with-includedir=/usr/public2/java/jdk1.3.1-sun/include/:/usr/public2/java/jdk1.3.1-sun/include/linux/ to configure flags))
253   fi
254 fi
255
256
257 dnl Checks for libraries.
258 dnl =====================
259
260 #dnl check for the gnu multiprecission (gmp) library
261
262 #AC_CHECK_LIB(gmp, main, ac_gmp_library="yes", ac_gmp_library="no")
263 #if test "$ac_gmp_library" != yes; then
264 #  dnl gmp library not found.
265 #  AC_MSG_ERROR("GNU multiprecission gmp library not found")
266 #fi
267
268
269 AC_CHECK_LIB(m, main, ac_m_library="yes", ac_m_library="no")
270 if test "$ac_m_library" != yes; then
271   dnl std math library not found.
272   AC_MSG_ERROR("standard math library not found")
273 fi
274
275
276 dnl Checks for typedefs, structures, and compiler characteristics.
277 dnl ==============================================================
278 AC_C_CONST
279 AC_C_VOLATILE
280 AC_C_INLINE
281 AC_C_BIGENDIAN(,,,)
282 AC_C_LONG_DOUBLE
283
284 dnl Checks for library functions.
285 dnl =============================
286
287 dnl check for strerror
288
289 AC_CHECK_FUNC(strerror,,
290   AC_MSG_ERROR("need strerror function")
291 )
292
293
294 dnl Error messaging
295 dnl ===============
296
297
298 AC_OUTPUT($ac_output_file,[ touch stamp-h ])
299
300 dnl snip the lower prt of config.h and put it to ir/common/firm_config.h
301 gawk -f filter.awk < config.h | sed -f filter.sed > ir/common/firm_config.h