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