use m4 macro ti check compiler flag
[profile/ivi/eina.git] / configure.ac
1 # get rid of that stupid cache mechanism
2 rm -f config.cache
3
4 AC_INIT([eina], [0.9.9.063], [enlightenment-devel@lists.sourceforge.net])
5 release="ver-pre-svn-05"
6 AC_PREREQ([2.60])
7 AC_CONFIG_SRCDIR([configure.ac])
8 AC_CONFIG_MACRO_DIR([m4])
9 AC_CANONICAL_BUILD
10 AC_CANONICAL_HOST
11 AC_ISC_POSIX
12
13 AM_INIT_AUTOMAKE([1.6 dist-bzip2])
14 AM_CONFIG_HEADER([config.h])
15 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
16
17 AC_LIBTOOL_WIN32_DLL
18 define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
19 define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
20 AC_PROG_LIBTOOL
21
22 VMAJ=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $1);}'`
23 VMIN=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $2);}'`
24 VMIC=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $3);}'`
25 SNAP=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $4);}'`
26 version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN"
27 AC_SUBST(VMAJ)
28 AC_SUBST(version_info)
29
30
31 ### Needed information
32
33 requirement_eina=""
34
35 case "$host_os" in
36    mingw32ce* | cegcc*)
37       MODULE_ARCH="$host_os-$host_cpu"
38       ;;
39    *)
40       release_info="-release $release"
41       MODULE_ARCH="$host_os-$host_cpu-$release"
42       ;;
43 esac
44 AC_SUBST(release_info)
45 AC_SUBST(MODULE_ARCH)
46 AC_DEFINE_UNQUOTED(MODULE_ARCH, "${MODULE_ARCH}", "Module architecture")
47
48 AC_DEFINE_UNQUOTED(SHARED_LIB_SUFFIX, "$shrext_cmds", [Suffix for shared objects])
49
50 EFL_CHECK_CPU_MMX([have_mmx="yes"], [have_mmx="no"])
51 EFL_CHECK_CPU_SSE([have_sse="yes"], [have_sse="no"])
52 EFL_CHECK_CPU_SSE2([have_sse2="yes"], [have_sse2="no"])
53 EFL_CHECK_CPU_ALTIVEC([have_altivec="yes"], [have_altivec="no"])
54
55 EFL_CHECK_PTHREAD(["yes"],
56    [have_pthread="yes"],
57    [have_pthread="no"],
58    [have_pthread_spinlock="yes"],
59    [have_pthread_spinlock="no"])
60
61 ### Additional options to configure
62
63 # Magic debug
64 AC_ARG_ENABLE([magic-debug],
65    [AC_HELP_STRING([--disable-magic-debug], [disable magic debug of eina structure @<:@default=enabled@:>@])],
66    [
67     if test "x${enableval}" = "xyes" ; then
68        have_magic_debug="yes"
69     else
70        have_magic_debug="no"
71     fi
72    ],
73    [have_magic_debug="yes"])
74
75 AC_MSG_CHECKING([whether magic debug is enable])
76 AC_MSG_RESULT([${have_magic_debug}])
77
78 if test "x${have_magic_debug}" = "xyes" ; then
79    EINA_CONFIGURE_MAGIC_DEBUG="#define EINA_MAGIC_DEBUG"
80 fi
81 AC_SUBST(EINA_CONFIGURE_MAGIC_DEBUG)
82
83 # Safety checks (avoid crashes on wrong api usage)
84 AC_ARG_ENABLE(safety-checks,
85    [AC_HELP_STRING([--disable-safety-checks], [disable safety checks for NULL pointers and like. @<:@default=enabled@:>@])],
86    [
87     if test "x${enableval}" = "xyes" ; then
88        have_safety_checks="yes"
89     else
90        have_safety_checks="no"
91     fi
92    ],
93    [have_safety_checks="yes"])
94
95 AC_MSG_CHECKING(whether to do safety checking on api parameters)
96 AC_MSG_RESULT($have_safety_checks)
97
98 AM_CONDITIONAL(SAFETY_CHECKS, test "x$have_safety_checks" = "xyes")
99 if test "x$have_safety_checks" = "xyes"; then
100   AC_DEFINE(EINA_SAFETY_CHECKS, 1, [disable safety checks for NULL pointers and like.])
101   EINA_CONFIGURE_SAFETY_CHECKS="#define EINA_SAFETY_CHECKS"
102 fi
103 AC_SUBST(EINA_CONFIGURE_SAFETY_CHECKS)
104
105 with_max_log_level="<unset>"
106 AC_ARG_WITH(internal-maximum-log-level,
107    [AC_HELP_STRING([--with-internal-maximum-log-level=NUMBER],
108                    [limit eina internal log level to the given number, any call to EINA_LOG() with values greater than this will be compiled out, ignoring runtime settings, but saving function calls.])],
109    [
110     if test "x${withval}" != "xno"; then
111        if echo "${withval}" | grep '^[[0-9]]\+$' >/dev/null 2>/dev/null; then
112           AC_MSG_NOTICE([ignoring any EINA_LOG() with level greater than ${withval}])
113           AC_DEFINE_UNQUOTED(EINA_LOG_LEVEL_MAXIMUM, ${withval}, [if set, logging is limited to this amount.])
114           with_max_log_level="${withval}"
115        else
116           AC_MSG_ERROR([--with-internal-maximum-log-level takes a decimal number, got "${withval}" instead.])
117        fi
118     fi
119     ], [:])
120
121 AC_ARG_ENABLE([amalgamation],
122    [AC_HELP_STRING([--enable-amalgamation], [enable generation of one single file with all source code in it, helps compiler optimizations.])],
123    [if test "x${enableval}" = "xyes"; then
124        do_amalgamation="yes"
125     else
126        do_amalgamation="no"
127     fi
128    ],
129    [do_amalgamation="no"]
130 )
131 AM_CONDITIONAL(EINA_AMALGAMATION, test "x${do_amalgamation}" = "xyes")
132
133 # Choose best memory pool
134 AC_ARG_ENABLE([default-mempool],
135    [AC_HELP_STRING([--enable-default-mempool], [Default memory allocator could be faster for some computer. @<:@default=disabled@:>@])],
136    [
137     if test "x${enableval}" = "xyes"; then
138        have_default_mempool="yes"
139     else
140        have_default_mempool="no"
141     fi
142    ],
143    [have_default_mempool="no"]
144 )
145 AC_MSG_CHECKING([whether to use default mempool allocator])
146 AC_MSG_RESULT([${have_default_mempool}])
147
148 if test "x${have_default_mempool}" = "xyes" ; then
149    EINA_CONFIGURE_DEFAULT_MEMPOOL="#define EINA_DEFAULT_MEMPOOL"
150 fi
151 AC_SUBST(EINA_CONFIGURE_DEFAULT_MEMPOOL)
152
153 # Report stringshare usage
154 AC_ARG_ENABLE([stringshare-usage],
155    [AC_HELP_STRING([--enable-stringshare-usage], [Report stringshare usage on stringshare shutdown. @<:@default=disabled@:>@])],
156    [
157     if test "x${enableval}" = "xyes"; then
158        have_stringshare_usage="yes"
159     else
160        have_stringshare_usage="no"
161     fi
162    ],
163    [have_stringshare_usage="no"]
164 )
165 AC_MSG_CHECKING([whether to report stringshare usage])
166 AC_MSG_RESULT([${have_stringshare_usage}])
167
168 if test "x${have_stringshare_usage}" = "xyes"; then
169    AC_DEFINE(EINA_STRINGSHARE_USAGE, 1, [Report Eina stringshare usage pattern])
170 fi
171
172 # Check if we want to benchmark on real data
173 enable_benchmark_e17="no"
174 AC_ARG_ENABLE([e17],
175    [AC_HELP_STRING([--enable-e17], [enable heavy benchmark @<:@default=no@:>@])],
176    [
177     if test "x${enableval}" = "xyes" ; then
178        enable_benchmark_e17="yes"
179     else
180        enable_benchmark_e17="no"
181     fi
182    ],
183    [enable_benchmark_e17="no"])
184
185 AC_MSG_CHECKING([whether e17 real data benchmark are built])
186 AC_MSG_RESULT([${enable_benchmark_e17}])
187
188 AM_CONDITIONAL(EINA_ENABLE_BENCHMARK_E17, test "x${enable_benchmark_e17}" = "xyes")
189
190
191 ### Checks for programs
192 AC_PROG_CC
193
194 # pkg-config
195 PKG_PROG_PKG_CONFIG
196
197 # Check whether pkg-config supports Requires.private
198 if $PKG_CONFIG --atleast-pkgconfig-version 0.22; then
199    pkgconfig_requires_private="Requires.private"
200 else
201    pkgconfig_requires_private="Requires"
202 fi
203 AC_SUBST(pkgconfig_requires_private)
204
205 # doxygen program for documentation building
206
207 EFL_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"])
208
209
210 ### Checks for libraries
211
212 # Evil library for compilation on Windows CE
213
214 EFL_EINA_BUILD=""
215 case "$host_os" in
216    mingw* | cegcc*)
217       PKG_CHECK_MODULES([EVIL], [evil])
218       AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed])
219       requirement_eina="evil"
220       EFL_EINA_BUILD="-DEFL_EINA_BUILD"
221    ;;
222 esac
223 AC_SUBST(EFL_EINA_BUILD)
224
225 # Check ememoa memory pool library
226
227 AC_ARG_ENABLE([ememoa],
228    [AC_HELP_STRING([--enable-ememoa], [build ememoa memory pool module @<:@default=yes@:>@])],
229    [
230     if test "x${enableval}" = "xyes" ; then
231        enable_ememoa="yes"
232     else
233        enable_ememoa="no"
234     fi
235    ],
236    [enable_ememoa="yes"]
237 )
238 AC_MSG_CHECKING([whether to use ememoa for memory pool])
239 AC_MSG_RESULT([$enable_ememoa])
240
241 if test "x${enable_ememoa}" = "xyes" ; then
242    PKG_CHECK_MODULES([EMEMOA],
243       [ememoa >= 0.0.26 ],
244       [enable_ememoa="yes"],
245       [enable_ememoa="no"]
246    )
247 fi
248
249 AM_CONDITIONAL(EINA_ENABLE_EMEMOA, test "x${enable_ememoa}" = "xyes")
250 if test "x${enable_ememoa}" = "xyes"; then
251    AC_DEFINE(EINA_EMEMOA_SUPPORT, 1, [Use by the test suite to try ememoa mempool])
252 fi
253
254 ### Checks for header files
255 AC_HEADER_ASSERT
256 AC_HEADER_DIRENT
257 AC_HEADER_TIME
258
259 AC_CHECK_HEADER([fnmatch.h],
260    [dummy="yes"],
261    [AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file. MinGW users: see the INSTALL file])])
262
263 ### Checks for types
264
265
266 ### Checks for structures
267
268
269 ### Checks for compiler characteristics
270 AC_C_CONST
271 AC_C_BIGENDIAN
272 AC_C_INLINE
273 AC_C___ATTRIBUTE__
274 AC_PROG_CC_STDC
275
276 EINA_CPPFLAGS=""
277 case "$host_os" in
278    mingw32ce* | cegcc*)
279       EINA_CPPFLAGS="-D_WIN32_WCE=0x0420"
280       ;;
281    mingw*)
282       EINA_CPPFLAGS="-D_WIN32_WINNT=0x0500"
283       ;;
284 esac
285
286 EINA_CFLAGS=
287 case "${host_os}" in
288    cegcc*)
289       EINA_CFLAGS="${EVIL_CFLAGS} -mwin32"
290    ;;
291    mingw*)
292       EINA_CFLAGS="${EVIL_CFLAGS}"
293    ;;
294 esac
295
296 if ! test "x${VMIC}" = "x" ; then
297    EFL_COMPILER_FLAG([-Wall])
298    EFL_COMPILER_FLAG([-W])
299 fi
300
301 EFL_COMPILER_FLAG([-Wshadow])
302 EFL_COMPILER_FLAG([-fno-strict-aliasing])
303
304 AC_SUBST(EINA_CPPFLAGS)
305 AC_SUBST(EINA_CFLAGS)
306
307
308 ### Checks for linker characteristics
309 EINA_LIBS=
310 lt_enable_auto_import=""
311 case "${host_os}" in
312    mingw* | cegcc*)
313       EINA_LIBS="-ldl ${EVIL_LIBS} -lm"
314       lt_enable_auto_import="-Wl,--enable-auto-import"
315    ;;
316    dragonfly*|openbsd*)
317       EINA_LIBS="-lm"
318    ;;
319    freebsd*|netbsd*)
320       EINA_LIBS="-lrt -lm"
321    ;;
322    darwin*)
323       EINA_LIBS="-lm"
324    ;;
325    cygwin*)
326       EINA_LIBS="-ldl -lm"
327    ;;
328    *)
329       EINA_LIBS="-ldl -lrt -lm"
330    ;;
331 esac
332 AC_SUBST(EINA_LIBS)
333 AC_SUBST(lt_enable_auto_import)
334
335
336 ### Checks for library functions
337 AC_FUNC_ALLOCA
338
339 #dlopen and dladdr
340 dlopen_libs=""
341 case "$host_os" in
342    mingw* | cegcc*)
343 # managed by evil
344       AC_DEFINE(HAVE_DLADDR)
345       ;;
346    *)
347       AC_CHECK_FUNCS([dlopen], [res="yes"], [res="no"])
348       if test "x${res}" = "xyes" ; then
349          AC_CHECK_FUNCS([dladdr], [AC_DEFINE(HAVE_DLADDR)])
350       else
351          AC_CHECK_LIB([dl], [dlopen], [res="yes"], [res="no"])
352          if test "x${res}" = "xyes" ; then
353             AC_CHECK_LIB([dl], [dladdr], [AC_DEFINE(HAVE_DLADDR)])
354             dlopen_libs="-ldl"
355          else
356             AC_MSG_ERROR([Cannot find dlopen])
357          fi
358       fi
359       ;;
360 esac
361 AC_SUBST(dlopen_libs)
362
363 fnmatch_libs=""
364 AC_CHECK_FUNCS([fnmatch], [res="yes"], [res="no"])
365 if test "x$res" = "xno"; then
366    AC_SEARCH_LIBS([fnmatch],
367       [fnmatch evil iberty],
368       [res="yes"],
369       [res="no"])
370    if test "x$res" = "xno"; then
371       AC_MSG_ERROR([Cannot find fnmatch() in neither libc nor libfnmatch, nor libiberty, nor libevil])
372    fi
373    fnmatch_libs="${ac_cv_search_fnmatch}"
374 fi
375 AC_SUBST(fnmatch_libs)
376
377 ### Modules
378
379 EINA_CHECK_MODULE([chained-pool], [yes], [chained pool])
380 EINA_CHECK_MODULE([ememoa-fixed], [${enable_ememoa}], [ememoa fixed])
381 EINA_CHECK_MODULE([ememoa-unknown], [${enable_ememoa}], [ememoa unknown])
382 EINA_CHECK_MODULE([fixed-bitmap], [yes], [fixed bitmap])
383 EINA_CHECK_MODULE([pass-through], [yes], [pass through])
384 EINA_CHECK_MODULE([buddy], [yes], [buddy])
385
386
387 ### Make the debug preprocessor configurable
388
389 ### Unit tests, coverage and benchmarking
390
391 EFL_CHECK_TESTS([enable_tests="yes"], [enable_tests="no"])
392
393 EFL_CHECK_COVERAGE([${enable_tests}], [enable_coverage="yes"], [enable_coverage="no"])
394 EINA_CFLAGS="${EINA_CFLAGS} ${EFL_COVERAGE_CFLAGS}"
395 EINA_LIBS="${EINA_LIBS} ${EFL_COVERAGE_LIBS}"
396 if test "x$enable_coverage" = "xyes" ; then
397    EINA_CFLAGS="${EINA_CFLAGS} ${EFL_DEBUG_CFLAGS}"
398 fi
399
400 EFL_CHECK_BENCHMARK([enable_benchmark="yes"], [enable_benchmark="no"])
401 EINA_BENCH_MODULE([evas], [${enable_benchmark}], [evas], [enable_benchmark_evas="yes"], [enable_benchmark_evas="no"])
402 EINA_BENCH_MODULE([glib], [${enable_benchmark}], [glib-2.0], [enable_benchmark_glib="yes"], [enable_benchmark_glib="no"])
403
404 AC_SUBST(requirement_eina)
405
406 ### Create the .pc.in file according to the major version
407 #cat > ${srcdir}/eina-${VMAJ}.pc.in << EOF
408 #prefix=@prefix@
409 #exec_prefix=@exec_prefix@
410 #libdir=@libdir@
411 #includedir=@includedir@
412 #
413 #Name: Eina
414 #Description: A Library that implements fast data types and miscellaneous tools
415 #Requires:
416 #Version: @VERSION@
417 #Libs: -L${libdir} -leina
418 #Libs.private: -ldl
419 #Cflags: -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-@VMAJ@/eina
420 #EOF
421
422 AC_CONFIG_FILES([
423 Makefile
424 eina-0.pc
425 eina.spec
426 doc/Makefile
427 src/Makefile
428 src/include/Makefile
429 src/include/eina_config.h
430 src/lib/Makefile
431 src/modules/Makefile
432 src/modules/mp/Makefile
433 src/modules/mp/chained_pool/Makefile
434 src/modules/mp/ememoa_fixed/Makefile
435 src/modules/mp/ememoa_unknown/Makefile
436 src/modules/mp/pass_through/Makefile
437 src/modules/mp/fixed_bitmap/Makefile
438 src/modules/mp/buddy/Makefile
439 src/tests/Makefile
440 ])
441
442 AC_OUTPUT
443
444 #####################################################################
445 ## Info
446
447 echo
448 echo
449 echo
450 echo "------------------------------------------------------------------------"
451 echo "$PACKAGE $VERSION"
452 echo "------------------------------------------------------------------------"
453 echo
454 echo
455 echo "Configuration Options Summary:"
456 echo
457 echo "  Magic debug..........: ${have_magic_debug}"
458 echo "  Safety checks........: ${have_safety_checks}"
459 echo "  Maximum log level....: ${with_max_log_level}"
460 echo "  Report string usage..: ${have_stringshare_usage}"
461 echo "  Default mempool......: ${have_default_mempool}"
462 echo "  Thread Support.......: ${have_pthread} (spinlock: ${have_pthread_spinlock})"
463 echo "  Amalgamation.........: ${do_amalgamation}"
464 echo
465 echo "  Documentation........: ${build_doc}"
466 echo "  Tests................: ${enable_tests}"
467 echo "  Coverage.............: ${enable_coverage}"
468 echo "  Benchmark............: ${enable_benchmark}"
469 if test "x${enable_benchmark}" = "xyes" ; then
470 echo "    Glib...............: ${enable_benchmark_glib}"
471 echo "    Evas...............: ${enable_benchmark_evas}"
472 echo "    E17 real data......: ${enable_benchmark_e17}"
473 fi
474 echo
475 echo "  CPU Specific Extensions:"
476 echo "    MMX................: ${have_mmx}"
477 echo "    SSE................: ${have_sse}"
478 echo "    SSE2...............: ${have_sse2}"
479 echo "    ALTIVEC............: ${have_altivec}"
480 echo
481 echo "  Memory pools:"
482 echo "    Chained pool.......: ${enable_chained_pool}"
483 echo "    Ememoa fixed.......: ${enable_ememoa_fixed}"
484 echo "    Ememoa unknown.....: ${enable_ememoa_unknown}"
485 echo "    Fixed bitmap.......: ${enable_fixed_bitmap}"
486 echo "    Pass through.......: ${enable_pass_through}"
487 echo "    Buddy..............: ${enable_buddy}"
488 echo
489 echo "Compilation............: make (or gmake)"
490 echo "  CPPFLAGS.............: $CPPFLAGS"
491 echo "  CFLAGS...............: $CFLAGS"
492 echo "  LDFLAGS..............: $LDFLAGS"
493 echo
494 echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
495 echo "  prefix...............: $prefix"
496 echo
497 if test "x${have_static_module}" = "xyes" ; then
498 echo -e "\0033\01331;31mWarning\0033\01331;0m: You are trying to link statically one or more modules to Eina."
499 echo "         You must know what you are doing, or else you will have a lot of problems."
500 echo "         And dolphins will disappear from the earth."
501 echo "         Think about that."
502 echo
503 fi