add missing includes, makefile updates
[libfirm] / configure.ac
1 dnl
2 dnl Project:     libFIRM
3 dnl File name:   configure.in
4 dnl Purpose:
5 dnl Author:      Matthias Braun
6 dnl CVS-ID:      $Id$
7 dnl Copyright:   (c) 2002-2007 University of Karlsruhe
8 dnl Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
9 dnl
10 AC_PREREQ([2.54])
11 AC_REVISION([$Id$])
12 m4_define([firm_major_version], [1])
13 m4_define([firm_minor_version], [10])
14 m4_define([firm_micro_version], [0])
15 m4_define([firm_version],
16           [firm_major_version.firm_minor_version.firm_micro_version])
17 AC_INIT([libfirm], [firm_version], [firm@ipd.info.uni-karlsruhe.de])
18 AC_CONFIG_SRCDIR([ir/common/firm.c])
19 AM_INIT_AUTOMAKE([foreign dist-bzip2 1.9])
20
21 # see libtool manual on what version numbers mean!
22 LT_VERSION=0:0:0
23 AC_SUBST([LT_VERSION])
24
25 AC_DEFINE([libfirm_VERSION_MAJOR], [firm_major_version], [Firms major version number])
26 AC_DEFINE([libfirm_VERSION_MINOR], [firm_minor_version], [Firms minor version number])
27 AC_DEFINE([libfirm_VERSION_MICRO], [firm_micro_version], [Firms micro version number])
28
29 dnl generate the config header file
30 AC_CONFIG_HEADER([config.h])
31
32 dnl keep track of the environment set by the user
33 libfirm_conf_env="${CC+CC='$CC'} ${CFLAGS+CFLAGS='$CFLAGS'} ${CPP+CPP='$CPP'} ${CPPFLAGS+CPPFLAGS='$CPPFLAGS'} ${LDFLAGS+LDFLAGS='$LDFLAGS'} ${LIBS+LIBS='$LIBS'}"
34 AC_SUBST(libfirm_conf_env)
35
36 dnl Package options
37 dnl ===============
38
39 dnl check for additional include dirs
40 AC_ARG_WITH(includedir, [  --with-includedir=add   colon seperated list of directories to include search path],
41     CPPFLAGS=$CPPFLAGS" -I"`echo $withval|sed 's;\:; -I;g'`)
42
43 dnl check for additional library dirs
44 AC_ARG_WITH(libdir, [  --with-libdir=add       colon seperated list of directories to linker search path],
45     LDFLAGS=$LDFLAGS" -L"`echo $withval|sed 's;\:; -L;g'`)
46
47 dnl set debugging
48 dnl -------------
49 AC_ARG_ENABLE([debug],
50 [AS_HELP_STRING([--disable-debug], [disable verifiers and additional debugging routines])],
51 [enable_debug_libfirm="$enableval"], [enable_debug_libfirm="yes"])
52 if test "$enable_debug_libfirm" = yes; then
53         FIRMCONFIG_DEBUG_libfirm="#define DEBUG_libfirm"
54 fi
55 AC_SUBST([FIRMCONFIG_DEBUG_libfirm])
56 AC_SUBST([enable_debug_libfirm])
57
58 AC_ARG_ENABLE([assert],
59 [AS_HELP_STRING([--disable-assert], [disable assertions])],
60 [enable_assert="$enableval"], [enable_assert="yes"])
61 if test "$enable_assert" = no; then
62   AC_DEFINE([NDEBUG], [], [define to disable asserts])
63 fi
64 AC_SUBST([enable_assert])
65
66 dnl disable inlining
67 dnl ----------------
68 AC_ARG_ENABLE([inlining],
69 [AS_HELP_STRING([--disable-inlining], [disable inline C-extension])],
70 [enable_inlining="$enableval"], [enable_inlining="yes"])
71
72 if test "$enable_inlining" = yes; then
73   FIRMCONFIG_USE_INLINING="#define USE_INLINING"
74 fi
75 AC_SUBST([FIRMCONFIG_USE_INLINING])
76 AC_SUBST([enable_inlining])
77
78 dnl set profiling
79 dnl -------------
80 AC_ARG_ENABLE([profile],
81 [AS_HELP_STRING([--enable-profile], [enable profiling])],
82 [enable_profile_libfirm="$enableval"], [enable_profile_libfirm="no"])
83
84 AC_SUBST([enable_profile_libfirm])
85
86 dnl set auto documentation
87 dnl ----------------------
88 AC_ARG_ENABLE([autodoc],
89 [AS_HELP_STRING([--enable-autodoc], [enable auto documentation])],
90 [enable_auto_documentation="$enableval"], [enable_auto_documentation="no"])
91
92 AC_SUBST([enable_auto_documentation])
93
94 dnl set firm jni
95 dnl ------------
96 AC_ARG_ENABLE([firmjni],
97 [AS_HELP_STRING([--enable-firmjni], [check for tools necesarry to construct a java native interface for Firm])],
98 [enable_firm_jni="$enableval"], [enable_firm_jni="no"])
99
100 AC_SUBST(enable_firm_jni)
101
102 dnl set heap analyses support
103 dnl -------------------------
104 AC_ARG_ENABLE([heapanalysis],
105 [AS_HELP_STRING([--enable-heapanalysis], [Compile with heap analysis.])],
106 [enable_heapanalysis=$enableval], [enable_heapanalysis="no"])
107
108 if test "$enable_heapanalysis" = "yes"; then
109         FIRMCONFIG_DO_HEAPANALYSIS="#define DO_HEAPANALYSIS"
110 fi
111 AC_SUBST([FIRMCONFIG_DO_HEAPANALYSIS])
112 AC_SUBST([enable_heapanalysis])
113
114 dnl enable Firm hooks
115 dnl -------------
116 AC_ARG_ENABLE([hooks],
117 [AS_HELP_STRING([--disable-hooks], [disable Firm hooks])],
118 [enable_hooks="$enableval"], [enable_hooks="yes"])
119
120 if test "$enable_hooks" = yes; then
121         FIRMCONFIG_FIRM_ENABLE_HOOKS="#define FIRM_ENABLE_HOOKS"
122 fi
123 AC_SUBST([FIRMCONFIG_FIRM_ENABLE_HOOKS])
124
125 dnl enable Firm statistics
126 dnl -------------
127 AC_ARG_ENABLE([statistics],
128 [AS_HELP_STRING([--enable-statistics], [enable Firm statistics])],
129 [enable_statistics="$enableval"], [enable_statistics="no"])
130
131 if test "$enable_statistics" = yes; then
132         FIRMCONFIG_FIRM_STATISTICS="#define FIRMCONFIG_FIRM_STATISTICS"
133 fi
134 AC_SUBST([FIRMCONFIG_FIRM_STATISTICS])
135 AC_SUBST([enable_statistics])
136
137 dnl enable libcore support
138 dnl --------------------------------
139 AC_ARG_ENABLE([libcore],
140 [AS_HELP_STRING([--disable-libcore], [disable libcore support])],
141 [enable_libcore="$enableval"],[enable_libcore="yes"])
142
143 AC_SUBST([enable_libcore])
144
145 dnl enable ILP solver support
146 dnl --------------------------------
147 AC_ARG_ENABLE([ilp],
148 [AS_HELP_STRING([--enable-ilp], [enable ilp solver])],
149 [enable_ilp="$enableval"], [enable_ilp="no"])
150
151 if test "$enable_ilp" = yes; then
152   FIRMCONFIG_WITH_ILP="#define FIRMCONFIG_WITH_ILP"
153 fi
154 AC_SUBST([FIRMCONFIG_WITH_ILP])
155 AC_SUBST(enable_ilp)
156
157 dnl enable JVM calling from Firm
158 dnl --------------------------------
159 AC_ARG_ENABLE([jvm],
160 [AS_HELP_STRING([--enable-jvm], [enable to call the jvm])],
161 [enable_jvm="$enableval"], [enable_jvm="no"])
162
163 if test "$enable_jvm" = yes; then
164   FIRMCONFIG_WITH_JVM="#define FIRMCONFIG_WITH_JVM"
165 fi
166 AC_SUBST([FIRMCONFIG_WITH_JVM])
167 AC_SUBST(enable_jvm)
168
169 dnl enable wchar_t support for identifiers
170 dnl --------------------------------
171 AC_ARG_ENABLE([wchar_support],
172 [AS_HELP_STRING([--enable-wchar-support], [enable wchar_t support for identifiers (needed for java)])],
173 [enable_wchar_support="$enableval"], [enable_wchar_support="no"])
174
175 if test "$enable_wchar_support" = yes; then
176   FIRMCONFIG_FIRM_ENABLE_WCHAR="#define FIRM_ENABLE_WCHAR"
177 fi
178 AC_SUBST([FIRMCONFIG_FIRM_ENABLE_WCHAR])
179 AC_SUBST([enable_wchar_support])
180
181 dnl disable external effects in XML
182 dnl -------------------------------
183 dnl AC_ARG_ENABLE([external-effects],
184 dnl [AS_HELP_STRING([--enable-external-effects], [enable reading of descriptions of external effects in XML])],
185 dnl [enable_external_effects="$enableval"], [enable_external_effects="no"])
186
187 dnl AC_SUBST(enable_external_effects)
188
189 dnl disable backend
190 dnl ---------------
191 AC_ARG_ENABLE([backend],
192 [AS_HELP_STRING([--disable-backend], [disable backends])],
193 [enable_backend="$enableval"], [enable_backend="yes"])
194
195 AC_SUBST(enable_backend)
196
197 dnl Checks for programs.
198 dnl ====================
199
200 dnl check for a C compiler
201 dnl ----------------------
202 AC_PROG_CC
203 AC_PROG_LIBTOOL
204
205 AC_PATH_PROGS(PERL, perl perl5)
206
207 dnl check for awk
208 dnl -------------
209 AC_PROG_AWK
210
211 dnl check for doxygen if enabled
212 dnl ----------------------------
213 if test "$enable_auto_documentation" = yes; then
214   AC_CHECK_PROG(DOXYGEN, doxygen, "doxygen", "")
215   if test "$DOXYGEN" != "doxygen"; then
216     AC_MSG_ERROR(need doxygen for auto documentation)
217   fi
218   AC_CHECK_PROG(DOT, dot, "dot", "")
219   if test "$DOT" != "dot"; then
220     AC_MSG_ERROR(need dot for doxygen documentation (for class graphs) (IPD: module add Graphviz))
221   fi
222 fi
223
224 dnl check for availability of a jdk
225 dnl -------------------------------
226 if test "$enable_firm_jni" = yes; then
227   AC_CHECK_PROG(JAVAC, javac, "javac", "")
228   if test "$JAVAC" != "javac"; then
229     AC_MSG_ERROR(need java compiler javac to generate jni (IPD: module add jdk-1.3.1-sun))
230   fi
231   AC_CHECK_PROG(JAVAH, javah, "javah", "")
232   if test "$JAVAH" != "javah"; then
233     AC_MSG_ERROR(need javah to generate jni headers (IPD: module add jdk-1.3.1-sun))
234   fi
235 fi
236
237 dnl check for availability of pkg-config
238 PKG_PROG_PKG_CONFIG
239
240
241 dnl Checks for header files.
242 dnl ========================
243
244 AC_HEADER_STDC
245
246 dnl check for the math header file
247
248 AC_CHECK_HEADERS(math.h, ac_math_headers="yes", ac_math_headers="no")
249 if test "$ac_math_headers" != yes; then
250   dnl math header not found.
251   AC_MSG_ERROR("math header file not found")
252 fi
253
254
255 dnl check for the obstack header file
256 dnl does not work with:
257 dnl  - cygwin
258 dnl  - MacOSX
259 #AC_FUNC_OBSTACK
260
261 AC_CHECK_HEADERS(obstack.h, ac_obstack_headers="yes", ac_obstack_headers="no")
262 if test "$ac_obstack_headers" != yes; then
263   dnl obstack header not found.
264   AC_MSG_ERROR("obstack.h not found")
265 fi
266
267
268 AC_CHECK_HEADERS(alloca.h, ac_alloca_headers="yes", ac_alloca_headers="no")
269 if test "$ac_alloca_headers" = "yes"; then
270     AC_DEFINE(HAVE_ALLOCA_H)
271 else
272   if test "$ac_cv_header_stdc" = "no"; then
273     AC_MSG_ERROR("alloca.h and stdlib.h not found")
274   fi
275 fi
276
277
278 dnl check for jni header files
279
280 if test "$enable_firm_jni" = yes; then
281   AC_CHECK_HEADERS(jni.h, ac_jni_headers="yes", ac_jni_headers="no")
282   if test "$ac_jni_headers" != yes; then
283     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))
284   fi
285 fi
286
287
288 if test "$enable_external_effects" == "yes"; then
289         dnl check for libxml2 library installation dir
290         AC_CHECK_PROG(XML2CONFIG, xml2-config, "xml2-config", "echo")
291         if test "$XML2CONFIG" != "xml2-config"; then
292           AC_MSG_ERROR(xml2-config for detecting libxml2 not found)
293         fi
294         AC_SUBST(XML2CONFIG)
295         LDFLAGS=$LDFLAGS" -L/usr/lib `$XML2CONFIG --libs`";
296         CPPFLAGS=$CPPFLAGS" `$XML2CONFIG --cflags`";
297
298         AC_CHECK_HEADERS(libxml/parser.h, ac_xml_headers="yes", ac_xml_headers="no")
299         if test "$ac_xml_headers" != yes; then
300                 AC_MSG_ERROR(xml header files not found. (IPD: add --with-includedir=/usr/public/libxml2/include/libxml2/ to configure flags))
301         fi
302 fi
303
304 dnl Checks for libraries.
305 dnl =====================
306
307 AC_CHECK_LIB(m, main, ac_m_library="yes", ac_m_library="no")
308 if test "$ac_m_library" != yes; then
309   dnl std math library not found.
310   AC_MSG_ERROR("standard math library not found")
311 fi
312
313
314 if test "$enable_external_effects" == "yes"; then
315   AC_CHECK_LIB(xml2, xmlParseFile, ac_xml_library="yes", ac_xml_library="no")
316   if test "$ac_m_library" != yes; then
317     AC_MSG_ERROR("xml2 library not found (IPD: add --with-libdir=/usr/public/libxml2/lib/ to configure flags)")
318   else
319     LIBS=$LIBS" -lxml2"
320   fi
321 fi
322
323 if test "$enable_libcore" == "yes"; then
324         PKG_CHECK_MODULES([LIBCORE], [libcore])
325         FIRMCONFIG_WITH_LIBCORE="#define WITH_LIBCORE"
326 fi
327 AC_SUBST([FIRMCONFIG_WITH_LIBCORE])
328
329 dnl Checks for typedefs, structures, and compiler characteristics.
330 dnl ==============================================================
331 AC_C_CONST
332 AC_C_VOLATILE
333 AC_C_INLINE
334 AC_C_BIGENDIAN(,,,)
335 AC_C_LONG_DOUBLE
336
337 dnl Checks for library functions.
338 dnl =============================
339
340 dnl check for strerror
341
342 AC_CHECK_FUNC(strerror,,
343   AC_MSG_ERROR("need strerror function")
344 )
345
346 dnl we use the gnu extension obstack_printf
347 AC_DEFINE([_GNU_SOURCE], [], [we use gnu extensions])
348 AC_CHECK_FUNC(strerror,,
349   AC_MSG_ERROR("need obstack_printf function")
350 )
351
352 dnl Error messaging
353 dnl ===============
354
355
356 dnl Output results
357 AC_CONFIG_FILES([
358         firm_config.h
359         Makefile
360         ir/Makefile
361         include/libfirm/Makefile
362         libfirm.pc
363 ])
364
365 BACKENDS=""
366 if test "$enable_backend" == yes; then
367         BACKENDS="arm ia32 mips ppc32"
368 fi
369 AC_SUBST([BACKENDS])
370
371 #if test "$BACKENDS"; then
372 #       for backend in $BACKENDS; do
373 #               AC_CONFIG_FILES([ir/be/$backend/Makefile])
374 #       done
375 #fi
376
377 AC_OUTPUT
378
379 dnl output summary of firm configuration
380 echo ""
381 echo "firm configuration summary:"
382 echo "     backends              $BACKENDS"
383 echo "     profiling             $enable_profile_libfirm"
384 echo "     debug/verifiers       $enable_debug_libfirm"
385 echo "     assertions            $enable_assert"
386 echo "     hooks                 $enable_hooks"
387 echo "     statistics            $enable_statistics"
388 echo "     libcore               $enable_libcore"
389 echo "     ilp                   $enable_ilp"
390 echo "     jvm                   $enable_jvm"
391 echo "     wide char support     $enable_wchar_support"
392 dnl echo "     external effects xml  $enable_external_effects"
393 echo ""