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