* test/ruby/envutil.rb (assert_normal_exit): show pid when fail.
[ruby-svn.git] / configure.in
blobfa1567880be40c2c329f2e1692eb78e8392770d7
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 if test x"${build}" != x"${host}"; then
180   AC_CHECK_TOOL(CC, gcc)
182 AC_PROG_CC
183 AC_PROG_CXX
184 AC_PROG_GCC_TRADITIONAL
185 if test "$GCC" = yes; then
186     linker_flag=-Wl,
187 else
188     linker_flag=
191 RUBY_PROG_GNU_LD
192 RUBY_CPPOUTFILE
194 : ${OUTFLAG='-o '}
195 : ${COUTFLAG=${OUTFLAG}}
196 AC_SUBST(OUTFLAG)
197 AC_SUBST(COUTFLAG)
199 RUBY_MINGW32
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)
208 ASFLAGS=$ASFLAGS
209 AC_SUBST(ASFLAGS)
211 case "$target_os" in
212 cygwin*|mingw*)
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/`
217     case "$target_os" in
218     mingw*)
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 |
225                                    tr A-Z a-z |
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])
229     esac
230     : ${enable_shared=yes}
231     ;;
232 aix*)
233     AC_CHECK_TOOL(NM, nm, /usr/ccs/bin/nm, /usr/ccs/bin:$PATH)
234     ;;
235 hiuxmpp*)
236     # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
237     AC_DEFINE(__HIUX_MPP__)
238     ;;
239 esac
241 AC_PROG_LN_S
242 AC_PROG_MAKE_SET
243 AC_PROG_INSTALL
245 # checks for UNIX variants that set C preprocessor variables
246 AC_USE_SYSTEM_EXTENSIONS
248 AC_SUBST(RM, ['rm -f'])
249 AC_SUBST(CP, ['cp'])
250 if $as_mkdir_p; then
251   MAKEDIRS='mkdir -p'
252 else
253   MAKEDIRS='install -d'
255 AC_SUBST(MAKEDIRS)
257 dnl check for large file stuff
258 mv confdefs.h confdefs1.h
259 : > confdefs.h
260 AC_SYS_LARGEFILE
261 mv confdefs.h largefile.h
262 mv confdefs1.h confdefs.h
263 cat largefile.h >> confdefs.h
265 case "$target_os" in
266 mingw*)
267         ac_cv_type_off_t=yes
268         ac_cv_sizeof_off_t=8
269         ;;
270 esac
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
287     AC_CHECK_TYPE([$1],
288         [AC_DEFINE_UNQUOTED(rb_[$1], [$1])],
289         [AC_DEFINE_UNQUOTED(rb_[$1], [$2])],
290         [$4])
291     AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
292         u= t=
293         AC_COMPILE_IFELSE(
294             [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
295                                       [$4], [(rb_[$1])-1 > 0])],
296             [u=U])
297         if test x"$t" = x; then
298             AC_COMPILE_IFELSE(
299                 [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
300                                           [$4], [sizeof(rb_[$1]) > sizeof(long)])],
301                 [t=LL])
302         fi
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=LONG])
308         fi
309         if test x"$t" = x; then
310             t=INT
311         fi
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])
335 else
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
342     AC_COMPILE_IFELSE([
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])
352   done]
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, [
362   AC_COMPILE_IFELSE([
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,
375   [AC_TRY_COMPILE([
376 #include <stdarg.h>
377 int foo(int x, ...) {
378         va_list va;
379         va_start(va, x);
380         va_arg(va, int);
381         va_arg(va, char *);
382         va_arg(va, double);
383         return 0;
385 ], [return foo(10, "", 3.14);],
386         rb_cv_stdarg=yes,
387         rb_cv_stdarg=no)])
388 if test "$rb_cv_stdarg" = yes; then
389   AC_DEFINE(HAVE_STDARG_PROTOTYPES)
392 AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
393 m4_ifval([$2], dnl
394   [AS_VAR_PUSHDEF([attrib],[$2])], dnl
395   [AS_VAR_PUSHDEF([attrib],[FUNC_]AS_TR_CPP($1))] dnl
396 )dnl
397 m4_ifval([$3], dnl
398   [AS_VAR_PUSHDEF([rbcv],[$3])], dnl
399   [AS_VAR_PUSHDEF([rbcv],[rb_cv_func_][$1])]dnl
400 )dnl
401 AC_CACHE_CHECK(for [$1] function attribute, rbcv,
402 [rbcv=x
403 if test "${ac_c_werror_flag+set}"; then
404   rb_c_werror_flag="$ac_c_werror_flag"
405 else
406   unset rb_c_werror_flag
408 ac_c_werror_flag=yes
409 for mac in "__attribute__ (($1)) x" "x __attribute__ (($1))" "__declspec($1) x" x; do
410   AC_TRY_COMPILE(
411     [#define ]attrib[(x) $mac
412     ]attrib[(void conftest_attribute_check(void));], [],
413     [rbcv="$mac"; break])
414 done
415 if test "${rb_c_werror_flag+set}"; then
416   ac_c_werror_flag="$rb_c_werror_flag"
417 else
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
436   AC_TRY_COMPILE(
437     [extern $mac void conftest(void);],
438     [rb_cv_ruby_extern="extern $mac"; break])
439 done])
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
446 #include <errno.h>])
448 case "$target_os" in
449 freebsd*)
450   AC_CACHE_CHECK([whether pthread should be enabled by default],
451     rb_cv_enable_pthread_default,
452     [AC_TRY_CPP([
453 #include <osreldate.h>
454 #if __FreeBSD_version < 502102
455 #error pthread should be disabled on this platform
456 #endif
457       ],
458       rb_cv_enable_pthread_default=yes,
459       rb_cv_enable_pthread_default=no)])
460   enable_pthread_default=$rb_cv_enable_pthread_default
461   ;;
462 mingw*)
463   enable_pthread_default=no
464   ;;
466   enable_pthread_default=yes
467   ;;
468 esac
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.
475 case "$target_os" in
476 nextstep*)      ;;
477 openstep*)      ;;
478 rhapsody*)      ;;
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
483                     #error pre OS X 10.4
484                     [!<===== pre OS X 10.4 =====>]
485                     #endif
486                     ],
487                     [
488                     test "x$target_cpu" = xppc && ac_cv_header_ucontext_h=no
489                     ],
490                     [
491                     AC_DEFINE(BROKEN_SETREUID, 1)
492                     AC_DEFINE(BROKEN_SETREGID, 1)
493                     ])
494                 ;;
495 hpux*)          LIBS="-lm $LIBS"
496                 ac_cv_c_inline=no;;
497 human*)         ac_cv_func_getpgrp_void=yes
498                 ac_cv_func_setitimer=no
499                 ;;
500 beos*)          ac_cv_func_link=no;;
501 cygwin*)        ;;
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
512                 ac_cv_func_times=yes
513                 ac_cv_func_waitpid=yes
514                 ac_cv_func_fsync=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
519                 ac_cv_func_isinf=yes
520                 ac_cv_func_isnan=yes
521                 ac_cv_func_finite=yes
522                 ac_cv_func_link=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
531                 rb_cv_binary_elf=no
532                 rb_cv_negative_time_t=no
533                 ac_cv_func_fcntl=yes
534                 ;;
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
541                 ac_cv_func_fork=no
542                 ac_cv_func_setrlimit=no
543                 ;;
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,
551                   [AC_TRY_CPP([
552 #include <osreldate.h>
553 #if __FreeBSD_version < 400020 || \
554    (__FreeBSD_version >= 500000 && __FreeBSD_version < 500005)
555 #error needs libxpg4
556 #endif
557                    ],
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)
563                 fi
564                 ;;
565 dragonfly*)     LIBS="-lm $LIBS"
566                 ;;
567 bow)            ac_cv_func_setitimer=no
568                 ;;
569 superux*)     ac_cv_func_setitimer=no
570               ;;
571 *) LIBS="-lm $LIBS";;
572 esac
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
583                 esac ;;
584 esac
586 dnl Checks for header files.
587 AC_HEADER_DIRENT
588 AC_HEADER_STDC
589 AC_HEADER_SYS_WAIT
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>
600   #endif
601   #ifdef HAVE_SYS_TIME_H
602   # include <sys/time.h>
603   #endif
604   #ifdef HAVE_SYS_RESOURCE_H
605   # include <sys/resource.h>
606   #endif
607   #ifdef HAVE_UNISTD_H
608   # include <unistd.h>
609   #endif
610   #include <stdio.h>
613 dnl Checks for typedefs, structures, and compiler characteristics.
614 AC_TYPE_SIZE_T
615 AC_CHECK_SIZEOF(size_t, 0)
616 AC_STRUCT_ST_BLKSIZE
617 AC_STRUCT_ST_BLOCKS
618 AC_STRUCT_ST_RDEV
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
630 @%:@include <time.h>
631 @%:@endif])
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;])],
640    [rb_cv_type_$1=yes],
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;;
649     esac])])
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
673   AC_TRY_LINK(
674     [extern void *$addr;],
675     [if (!$addr) return 1;],
676     [rb_cv_stack_end_address="$addr"; break])
677 done])
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.
683 AC_TYPE_GETGROUPS
684 AC_TYPE_SIGNAL
685 case "${target_cpu}-${target_os}" in
686 powerpc-darwin*)
687   AC_LIBSOURCES(alloca.c)
688   AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}])
689   AC_DEFINE(C_ALLOCA)
690   AC_DEFINE_UNQUOTED(alloca, alloca)
691   ;;
693   AC_FUNC_ALLOCA
694   ;;
695 esac
696 AC_FUNC_MEMCMP
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 \
700                  strlcpy strlcat)
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\
712               pread sendfile)
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], [
727         case $withval in
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)
738     fi
739 elif test "$ac_cv_func___builtin_setjmp" = yes; then
740     setjmp_prefix=__builtin_
741 elif test "$ac_cv_func__setjmp" = yes; then
742     setjmp_prefix=_
743 elif test "$ac_cv_func_sigsetjmp" = yes; then
744     case $target_os in
745     solaris*|cygwin*)
746         setjmp_prefix=;;
747     *)
748         setjmp_prefix=sig;;
749     esac
750 else
751     setjmp_prefix=
753 if test x$setjmp_prefix = xsig; then
754     setjmp_sigmask=yes
755 else
756     unset setjmp_sigmask
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)
770 AC_STRUCT_TIMEZONE
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>
781   int i;],
782         [i = daylight;],
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,
790   [rb_cv_var_$1=no
791   AC_TRY_COMPILE([
792 #ifndef _XOPEN_SOURCE
793 #define _XOPEN_SOURCE 1
794 #endif
797 const volatile void *volatile t;],
798     [t = &(&$1)[0];],
799     [for t in $3; do
800       AC_TRY_COMPILE([
801 #ifndef _XOPEN_SOURCE
802 #define _XOPEN_SOURCE 1
803 #endif
806 extern $t $1;
807 const volatile void *volatile t;],
808         [t = &(&$1)[0];],
809         [rb_cv_var_$1=$t; break])
810     done])])
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)
814 fi])
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])]
825     )
826     if test $rb_cv_func_timezone_void = yes; then
827       AC_DEFINE(TIMEZONE_VOID)
828     fi
829   fi
832 AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
833   [AC_TRY_RUN([
834 #include <time.h>
836 void
837 check(tm, y, m, d, h, s)
838     struct tm *tm;
839     int y, m, d, h, s;
841     if (!tm ||
842         tm->tm_year != y ||
843         tm->tm_mon  != m-1 ||
844         tm->tm_mday != d ||
845         tm->tm_hour != h ||
846         tm->tm_sec  != s) {
847         exit(1);
848     }
852 main()
854    time_t t = -1;
855    struct tm *tm;
857    check(gmtime(&t), 69, 12, 31, 23, 59);
858    t = ~(time_t)0 << 31;
859    check(gmtime(&t), 1, 12, 13, 20, 52);
860    return 0;
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)
872 else
873   AC_CHECK_FUNCS(sigsetmask)
874   AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
875     [AC_TRY_RUN([
876 #include <stdio.h>
877 #include <signal.h>
879 void
880 sig_handler(dummy)
881      int dummy;
886 main()
888   signal(SIGINT, sig_handler);
889   kill(getpid(), SIGINT);
890   kill(getpid(), SIGINT);
891   return 0;
894         rb_cv_bsd_signal=yes,
895         rb_cv_bsd_signal=no,
896         rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
897   if test "$rb_cv_bsd_signal" = yes; then
898     AC_DEFINE(BSD_SIGNAL)
899   fi
902 AC_FUNC_GETPGRP
903 AC_FUNC_SETPGRP  
905 AC_C_BIGENDIAN
906 AC_C_CONST
907 AC_C_CHAR_UNSIGNED
908 AC_C_INLINE
909 AC_C_VOLATILE
911 if test x"$target_cpu" = xia64; then
912     AC_LIBOBJ([ia64])
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
916     AC_TRY_LINK(
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)
923     fi
926 AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
927     [AC_TRY_RUN([
929 main()
931   if (-1==(-1>>1))
932     return 0;
933   return 1;
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))
941 else
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,
947 [for fcnt in    dnl
948      _cnt       dnl
949      __cnt      dnl
950      _r         dnl
951      readCount  dnl
952      _rcount    dnl for emx0.9c
953 ; do
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")
959 done])
960 if test "$rb_cv_fcnt" = "not found"; then
961   AC_MSG_RESULT([not found(OK if using GNU libc)])
962 else
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,
969 [for frptr in   dnl
970      _IO_read_ptr dnl
971      _ptr       dnl
972      __ptr      dnl
973      bufpos     dnl
974      _p dnl
975 ; do
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")
981 done])
982 if test "$rb_cv_frptr" = "not found"; then
983   AC_MSG_RESULT([not found])
984 else
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,
991     [for frend in       dnl
992          _IO_read_end   dnl
993          bufread        dnl
994     ; do
995         AC_TRY_COMPILE([#include <stdio.h>
996     ],
997         [FILE *f = stdin; char buf[256]; f->$frend = buf;],
998         rb_cv_frend="$frend"; break,
999         rb_cv_frend="not found")
1000     done])
1001     if test "$rb_cv_frend" = "not found"; then
1002       AC_MSG_RESULT([not found])
1003     else
1004       AC_MSG_RESULT($rb_cv_frend)
1005       AC_DEFINE_UNQUOTED(FILE_READEND, $rb_cv_frend)
1006     fi
1007   fi
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>
1026       ],
1027       [_SC_$1 >= 0],
1028       rb_cv_have_sc_[]m4_tolower($1)=yes,
1029       rb_cv_have_sc_[]m4_tolower($1)=no)
1030     ])
1031   if test "$rb_cv_have_sc_[]m4_tolower($1)" = yes; then
1032     AC_DEFINE(HAVE__SC_$1)
1033   fi
1034   ])
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;;
1041 esac
1042 AC_CACHE_CHECK(stack growing direction, rb_cv_stack_grow_dir,
1043   [AC_TRY_RUN([
1044 /* recurse to get rid of inlining */
1045 static int
1046 stack_growup_p(addr, n)
1047     volatile int *addr, n;
1049     volatile int end;
1050     if (n > 0)
1051         return *addr = stack_growup_p(addr, n - 1);
1052     else
1053         return (&end > addr);
1055 int main()
1057     int x;
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
1068     done
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
1074         c)
1075             ;;
1076         c_r)
1077             MAINLIBS="-pthread $MAINLIBS"
1078             ;;
1079         *)
1080             LIBS="-l$pthread_lib $LIBS"
1081             ;;
1082         esac
1083     else
1084         AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
1085     fi
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)
1091        fi
1092     fi
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)
1097     fi
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], [
1109         case $withval in
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,
1115 [AC_TRY_RUN([
1116 /* Test for whether ELF binaries are produced */
1117 #include <fcntl.h>
1118 #include <stdlib.h>
1119 main() {
1120         char buffer[4];
1121         int i=open("conftest",O_RDONLY);
1122         if(i==-1)
1123                 exit(1); /* fail */
1124         if(read(i,&buffer[0],4)<4)
1125                 exit(1); /* fail */
1126         if(buffer[0] != 127 || buffer[1] != 'E' ||
1127            buffer[2] != 'L' || buffer[3] != 'F')
1128                 exit(1); /* fail */
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
1137   AC_DEFINE(USE_ELF)
1140 case "$target_os" in
1141 linux* | gnu* | k*bsd*-gnu | bsdi*)
1142     if test "$rb_cv_binary_elf" = no; then
1143         with_dln_a_out=yes
1144     else
1145         LDFLAGS="$LDFLAGS -rdynamic"
1146     fi;;
1147 esac
1148 LIBEXT=a
1150 AC_SUBST(DLDFLAGS)dnl
1151 AC_SUBST(ARCH_FLAG)dnl
1153 AC_SUBST(STATIC)dnl
1154 AC_SUBST(CCDLFLAGS)dnl
1155 AC_SUBST(LDSHARED)dnl
1156 AC_SUBST(LDSHAREDXX)dnl
1157 AC_SUBST(DLEXT)dnl
1158 AC_SUBST(DLEXT2)dnl
1159 AC_SUBST(LIBEXT)dnl
1161 STATIC=
1162 : ${LIBPATHFLAG=' -L%s'}
1163 : ${PATHFLAG=''}
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";;
1176     esac
1177   else
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=""} ;;
1184     esac
1185   fi
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"
1194   fi
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'
1203                         fi
1204                         rb_cv_dlopen=yes;;
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"
1209                            fi
1210                         else
1211                            : ${LDSHARED='ld -G'}
1212                         fi
1213                         rb_cv_dlopen=yes;;
1214         sunos*)         : ${LDSHARED='ld -assert nodefinitions'}
1215                         rb_cv_dlopen=yes;;
1216         irix*)          : ${LDSHARED='ld -shared'}
1217                         rb_cv_dlopen=yes;;
1218         sysv4*)         : ${LDSHARED='ld -G'}
1219                         rb_cv_dlopen=yes;;
1220         nto-qnx*)       : ${LDSHARED="qcc -shared"}
1221                         rb_cv_dlopen=yes ;;
1222         esix*|uxpds*)   : ${LDSHARED="ld -G"}
1223                         rb_cv_dlopen=yes ;;
1224         osf*)           : ${LDSHARED="ld -shared -expect_unresolved \"*\""}
1225                         rb_cv_dlopen=yes ;;
1226         bsdi3*)         case "$CC" in
1227                         *shlicc*)       : ${LDSHARED="$CC -r"}
1228                                         rb_cv_dlopen=yes ;;
1229                         esac ;;
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"
1234                         fi
1235                         rb_cv_dlopen=yes ;;
1236         interix*)       : ${LDSHARED="$CC -shared"}
1237                         XLDFLAGS="$XLDFLAGS -Wl,-E"
1238                         LIBPATHFLAG=" -L%1\$-s"
1239                         rb_cv_dlopen=yes ;;
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)'
1244                         else
1245                           test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED="ld -Bshareable"
1246                         fi
1247                         rb_cv_dlopen=yes ;;
1248         openbsd*)       : ${LDSHARED="\$(CC) -shared ${CCDLFLAGS}"}
1249                         if test "$rb_cv_binary_elf" = yes; then
1250                             LDFLAGS="$LDFLAGS -Wl,-E"
1251                         fi
1252                         rb_cv_dlopen=yes ;;
1253         nextstep*)      : ${LDSHARED='cc -r -nostdlib'}
1254                         LDFLAGS="$LDFLAGS -u libsys_s"
1255                         rb_cv_dlopen=yes ;;
1256         openstep*)      : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
1257                         : ${LDFLAGS=""}
1258                         rb_cv_dlopen=yes ;;
1259         rhapsody*)      : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
1260                         : ${LDFLAGS=""}
1261                         rb_cv_dlopen=yes ;;
1262         darwin*)        : ${LDSHARED='cc -dynamic -bundle -undefined suppress -flat_namespace'}
1263                         : ${LDFLAGS=""}
1264                         : ${LIBPATHENV=DYLD_LIBRARY_PATH}
1265                         rb_cv_dlopen=yes ;;
1266         aix*)           if test "$GCC" = yes; then
1267                             : ${LDSHARED='$(CC) -shared'}
1268                         else
1269                             : ${LDSHARED='$(CC)'}
1270                         fi
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}
1278                         rb_cv_dlopen=yes ;;
1279         human*)         : ${DLDFLAGS=''}
1280                         : ${LDSHARED=''}
1281                         : ${LDFLAGS=''}
1282                         : ${LINK_SO='ar cru $@ $(OBJS)'}
1283                         rb_cv_dlopen=yes ;;
1284         beos*)          case "$target_cpu" in
1285                           powerpc*)
1286                             : ${LDSHARED="ld -xms"}
1287                             DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
1288                             ;;
1289                           i586*)
1290                             : ${LDSHARED="ld -shared"}
1291                             DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -lbe -lroot"
1292                             ;;
1293                         esac
1294                         : ${LIBPATHENV=LIBRARY_PATH}
1295                         rb_cv_dlopen=yes ;;
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"
1299                         rb_cv_dlopen=yes;;
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"
1303                         : ${LIBPATHENV=""}
1304                         rb_cv_dlopen=yes ;;
1305         hiuxmpp)        : ${LDSHARED='ld -r'} ;;
1306         atheos*)        : ${LDSHARED="$CC -shared"}
1307                         rb_cv_dlopen=yes ;;
1308         os2-emx*)       LDFLAGS="$LDFLAGS -Zbsd-signals"
1309                         ;;
1310         *)              : ${LDSHARED='ld'} ;;
1311   esac
1312   AC_MSG_RESULT($rb_cv_dlopen)
1314 if test "${LDSHAREDXX}" = ""; then
1315     case "${LDSHARED}" in
1316         *'$(CC)'*)
1317             LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\$(CC)/$(CXX)/'`
1318             ;;
1319         *'${CC}'*)
1320             LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\${CC}/${CXX}/'`
1321             ;;
1322         *$CC*)
1323             LDSHAREDXX=`echo "${LDSHARED}" | sed "s|$CC|$CXX|"`
1324             ;;
1325         ld" "*)
1326             ;;
1327     esac
1330 AC_SUBST(LINK_SO)
1331 AC_SUBST(LIBPATHFLAG)
1332 AC_SUBST(RPATHFLAG)
1333 AC_SUBST(LIBPATHENV, "${LIBPATHENV-LD_LIBRARY_PATH}")
1334 AC_SUBST(TRY_LINK)
1336 dln_a_out_works=no
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,
1341     [AC_TRY_COMPILE([
1342 #define USE_DLN_A_OUT
1343 #include "dln.c"
1345         [], 
1346         rb_cv_dln_a_out=yes,
1347         rb_cv_dln_a_out=no)])
1348     if test "$rb_cv_dln_a_out" = yes; then
1349       dln_a_out_works=yes
1350       AC_DEFINE(USE_DLN_A_OUT)
1351     fi
1352   fi
1355 if test "$dln_a_out_works" = yes; then
1356   if test "$GCC" = yes; then
1357     STATIC=-static
1358   else
1359     STATIC=-Bstatic
1360   fi
1361   DLEXT=so
1362   CCDLFLAGS=
1363 else
1364   case "$target_os" in
1365     hpux*)      DLEXT=sl;;
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;;
1372     *)          DLEXT=so;;
1373   esac
1375 len=2 # .rb
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")
1381 AC_SUBST(DLEXT)
1383 AC_SUBST(STRIP)dnl
1384 if test "$with_dln_a_out" = yes; then
1385   STRIP=true
1386 else
1387   STRIP=strip
1390 case "$target_os" in
1391   linux* | gnu* | k*bsd*-gnu)
1392         STRIP='strip -S -x';;
1393   nextstep*)
1394         STRIP='strip -A -n';;
1395   openstep*)
1396         STRIP='strip -A -n';;
1397   rhapsody*)
1398         STRIP='strip -A -n';;
1399   darwin*)
1400         STRIP='strip -A -n';;
1401 esac
1403 EXTSTATIC=
1404 AC_SUBST(EXTSTATIC)dnl
1405 AC_ARG_WITH(static-linked-ext,
1406             [  --with-static-linked-ext link external modules statically],
1407             [case $withval in
1408              yes) STATIC=
1409                   EXTSTATIC=static;;
1410              *) ;;
1411              esac])
1413 case "$target_os" in
1414   human*)
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,
1420     [AC_TRY_RUN(
1421 changequote(<<, >>)dnl
1423 #include <stdio.h>
1424 main ()
1426    char buf[256];
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)
1435     fi
1436     AC_CACHE_CHECK(whether PD libc fconvert fail to round,
1437                    rb_cv_missing_fconvert,
1438     [AC_TRY_RUN(
1439 changequote(<<, >>)dnl
1441 #include <stdio.h>
1442 #include <math.h>
1443 main ()
1445   char buf[256];
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)
1454     fi
1455     AC_LIBOBJ([x68.o])
1456     CFLAGS="$CFLAGS -fansi-only"
1457     XCFLAGS="$XCFLAGS -cc1-stack=262144 -cpp-stack=2694144"
1458     EXEEXT=.x
1459     OBJEXT=o
1460     setup=Setup.x68
1461     ;;
1462   dnl OS/2 environment w/ Autoconf 2.1x for EMX
1463   os2-emx)
1464     AC_LIBOBJ([os2])
1465     setup=Setup.emx
1466     ;;
1467   *djgpp*)
1468     setup=Setup.dj
1469     ;;
1470   *)
1471     setup=Setup
1472     ;;
1473 esac
1475 AC_SUBST(setup)
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"
1487   PREP=fake.rb
1488   RUNRUBY='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
1489 else
1490   MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib'
1491   MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common -I./- -r$(srcdir)/ext/purelib.rb'
1492   PREP='miniruby$(EXEEXT)'
1493   RUNRUBY='$(MINIRUBY) $(srcdir)/runruby.rb --extout=$(EXTOUT)'
1495 AC_SUBST(MINIRUBY)
1496 AC_SUBST(PREP)
1497 AC_SUBST(RUNRUBY)
1498 AC_SUBST(EXTOUT, [${EXTOUT=.ext}])
1500 FIRSTMAKEFILE=""
1501 LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
1502 LIBRUBY='$(LIBRUBY_A)'
1503 LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static'
1504 LIBRUBYARG='$(LIBRUBYARG_STATIC)'
1505 SOLIBS=
1507 case "$target_os" in
1508   cygwin*|mingw*|beos*|openstep*|nextstep*|rhapsody*|darwin*|os2-emx*)
1509     : ${DLDLIBS=""}
1510     ;;
1511   *)
1512     DLDLIBS="$DLDLIBS -lc"
1513     ;;
1514 esac
1516 RUBY_SO_NAME='$(RUBY_INSTALL_NAME)'
1517 LIBRUBY_LDSHARED=$LDSHARED
1518 LIBRUBY_DLDFLAGS=$DLDFLAGS
1519 LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
1520 LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so'
1521 ENABLE_SHARED=no
1523 AC_ARG_ENABLE(shared,
1524        [  --enable-shared         build a shared library for Ruby. ],
1525        [enable_shared=$enableval])
1526 if test "$enable_shared" = 'yes'; then
1527   LIBRUBY='$(LIBRUBY_SO)'
1528   LIBRUBYARG_SHARED='-l$(RUBY_SO_NAME)'
1529   LIBRUBYARG='$(LIBRUBYARG_SHARED)'
1530   CFLAGS="$CFLAGS $CCDLFLAGS"
1531   ENABLE_SHARED=yes
1532   if test "$rb_cv_binary_elf" = yes; then
1533     SOLIBS='$(LIBS)'
1534   fi
1535   case "$target_os" in
1536     sunos4*)
1537         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
1538         ;;
1539     linux* | gnu* | k*bsd*-gnu | atheos*)
1540         LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
1541         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
1542         ;;
1543     freebsd*|dragonfly*)
1544         SOLIBS='$(LIBS)'
1545         LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
1546         if test "$rb_cv_binary_elf" != "yes" ; then
1547             LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
1548             LIBRUBY_ALIASES=''
1549         fi
1550         ;;
1551     netbsd*)
1552         SOLIBS='$(LIBS)'
1553         LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR).$(TEENY)'
1554         LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
1555         if test "$rb_cv_binary_elf" = yes; then # ELF platforms
1556            LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_SO_NAME).so'
1557         else    # a.out platforms
1558            LIBRUBY_ALIASES=""
1559         fi
1560         ;;
1561     openbsd*)
1562         SOLIBS='$(LIBS)'
1563         LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
1564         ;;
1565     solaris*)
1566         SOLIBS='$(LIBS)'
1567         LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)'
1568         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY) lib$(RUBY_SO_NAME).so'
1569         if test "$GCC" = yes; then
1570             LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)'
1571         fi
1572         XLDFLAGS="$XLDFLAGS "'-R${libdir}'
1573         ;;
1574     hpux*)
1575         XLDFLAGS="$XLDFLAGS "'-Wl,+s,+b,$(libdir)'
1576         LIBRUBY_SO='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
1577         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
1578         ;;
1579     aix*)
1580         LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry $XLDFLAGS"
1581         LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
1582         SOLIBS='-lm -lc'
1583         ;;
1584     beos*)
1585         case "$target_cpu" in
1586         powerpc*)
1587             LIBRUBY_DLDFLAGS='-f ruby.exp -lnet -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
1588             ;;
1589         esac
1590         ;;
1591     darwin*)
1592         LIBRUBY_SO='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib'
1593         LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace'
1594         LIBRUBY_DLDFLAGS='-install_name $(libdir)/lib$(RUBY_SO_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
1595         LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib'
1596         ;;
1597     interix*)
1598         LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
1599         ;;
1600     *)
1601         ;;
1602   esac
1604 if test "$enable_rpath" = yes; then
1605     LIBRUBYARG_SHARED="${linker_flag}-R ${linker_flag}\$(libdir) -L\$(libdir) $LIBRUBYARG_SHARED"
1608 LDFLAGS="-L. $LDFLAGS"
1609 AC_SUBST(ARCHFILE)
1611 dnl build rdoc index if requested
1612 RDOCTARGET=""
1613 AC_ARG_ENABLE(install-doc,
1614        [  --disable-install-doc    do not install rdoc indexes during install ],
1615        [install_doc=$enableval], [install_doc=yes])
1616 if test "$install_doc" != no; then
1617    RDOCTARGET="install-doc"
1619 AC_SUBST(RDOCTARGET)
1621 if test "$rb_with_pthread" = "yes"; then
1622     THREAD_MODEL=pthread
1624 MINIDLNOBJ=dln.o
1625 case "$target_os" in
1626     linux*)
1627         ;;
1628     netbsd*)
1629         CFLAGS="$CFLAGS -pipe"
1630         ;;
1631     nextstep*|openstep*)
1632         # The -fno-common is needed if we wish to embed the Ruby interpreter
1633         # into a plugin module of some project (as opposed to embedding it
1634         # within the project's application).  The -I/usr/local/include is
1635         # needed because CPP as discovered by configure (cc -E -traditional)
1636         # fails to consult /usr/local/include by default.  This causes
1637         # mkmf.rb's have_header() to fail if the desired resource happens to be
1638         # installed in the /usr/local tree.
1639         CFLAGS="$CFLAGS -pipe -fno-common"
1640         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
1641         ;;
1642     rhapsody*)
1643         CFLAGS="$CFLAGS -pipe -no-precomp -fno-common"
1644         ;;
1645     darwin*)
1646         CFLAGS="$CFLAGS -pipe -fno-common"
1647         MINIDLNOBJ=dmydln.o
1648         ;;
1649     os2-emx)
1650         CFLAGS="$CFLAGS -DOS2 -Zmts"
1651         LIBRUBY_A=`echo $LIBRUBY_A | sed 's/^lib//'`
1652         LIBRUBY_SO=`echo $LIBRUBY_SO | sed 's/^lib//'`
1653         LIBRUBY_ALIASES=`for i in $LIBRUBY_ALIASES; do echo "$i"; done | sed 's/^lib//'`
1654         ;;
1655     osf*)
1656         if test "$GCC" != "yes" ; then
1657           # compile something small: taint.c is fine for this.
1658           # the main point is the '-v' flag of 'cc'.
1659           case "`cc -v -I. -c main.c -o /tmp/main.o 2>&1`" in
1660           */gemc_cc*)   # we have the new DEC GEM CC
1661                         CFLAGS="$CFLAGS -oldc"
1662                         ;;
1663           *)            # we have the old MIPS CC
1664                         ;;
1665           esac
1666           # cleanup
1667           rm -f /tmp/main.o
1668           CFLAGS="$CFLAGS -std"
1669         fi
1670         ;;
1671     beos*)
1672         case "$target_cpu" in
1673         powerpc*)
1674             CFLAGS="$CFLAGS -relax_pointers"
1675             ;;
1676         esac
1677         ;;
1678     cygwin*|mingw*)
1679         LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
1680         case "$target_os" in
1681         cygwin*)
1682             if test x"$enable_shared" = xyes; then
1683                 LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}${TEENY}.dll
1684             fi
1685             ;;
1686         mingw*)
1687             RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}${TEENY}
1688             if test x"$enable_shared" = xyes; then
1689                 LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
1690                 LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' $(RUBYDEF)'
1691             fi
1692             AC_LIBOBJ([win32])
1693             COMMON_LIBS=m
1694 #           COMMON_MACROS="WIN32_LEAN_AND_MEAN="
1695             COMMON_HEADERS="winsock2.h windows.h"
1696             THREAD_MODEL=win32
1697             ;;
1698         esac
1699         LIBRUBY_ALIASES=''
1700         FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
1701         SOLIBS='$(LIBS)'
1702         if test x"$enable_shared" = xyes; then
1703             LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
1704         else
1705             LIBRUBY_SO=dummy
1706             LIBRUBY='lib$(RUBY_SO_NAME).a'
1707             LIBRUBYARG='-l$(RUBY_SO_NAME)'
1708         fi
1709         MINIDLNOBJ=dmydln.o
1710         ;;
1711     hpux*)
1712         case "$YACC" in
1713           *yacc*)
1714             XCFLAGS="$XCFLAGS -DYYMAXDEPTH=300"
1715             YACC="$YACC -Nl40000 -Nm40000"
1716             ;;
1717         esac
1718         MINIDLNOBJ=dmydln.o
1719         ;;
1720     *)
1721         ;;
1722 esac
1723 MINIOBJS="$MINIDLNOBJ"
1725 case "$build_os" in
1726   *msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;;
1727 esac
1729 CPPFLAGS="$CPPFLAGS "'$(DEFS)'
1730 test -z "$CFLAGS" || CFLAGS="$CFLAGS "; CFLAGS="$CFLAGS"'${cflags}'
1731 test -z "$CPPFLAGS" || CPPFLAGS="$CPPFLAGS "; CPPFLAGS="$CPPFLAGS"'${cppflags}'
1732 AC_SUBST(cppflags, [])dnl
1733 AC_SUBST(cflags, ['${optflags} ${debugflags}'])dnl
1734 AC_SUBST(optflags)dnl
1735 AC_SUBST(debugflags)dnl
1736 AC_SUBST(XCFLAGS)dnl
1737 AC_SUBST(XLDFLAGS)dnl
1738 AC_SUBST(LIBRUBY_LDSHARED)
1739 AC_SUBST(LIBRUBY_DLDFLAGS)
1740 AC_SUBST(RUBY_INSTALL_NAME)
1741 AC_SUBST(rubyw_install_name)
1742 AC_SUBST(RUBYW_INSTALL_NAME)
1743 AC_SUBST(RUBY_SO_NAME)
1744 AC_SUBST(LIBRUBY_A)
1745 AC_SUBST(LIBRUBY_SO)
1746 AC_SUBST(LIBRUBY_ALIASES)
1747 AC_SUBST(LIBRUBY)
1748 AC_SUBST(LIBRUBYARG)
1749 AC_SUBST(LIBRUBYARG_STATIC)
1750 AC_SUBST(LIBRUBYARG_SHARED)
1751 AC_SUBST(SOLIBS)
1752 AC_SUBST(DLDLIBS)
1753 AC_SUBST(ENABLE_SHARED)
1754 AC_SUBST(MAINLIBS)
1755 AC_SUBST(COMMON_LIBS)
1756 AC_SUBST(COMMON_MACROS)
1757 AC_SUBST(COMMON_HEADERS)
1758 AC_SUBST(EXPORT_PREFIX)
1759 AC_SUBST(MINIOBJS)
1760 AC_SUBST(THREAD_MODEL)
1762 MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`"
1763 MAKEFILES="`echo $MAKEFILES`"
1764 AC_SUBST(MAKEFILES)
1766 ri_prefix=
1767 test "$program_prefix" != NONE &&
1768   ri_prefix=$program_prefix
1770 ri_suffix=
1771 test "$program_suffix" != NONE &&
1772   ri_suffix=$program_suffix
1774 RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
1775 case "$target_os" in
1776   cygwin*|mingw*)
1777     RUBYW_INSTALL_NAME="${ri_prefix}rubyw${ri_suffix}"
1778     rubyw_install_name="$RUBYW_INSTALL_NAME"
1779     ;;
1780 esac
1781 RUBY_LIB_PREFIX=`eval echo \\"${libdir}/ruby\\"`
1783 AC_ARG_WITH(sitedir,
1784             [  --with-sitedir=DIR      site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
1785             [sitedir=$withval],
1786             [sitedir='${libdir}/ruby/site_ruby'])
1787 SITE_DIR=`eval echo \\"${sitedir}\\"`
1789 AC_ARG_WITH(vendordir,
1790             [  --with-vendordir=DIR    vendor libraries in DIR [PREFIX/lib/ruby/vendor_ruby]],
1791             [vendordir=$withval],
1792             [vendordir='${prefix}/lib/ruby/vendor_ruby'])
1793 VENDOR_DIR=`eval echo \\"${vendordir}\\"`
1795 case "$target_os" in
1796   cygwin*|mingw*|*djgpp*|os2-emx*)
1797     RUBY_LIB_PREFIX="`eval echo "$RUBY_LIB_PREFIX" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1798     RUBY_SITE_LIB_PATH="`eval echo "$SITE_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1799     RUBY_VENDOR_LIB_PATH="`eval echo "$VENDOR_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
1800     ;;
1801   *)
1802     RUBY_LIB_PREFIX="`eval echo \\"$RUBY_LIB_PREFIX\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1803     RUBY_SITE_LIB_PATH="`eval echo \\"$SITE_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1804     RUBY_VENDOR_LIB_PATH="`eval echo \\"$VENDOR_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
1805     ;;
1806 esac
1807 RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}.${TEENY}"
1808 RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}.${TEENY}"
1809 RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}.${TEENY}"
1811 AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
1812 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
1813 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
1814 AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
1815 AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
1817 AC_SUBST(arch)dnl
1818 AC_SUBST(sitearch)dnl
1819 AC_SUBST(sitedir)dnl
1820 AC_SUBST(vendordir)dnl
1822 configure_args=$ac_configure_args
1823 AC_SUBST(configure_args)dnl
1825 if test "$fat_binary" != no ; then
1826     arch="fat-${target_os}"
1828     AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
1829                  "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1831     AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
1832                  "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1833     AC_DEFINE_UNQUOTED(RUBY_VENDOR_THIN_ARCHLIB,
1834                  "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1835     AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}")
1836 else
1837     arch="${target_cpu}-${target_os}"
1838     AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
1841 case "$target_os" in
1842   mingw*) sitearch="$target_cpu-$rb_cv_msvcrt" ;;
1843   *) sitearch="${arch}" ;;
1844 esac
1846 AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
1847 AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
1848 AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${RUBY_VENDOR_LIB_PATH2}/${sitearch}")
1850 AC_ARG_WITH(search-path,
1851                 [  --with-search-path=DIR specify the additional search path],
1852                 [search_path=$withval])
1853 if test "$search_path" != ""; then
1854     AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
1857 AC_ARG_WITH(rubyhdrdir,
1858             [  --with-ruby-hdrdir=DIR  core headers in DIR [INCLUDEDIR]],
1859             [rubyhdrdir=$withval],
1860             [rubyhdrdir='${includedir}/ruby-${MAJOR}.${MINOR}.${TEENY}'])
1862 AC_ARG_WITH(sitehdrdir,
1863             [  --with-site-hdrdir=DIR  core headers in DIR [INCLUDEDIR]],
1864             [sitehdrdir=$withval],
1865             [sitehdrdir='${rubyhdrdir}/site_ruby'])
1867 AC_ARG_WITH(vendorhdrdir,
1868             [  --with-vendor-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
1869             [vendorhdrdir=$withval],
1870             [vendorhdrdir='${rubyhdrdir}/vendor_ruby'])
1872 AC_SUBST(rubyhdrdir)dnl
1873 AC_SUBST(sitehdrdir)dnl
1874 AC_SUBST(vendorhdrdir)dnl
1876 AC_ARG_WITH(mantype,
1877                 [  --with-mantype=TYPE specify man page type; TYPE is one of man and doc],
1878                 [
1879                         case "$withval" in
1880                         man|doc)
1881                                 MANTYPE=$withval
1882                                 ;;
1883                         *)
1884                                 AC_MSG_ERROR(invalid man type: $withval)
1885                                 ;;
1886                         esac
1887                 ])
1888 if test -z "$MANTYPE"; then
1889         AC_PATH_PROGS(NROFF, nroff awf, /bin/false, "/usr/bin:/usr/ucb")
1890         if ${NROFF} -mdoc ${srcdir}/ruby.1 >/dev/null 2>&1; then
1891                 MANTYPE=doc
1892         else
1893                 MANTYPE=man
1894         fi
1896 AC_SUBST(MANTYPE)
1898 arch_hdrdir="${EXTOUT}/include/${arch}/ruby"
1899 $MAKEDIRS "${arch_hdrdir}"
1900 config_h="${arch_hdrdir}/config.h"
1901 if test -f "${config_h}" && tr -d '\015' < confdefs.h | cmp -s "${config_h}" -; then
1902   echo "config.h unchanged"
1903 else
1904   echo "creating config.h"
1905   tr -d '\015' < confdefs.h > "${config_h}"
1907 tr -d '\015' < largefile.h > confdefs.h
1908 rm largefile.h
1910 BUILTIN_ENCS=["`sed -n -e '/^BUILTIN_ENCS[      ]*=/{' \
1911         -e s/// -e :l -e '/\\\\$/N' -e 's/\\\\\\n/ /' -e 't l' -e p \
1912         -e '}' "${srcdir}/enc/Makefile.in"`"]
1913 BUILTIN_ENCOBJS=
1914 for e in $BUILTIN_ENCS; do BUILTIN_ENCOBJS="$BUILTIN_ENCOBJS `basename $e .c`"'.$(OBJEXT)'; done
1915 AC_SUBST(BUILTIN_ENCOBJS)
1917 AC_CONFIG_FILES($FIRSTMAKEFILE)
1918 AC_CONFIG_FILES(Makefile, [{
1919         sed '/^MISSING/s/\$U\././g' Makefile
1920         echo; test x"$EXEEXT" = x || echo 'miniruby: miniruby$(EXEEXT)'
1921         test "$RUBY_INSTALL_NAME$EXEEXT" = ruby || echo 'ruby: $(PROGRAM);'
1922         sed ['s/{\$([^(){}]*)[^{}]*}//g'] ${srcdir}/common.mk
1923       } >> confmk$$.tmp && mv -f confmk$$.tmp Makefile],
1924 [RUBY_INSTALL_NAME=$RUBY_INSTALL_NAME EXEEXT=$EXEEXT])
1925 AC_OUTPUT