renamed function due to a name clash
[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/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 dnl keep track of the environment set by the user
32 libfirm_conf_env="${CC+CC='$CC'} ${CFLAGS+CFLAGS='$CFLAGS'} ${CPP+CPP='$CPP'} ${CPPFLAGS+CPPFLAGS='$CPPFLAGS'} ${LDFLAGS+LDFLAGS='$LDFLAGS'} ${LIBS+LIBS='$LIBS'}"
33 AC_SUBST(libfirm_conf_env)
34
35 dnl where is the configure file
36 CONF_DIR_NAME=`dirname $0`
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 [  --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_output_file="$ac_output_file $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 check for libxml2 library installation dir
74 dnl AC_ARG_WITH(libxml2, [  --with-libxml2=prefix   installation prefix of libxml2 (IPD: --with-libxml2=/usr/public/libxml2)],
75 dnl     LDFLAGS=$LDFLAGS" -L"$withval"/lib";
76 dnl     CPPFLAGS=$CPPFLAGS" -I"$withval"/include/libxml2")
77
78 dnl check for libxml2 library installation dir
79 AC_CHECK_PROG(XML2CONFIG, xml2-config, "xml2-config", "echo")
80 if test "$XML2CONFIG" != "xml2-config"; then
81   AC_MSG_ERROR(xml2-config for detecting libxml2 not found)
82 fi
83 AC_SUBST(XML2CONFIG)
84 LDFLAGS=$LDFLAGS" -L/usr/lib `$XML2CONFIG --libs`";
85 CPPFLAGS=$CPPFLAGS" `$XML2CONFIG --cflags`";
86
87 dnl set debugging
88 dnl -------------
89 AC_ARG_ENABLE(debug,
90 [  --enable-debug          enable assertions and additional debugging routines],
91 [if test "$enableval" = yes; then
92   AC_DEFINE(DEBUG_libfirm)
93 else
94   AC_DEFINE(NDEBUG)
95 fi])
96 AC_SUBST(enable_debug_libfirm)
97
98 dnl disable inlining
99 dnl ----------------
100 AC_ARG_ENABLE(inlining,
101 [  --disable-inlining      disable inline C-extension],
102 [if test "$enableval" = yes; then
103   AC_DEFINE(USE_INLINING)
104 fi],
105 AC_DEFINE(USE_INLINING)
106 )
107
108 dnl set profiling
109 dnl -------------
110 AC_ARG_ENABLE(profile,
111 [  --enable-profile        enable profiling],
112 [if test "$enableval"=yes; then
113   enable_profile_libfirm=yes
114 fi],
115 [enable_profile_libfirm=no])
116 AC_SUBST(enable_profile_libfirm)
117
118 dnl set auto documentation
119 dnl ----------------------
120 AC_ARG_ENABLE(autodoc,
121 [  --enable-autodoc        enable auto documentation],
122 [if test "$enableval"=yes; then
123   enable_auto_documentation=yes
124 fi],
125 [enable_auto_documentation=no])
126 AC_SUBST(enable_auto_documentation)
127
128
129 dnl set firm jni
130 dnl ------------
131 AC_ARG_ENABLE(firmjni,
132 [  --enable-firmjni        check for tools necesarry to construct a java native interface for Firm],
133 [if test "$enableval"=yes; then
134   enable_firm_jni=yes
135 fi],
136 [enable_firm_jni=no])
137 AC_SUBST(enable_firm_jni)
138
139 dnl set heap analyses support
140 dnl -------------------------
141 AC_MSG_CHECKING([for heapanalysis])
142 AC_ARG_ENABLE(heapanalysis, [  --enable-heapanalysis   Compile with heap analysis.],
143         [enable_heapanalysis=$enableval], [enable_heapanalysis="no"])
144 if test "$enable_heapanalysis" = "no"; then
145   AC_MSG_RESULT([disabled])
146 else
147   AC_DEFINE(DO_HEAPANALYSIS)
148   AC_MSG_RESULT([enabled])
149 fi
150 AC_SUBST(enable_heapanalysis)
151
152 dnl disable linking of libiberty parts (xmalloc, xprintf, obstack, ...)
153 dnl ----------------------
154 AC_ARG_ENABLE(libiberty,
155 [  --disable-libiberty     disable own libiberty parts],
156 [if test "$enableval"=yes; then
157   disable_libiberty=yes
158 fi],
159 [disable_libiberty=no])
160 AC_SUBST(disable_libiberty)
161
162 dnl enable Firm hooks
163 dnl -------------
164 AC_ARG_ENABLE(hooks,
165 [  --disable-hooks         disable Firm hooks],
166 [if test "$enableval" = yes; then
167   AC_DEFINE(FIRM_ENABLE_HOOKS)
168 fi],
169 AC_DEFINE(FIRM_ENABLE_HOOKS)
170 )
171
172 dnl enable Firm statistics
173 dnl -------------
174 AC_ARG_ENABLE(statistics,
175 [  --enable-statistics     enable Firm statistics],
176 [if test "$enableval"=yes; then
177   AC_DEFINE(FIRM_STATISTICS)
178 fi])
179 AC_SUBST(enable_statistics)
180
181 dnl enable libcore debugging support
182 dnl --------------------------------
183 AC_ARG_ENABLE(libcore,
184 [  --enable-libcore        enable libcore debugging],
185 [if test "$enableval"=yes; then
186   AC_DEFINE(WITH_LIBCORE)
187 fi])
188 AC_SUBST(enable_libcore)
189
190 dnl enable ILP solver support
191 dnl --------------------------------
192 AC_MSG_CHECKING([for ilp solver support])
193 AC_ARG_ENABLE(ilp,
194 [  --enable-ilp            enable ilp solver],
195 [if test "$enableval"=yes; then
196   AC_DEFINE(WITH_ILP)
197 fi])
198 AC_SUBST(enable_ilp)
199 if test "$enable_ilp" == yes; then
200   AC_MSG_RESULT([enabled])
201 else
202   AC_MSG_RESULT([disabled])
203 fi
204
205 dnl enable JVM calling from Firm
206 dnl --------------------------------
207 AC_MSG_CHECKING([for jvm support])
208 AC_ARG_ENABLE(jvm,
209 [  --enable-jvm            enable to call the jvm],
210 [if test "$enableval"=yes; then
211   AC_DEFINE(WITH_JVM)
212 fi])
213 AC_SUBST(enable_jvm)
214 if test "$enable_jvm" == yes; then
215   AC_MSG_RESULT([enabled])
216 else
217   AC_MSG_RESULT([disabled])
218 fi
219
220
221 dnl enable wchar_t support for identifiers
222 dnl --------------------------------
223 AC_ARG_ENABLE(wchar_support,
224 [  --enable-wchar-support  enable wchar_t support for identifiers (needed for java)],
225 [if test "$enableval"=yes; then
226   AC_DEFINE(FIRM_ENABLE_WCHAR)
227 fi])
228 AC_SUBST(enable_wchar_support)
229
230
231 dnl disable external effects in XML
232 dnl -------------------------------
233 AC_MSG_CHECKING([for using external effects in xml2])
234 AC_ARG_ENABLE(external-effects,
235 [  --disable-external-effects  disable descriptions of external effects in XML],
236 [if test "$enableval"="no"; then
237   enable_external_effects=no
238 fi],
239 [enable_external_effects=yes])
240 AC_SUBST(enable_external_effects)
241 if test "$enable_external_effects" == no; then
242   AC_MSG_RESULT([disabled])
243 else
244   AC_MSG_RESULT([enabled])
245 fi
246 dnl check for header and library below
247
248 dnl Checks for programs.
249 dnl ====================
250
251 dnl check for a C compiler
252 dnl ----------------------
253 AC_PROG_CC
254
255 dnl check for awk
256 dnl -------------
257 AC_PROG_AWK
258
259 dnl check for prelinkable linker
260 dnl ----------------------------
261 LIBFIRM_PROG_LD_R
262 if test "$libfirm_cv_prog_ld_r" != "yes"; then
263   AC_MSG_ERROR(need a prelinkcapable linker)
264 fi
265
266 dnl check for ar
267 dnl ------------
268 AC_CHECK_PROG(AR, ar, "ar", "")
269 if test "$AR" != "ar"; then
270   AC_MSG_ERROR(need ar for creating archives)
271 fi
272
273 dnl check for tar
274 dnl -------------
275 AC_CHECK_PROG(TAR, tar, "tar", "")
276 if test "$TAR" != "tar"; then
277   AC_MSG_ERROR(need tar for creating archives in distribution)
278 fi
279
280 dnl check whether ar can handle option -s
281 dnl if not then ranlib is needed
282 dnl for simpliticity we use ranlib every time
283
284 AC_PROG_RANLIB
285
286 AC_PROG_INSTALL
287
288 touch tmp-install.a tmp-install.b
289 if eval "$INSTALL tmp-install.a tmp-install.b" ; then
290     INSTALL="$INSTALL"
291 fi
292 rm tmp-install.a tmp-install.b
293
294
295 AC_PROG_LN_S
296
297 dnl check for doxygen if enabled
298 dnl ----------------------------
299 if test "$enable_auto_documentation" = yes; then
300   AC_CHECK_PROG(DOXYGEN, doxygen, "doxygen", "")
301   if test "$DOXYGEN" != "doxygen"; then
302     AC_MSG_ERROR(need doxygen for auto documentation)
303   fi
304   AC_CHECK_PROG(DOT, dot, "dot", "")
305   if test "$DOT" != "dot"; then
306     AC_MSG_ERROR(need dot for doxygen documentation (for class graphs) (IPD: module add Graphviz))
307   fi
308 fi
309
310 dnl check for availability of a jdk
311 dnl -------------------------------
312 if test "$enable_firm_jni" = yes; then
313   AC_CHECK_PROG(JAVAC, javac, "javac", "")
314   if test "$JAVAC" != "javac"; then
315     AC_MSG_ERROR(need java compiler javac to generate jni (IPD: module add jdk-1.3.1-sun))
316   fi
317   AC_CHECK_PROG(JAVAH, javah, "javah", "")
318   if test "$JAVAH" != "javah"; then
319     AC_MSG_ERROR(need javah to generate jni headers (IPD: module add jdk-1.3.1-sun))
320   fi
321 fi
322
323
324 dnl Checks for header files.
325 dnl ========================
326
327 AC_HEADER_STDC
328
329 dnl check for the math header file
330
331 AC_CHECK_HEADERS(math.h, ac_math_headers="yes", ac_math_headers="no")
332 if test "$ac_math_headers" != yes; then
333   dnl math header not found.
334   AC_MSG_ERROR("math header file not found")
335 fi
336
337
338 #dnl check for the gnu multiprecission (gmp) header file
339
340 #AC_CHECK_HEADERS(gmp.h, ac_gmp_headers="yes", ac_gmp_headers="no")
341 #if test "$ac_gmp_headers" != yes; then
342 #  dnl gmp header not found.
343 #  AC_MSG_ERROR("GNU multiprecission gmp header file not found")
344 #fi
345
346
347 dnl check for the obstack header file
348 dnl does not work with:
349 dnl  - cygwin
350 dnl  - MacOSX
351 #AC_FUNC_OBSTACK
352
353 AC_CHECK_HEADERS(obstack.h, ac_obstack_headers="yes", ac_obstack_headers="no")
354 if test "$ac_obstack_headers" != yes; then
355   dnl obstack header not found.
356   AC_MSG_ERROR("obstack.h not found")
357 fi
358
359
360 AC_CHECK_HEADERS(alloca.h, ac_alloca_headers="yes", ac_alloca_headers="no")
361 if test "$ac_alloca_headers" = "yes"; then
362     AC_DEFINE(HAVE_ALLOCA_H)
363 else
364   if test "$ac_cv_header_stdc" = "no"; then
365     AC_MSG_ERROR("alloca.h and stdlib.h not found")
366   fi
367 fi
368
369
370 dnl check for jni header files
371
372 if test "$enable_firm_jni" = yes; then
373   AC_CHECK_HEADERS(jni.h, ac_jni_headers="yes", ac_jni_headers="no")
374   if test "$ac_jni_headers" != yes; then
375     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))
376   fi
377 fi
378
379
380 if test "$enable_external_effects" == "yes"; then
381   AC_CHECK_HEADERS(libxml/parser.h, ac_xml_headers="yes", ac_xml_headers="no")
382   if test "$ac_xml_headers" != yes; then
383     AC_MSG_ERROR(xml header files not found. (IPD: add --with-includedir=/usr/public/libxml2/include/libxml2/ to configure flags))
384   fi
385 fi
386
387 dnl Checks for libraries.
388 dnl =====================
389
390 #dnl check for the gnu multiprecission (gmp) library
391
392 #AC_CHECK_LIB(gmp, main, ac_gmp_library="yes", ac_gmp_library="no")
393 #if test "$ac_gmp_library" != yes; then
394 #  dnl gmp library not found.
395 #  AC_MSG_ERROR("GNU multiprecission gmp library not found")
396 #fi
397
398
399 AC_CHECK_LIB(m, main, ac_m_library="yes", ac_m_library="no")
400 if test "$ac_m_library" != yes; then
401   dnl std math library not found.
402   AC_MSG_ERROR("standard math library not found")
403 fi
404
405
406 if test "$enable_external_effects" == "yes"; then
407   AC_CHECK_LIB(xml2, xmlParseFile, ac_xml_library="yes", ac_xml_library="no")
408   if test "$ac_m_library" != yes; then
409     AC_MSG_ERROR("xml2 library not found (IPD: add --with-libdir=/usr/public/libxml2/lib/ to configure flags)")
410   else
411     LIBS=$LIBS" -lxml2"
412   fi
413 fi
414
415 dnl Checks for typedefs, structures, and compiler characteristics.
416 dnl ==============================================================
417 AC_C_CONST
418 AC_C_VOLATILE
419 AC_C_INLINE
420 AC_C_BIGENDIAN(,,,)
421 AC_C_LONG_DOUBLE
422
423 dnl Checks for library functions.
424 dnl =============================
425
426 dnl check for strerror
427
428 AC_CHECK_FUNC(strerror,,
429   AC_MSG_ERROR("need strerror function")
430 )
431
432
433 dnl Error messaging
434 dnl ===============
435
436
437 AC_OUTPUT($ac_output_file,[ touch stamp-h ])
438
439 dnl snip the lower part of config.h and put it to ir/config/firm_config.h
440 for i in $plugin_subdirs
441 do
442         suffix=`echo $i | tr /a-z _A-Z`
443         echo "/* enabled plugin: $i */" >> config.h
444         echo "#define PLUGIN_$suffix 1" >> config.h
445 done
446
447 $AWK -f $CONF_DIR_NAME/filter.awk < config.h | sed -f $CONF_DIR_NAME/filter.sed > ir/config/firm_config.h