3 dnl File name: configure.in
5 dnl Author: Matthias Braun
7 dnl Copyright: (c) 2002-2007 University of Karlsruhe
8 dnl Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
12 AC_INIT([libfirm],[1.9.0],[firm@ipd.info.uni-karlsruhe.de])
14 dnl generate the config header file
15 AC_CONFIG_HEADER([config.h])
26 /* Firm statistics need hooks */
27 #ifdef FIRM_STATISTICS
28 #ifndef FIRM_ENABLE_HOOKS
29 #define FIRM_ENABLE_HOOKS
34 dnl keep track of the environment set by the user
35 libfirm_conf_env="${CC+CC='$CC'} ${CFLAGS+CFLAGS='$CFLAGS'} ${CPP+CPP='$CPP'} ${CPPFLAGS+CPPFLAGS='$CPPFLAGS'} ${LDFLAGS+LDFLAGS='$LDFLAGS'} ${LIBS+LIBS='$LIBS'}"
36 AC_SUBST(libfirm_conf_env)
41 dnl enabled external libFirm plugins
43 AC_MSG_CHECKING([for external libfirm plugins])
44 AC_ARG_WITH([plugins],
45 [AS_HELP_STRING([--with-plugins=list], [include external libfirm plugins list (space separated)])],
47 plugin_subdirs=$withval
49 for i in $withval ; do
50 plugin_files="$i/Makefile $plugin_files"
52 AC_CONFIG_FILES($plugin_files)
58 AC_SUBST(plugin_subdirs)
59 if test "$plugin_subdirs" == ""; then
60 AC_MSG_RESULT([disabled])
62 AC_MSG_RESULT([$plugin_subdirs])
65 dnl check for additional include dirs
66 AC_ARG_WITH(includedir, [ --with-includedir=add colon seperated list of directories to include search path],
67 CPPFLAGS=$CPPFLAGS" -I"`echo $withval|sed 's;\:; -I;g'`)
69 dnl check for additional library dirs
70 AC_ARG_WITH(libdir, [ --with-libdir=add colon seperated list of directories to linker search path],
71 LDFLAGS=$LDFLAGS" -L"`echo $withval|sed 's;\:; -L;g'`)
75 AC_ARG_ENABLE([debug],
76 [AS_HELP_STRING([--disable-debug], [disable verifiers and additional debugging routines])],
77 [enable_debug_libfirm="$enableval"], [enable_debug_libfirm="yes"])
78 if test "$enable_debug_libfirm" = yes; then
79 AC_DEFINE([DEBUG_libfirm], [], [define to enable debugging stuff])
81 AC_SUBST([enable_debug_libfirm])
83 AC_ARG_ENABLE([assert],
84 [AS_HELP_STRING([--disable-assert], [disable assertions])],
85 [enable_assert="$enableval"], [enable_assert="yes"])
86 if test "$enable_assert" = no; then
87 AC_DEFINE([NDEBUG], [], [define to disable asserts])
89 AC_SUBST([enable_assert])
93 AC_ARG_ENABLE([inlining],
94 [AS_HELP_STRING([--disable-inlining], [disable inline C-extension])],
95 [enable_inlining="$enableval"], [enable_inlining="yes"])
97 if test "$enable_inlining" = yes; then
98 AC_DEFINE([USE_INLINING], [], [use inlining])
100 AC_SUBST([enable_inlining])
104 AC_ARG_ENABLE([profile],
105 [AS_HELP_STRING([--enable-profile], [enable profiling])],
106 [enable_profile_libfirm="$enableval"], [enable_profile_libfirm="no"])
108 AC_SUBST([enable_profile_libfirm])
110 dnl set auto documentation
111 dnl ----------------------
112 AC_ARG_ENABLE([autodoc],
113 [AS_HELP_STRING([--enable-autodoc], [enable auto documentation])],
114 [enable_auto_documentation="$enableval"], [enable_auto_documentation="no"])
116 AC_SUBST([enable_auto_documentation])
120 AC_ARG_ENABLE([firmjni],
121 [AS_HELP_STRING([--enable-firmjni], [check for tools necesarry to construct a java native interface for Firm])],
122 [enable_firm_jni="$enableval"], [enable_firm_jni="no"])
124 AC_SUBST(enable_firm_jni)
126 dnl set heap analyses support
127 dnl -------------------------
128 AC_ARG_ENABLE([heapanalysis],
129 [AS_HELP_STRING([--enable-heapanalysis], [Compile with heap analysis.])],
130 [enable_heapanalysis=$enableval], [enable_heapanalysis="no"])
132 if test "$enable_heapanalysis" = "yes"; then
133 AC_DEFINE([DO_HEAPANALYSIS], [], [enable heap analysis])
135 AC_SUBST([enable_heapanalysis])
137 dnl enable Firm hooks
139 AC_ARG_ENABLE([hooks],
140 [AS_HELP_STRING([--disable-hooks], [disable Firm hooks])],
141 [enable_hooks="$enableval"], [enable_hooks="yes"])
143 if test "$enable_hooks" = yes; then
144 AC_DEFINE([FIRM_ENABLE_HOOKS], [], [enable firm hooks])
147 dnl enable Firm statistics
149 AC_ARG_ENABLE([statistics],
150 [AS_HELP_STRING([--enable-statistics], [enable Firm statistics])],
151 [enable_statistics="$enableval"], [enable_statistics="no"])
153 if test "$enable_statistics" = yes; then
154 AC_DEFINE([FIRM_STATISTICS], [], [enable statistics code])
156 AC_SUBST([enable_statistics])
158 dnl enable libcore support
159 dnl --------------------------------
160 AC_ARG_ENABLE([libcore],
161 [AS_HELP_STRING([--disable-libcore], [disable libcore support])],
162 [enable_libcore="$enableval"],[enable_libcore="yes"])
164 AC_SUBST([enable_libcore])
166 dnl enable ILP solver support
167 dnl --------------------------------
169 [AS_HELP_STRING([--enable-ilp], [enable ilp solver])],
170 [enable_ilp="$enableval"], [enable_ilp="no"])
172 if test "$enable_ilp" = yes; then
173 AC_DEFINE([WITH_ILP], [], [compile with ilp solver support])
177 dnl enable JVM calling from Firm
178 dnl --------------------------------
180 [AS_HELP_STRING([--enable-jvm], [enable to call the jvm])],
181 [enable_jvm="$enableval"], [enable_jvm="no"])
183 if test "$enable_jvm" = yes; then
184 AC_DEFINE([WITH_JVM], [], [compile with jvm support])
188 dnl enable wchar_t support for identifiers
189 dnl --------------------------------
190 AC_ARG_ENABLE([wchar_support],
191 [AS_HELP_STRING([--enable-wchar-support], [enable wchar_t support for identifiers (needed for java)])],
192 [enable_wchar_support="$enableval"], [enable_wchar_support="no"])
194 if test "$enable_wchar_support" = yes; then
195 AC_DEFINE([FIRM_ENABLE_WCHAR], [], [enable wchar_t support for identifiers])
197 AC_SUBST([enable_wchar_support])
199 dnl disable external effects in XML
200 dnl -------------------------------
201 AC_ARG_ENABLE([external-effects],
202 [AS_HELP_STRING([--enable-external-effects], [enable reading of descriptions of external effects in XML])],
203 [enable_external_effects="$enableval"], [enable_external_effects="no"])
205 AC_SUBST(enable_external_effects)
209 AC_ARG_ENABLE([backend],
210 [AS_HELP_STRING([--disable-backend], [disable backends])],
211 [enable_backend="$enableval"], [enable_backend="yes"])
213 AC_SUBST(enable_backend)
215 dnl Checks for programs.
216 dnl ====================
218 dnl check for a C compiler
219 dnl ----------------------
226 dnl check for prelinkable linker
227 dnl ----------------------------
229 if test "$libfirm_cv_prog_ld_r" != "yes"; then
230 AC_MSG_ERROR(need a prelinkcapable linker)
235 AC_CHECK_PROG(AR, ar, "ar", "")
236 if test "$AR" != "ar"; then
237 AC_MSG_ERROR(need ar for creating archives)
242 AC_CHECK_PROG(TAR, tar, "tar", "")
243 if test "$TAR" != "tar"; then
244 AC_MSG_ERROR(need tar for creating archives in distribution)
247 dnl check whether ar can handle option -s
248 dnl if not then ranlib is needed
249 dnl for simpliticity we use ranlib every time
255 touch tmp-install.a tmp-install.b
256 if eval "$INSTALL tmp-install.a tmp-install.b" ; then
259 rm tmp-install.a tmp-install.b
264 dnl check for doxygen if enabled
265 dnl ----------------------------
266 if test "$enable_auto_documentation" = yes; then
267 AC_CHECK_PROG(DOXYGEN, doxygen, "doxygen", "")
268 if test "$DOXYGEN" != "doxygen"; then
269 AC_MSG_ERROR(need doxygen for auto documentation)
271 AC_CHECK_PROG(DOT, dot, "dot", "")
272 if test "$DOT" != "dot"; then
273 AC_MSG_ERROR(need dot for doxygen documentation (for class graphs) (IPD: module add Graphviz))
277 dnl check for availability of a jdk
278 dnl -------------------------------
279 if test "$enable_firm_jni" = yes; then
280 AC_CHECK_PROG(JAVAC, javac, "javac", "")
281 if test "$JAVAC" != "javac"; then
282 AC_MSG_ERROR(need java compiler javac to generate jni (IPD: module add jdk-1.3.1-sun))
284 AC_CHECK_PROG(JAVAH, javah, "javah", "")
285 if test "$JAVAH" != "javah"; then
286 AC_MSG_ERROR(need javah to generate jni headers (IPD: module add jdk-1.3.1-sun))
290 dnl check for availability of pkg-config
294 dnl Checks for header files.
295 dnl ========================
299 dnl check for the math header file
301 AC_CHECK_HEADERS(math.h, ac_math_headers="yes", ac_math_headers="no")
302 if test "$ac_math_headers" != yes; then
303 dnl math header not found.
304 AC_MSG_ERROR("math header file not found")
308 dnl check for the obstack header file
309 dnl does not work with:
314 AC_CHECK_HEADERS(obstack.h, ac_obstack_headers="yes", ac_obstack_headers="no")
315 if test "$ac_obstack_headers" != yes; then
316 dnl obstack header not found.
317 AC_MSG_ERROR("obstack.h not found")
321 AC_CHECK_HEADERS(alloca.h, ac_alloca_headers="yes", ac_alloca_headers="no")
322 if test "$ac_alloca_headers" = "yes"; then
323 AC_DEFINE(HAVE_ALLOCA_H)
325 if test "$ac_cv_header_stdc" = "no"; then
326 AC_MSG_ERROR("alloca.h and stdlib.h not found")
331 dnl check for jni header files
333 if test "$enable_firm_jni" = yes; then
334 AC_CHECK_HEADERS(jni.h, ac_jni_headers="yes", ac_jni_headers="no")
335 if test "$ac_jni_headers" != yes; then
336 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))
341 if test "$enable_external_effects" == "yes"; then
342 dnl check for libxml2 library installation dir
343 AC_CHECK_PROG(XML2CONFIG, xml2-config, "xml2-config", "echo")
344 if test "$XML2CONFIG" != "xml2-config"; then
345 AC_MSG_ERROR(xml2-config for detecting libxml2 not found)
348 LDFLAGS=$LDFLAGS" -L/usr/lib `$XML2CONFIG --libs`";
349 CPPFLAGS=$CPPFLAGS" `$XML2CONFIG --cflags`";
351 AC_CHECK_HEADERS(libxml/parser.h, ac_xml_headers="yes", ac_xml_headers="no")
352 if test "$ac_xml_headers" != yes; then
353 AC_MSG_ERROR(xml header files not found. (IPD: add --with-includedir=/usr/public/libxml2/include/libxml2/ to configure flags))
357 dnl Checks for libraries.
358 dnl =====================
360 AC_CHECK_LIB(m, main, ac_m_library="yes", ac_m_library="no")
361 if test "$ac_m_library" != yes; then
362 dnl std math library not found.
363 AC_MSG_ERROR("standard math library not found")
367 if test "$enable_external_effects" == "yes"; then
368 AC_CHECK_LIB(xml2, xmlParseFile, ac_xml_library="yes", ac_xml_library="no")
369 if test "$ac_m_library" != yes; then
370 AC_MSG_ERROR("xml2 library not found (IPD: add --with-libdir=/usr/public/libxml2/lib/ to configure flags)")
376 if test "$enable_libcore" == "yes"; then
377 PKG_CHECK_MODULES([LIBCORE], [libcore])
378 AC_DEFINE([WITH_LIBCORE], [], [define to 1 to use the libcore])
381 dnl Checks for typedefs, structures, and compiler characteristics.
382 dnl ==============================================================
389 dnl Checks for library functions.
390 dnl =============================
392 dnl check for strerror
394 AC_CHECK_FUNC(strerror,,
395 AC_MSG_ERROR("need strerror function")
398 dnl we use the gnu extension obstack_printf
399 AC_DEFINE([_GNU_SOURCE], [], [we use gnu extensions])
400 AC_CHECK_FUNC(strerror,,
401 AC_MSG_ERROR("need obstack_printf function")
429 testprograms/Makefile
431 firmjni/testprograms/Makefile
435 AC_CONFIG_COMMANDS([stamp-h], [touch stamp-h])
436 dnl snip the lower part of config.h and put it to ir/config/firm_config.h
437 AC_CONFIG_COMMANDS([firm_config.h],
438 [awk -f ${ac_top_srcdir}/filter.awk < ${ac_top_builddir}config.h > ${ac_top_builddir}ir/config/firm_config.h])
441 if test "$enable_backend" == yes; then
442 BACKENDS="arm ia32 mips ppc32"
446 if test "$BACKENDS"; then
447 AC_CONFIG_FILES([ir/be/Makefile])
448 for backend in $BACKENDS; do
449 AC_CONFIG_FILES([ir/be/$backend/Makefile])
455 dnl output summary of firm configuration
457 echo "firm configuration summary:"
458 echo " backends $BACKENDS"
459 echo " profiling $enable_profile_libfirm"
460 echo " debug/verifiers $enable_debug_libfirm"
461 echo " assertions $enable_assert"
462 echo " hooks $enable_hooks"
463 echo " statistics $enable_statistics"
464 echo " libcore $enable_libcore"
465 echo " ilp $enable_ilp"
466 echo " jvm $enable_jvm"
467 echo " wide char support $enable_wchar_support"
468 echo " external effects xml $enable_external_effects"
469 echo " plugins $plugin_subdirs"
472 dnl FIXME: this is bad
473 dnl for i in $plugin_subdirs
475 dnl suffix=`echo $i | tr /a-z _A-Z`
476 dnl echo "/* enabled plugin: $i */" >> config.h
477 dnl echo "#define PLUGIN_$suffix 1" >> config.h