Debian Codegraph @

src/aclocal.m4

raw
1 dnl -*- autoconf -*-
2
3 dnl --------------------------------------------------------------
4 dnl check for existence of complex float
5 AC_DEFUN([ECL_COMPLEX_C99],[
6 if test "$enable_c99complex" != "no" ; then
7 AC_CHECK_TYPES([float complex, double complex, long complex],
8 [enable_c99complex=yes],
9 [enable_c99complex=no],
10 [#include <complex.h>])
11 fi
12 dnl Android have complex types defined, but not all corresponding
13 dnl numeric functions.
14 if test "$enable_c99complex" != "no" ; then
15 AC_CHECK_FUNCS([crealf creal creall cimagf cimag cimagl] \
16 [cabsf cabs cabsl conjf conj conjl csqrtf csqrt csqrtl] \
17 [ccosf ccos ccosl csinf csin csinl ctanf ctan ctanl] \
18 [ccoshf ccosh ccoshl csinhf csinh csinhl ctanhf ctanh ctanhl] \
19 [cexpf cexp cexpl cpowf cpow cpowl clogf clog clogl] \
20 [casinf casin casinl cacosf cacos cacosl catanf catan catanl] \
21 [casinhf casinh casinhl cacoshf cacosh cacoshl catanhf catanh catanhl],
22 [],
23 [enable_c99complex=no])
24 fi
25 if test "$enable_c99complex" != "no" ; then
26 AC_DEFINE([ECL_COMPLEX_FLOAT], [], [ECL_COMPLEX_FLOAT])
27 ECL_ADD_FEATURE(complex-float)
28 AC_MSG_RESULT("C99 Complex Float support is available")
29 else
30 AC_MSG_RESULT("C99 Complex Float support is not available")
31 fi])
32
33 dnl --------------------------------------------------------------
34 dnl http://autoconf-archive.cryp.to/ac_c_long_long_.html
35 dnl Provides a test for the existance of the long long int type and defines HAVE_LONG_LONG if it is found.
36 AC_DEFUN([ECL_LONG_LONG],
37 [AC_MSG_CHECKING(size of long long)
38 if test "x$ECL_LONG_LONG_BITS" = "xno"; then
39 AC_MSG_RESULT(not available)
40 ac_cv_c_long_long=no
41 ECL_LONG_LONG_BITS=""
42 else
43 if test "$GCC" = yes; then
44 ac_cv_c_long_long=yes
45 else
46 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[long long int i;]])],
47 ac_cv_c_long_long=yes,
48 ac_cv_c_long_long=no)
49 fi
50 fi
51 if test $ac_cv_c_long_long = yes; then
52 if test "x$ECL_LONG_LONG_BITS" = "x"; then
53 AC_RUN_IFELSE([AC_LANG_SOURCE([
54 [#include <stdio.h>
55 #include <stdlib.h>
56 int main() {
57 const char *int_type;
58 int bits;
59 unsigned long long x = 1;
60 FILE *f=fopen("conftestval", "w");
61 if (!f) exit(1);
62 for (bits = 0; x; bits++) {
63 x <<= 1;
64 }
65 fprintf(f,"ECL_LONG_LONG_BITS='%d'",bits);
66 exit(0);
67 }]])],[eval "`cat conftestval`"],[],[])
68 fi
69 fi
70 if test "x$ECL_LONG_LONG_BITS" = "x"; then
71 AC_MSG_RESULT(not available)
72 else
73 AC_MSG_RESULT([$ECL_LONG_LONG_BITS])
74 AC_DEFINE([ecl_long_long_t], [long long], [compiler understands long long])
75 AC_DEFINE([ecl_ulong_long_t], [unsigned long long], [compiler understands long long])
76 AC_DEFINE_UNQUOTED([ECL_LONG_LONG_BITS],[$ECL_LONG_LONG_BITS], [ECL_LONG_LONG_BITS])
77 AC_SUBST(ECL_LONG_LONG_BITS)
78 ECL_ADD_FEATURE(long-long)
79 fi
80 ])
81
82 dnl --------------------------------------------------------------
83 dnl Add *feature* for the target executable.
84 AC_DEFUN([ECL_ADD_FEATURE], [
85 LSP_FEATURES="${LSP_FEATURES} :$1"
86 ])
87 dnl --------------------------------------------------------------
88 dnl Add *feature* for conditional compilation.
89 AC_DEFUN([ECL_ADD_COMPILATION_FEATURE], [
90 COMPILATION_FEATURES=":$1 ${COMPILATION_FEATURES}"
91 ])
92
93 dnl --------------------------------------------------------------
94 dnl Add lisp module to compile; if second argument is given,
95 dnl compile module into Lisp library if we don't support shared
96 dnl libraries.
97 dnl
98 AC_DEFUN([ECL_ADD_LISP_MODULE], [
99 ECL_ADD_COMPILATION_FEATURE([wants-$1])
100 ])
101
102 dnl --------------------------------------------------------------
103 dnl Add lisp module and build it into the compiler.
104 dnl
105 AC_DEFUN([ECL_ADD_BUILTIN_MODULE], [
106 ECL_ADD_COMPILATION_FEATURE([builtin-$1])
107 ])
108
109 dnl --------------------------------------------------------------
110 dnl Set up a configuration file for the case when we are cross-
111 dnl compiling
112 dnl
113 AC_DEFUN(ECL_CROSS_CONFIG,[
114 if test "x${cross_compiling}" = "xyes"; then
115 if test -n "${with_cross_config}" -a -f "${with_cross_config}"; then
116 . ${with_cross_config}
117 elif test -f ./cross_config; then
118 . ./cross_config
119 elif test -n "${srcdir}" -a -f ${srcdir}/cross_config; then
120 . ${srcdir}/cross_config
121 else
122 test -z ${with_cross_config} && cross_config=`pwd`/cross_config
123 cat > ${with_cross_config} <<EOF
124 ###
125 ### YOU ARE TRYING TO CROSS COMPILE ECL.
126 ### PLEASE FOLLOW THESE INSTRUCTIONS:
127 ###
128 ### 1) Vital information cannot be determined at configuration time
129 ### because we are not able to run test programs. A file called
130 ### ${cross_config}
131 ### has been created, that you will have to fill out. Please do
132 ### it before invoking "configure" again.
133
134 ### 1.1) Direction of growth of the stack
135 ECL_STACK_DIR=down
136
137 ### 1.2) Choose an integer datatype which is large enough to host a pointer
138 CL_FIXNUM_TYPE=int
139 CL_FIXNUM_BITS=32
140 CL_FIXNUM_MAX=536870911L
141 CL_FIXNUM_MIN=-536870912L
142 CL_SHORT_BITS=32
143 CL_INT_BITS=32
144 CL_LONG_BITS=32
145
146 ### 1.3) Order of bytes within a word
147 ECL_BIGENDIAN=no
148
149 ### 1.4) What characters signal an end of line. May be LF (Linefeed or \\n)
150 ### CR (Carriage return or \\r), and CRLF (CR followed by LF).
151 ECL_NEWLINE=LF
152
153 ### 1.5) Can we guess how many characters are available for reading from
154 ### the FILE structure?
155 ### 0 = no
156 ### 1 = __freadahead((f))
157 ### 2 = (f)->_IO_read_end - (f)->_IO_read_ptr
158 ### 3 = (f)->_r
159 ### 4 = (f)->_cnt
160 ECL_FILE_CNT=0
161
162 ###
163 ### 1.6) Other integer types (set to 'no' to disable)
164 ###
165 ECL_STDINT_HEADER="#include <stdint.h>"
166 ECL_UINT8_T=uint8_t
167 ECL_UINT16_T=uint16_t
168 ECL_UINT32_T=uint32_t
169 ECL_UINT64_T=no
170 ECL_INT8_T=int8_t
171 ECL_INT16_T=int16_t
172 ECL_INT32_T=int32_t
173 ECL_INT64_T=no
174 ECL_LONG_LONG_BITS=no
175
176 ###
177 ### 1.7) Other features (set to 'no' to disable)
178 ###
179 ECL_WORKING_ENVIRON=yes
180
181 ### 2) To cross-compile ECL so that it runs on the system
182 ### ${host}
183 ### you need to first compile ECL on the system in which you are building
184 ### the cross-compiled files, that is
185 ### ${build}
186 ### By default we assume that ECL can be accessed from some directory in
187 ### the path.
188 ECL_TO_RUN=`which ecl`
189 EOF
190 cat ${with_cross_config}
191 AC_MSG_ERROR(Configuration aborted)
192 fi
193 if test "${ECL_TO_RUN}" = "failed"; then
194 AC_MSG_ERROR(The program ECL is not installed in your system)
195 fi
196 ECL_MIN_TO_RUN=`${ECL_TO_RUN} -norc -eval '(progn (print (truename "sys:ecl_min")) (si:quit))' \
197 | grep '\#\P' | sed 's,#P"\(.*\)",\1,'`
198 if test -z "${ECL_MIN_TO_RUN}" -o "${ECL_MIN_TO_RUN}" = "failed" ; then
199 AC_MSG_ERROR(The program ECL-MIN is not installed in your system)
200 fi
201 DPP_TO_RUN=`${ECL_TO_RUN} -norc -eval '(progn (print (truename "sys:dpp")) (si:quit))' \
202 | grep '\#\P' | sed 's,#P"\(.*\)",\1,'`
203 if test -z "${DPP_TO_RUN}" -o "${DPP_TO_RUN}" = "failed" ; then
204 AC_MSG_ERROR(The program DPP is not installed in your system)
205 fi
206 dnl (echo '#!/bin/sh'; echo exec ${ECL_TO_RUN} -eval "'"'(push :cross *features*)'"'" '$''*') > CROSS-COMPILER
207 (echo '#!/bin/sh'; echo exec ${ECL_MIN_TO_RUN} '$''*') > CROSS-COMPILER
208 (echo '#!/bin/sh'; echo exec ${DPP_TO_RUN} '$''*') > CROSS-DPP
209 chmod +x CROSS-COMPILER CROSS-DPP
210 ECL_ADD_COMPILATION_FEATURE([cross])
211 fi
212 ])
213
214 dnl --------------------------------------------------------------
215 dnl Make srcdir absolute, if it isn't already. It's important to
216 dnl avoid running the path through pwd unnecessarily, since pwd can
217 dnl give you automounter prefixes, which can go away.
218 dnl
219 AC_DEFUN(ECL_MAKE_ABSOLUTE_SRCDIR,[
220 AC_SUBST(true_srcdir)
221 AC_SUBST(true_builddir)
222 PWDCMD="pwd";
223 case "${srcdir}" in
224 /* | ?:/* ) ;;
225 * ) srcdir="`(cd ${srcdir}; ${PWDCMD})`";
226 esac
227 if uname -a | grep -i 'mingw' > /dev/null; then
228 true_srcdir=`(cd ${srcdir}; pwd -W)`
229 true_builddir=`pwd -W`
230 else
231 true_srcdir=`(cd ${srcdir}; pwd)`
232 true_builddir=`pwd`
233 fi
234 ])
235
236 dnl
237 dnl --------------------------------------------------------------
238 dnl Define a name for this operating system and set some defaults
239 dnl
240 AC_DEFUN(ECL_GUESS_HOST_OS,[
241 #### Some command variations:
242 AC_SUBST(CP)
243 AC_SUBST(RM)
244 AC_SUBST(MV)
245 AC_SUBST(EXE_SUFFIX)
246 RM="rm -f"
247 CP="cp"
248 MV="mv"
249
250 ### Guess the operating system
251 AC_SUBST(ARCHITECTURE)dnl Type of processor for which this is compiled
252 AC_SUBST(SOFTWARE_TYPE)dnl Type of operating system
253 AC_SUBST(SOFTWARE_VERSION)dnl Version number of operating system
254 AC_SUBST(MACHINE_VERSION)dnl Version of the machine
255
256 AC_SUBST(ECL_LDRPATH)dnl Sometimes the path for finding DLLs must be hardcoded.
257 AC_SUBST(LIBPREFIX)dnl Name components of a statically linked library
258 AC_SUBST(LIBEXT)
259 AC_SUBST(SHAREDEXT)dnl Name components of a dynamically linked library
260 AC_SUBST(SHAREDPREFIX)
261 AC_SUBST(OBJEXT)dnl These are set by autoconf
262 AC_SUBST(EXEEXT)
263 AC_SUBST(INSTALL_TARGET)dnl Which type of installation: flat directory or unix like.
264 AC_SUBST(thehost)
265 AC_SUBST(ECL_GC_DIR)dnl Which version of the Boehm-Weiser library to use
266 AC_SUBST(ECL_DEFAULT_C_STACK_SIZE)dnl Default size of the C stack in bytes
267 AC_SUBST(ECL_MIN,ecl_min)
268 ECL_DEFAULT_C_STACK_SIZE=1048576 dnl Default to 1 MB if we can't set the stack size at runtime
269 ECL_GC_DIR=bdwgc
270 ECL_LDRPATH=''
271 SHAREDEXT='so'
272 SHAREDPREFIX='lib'
273 LIBPREFIX='lib'
274 LIBEXT='a'
275 PICFLAG='-fPIC'
276 THREAD_CFLAGS=''
277 THREAD_LIBS=''
278 THREAD_GC_FLAGS='--enable-threads=posix'
279 INSTALL_TARGET='install'
280 THREAD_OBJ="$THREAD_OBJ threads/thread threads/mutex threads/condition_variable threads/semaphore threads/barrier threads/mailbox threads/rwlock"
281 clibs='-lm'
282 SONAME=''
283 SONAME_LDFLAGS=''
284 case "${host_os}" in
285 linux-android*)
286 thehost='ANDROID'
287 THREAD_CFLAGS='-D_THREAD_SAFE'
288 SHARED_LDFLAGS="-shared ${LDFLAGS}"
289 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
290 ECL_LDRPATH='-Wl,--rpath,~A'
291 clibs="-ldl ${clibs}"
292 CFLAGS="-D_GNU_SOURCE -DPLATFORM_ANDROID -DUSE_GET_STACKBASE_FOR_MAIN -DIGNORE_DYNAMIC_LOADING ${CFLAGS}"
293 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}"
294 SONAME_LDFLAGS="-Wl,-soname,SONAME"
295 ECL_ADD_FEATURE([android])
296 ECL_ADD_FEATURE([unix])
297 ;;
298
299 # libdir may have a dollar expression inside
300 linux*)
301 thehost='linux'
302 THREAD_CFLAGS='-D_THREAD_SAFE'
303 THREAD_LIBS='-lpthread'
304 SHARED_LDFLAGS="-shared ${LDFLAGS}"
305 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
306 ECL_LDRPATH='-Wl,--rpath,~A'
307 clibs="-ldl ${clibs}"
308 # Maybe CFLAGS="-D_ISOC99_SOURCE ${CFLAGS}" ???
309 CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 ${CFLAGS}"
310 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
311 SONAME_LDFLAGS="-Wl,-soname,SONAME"
312 ECL_ADD_FEATURE([unix])
313 ;;
314 gnu*)
315 thehost='gnu'
316 THREAD_CFLAGS='-D_THREAD_SAFE'
317 THREAD_LIBS='-lpthread'
318 SHARED_LDFLAGS="-shared ${LDFLAGS}"
319 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
320 ECL_LDRPATH='-Wl,--rpath,~A'
321 clibs="-ldl ${clibs}"
322 CFLAGS="-D_GNU_SOURCE ${CFLAGS}"
323 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
324 SONAME_LDFLAGS="-Wl,-soname,SONAME"
325 ECL_ADD_FEATURE([unix])
326 ;;
327 kfreebsd*-gnu)
328 thehost='kfreebsd'
329 THREAD_CFLAGS='-D_THREAD_SAFE'
330 THREAD_LIBS='-lpthread'
331 SHARED_LDFLAGS="-shared ${LDFLAGS}"
332 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
333 ECL_LDRPATH='-Wl,--rpath,~A'
334 clibs="-ldl ${clibs}"
335 CFLAGS="-D_GNU_SOURCE ${CFLAGS}"
336 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
337 SONAME_LDFLAGS="-Wl,-soname,SONAME"
338 ECL_ADD_FEATURE([unix])
339 ECL_ADD_FEATURE([bsd])
340 ;;
341 dragonfly*)
342 thehost='dragonfly'
343 THREAD_LIBS='-lpthread'
344 SHARED_LDFLAGS="-shared ${LDFLAGS}"
345 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
346 ECL_LDRPATH="-Wl,--rpath,~A"
347 clibs="${clibs}"
348 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
349 SONAME_LDFLAGS="-Wl,-soname,SONAME"
350 ECL_ADD_FEATURE([unix])
351 ECL_ADD_FEATURE([bsd])
352 ;;
353 freebsd*)
354 thehost='freebsd'
355 THREAD_LIBS='-lpthread'
356 SHARED_LDFLAGS="-shared ${LDFLAGS}"
357 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
358 ECL_LDRPATH="-Wl,--rpath,~A"
359 clibs="${clibs}"
360 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
361 SONAME_LDFLAGS="-Wl,-soname,SONAME"
362 ECL_ADD_FEATURE([unix])
363 ECL_ADD_FEATURE([bsd])
364 ;;
365 netbsd*)
366 thehost='netbsd'
367 THREAD_LIBS='-lpthread'
368 SHARED_LDFLAGS="-shared ${LDFLAGS}"
369 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
370 ECL_LDRPATH="-Wl,--rpath,~A"
371 clibs="${clibs}"
372 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
373 SONAME_LDFLAGS="-Wl,-soname,SONAME"
374 ECL_ADD_FEATURE([unix])
375 ECL_ADD_FEATURE([bsd])
376 ;;
377 openbsd*)
378 thehost='openbsd'
379 THREAD_CFLAGS=''
380 THREAD_LIBS=''
381 SHARED_LDFLAGS="-shared ${LDFLAGS}"
382 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
383 ECL_LDRPATH="-Wl,--rpath,~A"
384 clibs="-lpthread ${clibs}"
385 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
386 SONAME_LDFLAGS="-Wl,-soname,SONAME"
387 ECL_ADD_FEATURE([unix])
388 ECL_ADD_FEATURE([bsd])
389 ;;
390 solaris*)
391 thehost='sun4sol2'
392 THREAD_LIBS='-lrt -lpthread'
393 SHARED_LDFLAGS="-dy -G ${LDFLAGS}"
394 BUNDLE_LDFLAGS="-dy -G ${LDFLAGS}"
395 ECL_LDRPATH='-Wl,-R,~A'
396 TCPLIBS='-lsocket -lnsl -lintl'
397 clibs="${clibs} -ldl"
398 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
399 SONAME_LDFLAGS="-Wl,-soname,SONAME"
400 if test "x$GCC" = "xyes"; then
401 CFLAGS="${CFLAGS} -std=gnu99 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__"
402 SHARED_LDFLAGS="-shared $SHARED_LDFLAGS"
403 BUNDLE_LDFLAGS="-shared $BUNDLE_LDFLAGS"
404 fi
405 ECL_ADD_FEATURE([unix])
406 ;;
407 cygwin*)
408 thehost='cygwin'
409 #enable_threads='no'
410 shared='yes'
411 THREAD_CFLAGS='-D_THREAD_SAFE'
412 THREAD_LIBS='-lpthread'
413 SHARED_LDFLAGS="-shared ${LDFLAGS}"
414 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
415 SHAREDPREFIX=''
416 SHAREDEXT='dll'
417 PICFLAG=''
418 if test "x$host_cpu" = "xx86_64" ; then
419 # Our GMP library is too old and does not support
420 # Windows64 calling conventions.
421 with_c_gmp=yes
422 fi
423 ECL_ADD_FEATURE([cygwin])
424 ECL_ADD_FEATURE([unix])
425 ;;
426 mingw*)
427 thehost='mingw32'
428 dnl We disable fpe because ECL/MinGW has problems with FE_INEXACT
429 with_fpe='no'
430 clibs=''
431 shared='yes'
432 enable_threads='yes'
433 THREAD_CFLAGS='-D_THREAD_SAFE'
434 THREAD_GC_FLAGS='--enable-threads=win32'
435 SHARED_LDFLAGS="-Wl,--stack,${ECL_DEFAULT_C_STACK_SIZE}"
436 BUNDLE_LDFLAGS="-Wl,--stack,${ECL_DEFAULT_C_STACK_SIZE}"
437 SHAREDPREFIX=''
438 SHAREDEXT='dll'
439 PICFLAG=''
440 INSTALL_TARGET='flatinstall'
441 TCPLIBS='-lws2_32'
442 if test "${with_tcp}" = "yes"; then
443 ECL_ADD_FEATURE(wsock)
444 fi
445 ECL_ADD_FEATURE([mingw32])
446 ECL_ADD_FEATURE([win32])
447 ECL_ADD_FEATURE([windows])
448 if test "x$host_cpu" = "xx86_64" ; then
449 ECL_ADD_FEATURE([win64])
450 fi
451 ;;
452 darwin*)
453 thehost='darwin'
454 shared='yes'
455 SHAREDEXT='dylib'
456 PICFLAG='-fPIC -fno-common'
457 SHARED_LDFLAGS="-dynamiclib ${LDFLAGS}"
458 BUNDLE_LDFLAGS="-bundle ${LDFLAGS}"
459 ECL_LDRPATH='-Wl,-rpath,~A'
460 THREAD_CFLAGS='-D_THREAD_SAFE'
461 THREAD_LIBS='-lpthread'
462 # The GMP library has not yet been ported to Intel or Arm-OSX
463 case "`uname -m`" in
464 i386*|x86_64|arm64) gmp_build=none-apple-${host_os};;
465 *) ABI=32;;
466 esac
467 if test "x$ABI" = "x64"; then
468 if echo "$CFLAGS" | grep -v '[ ]*-m64' >/dev/null ; then
469 CFLAGS="-m64 $CFLAGS"
470 LDFLAGS="-m64 $LDFLAGS"
471 fi
472 # Needed when building the old version of GMP.
473 # Should be removed when moving to MPIR
474 ABI="long"
475 fi
476 if test "x$ABI" = "x32"; then
477 ABI="long"
478 fi
479 # The Boehm-Weiser GC library shipped with Fink does not work
480 # well with our signal handler.
481 # enable_boehm=included
482 if test `uname -r | cut -d '.' -f 1` -ge 11; then
483 ECL_GC_DIR=bdwgc
484 fi
485 SONAME="${SHAREDPREFIX}ecl.SOVERSION.${SHAREDEXT}"
486 SONAME_LDFLAGS="-Wl,-install_name,@rpath/SONAME -Wl,-compatibility_version,${PACKAGE_VERSION}"
487 if test "`uname -m`" = arm64; then
488 AC_DEFINE([ECL_C_COMPATIBLE_VARIADIC_DISPATCH], [], [Do the fixed and optional arguments of a variadic function use a different calling convention?])
489 ECL_ADD_FEATURE(c-compatible-variadic-dispatch)
490 fi
491 ECL_ADD_FEATURE(unix)
492 ;;
493 nsk*)
494 # HP Non-Stop platform
495 thehost='nonstop'
496 shared='yes'
497 PICFLAG='-call_shared'
498 THREAD_CFLAGS='-spthread'
499 SHARED_LDFLAGS="-shared ${LDFLAGS}"
500 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
501 ECL_LDRPATH='-Wld=\"-rld_l ~A\"'
502 clibs="-Wld=-lrld ${clibs}"
503 ;;
504 haiku*)
505 thehost='haiku'
506 THREAD_LIBS=''
507 SHARED_LDFLAGS="-shared ${LDFLAGS}"
508 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
509 ECL_LDRPATH="-Wl,--rpath,~A"
510 clibs="-lnetwork"
511 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
512 SONAME_LDFLAGS="-Wl,-soname,SONAME"
513 ECL_ADD_FEATURE(haiku)
514 ;;
515 aix*)
516 PICFLAG='-DPIC'
517 thehost="aix"
518 THREAD_LIBS='-lpthread'
519 SHARED_LDFLAGS="-G -bsvr4 -brtl ${LDFLAGS}"
520 BUNDLE_LDFLAGS="-G -bsvr4 -brtl ${LDFLAGS}"
521 ECL_LDRPATH="-Wl,-R~A"
522 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
523 SONAME_LDFLAGS="-bsvr4 -brtl"
524 ;;
525 *)
526 thehost="$host_os"
527 shared="no"
528 ECL_ADD_FEATURE(unix)
529 ;;
530 esac
531
532 case "${host}" in
533 *-nacl)
534 thehost='linux'
535 THREAD_CFLAGS='-D_THREAD_SAFE'
536 THREAD_LIBS='-lpthread'
537 SHARED_LDFLAGS="-shared ${LDFLAGS}"
538 BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
539 ECL_LDRPATH='-Wl,--rpath,~A'
540 CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 ${CFLAGS}"
541 SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
542 SONAME_LDFLAGS="-Wl,-soname,SONAME"
543 ECL_ADD_FEATURE([nacl])
544 ;;
545 *-pnacl)
546 thehost='linux'
547 THREAD_CFLAGS='-D_THREAD_SAFE'
548 THREAD_LIBS='-lpthread'
549 dnl SHARED_LDFLAGS="-shared ${LDFLAGS}"
550 dnl BUNDLE_LDFLAGS="-shared ${LDFLAGS}"
551 dnl ECL_LDRPATH='-Wl,--rpath,~A'
552 CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 ${CFLAGS}"
553 dnl SONAME="${SHAREDPREFIX}ecl.${SHAREDEXT}.SOVERSION"
554 dnl SONAME_LDFLAGS="-Wl,-soname,SONAME"
555 ECL_ADD_FEATURE([nacl])
556 ECL_ADD_FEATURE([pnacl])
557 ;;
558 i686*-android*)
559 THREAD_LIBS=''
560 CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DANDROID -DPLATFORM_ANDROID -DUSE_GET_STACKBASE_FOR_MAIN -DIGNORE_DYNAMIC_LOADING -DNO_GETCONTEXT -DHAVE_GETTIMEOFDAY -DHAVE_SIGPROCMASK ${CFLAGS}"
561 ECL_ADD_FEATURE([android])
562 ECL_ADD_FEATURE(unix)
563 ;;
564 wasm32-unknown-emscripten)
565 # Non-zero optimization levels seem to be slower in
566 # combination with the binaryen spill-pointers pass.
567 CFLAGS="${CFLAGS} -DECL_C_COMPATIBLE_VARIADIC_DISPATCH -O0"
568 # The default stack size is 64KB, that's too little
569 # for ECL. The spill-pointers pass is needed for the
570 # gc to find pointers on the stack.
571 LDFLAGS="${LDFLAGS} -sSTACK_SIZE=1048576 -sBINARYEN_EXTRA_PASSES=--spill-pointers"
572 ECL_MIN="ecl_min.html"
573 EXEEXT=".html"
574 enable_threads='no'
575 enable_libffi='no'
576 enable_gmp='portable'
577 with_c_gmp=yes
578 SHARED_LDFLAGS="-shared -sSIDE_MODULE ${LDFLAGS}"
579 BUNDLE_LDFLAGS="-shared -sSIDE_MODULE ${LDFLAGS}"
580 PROGRAM_LDFLAGS="-sMAIN_MODULE -sERROR_ON_UNDEFINED_SYMBOLS=0 ${LDFLAGS}"
581 INSTALL_TARGET='flatinstall'
582 AC_DEFINE([ECL_C_COMPATIBLE_VARIADIC_DISPATCH], [], [Do the fixed and optional arguments of a variadic function use a different calling convention?])
583 ECL_ADD_FEATURE(c-compatible-variadic-dispatch)
584 ECL_ADD_FEATURE(emscripten)
585 ;;
586 esac
587
588 if test "${INSTALL_TARGET}" = "flatinstall"; then
589 exec_prefix=""
590 bindir="${exec_prefix}"
591 libdir="${prefix}"
592 includedir="${prefix}"
593 ecldir="${prefix}"
594 fi
595
596 case "${host_cpu}" in
597 alpha*)
598 CFLAGS="${CFLAGS} -mieee";;
599 esac
600 ECL_CFLAGS="-D${thehost}"
601 AC_MSG_CHECKING(for ld flags when building shared libraries)
602 if test "${enable_shared}" = "yes"; then
603 AC_MSG_RESULT([${SHARED_LDFLAGS}])
604 CFLAGS="${CFLAGS} ${PICFLAG}"
605 else
606 shared="no";
607 AC_MSG_RESULT(cannot build)
608 fi
609 LIBS="${clibs} ${LIBS}"
610 AC_MSG_CHECKING(for required libraries)
611 AC_MSG_RESULT([${clibs}])
612 AC_MSG_CHECKING(for architecture)
613 ARCHITECTURE=`echo "${host_cpu}" | tr a-z A-Z` # i386 -> I386
614 AC_MSG_RESULT([${ARCHITECTURE}])
615 AC_MSG_CHECKING(for software type)
616 SOFTWARE_TYPE="$thehost"
617 SOFTWARE_VERSION=""
618 AC_MSG_RESULT([${SOFTWARE_TYPE} / ${SOFTWARE_VERSION}])
619 ])
620
621 dnl
622 dnl --------------------------------------------------------------
623 dnl Check whether the FILE structure has a field with the number of
624 dnl characters left in the buffer.
625 dnl
626 AC_DEFUN(ECL_FILE_STRUCTURE,[
627 AC_SUBST(ECL_FILE_CNT)
628 if test -z "${ECL_FILE_CNT}"; then
629 ECL_FILE_CNT=0
630 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
631 #include <stdio.h>
632 #include <stdio_ext.h>
633 ]], [[
634 FILE *f = fopen("conftestval","w");
635 if (__freadahead((f)))
636 return 1;
637 ]])],[ECL_FILE_CNT=1],[])
638 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
639 FILE *f = fopen("conftestval","w");
640 if ((f)->_IO_read_end - (f)->_IO_read_ptr)
641 return 1;
642 ]])],[ECL_FILE_CNT=2],[])
643 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
644 FILE *f = fopen("conftestval","w");
645 if ((f)->_r)
646 return 1;
647 ]])],[ECL_FILE_CNT=3],[])
648 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
649 FILE *f = fopen("conftestval","w");
650 if ((f)->_cnt)
651 return 1;
652 ]])],[ECL_FILE_CNT=4],[])
653 fi
654 ])
655
656 dnl ---------------------------------------------------------------------
657 dnl Check availability of standard sized integer types of a given width.
658 dnl On success, define the global variables ECL_INTx_T and ECL_UINTx_T to
659 dnl hold the names of the corresponding standard C integer types.
660 AC_DEFUN(ECL_CHECK_SIZED_INTEGER_TYPE,[
661 AC_TYPE_INT$1_T
662 AC_TYPE_UINT$1_T
663 if test "x$ac_cv_c_int$1_t" = xyes; then
664 eval ECL_INT$1_T="int$1_t"
665 eval ECL_UINT$1_T="uint$1_t"
666 AC_DEFINE_UNQUOTED([ecl_int$1_t], [int$1_t], [ecl_int$1_t])
667 AC_DEFINE_UNQUOTED([ecl_uint$1_t], [uint$1_t], [ecl_uint$1_t])
668 ECL_ADD_FEATURE(uint$1-t)
669 fi])
670
671 dnl
672 dnl --------------------------------------------------------------
673 dnl Check the existence of different integer types and that they
674 dnl have the right size;
675 dnl
676 AC_DEFUN(ECL_INTEGER_TYPES,[
677 AC_SUBST(ECL_STDINT_HEADER)
678 AC_CHECK_HEADER([stdint.h],[AC_DEFINE(HAVE_STDINT_H)
679 ECL_STDINT_HEADER="#include <stdint.h>"],[])
680 if test -z "${ECL_STDINT_HEADER}"; then
681 AC_CHECK_HEADER([inttypes.h],[AC_DEFINE(HAVE_INTTYPES_H)
682 ECL_STDINT_HEADER="#include <inttypes.h>"],[])
683 fi
684
685 ECL_CHECK_SIZED_INTEGER_TYPE(8)
686 ECL_CHECK_SIZED_INTEGER_TYPE(16)
687 ECL_CHECK_SIZED_INTEGER_TYPE(32)
688 ECL_CHECK_SIZED_INTEGER_TYPE(64)
689
690 if test "${ECL_UINT32_T}${CL_FIXNUM_BITS}" = "32"; then
691 ECL_UINT32_T="cl_index"
692 ECL_INT32_T="cl_fixnum"
693 fi
694 if test "${ECL_UINT64_T}${CL_FIXNUM_BITS}" = "64"; then
695 ECL_UINT64_T="cl_index"
696 ECL_INT64_T="cl_fixnum"
697 fi
698 if test "${ECL_UINT16_T}${CL_FIXNUM_BITS}" = "16"; then
699 ECL_UINT16_T=$ECL_UINT32_T
700 ECL_INT16_T=$ECL_INT32_T
701 fi
702
703 if test "x${ECL_UINT8_T}" = "x" -o "x${ECL_UINT8_T}" = xno; then
704 AC_MSG_ERROR(Can not build ECL without byte types)
705 fi
706 ])
707 dnl
708 dnl --------------------------------------------------------------
709 dnl Check the direction to which the stack grows (for garbage
710 dnl collection).
711 dnl
712 AC_DEFUN(ECL_STACK_DIRECTION,[
713 AC_MSG_CHECKING(whether stack growns downwards)
714 if test -z "${ECL_STACK_DIR}" ; then
715 AC_RUN_IFELSE([AC_LANG_SOURCE([[
716
717 #include <stddef.h>
718 #include <stdlib.h>
719
720 ptrdiff_t f2(const char *d) {
721 char c[2];
722 return c-d;
723 }
724
725 ptrdiff_t f1(const char *d) {
726 char c[2];
727 return c+1-d;
728 }
729
730 typedef ptrdiff_t (*f_ptr)(const char *);
731 f_ptr f[2] = { f1, f2 };
732
733 ptrdiff_t signo() {
734 char d[1];
735 return f[rand() & 1](d);
736 }
737
738 int main() {
739 if (signo() > 0)
740 return 1;
741 else
742 return 0;
743 }
744 ]])],[ECL_STACK_DIR=down],[ECL_STACK_DIR=up],[])
745 fi
746 case "${ECL_STACK_DIR}" in
747 down|DOWN) AC_MSG_RESULT(yes); AC_DEFINE([ECL_DOWN_STACK], [1], [Stack grows downwards]) ;;
748 up|UP) AC_MSG_RESULT(no) ;;
749 *) AC_MSG_ERROR(Unable to determine stack growth direction)
750 esac])
751
752 dnl
753 dnl --------------------------------------------------------------
754 dnl Check if we can determine the stack size at runtime
755 dnl
756 AC_DEFUN(ECL_STACK_SIZE,[
757 AC_CHECK_HEADER([sys/resource.h],
758 [AC_DEFINE([HAVE_SYS_RESOURCE_H], [], [Define to 1 if you have the <sys/resource.h> header file.])
759 AC_CHECK_DECL([RLIMIT_STACK],
760 [AC_DEFINE([ECL_CAN_SET_STACK_SIZE], [], [Define to 1 if we can set the stack size at runtime.])],
761 [],
762 [#include <sys/resource.h>])],
763 [],[])
764 ])
765
766 dnl
767 dnl ------------------------------------------------------------
768 dnl Find out a setjmp() that does not save signals. It is called
769 dnl in several architectures.
770 AC_DEFUN(ECL_FIND_SETJMP,[
771 AC_SUBST(ECL_SETJMP)
772 AC_SUBST(ECL_LONGJMP)
773 AC_CHECK_FUNC(_longjmp,
774 ECL_SETJMP="_setjmp";ECL_LONGJMP="_longjmp",
775 ECL_SETJMP="setjmp";ECL_LONGJMP="longjmp")])
776
777 dnl
778 dnl --------------------------------------------------------------
779 dnl Guess the right type and size for cl_fixnum. It must be large
780 dnl enough that convertion back and forth to pointer implies no
781 dnl loss of information.
782 AC_DEFUN(ECL_FIXNUM_TYPE,[
783 AC_SUBST(CL_FIXNUM_TYPE)
784 AC_SUBST(CL_FIXNUM_BITS)
785 AC_SUBST(CL_FIXNUM_MAX)
786 AC_SUBST(CL_FIXNUM_MIN)
787 AC_SUBST(CL_SHORT_BITS)
788 AC_SUBST(CL_INT_BITS)
789 AC_SUBST(CL_LONG_BITS)
790 AC_MSG_CHECKING(appropriate type for fixnums)
791 if test -z "${CL_FIXNUM_TYPE}" ; then
792 AC_RUN_IFELSE([AC_LANG_SOURCE([[
793 #include <stdio.h>
794 #include <stdlib.h>
795 int main() {
796 const char *int_type;
797 int bits;
798 FILE *f=fopen("conftestval", "w");
799 if (!f) exit(1);
800 if (sizeof(int) >= sizeof(void*)) {
801 unsigned int t = 1;
802 signed int l = 0;
803 int_type="int";
804 for (bits=1; ((t << 1) >> 1) == t; bits++, t <<= 1);
805 l = (~l) << (bits - 3);
806 #if 1
807 fprintf(f,"CL_FIXNUM_MIN='%d';",l);
808 fprintf(f,"CL_FIXNUM_MAX='%d';",-(l+1));
809 #else
810 l++;
811 fprintf(f,"CL_FIXNUM_MIN='%d';",l);
812 fprintf(f,"CL_FIXNUM_MAX='%d';",-l);
813 #endif
814 } else if (sizeof(long) >= sizeof(void*)) {
815 unsigned long int t = 1;
816 signed long int l = 0;
817 int_type="long int";
818 for (bits=1; ((t << 1) >> 1) == t; bits++, t <<= 1);
819 l = (~l) << (bits - 3);
820 #if 1
821 fprintf(f,"CL_FIXNUM_MIN='%ldL';",l);
822 fprintf(f,"CL_FIXNUM_MAX='%ldL';",-(l+1));
823 #else
824 l++;
825 fprintf(f,"CL_FIXNUM_MIN='%ldL';",l);
826 fprintf(f,"CL_FIXNUM_MAX='%ldL';",-l);
827 #endif
828 #ifdef ECL_LONG_LONG_BITS
829 } else if (sizeof(long long) >= sizeof(void*)) {
830 unsigned long long int t = 1;
831 signed long long int l = 0;
832 int_type="long long";
833 for (bits=1; ((t << 1) >> 1) == t; bits++, t <<= 1);
834 l = (~l) << (bits - 3);
835 # if 1
836 fprintf(f,"CL_FIXNUM_MIN='%lldLL';",l);
837 fprintf(f,"CL_FIXNUM_MAX='%lldLL';",-(l+1));
838 # else
839 l++;
840 fprintf(f,"CL_FIXNUM_MIN='%lldLL';",l);
841 fprintf(f,"CL_FIXNUM_MAX='%lldLL';",-l);
842 # endif
843 #endif
844 } else {
845 exit(1);
846 }
847 fprintf(f,"CL_FIXNUM_TYPE='%s';",int_type);
848 fprintf(f,"CL_FIXNUM_BITS='%d';",bits);
849 {
850 unsigned short x = 1;
851 for (bits = 0; x; bits++) {
852 x <<= 1;
853 }
854 fprintf(f,"CL_SHORT_BITS='%d';",bits);
855 }
856 {
857 unsigned int x = 1;
858 for (bits = 0; x; bits++) {
859 x <<= 1;
860 }
861 fprintf(f,"CL_INT_BITS='%d';",bits);
862 }
863 {
864 unsigned long x = 1;
865 for (bits = 0; x; bits++) {
866 x <<= 1;
867 }
868 fprintf(f,"CL_LONG_BITS='%d'",bits);
869 }
870 exit(0);
871 }]])],[eval "`cat conftestval`"],[],[])
872 fi
873 if test -z "${CL_FIXNUM_TYPE}" ; then
874 AC_MSG_ERROR(There is no appropriate integer type for the cl_fixnum type)
875 fi
876 AC_MSG_RESULT([${CL_FIXNUM_TYPE}])])
877
878 dnl
879 dnl ------------------------------------------------------------
880 dnl Find out what is written for every '\n' character, when
881 dnl opening a text file.
882 dnl
883 AC_DEFUN(ECL_LINEFEED_MODE,[
884 AC_MSG_CHECKING(character sequence for end of line)
885 if test -z "${ECL_NEWLINE}" ; then
886 AC_RUN_IFELSE([AC_LANG_SOURCE([[
887 #include <stdio.h>
888 #include <stdlib.h>
889 int main() {
890 FILE *f = fopen("conftestval","w");
891 int c1, c2;
892 char *output;
893 if (f == NULL) exit(1);
894 fprintf(f, "\n");
895 fclose(f);
896 f = fopen("conftestval","rb");
897 if (f == NULL) exit(1);
898 c1 = fgetc(f);
899 c2 = fgetc(f);
900 fclose(f);
901 f = fopen("conftestval","w");
902 if (f == NULL) exit(1);
903 if (c1 == '\r')
904 if (c2 == EOF)
905 output="CR";
906 else
907 output="CRLF";
908 else
909 output="LF";
910 fclose(f);
911 f = fopen("conftestval","w");
912 if (f == NULL) exit(1);
913 fputs(output, f);
914 fclose(f);
915 exit(0);
916 }
917 ]])],[ECL_NEWLINE=`cat conftestval`],[],[])
918 fi
919 case "${ECL_NEWLINE}" in
920 LF) AC_MSG_RESULT(lf) ;;
921 CR) AC_MSG_RESULT(cr); AC_DEFINE([ECL_NEWLINE_IS_CR], [1], [Define if your newline is CR]) ;;
922 CRLF) AC_MSG_RESULT(cr+lf); AC_DEFINE([ECL_NEWLINE_IS_CRLF], [1], [Define if your newline is CRLF]) ;;
923 *) AC_MSG_ERROR(Unable to determine linefeed mode) ;;
924 esac
925 ])
926
927 dnl
928 dnl ------------------------------------------------------------
929 dnl Find out which program we can use to install INFO files
930 dnl
931 AC_DEFUN(ECL_INSTALL_INFO,[
932 AC_SUBST(INSTALL_INFO)
933 AC_PATH_PROG(INSTALL_INFO, install-info, [/sbin/install-info],
934 [$PATH:/usr/bin:/usr/sbin:/usr/etc:/usr/libexec])
935 ])
936
937 dnl
938 dnl ------------------------------------------------------------
939 dnl Use the configuration scripts in the GMP library for
940 dnl configuring ECL in a compatible way.
941 dnl
942 AC_DEFUN(ECL_GMP_BASED_CONFIG,[
943 AC_MSG_CHECKING([Using the GMP library to guess good compiler/linker flags])
944 if test ! -f gmp/config.status; then
945 AC_MSG_ERROR([Cannot find GMP's configuration file. Aborting])
946 fi
947 GMP_CFLAGS=`grep '^s,@CFLAGS@' gmp/config.status| sed 's&s,@CFLAGS@,\(.*\),;t t&\1&'`
948 GMP_LDFLAGS=`grep '^s,@GMP_LDFLAGS@' gmp/config.status| sed 's&s,@GMP_LDFLAGS@,\(.*\),;t t&\1&'`;
949 # Notice that GMP_LDFLAGS is designed to be passed to libtool, and therefore
950 # some options could be prefixed by -Wc, which means "flag for the compiler".
951 LDFLAGS=`echo ${LDFLAGS} ${GMP_LDFLAGS} | sed 's%-Wc,%%g'`
952 CFLAGS=`echo ${CFLAGS} ${GMP_CFLAGS} | sed 's%-Wc,%%g'`
953 GMP_CFLAGS=""
954 GMP_LDFLAGS=""
955 #host=`grep '^s,@host@' config.status | sed 's&s,@host@,\(.*\),;t t&\1&'`
956 AC_MSG_CHECKING([C/C++ compiler flags])
957 AC_MSG_RESULT([${CFLAGS}])
958 AC_MSG_CHECKING([Linker flags])
959 AC_MSG_RESULT([${LDFLAGS}])
960 ])
961
962 dnl ----------------------------------------------------------------------
963 dnl Choose the type of code to detect floating point exceptions and
964 dnl raise them.
965 dnl
966 AC_DEFUN([ECL_FPE_MODEL],
967 [AC_MSG_CHECKING([for code to detect FP exceptions])
968 case "${host_cpu}" in
969 i686 | i586 | pentium* | athlon* )
970 ECL_FPE_CODE="arch/fpe_x86.c"
971 AC_MSG_RESULT([x86])
972 ;;
973 x86_64* )
974 ECL_FPE_CODE="arch/fpe_x86.c"
975 AC_MSG_RESULT([x86_64])
976 ;;
977 *)
978 ECL_FPE_CODE="arch/fpe_none.c"
979 AC_MSG_RESULT([not available])
980 ;;
981 esac
982 AC_SUBST(ECL_FPE_CODE)
983 ])
984
985 dnl ----------------------------------------------------------------------
986 dnl Decide whether ECL should export SSE intrinsics
987 dnl
988 AC_DEFUN([ECL_SSE],[
989 if test "x$with_sse" = xyes; then
990 AC_MSG_CHECKING([for SSE intrinsics])
991 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
992 #include <xmmintrin.h>
993 #include <emmintrin.h>
994 ]],[[__m128 value;
995 _mm_getcsr();]])],[sse_included=yes],[sse_included=no])
996 if test "$sse_included" = "no"; then
997 OLD_CFLAGS="$CFLAGS"
998 CFLAGS="$CFLAGS -msse2"
999 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1000 #include <xmmintrin.h>
1001 #include <emmintrin.h>
1002 ]],[[__m128 value;
1003 _mm_getcsr();]])],[sse_included=yes],[sse_included=no])
1004 if test "$sse_included" = "no"; then
1005 CFLAGS="$OLD_CFLAGS"
1006 with_sse=no
1007 fi
1008 fi
1009 if test "x$with_sse" = xyes; then
1010 AC_DEFINE([ECL_SSE2], [], [ECL_SSE2])
1011 ECL_ADD_FEATURE(sse2)
1012 AC_MSG_RESULT([yes])
1013 else
1014 AC_MSG_RESULT([no])
1015 fi
1016 fi
1017 ])
1018
1019 dnl ----------------------------------------------------------------------
1020 dnl Check whether we have POSIX read/write locks are available
1021 AC_DEFUN([ECL_PTHREAD_EXTENSIONS],[
1022 AC_CHECK_FUNC( [pthread_rwlock_init], [
1023 AC_CHECK_TYPES([pthread_rwlock_t], [
1024 AC_DEFINE([HAVE_POSIX_RWLOCK], [], [HAVE_POSIX_RWLOCK])
1025 ], [])
1026 ], [])
1027 AC_CHECK_FUNCS([pthread_mutex_timedlock pthread_condattr_setclock])
1028 ])
1029
1030
1031 dnl ----------------------------------------------------------------------
1032 dnl Check "char **environ" is available
1033 AC_DEFUN([ECL_POSIX_ENVIRON],[
1034 AC_MSG_CHECKING(working environ)
1035 if test -z "$ECL_WORKING_ENVIRON"; then
1036 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1037 #include <stdlib.h>
1038 extern char **environ;
1039 int main() {
1040 if (environ)
1041 exit(0);
1042 exit(1);
1043 }]])],[ECL_WORKING_ENVIRON=yes],[ECL_WORKING_ENVIRON=no],[])
1044 fi
1045 AC_MSG_RESULT([$ECL_WORKING_ENVIRON])
1046 if test $ECL_WORKING_ENVIRON = yes ; then
1047 AC_DEFINE([HAVE_ENVIRON], [], [HAVE_ENVIRON])
1048 fi
1049 ])
1050
1051 dnl
1052 dnl --------------------------------------------------------------
1053 dnl Check if we have feenableexcept and the hardware generates
1054 dnl floating point exceptions.
1055 dnl
1056 AC_DEFUN(ECL_FLOATING_POINT_EXCEPTIONS,[
1057 if test "${with_fpe}" = "yes" ; then
1058 AC_MSG_CHECKING(for working feenableexcept)
1059 saved_libs="${LIBS}"
1060 LIBS="-lm"
1061 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1062
1063 #define _GNU_SOURCE
1064 #include <fenv.h>
1065 #include <signal.h>
1066 #include <stdlib.h>
1067
1068 const int traps = FE_DIVBYZERO | FE_OVERFLOW;
1069
1070 void fpe_handler(int code) {
1071 if (code == SIGFPE)
1072 exit(0);
1073 }
1074
1075 double raises_fpe(double x) {
1076 return x / 0.0;
1077 }
1078
1079 int main() {
1080 signal(SIGFPE, fpe_handler);
1081 feclearexcept(traps);
1082 feenableexcept(traps);
1083 raises_fpe(1.0);
1084 return 1;
1085 }
1086 ]])],
1087 [AC_DEFINE([HAVE_FEENABLEEXCEPT], [], [feenableexcept works])
1088 AC_MSG_RESULT(yes)],
1089 [AC_MSG_RESULT(no)],
1090 [AC_MSG_RESULT(only checking if feenableexcept is present due to cross compilation)
1091 AC_CHECK_DECL([feenableexcept],
1092 [AC_DEFINE(HAVE_FEENABLEEXCEPT,[],[feenableexcept is declared])],
1093 [],
1094 [#include <fenv.h>])])
1095 LIBS="${saved_libs}"
1096 fi])
1097
1098 dnl ----------------------------------------------------------------------
1099 dnl Configure libatomic-ops
1100 dnl
1101 AC_DEFUN([ECL_LIBATOMIC_OPS],[
1102 case "${enable_libatomic}" in
1103 auto|system|included) ;;
1104 *) AC_MSG_ERROR( [Invalid value of --enable-libatomic: ${enable_libatomic}] );;
1105 esac
1106 if test "x${enable_threads}" != "xno"; then
1107 AC_CHECK_HEADER([atomic_ops.h],[system_libatomic=yes],[system_libatomic=no],[])
1108 if test "${system_libatomic}" = yes; then
1109 dnl checking that we can link against libatomic_ops requires a
1110 dnl manual AC_LINK_IFELSE call, since all functionality could be
1111 dnl implemented by macros
1112 OLD_LIBS="${LIBS}"
1113 LIBS="${LIBS} -latomic_ops"
1114 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <atomic_ops.h>]],
1115 [[AO_nop();]])],
1116 [system_libatomic=yes],
1117 [system_libatomic=no])
1118 LIBS="${OLD_LIBS}"
1119 fi
1120 AC_MSG_CHECKING( [libatomic-ops version] )
1121 if test "${enable_libatomic}" = auto; then
1122 if test "${system_libatomic}" = yes; then
1123 enable_libatomic=system
1124 else
1125 enable_libatomic=included
1126 fi
1127 fi
1128 if test "${enable_libatomic}" = system; then
1129 if test "${system_libatomic}" = no; then
1130 AC_MSG_ERROR( [Cannot find libatomic-ops in the system] )
1131 enable_libatomic=included
1132 fi
1133 fi
1134 AC_MSG_RESULT( [${enable_libatomic}] )
1135 if test "${enable_libatomic}" = included; then
1136 test -d atomic || mkdir atomic
1137 (destdir=`${PWDCMD}`; cd atomic && CC="${CC} ${PICFLAG}" \
1138 $srcdir/${ECL_GC_DIR}/libatomic*/configure --disable-shared \
1139 --prefix=${destdir} infodir=${destdir}/doc \
1140 --includedir=${destdir}/ecl --with-pic \
1141 --libdir=${destdir} --build=${build_alias} --host=${host_alias} \
1142 CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" CC="${CC} \
1143 ${PICFLAG}")
1144 SUBDIRS="${SUBDIRS} atomic"
1145 if test "${enable_shared}" = "no"; then
1146 LIBRARIES="${LIBRARIES} ${LIBPREFIX}eclatomic.${LIBEXT}"
1147 fi
1148 AC_DEFINE([ECL_LIBATOMIC_OPS_H], [], [ECL_LIBATOMIC_OPS_H])
1149 CORE_LIBS="-leclatomic ${CORE_LIBS}"
1150 else
1151 CORE_LIBS="-latomic_ops ${CORE_LIBS}"
1152 fi
1153 fi
1154 ])
1155
1156 dnl ----------------------------------------------------------------------
1157 dnl Configure included Boehm GC if needed
1158 AC_DEFUN([ECL_BOEHM_GC],[
1159 AC_SUBST(ECL_BOEHM_GC_HEADER)
1160 case "${enable_boehm}" in
1161 yes) enable_boehm=auto;;
1162 auto|system|included) ;;
1163 *) AC_MSG_ERROR( [Invalid value of --enable-boehm: ${enable_boehm}] );;
1164 esac
1165 if test "${enable_boehm}" = auto -o "${enable_boehm}" = system; then
1166 dnl
1167 dnl Try first with the prebuilt versions, if installed and accessible
1168 dnl
1169 system_boehm=yes
1170 if test "${enable_threads}" = no; then
1171 AC_CHECK_LIB( [gc], [GC_malloc],
1172 [], [system_boehm="no"] )
1173 else
1174 AC_CHECK_LIB( [gc], [GC_get_thr_restart_signal],
1175 [], [system_boehm="no"] )
1176 AC_CHECK_LIB( [gc], [GC_register_my_thread],
1177 [], [system_boehm="no"] )
1178 AC_CHECK_LIB( [gc], [GC_set_start_callback],
1179 [], [system_boehm="no"] )
1180 fi
1181 if test "${system_boehm}" = yes; then
1182 AC_CHECK_HEADER([gc/gc.h],[ECL_BOEHM_GC_HEADER='gc/gc.h'],
1183 [system_boehm=no],[])
1184 fi
1185 AC_MSG_CHECKING( [whether we can use the existing Boehm-Weiser library] )
1186 AC_MSG_RESULT( [${system_boehm}] )
1187 if test "${system_boehm}" = "no"; then
1188 if test "${enable_boehm}" = "auto" -o "${enable_boehm}" = "included"; then
1189 enable_boehm="included";
1190 else
1191 AC_MSG_ERROR([System Boehm GC library requested but not found.])
1192 fi
1193 else
1194 FASL_LIBS="${FASL_LIBS} -lgc"
1195 EXTRA_OBJS="${EXTRA_OBJS} alloc_2.${OBJEXT}"
1196 AC_DEFINE(GBC_BOEHM, [1], [Use Boehm's garbage collector])
1197 fi
1198 fi
1199 if test "${enable_boehm}" = "included"; then
1200 dnl
1201 dnl Try here with the version shipped with ECL. Note that we have to use
1202 dnl the same compiler flags and that we will not export this library: it
1203 dnl is installed in the build directory.
1204 dnl
1205 AC_MSG_NOTICE([Configuring included Boehm GC library:])
1206 test -d gc && rm -rf gc
1207 currentdir=`${PWDCMD}`
1208 cd $srcdir/${ECL_GC_DIR};
1209 if test -d configure; then
1210 autoreconf -vif
1211 automake --add-missing
1212 fi;
1213 CFLAGS="$CFLAGS $GC_CFLAGS";
1214 cd $currentdir;
1215 if mkdir gc; then
1216 if (destdir=`${PWDCMD}`; cd gc; \
1217 $srcdir/${ECL_GC_DIR}/configure --disable-shared --prefix=${destdir} \
1218 --includedir=${destdir}/ecl/ --libdir=${destdir} \
1219 --build=${build_alias} --host=${host_alias} --enable-large-config \
1220 CC="${CC} ${PICFLAG}" \
1221 CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
1222 CPPFLAGS="$CPPFLAGS -I${destdir}/ecl" \
1223 ${boehm_configure_flags}); then
1224 ECL_BOEHM_GC_HEADER='ecl/gc/gc.h'
1225 SUBDIRS="${SUBDIRS} gc"
1226 CORE_LIBS="-leclgc ${CORE_LIBS}"
1227 EXTRA_OBJS="${EXTRA_OBJS} alloc_2.${OBJEXT}"
1228 if test "${enable_shared}" = "no"; then
1229 LIBRARIES="${LIBRARIES} ${LIBPREFIX}eclgc.${LIBEXT}"
1230 fi
1231 AC_DEFINE(GBC_BOEHM, [0], [Use Boehm's garbage collector])
1232 else
1233 AC_MSG_ERROR([Unable to configure Boehm-Weiser GC])
1234 fi
1235 fi
1236 fi
1237 if test "${enable_gengc}" != "no" ; then
1238 AC_DEFINE([GBC_BOEHM_GENGC], [], [GBC_BOEHM_GENGC])
1239 fi
1240 AC_MSG_CHECKING([if we use Boehm-Demers-Weiser precise garbage collector]);
1241 if test "${enable_precisegc}" != "no" ; then
1242 AC_DEFINE([GBC_BOEHM_PRECISE], [], [GBC_BOEHM_PRECISE])
1243 AC_MSG_RESULT([yes])
1244 else
1245 AC_MSG_RESULT([no])
1246 fi
1247 if test "${enable_serialization}" != "no" ; then
1248 AC_DEFINE([ECL_EXTERNALIZABLE], [], [Use the serialization framework])
1249 ECL_ADD_FEATURE(externalizable)
1250 fi
1251 ])
1252
1253 dnl ----------------------------------------------------------------------
1254 dnl Configure included Boehm GC if needed
1255 AC_DEFUN([ECL_LIBFFI],[
1256 AC_SUBST(ECL_LIBFFI_HEADER)
1257 case "${enable_libffi}" in
1258 yes) enable_libffi=auto;;
1259 no|auto|system|included) ;;
1260 *) AC_MSG_ERROR( [Invalid value of --enable-dffi: ${enable_libffi}] );;
1261 esac
1262 if test "${enable_libffi}" = auto -o "${enable_libffi}" = system; then
1263 dnl
1264 dnl Try first with the prebuilt versions, if installed and accessible
1265 dnl
1266 AC_CHECK_LIB( ffi, ffi_closure_alloc, [system_libffi=yes], [system_libffi=no] )
1267 if test "${system_libffi}" = yes; then
1268 AC_CHECK_HEADER([ffi/ffi.h],[ECL_LIBFFI_HEADER='ffi/ffi.h'],[],[])
1269 if test -z "$ECL_LIBFFI_HEADER"; then
1270 AC_CHECK_HEADER([ffi.h],[ECL_LIBFFI_HEADER='ffi.h'],[system_libffi=no],[])
1271 fi
1272 fi
1273 AC_MSG_CHECKING( [whether we can use the existing libffi library] )
1274 AC_MSG_RESULT( [${system_libffi}] )
1275 if test "${system_libffi}" = "no"; then
1276 if test "${enable_libffi}" = "auto"; then
1277 enable_libffi="included";
1278 else
1279 AC_MSG_ERROR([System libffi library requested but not found.])
1280 fi
1281 else
1282 FASL_LIBS="${FASL_LIBS} -lffi"
1283 fi
1284 fi
1285 if test "${enable_libffi}" = "included"; then
1286 dnl
1287 dnl Try here with the version shipped with ECL. Note that we have to use
1288 dnl the same compiler flags and that we will not export this library: it
1289 dnl is installed in the build directory.
1290 dnl
1291 AC_MSG_NOTICE([Configuring included libffi library:])
1292 test -d libffi && rm -rf libffi
1293 if mkdir libffi; then
1294 if (destdir=`${PWDCMD}`; cd libffi; \
1295 $srcdir/libffi/configure --disable-shared --prefix=${destdir} \
1296 --includedir=${destdir}/ecl/ --libdir=${destdir} --build=${build_alias} \
1297 --host=${host_alias} --disable-multi-os-directory --disable-docs \
1298 CC="${CC} ${PICFLAG}" CFLAGS="$CFLAGS" \
1299 LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS"); then
1300 ECL_LIBFFI_HEADER='ecl/ffi.h'
1301 SUBDIRS="${SUBDIRS} libffi"
1302 CORE_LIBS="-leclffi ${CORE_LIBS}"
1303 EXTRA_OBJS="${EXTRA_OBJS} alloc_2.${OBJEXT}"
1304 if test "${enable_shared}" = "no"; then
1305 LIBRARIES="${LIBRARIES} ${LIBPREFIX}eclffi.${LIBEXT}"
1306 fi
1307 fi
1308 fi
1309 fi
1310 if test -z "${ECL_LIBFFI_HEADER}"; then
1311 AC_MSG_WARN([Unable to configure or find libffi library; disabling dynamic FFI])
1312 else
1313 AC_DEFINE([HAVE_LIBFFI], [], [HAVE_LIBFFI])
1314 ECL_ADD_FEATURE(dffi)
1315 fi
1316 ])
1317