reworked configure script
[libfirm] / configure.in
1 dnl  \
2 dnl Project:     libFIRM
3 dnl File name:   configure.in
4 dnl Purpose:
5 dnl Author:      Till Riedel, 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.3.0],[firm@info.uni-karlsruhe.de])
13
14 dnl generate the config header file
15 AC_CONFIG_HEADER(config.h)
16
17 AH_TOP([])
18
19 AH_BOTTOM([
20 #ifdef USE_INLINING
21 #define INLINE inline
22 #else
23 #define INLINE
24 #endif
25
26 /* Firm statistics need hooks */
27 #ifdef FIRM_STATISTICS
28 #ifndef FIRM_ENABLE_HOOKS
29 #define FIRM_ENABLE_HOOKS
30 #endif
31 #endif
32 ])
33
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)
37
38 dnl Package options
39 dnl ===============
40
41 dnl enabled external libFirm plugins
42 dnl -------------
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)])],
46 [
47   plugin_subdirs=$withval
48   plugin_files=
49   for i in $withval ; do
50     plugin_files="$i/Makefile $plugin_files"
51   done
52   AC_CONFIG_FILES($plugin_files)
53 ],
54 [
55  plugin_files=
56  plugin_subdirs=
57 ])
58 AC_SUBST(plugin_subdirs)
59 if test "$plugin_subdirs" == ""; then
60   AC_MSG_RESULT([disabled])
61 else
62   AC_MSG_RESULT([$plugin_subdirs])
63 fi
64
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'`)
68
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'`)
72
73 dnl set debugging
74 dnl -------------
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])
80 fi
81 AC_SUBST([enable_debug_libfirm])
82
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])
88 fi
89 AC_SUBST([enable_assert])
90
91 dnl disable inlining
92 dnl ----------------
93 AC_ARG_ENABLE([inlining],
94 [AS_HELP_STRING([--disable-inlining], [disable inline C-extension])],
95 [enable_inlining="$enableval"], [enable_inlining="yes"])
96
97 if test "$enable_inlining" = yes; then
98   AC_DEFINE([USE_INLINING], [], [use inlining])
99 fi
100 AC_SUBST([enable_inlining])
101
102 dnl set profiling
103 dnl -------------
104 AC_ARG_ENABLE([profile],
105 [AS_HELP_STRING([--enable-profile], [enable profiling])],
106 [enable_profile_libfirm="$enableval"], [enable_profile_libfirm="no"])
107
108 AC_SUBST([enable_profile_libfirm])
109
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"])
115
116 AC_SUBST([enable_auto_documentation])
117
118 dnl set firm jni
119 dnl ------------
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"])
123
124 AC_SUBST(enable_firm_jni)
125
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"])
131
132 if test "$enable_heapanalysis" = "yes"; then
133   AC_DEFINE([DO_HEAPANALYSIS], [], [enable heap analysis])
134 fi
135 AC_SUBST([enable_heapanalysis])
136
137 dnl disable linking of libiberty parts (xmalloc, xprintf, obstack, ...)
138 dnl ----------------------
139 AC_ARG_ENABLE([libiberty],
140 [AS_HELP_STRING([--disable-libiberty], [disable own libiberty parts])],
141 [enable_libiberty="$enableval"], [enable_libiberty="yes"])
142
143 if test "$enable_libiberty"=yes; then
144         disable_libiberty=no
145 else
146         disable_libiberty=yes
147 fi
148 AC_SUBST(disable_libiberty)
149
150 dnl enable Firm hooks
151 dnl -------------
152 AC_ARG_ENABLE([hooks],
153 [AS_HELP_STRING([--disable-hooks], [disable Firm hooks])],
154 [enable_hooks="$enableval"], [enable_hooks="yes"])
155
156 if test "$enable_hooks" = yes; then
157         AC_DEFINE([FIRM_ENABLE_HOOKS], [], [enable firm hooks])
158 fi
159
160 dnl enable Firm statistics
161 dnl -------------
162 AC_ARG_ENABLE([statistics],
163 [AS_HELP_STRING([--enable-statistics], [enable Firm statistics])],
164 [enable_statistics="$enableval"], [enable_statistics="no"])
165
166 if test "$enable_statistics"=yes; then
167   AC_DEFINE([FIRM_STATISTICS], [], [enable statistics code])
168 fi
169 AC_SUBST([enable_statistics])
170
171 dnl enable libcore support
172 dnl --------------------------------
173 AC_ARG_ENABLE([libcore],
174 [AS_HELP_STRING([--disable-libcore], [disable libcore support])],
175 [enable_libcore="$enableval"],[enable_libcore="yes"])
176
177 if test "$enable_libcore"=yes; then
178         AC_MSG_CHECKING([for libcore])
179         LIBS="$LIBS -lcore"
180         AC_LINK_IFELSE(
181                 AC_LANG_PROGRAM([#include <libcore/lc_opts.h>],
182                         [lc_opts_init("", 0, "", 1, 0)]),
183                 [],
184                 [AC_MSG_ERROR(
185                         [Couldn't build libcore testprogramm. Check config.log for details])])
186         AC_DEFINE([WITH_LIBCORE], [], [compile with libcore support])
187 fi
188 AC_SUBST([enable_libcore])
189
190 dnl enable ILP solver support
191 dnl --------------------------------
192 AC_ARG_ENABLE([ilp],
193 [AS_HELP_STRING([--enable-ilp], [enable ilp solver])],
194 [enable_ilp="$enableval"], [enable_ilp="no"])
195
196 if test "$enable_ilpd"=yes; then
197   AC_DEFINE([WITH_ILP], [], [compile with ilp solver support])
198 fi
199 AC_SUBST(enable_ilp)
200
201 dnl enable JVM calling from Firm
202 dnl --------------------------------
203 AC_ARG_ENABLE([jvm],
204 [AS_HELP_STRING([--enable-jvm], [enable to call the jvm])],
205 [enable_jvm="$enableval"], [enable_jvm="no"])
206
207 if test "$enable_jvm"=yes; then
208   AC_DEFINE([WITH_JVM], [], [compile with jvm support])
209 fi
210 AC_SUBST(enable_jvm)
211
212 dnl enable wchar_t support for identifiers
213 dnl --------------------------------
214 AC_ARG_ENABLE([wchar_support],
215 [AS_HELP_STRING([--enable-wchar-support], [enable wchar_t support for identifiers (needed for java)])],
216 [enable_wchar_support="$enableval"], [enable_wchar_support="no"])
217
218 if test "$enable_wchar_support"=yes; then
219   AC_DEFINE([FIRM_ENABLE_WCHAR], [], [enable wchar_t support for identifiers])
220 fi
221 AC_SUBST([enable_wchar_support])
222
223 dnl disable external effects in XML
224 dnl -------------------------------
225 AC_ARG_ENABLE([external-effects],
226 [AS_HELP_STRING([--enable-external-effects], [enable reading of descriptions of external effects in XML])],
227 [enable_external_effects="$enableval"], [enable_external_effects="no"])
228
229 AC_SUBST(enable_external_effects)
230
231 dnl Checks for programs.
232 dnl ====================
233
234 dnl check for a C compiler
235 dnl ----------------------
236 AC_PROG_CC
237
238 dnl check for awk
239 dnl -------------
240 AC_PROG_AWK
241
242 dnl check for prelinkable linker
243 dnl ----------------------------
244 LIBFIRM_PROG_LD_R
245 if test "$libfirm_cv_prog_ld_r" != "yes"; then
246   AC_MSG_ERROR(need a prelinkcapable linker)
247 fi
248
249 dnl check for ar
250 dnl ------------
251 AC_CHECK_PROG(AR, ar, "ar", "")
252 if test "$AR" != "ar"; then
253   AC_MSG_ERROR(need ar for creating archives)
254 fi
255
256 dnl check for tar
257 dnl -------------
258 AC_CHECK_PROG(TAR, tar, "tar", "")
259 if test "$TAR" != "tar"; then
260   AC_MSG_ERROR(need tar for creating archives in distribution)
261 fi
262
263 dnl check whether ar can handle option -s
264 dnl if not then ranlib is needed
265 dnl for simpliticity we use ranlib every time
266
267 AC_PROG_RANLIB
268
269 AC_PROG_INSTALL
270
271 touch tmp-install.a tmp-install.b
272 if eval "$INSTALL tmp-install.a tmp-install.b" ; then
273     INSTALL="$INSTALL"
274 fi
275 rm tmp-install.a tmp-install.b
276
277
278 AC_PROG_LN_S
279
280 dnl check for doxygen if enabled
281 dnl ----------------------------
282 if test "$enable_auto_documentation" = yes; then
283   AC_CHECK_PROG(DOXYGEN, doxygen, "doxygen", "")
284   if test "$DOXYGEN" != "doxygen"; then
285     AC_MSG_ERROR(need doxygen for auto documentation)
286   fi
287   AC_CHECK_PROG(DOT, dot, "dot", "")
288   if test "$DOT" != "dot"; then
289     AC_MSG_ERROR(need dot for doxygen documentation (for class graphs) (IPD: module add Graphviz))
290   fi
291 fi
292
293 dnl check for availability of a jdk
294 dnl -------------------------------
295 if test "$enable_firm_jni" = yes; then
296   AC_CHECK_PROG(JAVAC, javac, "javac", "")
297   if test "$JAVAC" != "javac"; then
298     AC_MSG_ERROR(need java compiler javac to generate jni (IPD: module add jdk-1.3.1-sun))
299   fi
300   AC_CHECK_PROG(JAVAH, javah, "javah", "")
301   if test "$JAVAH" != "javah"; then
302     AC_MSG_ERROR(need javah to generate jni headers (IPD: module add jdk-1.3.1-sun))
303   fi
304 fi
305
306
307 dnl Checks for header files.
308 dnl ========================
309
310 AC_HEADER_STDC
311
312 dnl check for the math header file
313
314 AC_CHECK_HEADERS(math.h, ac_math_headers="yes", ac_math_headers="no")
315 if test "$ac_math_headers" != yes; then
316   dnl math header not found.
317   AC_MSG_ERROR("math header file not found")
318 fi
319
320
321 dnl check for the obstack header file
322 dnl does not work with:
323 dnl  - cygwin
324 dnl  - MacOSX
325 #AC_FUNC_OBSTACK
326
327 AC_CHECK_HEADERS(obstack.h, ac_obstack_headers="yes", ac_obstack_headers="no")
328 if test "$ac_obstack_headers" != yes; then
329   dnl obstack header not found.
330   AC_MSG_ERROR("obstack.h not found")
331 fi
332
333
334 AC_CHECK_HEADERS(alloca.h, ac_alloca_headers="yes", ac_alloca_headers="no")
335 if test "$ac_alloca_headers" = "yes"; then
336     AC_DEFINE(HAVE_ALLOCA_H)
337 else
338   if test "$ac_cv_header_stdc" = "no"; then
339     AC_MSG_ERROR("alloca.h and stdlib.h not found")
340   fi
341 fi
342
343
344 dnl check for jni header files
345
346 if test "$enable_firm_jni" = yes; then
347   AC_CHECK_HEADERS(jni.h, ac_jni_headers="yes", ac_jni_headers="no")
348   if test "$ac_jni_headers" != yes; then
349     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))
350   fi
351 fi
352
353
354 if test "$enable_external_effects" == "yes"; then
355         dnl check for libxml2 library installation dir
356         AC_CHECK_PROG(XML2CONFIG, xml2-config, "xml2-config", "echo")
357         if test "$XML2CONFIG" != "xml2-config"; then
358           AC_MSG_ERROR(xml2-config for detecting libxml2 not found)
359         fi
360         AC_SUBST(XML2CONFIG)
361         LDFLAGS=$LDFLAGS" -L/usr/lib `$XML2CONFIG --libs`";
362         CPPFLAGS=$CPPFLAGS" `$XML2CONFIG --cflags`";
363
364         AC_CHECK_HEADERS(libxml/parser.h, ac_xml_headers="yes", ac_xml_headers="no")
365         if test "$ac_xml_headers" != yes; then
366                 AC_MSG_ERROR(xml header files not found. (IPD: add --with-includedir=/usr/public/libxml2/include/libxml2/ to configure flags))
367         fi
368 fi
369
370 dnl Checks for libraries.
371 dnl =====================
372
373 AC_CHECK_LIB(m, main, ac_m_library="yes", ac_m_library="no")
374 if test "$ac_m_library" != yes; then
375   dnl std math library not found.
376   AC_MSG_ERROR("standard math library not found")
377 fi
378
379
380 if test "$enable_external_effects" == "yes"; then
381   AC_CHECK_LIB(xml2, xmlParseFile, ac_xml_library="yes", ac_xml_library="no")
382   if test "$ac_m_library" != yes; then
383     AC_MSG_ERROR("xml2 library not found (IPD: add --with-libdir=/usr/public/libxml2/lib/ to configure flags)")
384   else
385     LIBS=$LIBS" -lxml2"
386   fi
387 fi
388
389 dnl Checks for typedefs, structures, and compiler characteristics.
390 dnl ==============================================================
391 AC_C_CONST
392 AC_C_VOLATILE
393 AC_C_INLINE
394 AC_C_BIGENDIAN(,,,)
395 AC_C_LONG_DOUBLE
396
397 dnl Checks for library functions.
398 dnl =============================
399
400 dnl check for strerror
401
402 AC_CHECK_FUNC(strerror,,
403   AC_MSG_ERROR("need strerror function")
404 )
405
406 dnl we use the gnu extension obstack_printf
407 AC_DEFINE([_GNU_SOURCE], [], [we use gnu extensions])
408 AC_CHECK_FUNC(strerror,,
409   AC_MSG_ERROR("need obstack_printf function")
410 )
411
412 dnl Error messaging
413 dnl ===============
414
415
416 AC_CONFIG_FILES([
417         Makefile
418         MakeRules
419         ir/Makefile
420         ir/adt/Makefile
421         ir/net/Makefile
422         ir/debug/Makefile
423         ir/tv/Makefile
424         ir/common/Makefile
425         ir/ident/Makefile
426         ir/ir/Makefile
427         ir/ana/Makefile
428         ir/tr/Makefile
429         ir/ana2/Makefile
430         ir/stat/Makefile
431         ir/opt/Makefile
432         ir/external/Makefile
433         ir/config/Makefile
434         ir/arch/Makefile
435         ir/lower/Makefile
436         testprograms/Makefile
437         firmjni/Makefile
438         firmjni/testprograms/Makefile
439         libfirm.doxygen
440 ])
441 AC_CONFIG_COMMANDS([stamp-h], [touch stamp-h])
442 dnl snip the lower part of config.h and put it to ir/config/firm_config.h
443 AC_CONFIG_COMMANDS([firm_config.h],
444         [awk -f ${ac_top_srcdir}/filter.awk < ${ac_top_builddir}config.h > ${ac_top_builddir}ir/config/firm_config.h])
445 AC_OUTPUT
446
447 dnl output summary of firm configuration
448 echo ""
449 echo "firm configuration summary:"
450 echo "     profiling             $enable_profile_libfirm"
451 echo "     debug/verifiers       $enable_debug_libfirm"
452 echo "     assertions            $enable_assert"
453 echo "     hooks                 $enable_hooks"
454 echo "     statistics            $enable_statistics"
455 echo "     libcore               $enable_libcore"
456 echo "     ilp                   $enable_ilp"
457 echo "     jvm                   $enable_jvm"
458 echo "     wide char support     $enable_wchar_support"
459 echo "     external effects xml  $enable_external_effects"
460 echo ""
461
462 dnl FIXME: this is bad
463 dnl for i in $plugin_subdirs
464 dnl do
465 dnl     suffix=`echo $i | tr /a-z _A-Z`
466 dnl     echo "/* enabled plugin: $i */" >> config.h
467 dnl     echo "#define PLUGIN_$suffix 1" >> config.h
468 dnl done