* include stdlib.h so that NULL is always defined
[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.59])
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_DEFINE_UNQUOTED(VMAJ, ["$VMAJ"], [Eina major version number])
28 AC_SUBST(VMAJ)
29 AC_SUBST(version_info)
30
31 MODULE_ARCH="$host_os-$host_cpu-$release"
32 AC_SUBST(MODULE_ARCH)
33 AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
34
35 ### Needed information
36
37 requirement_eina=""
38
39 case "$host_os" in
40    mingw32ce* | cegcc*)
41       MODULE_ARCH="$host_os-$host_cpu"
42       ;;
43    *)
44       release_info="-release $release"
45       MODULE_ARCH="$host_os-$host_cpu-$release"
46       ;;
47 esac
48 AC_SUBST(release_info)
49 AC_SUBST(MODULE_ARCH)
50 AC_DEFINE_UNQUOTED(MODULE_ARCH, "${MODULE_ARCH}", "Module architecture")
51
52 AC_DEFINE_UNQUOTED(SHARED_LIB_SUFFIX, "$shrext_cmds", [Suffix for shared objects])
53
54 EFL_CHECK_CPU_MMX([have_mmx="yes"], [have_mmx="no"])
55 EFL_CHECK_CPU_SSE([have_sse="yes"], [have_sse="no"])
56 EFL_CHECK_CPU_SSE2([have_sse2="yes"], [have_sse2="no"])
57 EFL_CHECK_CPU_ALTIVEC([have_altivec="yes"], [have_altivec="no"])
58
59 EFL_CHECK_PTHREAD(["yes"],
60    [have_pthread="yes"],
61    [have_pthread="no"],
62    [have_pthread_spinlock="yes"],
63    [have_pthread_spinlock="no"])
64
65 ### Additional options to configure
66
67 # Magic debug
68 AC_ARG_ENABLE([magic-debug],
69    [AC_HELP_STRING([--disable-magic-debug], [disable magic debug of eina structure @<:@default=enabled@:>@])],
70    [
71     if test "x${enableval}" = "xyes" ; then
72        have_magic_debug="yes"
73     else
74        have_magic_debug="no"
75     fi
76    ],
77    [have_magic_debug="yes"])
78
79 AC_MSG_CHECKING([whether magic debug is enable])
80 AC_MSG_RESULT([${have_magic_debug}])
81
82 if test "x${have_magic_debug}" = "xyes" ; then
83    EINA_CONFIGURE_MAGIC_DEBUG="#define EINA_MAGIC_DEBUG"
84 fi
85 AC_SUBST(EINA_CONFIGURE_MAGIC_DEBUG)
86
87 # Safety checks (avoid crashes on wrong api usage)
88 AC_ARG_ENABLE(safety-checks,
89    [AC_HELP_STRING([--disable-safety-checks], [disable safety checks for NULL pointers and like. @<:@default=enabled@:>@])],
90    [
91     if test "x${enableval}" = "xyes" ; then
92        have_safety_checks="yes"
93     else
94        have_safety_checks="no"
95     fi
96    ],
97    [have_safety_checks="yes"])
98
99 AC_MSG_CHECKING(whether to do safety checking on api parameters)
100 AC_MSG_RESULT($have_safety_checks)
101
102 AM_CONDITIONAL(SAFETY_CHECKS, test "x$have_safety_checks" = "xyes")
103 if test "x$have_safety_checks" = "xyes"; then
104   AC_DEFINE(EINA_SAFETY_CHECKS, 1, [disable safety checks for NULL pointers and like.])
105   EINA_CONFIGURE_SAFETY_CHECKS="#define EINA_SAFETY_CHECKS"
106 fi
107 AC_SUBST(EINA_CONFIGURE_SAFETY_CHECKS)
108
109 with_max_log_level="<unset>"
110 AC_ARG_WITH(internal-maximum-log-level,
111    [AC_HELP_STRING([--with-internal-maximum-log-level=NUMBER],
112                    [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.])],
113    [
114     if test "x${withval}" != "xno"; then
115        if echo "${withval}" | grep '^[[0-9]]\+$' >/dev/null 2>/dev/null; then
116           AC_MSG_NOTICE([ignoring any EINA_LOG() with level greater than ${withval}])
117           AC_DEFINE_UNQUOTED(EINA_LOG_LEVEL_MAXIMUM, ${withval}, [if set, logging is limited to this amount.])
118           with_max_log_level="${withval}"
119        else
120           AC_MSG_ERROR([--with-internal-maximum-log-level takes a decimal number, got "${withval}" instead.])
121        fi
122     fi
123     ], [:])
124
125 AC_ARG_ENABLE([amalgamation],
126    [AC_HELP_STRING([--enable-amalgamation], [enable generation of one single file with all source code in it, helps compiler optimizations.])],
127    [if test "x${enableval}" = "xyes"; then
128        do_amalgamation="yes"
129     else
130        do_amalgamation="no"
131     fi
132    ],
133    [do_amalgamation="no"]
134 )
135 AM_CONDITIONAL(EINA_AMALGAMATION, test "x${do_amalgamation}" = "xyes")
136
137 # Choose best memory pool
138 AC_ARG_ENABLE([default-mempool],
139    [AC_HELP_STRING([--enable-default-mempool], [Default memory allocator could be faster for some computer. @<:@default=disabled@:>@])],
140    [
141     if test "x${enableval}" = "xyes"; then
142        have_default_mempool="yes"
143     else
144        have_default_mempool="no"
145     fi
146    ],
147    [have_default_mempool="no"]
148 )
149 AC_MSG_CHECKING([whether to use default mempool allocator])
150 AC_MSG_RESULT([${have_default_mempool}])
151
152 if test "x${have_default_mempool}" = "xyes" ; then
153    EINA_CONFIGURE_DEFAULT_MEMPOOL="#define EINA_DEFAULT_MEMPOOL"
154 fi
155 AC_SUBST(EINA_CONFIGURE_DEFAULT_MEMPOOL)
156
157 # Report stringshare usage
158 AC_ARG_ENABLE([stringshare-usage],
159    [AC_HELP_STRING([--enable-stringshare-usage], [Report stringshare usage on stringshare shutdown. @<:@default=disabled@:>@])],
160    [
161     if test "x${enableval}" = "xyes"; then
162        have_stringshare_usage="yes"
163     else
164        have_stringshare_usage="no"
165     fi
166    ],
167    [have_stringshare_usage="no"]
168 )
169 AC_MSG_CHECKING([whether to report stringshare usage])
170 AC_MSG_RESULT([${have_stringshare_usage}])
171
172 if test "x${have_stringshare_usage}" = "xyes"; then
173    AC_DEFINE(EINA_STRINGSHARE_USAGE, 1, [Report Eina stringshare usage pattern])
174 fi
175
176 # Check if we want to benchmark on real data
177 enable_benchmark_e17="no"
178 AC_ARG_ENABLE([e17],
179    [AC_HELP_STRING([--enable-e17], [enable heavy benchmark @<:@default=no@:>@])],
180    [
181     if test "x${enableval}" = "xyes" ; then
182        enable_benchmark_e17="yes"
183     else
184        enable_benchmark_e17="no"
185     fi
186    ],
187    [enable_benchmark_e17="no"])
188
189 AC_MSG_CHECKING([whether e17 real data benchmark are built])
190 AC_MSG_RESULT([${enable_benchmark_e17}])
191
192 AM_CONDITIONAL(EINA_ENABLE_BENCHMARK_E17, test "x${enable_benchmark_e17}" = "xyes")
193
194
195 ### Checks for programs
196 AC_PROG_CC
197
198 # pkg-config
199 PKG_PROG_PKG_CONFIG
200
201 # Check whether pkg-config supports Requires.private
202 if $PKG_CONFIG --atleast-pkgconfig-version 0.22; then
203    pkgconfig_requires_private="Requires.private"
204 else
205    pkgconfig_requires_private="Requires"
206 fi
207 AC_SUBST(pkgconfig_requires_private)
208
209 # doxygen program for documentation building
210
211 EFL_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"])
212
213
214 ### Checks for libraries
215
216 # Evil library for compilation on Windows CE
217
218 EFL_EINA_BUILD=""
219 case "$host_os" in
220    mingw* | cegcc*)
221       PKG_CHECK_MODULES([EVIL], [evil])
222       AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed])
223       requirement_eina="evil"
224       EFL_EINA_BUILD="-DEFL_EINA_BUILD"
225    ;;
226 esac
227 AC_SUBST(EFL_EINA_BUILD)
228
229 # Check ememoa memory pool library
230
231 AC_ARG_ENABLE([ememoa],
232    [AC_HELP_STRING([--enable-ememoa], [build ememoa memory pool module @<:@default=yes@:>@])],
233    [
234     if test "x${enableval}" = "xyes" ; then
235        enable_ememoa="yes"
236     else
237        enable_ememoa="no"
238     fi
239    ],
240    [enable_ememoa="yes"]
241 )
242 AC_MSG_CHECKING([whether to use ememoa for memory pool])
243 AC_MSG_RESULT([$enable_ememoa])
244
245 if test "x${enable_ememoa}" = "xyes" ; then
246    PKG_CHECK_MODULES([EMEMOA],
247       [ememoa >= 0.0.26 ],
248       [enable_ememoa="yes"],
249       [enable_ememoa="no"]
250    )
251 fi
252
253 AM_CONDITIONAL(EINA_ENABLE_EMEMOA, test "x${enable_ememoa}" = "xyes")
254 if test "x${enable_ememoa}" = "xyes"; then
255    AC_DEFINE(EINA_EMEMOA_SUPPORT, 1, [Use by the test suite to try ememoa mempool])
256 fi
257
258 ### Checks for header files
259 AC_HEADER_ASSERT
260 AC_HEADER_DIRENT
261 AC_HEADER_TIME
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 AC_CHECK_FUNCS(strlcpy)
339
340 #dlopen and dladdr
341 dlopen_libs=""
342 case "$host_os" in
343    mingw* | cegcc*)
344 # managed by evil
345       AC_DEFINE(HAVE_DLADDR)
346       ;;
347    *)
348       AC_CHECK_FUNCS([dlopen], [res="yes"], [res="no"])
349       if test "x${res}" = "xyes" ; then
350          AC_CHECK_FUNCS([dladdr], [AC_DEFINE(HAVE_DLADDR)])
351       else
352          AC_CHECK_LIB([dl], [dlopen], [res="yes"], [res="no"])
353          if test "x${res}" = "xyes" ; then
354             AC_CHECK_LIB([dl], [dladdr], [AC_DEFINE(HAVE_DLADDR)])
355             dlopen_libs="-ldl"
356          else
357             AC_MSG_ERROR([Cannot find dlopen])
358          fi
359       fi
360       ;;
361 esac
362 AC_SUBST(dlopen_libs)
363
364 EFL_CHECK_FNMATCH([], [AC_MSG_ERROR([Cannot find fnmatch()])])
365
366 # iconv library
367 have_iconv="no"
368 AC_ARG_WITH([iconv-link],
369    AC_HELP_STRING([--with-iconv-link=ICONV_LINK], [explicitly specify an iconv link option]),
370    [
371     LIBS="$withval $LIBS"
372     have_iconv="yes"
373    ])
374
375 AC_MSG_CHECKING(for explicit iconv link options)
376 if test "x${iconv_libs}" = "x" ; then
377    AC_MSG_RESULT([no explicit iconv link option])
378 else
379    AC_MSG_RESULT([$iconv_libs])
380 fi
381
382 if test "x${have_iconv}" = "xno" ; then
383    AC_CHECK_HEADERS([iconv.h], [have_iconv="yes"])
384
385    if test "x${have_iconv}" = "xyes" ; then
386       AC_MSG_CHECKING([whether iconv() is in libc])
387       
388       AC_LINK_IFELSE(
389          [AC_LANG_PROGRAM(
390              [[
391 #include <stdlib.h>
392 #include <iconv.h>
393              ]],
394              [[
395 iconv_t ic;
396 size_t count = iconv(ic, NULL, NULL, NULL, NULL);
397              ]])],
398          [have_iconv="yes"],
399          [have_iconv="no"])
400
401       AC_MSG_RESULT([${have_iconv}])
402    fi
403
404    if test "x${have_iconv}" = "xno" ; then
405       AC_MSG_CHECKING([whether iconv() is in libiconv.a])
406
407       LIBS_save="${LIBS}"
408       LIBS="-liconv $LIBS"
409       AC_LINK_IFELSE(
410          [AC_LANG_PROGRAM(
411              [[
412 #include <stdlib.h>
413 #include <iconv.h>
414              ]],
415              [[
416 iconv_t ic;
417 size_t count;
418 count = iconv(ic, NULL, NULL, NULL, NULL);
419              ]])],
420          [have_iconv="yes"],
421          [
422           have_iconv="no"
423           LIBS=${LIBS_save}
424          ])
425
426       AC_MSG_RESULT([${have_iconv}])
427    fi
428
429    if test "x${have_iconv}" = "xno" ; then
430       AC_MSG_CHECKING([whether iconv() is in libiconv_plug.a])
431
432       LIBS_save="${LIBS}"
433       LIBS="-liconv_plug $LIBS"
434       AC_LINK_IFELSE(
435          [AC_LANG_PROGRAM(
436              [[
437 #include <stdlib.h>
438 #include <iconv.h>
439              ]],
440              [[
441 iconv_t ic;
442 size_t count = iconv(ic, NULL, NULL, NULL, NULL);
443              ]])],
444          [have_iconv="yes"],
445          [
446           have_iconv="no"
447           LIBS=${LIBS_save}
448          ])
449
450       AC_MSG_RESULT([${have_iconv}])
451    fi
452 fi
453
454 if test "x${have_iconv}" = "xyes" ; then
455    AC_DEFINE([HAVE_ICONV], [1], [Set to 1 if iconv library is installed])
456 fi
457
458
459 ### Modules
460
461 if test "x${have_default_mempool}" = "xyes" ; then
462    enable_chained_pool="no"
463    enable_pass_through="static"
464 else
465    enable_chained_pool="static"
466    enable_pass_through="no"
467 fi
468
469 EINA_CHECK_MODULE([chained-pool],   [${enable_chained_pool}], [chained pool])
470 EINA_CHECK_MODULE([ememoa-fixed],   [${enable_ememoa}],       [ememoa fixed])
471 EINA_CHECK_MODULE([ememoa-unknown], [${enable_ememoa}],       [ememoa unknown])
472 EINA_CHECK_MODULE([fixed-bitmap],   [no],                     [fixed bitmap])
473 EINA_CHECK_MODULE([pass-through],   [${enable_pass_through}], [pass through])
474 EINA_CHECK_MODULE([buddy],          [no],                     [buddy])
475
476
477 ### Make the debug preprocessor configurable
478
479 ### Unit tests, coverage and benchmarking
480
481 EFL_CHECK_TESTS([enable_tests="yes"], [enable_tests="no"])
482
483 EFL_CHECK_COVERAGE([${enable_tests}], [enable_coverage="yes"], [enable_coverage="no"])
484 EINA_CFLAGS="${EINA_CFLAGS} ${EFL_COVERAGE_CFLAGS}"
485 EINA_LIBS="${EINA_LIBS} ${EFL_COVERAGE_LIBS}"
486 if test "x$enable_coverage" = "xyes" ; then
487    EINA_CFLAGS="${EINA_CFLAGS} ${EFL_DEBUG_CFLAGS}"
488 fi
489
490 EFL_CHECK_BENCHMARK([enable_benchmark="yes"], [enable_benchmark="no"])
491 EINA_BENCH_MODULE([evas], [${enable_benchmark}], [evas], [enable_benchmark_evas="yes"], [enable_benchmark_evas="no"])
492 EINA_BENCH_MODULE([glib], [${enable_benchmark}], [glib-2.0], [enable_benchmark_glib="yes"], [enable_benchmark_glib="no"])
493
494 AC_SUBST(requirement_eina)
495
496 ### Create the .pc.in file according to the major version
497 #cat > ${srcdir}/eina-${VMAJ}.pc.in << EOF
498 #prefix=@prefix@
499 #exec_prefix=@exec_prefix@
500 #libdir=@libdir@
501 #includedir=@includedir@
502 #
503 #Name: Eina
504 #Description: A Library that implements fast data types and miscellaneous tools
505 #Requires:
506 #Version: @VERSION@
507 #Libs: -L${libdir} -leina
508 #Libs.private: -ldl
509 #Cflags: -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-@VMAJ@/eina
510 #EOF
511
512 AC_CONFIG_FILES([
513 Makefile
514 eina-0.pc
515 eina.spec
516 doc/Makefile
517 src/Makefile
518 src/include/Makefile
519 src/include/eina_config.h
520 src/lib/Makefile
521 src/modules/Makefile
522 src/modules/mp/Makefile
523 src/modules/mp/chained_pool/Makefile
524 src/modules/mp/ememoa_fixed/Makefile
525 src/modules/mp/ememoa_unknown/Makefile
526 src/modules/mp/pass_through/Makefile
527 src/modules/mp/fixed_bitmap/Makefile
528 src/modules/mp/buddy/Makefile
529 src/tests/Makefile
530 ])
531
532 AC_OUTPUT
533
534 #####################################################################
535 ## Info
536
537 echo
538 echo
539 echo
540 echo "------------------------------------------------------------------------"
541 echo "$PACKAGE $VERSION"
542 echo "------------------------------------------------------------------------"
543 echo
544 echo
545 echo "Configuration Options Summary:"
546 echo
547 echo "  Magic debug..........: ${have_magic_debug}"
548 echo "  Safety checks........: ${have_safety_checks}"
549 echo "  Maximum log level....: ${with_max_log_level}"
550 echo "  Report string usage..: ${have_stringshare_usage}"
551 echo "  Default mempool......: ${have_default_mempool}"
552 echo "  Thread Support.......: ${have_pthread} (spinlock: ${have_pthread_spinlock})"
553 echo "  Amalgamation.........: ${do_amalgamation}"
554 echo "  Iconv support........: ${have_iconv}"
555 echo
556 echo "  Documentation........: ${build_doc}"
557 echo "  Tests................: ${enable_tests}"
558 echo "  Coverage.............: ${enable_coverage}"
559 echo "  Benchmark............: ${enable_benchmark}"
560 if test "x${enable_benchmark}" = "xyes" ; then
561 echo "    Glib...............: ${enable_benchmark_glib}"
562 echo "    Evas...............: ${enable_benchmark_evas}"
563 echo "    E17 real data......: ${enable_benchmark_e17}"
564 fi
565 echo
566 echo "  CPU Specific Extensions:"
567 echo "    MMX................: ${have_mmx}"
568 echo "    SSE................: ${have_sse}"
569 echo "    SSE2...............: ${have_sse2}"
570 echo "    ALTIVEC............: ${have_altivec}"
571 echo
572 echo "  Memory pools:"
573 echo "    Chained pool.......: ${enable_chained_pool}"
574 echo "    Ememoa fixed.......: ${enable_ememoa_fixed}"
575 echo "    Ememoa unknown.....: ${enable_ememoa_unknown}"
576 echo "    Fixed bitmap.......: ${enable_fixed_bitmap}"
577 echo "    Pass through.......: ${enable_pass_through}"
578 echo "    Buddy..............: ${enable_buddy}"
579 echo
580 echo "Compilation............: make (or gmake)"
581 echo "  CPPFLAGS.............: $CPPFLAGS"
582 echo "  CFLAGS...............: $CFLAGS"
583 echo "  LDFLAGS..............: $LDFLAGS"
584 echo
585 echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
586 echo "  prefix...............: $prefix"
587 echo
588 if test "x${have_static_module}" = "xyes" ; then
589 echo -e "\0033\01331;31mWarning\0033\01331;0m: You are trying to link statically one or more modules to Eina."
590 echo "         You must know what you are doing, or else you will have a lot of problems."
591 echo "         And dolphins will disappear from the earth."
592 echo "         Think about that."
593 echo
594 fi