summaryrefslogtreecommitdiffstats
path: root/kdecore/malloc/configure.in.in
blob: d669f8daaa0b4f2ffe7f85f1fe3e1043ba031369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
dnl --enable-fast-malloc      - depends on $KDE_MALLOC
dnl --disable-fast-malloc     - disabled
dnl --enable-fast-malloc=full - enabled always
dnl
dnl gcc3.0 needs -finline-limit=100000 (large num)

kde_fast_malloc=
AC_ARG_ENABLE(fast-malloc,
    [  --enable-fast-malloc    Use own malloc implementation : yes,no,full,debug],
    [
    if test "$enableval" = "full"; then
        kde_fast_malloc=full
    elif test "$enableval" = "yes"; then
        kde_fast_malloc=yes
    elif test "$enableval" = "debug"; then
        kde_fast_malloc=debug
    else
        kde_fast_malloc=no
    fi
    ],
    [
    kde_fast_malloc=notgiven
    ])

dnl gcc needed for __inline__
if test "$kde_fast_malloc" != "no"; then
    if test "$GCC" != "yes"; then
        if test "$kde_fast_malloc" = "notgiven"; then
            kde_fast_malloc=no
        else
            AC_MSG_ERROR([Fast malloc needs GCC.])
            kde_fast_malloc=no
        fi
    fi
fi

if test "$kde_fast_malloc" != "no"; then
dnl platforms for which there's a spinlock implementation
    case $target_cpu in
        i?86)
            AC_DEFINE(KDE_MALLOC_X86, 1, [The platform is x86])
            ;;
        *)
            if test "$kde_fast_malloc" = "notgiven"; then
                kde_fast_malloc=no
            else
                AC_MSG_ERROR([Fast malloc is not supported on this platform (missing spinlock implementation).])
            fi
            ;;
    esac
dnl warn on untested platforms
    case $target_os in
        linux*) ;;
        freebsd*) ;;
        *)
            if test "$kde_fast_malloc" = "notgiven"; then
                kde_fast_malloc=no
            else
                AC_MSG_WARN([Fast malloc is not tested on this platform. The build may fail or the executables may crash.])
            fi
            ;;
    esac
fi

if test "$kde_fast_malloc" = "yes" -o "$kde_fast_malloc" = "notgiven" -o "$kde_fast_malloc" = "debug"; then
dnl $KDE_MALLOC needs glibc (__libc_malloc etc.)
    AC_CACHE_CHECK([if the libc is glibc],kde_cv_libc_glibc,
        [AC_TRY_COMPILE(
            [#include<stdlib.h>],
            [
            #ifndef __GLIBC__
            error no glibc
            #endif
            ],
            [kde_cv_libc_glibc=yes],
            [kde_cv_libc_glibc=no])
        ])
    if test "$kde_cv_libc_glibc" = "yes"; then
        AC_DEFINE(KDE_MALLOC_GLIBC, 1, [The libc used is glibc])
    else
        if test "$kde_fast_malloc" = "notgiven"; then
            kde_fast_malloc=notgiven_full
        elif test "$enableval" = "debug"; then
            AC_MSG_WARN([This libc is not supported for fast malloc. Runtime disabling won't work.])
            kde_fast_malloc=debug_full
        else
            AC_MSG_ERROR([This libc is not supported for fast malloc. Either use --enable-fast-malloc=full, or don't use it at all.])
        fi
    fi
fi

if test "$kde_fast_malloc" = "notgiven"; then
    #kde_fast_malloc=yes
    kde_fast_malloc=no
fi
if test "$kde_fast_malloc" = "notgiven_full"; then
    if test "$kde_use_debug_code" = "no"; then
        #kde_fast_malloc=full
        kde_fast_malloc=no
    else
        kde_fast_malloc=no
    fi
fi

AC_MSG_CHECKING(whether to enable fast malloc)
if test "$kde_fast_malloc" = "yes"; then
    AC_MSG_RESULT(yes)
elif test "$kde_fast_malloc" = "full"; then
    AC_MSG_RESULT([yes(full)])
elif test "$kde_fast_malloc" = "debug"; then
    AC_MSG_RESULT([yes(debug)])
elif test "$kde_fast_malloc" = "debug_full"; then
    AC_MSG_RESULT([yes(full+debug)])
else
    AC_MSG_RESULT(no)
fi

if test "$kde_fast_malloc" != "no"; then
    AC_DEFINE(KDE_MALLOC, 1, [Use own malloc implementation])
fi

if test "$kde_fast_malloc" = "debug" -o "$kde_fast_malloc" = "debug_full"; then
    AC_DEFINE(KDE_MALLOC_DEBUG, 1, [Enable debugging in fast malloc])
fi

if test "$kde_fast_malloc" = "full" -o "$kde_fast_malloc" = "debug_full"; then
    AC_DEFINE(KDE_MALLOC_FULL, 1, [Make alloc as fast as possible])
fi

dnl -finline-limit=<large num> is needed for gcc3 in order to inline large functions
KDE_CHECK_COMPILER_FLAG(finline-limit=100000,
    [KDE_FORCE_INLINE="-finline-limit=100000"],
    [KDE_FORCE_INLINE= ])
AC_SUBST(KDE_FORCE_INLINE)