1 dnl Process this file with autoconf to produce a configure script.
7 [ --with-baseruby=RUBY use RUBY as baseruby; RUBY is the pathname of ruby],
14 AC_MSG_ERROR(need ruby)
21 test "`$BASERUBY -e 'p 42' 2>/dev/null`" = 42 ||
22 BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
25 AC_DEFUN([RUBY_MINGW32],
28 AC_CACHE_CHECK(for mingw32 environment, rb_cv_mingw32,
33 ], rb_cv_mingw32=yes,rb_cv_mingw32=no)
35 test "$rb_cv_mingw32" = yes && target_os="mingw32"
39 AC_DEFUN([RUBY_CPPOUTFILE],
40 [AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
42 CPPFLAGS='-o conftest.i'
43 AC_TRY_CPP([], rb_cv_cppoutfile=yes, rb_cv_cppoutfile=no)
46 if test "$rb_cv_cppoutfile" = yes; then
47 CPPOUTFILE='-o conftest.i'
48 elif test "$rb_cv_cppoutfile" = no; then
49 CPPOUTFILE='> conftest.i'
50 elif test -n "$rb_cv_cppoutfile"; then
51 CPPOUTFILE="$rb_cv_cppoutfile"
53 AC_SUBST(CPPOUTFILE)])
55 AC_DEFUN([RUBY_PROG_GNU_LD],
56 [AC_CACHE_CHECK(whether the linker is GNU ld, rb_cv_prog_gnu_ld,
57 [if `$CC $CFLAGS $CPPFLAGS $LDFLAGS --print-prog-name=ld 2>&1` -v 2>&1 | grep "GNU ld" > /dev/null; then
63 GNU_LD=$rb_cv_prog_gnu_ld
67 rb_version=`grep RUBY_VERSION $srcdir/version.h`
68 MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
69 MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
70 TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
71 if test "$MAJOR" = ""; then
72 AC_MSG_ERROR(could not determine MAJOR number from version.h)
74 if test "$MINOR" = ""; then
75 AC_MSG_ERROR(could not determine MINOR number from version.h)
77 if test "$TEENY" = ""; then
78 AC_MSG_ERROR(could not determine TEENY number from version.h)
83 dnl checks for alternative programs
84 AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
93 dnl If the user switches compilers, we can't believe the cache
94 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
96 AC_MSG_ERROR(cached CC is different -- throw away $cache_file
97 (it is also a good idea to do 'make clean' before compiling))
100 if test "$program_prefix" = NONE; then
105 target_os=`echo $target_os | sed 's/linux-gnu$/linux/;s/linux-gnu/linux-/'`
106 ac_install_sh='' # unusable for extension libraries.
108 ifelse(currently,disabled, [
109 dnl checks for fat-binary
110 AC_ARG_ENABLE(fat-binary,
111 [ --enable-fat-binary=ARCHS
112 build an Apple/NeXT Multi Architecture Binary (MAB);
113 ARCHS is a comma-delimited list of architectures for
114 which to build; if ARCHS is omitted, then the package
115 will be built for all architectures supported by the
116 platform ("ppc" for MacOS/X and Darwin; "ppc,i386"
117 for Rhapsody; "m68k,i386,sparc" for OpenStep;
118 "m68k,i386,sparc,hppa" for NextStep); if this option
119 is disabled or omitted entirely, then the package
120 will be built only for the target platform],
121 [fat_binary=$enableval], [fat_binary=no])
122 if test "$fat_binary" != no; then
124 AC_MSG_CHECKING([target architectures])
126 # Respect TARGET_ARCHS setting from environment if available.
127 if test -z "$TARGET_ARCHS"; then
128 # Respect ARCH given to --enable-fat-binary if present.
129 if test "$fat_binary" != yes; then
130 TARGET_ARCHS=`echo "$fat_binary" | tr ',' ' '`
132 # Choose a default set of architectures based upon platform.
138 TARGET_ARCHS="ppc i386"
141 TARGET_ARCHS="m68k i386 sparc"
144 TARGET_ARCHS="m68k i386 sparc hppa"
152 AC_MSG_RESULT([$TARGET_ARCHS])
154 # /usr/lib/arch_tool -archify_list $TARGET_ARCHS
156 for archs in $TARGET_ARCHS
158 ARCH_FLAG="$ARCH_FLAG -arch $archs"
160 AC_DEFINE(NEXT_FAT_BINARY)
165 i?86) frame_address=yes;;
166 *) frame_address=no;;
168 AC_ARG_ENABLE(frame-address,
169 [ --enable-frame-address use GCC __builtin_frame_address(). ],
170 [frame_address=$enableval])
171 if test $frame_address = yes; then
172 AC_DEFINE(USE_BUILTIN_FRAME_ADDRESS)
177 dnl Checks for programs.
179 if test x"${build}" != x"${host}"; then
180 AC_CHECK_TOOL(CC, gcc)
184 AC_PROG_GCC_TRADITIONAL
185 if test "$GCC" = yes; then
195 : ${COUTFLAG=${OUTFLAG}}
201 AC_CHECK_TOOL(RANLIB, ranlib, :)
202 AC_CHECK_TOOL(AR, ar)
203 if test -z "$AR"; then
204 AC_CHECK_PROGS(AR, aal, ar)
207 AC_CHECK_TOOL(AS, as)
213 AC_CHECK_TOOL(NM, nm)
214 AC_CHECK_TOOL(WINDRES, windres)
215 AC_CHECK_TOOL(DLLWRAP, dllwrap)
216 target_cpu=`echo $target_cpu | sed s/i.86/i386/`
219 test "$rb_cv_msvcrt" = "" && unset rb_cv_msvcrt
220 AC_CHECK_TOOL(OBJDUMP, objdump)
221 AC_CACHE_CHECK(for mingw32 runtime DLL, rb_cv_msvcrt, [
222 AC_TRY_LINK([#include <stdio.h>],
223 [FILE* volatile f = stdin; return 0;],
224 [rb_cv_msvcrt=`$OBJDUMP -p conftest$ac_exeext |
226 sed -n '/^[[ ]]*dll name: \(msvc.*\)\.dll$/{s//\1/p;q;}'`],
227 [rb_cv_msvcrt=msvcrt])
228 test "$rb_cv_msvcrt" = "" && rb_cv_msvcrt=msvcrt])
230 : ${enable_shared=yes}
233 AC_CHECK_TOOL(NM, nm, /usr/ccs/bin/nm, /usr/ccs/bin:$PATH)
236 # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
237 AC_DEFINE(__HIUX_MPP__)
245 # checks for UNIX variants that set C preprocessor variables
246 AC_USE_SYSTEM_EXTENSIONS
248 AC_SUBST(RM, ['rm -f'])
253 MAKEDIRS='install -d'
257 dnl check for large file stuff
258 mv confdefs.h confdefs1.h
261 mv confdefs.h largefile.h
262 mv confdefs1.h confdefs.h
263 cat largefile.h >> confdefs.h
272 AC_CHECK_TYPES([long long, off_t])
274 AC_CHECK_SIZEOF(int, 4)
275 AC_CHECK_SIZEOF(short, 2)
276 AC_CHECK_SIZEOF(long, 4)
277 AC_CHECK_SIZEOF(long long, 0)
278 AC_CHECK_SIZEOF(__int64, 0)
279 AC_CHECK_SIZEOF(off_t, 0)
280 AC_CHECK_SIZEOF(void*, 4)
281 AC_CHECK_SIZEOF(float, 4)
282 AC_CHECK_SIZEOF(double, 8)
283 AC_CHECK_SIZEOF(time_t, 0)
285 dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
286 AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
288 [AC_DEFINE_UNQUOTED(rb_[$1], [$1])],
289 [AC_DEFINE_UNQUOTED(rb_[$1], [$2])],
291 AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
294 [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
295 [$4], [(rb_[$1])-1 > 0])],
297 if test x"$t" = x; then
299 [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
300 [$4], [sizeof(rb_[$1]) > sizeof(long)])],
303 if test x"$t" = x; then
305 [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
306 [$4], [sizeof(rb_[$1]) == sizeof(long)])],
309 if test x"$t" = x; then
312 rb_cv_[$1]_convertible=${u}${t}])
313 AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)])
314 AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)])
316 RUBY_REPLACE_TYPE(pid_t, int, PIDT)
317 RUBY_REPLACE_TYPE(uid_t, int, UIDT)
318 RUBY_REPLACE_TYPE(gid_t, int, GIDT)
320 AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
321 [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
322 rb_cv_have_prototypes=yes,
323 rb_cv_have_prototypes=no)])
324 if test "$rb_cv_have_prototypes" = yes; then
325 AC_DEFINE(HAVE_PROTOTYPES)
328 AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
329 [AC_TRY_COMPILE([#define paste(a,b) a##b],
330 [int xy = 1; return paste(x,y);],
331 rb_cv_tokenpaste=ansi,
332 rb_cv_tokenpaste=knr)])
333 if test "$rb_cv_tokenpaste" = ansi; then
334 AC_DEFINE(TOKEN_PASTE(x,y),[x##y])
336 AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
339 AC_CACHE_CHECK(stringization, rb_cv_stringization, [
340 rb_cv_stringization=no
341 for string in "#expr" '"expr"'; do
343 AC_LANG_BOOL_COMPILE_TRY([
344 #define STRINGIZE0(expr) $string
345 #define STRINGIZE(expr) STRINGIZE0(expr)
346 #undef real_test_for_stringization
347 #define test_for_stringization -.real_test_for_stringization.-
348 const char stringized[[]] = STRINGIZE(test_for_stringization);
349 ], [sizeof(stringized) == 32])],
350 [rb_cv_stringization="$string"; break],
351 [rb_cv_stringization=no])
354 AC_DEFINE(STRINGIZE(expr),STRINGIZE0(expr))
355 if test x"$rb_cv_stringization" != xno -a "$rb_cv_stringization" != "#expr"; then
356 AC_DEFINE_UNQUOTED(STRINGIZE0(expr),$rb_cv_stringization)
357 AC_DEFINE(OLD_FASHIONED_STRINGIZATION,1)
360 AC_CACHE_CHECK([string literal concatenation],
361 rb_cv_string_literal_concatenation, [
363 AC_LANG_BOOL_COMPILE_TRY([
364 const char concatenated_literal[[]] = "literals" "to"
365 "be" "concatenated.";
366 ], [sizeof(concatenated_literal) == 26])],
367 [rb_cv_string_literal_concatenation=yes],
368 [rb_cv_string_literal_concatenation=no])]
370 if test "$rb_cv_string_literal_concatenation" = no; then
371 AC_DEFINE(NO_STRING_LITERAL_CONCATENATION,1)
374 AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
377 int foo(int x, ...) {
385 ], [return foo(10, "", 3.14);],
388 if test "$rb_cv_stdarg" = yes; then
389 AC_DEFINE(HAVE_STDARG_PROTOTYPES)
392 AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
394 [AS_VAR_PUSHDEF([attrib],[$2])], dnl
395 [AS_VAR_PUSHDEF([attrib],[FUNC_]AS_TR_CPP($1))] dnl
398 [AS_VAR_PUSHDEF([rbcv],[$3])], dnl
399 [AS_VAR_PUSHDEF([rbcv],[rb_cv_func_][$1])]dnl
401 AC_CACHE_CHECK(for [$1] function attribute, rbcv,
403 if test "${ac_c_werror_flag+set}"; then
404 rb_c_werror_flag="$ac_c_werror_flag"
406 unset rb_c_werror_flag
409 for mac in "__attribute__ (($1)) x" "x __attribute__ (($1))" "__declspec($1) x" x; do
411 [#define ]attrib[(x) $mac
412 ]attrib[(void conftest_attribute_check(void));], [],
413 [rbcv="$mac"; break])
415 if test "${rb_c_werror_flag+set}"; then
416 ac_c_werror_flag="$rb_c_werror_flag"
418 unset ac_c_werror_flag
421 AC_DEFINE_UNQUOTED(attrib[(x)], $rbcv)
422 AS_VAR_POPDEF([attrib])
423 AS_VAR_POPDEF([rbcv])
426 RUBY_FUNC_ATTRIBUTE(noreturn, NORETURN)
427 RUBY_FUNC_ATTRIBUTE(deprecated, DEPRECATED)
428 RUBY_FUNC_ATTRIBUTE(noinline, NOINLINE)
429 RUBY_FUNC_ATTRIBUTE(stdcall)
430 RUBY_FUNC_ATTRIBUTE(cdecl)
431 RUBY_FUNC_ATTRIBUTE(fastcall)
433 AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
434 [rb_cv_ruby_extern=no
435 for mac in "__attribute__((dllimport))" "__declspec(dllimport)"; do
437 [extern $mac void conftest(void);],
438 [rb_cv_ruby_extern="extern $mac"; break])
440 test "x$rb_cv_ruby_extern" = xno || AC_DEFINE_UNQUOTED(RUBY_EXTERN, $rb_cv_ruby_extern)
442 XCFLAGS="$XCFLAGS -DRUBY_EXPORT"
444 dnl Check whether we need to define sys_nerr locally
445 AC_CHECK_DECLS([sys_nerr], [], [], [$ac_includes_default
450 AC_CACHE_CHECK([whether pthread should be enabled by default],
451 rb_cv_enable_pthread_default,
453 #include <osreldate.h>
454 #if __FreeBSD_version < 502102
455 #error pthread should be disabled on this platform
458 rb_cv_enable_pthread_default=yes,
459 rb_cv_enable_pthread_default=no)])
460 enable_pthread_default=$rb_cv_enable_pthread_default
463 enable_pthread_default=no
466 enable_pthread_default=yes
470 AC_ARG_ENABLE(pthread,
471 [ --enable-pthread use pthread library.],
472 [enable_pthread=$enableval], [enable_pthread=$enable_pthread_default])
474 dnl Checks for libraries.
479 darwin*) LIBS="-lobjc $LIBS"
480 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE"
481 AC_TRY_CPP([#include <AvailabilityMacros.h>
482 #if MAC_OS_X_VERSION_MAX_ALLOWED <= 1040
484 [!<===== pre OS X 10.4 =====>]
488 test "x$target_cpu" = xppc && ac_cv_header_ucontext_h=no
491 AC_DEFINE(BROKEN_SETREUID, 1)
492 AC_DEFINE(BROKEN_SETREGID, 1)
495 hpux*) LIBS="-lm $LIBS"
497 human*) ac_cv_func_getpgrp_void=yes
498 ac_cv_func_setitimer=no
500 beos*) ac_cv_func_link=no;;
502 mingw*) LIBS="-lshell32 -lws2_32 $LIBS"
503 ac_cv_header_a_out_h=no
504 ac_cv_header_pwd_h=no
505 ac_cv_header_utime_h=no
506 ac_cv_header_sys_ioctl_h=no
507 ac_cv_header_sys_param_h=no
508 ac_cv_header_sys_resource_h=no
509 ac_cv_header_sys_select_h=no
510 ac_cv_header_sys_time_h=no
511 ac_cv_header_sys_times_h=no
513 ac_cv_func_waitpid=yes
515 ac_cv_func_snprintf=yes
516 ac_cv_func_vsnprintf=yes
517 ac_cv_func_seekdir=yes
518 ac_cv_func_telldir=yes
521 ac_cv_func_finite=yes
523 ac_cv_func_truncate=yes
524 ac_cv_func_fseeko=yes
525 ac_cv_func_ftello=yes
526 ac_cv_lib_crypt_crypt=no
527 ac_cv_func_getpgrp_void=no
528 ac_cv_func_setpgrp_void=yes
529 ac_cv_func_memcmp_working=yes
530 ac_cv_lib_dl_dlopen=no
532 rb_cv_negative_time_t=no
535 os2-emx*) LIBS="-lm $LIBS"
536 ac_cv_lib_dir_opendir=no;;
537 msdosdjgpp*) LIBS="-lm $LIBS"
538 ac_cv_func_getpgrp_void=yes
539 ac_cv_func_setitimer=no
540 ac_cv_sizeof_rlim_t=4
542 ac_cv_func_setrlimit=no
544 bsdi*) LIBS="-lm $LIBS"
545 AC_DEFINE(BROKEN_SETREUID, 1)
546 AC_DEFINE(BROKEN_SETREGID, 1)
547 ac_cv_sizeof_rlim_t=8;;
548 freebsd*) LIBS="-lm $LIBS"
549 AC_CACHE_CHECK([whether -lxpg4 has to be linked],
550 rb_cv_lib_xpg4_needed,
552 #include <osreldate.h>
553 #if __FreeBSD_version < 400020 || \
554 (__FreeBSD_version >= 500000 && __FreeBSD_version < 500005)
558 rb_cv_lib_xpg4_needed=no,
559 rb_cv_lib_xpg4_needed=yes,
560 rb_cv_lib_xpg4_needed=yes)])
561 if test "$rb_cv_lib_xpg4_needed" = yes; then
562 AC_CHECK_LIB(xpg4, setlocale)
565 dragonfly*) LIBS="-lm $LIBS"
567 bow) ac_cv_func_setitimer=no
569 superux*) ac_cv_func_setitimer=no
571 *) LIBS="-lm $LIBS";;
573 AC_CHECK_LIB(crypt, crypt)
574 AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
575 AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
576 AC_CHECK_LIB(socket, socketpair) # SunOS/Solaris
577 AC_CHECK_LIB(rt, clock_gettime) # GNU/Linux
579 case "$target_cpu" in
580 alpha*) case "$target_os"::"$GCC" in
581 *::yes) CFLAGS="-mieee $CFLAGS" ;; # gcc
582 osf*) CFLAGS="-ieee $CFLAGS" ;; # ccc
586 dnl Checks for header files.
590 AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h sys/syscall.h\
591 fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
592 syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \
593 sys/mkdev.h sys/utime.h xti.h netinet/in_systm.h float.h ieeefp.h pthread.h \
594 ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h)
596 dnl Check additional types.
597 AC_CHECK_SIZEOF(rlim_t, 0, [
598 #ifdef HAVE_SYS_TYPES_H
599 # include <sys/types.h>
601 #ifdef HAVE_SYS_TIME_H
602 # include <sys/time.h>
604 #ifdef HAVE_SYS_RESOURCE_H
605 # include <sys/resource.h>
613 dnl Checks for typedefs, structures, and compiler characteristics.
615 AC_CHECK_SIZEOF(size_t, 0)
619 AC_CHECK_MEMBERS([struct stat.st_atim])
620 AC_CHECK_MEMBERS([struct stat.st_atimespec])
621 AC_CHECK_MEMBERS([struct stat.st_atimensec])
622 AC_CHECK_MEMBERS([struct stat.st_mtim])
623 AC_CHECK_MEMBERS([struct stat.st_mtimespec])
624 AC_CHECK_MEMBERS([struct stat.st_mtimensec])
625 AC_CHECK_MEMBERS([struct stat.st_ctim])
626 AC_CHECK_MEMBERS([struct stat.st_ctimespec])
627 AC_CHECK_MEMBERS([struct stat.st_ctimensec])
629 AC_CHECK_TYPES([struct timespec], [], [], [@%:@ifdef HAVE_TIME_H
633 AC_CHECK_TYPE(fd_mask, [AC_DEFINE(HAVE_RB_FD_INIT, 1)])
635 dnl RUBY_DEFINT TYPENAME, SIZE, [SIGNED-OR-UNSIGNED], [INCLUDES = DEFAULT-INCLUDES]
636 AC_DEFUN([RUBY_DEFINT], [dnl
637 AC_CACHE_CHECK([for $1], [rb_cv_type_$1],
638 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])
639 typedef $1 t; int s = sizeof(t) == 42;])],
641 [case m4_bmatch([$2], [^[1-9][0-9]*$], $2, [$ac_cv_sizeof_]AS_TR_SH($2)) in
642 "1") rb_cv_type_$1="m4_if([$3], [], [signed ], [$3 ])char";;
643 "$ac_cv_sizeof_short") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])short";;
644 "$ac_cv_sizeof_int") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])int";;
645 "$ac_cv_sizeof_long") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long";;
646 "$ac_cv_sizeof_long_long") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long long";;
647 "$ac_cv_sizeof___int64") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int64";;
648 *) rb_cv_type_$1=no;;
650 if test "${rb_cv_type_$1}" != no; then
651 AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)
652 test "${rb_cv_type_$1}" = yes || AC_DEFINE_UNQUOTED($1, [$rb_cv_type_$1])
656 RUBY_DEFINT(int8_t, 1)
657 RUBY_DEFINT(uint8_t, 1, unsigned)
658 RUBY_DEFINT(int16_t, 2)
659 RUBY_DEFINT(uint16_t, 2, unsigned)
660 RUBY_DEFINT(int32_t, 4)
661 RUBY_DEFINT(uint32_t, 4, unsigned)
662 RUBY_DEFINT(int64_t, 8)
663 RUBY_DEFINT(uint64_t, 8, unsigned)
664 RUBY_DEFINT(int128_t, 16)
665 RUBY_DEFINT(uint128_t, 16, unsigned)
666 RUBY_DEFINT(intptr_t, void*)
667 RUBY_DEFINT(uintptr_t, void*, unsigned)
668 RUBY_DEFINT(ssize_t, size_t) dnl may differ from int, so not use AC_TYPE_SSIZE_T.
670 AC_CACHE_CHECK(for stack end address, rb_cv_stack_end_address,
671 [rb_cv_stack_end_address=no
672 for addr in __libc_stack_end _SEND; do
674 [extern void *$addr;],
675 [if (!$addr) return 1;],
676 [rb_cv_stack_end_address="$addr"; break])
678 if test $rb_cv_stack_end_address != no; then
679 AC_DEFINE_UNQUOTED(STACK_END_ADDRESS, $rb_cv_stack_end_address)
682 dnl Checks for library functions.
685 case "${target_cpu}-${target_os}" in
687 AC_LIBSOURCES(alloca.c)
688 AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}])
690 AC_DEFINE_UNQUOTED(alloca, alloca)
697 AC_REPLACE_FUNCS(dup2 memmove strerror strftime\
698 strchr strstr crypt flock vsnprintf\
699 isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt \
701 AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd eaccess\
702 truncate ftruncate chsize times utimes utimensat fcntl lockf lstat\
703 link symlink readlink\
704 setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
705 setrgid setegid setregid setresgid issetugid pause lchown lchmod\
706 getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
707 getpriority getrlimit setrlimit sysconf group_member\
708 dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp vsnprintf snprintf\
709 setsid telldir seekdir fchmod cosh sinh tanh log2 round signbit\
710 setuid setgid daemon select_large_fdset setenv unsetenv\
711 mktime timegm clock_gettime gettimeofday\
714 AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp,
715 [AC_TRY_LINK([@%:@include <setjmp.h>
716 jmp_buf jb; void t(v) int v; {__builtin_longjmp(jb, v);}],
717 [__builtin_setjmp(jb);],
718 [ac_cv_func___builtin_setjmp=yes],
719 [ac_cv_func___builtin_setjmp=no])
722 test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no
724 AC_MSG_CHECKING(for setjmp type)
725 AC_ARG_WITH(setjmp-type,
726 [ --with-setjmp-type select setjmp type], [
728 __builtin_setjmp) setjmp_prefix=__builtin_;;
729 _setjmp) setjmp_prefix=_;;
730 sigsetjmp) setjmp_prefix=sig;;
731 setjmp) setjmp_prefix=;;
732 '') unset setjmp_prefix;;
733 *) AC_MSG_ERROR(invalid setjmp type: $withval);;
734 esac], [unset setjmp_prefix])
735 if test ${setjmp_prefix+set}; then
736 if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp = no; then
737 AC_MSG_ERROR(${setjmp_prefix}setjmp is not available)
739 elif test "$ac_cv_func___builtin_setjmp" = yes; then
740 setjmp_prefix=__builtin_
741 elif test "$ac_cv_func__setjmp" = yes; then
743 elif test "$ac_cv_func_sigsetjmp" = yes; then
753 if test x$setjmp_prefix = xsig; then
758 AC_MSG_RESULT(${setjmp_prefix}setjmp)
759 AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp(env${setjmp_sigmask+,0})])
760 AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)])
761 AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
763 AC_ARG_ENABLE(setreuid,
764 [ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
765 [use_setreuid=$enableval])
766 if test "$use_setreuid" = yes; then
767 AC_DEFINE(USE_SETREUID)
768 AC_DEFINE(USE_SETREGID)
771 AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
772 [AC_TRY_COMPILE([#include <time.h>],
773 [struct tm t; t.tm_gmtoff = 3600;],
774 [rb_cv_member_struct_tm_tm_gmtoff=yes],
775 [rb_cv_member_struct_tm_tm_gmtoff=no])])
776 if test "$rb_cv_member_struct_tm_tm_gmtoff" = yes; then
777 AC_DEFINE(HAVE_STRUCT_TM_TM_GMTOFF)
779 AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
780 [AC_TRY_LINK([#include <time.h>
783 rb_cv_have_daylight=yes,
784 rb_cv_have_daylight=no)])
785 if test "$rb_cv_have_daylight" = yes; then
786 AC_DEFINE(HAVE_DAYLIGHT)
788 AC_DEFUN([RUBY_CHECK_VARTYPE], [dnl
789 AC_CACHE_CHECK([for external $1], rb_cv_var_$1,
792 #ifndef _XOPEN_SOURCE
793 #define _XOPEN_SOURCE 1
797 const volatile void *volatile t;],
801 #ifndef _XOPEN_SOURCE
802 #define _XOPEN_SOURCE 1
807 const volatile void *volatile t;],
809 [rb_cv_var_$1=$t; break])
811 if test "[$rb_cv_var_]$1" != no; then
812 AC_DEFINE([HAVE_VAR_]m4_toupper($1))
813 AC_DEFINE_UNQUOTED([TYPEOF_VAR_]m4_toupper($1), $rb_cv_var_$1)
815 RUBY_CHECK_VARTYPE(timezone, [@%:@include <time.h>], [long int])
816 RUBY_CHECK_VARTYPE(altzone, [@%:@include <time.h>], [long int])
817 if test "$rb_cv_var_timezone" = no; then
818 AC_CHECK_FUNCS(timezone)
819 if test "$ac_cv_func_timezone" = yes; then
820 AC_CACHE_CHECK([whether timezone requires zero arguments], rb_cv_func_timezone_void,
821 [AC_TRY_COMPILE([@%:@include <time.h>],
822 [(void)timezone(0, 0);],
823 [rb_cv_func_timezone_void=no],
824 [rb_cv_func_timezone_void=yes])]
826 if test $rb_cv_func_timezone_void = yes; then
827 AC_DEFINE(TIMEZONE_VOID)
832 AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
837 check(tm, y, m, d, h, s)
857 check(gmtime(&t), 69, 12, 31, 23, 59);
858 t = ~(time_t)0 << 31;
859 check(gmtime(&t), 1, 12, 13, 20, 52);
863 rb_cv_negative_time_t=yes,
864 rb_cv_negative_time_t=no,
865 rb_cv_negative_time_t=yes)])
866 if test "$rb_cv_negative_time_t" = yes; then
867 AC_DEFINE(NEGATIVE_TIME_T)
870 if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
871 AC_DEFINE(POSIX_SIGNAL)
873 AC_CHECK_FUNCS(sigsetmask)
874 AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
888 signal(SIGINT, sig_handler);
889 kill(getpid(), SIGINT);
890 kill(getpid(), SIGINT);
894 rb_cv_bsd_signal=yes,
896 rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
897 if test "$rb_cv_bsd_signal" = yes; then
898 AC_DEFINE(BSD_SIGNAL)
911 if test x"$target_cpu" = xia64; then
913 AC_CACHE_CHECK(for __libc_ia64_register_backing_store_base,
914 rb_cv___libc_ia64_register_backing_store_base,
915 [rb_cv___libc_ia64_register_backing_store_base=no
917 [extern unsigned long __libc_ia64_register_backing_store_base;],
918 [unsigned long p = __libc_ia64_register_backing_store_base;
919 printf("%ld\n", p);],
920 [rb_cv___libc_ia64_register_backing_store_base=yes])])
921 if test $rb_cv___libc_ia64_register_backing_store_base = yes; then
922 AC_DEFINE(HAVE___LIBC_IA64_REGISTER_BACKING_STORE_BASE)
926 AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
936 rb_cv_rshift_sign=yes,
937 rb_cv_rshift_sign=no,
938 rb_cv_rshift_sign=yes)])
939 if test "$rb_cv_rshift_sign" = yes; then
940 AC_DEFINE(RSHIFT(x,y), ((x)>>(int)y))
942 AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
945 AC_MSG_CHECKING(read count field in FILE structures)
946 AC_CACHE_VAL(rb_cv_fcnt,
952 _rcount dnl for emx0.9c
954 AC_TRY_COMPILE([#include <stdio.h>
956 [FILE *f = stdin; f->$fcnt = 0;],
957 rb_cv_fcnt="$fcnt"; break,
958 rb_cv_fcnt="not found")
960 if test "$rb_cv_fcnt" = "not found"; then
961 AC_MSG_RESULT([not found(OK if using GNU libc)])
963 AC_MSG_RESULT($rb_cv_fcnt)
964 AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
967 AC_MSG_CHECKING(read buffer ptr field in FILE structures)
968 AC_CACHE_VAL(rb_cv_frptr,
976 AC_TRY_COMPILE([#include <stdio.h>
978 [FILE *f = stdin; char buf[256]; f->$frptr = buf;],
979 rb_cv_frptr="$frptr"; break,
980 rb_cv_frptr="not found")
982 if test "$rb_cv_frptr" = "not found"; then
983 AC_MSG_RESULT([not found])
985 AC_MSG_RESULT($rb_cv_frptr)
986 AC_DEFINE_UNQUOTED(FILE_READPTR, $rb_cv_frptr)
988 if test "$rb_cv_fcnt" = "not found"; then
989 AC_MSG_CHECKING(read buffer end field in FILE structures)
990 AC_CACHE_VAL(rb_cv_frend,
995 AC_TRY_COMPILE([#include <stdio.h>
997 [FILE *f = stdin; char buf[256]; f->$frend = buf;],
998 rb_cv_frend="$frend"; break,
999 rb_cv_frend="not found")
1001 if test "$rb_cv_frend" = "not found"; then
1002 AC_MSG_RESULT([not found])
1004 AC_MSG_RESULT($rb_cv_frend)
1005 AC_DEFINE_UNQUOTED(FILE_READEND, $rb_cv_frend)
1010 AC_CACHE_CHECK([whether st_ino is huge], rb_cv_huge_st_ino,
1011 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([
1012 #include <sys/stat.h>
1013 struct stat test_stat;
1014 ], [sizeof(test_stat.st_ino)>sizeof(long)])],
1015 rb_cv_huge_st_ino=yes,
1016 rb_cv_huge_st_ino=no)
1018 if test $rb_cv_huge_st_ino = yes; then
1019 AC_DEFINE(HUGE_ST_INO)
1022 if test "$ac_cv_func_sysconf" = yes; then
1023 AC_DEFUN([RUBY_CHECK_SYSCONF], [dnl
1024 AC_CACHE_CHECK([whether _SC_$1 is supported], rb_cv_have_sc_[]m4_tolower($1),
1025 [AC_TRY_COMPILE([#include <unistd.h>
1028 rb_cv_have_sc_[]m4_tolower($1)=yes,
1029 rb_cv_have_sc_[]m4_tolower($1)=no)
1031 if test "$rb_cv_have_sc_[]m4_tolower($1)" = yes; then
1032 AC_DEFINE(HAVE__SC_$1)
1035 RUBY_CHECK_SYSCONF(CLK_TCK)
1038 case "$target_cpu" in
1039 m68*|i?86|ia64|sparc*|alpha*) rb_cv_stack_grow_dir=-1;;
1040 hppa*) rb_cv_stack_grow_dir=+1;;
1042 AC_CACHE_CHECK(stack growing direction, rb_cv_stack_grow_dir,
1044 /* recurse to get rid of inlining */
1046 stack_growup_p(addr, n)
1047 volatile int *addr, n;
1051 return *addr = stack_growup_p(addr, n - 1);
1053 return (&end > addr);
1058 return stack_growup_p(&x, 10);
1060 ], rb_cv_stack_grow_dir=-1, rb_cv_stack_grow_dir=+1, rb_cv_stack_grow_dir=0)])
1061 AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
1063 if test x"$enable_pthread" = xyes; then
1064 for pthread_lib in thr pthread pthreads c c_r; do
1065 AC_CHECK_LIB($pthread_lib, pthread_kill,
1066 rb_with_pthread=yes, rb_with_pthread=no)
1067 if test "$rb_with_pthread" = "yes"; then break; fi
1069 if test x"$rb_with_pthread" = xyes; then
1070 AC_DEFINE(_REENTRANT)
1071 AC_DEFINE(_THREAD_SAFE)
1072 AC_DEFINE(HAVE_LIBPTHREAD)
1073 case $pthread_lib in
1077 MAINLIBS="-pthread $MAINLIBS"
1080 LIBS="-l$pthread_lib $LIBS"
1084 AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
1086 AC_CHECK_FUNCS(nanosleep)
1087 if test x"$ac_cv_func_nanosleep" = xno; then
1088 AC_CHECK_LIB(rt, nanosleep)
1089 if test x"$ac_cv_lib_rt_nanosleep" = xyes; then
1090 AC_DEFINE(HAVE_NANOSLEEP)
1094 if test x"$ac_cv_header_ucontext_h" = xyes; then
1095 if test x"$rb_with_pthread" = xyes; then
1096 AC_CHECK_FUNCS(getcontext setcontext)
1100 AC_CHECK_FUNCS(backtrace)
1102 AC_ARG_WITH(valgrind,
1103 [ --with-valgrind enable valgrind memcheck support.],
1104 [AC_CHECK_HEADERS(valgrind/memcheck.h)])
1106 dnl wheather use dln_a_out or not
1107 AC_ARG_WITH(dln-a-out,
1108 [ --with-dln-a-out use dln_a_out if possible], [
1110 yes) with_dln_a_out=yes;;
1111 *) with_dln_a_out=no;;
1112 esac], [with_dln_a_out=no])
1114 AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
1116 /* Test for whether ELF binaries are produced */
1121 int i=open("conftest",O_RDONLY);
1124 if(read(i,&buffer[0],4)<4)
1126 if(buffer[0] != 127 || buffer[1] != 'E' ||
1127 buffer[2] != 'L' || buffer[3] != 'F')
1129 exit(0); /* succeed (yes, it's ELF) */
1132 rb_cv_binary_elf=yes,
1133 rb_cv_binary_elf=no,
1134 rb_cv_binary_elf=yes)])
1136 if test "$rb_cv_binary_elf" = yes; then
1140 case "$target_os" in
1141 linux* | gnu* | k*bsd*-gnu | bsdi*)
1142 if test "$rb_cv_binary_elf" = no; then
1145 LDFLAGS="$LDFLAGS -rdynamic"
1150 AC_SUBST(DLDFLAGS)dnl
1151 AC_SUBST(ARCH_FLAG)dnl
1154 AC_SUBST(CCDLFLAGS)dnl
1155 AC_SUBST(LDSHARED)dnl
1156 AC_SUBST(LDSHAREDXX)dnl
1162 : ${LIBPATHFLAG=' -L%s'}
1165 if test "$with_dln_a_out" != yes; then
1166 rb_cv_dlopen=unknown
1167 AC_MSG_CHECKING(whether OS depend dynamic link works)
1168 if test "$GCC" = yes; then
1169 case "$target_os" in
1170 nextstep*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
1171 openstep*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
1172 rhapsody*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
1173 darwin*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
1174 human*|bsdi*|beos*|cygwin*|mingw*|aix*|interix*) ;;
1175 *) CCDLFLAGS="$CCDLFLAGS -fPIC";;
1178 case "$target_os" in
1179 hpux*) CCDLFLAGS="$CCDLFLAGS +Z";;
1180 solaris*|irix*) CCDLFLAGS="$CCDLFLAGS -KPIC" ;;
1181 sunos*) CCDLFLAGS="$CCDLFLAGS -PIC" ;;
1182 esix*|uxpds*) CCDLFLAGS="$CCDLFLAGS -KPIC" ;;
1183 *) : ${CCDLFLAGS=""} ;;
1188 AC_ARG_ENABLE(rpath,
1189 [ --disable-rpath embed run path into extension libraries.],
1190 [enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"])
1191 if test "$enable_rpath" = yes; then
1192 LIBPATHFLAG=" -L%1\$-s"
1193 RPATHFLAG=" ${linker_flag}-R%1\$-s"
1196 case "$target_os" in
1197 hpux*) DLDFLAGS="$DLDFLAGS -E"
1198 : ${LDSHARED='ld -b'}
1199 XLDFLAGS="$XLDFLAGS -Wl,-E"
1200 : ${LIBPATHENV=SHLIB_PATH}
1201 if test "$rb_cv_prog_gnu_ld" = no; then
1202 RPATHFLAG=' +b %1$-s'
1205 solaris*) if test "$GCC" = yes; then
1206 : ${LDSHARED='$(CC) -shared'}
1207 if test "$rb_cv_prog_gnu_ld" = yes; then
1208 LDFLAGS="$LDFLAGS -Wl,-E"
1211 : ${LDSHARED='ld -G'}
1214 sunos*) : ${LDSHARED='ld -assert nodefinitions'}
1216 irix*) : ${LDSHARED='ld -shared'}
1218 sysv4*) : ${LDSHARED='ld -G'}
1220 nto-qnx*) : ${LDSHARED="qcc -shared"}
1222 esix*|uxpds*) : ${LDSHARED="ld -G"}
1224 osf*) : ${LDSHARED="ld -shared -expect_unresolved \"*\""}
1226 bsdi3*) case "$CC" in
1227 *shlicc*) : ${LDSHARED="$CC -r"}
1230 linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi*)
1231 : ${LDSHARED='${CC} -shared'}
1232 if test "$rb_cv_binary_elf" = yes; then
1233 LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
1236 interix*) : ${LDSHARED="$CC -shared"}
1237 XLDFLAGS="$XLDFLAGS -Wl,-E"
1238 LIBPATHFLAG=" -L%1\$-s"
1240 freebsd*|dragonfly*) : ${LDSHARED="$CC -shared"}
1241 if test "$rb_cv_binary_elf" = yes; then
1242 LDFLAGS="$LDFLAGS -rdynamic"
1243 DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)'
1245 test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED="ld -Bshareable"
1248 openbsd*) : ${LDSHARED="\$(CC) -shared ${CCDLFLAGS}"}
1249 if test "$rb_cv_binary_elf" = yes; then
1250 LDFLAGS="$LDFLAGS -Wl,-E"
1253 nextstep*) : ${LDSHARED='cc -r -nostdlib'}
1254 LDFLAGS="$LDFLAGS -u libsys_s"
1256 openstep*) : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
1259 rhapsody*) : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
1262 darwin*) : ${LDSHARED='cc -dynamic -bundle -undefined suppress -flat_namespace'}
1264 : ${LIBPATHENV=DYLD_LIBRARY_PATH}
1266 aix*) if test "$GCC" = yes; then
1267 : ${LDSHARED='$(CC) -shared'}
1269 : ${LDSHARED='$(CC)'}
1271 LDSHARED="$LDSHARED ${linker_flag}-G"
1272 DLDFLAGS='-eInit_$(TARGET)'
1273 XLDFLAGS="${linker_flag}-bE:ruby.imp ${linker_flag}-brtl"
1274 : ${ARCHFILE="ruby.imp"}
1275 TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
1276 TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
1277 : ${LIBPATHENV=SHLIB_PATH}
1279 human*) : ${DLDFLAGS=''}
1282 : ${LINK_SO='ar cru $@ $(OBJS)'}
1284 beos*) case "$target_cpu" in
1286 : ${LDSHARED="ld -xms"}
1287 DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
1290 : ${LDSHARED="ld -shared"}
1291 DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -lbe -lroot"
1294 : ${LIBPATHENV=LIBRARY_PATH}
1296 nto-qnx*) DLDFLAGS="$DLDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
1297 : ${LDSHARED='ld -Bshareable -x'}
1298 LDFLAGS="$LDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
1300 cygwin*|mingw*) : ${LDSHARED="${CC} -shared -s"}
1301 XLDFLAGS="$XLDFLAGS -Wl,--stack,0x00200000"
1302 DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-image-base,--enable-auto-import,--export-all"
1305 hiuxmpp) : ${LDSHARED='ld -r'} ;;
1306 atheos*) : ${LDSHARED="$CC -shared"}
1308 os2-emx*) LDFLAGS="$LDFLAGS -Zbsd-signals"
1310 *) : ${LDSHARED='ld'} ;;
1312 AC_MSG_RESULT($rb_cv_dlopen)
1314 if test "${LDSHAREDXX}" = ""; then
1315 case "${LDSHARED}" in
1317 LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\$(CC)/$(CXX)/'`
1320 LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\${CC}/${CXX}/'`
1323 LDSHAREDXX=`echo "${LDSHARED}" | sed "s|$CC|$CXX|"`
1331 AC_SUBST(LIBPATHFLAG)
1333 AC_SUBST(LIBPATHENV, "${LIBPATHENV-LD_LIBRARY_PATH}")
1337 if test "$ac_cv_header_a_out_h" = yes; then
1338 if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
1339 cat confdefs.h > config.h
1340 AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out,
1342 #define USE_DLN_A_OUT
1346 rb_cv_dln_a_out=yes,
1347 rb_cv_dln_a_out=no)])
1348 if test "$rb_cv_dln_a_out" = yes; then
1350 AC_DEFINE(USE_DLN_A_OUT)
1355 if test "$dln_a_out_works" = yes; then
1356 if test "$GCC" = yes; then
1364 case "$target_os" in
1366 nextstep*) DLEXT=bundle;;
1367 openstep*) DLEXT=bundle;;
1368 rhapsody*) DLEXT=bundle;;
1369 darwin*) DLEXT=bundle;;
1370 os2-emx*) DLEXT=dll;;
1371 cygwin*|mingw*) DLEXT=so;;
1376 n=`expr "$DLEXT" : '.*'`; test "$n" -gt "$len" && len=$n
1377 n=`expr "$DLEXT2" : '.*'`; test "$n" -gt "$len" && len=$n
1378 AC_DEFINE_UNQUOTED(DLEXT_MAXLEN, `expr $len + 1`)
1379 test ".$DLEXT" = "." || AC_DEFINE_UNQUOTED(DLEXT, ".$DLEXT")
1380 test ".$DLEXT2" = "." || AC_DEFINE_UNQUOTED(DLEXT2, ".$DLEXT2")
1384 if test "$with_dln_a_out" = yes; then
1390 case "$target_os" in
1391 linux* | gnu* | k*bsd*-gnu)
1392 STRIP='strip -S -x';;
1394 STRIP='strip -A -n';;
1396 STRIP='strip -A -n';;
1398 STRIP='strip -A -n';;
1400 STRIP='strip -A -n';;
1404 AC_SUBST(EXTSTATIC)dnl
1405 AC_ARG_WITH(static-linked-ext,
1406 [ --with-static-linked-ext link external modules statically],
1413 case "$target_os" in
1415 AC_CHECK_LIB(signal, _harderr)
1416 AC_CHECK_LIB(hmem, hmemset)
1417 AC_CHECK_FUNCS(select)
1418 AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
1419 rb_cv_missing__dtos18,
1421 changequote(<<, >>)dnl
1427 sprintf (buf, "%g", 1e+300);
1428 exit (strcmp (buf, "1e+300") ? 0 : 1);
1431 changequote([, ])dnl
1432 rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no, rb_cv_missing__dtos18=no)])
1433 if test "$rb_cv_missing__dtos18" = yes; then
1434 AC_DEFINE(MISSING__DTOS18)
1436 AC_CACHE_CHECK(whether PD libc fconvert fail to round,
1437 rb_cv_missing_fconvert,
1439 changequote(<<, >>)dnl
1446 sprintf (buf, "%f", log(exp(1.0)));
1447 exit (strcmp (buf, "1.000000") ? 0 : 1);
1450 changequote([, ])dnl
1451 rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no)])
1452 if test "$rb_cv_missing_fconvert" = yes; then
1453 AC_DEFINE(MISSING_FCONVERT)
1456 CFLAGS="$CFLAGS -fansi-only"
1457 XCFLAGS="$XCFLAGS -cc1-stack=262144 -cpp-stack=2694144"
1462 dnl OS/2 environment w/ Autoconf 2.1x for EMX
1477 if test "$prefix" = NONE; then
1478 prefix=$ac_default_prefix
1481 #if test "$fat_binary" != no ; then
1482 # CFLAGS="$CFLAGS $ARCH_FLAG"
1485 if test x"$cross_compiling" = xyes; then
1486 test x"$MINIRUBY" = x && MINIRUBY="${RUBY-ruby} -I`pwd` -rfake"
1488 RUNRUBY='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
1490 MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib'
1491 PREP='miniruby$(EXEEXT)'
1492 RUNRUBY='$(MINIRUBY) $(srcdir)/runruby.rb --extout=$(EXTOUT)'
1497 AC_SUBST(EXTOUT, [${EXTOUT=.ext}])
1500 LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
1501 LIBRUBY='$(LIBRUBY_A)'
1502 LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static'
1503 LIBRUBYARG='$(LIBRUBYARG_STATIC)'
1506 case "$target_os" in
1507 cygwin*|mingw*|beos*|openstep*|nextstep*|rhapsody*|darwin*|os2-emx*)
1511 DLDLIBS="$DLDLIBS -lc"
1515 RUBY_SO_NAME='$(RUBY_INSTALL_NAME)'
1516 LIBRUBY_LDSHARED=$LDSHARED
1517 LIBRUBY_DLDFLAGS=$DLDFLAGS
1518 LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
1519 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so'
1522 AC_ARG_ENABLE(shared,
1523 [ --enable-shared build a shared library for Ruby. ],
1524 [enable_shared=$enableval])
1525 if test "$enable_shared" = 'yes'; then
1526 LIBRUBY='$(LIBRUBY_SO)'
1527 LIBRUBYARG_SHARED='-l$(RUBY_SO_NAME)'
1528 LIBRUBYARG='$(LIBRUBYARG_SHARED)'
1529 CFLAGS="$CFLAGS $CCDLFLAGS"
1531 if test "$rb_cv_binary_elf" = yes; then
1534 case "$target_os" in
1536 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
1538 linux* | gnu* | k*bsd*-gnu | atheos*)
1539 LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
1540 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
1542 freebsd*|dragonfly*)
1544 LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
1545 if test "$rb_cv_binary_elf" != "yes" ; then
1546 LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
1552 LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR).$(TEENY)'
1553 LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
1554 if test "$rb_cv_binary_elf" = yes; then # ELF platforms
1555 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_SO_NAME).so'
1556 else # a.out platforms
1562 LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
1566 LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)'
1567 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY) lib$(RUBY_SO_NAME).so'
1568 if test "$GCC" = yes; then
1569 LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)'
1571 XLDFLAGS="$XLDFLAGS "'-R${libdir}'
1574 XLDFLAGS="$XLDFLAGS "'-Wl,+s,+b,$(libdir)'
1575 LIBRUBY_SO='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
1576 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
1579 LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry $XLDFLAGS"
1580 LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
1584 case "$target_cpu" in
1586 LIBRUBY_DLDFLAGS='-f ruby.exp -lnet -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
1591 LIBRUBY_SO='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib'
1592 LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace'
1593 LIBRUBY_DLDFLAGS='-install_name $(libdir)/lib$(RUBY_SO_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
1594 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib'
1597 LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
1603 if test "$enable_rpath" = yes; then
1604 LIBRUBYARG_SHARED="${linker_flag}-R ${linker_flag}\$(libdir) -L\$(libdir) $LIBRUBYARG_SHARED"
1607 LDFLAGS="-L. $LDFLAGS"
1610 dnl build rdoc index if requested
1612 AC_ARG_ENABLE(install-doc,
1613 [ --disable-install-doc do not install rdoc indexes during install ],
1614 [install_doc=$enableval], [install_doc=yes])
1615 if test "$install_doc" != no; then
1616 RDOCTARGET="install-doc"
1618 AC_SUBST(RDOCTARGET)
1620 if test "$rb_with_pthread" = "yes"; then
1621 THREAD_MODEL=pthread
1624 case "$target_os" in
1628 CFLAGS="$CFLAGS -pipe"
1630 nextstep*|openstep*)
1631 # The -fno-common is needed if we wish to embed the Ruby interpreter
1632 # into a plugin module of some project (as opposed to embedding it
1633 # within the project's application). The -I/usr/local/include is
1634 # needed because CPP as discovered by configure (cc -E -traditional)
1635 # fails to consult /usr/local/include by default. This causes
1636 # mkmf.rb's have_header() to fail if the desired resource happens to be
1637 # installed in the /usr/local tree.
1638 CFLAGS="$CFLAGS -pipe -fno-common"
1639 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
1642 CFLAGS="$CFLAGS -pipe -no-precomp -fno-common"
1645 CFLAGS="$CFLAGS -pipe -fno-common"
1649 CFLAGS="$CFLAGS -DOS2 -Zmts"
1650 LIBRUBY_A=`echo $LIBRUBY_A | sed 's/^lib//'`
1651 LIBRUBY_SO=`echo $LIBRUBY_SO | sed 's/^lib//'`
1652 LIBRUBY_ALIASES=`for i in $LIBRUBY_ALIASES; do echo "$i"; done | sed 's/^lib//'`
1655 if test "$GCC" != "yes" ; then
1656 # compile something small: taint.c is fine for this.
1657 # the main point is the '-v' flag of 'cc'.
1658 case "`cc -v -I. -c main.c -o /tmp/main.o 2>&1`" in
1659 */gemc_cc*) # we have the new DEC GEM CC
1660 CFLAGS="$CFLAGS -oldc"
1662 *) # we have the old MIPS CC
1667 CFLAGS="$CFLAGS -std"
1671 case "$target_cpu" in
1673 CFLAGS="$CFLAGS -relax_pointers"
1678 LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
1679 case "$target_os" in
1681 if test x"$enable_shared" = xyes; then
1682 LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}${TEENY}.dll
1686 RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}${TEENY}
1687 if test x"$enable_shared" = xyes; then
1688 LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
1689 LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' $(RUBYDEF)'
1693 # COMMON_MACROS="WIN32_LEAN_AND_MEAN="
1694 COMMON_HEADERS="winsock2.h windows.h"
1699 FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
1701 if test x"$enable_shared" = xyes; then
1702 LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
1705 LIBRUBY='lib$(RUBY_SO_NAME).a'
1706 LIBRUBYARG='-l$(RUBY_SO_NAME)'
1713 XCFLAGS="$XCFLAGS -DYYMAXDEPTH=300"
1714 YACC="$YACC -Nl40000 -Nm40000"
1722 MINIOBJS="$MINIDLNOBJ"
1725 *msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;;
1728 CPPFLAGS="$CPPFLAGS "'$(DEFS)'
1729 test -z "$CFLAGS" || CFLAGS="$CFLAGS "; CFLAGS="$CFLAGS"'${cflags}'
1730 test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
1731 AC_SUBST(cppflags, [])dnl
1732 AC_SUBST(cflags, ['${optflags} ${debugflags}'])dnl
1733 AC_SUBST(optflags)dnl
1734 AC_SUBST(debugflags)dnl
1735 AC_SUBST(XCFLAGS)dnl
1736 AC_SUBST(XLDFLAGS)dnl
1737 AC_SUBST(LIBRUBY_LDSHARED)
1738 AC_SUBST(LIBRUBY_DLDFLAGS)
1739 AC_SUBST(RUBY_INSTALL_NAME)
1740 AC_SUBST(rubyw_install_name)
1741 AC_SUBST(RUBYW_INSTALL_NAME)
1742 AC_SUBST(RUBY_SO_NAME)
1744 AC_SUBST(LIBRUBY_SO)
1745 AC_SUBST(LIBRUBY_ALIASES)
1747 AC_SUBST(LIBRUBYARG)
1748 AC_SUBST(LIBRUBYARG_STATIC)
1749 AC_SUBST(LIBRUBYARG_SHARED)
1752 AC_SUBST(ENABLE_SHARED)
1754 AC_SUBST(COMMON_LIBS)
1755 AC_SUBST(COMMON_MACROS)
1756 AC_SUBST(COMMON_HEADERS)
1757 AC_SUBST(EXPORT_PREFIX)
1759 AC_SUBST(THREAD_MODEL)
1761 MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`"
1762 MAKEFILES="`echo $MAKEFILES`"
1766 test "$program_prefix" != NONE &&
1767 ri_prefix=$program_prefix
1770 test "$program_suffix" != NONE &&
1771 ri_suffix=$program_suffix
1773 RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
1774 case "$target_os" in
1776 RUBYW_INSTALL_NAME="${ri_prefix}rubyw${ri_suffix}"
1777 rubyw_install_name="$RUBYW_INSTALL_NAME"
1780 RUBY_LIB_PREFIX=`eval echo \\"${libdir}/ruby\\"`
1782 AC_ARG_WITH(sitedir,
1783 [ --with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
1785 [sitedir='${libdir}/ruby/site_ruby'])
1786 SITE_DIR=`eval echo \\"${sitedir}\\"`
1788 AC_ARG_WITH(vendordir,
1789 [ --with-vendordir=DIR vendor libraries in DIR [PREFIX/lib/ruby/vendor_ruby]],
1790 [vendordir=$withval],
1791 [vendordir='${prefix}/lib/ruby/vendor_ruby'])
1792 VENDOR_DIR=`eval echo \\"${vendordir}\\"`
1794 case "$target_os" in
1795 cygwin*|mingw*|*djgpp*|os2-emx*)
1796 RUBY_LIB_PREFIX="`eval echo "$RUBY_LIB_PREFIX" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1797 RUBY_SITE_LIB_PATH="`eval echo "$SITE_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1798 RUBY_VENDOR_LIB_PATH="`eval echo "$VENDOR_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1801 RUBY_LIB_PREFIX="`eval echo \\"$RUBY_LIB_PREFIX\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1802 RUBY_SITE_LIB_PATH="`eval echo \\"$SITE_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1803 RUBY_VENDOR_LIB_PATH="`eval echo \\"$VENDOR_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1806 RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}.${TEENY}"
1807 RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}.${TEENY}"
1808 RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}.${TEENY}"
1810 AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
1811 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
1812 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
1813 AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
1814 AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
1817 AC_SUBST(sitearch)dnl
1818 AC_SUBST(sitedir)dnl
1819 AC_SUBST(vendordir)dnl
1821 configure_args=$ac_configure_args
1822 AC_SUBST(configure_args)dnl
1824 if test "$fat_binary" != no ; then
1825 arch="fat-${target_os}"
1827 AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
1828 "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1830 AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
1831 "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1832 AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB,
1833 "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1834 AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}")
1836 arch="${target_cpu}-${target_os}"
1837 AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
1840 case "$target_os" in
1841 mingw*) sitearch="$target_cpu-$rb_cv_msvcrt" ;;
1842 *) sitearch="${arch}" ;;
1845 AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
1846 AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
1847 AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${RUBY_VENDOR_LIB_PATH2}/${sitearch}")
1849 AC_ARG_WITH(search-path,
1850 [ --with-search-path=DIR specify the additional search path],
1851 [search_path=$withval])
1852 if test "$search_path" != ""; then
1853 AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
1856 AC_ARG_WITH(rubyhdrdir,
1857 [ --with-ruby-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
1858 [rubyhdrdir=$withval],
1859 [rubyhdrdir='${includedir}/ruby-${MAJOR}.${MINOR}.${TEENY}'])
1861 AC_ARG_WITH(sitehdrdir,
1862 [ --with-site-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
1863 [sitehdrdir=$withval],
1864 [sitehdrdir='${rubyhdrdir}/site_ruby'])
1866 AC_ARG_WITH(vendorhdrdir,
1867 [ --with-vendor-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
1868 [vendorhdrdir=$withval],
1869 [vendorhdrdir='${rubyhdrdir}/vendor_ruby'])
1871 AC_SUBST(rubyhdrdir)dnl
1872 AC_SUBST(sitehdrdir)dnl
1873 AC_SUBST(vendorhdrdir)dnl
1875 AC_ARG_WITH(mantype,
1876 [ --with-mantype=TYPE specify man page type; TYPE is one of man and doc],
1883 AC_MSG_ERROR(invalid man type: $withval)
1887 if test -z "$MANTYPE"; then
1888 AC_PATH_PROGS(NROFF, nroff awf, /bin/false, "/usr/bin:/usr/ucb")
1889 if ${NROFF} -mdoc ${srcdir}/ruby.1 >/dev/null 2>&1; then
1897 arch_hdrdir="${EXTOUT}/include/${arch}/ruby"
1898 $MAKEDIRS "${arch_hdrdir}"
1899 config_h="${arch_hdrdir}/config.h"
1900 if test -f "${config_h}" && tr -d '\015' < confdefs.h | cmp -s "${config_h}" -; then
1901 echo "config.h unchanged"
1903 echo "creating config.h"
1904 tr -d '\015' < confdefs.h > "${config_h}"
1906 tr -d '\015' < largefile.h > confdefs.h
1909 BUILTIN_ENCS=["`sed -n -e '/^BUILTIN_ENCS[ ]*=/{' \
1910 -e s/// -e :l -e '/\\\\$/N' -e 's/\\\\\\n/ /' -e 't l' -e p \
1911 -e '}' "${srcdir}/enc/Makefile.in"`"]
1913 for e in $BUILTIN_ENCS; do BUILTIN_ENCOBJS="$BUILTIN_ENCOBJS `basename $e .c`"'.$(OBJEXT)'; done
1914 AC_SUBST(BUILTIN_ENCOBJS)
1916 AC_CONFIG_FILES($FIRSTMAKEFILE)
1917 AC_CONFIG_FILES(Makefile, [{
1918 sed '/^MISSING/s/\$U\././g' Makefile
1919 echo; test x"$EXEEXT" = x || echo 'miniruby: miniruby$(EXEEXT)'
1920 test "$RUBY_INSTALL_NAME$EXEEXT" = ruby || echo 'ruby: $(PROGRAM);'
1921 sed ['s/{\$([^(){}]*)[^{}]*}//g'] ${srcdir}/common.mk
1922 } >> confmk$$.tmp && mv -f confmk$$.tmp Makefile],
1923 [RUBY_INSTALL_NAME=$RUBY_INSTALL_NAME EXEEXT=$EXEEXT])