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