SXEmacs v22.1.16 is released!
[sxemacs] / m4 / sxe-mem.m4
1 dnl sxe-mem.m4 -- memory managers
2
3 AC_DEFUN([SXE_CHECK_BDWGC], [dnl
4         ## the actual check
5         AC_REQUIRE([SXE_CHECK_CC_VERSION])
6
7         AC_CACHE_CHECK([for Boehm-Demers-Weiser GC support],
8                 [sxe_cv_feat_bdwgc], [_SXE_CHECK_BDWGC])
9
10         ## quick compiler check
11         if test "$with_experimental_features_bdwgc" = "yes"; then
12                 case "$compiler_version" in
13                 gcc*\ 3.* | gcc*\ 2.* )
14                         AC_MSG_NOTICE([
15 Stop right there, my friend!
16 The powers that be have deemed you unworthy of succeeding in building
17 SXEmacs in BDWGC mode with _that_ compiler ($compiler_version)!
18
19 It's not that we are going to stop you now but this will definitely fail.
20 In order to build a BDWGC-flavoured SXEmacs you want to use a GCC C compiler
21 of the 4th series.
22
23 The alternative is likewisely simple, do NOT enable the BDWGC feature,
24 that is leave --with-experimental-features alone, or explicitly turn off the
25 BDWGC feature like so: --with-experimental-features=nobdwgc.
26
27 I shall now give you a grace period of 32 seconds to consider your answer,
28 will you (from most recommended to least recommended)
29 a) upgrade your gcc, or
30 b) rerun configure not requesting the BDWGC feature, or
31 c) continue the build and promise not to complain?
32                                 ])
33                         sleep 32
34                         AC_MSG_NOTICE([
35 Your time is up and you've made the wrongest decision, possibly, ever!
36 Well, you can still press C-c (control c, that is).
37                                 ])
38                         sleep 5
39                         ;;
40                 esac
41         fi
42
43         AM_CONDITIONAL([HAVE_BDWGC], [test "$have_bdwgc" = "yes"])
44 ])dnl SXE_CHECK_BDWGC
45
46 AC_DEFUN([SXE_CHECK_BDWGC_HEADERS], [dnl
47         ## defines sxe_cv_bdwgc_headers
48
49         AC_MSG_CHECKING([for bdwgc includes directory])
50         if test -n "${with_bdwgc_includes}"; then
51                 SXE_BDWGC_INCLUDES_PATH([${with_bdwgc_includes}])
52         elif test -n "${with_bdwgc}"; then
53                 SXE_BDWGC_INCLUDES_PATH([${with_bdwgc}])
54         else
55                 ## just try ${prefix}/include
56                 SXE_BDWGC_INCLUDES_PATH([${prefix}])
57         fi
58         AC_MSG_RESULT([$BDWGC_CPPFLAGS])
59
60         SXE_DUMP_LIBS
61         CPPFLAGS="$CPPFLAGS ${BDWGC_CPPFLAGS}"
62         SXE_CHECK_HEADERS([gc.h])
63         SXE_CHECK_HEADERS([gc/gc.h])
64         SXE_CHECK_HEADERS([cord.h])
65         SXE_CHECK_HEADERS([gc/cord.h])
66         SXE_RESTORE_LIBS
67
68         if test "$ac_cv_header_gc_gc_h" = "yes" -o \
69                 "$ac_cv_header_gc_h" = "yes"; then
70                 sxe_cv_bdwgc_headers="yes"
71         else
72                 sxe_cv_bdwgc_headers="no"
73         fi
74
75         AC_SUBST([BDWGC_CPPFLAGS])
76 ])dnl SXE_CHECK_BDWGC_HEADERS
77
78 AC_DEFUN([SXE_CHECK_BDWGC_LIBS], [dnl
79         AC_MSG_CHECKING([for bdwgc library])
80         if test -n "$with_bdwgc_libs"; then
81                 SXE_BDWGC_LIBS_PATH([${with_bdwgc_libs}])
82         elif test -n "${with_bdwgc}"; then
83                 SXE_BDWGC_LIBS_PATH([${with_bdwgc}])
84         else
85                 ## just try under ${prefix}/lib
86                 SXE_BDWGC_LIBS_PATH([${prefix}])
87         fi
88         AC_MSG_RESULT([$BDWGC_LDFLAGS])
89
90         AC_CHECK_LIB([gc], [GC_init], [:], [:])
91         AC_CHECK_LIB([gc], [GC_malloc], [:], [:])
92         AC_CHECK_LIB([gc], [GC_malloc_atomic], [:], [:])
93         AC_CHECK_LIB([gc], [GC_malloc_uncollectable], [:], [:])
94         AC_CHECK_LIB([gc], [GC_realloc], [:], [:])
95         AC_CHECK_LIB([gc], [GC_strdup], [:], [:])
96         AC_CHECK_LIB([gc], [GC_free], [:], [:])
97
98         if test "$ac_cv_lib_gc___GC_init" = "yes" -a \
99                 "$ac_cv_lib_gc___GC_malloc" = "yes" -a \
100                 "$ac_cv_lib_gc___GC_malloc_atomic" = "yes" -a \
101                 "$ac_cv_lib_gc___GC_malloc_uncollectable" = "yes" -a \
102                 "$ac_cv_lib_gc___GC_realloc" = "yes" -a \
103                 "$ac_cv_lib_gc___GC_strdup" = "yes" -a \
104                 "$ac_cv_lib_gc___GC_free" = "yes"; then
105                 sxe_cv_bdwgc_libs="yes"
106                 BDWGC_LIBS="-lgc"
107
108         elif test "$ac_cv_lib_gc_GC_init" = "yes" -a \
109                 "$ac_cv_lib_gc_GC_malloc" = "yes" -a \
110                 "$ac_cv_lib_gc_GC_malloc_atomic" = "yes" -a \
111                 "$ac_cv_lib_gc_GC_malloc_uncollectable" = "yes" -a \
112                 "$ac_cv_lib_gc_GC_realloc" = "yes" -a \
113                 "$ac_cv_lib_gc_GC_strdup" = "yes" -a \
114                 "$ac_cv_lib_gc_GC_free" = "yes"; then
115                 sxe_cv_bdwgc_libs="yes"
116                 BDWGC_LIBS="-lgc"
117
118         else
119                 sxe_cv_bdwgc_libs="no"
120         fi
121
122         AC_SUBST([BDWGC_LDFLAGS])
123         AC_SUBST([BDWGC_LIBS])
124 ])dnl SXE_CHECK_BDWGC_LIBS
125
126 AC_DEFUN([_SXE_CHECK_BDWGC], [dnl
127         ## defines have_bdwgc and sxe_cv_feat_bdwgc
128         AC_REQUIRE([SXE_CHECK_BDWGC_HEADERS])
129         AC_REQUIRE([SXE_CHECK_BDWGC_LIBS])
130
131         if test "$sxe_cv_bdwgc_headers" = "yes" -a \
132                 "$sxe_cv_bdwgc_libs" = "yes"; then
133                 AC_DEFINE([HAVE_BDWGC], [1],
134                         [Whether all necessary functions could be found in lgc.])
135                 have_bdwgc="yes"
136         else
137                 have_bdwgc="no"
138         fi
139         sxe_cv_feat_bdwgc="$have_bdwgc"
140 ])dnl _SXE_CHECK_BDWGC
141
142 AC_DEFUN([SXE_BDWGC_INCLUDES_PATH], [dnl
143         ## arg 1 is /path/to/kant/src
144         pushdef([bdwgc_path], [$1])
145
146         if test -d "/[]bdwgc_path[]"; then
147                 path=/[]bdwgc_path[]
148         elif test -d "$(pwd)/[]bdwgc_path[]" -o -d "[]bdwgc_path[]"; then
149                 ## relative thing
150                 path=$(pwd)/[]bdwgc_path
151         elif test -f "/[]bdwgc_path[]"; then
152                 ## PEBKAC
153                 path=/$(dirname []bdwgc_path[])
154         elif test -f "$(pwd)/[]bdwgc_path[]" -o -f "[]bdwgc_path[]"; then
155                 ## still PEBKAC
156                 path=$(dirname $(pwd)/[]bdwgc_path[])
157         elif test -n "[]bdwgc_path[]"; then
158                 path=[]bdwgc_path[]
159         else
160                 ## yuck, path's empty, dunno what to do
161                 path=
162         fi
163
164         if test -d "$path/include" -a \
165                 -e "$path/include/gc/gc.h" -o \
166                 -d "$path/include" -a \
167                 -e "$path/include/gc.h"; then
168                 ## we went to prefix
169                 path="$path/include"
170         elif test -d "$path/../include" -a \
171                 -e "$path/../include/gc/gc.h" -o \
172                 -d "$path/../include" -a \
173                 -e "$path/../include/gc.h"; then
174                 ## we went to directly to the include dir
175                 path="${path}/../include"
176         else
177                 ## whatever
178                 path=
179         fi
180
181         ## simple canonicalisation
182         if test -n "$path"; then
183                 SXE_CANONICALISE_PATH([path])
184                 BDWGC_CPPFLAGS="${BDWGC_CPPFLAGS} -I${path}"
185         fi
186
187         popdef([bdwgc_path])
188 ])dnl SXE_BDWGC_INCLUDES_PATH
189
190 AC_DEFUN([SXE_BDWGC_LIBS_PATH], [dnl
191         ## arg 1 is /path/to/libgc.so
192         pushdef([bdwgc_path], [$1])
193
194         if test -d "/[]bdwgc_path[]"; then
195                 path=/[]bdwgc_path[]
196         elif test -d "$(pwd)/[]bdwgc_path[]" -o -d "[]bdwgc_path[]"; then
197                 ## relative thing
198                 path=$(pwd)/[]bdwgc_path
199         elif test -f "/[]bdwgc_path[]"; then
200                 ## PEBKAC
201                 path=/$(dirname []bdwgc_path[])
202         elif test -f "$(pwd)/[]bdwgc_path[]" -o -f "[]bdwgc_path[]"; then
203                 ## still PEBKAC
204                 path=$(dirname $(pwd)/[]bdwgc_path[])
205         elif test -n "[]bdwgc_path[]"; then
206                 path=[]bdwgc_path[]
207         else
208                 ## yuck, path's empty, dunno what to do
209                 path=
210         fi
211
212         if test -d "$path/lib" -a -e "$path/lib/libgc.so"; then
213                 ## we went to prefix
214                 path="$path/lib"
215         elif test -d "$path/../lib" -a -e "$path/../lib/libgc.so"; then
216                 ## we went to directly to the lib dir
217                 path="${path}/../lib"
218         else
219                 ## whatever
220                 path=
221         fi
222
223         ## simple canonicalisation
224         if test -n "$path"; then
225                 SXE_CANONICALISE_PATH([path])
226                 BDWGC_LDFLAGS="${BDWGC_LDFLAGS} -L${path}"
227         fi
228
229         popdef([bdwgc_path])
230 ])dnl SXE_BDWGC_LIBS_PATH
231
232
233 dnl sxe-mem.m4 ends here