* transcode_data.h (rb_trans_elem_t): new field: from and to.
[ruby-svn.git] / configure.in
blobbd38c2b8b486cdbe1c10850d3092a9fdd350cece
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT()
4 AC_PREREQ(2.60)
6 AC_ARG_WITH(baseruby,
7         [  --with-baseruby=RUBY use RUBY as baseruby; RUBY is the pathname of ruby],
8         [
9                 case "$withval" in
10                 *ruby*)
11                         BASERUBY=$withval
12                         ;;
13                 *)
14                         AC_MSG_ERROR(need ruby)
15                         ;;
16                 esac
17         ],
18         [
19                 BASERUBY="ruby"
20         ])
21 test "`$BASERUBY -e 'p 42' 2>/dev/null`" = 42 ||
22     BASERUBY="echo executable host ruby is required.  use --with-baseruby option.; false"
23 AC_SUBST(BASERUBY)
25 AC_DEFUN([RUBY_MINGW32],
26 [case "$host_os" in
27 cygwin*)
28 AC_CACHE_CHECK(for mingw32 environment, rb_cv_mingw32,
29 [AC_TRY_CPP([
30 #ifndef __MINGW32__
31 # error
32 #endif
33 ], rb_cv_mingw32=yes,rb_cv_mingw32=no)
34 rm -f conftest*])
35 test "$rb_cv_mingw32" = yes && target_os="mingw32"
36   ;;
37 esac])
39 AC_DEFUN([RUBY_CPPOUTFILE],
40 [AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
41 [cppflags=$CPPFLAGS
42 CPPFLAGS='-o conftest.i'
43 AC_TRY_CPP([], rb_cv_cppoutfile=yes, rb_cv_cppoutfile=no)
44 CPPFLAGS=$cppflags
45 rm -f conftest*])
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
58   rb_cv_prog_gnu_ld=yes
59 else
60   rb_cv_prog_gnu_ld=no
63 GNU_LD=$rb_cv_prog_gnu_ld
64 AC_SUBST(GNU_LD)])
66 unset GREP_OPTIONS
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)
80 AC_SUBST(MAJOR)
81 AC_SUBST(MINOR)
82 AC_SUBST(TEENY)
83 dnl checks for alternative programs
84 AC_ARG_WITH(gcc, [  --without-gcc           never use gcc], [
85         case $withval in
86         no)     : ${CC=cc}
87                 ;;
88         yes)    : ${CC=gcc}
89                 ;;
90         *)      CC=$withval
91                 ;;
92         esac])
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"
95 then
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
101   program_prefix=
104 AC_CANONICAL_TARGET
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 ',' ' '`
131         else
132             # Choose a default set of architectures based upon platform.
133             case "$target_os" in
134             darwin*)
135                 TARGET_ARCHS="ppc"
136                 ;;
137             rhapsody*)
138                 TARGET_ARCHS="ppc i386"
139                 ;;
140             openstep*)
141                 TARGET_ARCHS="m68k i386 sparc"
142                 ;;
143             nextstep*)
144                 TARGET_ARCHS="m68k i386 sparc hppa"
145                 ;;
146             *)
147                 TARGET_ARCHS=`arch`
148             esac
149         fi
150     fi
152     AC_MSG_RESULT([$TARGET_ARCHS])
154     # /usr/lib/arch_tool -archify_list $TARGET_ARCHS
155     ARCH_FLAG=
156     for archs in $TARGET_ARCHS 
157     do
158         ARCH_FLAG="$ARCH_FLAG -arch $archs"
159     done
160     AC_DEFINE(NEXT_FAT_BINARY)
162 ], [fat_binary=no])
164 case $target_cpu in
165   i?86) frame_address=yes;;
166   *)    frame_address=no;;
167 esac
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)
175 AC_ARG_PROGRAM
177 dnl Checks for programs.
179 : ${CFLAGS=} ${cflags='${optflags} ${debugflags} ${warnflags}'}
180 : ${CXXFLAGS=} ${cxxflags='${optflags} ${debugflags} ${warnflags}'}
181 if test x"${build}" != x"${host}"; then
182   AC_CHECK_TOOL(CC, gcc)
184 AC_PROG_CC
185 AC_PROG_CXX
186 AC_PROG_GCC_TRADITIONAL
187 test $ac_cv_prog_cc_g = yes && : ${debugflags=-g}
188 if test "$GCC" = yes; then
189     linker_flag=-Wl,
190     : ${optflags=-O2} ${warnflags="-Wall -Wno-parentheses"}
191 else
192     linker_flag=
194 CFLAGS="${CFLAGS} `eval echo $cflags`"
195 CXXFLAGS="${CXXFLAGS} `eval echo $cxxflags`"
197 RUBY_PROG_GNU_LD
198 RUBY_CPPOUTFILE
200 : ${OUTFLAG='-o '}
201 : ${COUTFLAG=${OUTFLAG}}
202 AC_SUBST(OUTFLAG)
203 AC_SUBST(COUTFLAG)
205 RUBY_MINGW32
207 AC_CHECK_TOOL(RANLIB, ranlib, :)
208 AC_CHECK_TOOL(AR, ar)
209 if test -z "$AR"; then
210   AC_CHECK_PROGS(AR, aal, ar)
213 AC_CHECK_TOOL(AS, as)
214 ASFLAGS=$ASFLAGS
215 AC_SUBST(ASFLAGS)
217 case "$target_os" in
218 cygwin*|mingw*)
219     AC_CHECK_TOOL(NM, nm)
220     AC_CHECK_TOOL(WINDRES, windres)
221     AC_CHECK_TOOL(DLLWRAP, dllwrap)
222     target_cpu=`echo $target_cpu | sed s/i.86/i386/`
223     case "$target_os" in
224     mingw*)
225         test "$rb_cv_msvcrt" = "" && unset rb_cv_msvcrt
226         AC_CHECK_TOOL(OBJDUMP, objdump)
227         AC_CACHE_CHECK(for mingw32 runtime DLL, rb_cv_msvcrt, [
228         AC_TRY_LINK([#include <stdio.h>],
229                     [FILE* volatile f = stdin; return 0;],
230                     [rb_cv_msvcrt=`$OBJDUMP -p conftest$ac_exeext |
231                                    tr A-Z a-z |
232                                    sed -n '/^[[         ]]*dll name: \(msvc.*\)\.dll$/{s//\1/p;q;}'`],
233                     [rb_cv_msvcrt=msvcrt])
234         test "$rb_cv_msvcrt" = "" && rb_cv_msvcrt=msvcrt])
235     esac
236     : ${enable_shared=yes}
237     ;;
238 aix*)
239     AC_CHECK_TOOL(NM, nm, /usr/ccs/bin/nm, /usr/ccs/bin:$PATH)
240     ;;
241 hiuxmpp*)
242     # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
243     AC_DEFINE(__HIUX_MPP__)
244     ;;
245 esac
247 AC_PROG_LN_S
248 AC_PROG_MAKE_SET
249 AC_PROG_INSTALL
251 # checks for UNIX variants that set C preprocessor variables
252 AC_USE_SYSTEM_EXTENSIONS
254 AC_SUBST(RM, ['rm -f'])
255 AC_SUBST(CP, ['cp'])
256 if $as_mkdir_p; then
257   MAKEDIRS='mkdir -p'
258 else
259   MAKEDIRS='install -d'
261 AC_SUBST(MAKEDIRS)
263 dnl check for large file stuff
264 mv confdefs.h confdefs1.h
265 : > confdefs.h
266 AC_SYS_LARGEFILE
267 mv confdefs.h largefile.h
268 mv confdefs1.h confdefs.h
269 cat largefile.h >> confdefs.h
271 case "$target_os" in
272 mingw*)
273         ac_cv_type_off_t=yes
274         ac_cv_sizeof_off_t=8
275         ;;
276 esac
278 AC_CHECK_TYPES([long long, off_t])
280 AC_CHECK_SIZEOF(int, 4)
281 AC_CHECK_SIZEOF(short, 2)
282 AC_CHECK_SIZEOF(long, 4)
283 AC_CHECK_SIZEOF(long long, 0)
284 AC_CHECK_SIZEOF(__int64, 0)
285 AC_CHECK_SIZEOF(off_t, 0)
286 AC_CHECK_SIZEOF(void*, 4)
287 AC_CHECK_SIZEOF(float, 4)
288 AC_CHECK_SIZEOF(double, 8)
289 AC_CHECK_SIZEOF(time_t, 0)
291 dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
292 AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
293     AC_CHECK_TYPE([$1],
294         [AC_DEFINE_UNQUOTED(rb_[$1], [$1])],
295         [AC_DEFINE_UNQUOTED(rb_[$1], [$2])],
296         [$4])
297     AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
298         u= t=
299         AC_COMPILE_IFELSE(
300             [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
301                                       [$4], [(rb_[$1])-1 > 0])],
302             [u=U])
303         if test x"$t" = x; then
304             AC_COMPILE_IFELSE(
305                 [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
306                                           [$4], [sizeof(rb_[$1]) > sizeof(long)])],
307                 [t=LL])
308         fi
309         if test x"$t" = x; then
310             AC_COMPILE_IFELSE(
311                 [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
312                                           [$4], [sizeof(rb_[$1]) == sizeof(long)])],
313                 [t=LONG])
314         fi
315         if test x"$t" = x; then
316             t=INT
317         fi
318         rb_cv_[$1]_convertible=${u}${t}])
319     AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)])
320     AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)])
322 RUBY_REPLACE_TYPE(pid_t, int, PIDT)
323 RUBY_REPLACE_TYPE(uid_t, int, UIDT)
324 RUBY_REPLACE_TYPE(gid_t, int, GIDT)
326 AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
327   [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
328         rb_cv_have_prototypes=yes,
329         rb_cv_have_prototypes=no)])
330 if test "$rb_cv_have_prototypes" = yes; then
331   AC_DEFINE(HAVE_PROTOTYPES)
334 AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
335   [AC_TRY_COMPILE([#define paste(a,b) a##b],
336                   [int xy = 1; return paste(x,y);],
337                   rb_cv_tokenpaste=ansi,
338                   rb_cv_tokenpaste=knr)])
339 if test "$rb_cv_tokenpaste" = ansi; then
340   AC_DEFINE(TOKEN_PASTE(x,y),[x##y])
341 else
342   AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
345 AC_CACHE_CHECK(stringization, rb_cv_stringization, [
346   rb_cv_stringization=no
347   for string in "#expr" '"expr"'; do
348     AC_COMPILE_IFELSE([
349       AC_LANG_BOOL_COMPILE_TRY([
350 #define STRINGIZE0(expr) $string
351 #define STRINGIZE(expr) STRINGIZE0(expr)
352 #undef real_test_for_stringization
353 #define test_for_stringization -.real_test_for_stringization.-
354 const char stringized[[]] = STRINGIZE(test_for_stringization);
355 ], [sizeof(stringized) == 32])],
356       [rb_cv_stringization="$string"; break],
357       [rb_cv_stringization=no])
358   done]
360 AC_DEFINE(STRINGIZE(expr),STRINGIZE0(expr))
361 if test x"$rb_cv_stringization" != xno -a "$rb_cv_stringization" != "#expr"; then
362   AC_DEFINE_UNQUOTED(STRINGIZE0(expr),$rb_cv_stringization)
363   AC_DEFINE(OLD_FASHIONED_STRINGIZATION,1)
366 AC_CACHE_CHECK([string literal concatenation],
367   rb_cv_string_literal_concatenation, [
368   AC_COMPILE_IFELSE([
369     AC_LANG_BOOL_COMPILE_TRY([
370 const char concatenated_literal[[]] = "literals" "to"
371   "be" "concatenated.";
372 ], [sizeof(concatenated_literal) == 26])],
373     [rb_cv_string_literal_concatenation=yes],
374     [rb_cv_string_literal_concatenation=no])]
376 if test "$rb_cv_string_literal_concatenation" = no; then
377   AC_DEFINE(NO_STRING_LITERAL_CONCATENATION,1)
380 AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
381   [AC_TRY_COMPILE([
382 #include <stdarg.h>
383 int foo(int x, ...) {
384         va_list va;
385         va_start(va, x);
386         va_arg(va, int);
387         va_arg(va, char *);
388         va_arg(va, double);
389         return 0;
391 ], [return foo(10, "", 3.14);],
392         rb_cv_stdarg=yes,
393         rb_cv_stdarg=no)])
394 if test "$rb_cv_stdarg" = yes; then
395   AC_DEFINE(HAVE_STDARG_PROTOTYPES)
398 AC_CACHE_CHECK(for variable length macro, rb_cv_va_args_macro,
399   [AC_TRY_COMPILE([@%:@define FOO(a, ...) foo(a, @%:@@%:@__VA_ARGS__)],
400   [FOO(1);FOO(1,2);FOO(1,2,3);],
401   rb_cv_va_args_macro=yes,
402   rb_cv_va_args_macro=no)])
403 if test "$rb_cv_va_args_macro" = yes; then
404   AC_DEFINE(HAVE_VA_ARGS_MACRO)
407 AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
408 m4_ifval([$2], dnl
409   [AS_VAR_PUSHDEF([attrib],[$2])], dnl
410   [AS_VAR_PUSHDEF([attrib],[FUNC_]AS_TR_CPP($1))] dnl
411 )dnl
412 m4_ifval([$3], dnl
413   [AS_VAR_PUSHDEF([rbcv],[$3])], dnl
414   [AS_VAR_PUSHDEF([rbcv],[rb_cv_func_][$1])]dnl
415 )dnl
416 AC_CACHE_CHECK(for [$1] function attribute, rbcv,
417 [rbcv=x
418 if test "${ac_c_werror_flag+set}"; then
419   rb_c_werror_flag="$ac_c_werror_flag"
420 else
421   unset rb_c_werror_flag
423 ac_c_werror_flag=yes
424 for mac in "__attribute__ (($1)) x" "x __attribute__ (($1))" "__declspec($1) x" x; do
425   AC_TRY_COMPILE(
426     [#define ]attrib[(x) $mac
427     ]attrib[(void conftest_attribute_check(void));], [],
428     [rbcv="$mac"; break])
429 done
430 if test "${rb_c_werror_flag+set}"; then
431   ac_c_werror_flag="$rb_c_werror_flag"
432 else
433   unset ac_c_werror_flag
436 AC_DEFINE_UNQUOTED(attrib[(x)], $rbcv)
437 AS_VAR_POPDEF([attrib])
438 AS_VAR_POPDEF([rbcv])
441 RUBY_FUNC_ATTRIBUTE(noreturn, NORETURN)
442 RUBY_FUNC_ATTRIBUTE(deprecated, DEPRECATED)
443 RUBY_FUNC_ATTRIBUTE(noinline, NOINLINE)
444 RUBY_FUNC_ATTRIBUTE(stdcall)
445 RUBY_FUNC_ATTRIBUTE(cdecl)
446 RUBY_FUNC_ATTRIBUTE(fastcall)
448 AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
449 [rb_cv_ruby_extern=no
450 for mac in "__attribute__((dllimport))" "__declspec(dllimport)"; do
451   AC_TRY_COMPILE(
452     [extern $mac void conftest(void);],
453     [rb_cv_ruby_extern="extern $mac"; break])
454 done])
455 test "x$rb_cv_ruby_extern" = xno || AC_DEFINE_UNQUOTED(RUBY_EXTERN, $rb_cv_ruby_extern)
457 XCFLAGS="$XCFLAGS -DRUBY_EXPORT"
459 dnl Check whether we need to define sys_nerr locally
460 AC_CHECK_DECLS([sys_nerr], [], [], [$ac_includes_default
461 #include <errno.h>])
463 case "$target_os" in
464 freebsd*)
465   AC_CACHE_CHECK([whether pthread should be enabled by default],
466     rb_cv_enable_pthread_default,
467     [AC_TRY_CPP([
468 #include <osreldate.h>
469 #if __FreeBSD_version < 502102
470 #error pthread should be disabled on this platform
471 #endif
472       ],
473       rb_cv_enable_pthread_default=yes,
474       rb_cv_enable_pthread_default=no)])
475   enable_pthread_default=$rb_cv_enable_pthread_default
476   ;;
477 mingw*)
478   enable_pthread_default=no
479   ;;
481   enable_pthread_default=yes
482   ;;
483 esac
485 AC_ARG_ENABLE(pthread,
486        [  --enable-pthread        use pthread library.],
487        [enable_pthread=$enableval], [enable_pthread=$enable_pthread_default])
489 dnl Checks for libraries.
490 case "$target_os" in
491 nextstep*)      ;;
492 openstep*)      ;;
493 rhapsody*)      ;;
494 darwin*)        LIBS="-lobjc $LIBS"
495                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE"
496                 AC_TRY_CPP([#include <AvailabilityMacros.h>
497                     #if MAC_OS_X_VERSION_MAX_ALLOWED <= 1040
498                     #error pre OS X 10.4
499                     [!<===== pre OS X 10.4 =====>]
500                     #endif
501                     ],
502                     [
503                     test "x$target_cpu" = xppc && ac_cv_header_ucontext_h=no
504                     ],
505                     [
506                     AC_DEFINE(BROKEN_SETREUID, 1)
507                     AC_DEFINE(BROKEN_SETREGID, 1)
508                     ])
509                 ;;
510 hpux*)          LIBS="-lm $LIBS"
511                 ac_cv_c_inline=no;;
512 human*)         ac_cv_func_getpgrp_void=yes
513                 ac_cv_func_setitimer=no
514                 ;;
515 beos*|haiku*)   ac_cv_func_link=no
516                 ac_cv_func_sched_yield=no
517                 ac_cv_func_pthread_attr_setinheritsched=no
518                 case "$target_os" in
519                 beos*) ac_cv_header_net_socket_h=yes;;
520                 haiku*) ac_cv_func_shutdown=no;;
521                 esac
522                 LIBS="$LIBS" # m lib is include in root under BeOS/Haiku
523                 ;;
524 cygwin*)        ;;
525 mingw*)         LIBS="-lshell32 -lws2_32 $LIBS"
526                 ac_cv_header_a_out_h=no
527                 ac_cv_header_pwd_h=no
528                 ac_cv_header_utime_h=no
529                 ac_cv_header_sys_ioctl_h=no
530                 ac_cv_header_sys_param_h=no
531                 ac_cv_header_sys_resource_h=no
532                 ac_cv_header_sys_select_h=no
533                 ac_cv_header_sys_time_h=no
534                 ac_cv_header_sys_times_h=no
535                 ac_cv_header_sys_socket_h=no
536                 ac_cv_func_times=yes
537                 ac_cv_func_waitpid=yes
538                 ac_cv_func_fsync=yes
539                 ac_cv_func_snprintf=yes
540                 ac_cv_func_vsnprintf=yes
541                 ac_cv_func_seekdir=yes
542                 ac_cv_func_telldir=yes
543                 ac_cv_func_isinf=yes
544                 ac_cv_func_isnan=yes
545                 ac_cv_func_finite=yes
546                 ac_cv_func_link=yes
547                 ac_cv_func_truncate=yes
548                 ac_cv_func_fseeko=yes
549                 ac_cv_func_ftello=yes
550                 ac_cv_lib_crypt_crypt=no
551                 ac_cv_func_getpgrp_void=no
552                 ac_cv_func_setpgrp_void=yes
553                 ac_cv_func_memcmp_working=yes
554                 ac_cv_lib_dl_dlopen=no
555                 rb_cv_binary_elf=no
556                 rb_cv_negative_time_t=no
557                 ac_cv_func_fcntl=yes
558                 ;;
559 os2-emx*)       LIBS="-lm $LIBS"
560                 ac_cv_lib_dir_opendir=no;;
561 msdosdjgpp*)    LIBS="-lm $LIBS"
562                 ac_cv_func_getpgrp_void=yes
563                 ac_cv_func_setitimer=no
564                 ac_cv_sizeof_rlim_t=4
565                 ac_cv_func_fork=no
566                 ac_cv_func_setrlimit=no
567                 ac_cv_header_sys_socket_h=no
568                 ;;
569 bsdi*)          LIBS="-lm $LIBS"
570                 AC_DEFINE(BROKEN_SETREUID, 1)
571                 AC_DEFINE(BROKEN_SETREGID, 1)
572                 ac_cv_sizeof_rlim_t=8;;
573 freebsd*)       LIBS="-lm $LIBS"
574                 AC_CACHE_CHECK([whether -lxpg4 has to be linked],
575                   rb_cv_lib_xpg4_needed,
576                   [AC_TRY_CPP([
577 #include <osreldate.h>
578 #if __FreeBSD_version < 400020 || \
579    (__FreeBSD_version >= 500000 && __FreeBSD_version < 500005)
580 #error needs libxpg4
581 #endif
582                    ],
583                    rb_cv_lib_xpg4_needed=no,
584                    rb_cv_lib_xpg4_needed=yes,
585                    rb_cv_lib_xpg4_needed=yes)])
586                 if test "$rb_cv_lib_xpg4_needed" = yes; then
587                         AC_CHECK_LIB(xpg4, setlocale)
588                 fi
589                 ;;
590 dragonfly*)     LIBS="-lm $LIBS"
591                 ;;
592 bow)            ac_cv_func_setitimer=no
593                 ;;
594 superux*)     ac_cv_func_setitimer=no
595               ;;
596 *) LIBS="-lm $LIBS";;
597 esac
598 AC_CHECK_LIB(crypt, crypt)
599 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
600 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
601 AC_CHECK_LIB(socket, socketpair)        # SunOS/Solaris
602 AC_CHECK_LIB(rt, clock_gettime) # GNU/Linux
604 case "$target_cpu" in
605 alpha*)         case "$target_os"::"$GCC" in
606                 *::yes) CFLAGS="-mieee $CFLAGS" ;;   # gcc
607                 osf*)   CFLAGS="-ieee $CFLAGS" ;;    # ccc
608                 esac ;;
609 esac
611 ac_cv_header_net_socket_h=${ac_cv_header_net_socket_h=no}
612 if test "$ac_cv_header_net_socket_h" = yes; then
613     ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=no}
614 else
615     ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=yes}
618 dnl Checks for header files.
619 AC_HEADER_DIRENT
620 AC_HEADER_STDC
621 AC_HEADER_SYS_WAIT
622 AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h sys/syscall.h\
623                  fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
624                  syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \
625                  sys/mkdev.h sys/utime.h xti.h netinet/in_systm.h float.h ieeefp.h pthread.h \
626                  ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h \
627                  net/socket.h sys/socket.h)
629 dnl Check additional types.
630 AC_CHECK_SIZEOF(rlim_t, 0, [
631   #ifdef HAVE_SYS_TYPES_H
632   # include <sys/types.h>
633   #endif
634   #ifdef HAVE_SYS_TIME_H
635   # include <sys/time.h>
636   #endif
637   #ifdef HAVE_SYS_RESOURCE_H
638   # include <sys/resource.h>
639   #endif
640   #ifdef HAVE_UNISTD_H
641   # include <unistd.h>
642   #endif
643   #include <stdio.h>
646 dnl Checks for typedefs, structures, and compiler characteristics.
647 AC_TYPE_SIZE_T
648 AC_CHECK_SIZEOF(size_t, 0)
649 AC_CHECK_SIZEOF(ptrdiff_t, $ac_cv_sizeof_size_t)
650 AC_STRUCT_ST_BLKSIZE
651 AC_STRUCT_ST_BLOCKS
652 AC_STRUCT_ST_RDEV
653 AC_CHECK_MEMBERS([struct stat.st_atim])
654 AC_CHECK_MEMBERS([struct stat.st_atimespec])
655 AC_CHECK_MEMBERS([struct stat.st_atimensec])
656 AC_CHECK_MEMBERS([struct stat.st_mtim])
657 AC_CHECK_MEMBERS([struct stat.st_mtimespec])
658 AC_CHECK_MEMBERS([struct stat.st_mtimensec])
659 AC_CHECK_MEMBERS([struct stat.st_ctim])
660 AC_CHECK_MEMBERS([struct stat.st_ctimespec])
661 AC_CHECK_MEMBERS([struct stat.st_ctimensec])
663 AC_CHECK_TYPES([struct timespec], [], [], [@%:@ifdef HAVE_TIME_H
664 @%:@include <time.h>
665 @%:@endif])
667 AC_CHECK_TYPE(fd_mask, [AC_DEFINE(HAVE_RB_FD_INIT, 1)])
669 dnl RUBY_DEFINT TYPENAME, SIZE, [SIGNED-OR-UNSIGNED], [INCLUDES = DEFAULT-INCLUDES]
670 AC_DEFUN([RUBY_DEFINT], [dnl
671 AC_CACHE_CHECK([for $1], [rb_cv_type_$1],
672 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])
673 typedef $1 t; int s = sizeof(t) == 42;])],
674    [rb_cv_type_$1=yes],
675    [case m4_bmatch([$2], [^[1-9][0-9]*$], $2, [$ac_cv_sizeof_]AS_TR_SH($2)) in
676     "1") rb_cv_type_$1="m4_if([$3], [], [signed ], [$3 ])char";;
677     "$ac_cv_sizeof_short") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])short";;
678     "$ac_cv_sizeof_int") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])int";;
679     "$ac_cv_sizeof_long") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long";;
680     "$ac_cv_sizeof_long_long") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long long";;
681     "$ac_cv_sizeof___int64") rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int64";;
682     *) rb_cv_type_$1=no;;
683     esac])])
684 if test "${rb_cv_type_$1}" != no; then
685     AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)
686     test "${rb_cv_type_$1}" = yes || AC_DEFINE_UNQUOTED($1, [$rb_cv_type_$1])
690 RUBY_DEFINT(int8_t, 1)
691 RUBY_DEFINT(uint8_t, 1, unsigned)
692 RUBY_DEFINT(int16_t, 2)
693 RUBY_DEFINT(uint16_t, 2, unsigned)
694 RUBY_DEFINT(int32_t, 4)
695 RUBY_DEFINT(uint32_t, 4, unsigned)
696 RUBY_DEFINT(int64_t, 8)
697 RUBY_DEFINT(uint64_t, 8, unsigned)
698 RUBY_DEFINT(int128_t, 16)
699 RUBY_DEFINT(uint128_t, 16, unsigned)
700 RUBY_DEFINT(intptr_t, void*)
701 RUBY_DEFINT(uintptr_t, void*, unsigned)
702 RUBY_DEFINT(ssize_t, size_t)    dnl may differ from int, so not use AC_TYPE_SSIZE_T.
704 AC_CACHE_CHECK(for stack end address, rb_cv_stack_end_address,
705 [rb_cv_stack_end_address=no
706 for addr in __libc_stack_end _SEND; do
707   AC_TRY_LINK(
708     [extern void *$addr;],
709     [if (!$addr) return 1;],
710     [rb_cv_stack_end_address="$addr"; break])
711 done])
712 if test $rb_cv_stack_end_address != no; then
713   AC_DEFINE_UNQUOTED(STACK_END_ADDRESS, $rb_cv_stack_end_address)
716 dnl Checks for library functions.
717 AC_TYPE_GETGROUPS
718 AC_TYPE_SIGNAL
719 case "${target_cpu}-${target_os}" in
720 powerpc-darwin*)
721   AC_LIBSOURCES(alloca.c)
722   AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}])
723   AC_DEFINE(C_ALLOCA)
724   AC_DEFINE_UNQUOTED(alloca, alloca)
725   ;;
727   AC_FUNC_ALLOCA
728   ;;
729 esac
730 AC_FUNC_MEMCMP
732 # http://sources.redhat.com/ml/libc-hacker/2005-08/msg00008.html
733 # Debian GNU/Linux Etch's libc6.1 2.3.6.ds1-13etch5 has this problem.
734 # Debian GNU/Linux Lenny's libc6.1 2.7-10 has no problem.
735 AC_CACHE_CHECK(for broken erfc of glibc-2.3.6 on IA64, rb_cv_broken_glibc_ia64_erfc,
736   [AC_TRY_RUN([
737 #include <math.h>
739 main()
741    erfc(10000.0);
742    return 0;
745         rb_cv_broken_glibc_ia64_erfc=no,
746         rb_cv_broken_glibc_ia64_erfc=yes,
747         rb_cv_broken_glibc_ia64_erfc=no)])
748 case $rb_cv_broken_glibc_ia64_erfc in
749   yes) ac_cv_func_erf=no;;
750 esac
752 AC_REPLACE_FUNCS(dup2 memmove strerror strftime\
753                  strchr strstr crypt flock vsnprintf\
754                  isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt \
755                  strlcpy strlcat)
756 AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd eaccess\
757               truncate ftruncate chsize times utimes utimensat fcntl lockf lstat\
758               link symlink readlink\
759               setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
760               setrgid setegid setregid setresgid issetugid pause lchown lchmod\
761               getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
762               getpriority getrlimit setrlimit sysconf group_member\
763               dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp vsnprintf snprintf\
764               setsid telldir seekdir fchmod cosh sinh tanh log2 round signbit\
765               setuid setgid daemon select_large_fdset setenv unsetenv\
766               mktime timegm clock_gettime gettimeofday\
767               pread sendfile shutdown)
769 AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp,
770 [AC_TRY_LINK([@%:@include <setjmp.h>
771     jmp_buf jb; void t(v) int v; {__builtin_longjmp(jb, v);}],
772     [__builtin_setjmp(jb);],
773     [ac_cv_func___builtin_setjmp=yes],
774     [ac_cv_func___builtin_setjmp=no])
777 test x$ac_cv_func__longjmp = xno && ac_cv_func__setjmp=no
779 AC_MSG_CHECKING(for setjmp type)
780 AC_ARG_WITH(setjmp-type, 
781         [  --with-setjmp-type      select setjmp type], [
782         case $withval in
783         __builtin_setjmp) setjmp_prefix=__builtin_;;
784         _setjmp) setjmp_prefix=_;;
785         sigsetjmp) setjmp_prefix=sig;;
786         setjmp) setjmp_prefix=;;
787         '') unset setjmp_prefix;;
788         *)   AC_MSG_ERROR(invalid setjmp type: $withval);;
789         esac], [unset setjmp_prefix])
790 if test ${setjmp_prefix+set}; then
791     if test "${setjmp_prefix}" && eval test '$ac_cv_func_'${setjmp_prefix}setjmp = no; then
792         AC_MSG_ERROR(${setjmp_prefix}setjmp is not available)
793     fi
794 elif test "$ac_cv_func___builtin_setjmp" = yes; then
795     setjmp_prefix=__builtin_
796 elif test "$ac_cv_func__setjmp" = yes; then
797     setjmp_prefix=_
798 elif test "$ac_cv_func_sigsetjmp" = yes; then
799     case $target_os in
800     solaris*|cygwin*)
801         setjmp_prefix=;;
802     *)
803         setjmp_prefix=sig;;
804     esac
805 else
806     setjmp_prefix=
808 if test x$setjmp_prefix = xsig; then
809     setjmp_sigmask=yes
810 else
811     unset setjmp_sigmask
813 AC_MSG_RESULT(${setjmp_prefix}setjmp)
814 AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp(env${setjmp_sigmask+,0})])
815 AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)])
816 AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
818 AC_ARG_ENABLE(setreuid,
819        [  --enable-setreuid       use setreuid()/setregid() according to need even if obsolete.],
820        [use_setreuid=$enableval])
821 if test "$use_setreuid" = yes; then
822     AC_DEFINE(USE_SETREUID)
823     AC_DEFINE(USE_SETREGID)
825 AC_STRUCT_TIMEZONE
826 AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
827   [AC_TRY_COMPILE([#include <time.h>],
828     [struct tm t; t.tm_gmtoff = 3600;],
829   [rb_cv_member_struct_tm_tm_gmtoff=yes],
830   [rb_cv_member_struct_tm_tm_gmtoff=no])])
831 if test "$rb_cv_member_struct_tm_tm_gmtoff" = yes; then
832   AC_DEFINE(HAVE_STRUCT_TM_TM_GMTOFF)
834 AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
835   [AC_TRY_LINK([#include <time.h>
836   int i;],
837         [i = daylight;],
838         rb_cv_have_daylight=yes,
839         rb_cv_have_daylight=no)])
840 if test "$rb_cv_have_daylight" = yes; then
841   AC_DEFINE(HAVE_DAYLIGHT)
843 AC_DEFUN([RUBY_CHECK_VARTYPE], [dnl
844 AC_CACHE_CHECK([for external $1], rb_cv_var_$1,
845   [rb_cv_var_$1=no
846   AC_TRY_COMPILE([
847 #ifndef _XOPEN_SOURCE
848 #define _XOPEN_SOURCE 1
849 #endif
852 const volatile void *volatile t;],
853     [t = &(&$1)[0];],
854     [for t in $3; do
855       AC_TRY_COMPILE([
856 #ifndef _XOPEN_SOURCE
857 #define _XOPEN_SOURCE 1
858 #endif
861 extern $t $1;
862 const volatile void *volatile t;],
863         [t = &(&$1)[0];],
864         [rb_cv_var_$1=$t; break])
865     done])])
866 if test "[$rb_cv_var_]$1" != no; then
867   AC_DEFINE([HAVE_VAR_]m4_toupper($1))
868   AC_DEFINE_UNQUOTED([TYPEOF_VAR_]m4_toupper($1), $rb_cv_var_$1)
869 fi])
870 RUBY_CHECK_VARTYPE(timezone, [@%:@include <time.h>], [long int])
871 RUBY_CHECK_VARTYPE(altzone, [@%:@include <time.h>], [long int])
872 if test "$rb_cv_var_timezone" = no; then
873   AC_CHECK_FUNCS(timezone)
874   if test "$ac_cv_func_timezone" = yes; then
875     AC_CACHE_CHECK([whether timezone requires zero arguments], rb_cv_func_timezone_void,
876       [AC_TRY_COMPILE([@%:@include <time.h>],
877         [(void)timezone(0, 0);],
878         [rb_cv_func_timezone_void=no],
879         [rb_cv_func_timezone_void=yes])]
880     )
881     if test $rb_cv_func_timezone_void = yes; then
882       AC_DEFINE(TIMEZONE_VOID)
883     fi
884   fi
887 AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
888   [AC_TRY_RUN([
889 #include <time.h>
891 void
892 check(tm, y, m, d, h, s)
893     struct tm *tm;
894     int y, m, d, h, s;
896     if (!tm ||
897         tm->tm_year != y ||
898         tm->tm_mon  != m-1 ||
899         tm->tm_mday != d ||
900         tm->tm_hour != h ||
901         tm->tm_sec  != s) {
902         exit(1);
903     }
907 main()
909    time_t t = -1;
910    struct tm *tm;
912    check(gmtime(&t), 69, 12, 31, 23, 59);
913    t = ~(time_t)0 << 31;
914    check(gmtime(&t), 1, 12, 13, 20, 52);
915    return 0;
918         rb_cv_negative_time_t=yes,
919         rb_cv_negative_time_t=no,
920         rb_cv_negative_time_t=yes)])
921 if test "$rb_cv_negative_time_t" = yes; then
922   AC_DEFINE(NEGATIVE_TIME_T)
925 if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
926    AC_DEFINE(POSIX_SIGNAL)
927 else
928   AC_CHECK_FUNCS(sigsetmask)
929   AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
930     [AC_TRY_RUN([
931 #include <stdio.h>
932 #include <signal.h>
934 void
935 sig_handler(dummy)
936      int dummy;
941 main()
943   signal(SIGINT, sig_handler);
944   kill(getpid(), SIGINT);
945   kill(getpid(), SIGINT);
946   return 0;
949         rb_cv_bsd_signal=yes,
950         rb_cv_bsd_signal=no,
951         rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
952   if test "$rb_cv_bsd_signal" = yes; then
953     AC_DEFINE(BSD_SIGNAL)
954   fi
957 AC_FUNC_GETPGRP
958 AC_FUNC_SETPGRP  
960 AC_C_BIGENDIAN
961 AC_C_CONST
962 AC_C_CHAR_UNSIGNED
963 AC_C_INLINE
964 AC_C_VOLATILE
966 if test x"$target_cpu" = xia64; then
967     AC_LIBOBJ([ia64])
968     AC_CACHE_CHECK(for __libc_ia64_register_backing_store_base,
969                    rb_cv___libc_ia64_register_backing_store_base,
970     [rb_cv___libc_ia64_register_backing_store_base=no
971     AC_TRY_LINK(
972       [extern unsigned long __libc_ia64_register_backing_store_base;],
973       [unsigned long p = __libc_ia64_register_backing_store_base;
974        printf("%ld\n", p);],
975       [rb_cv___libc_ia64_register_backing_store_base=yes])])
976     if test $rb_cv___libc_ia64_register_backing_store_base = yes; then
977       AC_DEFINE(HAVE___LIBC_IA64_REGISTER_BACKING_STORE_BASE)
978     fi
981 AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
982     [AC_COMPILE_IFELSE(AC_LANG_BOOL_COMPILE_TRY([], [(-1==(-1>>1))]),
983         rb_cv_rshift_sign=yes,
984         rb_cv_rshift_sign=no)])
985 if test "$rb_cv_rshift_sign" = yes; then
986   AC_DEFINE(RSHIFT(x,y), ((x)>>(int)y))
987 else
988   AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
991 AC_MSG_CHECKING(read count field in FILE structures)
992 AC_CACHE_VAL(rb_cv_fcnt,
993 [for fcnt in    dnl
994      _cnt       dnl
995      __cnt      dnl
996      _r         dnl
997      readCount  dnl
998      _rcount    dnl for emx0.9c
999 ; do
1000     AC_TRY_COMPILE([#include <stdio.h>
1002         [FILE *f = stdin; f->$fcnt = 0;],
1003         rb_cv_fcnt="$fcnt"; break,
1004         rb_cv_fcnt="not found")
1005 done])
1006 if test "$rb_cv_fcnt" = "not found"; then
1007   AC_MSG_RESULT([not found(OK if using GNU libc)])
1008 else
1009   AC_MSG_RESULT($rb_cv_fcnt)
1010   AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
1013 AC_MSG_CHECKING(read buffer ptr field in FILE structures)
1014 AC_CACHE_VAL(rb_cv_frptr,
1015 [for frptr in   dnl
1016      _IO_read_ptr dnl
1017      _ptr       dnl
1018      __ptr      dnl
1019      bufpos     dnl
1020      _p dnl
1021 ; do
1022     AC_TRY_COMPILE([#include <stdio.h>
1024         [FILE *f = stdin; char buf[256]; f->$frptr = buf;],
1025         rb_cv_frptr="$frptr"; break,
1026         rb_cv_frptr="not found")
1027 done])
1028 if test "$rb_cv_frptr" = "not found"; then
1029   AC_MSG_RESULT([not found])
1030 else
1031   AC_MSG_RESULT($rb_cv_frptr)
1032   AC_DEFINE_UNQUOTED(FILE_READPTR, $rb_cv_frptr)
1034   if test "$rb_cv_fcnt" = "not found"; then
1035     AC_MSG_CHECKING(read buffer end field in FILE structures)
1036     AC_CACHE_VAL(rb_cv_frend,
1037     [for frend in       dnl
1038          _IO_read_end   dnl
1039          bufread        dnl
1040     ; do
1041         AC_TRY_COMPILE([#include <stdio.h>
1042     ],
1043         [FILE *f = stdin; char buf[256]; f->$frend = buf;],
1044         rb_cv_frend="$frend"; break,
1045         rb_cv_frend="not found")
1046     done])
1047     if test "$rb_cv_frend" = "not found"; then
1048       AC_MSG_RESULT([not found])
1049     else
1050       AC_MSG_RESULT($rb_cv_frend)
1051       AC_DEFINE_UNQUOTED(FILE_READEND, $rb_cv_frend)
1052     fi
1053   fi
1056 AC_CACHE_CHECK([whether st_ino is huge], rb_cv_huge_st_ino,
1057 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([
1058 #include <sys/stat.h>
1059 struct stat test_stat;
1060 ], [sizeof(test_stat.st_ino)>sizeof(long)])],
1061 rb_cv_huge_st_ino=yes,
1062 rb_cv_huge_st_ino=no)
1064 if test $rb_cv_huge_st_ino = yes; then
1065   AC_DEFINE(HUGE_ST_INO)
1068 if test "$ac_cv_func_sysconf" = yes; then
1069   AC_DEFUN([RUBY_CHECK_SYSCONF], [dnl
1070   AC_CACHE_CHECK([whether _SC_$1 is supported], rb_cv_have_sc_[]m4_tolower($1),
1071     [AC_TRY_COMPILE([#include <unistd.h>
1072       ],
1073       [_SC_$1 >= 0],
1074       rb_cv_have_sc_[]m4_tolower($1)=yes,
1075       rb_cv_have_sc_[]m4_tolower($1)=no)
1076     ])
1077   if test "$rb_cv_have_sc_[]m4_tolower($1)" = yes; then
1078     AC_DEFINE(HAVE__SC_$1)
1079   fi
1080   ])
1081   RUBY_CHECK_SYSCONF(CLK_TCK)
1084 case "$target_cpu" in
1085 m68*|i?86|ia64|sparc*|alpha*) rb_cv_stack_grow_dir=-1;;
1086 hppa*) rb_cv_stack_grow_dir=+1;;
1087 esac
1088 AC_CACHE_CHECK(stack growing direction, rb_cv_stack_grow_dir,
1089   [AC_TRY_RUN([
1090 /* recurse to get rid of inlining */
1091 static int
1092 stack_growup_p(addr, n)
1093     volatile int *addr, n;
1095     volatile int end;
1096     if (n > 0)
1097         return *addr = stack_growup_p(addr, n - 1);
1098     else
1099         return (&end > addr);
1101 int main()
1103     int x;
1104     return stack_growup_p(&x, 10);
1106 ], rb_cv_stack_grow_dir=-1, rb_cv_stack_grow_dir=+1, rb_cv_stack_grow_dir=0)])
1107 AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
1109 if test x"$enable_pthread" = xyes; then
1110     for pthread_lib in thr pthread pthreads c c_r root; do
1111         AC_CHECK_LIB($pthread_lib, pthread_kill,
1112                      rb_with_pthread=yes, rb_with_pthread=no)
1113         if test "$rb_with_pthread" = "yes"; then break; fi
1114     done
1115     if test x"$rb_with_pthread" = xyes; then
1116         AC_DEFINE(_REENTRANT)
1117         AC_DEFINE(_THREAD_SAFE)
1118         AC_DEFINE(HAVE_LIBPTHREAD)
1119         case $pthread_lib in
1120         c)
1121             ;;
1122         root)
1123                 ;;
1124         c_r)
1125             MAINLIBS="-pthread $MAINLIBS"
1126             ;;
1127         *)
1128             LIBS="-l$pthread_lib $LIBS"
1129             ;;
1130         esac
1131     else
1132         AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
1133     fi
1134     AC_CHECK_FUNCS(nanosleep sched_yield pthread_attr_setinheritsched)
1135     if test x"$ac_cv_func_nanosleep" = xno; then
1136        AC_CHECK_LIB(rt, nanosleep)
1137        if test x"$ac_cv_lib_rt_nanosleep" = xyes; then
1138            AC_DEFINE(HAVE_NANOSLEEP)
1139        fi
1140     fi
1142 if test x"$ac_cv_header_ucontext_h" = xyes; then
1143     if test x"$rb_with_pthread" = xyes; then
1144         AC_CHECK_FUNCS(getcontext setcontext)
1145     fi
1148 if test "$ac_cv_func_fork" = "yes" -a "$rb_with_pthread" = "yes"; then
1149     AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
1150         [AC_TRY_RUN([
1151 #include <stdlib.h>
1152 #include <unistd.h>
1153 #include <pthread.h>
1154 #include <stdio.h>
1155 #include <sys/types.h>
1156 #include <sys/wait.h>
1157 #include <signal.h>
1158 #ifndef EXIT_SUCCESS
1159 #define EXIT_SUCCESS 0
1160 #endif
1161 #ifndef EXIT_FAILURE
1162 #define EXIT_FAILURE 1
1163 #endif
1165 void *
1166 thread_func(void *dmy)
1168     return dmy;
1172 use_threads(void)
1174     pthread_t tid;
1175     if (pthread_create(&tid, 0, thread_func, 0) != 0) {
1176         return -1;
1177     }
1178     if (pthread_join(tid, 0) != 0) {
1179         return -1;
1180     }
1181     return 0;
1185 main(int argc, char *argv[])
1187     pid_t pid;
1188     if (use_threads()) return EXIT_FAILURE;
1189     pid = fork();
1191     if (pid) {
1192         int loc;
1193         sleep(1);
1194         if (waitpid(pid, &loc, WNOHANG) == 0) {
1195             kill(pid, SIGKILL);
1196             return EXIT_FAILURE;
1197         }
1198     }
1199     else {
1200         if (use_threads()) return EXIT_FAILURE;
1201     }
1203     return EXIT_SUCCESS;
1205         rb_cv_fork_with_pthread=yes,
1206         rb_cv_fork_with_pthread=no,
1207         rb_cv_fork_with_pthread=yes)])
1208     test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
1211 AC_CHECK_FUNCS(backtrace)
1213 AC_ARG_WITH(valgrind,
1214         [  --with-valgrind         enable valgrind memcheck support.],
1215         [AC_CHECK_HEADERS(valgrind/memcheck.h)])
1217 dnl wheather use dln_a_out or not
1218 AC_ARG_WITH(dln-a-out, 
1219         [  --with-dln-a-out        use dln_a_out if possible], [
1220         case $withval in
1221         yes) with_dln_a_out=yes;;
1222         *)   with_dln_a_out=no;;
1223         esac], [with_dln_a_out=no])
1225 AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
1226 [AC_TRY_LINK([],[], [
1227 case "`head -1 conftest$EXEEXT | cat -e`" in
1228 dnl (
1229 '^?ELF'*)
1230     rb_cv_binary_elf=yes;;
1231 dnl (
1233     rb_cv_binary_elf=no;;
1234 esac],
1235 rb_cv_binary_elf=no)])
1237 if test "$rb_cv_binary_elf" = yes; then
1238   AC_DEFINE(USE_ELF)
1241 case "$target_os" in
1242 linux* | gnu* | k*bsd*-gnu | bsdi*)
1243     if test "$rb_cv_binary_elf" = no; then
1244         with_dln_a_out=yes
1245     else
1246         LDFLAGS="$LDFLAGS -rdynamic"
1247     fi;;
1248 esac
1249 LIBEXT=a
1251 AC_SUBST(DLDFLAGS)dnl
1252 AC_SUBST(ARCH_FLAG)dnl
1254 AC_SUBST(STATIC)dnl
1255 AC_SUBST(CCDLFLAGS)dnl
1256 AC_SUBST(LDSHARED)dnl
1257 AC_SUBST(LDSHAREDXX)dnl
1258 AC_SUBST(DLEXT)dnl
1259 AC_SUBST(DLEXT2)dnl
1260 AC_SUBST(LIBEXT)dnl
1262 STATIC=
1263 : ${LIBPATHFLAG=' -L%s'}
1264 : ${PATHFLAG=''}
1266 if test "$with_dln_a_out" != yes; then
1267   rb_cv_dlopen=unknown
1268   AC_MSG_CHECKING(whether OS depend dynamic link works)
1269   if test "$GCC" = yes; then
1270     case "$target_os" in
1271     nextstep*)  CCDLFLAGS="$CCDLFLAGS -fno-common";;
1272     openstep*)  CCDLFLAGS="$CCDLFLAGS -fno-common";;
1273     rhapsody*)  CCDLFLAGS="$CCDLFLAGS -fno-common";;
1274     darwin*)    CCDLFLAGS="$CCDLFLAGS -fno-common";;
1275     human*|bsdi*|beos*|haiku*|cygwin*|mingw*|aix*|interix*) ;;
1276     *) CCDLFLAGS="$CCDLFLAGS -fPIC";;
1277     esac
1278   else
1279     case "$target_os" in
1280         hpux*)          CCDLFLAGS="$CCDLFLAGS +Z";;
1281         solaris*|irix*) CCDLFLAGS="$CCDLFLAGS -KPIC" ;;
1282         sunos*)         CCDLFLAGS="$CCDLFLAGS -PIC" ;;
1283         esix*|uxpds*)   CCDLFLAGS="$CCDLFLAGS -KPIC" ;;
1284         *)              : ${CCDLFLAGS=""} ;;
1285     esac
1286   fi
1289   AC_ARG_ENABLE(rpath,
1290        [  --disable-rpath         embed run path into extension libraries.],
1291        [enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"])
1292   if test "$enable_rpath" = yes; then
1293     LIBPATHFLAG=" -L%1\$-s"
1294     RPATHFLAG=" ${linker_flag}-R%1\$-s"
1295   fi
1297   case "$target_os" in
1298         hpux*)          DLDFLAGS="$DLDFLAGS -E"
1299                         : ${LDSHARED='ld -b'}
1300                         XLDFLAGS="$XLDFLAGS -Wl,-E"
1301                         : ${LIBPATHENV=SHLIB_PATH}
1302                         if test "$rb_cv_prog_gnu_ld" = no; then
1303                             RPATHFLAG=' +b %1$-s'
1304                         fi
1305                         rb_cv_dlopen=yes;;
1306         solaris*)       if test "$GCC" = yes; then
1307                           : ${LDSHARED='$(CC) -shared'}
1308                            if test "$rb_cv_prog_gnu_ld" = yes; then
1309                                LDFLAGS="$LDFLAGS -Wl,-E"
1310                            fi
1311                         else
1312                            : ${LDSHARED='ld -G'}
1313                         fi
1314                         rb_cv_dlopen=yes;;
1315         sunos*)         : ${LDSHARED='ld -assert nodefinitions'}
1316                         rb_cv_dlopen=yes;;
1317         irix*)          : ${LDSHARED='ld -shared'}
1318                         rb_cv_dlopen=yes;;
1319         sysv4*)         : ${LDSHARED='ld -G'}
1320                         rb_cv_dlopen=yes;;
1321         nto-qnx*)       : ${LDSHARED="qcc -shared"}
1322                         rb_cv_dlopen=yes ;;
1323         esix*|uxpds*)   : ${LDSHARED="ld -G"}
1324                         rb_cv_dlopen=yes ;;
1325         osf*)           : ${LDSHARED="ld -shared -expect_unresolved \"*\""}
1326                         rb_cv_dlopen=yes ;;
1327         bsdi3*)         case "$CC" in
1328                         *shlicc*)       : ${LDSHARED="$CC -r"}
1329                                         rb_cv_dlopen=yes ;;
1330                         esac ;;
1331         linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi*)
1332                         : ${LDSHARED='${CC} -shared'}
1333                         if test "$rb_cv_binary_elf" = yes; then
1334                             LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
1335                         fi
1336                         rb_cv_dlopen=yes ;;
1337         interix*)       : ${LDSHARED="$CC -shared"}
1338                         XLDFLAGS="$XLDFLAGS -Wl,-E"
1339                         LIBPATHFLAG=" -L%1\$-s"
1340                         rb_cv_dlopen=yes ;;
1341         freebsd*|dragonfly*)       : ${LDSHARED="$CC -shared"}
1342                         if test "$rb_cv_binary_elf" = yes; then
1343                             LDFLAGS="$LDFLAGS -rdynamic"
1344                             DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)'
1345                         else
1346                           test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED="ld -Bshareable"
1347                         fi
1348                         rb_cv_dlopen=yes ;;
1349         openbsd*)       : ${LDSHARED="\$(CC) -shared ${CCDLFLAGS}"}
1350                         if test "$rb_cv_binary_elf" = yes; then
1351                             LDFLAGS="$LDFLAGS -Wl,-E"
1352                         fi
1353                         rb_cv_dlopen=yes ;;
1354         nextstep*)      : ${LDSHARED='cc -r -nostdlib'}
1355                         LDFLAGS="$LDFLAGS -u libsys_s"
1356                         rb_cv_dlopen=yes ;;
1357         openstep*)      : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
1358                         : ${LDFLAGS=""}
1359                         rb_cv_dlopen=yes ;;
1360         rhapsody*)      : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
1361                         : ${LDFLAGS=""}
1362                         rb_cv_dlopen=yes ;;
1363         darwin*)        : ${LDSHARED='cc -dynamic -bundle -undefined suppress -flat_namespace'}
1364                         : ${LDFLAGS=""}
1365                         : ${LIBPATHENV=DYLD_LIBRARY_PATH}
1366                         rb_cv_dlopen=yes ;;
1367         aix*)           if test "$GCC" = yes; then
1368                             : ${LDSHARED='$(CC) -shared'}
1369                         else
1370                             : ${LDSHARED='$(CC)'}
1371                         fi
1372                         LDSHARED="$LDSHARED ${linker_flag}-G"
1373                         DLDFLAGS='-eInit_$(TARGET)'
1374                         XLDFLAGS="${linker_flag}-bE:ruby.imp ${linker_flag}-brtl"
1375                         : ${ARCHFILE="ruby.imp"}
1376                         TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
1377                         TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
1378                         : ${LIBPATHENV=SHLIB_PATH}
1379                         rb_cv_dlopen=yes ;;
1380         human*)         : ${DLDFLAGS=''}
1381                         : ${LDSHARED=''}
1382                         : ${LDFLAGS=''}
1383                         : ${LINK_SO='ar cru $@ $(OBJS)'}
1384                         rb_cv_dlopen=yes ;;
1385         beos*)          case "$target_cpu" in
1386                           powerpc*)
1387                             : ${LDSHARED="ld -xms"}
1388                             DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
1389                             ;;
1390                           i586*)
1391                             : ${LDSHARED="ld -shared"}
1392                             DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -lbe -lroot"
1393                             ;;
1394                         esac
1395                         : ${LIBPATHENV=LIBRARY_PATH}
1396                         rb_cv_dlopen=yes ;;
1397         haiku*)                 case "$target_cpu" in
1398                           powerpc*)
1399                             : ${LDSHARED="ld -xms"}
1400                             DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
1401                             ;;
1402                           i586*)
1403                             : ${LDSHARED="ld -shared"}
1404                             DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -lbe -lroot"
1405                             ;;
1406                         esac
1407                         : ${LIBPATHENV=LIBRARY_PATH}
1408                         rb_cv_dlopen=yes ;;
1409         nto-qnx*)       DLDFLAGS="$DLDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
1410                         : ${LDSHARED='ld -Bshareable -x'}
1411                         LDFLAGS="$LDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
1412                         rb_cv_dlopen=yes;;
1413         cygwin*|mingw*) : ${LDSHARED="${CC} -shared -s"}
1414                         XLDFLAGS="$XLDFLAGS -Wl,--stack,0x00200000"
1415                         DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-image-base,--enable-auto-import,--export-all"
1416                         : ${LIBPATHENV=""}
1417                         rb_cv_dlopen=yes ;;
1418         hiuxmpp)        : ${LDSHARED='ld -r'} ;;
1419         atheos*)        : ${LDSHARED="$CC -shared"}
1420                         rb_cv_dlopen=yes ;;
1421         os2-emx*)       LDFLAGS="$LDFLAGS -Zbsd-signals"
1422                         ;;
1423         *)              : ${LDSHARED='ld'} ;;
1424   esac
1425   AC_MSG_RESULT($rb_cv_dlopen)
1427 if test "${LDSHAREDXX}" = ""; then
1428     case "${LDSHARED}" in
1429         *'$(CC)'*)
1430             LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\$(CC)/$(CXX)/'`
1431             ;;
1432         *'${CC}'*)
1433             LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\${CC}/${CXX}/'`
1434             ;;
1435         *$CC*)
1436             LDSHAREDXX=`echo "${LDSHARED}" | sed "s|$CC|$CXX|"`
1437             ;;
1438         ld" "*)
1439             ;;
1440     esac
1443 AC_SUBST(LINK_SO)
1444 AC_SUBST(LIBPATHFLAG)
1445 AC_SUBST(RPATHFLAG)
1446 AC_SUBST(LIBPATHENV, "${LIBPATHENV-LD_LIBRARY_PATH}")
1447 AC_SUBST(TRY_LINK)
1449 dln_a_out_works=no
1450 if test "$ac_cv_header_a_out_h" = yes; then
1451   if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
1452     cat confdefs.h > config.h
1453     AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out,
1454     [AC_TRY_COMPILE([
1455 #define USE_DLN_A_OUT
1456 #include "dln.c"
1458         [], 
1459         rb_cv_dln_a_out=yes,
1460         rb_cv_dln_a_out=no)])
1461     if test "$rb_cv_dln_a_out" = yes; then
1462       dln_a_out_works=yes
1463       AC_DEFINE(USE_DLN_A_OUT)
1464     fi
1465   fi
1468 if test "$dln_a_out_works" = yes; then
1469   if test "$GCC" = yes; then
1470     STATIC=-static
1471   else
1472     STATIC=-Bstatic
1473   fi
1474   DLEXT=so
1475   CCDLFLAGS=
1476 else
1477   case "$target_os" in
1478     hpux*)      DLEXT=sl;;
1479     nextstep*)  DLEXT=bundle;;
1480     openstep*)  DLEXT=bundle;;
1481     rhapsody*)  DLEXT=bundle;;
1482     darwin*)    DLEXT=bundle;;
1483     os2-emx*)   DLEXT=dll;;
1484     cygwin*|mingw*)     DLEXT=so;;
1485     *)          DLEXT=so;;
1486   esac
1488 len=2 # .rb
1489 n=`expr "$DLEXT"  : '.*'`; test "$n" -gt "$len" && len=$n
1490 n=`expr "$DLEXT2" : '.*'`; test "$n" -gt "$len" && len=$n
1491 AC_DEFINE_UNQUOTED(DLEXT_MAXLEN, `expr $len + 1`)
1492 test ".$DLEXT"  = "." || AC_DEFINE_UNQUOTED(DLEXT,  ".$DLEXT")
1493 test ".$DLEXT2" = "." || AC_DEFINE_UNQUOTED(DLEXT2, ".$DLEXT2")
1494 AC_SUBST(DLEXT)
1496 AC_SUBST(STRIP)dnl
1497 if test "$with_dln_a_out" = yes; then
1498   STRIP=true
1499 else
1500   STRIP=strip
1503 case "$target_os" in
1504   linux* | gnu* | k*bsd*-gnu)
1505         STRIP='strip -S -x';;
1506   nextstep*)
1507         STRIP='strip -A -n';;
1508   openstep*)
1509         STRIP='strip -A -n';;
1510   rhapsody*)
1511         STRIP='strip -A -n';;
1512   darwin*)
1513         STRIP='strip -A -n';;
1514 esac
1516 EXTSTATIC=
1517 AC_SUBST(EXTSTATIC)dnl
1518 AC_ARG_WITH(static-linked-ext,
1519             [  --with-static-linked-ext link external modules statically],
1520             [case $withval in
1521              yes) STATIC=
1522                   EXTSTATIC=static;;
1523              *) ;;
1524              esac])
1526 case "$target_os" in
1527   human*)
1528     AC_CHECK_LIB(signal, _harderr)
1529     AC_CHECK_LIB(hmem, hmemset)
1530     AC_CHECK_FUNCS(select)
1531     AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
1532                    rb_cv_missing__dtos18,
1533     [AC_TRY_RUN(
1534 changequote(<<, >>)dnl
1536 #include <stdio.h>
1538 main()
1540    char buf[256];
1541    sprintf(buf, "%g", 1e+300);
1542    return (strcmp (buf, "1e+300") ? 0 : 1);
1545 changequote([, ])dnl
1546 rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no, rb_cv_missing__dtos18=no)])
1547     if test "$rb_cv_missing__dtos18" = yes; then
1548       AC_DEFINE(MISSING__DTOS18)
1549     fi
1550     AC_CACHE_CHECK(whether PD libc fconvert fail to round,
1551                    rb_cv_missing_fconvert,
1552     [AC_TRY_RUN(
1553 changequote(<<, >>)dnl
1555 #include <stdio.h>
1556 #include <math.h>
1558 main()
1560   char buf[256];
1561   sprintf(buf, "%f", log(exp(1.0)));
1562   return (strcmp (buf, "1.000000") ? 0 : 1);
1565 changequote([, ])dnl
1566 rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no)])
1567     if test "$rb_cv_missing_fconvert" = yes; then
1568       AC_DEFINE(MISSING_FCONVERT)
1569     fi
1570     AC_LIBOBJ([x68.o])
1571     CFLAGS="$CFLAGS -fansi-only"
1572     XCFLAGS="$XCFLAGS -cc1-stack=262144 -cpp-stack=2694144"
1573     EXEEXT=.x
1574     OBJEXT=o
1575     setup=Setup.x68
1576     ;;
1577   dnl OS/2 environment w/ Autoconf 2.1x for EMX
1578   os2-emx)
1579     AC_LIBOBJ([os2])
1580     setup=Setup.emx
1581     ;;
1582   *djgpp*)
1583     setup=Setup.dj
1584     ;;
1585   *)
1586     setup=Setup
1587     ;;
1588 esac
1590 AC_SUBST(setup)
1592 if test "$prefix" = NONE; then
1593   prefix=$ac_default_prefix
1596 #if test "$fat_binary" != no ; then
1597 #  CFLAGS="$CFLAGS $ARCH_FLAG"
1600 if test x"$cross_compiling" = xyes; then
1601   test x"$MINIRUBY" = x && MINIRUBY="${RUBY-ruby} -I`pwd` -rfake"
1602   PREP=fake.rb
1603   RUNRUBY='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
1604 else
1605   MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib'
1606   MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common -I./- -r$(srcdir)/ext/purelib.rb'
1607   PREP='miniruby$(EXEEXT)'
1608   RUNRUBY='$(MINIRUBY) $(srcdir)/runruby.rb --extout=$(EXTOUT)'
1610 AC_SUBST(MINIRUBY)
1611 AC_SUBST(PREP)
1612 AC_SUBST(RUNRUBY)
1613 AC_SUBST(EXTOUT, [${EXTOUT=.ext}])
1615 FIRSTMAKEFILE=""
1616 LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
1617 LIBRUBY='$(LIBRUBY_A)'
1618 LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static'
1619 LIBRUBYARG='$(LIBRUBYARG_STATIC)'
1620 SOLIBS=
1622 case "$target_os" in
1623   cygwin*|mingw*|beos*|haiku*|openstep*|nextstep*|rhapsody*|darwin*|os2-emx*)
1624     : ${DLDLIBS=""}
1625     ;;
1626   *)
1627     DLDLIBS="$DLDLIBS -lc"
1628     ;;
1629 esac
1631 RUBY_SO_NAME='$(RUBY_INSTALL_NAME)'
1632 LIBRUBY_LDSHARED=$LDSHARED
1633 LIBRUBY_DLDFLAGS=$DLDFLAGS
1634 LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
1635 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so'
1636 ENABLE_SHARED=no
1638 AC_ARG_ENABLE(shared,
1639        [  --enable-shared         build a shared library for Ruby. ],
1640        [enable_shared=$enableval])
1641 if test "$enable_shared" = 'yes'; then
1642   LIBRUBY='$(LIBRUBY_SO)'
1643   LIBRUBYARG_SHARED='-l$(RUBY_SO_NAME)'
1644   LIBRUBYARG='$(LIBRUBYARG_SHARED)'
1645   CFLAGS="$CFLAGS $CCDLFLAGS"
1646   ENABLE_SHARED=yes
1647   if test "$rb_cv_binary_elf" = yes; then
1648     SOLIBS='$(LIBS)'
1649   fi
1650   case "$target_os" in
1651     sunos4*)
1652         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
1653         ;;
1654     linux* | gnu* | k*bsd*-gnu | atheos*)
1655         LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
1656         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
1657         ;;
1658     freebsd*|dragonfly*)
1659         SOLIBS='$(LIBS)'
1660         LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
1661         if test "$rb_cv_binary_elf" != "yes" ; then
1662             LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
1663             LIBRUBY_ALIASES=''
1664         fi
1665         ;;
1666     netbsd*)
1667         SOLIBS='$(LIBS)'
1668         LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR).$(TEENY)'
1669         LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
1670         if test "$rb_cv_binary_elf" = yes; then # ELF platforms
1671            LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_SO_NAME).so'
1672         else    # a.out platforms
1673            LIBRUBY_ALIASES=""
1674         fi
1675         ;;
1676     openbsd*)
1677         SOLIBS='$(LIBS)'
1678         LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
1679         ;;
1680     solaris*)
1681         SOLIBS='$(LIBS)'
1682         LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)'
1683         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY) lib$(RUBY_SO_NAME).so'
1684         if test "$GCC" = yes; then
1685             LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)'
1686         fi
1687         XLDFLAGS="$XLDFLAGS "'-R${libdir}'
1688         ;;
1689     hpux*)
1690         XLDFLAGS="$XLDFLAGS "'-Wl,+s,+b,$(libdir)'
1691         LIBRUBY_SO='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
1692         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
1693         ;;
1694     aix*)
1695         LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry $XLDFLAGS"
1696         LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
1697         SOLIBS='-lm -lc'
1698         ;;
1699     beos*)
1700         case "$target_cpu" in
1701         powerpc*)
1702             LIBRUBY_DLDFLAGS='-f ruby.exp -lnet -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
1703             ;;
1704         esac
1705         ;;
1706     darwin*)
1707         LIBRUBY_SO='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib'
1708         LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace'
1709         LIBRUBY_DLDFLAGS='-install_name $(libdir)/lib$(RUBY_SO_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
1710         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib'
1711         ;;
1712     interix*)
1713         LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
1714         ;;
1715     *)
1716         ;;
1717   esac
1719 if test "$enable_rpath" = yes; then
1720     LIBRUBYARG_SHARED="${linker_flag}-R ${linker_flag}\$(libdir) -L\$(libdir) $LIBRUBYARG_SHARED"
1723 LDFLAGS="-L. $LDFLAGS"
1724 AC_SUBST(ARCHFILE)
1726 dnl build rdoc index if requested
1727 RDOCTARGET=""
1728 AC_ARG_ENABLE(install-doc,
1729        [  --disable-install-doc    do not install rdoc indexes during install ],
1730        [install_doc=$enableval], [install_doc=yes])
1731 if test "$install_doc" != no; then
1732    RDOCTARGET="install-doc"
1734 AC_SUBST(RDOCTARGET)
1736 if test "$rb_with_pthread" = "yes"; then
1737     THREAD_MODEL=pthread
1739 MINIDLNOBJ=dln.o
1740 case "$target_os" in
1741     linux*)
1742         ;;
1743     netbsd*)
1744         CFLAGS="$CFLAGS -pipe"
1745         ;;
1746     nextstep*|openstep*)
1747         # The -fno-common is needed if we wish to embed the Ruby interpreter
1748         # into a plugin module of some project (as opposed to embedding it
1749         # within the project's application).  The -I/usr/local/include is
1750         # needed because CPP as discovered by configure (cc -E -traditional)
1751         # fails to consult /usr/local/include by default.  This causes
1752         # mkmf.rb's have_header() to fail if the desired resource happens to be
1753         # installed in the /usr/local tree.
1754         CFLAGS="$CFLAGS -pipe -fno-common"
1755         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
1756         ;;
1757     rhapsody*)
1758         CFLAGS="$CFLAGS -pipe -no-precomp -fno-common"
1759         ;;
1760     darwin*)
1761         CFLAGS="$CFLAGS -pipe -fno-common"
1762         MINIDLNOBJ=dmydln.o
1763         ;;
1764     os2-emx)
1765         CFLAGS="$CFLAGS -DOS2 -Zmts"
1766         LIBRUBY_A=`echo $LIBRUBY_A | sed 's/^lib//'`
1767         LIBRUBY_SO=`echo $LIBRUBY_SO | sed 's/^lib//'`
1768         LIBRUBY_ALIASES=`for i in $LIBRUBY_ALIASES; do echo "$i"; done | sed 's/^lib//'`
1769         ;;
1770     osf*)
1771         if test "$GCC" != "yes" ; then
1772           # compile something small: taint.c is fine for this.
1773           # the main point is the '-v' flag of 'cc'.
1774           case "`cc -v -I. -c main.c -o /tmp/main.o 2>&1`" in
1775           */gemc_cc*)   # we have the new DEC GEM CC
1776                         CFLAGS="$CFLAGS -oldc"
1777                         ;;
1778           *)            # we have the old MIPS CC
1779                         ;;
1780           esac
1781           # cleanup
1782           rm -f /tmp/main.o
1783           CFLAGS="$CFLAGS -std"
1784         fi
1785         ;;
1786     beos*)
1787         case "$target_cpu" in
1788         powerpc*)
1789             CFLAGS="$CFLAGS -relax_pointers"
1790             ;;
1791         esac
1792         ;;
1793     cygwin*|mingw*)
1794         LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
1795         case "$target_os" in
1796         cygwin*)
1797             if test x"$enable_shared" = xyes; then
1798                 LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}${TEENY}.dll
1799             fi
1800             ;;
1801         mingw*)
1802             RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}${TEENY}
1803             if test x"$enable_shared" = xyes; then
1804                 LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
1805                 LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' $(RUBYDEF)'
1806             fi
1807             AC_LIBOBJ([win32])
1808             COMMON_LIBS=m
1809 #           COMMON_MACROS="WIN32_LEAN_AND_MEAN="
1810             COMMON_HEADERS="winsock2.h windows.h"
1811             THREAD_MODEL=win32
1812             ;;
1813         esac
1814         LIBRUBY_ALIASES=''
1815         FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
1816         SOLIBS='$(LIBS)'
1817         if test x"$enable_shared" = xyes; then
1818             LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
1819         else
1820             LIBRUBY_SO=dummy
1821             LIBRUBY='lib$(RUBY_SO_NAME).a'
1822             LIBRUBYARG='-l$(RUBY_SO_NAME)'
1823         fi
1824         MINIDLNOBJ=dmydln.o
1825         ;;
1826     hpux*)
1827         case "$YACC" in
1828           *yacc*)
1829             XCFLAGS="$XCFLAGS -DYYMAXDEPTH=300"
1830             YACC="$YACC -Nl40000 -Nm40000"
1831             ;;
1832         esac
1833         MINIDLNOBJ=dmydln.o
1834         ;;
1835     *)
1836         ;;
1837 esac
1838 MINIOBJS="$MINIDLNOBJ"
1840 case "$build_os" in
1841   *msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;;
1842 esac
1844 CPPFLAGS="$CPPFLAGS "'$(DEFS)'
1845 test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
1846 cflagspat=`eval echo '"'"${cflags}"'"' | sed 's/[][|.*]/\\&/g'`
1847 CFLAGS=`echo "$CFLAGS" | sed "s|$cflagspat"'|${cflags}|'`
1848 cxxflagspat=`eval echo '"'"${cxxflags}"'"' | sed 's/[][|.*]/\\&/g'`
1849 CXXFLAGS=`echo "$CXXFLAGS" | sed "s|$cxxflagspat"'|${cxxflags}|'`
1850 AC_SUBST(cppflags, [])dnl
1851 AC_SUBST(cflags, ['${optflags} ${debugflags} ${warnflags}'])dnl
1852 AC_SUBST(optflags)dnl
1853 AC_SUBST(debugflags)dnl
1854 AC_SUBST(warnflags)dnl
1855 AC_SUBST(XCFLAGS)dnl
1856 AC_SUBST(XLDFLAGS)dnl
1857 AC_SUBST(LIBRUBY_LDSHARED)
1858 AC_SUBST(LIBRUBY_DLDFLAGS)
1859 AC_SUBST(RUBY_INSTALL_NAME)
1860 AC_SUBST(rubyw_install_name)
1861 AC_SUBST(RUBYW_INSTALL_NAME)
1862 AC_SUBST(RUBY_SO_NAME)
1863 AC_SUBST(LIBRUBY_A)
1864 AC_SUBST(LIBRUBY_SO)
1865 AC_SUBST(LIBRUBY_ALIASES)
1866 AC_SUBST(LIBRUBY)
1867 AC_SUBST(LIBRUBYARG)
1868 AC_SUBST(LIBRUBYARG_STATIC)
1869 AC_SUBST(LIBRUBYARG_SHARED)
1870 AC_SUBST(SOLIBS)
1871 AC_SUBST(DLDLIBS)
1872 AC_SUBST(ENABLE_SHARED)
1873 AC_SUBST(MAINLIBS)
1874 AC_SUBST(COMMON_LIBS)
1875 AC_SUBST(COMMON_MACROS)
1876 AC_SUBST(COMMON_HEADERS)
1877 AC_SUBST(EXPORT_PREFIX)
1878 AC_SUBST(MINIOBJS)
1879 AC_SUBST(THREAD_MODEL)
1881 MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`"
1882 MAKEFILES="`echo $MAKEFILES`"
1883 AC_SUBST(MAKEFILES)
1885 ri_prefix=
1886 test "$program_prefix" != NONE &&
1887   ri_prefix=$program_prefix
1889 ri_suffix=
1890 test "$program_suffix" != NONE &&
1891   ri_suffix=$program_suffix
1893 RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
1894 case "$target_os" in
1895   cygwin*|mingw*)
1896     RUBYW_INSTALL_NAME="${ri_prefix}rubyw${ri_suffix}"
1897     rubyw_install_name="$RUBYW_INSTALL_NAME"
1898     ;;
1899 esac
1900 RUBY_LIB_PREFIX=`eval echo \\"${libdir}/ruby\\"`
1902 AC_ARG_WITH(ruby-version,
1903             [  --with-ruby-version=STR ruby version string for version specific directories [[full]] (full|minor|STR)],
1904             [ruby_version=$withval],
1905             [ruby_version=full])
1906 case "$ruby_version" in
1907   full)
1908     ruby_version="${MAJOR}.${MINOR}.${TEENY}"
1909     ;;
1910   minor)
1911     ruby_version="${MAJOR}.${MINOR}"
1912     ;;
1913 esac
1915 AC_ARG_WITH(sitedir,
1916             [  --with-sitedir=DIR      site libraries in DIR [[LIBDIR/ruby/site_ruby]]],
1917             [sitedir=$withval],
1918             [sitedir='${libdir}/ruby/site_ruby'])
1919 SITE_DIR=`eval echo \\"${sitedir}\\"`
1921 AC_ARG_WITH(vendordir,
1922             [  --with-vendordir=DIR    vendor libraries in DIR [[LIBDIR/ruby/vendor_ruby]]],
1923             [vendordir=$withval],
1924             [vendordir='${libdir}/ruby/vendor_ruby'])
1925 VENDOR_DIR=`eval echo \\"${vendordir}\\"`
1927 case "$target_os" in
1928   cygwin*|mingw*|*djgpp*|os2-emx*)
1929     RUBY_LIB_PREFIX="`eval echo "$RUBY_LIB_PREFIX" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1930     RUBY_SITE_LIB_PATH="`eval echo "$SITE_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1931     RUBY_VENDOR_LIB_PATH="`eval echo "$VENDOR_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1932     ;;
1933   *)
1934     RUBY_LIB_PREFIX="`eval echo \\"$RUBY_LIB_PREFIX\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1935     RUBY_SITE_LIB_PATH="`eval echo \\"$SITE_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1936     RUBY_VENDOR_LIB_PATH="`eval echo \\"$VENDOR_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1937     ;;
1938 esac
1939 RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${ruby_version}"
1940 RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${ruby_version}"
1941 RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${ruby_version}"
1943 AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
1944 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
1945 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
1946 AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
1947 AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
1949 AC_SUBST(arch)dnl
1950 AC_SUBST(sitearch)dnl
1951 AC_SUBST(ruby_version)dnl
1952 AC_SUBST(sitedir)dnl
1953 AC_SUBST(vendordir)dnl
1955 configure_args=$ac_configure_args
1956 AC_SUBST(configure_args)dnl
1958 if test "$fat_binary" != no ; then
1959     arch="fat-${target_os}"
1961     AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
1962                  "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1964     AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
1965                  "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1966     AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB,
1967                  "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1968     AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}")
1969 else
1970     arch="${target_cpu}-${target_os}"
1971     AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
1974 case "$target_os" in
1975   mingw*) sitearch="$target_cpu-$rb_cv_msvcrt" ;;
1976   *) sitearch="${arch}" ;;
1977 esac
1979 AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
1980 AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
1981 AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${RUBY_VENDOR_LIB_PATH2}/${sitearch}")
1983 AC_ARG_WITH(search-path,
1984                 [  --with-search-path=DIR specify the additional search path],
1985                 [search_path=$withval])
1986 if test "$search_path" != ""; then
1987     AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
1990 AC_ARG_WITH(rubyhdrdir,
1991             [  --with-ruby-hdrdir=DIR  core headers in DIR [INCLUDEDIR]],
1992             [rubyhdrdir=$withval],
1993             [rubyhdrdir='${includedir}/ruby-${ruby_version}'])
1995 AC_ARG_WITH(sitehdrdir,
1996             [  --with-site-hdrdir=DIR  core headers in DIR [INCLUDEDIR]],
1997             [sitehdrdir=$withval],
1998             [sitehdrdir='${rubyhdrdir}/site_ruby'])
2000 AC_ARG_WITH(vendorhdrdir,
2001             [  --with-vendor-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
2002             [vendorhdrdir=$withval],
2003             [vendorhdrdir='${rubyhdrdir}/vendor_ruby'])
2005 AC_SUBST(rubyhdrdir)dnl
2006 AC_SUBST(sitehdrdir)dnl
2007 AC_SUBST(vendorhdrdir)dnl
2009 AC_ARG_WITH(mantype,
2010                 [  --with-mantype=TYPE specify man page type; TYPE is one of man and doc],
2011                 [
2012                         case "$withval" in
2013                         man|doc)
2014                                 MANTYPE=$withval
2015                                 ;;
2016                         *)
2017                                 AC_MSG_ERROR(invalid man type: $withval)
2018                                 ;;
2019                         esac
2020                 ])
2021 if test -z "$MANTYPE"; then
2022         AC_PATH_PROGS(NROFF, nroff awf, /bin/false, "/usr/bin:/usr/ucb")
2023         if ${NROFF} -mdoc ${srcdir}/ruby.1 >/dev/null 2>&1; then
2024                 MANTYPE=doc
2025         else
2026                 MANTYPE=man
2027         fi
2029 AC_SUBST(MANTYPE)
2031 arch_hdrdir="${EXTOUT}/include/${arch}/ruby"
2032 $MAKEDIRS "${arch_hdrdir}"
2033 config_h="${arch_hdrdir}/config.h"
2034 if test -f "${config_h}" && tr -d '\015' < confdefs.h | cmp -s "${config_h}" -; then
2035   echo "config.h unchanged"
2036 else
2037   echo "creating config.h"
2038   tr -d '\015' < confdefs.h > "${config_h}"
2040 tr -d '\015' < largefile.h > confdefs.h
2041 rm largefile.h
2043 BUILTIN_ENCS=["`sed -n -e '/^BUILTIN_ENCS[      ]*=/{' \
2044         -e s/// -e :l -e '/\\\\$/N' -e 's/\\\\\\n/ /' -e 't l' -e p \
2045         -e '}' "${srcdir}/enc/Makefile.in"`"]
2046 BUILTIN_ENCOBJS=
2047 for e in $BUILTIN_ENCS; do BUILTIN_ENCOBJS="$BUILTIN_ENCOBJS `basename $e .c`"'.$(OBJEXT)'; done
2048 AC_SUBST(BUILTIN_ENCOBJS)
2050 AC_CONFIG_FILES($FIRSTMAKEFILE)
2051 AC_CONFIG_FILES(Makefile, [{
2052         sed '/^MISSING/s/\$U\././g' Makefile
2053         echo; test x"$EXEEXT" = x || echo 'miniruby: miniruby$(EXEEXT)'
2054         test "$RUBY_INSTALL_NAME$EXEEXT" = ruby || echo 'ruby: $(PROGRAM);'
2055         sed ['s/{\$([^(){}]*)[^{}]*}//g'] ${srcdir}/common.mk
2056       } >> confmk$$.tmp && mv -f confmk$$.tmp Makefile],
2057 [RUBY_INSTALL_NAME=$RUBY_INSTALL_NAME EXEEXT=$EXEEXT])
2058 AC_OUTPUT