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 AC_INIT([libfirm], [1.10.0], [firm@ipd.info.uni-karlsruhe.de])
13 AC_CONFIG_SRCDIR([ir/common/firm.c])
14 AM_INIT_AUTOMAKE([foreign dist-bzip2 1.9])
15
16 # see libtool manual on what version numbers mean!
17 LT_VERSION=0:0:0
18 AC_SUBST([LT_VERSION])
19
20 dnl generate the config header file
21 AC_CONFIG_HEADER([config.h])
22
23 AH_TOP([])
24
25 AH_BOTTOM([
26 #ifdef USE_INLINING
27 #define INLINE inline
28 #else
29 #define INLINE
30 #endif
31
32 /* Firm statistics need hooks */
33 #ifdef FIRM_STATISTICS
34 #ifndef FIRM_ENABLE_HOOKS
35 #define FIRM_ENABLE_HOOKS
36 #endif
37 #endif
38 ])
39
40 dnl keep track of the environment set by the user
41 libfirm_conf_env="${CC+CC='$CC'} ${CFLAGS+CFLAGS='$CFLAGS'} ${CPP+CPP='$CPP'} ${CPPFLAGS+CPPFLAGS='$CPPFLAGS'} ${LDFLAGS+LDFLAGS='$LDFLAGS'} ${LIBS+LIBS='$LIBS'}"
42 AC_SUBST(libfirm_conf_env)
43
44 dnl Package options
45 dnl ===============
46
47 dnl check for additional include dirs
48 AC_ARG_WITH(includedir, [  --with-includedir=add   colon seperated list of directories to include search path],
49     CPPFLAGS=$CPPFLAGS" -I"`echo $withval|sed 's;\:; -I;g'`)
50
51 dnl check for additional library dirs
52 AC_ARG_WITH(libdir, [  --with-libdir=add       colon seperated list of directories to linker search path],
53     LDFLAGS=$LDFLAGS" -L"`echo $withval|sed 's;\:; -L;g'`)
54
55 dnl set debugging
56 dnl -------------
57 AC_ARG_ENABLE([debug],
58 [AS_HELP_STRING([--disable-debug], [disable verifiers and additional debugging routines])],
59 [enable_debug_libfirm="$enableval"], [enable_debug_libfirm="yes"])
60 if test "$enable_debug_libfirm" = yes; then
61   AC_DEFINE([DEBUG_libfirm], [], [define to enable debugging stuff])
62 fi
63 AC_SUBST([enable_debug_libfirm])
64
65 AC_ARG_ENABLE([assert],
66 [AS_HELP_STRING([--disable-assert], [disable assertions])],
67 [enable_assert="$enableval"], [enable_assert="yes"])
68 if test "$enable_assert" = no; then
69   AC_DEFINE([NDEBUG], [], [define to disable asserts])
70 fi
71 AC_SUBST([enable_assert])
72
73 dnl disable inlining
74 dnl ----------------
75 AC_ARG_ENABLE([inlining],
76 [AS_HELP_STRING([--disable-inlining], [disable inline C-extension])],
77 [enable_inlining="$enableval"], [enable_inlining="yes"])
78
79 if test "$enable_inlining" = yes; then
80   AC_DEFINE([USE_INLINING], [], [use inlining])
81 fi
82 AC_SUBST([enable_inlining])
83
84 dnl set profiling
85 dnl -------------
86 AC_ARG_ENABLE([profile],
87 [AS_HELP_STRING([--enable-profile], [enable profiling])],
88 [enable_profile_libfirm="$enableval"], [enable_profile_libfirm="no"])
89
90 AC_SUBST([enable_profile_libfirm])
91
92 dnl set auto documentation
93 dnl ----------------------
94 AC_ARG_ENABLE([autodoc],
95 [AS_HELP_STRING([--enable-autodoc], [enable auto documentation])],
96 [enable_auto_documentation="$enableval"], [enable_auto_documentation="no"])
97
98 AC_SUBST([enable_auto_documentation])
99
100 dnl set firm jni
101 dnl ------------
102 AC_ARG_ENABLE([firmjni],
103 [AS_HELP_STRING([--enable-firmjni], [check for tools necesarry to construct a java native interface for Firm])],
104 [enable_firm_jni="$enableval"], [enable_firm_jni="no"])
105
106 AC_SUBST(enable_firm_jni)
107
108 dnl set heap analyses support
109 dnl -------------------------
110 AC_ARG_ENABLE([heapanalysis],
111 [AS_HELP_STRING([--enable-heapanalysis], [Compile with heap analysis.])],
112 [enable_heapanalysis=$enableval], [enable_heapanalysis="no"])
113
114 if test "$enable_heapanalysis" = "yes"; then
115   AC_DEFINE([DO_HEAPANALYSIS], [], [enable heap analysis])
116 fi
117 AC_SUBST([enable_heapanalysis])
118
119 dnl enable Firm hooks
120 dnl -------------
121 AC_ARG_ENABLE([hooks],
122 [AS_HELP_STRING([--disable-hooks], [disable Firm hooks])],
123 [enable_hooks="$enableval"], [enable_hooks="yes"])
124
125 if test "$enable_hooks" = yes; then
126         AC_DEFINE([FIRM_ENABLE_HOOKS], [], [enable firm hooks])
127 fi
128
129 dnl enable Firm statistics
130 dnl -------------
131 AC_ARG_ENABLE([statistics],
132 [AS_HELP_STRING([--enable-statistics], [enable Firm statistics])],
133 [enable_statistics="$enableval"], [enable_statistics="no"])
134
135 if test "$enable_statistics" = yes; then
136   AC_DEFINE([FIRM_STATISTICS], [], [enable statistics code])
137 fi
138 AC_SUBST([enable_statistics])
139
140 dnl enable libcore support
141 dnl --------------------------------
142 AC_ARG_ENABLE([libcore],
143 [AS_HELP_STRING([--disable-libcore], [disable libcore support])],
144 [enable_libcore="$enableval"],[enable_libcore="yes"])
145
146 AC_SUBST([enable_libcore])
147
148 dnl enable ILP solver support
149 dnl --------------------------------
150 AC_ARG_ENABLE([ilp],
151 [AS_HELP_STRING([--enable-ilp], [enable ilp solver])],
152 [enable_ilp="$enableval"], [enable_ilp="no"])
153
154 if test "$enable_ilp" = yes; then
155   AC_DEFINE([WITH_ILP], [], [compile with ilp solver support])
156 fi
157 AC_SUBST(enable_ilp)
158
159 dnl enable JVM calling from Firm
160 dnl --------------------------------
161 AC_ARG_ENABLE([jvm],
162 [AS_HELP_STRING([--enable-jvm], [enable to call the jvm])],
163 [enable_jvm="$enableval"], [enable_jvm="no"])
164
165 if test "$enable_jvm" = yes; then
166   AC_DEFINE([WITH_JVM], [], [compile with jvm support])
167 fi
168 AC_SUBST(enable_jvm)
169
170 dnl enable wchar_t support for identifiers
171 dnl --------------------------------
172 AC_ARG_ENABLE([wchar_support],
173 [AS_HELP_STRING([--enable-wchar-support], [enable wchar_t support for identifiers (needed for java)])],
174 [enable_wchar_support="$enableval"], [enable_wchar_support="no"])
175
176 if test "$enable_wchar_support" = yes; then
177   AC_DEFINE([FIRM_ENABLE_WCHAR], [], [enable wchar_t support for identifiers])
178 fi
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         AC_DEFINE([WITH_LIBCORE], [], [define to 1 to use the libcore])
326 fi
327
328 dnl Checks for typedefs, structures, and compiler characteristics.
329 dnl ==============================================================
330 AC_C_CONST
331 AC_C_VOLATILE
332 AC_C_INLINE
333 AC_C_BIGENDIAN(,,,)
334 AC_C_LONG_DOUBLE
335
336 dnl Checks for library functions.
337 dnl =============================
338
339 dnl check for strerror
340
341 AC_CHECK_FUNC(strerror,,
342   AC_MSG_ERROR("need strerror function")
343 )
344
345 dnl we use the gnu extension obstack_printf
346 AC_DEFINE([_GNU_SOURCE], [], [we use gnu extensions])
347 AC_CHECK_FUNC(strerror,,
348   AC_MSG_ERROR("need obstack_printf function")
349 )
350
351 dnl Error messaging
352 dnl ===============
353
354
355 dnl Output results
356 AC_CONFIG_FILES([
357         Makefile
358         ir/Makefile
359         include/libfirm/Makefile
360         libfirm.pc
361 ])
362 AC_CONFIG_COMMANDS([stamp-h], [touch stamp-h])
363 dnl snip the lower part of config.h and put it to firm_config.h
364 AC_CONFIG_COMMANDS([firm_config.h],
365         [awk -f ${ac_top_srcdir}/filter.awk < ${ac_top_builddir}config.h > ${ac_top_builddir}firm_config.h])
366
367 BACKENDS=""
368 if test "$enable_backend" == yes; then
369         BACKENDS="arm ia32 mips ppc32"
370 fi
371 AC_SUBST([BACKENDS])
372
373 #if test "$BACKENDS"; then
374 #       for backend in $BACKENDS; do
375 #               AC_CONFIG_FILES([ir/be/$backend/Makefile])
376 #       done
377 #fi
378
379 AC_OUTPUT
380
381 dnl output summary of firm configuration
382 echo ""
383 echo "firm configuration summary:"
384 echo "     backends              $BACKENDS"
385 echo "     profiling             $enable_profile_libfirm"
386 echo "     debug/verifiers       $enable_debug_libfirm"
387 echo "     assertions            $enable_assert"
388 echo "     hooks                 $enable_hooks"
389 echo "     statistics            $enable_statistics"
390 echo "     libcore               $enable_libcore"
391 echo "     ilp                   $enable_ilp"
392 echo "     jvm                   $enable_jvm"
393 echo "     wide char support     $enable_wchar_support"
394 dnl echo "     external effects xml  $enable_external_effects"
395 echo ""