configure.in


DEFINITIONS

This source file includes following functions.


   1  dnl Process this file with autoconf to produce a configure script.
   2  AC_INIT()
   3  
   4  AC_PREREQ(2.50)
   5  
   6  rb_version=`grep RUBY_VERSION $srcdir/version.h`
   7  MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
   8  MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
   9  TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
  10  AC_SUBST(MAJOR)
  11  AC_SUBST(MINOR)
  12  AC_SUBST(TEENY)
  13  dnl checks for alternative programs
  14  AC_ARG_WITH(gcc, [  --without-gcc           never use gcc], [
  15          case $withval in
  16          no)     : ${CC=cc}
  17                  ;;
  18          yes)    : ${CC=gcc}
  19                  ;;
  20          *)      CC=$withval
  21                  ;;
  22          esac])
  23  dnl If the user switches compilers, we can't believe the cache
  24  if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
  25  then
  26    AC_MSG_ERROR(cached CC is different -- throw away $cache_file
  27  (it is also a good idea to do 'make clean' before compiling))
  28  fi
  29  
  30  if test "$program_prefix" = NONE; then
  31    program_prefix=
  32  fi
  33  AC_CANONICAL_TARGET
  34  
  35  dnl checks for fat-binary
  36  fat_binary=no
  37  AC_ARG_ENABLE(fat-binary,
  38         [  --enable-fat-binary     build a NeXT/Apple Multi Architecture Binary. ],
  39         [fat_binary=$enableval])
  40   if test "$fat_binary" = yes ; then
  41  
  42      AC_MSG_CHECKING(target architecture)
  43  
  44      case "$target_os" in
  45      rhapsody*)
  46          echo -n "MacOS X Server: "
  47                  if test "$TARGET_ARCHS" = "" ; then
  48                  TARGET_ARCHS="ppc i386"
  49                  fi
  50          ;;
  51      nextstep*|openstep*)
  52              echo -n "NeXTSTEP/OPENSTEP: "
  53              if test "$TARGET_ARCHS" = "" ; then
  54                 if test `/usr/bin/arch` = "m68k" ; then
  55                     TARGET_ARCHS="m68k i486"
  56                 else # Black and Native one
  57                     TARGET_ARCHS="m68k `/usr/bin/arch`"
  58                 fi
  59              fi
  60          # to ensure AC_HEADER_SYS_WAIT works
  61          AC_DEFINE(_POSIX_SOURCE)
  62          ;;
  63      macos*|darwin*)
  64          echo -n "MacOS X (Darwin): "
  65              if test "$TARGET_ARCHS" = "" ; then
  66                  TARGET_ARCHS="ppc i386"
  67              fi
  68          ;;
  69      esac
  70      # /usr/lib/arch_tool -archify_list $TARGET_ARCHS
  71      for archs in $TARGET_ARCHS 
  72      do
  73          ARCH_FLAG="$ARCH_FLAG -arch $archs "
  74          echo -n " $archs"
  75      done
  76      AC_DEFINE(NEXT_FAT_BINARY)
  77      echo "."
  78  fi 
  79  
  80  case $target_cpu in
  81    i?86) frame_address=yes;;
  82    *)    frame_address=no;;
  83  esac
  84  AC_ARG_ENABLE(frame-address,
  85         [  --enable-frame-address  use GCC __builtin_frame_address(). ],
  86         [frame_address=$enableval])
  87  if test $frame_address = yes; then
  88      AC_DEFINE(USE_BUILTIN_FRAME_ADDRESS)
  89  fi
  90  
  91  AC_ARG_PROGRAM
  92  
  93  dnl Checks for programs.
  94  
  95  if test x"${build}" != x"${host}"; then
  96    AC_CHECK_TOOL(CC, gcc)
  97  fi
  98  AC_PROG_CC
  99  AC_PROG_GCC_TRADITIONAL
 100  
 101  AC_PROG_YACC
 102  AC_CHECK_TOOL(RANLIB, ranlib, :)
 103  AC_CHECK_TOOL(AR, ar)
 104  if test -z "$AR"; then
 105    AC_CHECK_PROGS(AR, aal, ar)
 106  fi
 107  
 108  case "$target_os" in
 109  cygwin*|mingw*)
 110      AC_CHECK_TOOL(NM, nm)
 111      AC_CHECK_TOOL(WINDRES, windres)
 112      AC_CHECK_TOOL(DLLWRAP, dllwrap)
 113      target_cpu=`echo $target_cpu | sed s/i.86/i386/`
 114      : ${enable_shared=yes}
 115      ;;
 116  esac
 117  
 118  # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
 119  case "$target_os" in
 120  hiuxmpp*)
 121      AC_DEFINE(__HIUX_MPP__)
 122      ;;
 123  esac
 124  
 125  AC_PROG_LN_S
 126  AC_PROG_MAKE_SET
 127  
 128  # checks for UNIX variants that set C preprocessor variables
 129  AC_AIX
 130  AC_MINIX
 131  
 132  dnl check for large file stuff
 133  AC_SYS_LARGEFILE
 134  
 135  AC_CHECK_TYPES([long long, off_t])
 136  
 137  AC_CHECK_SIZEOF(int, 4)
 138  AC_CHECK_SIZEOF(short, 2)
 139  AC_CHECK_SIZEOF(long, 4)
 140  AC_CHECK_SIZEOF(long long, 0)
 141  AC_CHECK_SIZEOF(__int64, 0)
 142  AC_CHECK_SIZEOF(off_t, 0)
 143  AC_CHECK_SIZEOF(void*, 4)
 144  AC_CHECK_SIZEOF(float, 4)
 145  AC_CHECK_SIZEOF(double, 8)
 146  
 147  AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
 148    [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
 149          rb_cv_have_prototypes=yes,
 150          rb_cv_have_prototypes=no)])
 151  if test "$rb_cv_have_prototypes" = yes; then
 152    AC_DEFINE(HAVE_PROTOTYPES)
 153  fi
 154  
 155  AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
 156    [AC_TRY_COMPILE([#define paste(a,b) a##b],
 157                    [int xy = 1; return paste(x,y);],
 158                    rb_cv_tokenpaste=ansi,
 159                    rb_cv_tokenpaste=knr)])
 160  if test "$rb_cv_tokenpaste" = ansi; then
 161    AC_DEFINE(TOKEN_PASTE(x,y),[x##y])
 162  else
 163    AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
 164  fi
 165  
 166  AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
 167    [AC_TRY_COMPILE([
 168  #include <stdarg.h>
 169  int foo(int x, ...) {
 170          va_list va;
 171          va_start(va, x);
 172          va_arg(va, int);
 173          va_arg(va, char *);
 174          va_arg(va, double);
 175          return 0;
 176  }
 177  ], [return foo(10, "", 3.14);],
 178          rb_cv_stdarg=yes,
 179          rb_cv_stdarg=no)])
 180  if test "$rb_cv_stdarg" = yes; then
 181    AC_DEFINE(HAVE_STDARG_PROTOTYPES)
 182  fi
 183  
 184  AC_CACHE_CHECK([for noreturn], rb_cv_noreturn,
 185  [rb_cv_noreturn=no
 186  for mac in "x __attribute__ ((noreturn))" "__declspec(noreturn) x" x; do
 187    AC_TRY_COMPILE(
 188      [#define NORETURN(x) $mac
 189  NORETURN(void exit(int x));],
 190      [],
 191      [rb_cv_noreturn="$mac"; break])
 192  done])
 193  AC_DEFINE_UNQUOTED([NORETURN(x)], $rb_cv_noreturn)
 194  
 195  dnl Check whether we need to define sys_nerr locally
 196  AC_CHECK_DECLS([sys_nerr], [], [], [$ac_includes_default
 197  #include <errno.h>])
 198  
 199  dnl whether link libc_r or not
 200  AC_ARG_WITH(libc_r, 
 201          [  --with-libc_r           link libc_r if possible (FreeBSD only)], [
 202          case $withval in
 203          yes) with_libc_r=yes;;
 204          *)   with_libc_r=no;;
 205          esac], [with_libc_r=no])
 206  
 207  dnl Checks for libraries.
 208  case "$target_os" in
 209  nextstep*)      ;;
 210  openstep*)      ;;
 211  rhapsody*)      ;;
 212  darwin*)        LIBS="-lobjc $LIBS";;
 213  human*)         ac_cv_func_getpgrp_void=yes;;
 214  beos*)          ;;
 215  cygwin*)        rb_cv_have_daylight=no
 216                  ac_cv_var_tzname=no
 217                  ac_cv_func__setjmp=no;;
 218  mingw*)         LIBS="-lwsock32 -lmsvcrt $LIBS"
 219                  ac_cv_header_a_out_h=no
 220                  ac_cv_header_pwd_h=no
 221                  ac_cv_header_utime_h=no
 222                  ac_cv_header_sys_ioctl_h=no
 223                  ac_cv_header_sys_param_h=no
 224                  ac_cv_header_sys_resource_h=no
 225                  ac_cv_header_sys_select_h=no
 226                  ac_cv_header_sys_times_h=no
 227                  ac_cv_func_times=yes
 228                  ac_cv_func_waitpid=yes
 229                  ac_cv_func_vsnprintf=yes
 230                  ac_cv_func_seekdir=yes
 231                  ac_cv_func_telldir=yes
 232                  ac_cv_func_crypt=no
 233                  ;;
 234  os2_emx*)       LIBS="-lm $LIBS"
 235                  ac_cv_lib_dir_opendir=no;;
 236  msdosdjgpp*)    LIBS="-lm $LIBS"
 237                  ac_cv_func_getpgrp_void=yes;;
 238  freebsd*)       LIBS="-lm $LIBS"
 239                  AC_CACHE_CHECK([whether -lxpg4 has to be linked],
 240                    rb_cv_lib_xpg4_needed,
 241                    [AC_TRY_CPP([
 242  #include <osreldate.h>
 243  #if __FreeBSD_version < 400020 || \
 244     (__FreeBSD_version >= 500000 && __FreeBSD_version < 500005)
 245  #error needs libxpg4
 246  #endif
 247                     ],
 248                     rb_cv_lib_xpg4_needed=no,
 249                     rb_cv_lib_xpg4_needed=yes,
 250                     rb_cv_lib_xpg4_needed=yes)])
 251                  if test "$rb_cv_lib_xpg4_needed" = yes; then
 252                          AC_CHECK_LIB(xpg4, setlocale)
 253                  fi
 254                  if test "$with_libc_r" = yes; then
 255                          AC_CACHE_CHECK([whether libc_r is supplementary to libc],
 256                            rb_cv_supplementary_lib_c_r,
 257                            [AC_TRY_CPP([
 258  #include <osreldate.h>
 259  #if 500016 <= __FreeBSD_version
 260  #error libc_r is supplementary to libc
 261  #endif
 262                             ],
 263                             rb_cv_supplementary_lib_c_r=no,
 264                             rb_cv_supplementary_lib_c_r=yes,
 265                             rb_cv_supplementary_lib_c_r=yes)])
 266                          if test "$rb_cv_supplementary_lib_c_r" = yes; then
 267                                  MAINLIBS="-lc_r $MAINLIBS"                      
 268                          else
 269                                  MAINLIBS="-pthread $MAINLIBS"                   
 270                                  CFLAGS="-D_THREAD_SAFE $CFLAGS"
 271                          fi
 272                  fi
 273                  ;;
 274  linux*)         LIBS="-lm $LIBS"
 275                  case "$target_cpu" in
 276                  alpha*)
 277                      CFLAGS="-mieee $CFLAGS" ;;
 278                  esac ;;
 279  osf*)           LIBS="-lm $LIBS"
 280                  case "$target_cpu"::"$GCC" in
 281                  alpha*::yes)
 282                      CFLAGS="-mieee $CFLAGS" ;;
 283                  alpha*::no|alpha*::)
 284                      CFLAGS="-ieee $CFLAGS" ;;
 285                  esac ;;
 286  *) LIBS="-lm $LIBS";;
 287  esac
 288  AC_CHECK_LIB(crypt, crypt)
 289  AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
 290  AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
 291  
 292  dnl Checks for header files.
 293  AC_HEADER_DIRENT
 294  AC_HEADER_STDC
 295  AC_HEADER_SYS_WAIT
 296  AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
 297                   fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
 298                   syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h \
 299                   sys/mkdev.h)
 300  
 301  dnl Checks for typedefs, structures, and compiler characteristics.
 302  AC_TYPE_UID_T
 303  AC_TYPE_SIZE_T
 304  AC_STRUCT_ST_BLKSIZE
 305  AC_STRUCT_ST_BLOCKS
 306  AC_STRUCT_ST_RDEV
 307  
 308  dnl Checks for library functions.
 309  AC_TYPE_GETGROUPS
 310  AC_TYPE_SIGNAL
 311  AC_FUNC_ALLOCA
 312  AC_FUNC_MEMCMP
 313  AC_FUNC_FSEEKO
 314  AC_CHECK_FUNCS(ftello)
 315  AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
 316                   strchr strstr strtoul crypt flock vsnprintf\
 317                   isinf isnan finite hypot acosh)
 318  AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync\
 319                truncate chsize times utimes fcntl lockf lstat symlink readlink\
 320                setitimer setruid seteuid setreuid setresuid setproctitle\
 321                setrgid setegid setregid setresgid pause lchown lchmod\
 322                getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\
 323                dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod\
 324                mktime timegm cosh sinh tanh)
 325  AC_STRUCT_TIMEZONE
 326  AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
 327    [AC_TRY_COMPILE([#include <time.h>],
 328      [struct tm t; t.tm_gmtoff = 3600;],
 329    [rb_cv_member_struct_tm_tm_gmtoff=yes],
 330    [rb_cv_member_struct_tm_tm_gmtoff=no])])
 331  if test "$rb_cv_member_struct_tm_tm_gmtoff" = yes; then
 332    AC_DEFINE(HAVE_STRUCT_TM_TM_GMTOFF)
 333  fi
 334  AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
 335    [AC_TRY_LINK([#include <time.h>
 336    int i;],
 337          [i = daylight;],
 338          rb_cv_have_daylight=yes,
 339          rb_cv_have_daylight=no)])
 340  if test "$rb_cv_have_daylight" = yes; then
 341    AC_DEFINE(HAVE_DAYLIGHT)
 342  fi
 343  AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
 344    [AC_TRY_RUN([
 345  #include <time.h>
 346  
 347  void
 348  check(tm, y, m, d, h, s)
 349      struct tm *tm;
 350      int y, m, d, h, s;
 351  {
 352      if (!tm ||
 353          tm->tm_year != y ||
 354          tm->tm_mon  != m-1 ||
 355          tm->tm_mday != d ||
 356          tm->tm_hour != h ||
 357          tm->tm_sec  != s) {
 358          exit(1);
 359      }
 360  }
 361  
 362  int
 363  main()
 364  {
 365     time_t t = -1;
 366     struct tm *tm;
 367  
 368     check(gmtime(&t), 69, 12, 31, 23, 59);
 369     t = ~(time_t)0 << 31;
 370     check(gmtime(&t), 1, 12, 13, 20, 52);
 371     return 0;
 372  }
 373  ],
 374          rb_cv_negative_time_t=yes,
 375          rb_cv_negative_time_t=no,
 376          rb_cv_negative_time_t=yes)])
 377  if test "$rb_cv_negative_time_t" = yes; then
 378    AC_DEFINE(NEGATIVE_TIME_T)
 379  fi
 380  
 381  if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
 382     AC_DEFINE(POSIX_SIGNAL)
 383  else
 384    AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
 385      [AC_TRY_RUN([
 386  #include <stdio.h>
 387  #include <signal.h>
 388  
 389  void
 390  sig_handler(dummy)
 391       int dummy;
 392  {
 393  }
 394  
 395  int
 396  main()
 397  {
 398    signal(SIGINT, sig_handler);
 399    kill(getpid(), SIGINT);
 400    kill(getpid(), SIGINT);
 401    return 0;
 402  }
 403  ],
 404          rb_cv_bsd_signal=yes,
 405          rb_cv_bsd_signal=no,
 406          rb_cv_bsd_signal=no)])
 407    if test "$rb_cv_bsd_signal" = yes; then
 408      AC_DEFINE(BSD_SIGNAL)
 409    fi
 410  fi
 411  
 412  AC_FUNC_GETPGRP
 413  AC_FUNC_SETPGRP  
 414  
 415  AC_CACHE_CHECK(for working strtod, rb_cv_func_strtod,
 416  [AC_TRY_RUN([
 417  double strtod ();
 418  int
 419  main()
 420  {
 421    {
 422      /* Some versions of Linux strtod mis-parse strings with leading '+'.  */
 423      char *string = " +69";
 424      char *term;
 425      double value;
 426      value = strtod(string, &term);
 427      if (value != 69 || term != (string + 4))
 428        exit(1);
 429    }
 430  
 431    {
 432      /* Under Solaris 2.4, strtod returns the wrong value for the
 433         terminating character under some conditions.  */
 434      char *string = "NaN";
 435      char *term;
 436      strtod(string, &term);
 437      if (term != string && *(term - 1) == 0)
 438        exit(1);
 439    }
 440    exit(0);
 441  }
 442  ], rb_cv_func_strtod=yes, rb_cv_func_strtod=no, rb_cv_func_strtod=no)])
 443  test $rb_cv_func_strtod = no && AC_LIBOBJ([strtod])
 444  
 445  AC_C_BIGENDIAN
 446  AC_C_CONST
 447  AC_C_CHAR_UNSIGNED
 448  AC_C_INLINE
 449  
 450  AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
 451      [AC_TRY_RUN([
 452  int
 453  main()
 454  {
 455    if (-1==(-1>>1))
 456      return 0;
 457    return 1;
 458  }
 459  ],
 460          rb_cv_rshift_sign=yes,
 461          rb_cv_rshift_sign=no,
 462          rb_cv_rshift_sign=yes)])
 463  if test "$rb_cv_rshift_sign" = yes; then
 464    AC_DEFINE(RSHIFT(x,y), ((x)>>(int)y))
 465  else
 466    AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
 467  fi
 468  
 469  AC_MSG_CHECKING(read count field in FILE structures)
 470  AC_CACHE_VAL(rb_cv_fcnt,
 471  [for fcnt in    dnl
 472       _cnt       dnl
 473       __cnt      dnl
 474       _r         dnl
 475       readCount  dnl
 476       _rcount    dnl for emx0.9c
 477  ; do
 478      AC_TRY_COMPILE([#include <stdio.h>
 479  ],
 480          [FILE *f = stdin; f->$fcnt = 0;],
 481          rb_cv_fcnt="$fcnt"; break,
 482          rb_cv_fcnt="not found")
 483  done])
 484  if test "$rb_cv_fcnt" = "not found"; then
 485    AC_MSG_RESULT([not found(OK if using GNU libc)])
 486  else
 487    AC_MSG_RESULT($rb_cv_fcnt)
 488    AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
 489  fi
 490  
 491  AC_MSG_CHECKING(read buffer ptr field in FILE structures)
 492  AC_CACHE_VAL(rb_cv_frptr,
 493  [for frptr in   dnl
 494       _IO_read_ptr dnl
 495       _ptr       dnl
 496       __ptr      dnl
 497       bufpos     dnl
 498       _p dnl
 499  ; do
 500      AC_TRY_COMPILE([#include <stdio.h>
 501  ],
 502          [FILE *f = stdin; char buf[256]; f->$frptr = buf;],
 503          rb_cv_frptr="$frptr"; break,
 504          rb_cv_frptr="not found")
 505  done])
 506  if test "$rb_cv_frptr" = "not found"; then
 507    AC_MSG_RESULT([not found])
 508  else
 509    AC_MSG_RESULT($rb_cv_frptr)
 510    AC_DEFINE_UNQUOTED(FILE_READPTR, $rb_cv_frptr)
 511  
 512    if test "$rb_cv_fcnt" = "not found"; then
 513      AC_MSG_CHECKING(read buffer end field in FILE structures)
 514      AC_CACHE_VAL(rb_cv_frend,
 515      [for frend in       dnl
 516           _IO_read_end   dnl
 517           bufread        dnl
 518      ; do
 519          AC_TRY_COMPILE([#include <stdio.h>
 520      ],
 521          [FILE *f = stdin; char buf[256]; f->$frend = buf;],
 522          rb_cv_frend="$frend"; break,
 523          rb_cv_frend="not found")
 524      done])
 525      if test "$rb_cv_frend" = "not found"; then
 526        AC_MSG_RESULT([not found])
 527      else
 528        AC_MSG_RESULT($rb_cv_frend)
 529        AC_DEFINE_UNQUOTED(FILE_READEND, $rb_cv_frend)
 530      fi
 531    fi
 532  fi
 533  
 534  dnl default value for $KANJI
 535  DEFAULT_KCODE="KCODE_NONE"
 536  
 537  AC_ARG_WITH(default-kcode, 
 538          [  --with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)], 
 539          [case $withval in
 540          utf8) DEFAULT_KCODE="KCODE_UTF8";;
 541          euc)  DEFAULT_KCODE="KCODE_EUC";;
 542          sjis) DEFAULT_KCODE="KCODE_SJIS";;
 543          none) DEFAULT_KCODE="KCODE_NONE";;
 544          *)    AC_MSG_WARN($withval is not valid kcode; ignored);;
 545          esac])
 546  AC_DEFINE_UNQUOTED(DEFAULT_KCODE, $DEFAULT_KCODE)
 547  
 548  dnl wheather use dln_a_out or not
 549  AC_ARG_WITH(dln-a-out, 
 550          [  --with-dln-a-out        use dln_a_out if possible], [
 551          case $withval in
 552          yes) with_dln_a_out=yes;;
 553          *)   with_dln_a_out=no;;
 554          esac], [with_dln_a_out=no])
 555  
 556  AC_SUBST(XLDFLAGS)dnl
 557  
 558  AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
 559  [AC_TRY_RUN([
 560  /* Test for whether ELF binaries are produced */
 561  #include <fcntl.h>
 562  #include <stdlib.h>
 563  main() {
 564          char buffer[4];
 565          int i=open("conftest",O_RDONLY);
 566          if(i==-1)
 567                  exit(1); /* fail */
 568          if(read(i,&buffer[0],4)<4)
 569                  exit(1); /* fail */
 570          if(buffer[0] != 127 || buffer[1] != 'E' ||
 571             buffer[2] != 'L' || buffer[3] != 'F')
 572                  exit(1); /* fail */
 573          exit(0); /* succeed (yes, it's ELF) */
 574  }
 575  ],
 576  rb_cv_binary_elf=yes,
 577  rb_cv_binary_elf=no,
 578  rb_cv_binary_elf=yes)])
 579  
 580  if test "$rb_cv_binary_elf" = yes; then
 581    AC_DEFINE(USE_ELF)
 582  fi
 583  
 584  case "$target_os" in
 585      linux*)
 586    if test "$rb_cv_binary_elf" = no; then
 587      with_dln_a_out=yes
 588      target_os=${target_os}-a_out
 589    else
 590      LDFLAGS="-rdynamic"
 591    fi;;
 592  netbsd*)
 593      if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
 594      then
 595          netbsd_elf=yes
 596      else
 597          netbsd_elf=no
 598      fi
 599      ;;
 600  esac
 601  
 602  AC_SUBST(DLDFLAGS)dnl
 603  
 604  AC_SUBST(STATIC)dnl
 605  AC_SUBST(CCDLFLAGS)dnl
 606  AC_SUBST(LDSHARED)dnl
 607  AC_SUBST(DLEXT)dnl
 608  AC_SUBST(DLEXT2)dnl
 609  
 610  STATIC=
 611  
 612  if test "$with_dln_a_out" != yes; then
 613    rb_cv_dlopen=unknown
 614    AC_MSG_CHECKING(whether OS depend dynamic link works)
 615    if test "$GCC" = yes; then
 616      case "$target_os" in
 617      nextstep*)  ;;
 618      openstep*)  ;;
 619      rhapsody*)  ;;
 620      darwin*)    CCDLFLAGS=-fno-common;;
 621      human*)     ;;
 622      bsdi*)      ;;
 623      beos*)      ;;
 624      cygwin*)    ;;
 625      mingw*)     ;;
 626      netbsd*) CCDLFLAGS=-fPIC;;
 627      *) CCDLFLAGS=-fPIC;;
 628      esac
 629    else
 630      case "$target_os" in
 631          hpux*)          CCDLFLAGS='+z';;
 632          solaris*|irix*) CCDLFLAGS='-KPIC' ;;
 633          sunos*)         CCDLFLAGS='-PIC' ;;
 634          esix*|uxpds*)   CCDLFLAGS='-KPIC' ;;
 635          *)              CCDLFLAGS='' ;;
 636      esac
 637    fi
 638  
 639    case "$target_os" in
 640          hpux*)          DLDFLAGS="-E"
 641                          LDSHARED='ld -b'
 642                          LDFLAGS="-Wl,-E"
 643                          rb_cv_dlopen=yes;;
 644          solaris*)       if test "$GCC" = yes; then
 645                             LDSHARED='$(CC) -Wl,-G'
 646                             if `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null; then
 647                                 LDFLAGS="-Wl,-E"
 648                                 LDSHARED="$LDSHARED -shared"
 649                             fi
 650                          else
 651                             LDSHARED='ld -G'
 652                          fi
 653                          rb_cv_dlopen=yes;;
 654          sunos*)         LDSHARED='ld -assert nodefinitions'
 655                          rb_cv_dlopen=yes;;
 656          irix*)          LDSHARED='ld -shared'
 657                          rb_cv_dlopen=yes;;
 658          sysv4*)         LDSHARED='ld -G'
 659                          rb_cv_dlopen=yes;;
 660          nto-qnx*)       LDSHARED="qcc -shared"
 661                          rb_cv_dlopen=yes ;;
 662          esix*|uxpds*)   LDSHARED="ld -G"
 663                          rb_cv_dlopen=yes ;;
 664          osf*)           LDSHARED="$CC -shared"
 665                          rb_cv_dlopen=yes ;;
 666          linux*)         LDSHARED="$CC -shared"
 667                          rb_cv_dlopen=yes ;;
 668          gnu*)           LDSHARED="$CC -shared"
 669                          rb_cv_dlopen=yes
 670                          LDFLAGS="-rdynamic" ;;
 671          freebsd*)       LDSHARED="$CC -shared"
 672                          if test "$rb_cv_binary_elf" = yes; then
 673                              LDFLAGS="-rdynamic"
 674                              DLDFLAGS='-Wl,-soname,$(.TARGET)'
 675                          else
 676                            test "$GCC" = yes && `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null || LDSHARED="ld -Bshareable"
 677                          fi
 678                          rb_cv_dlopen=yes ;;
 679          netbsd*)        LDSHARED='${CC} -shared'
 680                          if test "$rb_cv_binary_elf" = yes; then
 681                              LDFLAGS="-Wl,-export-dynamic"
 682                          fi
 683                          rb_cv_dlopen=yes ;;
 684          openbsd*)       LDSHARED="ld -Bforcearchive -Bshareable"
 685                          rb_cv_dlopen=yes ;;
 686          bsdi3*)         case "$CC" in
 687                          *shlicc*)       LDSHARED="$CC -r"
 688                                          rb_cv_dlopen=yes ;;
 689                          esac ;;
 690          bsdi*)          LDSHARED="ld -shared"
 691                          LDFLAGS='-rdynamic -Wl,-rpath,$(prefix)/lib/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0'
 692                          rb_cv_dlopen=yes ;;
 693          nextstep*)      LDSHARED='cc -r -nostdlib'
 694                          LDFLAGS="-u libsys_s"
 695                          DLDFLAGS="$ARCH_FLAG" 
 696                          rb_cv_dlopen=yes ;;
 697          openstep*)      LDSHARED='cc -dynamic -bundle -undefined suppress'
 698                          LDFLAGS=""
 699                          DLDFLAGS="$ARCH_FLAG"
 700                          rb_cv_dlopen=yes ;;
 701          rhapsody*)      LDSHARED='cc -dynamic -bundle -undefined suppress'
 702                          LDFLAGS=""
 703                          DLDFLAGS="$ARCH_FLAG"
 704                          rb_cv_dlopen=yes ;;
 705          darwin*)        LDSHARED='cc -dynamic -bundle -undefined suppress -flat_namespace'
 706                          LDFLAGS=""
 707                          DLDFLAGS="$ARCH_FLAG"
 708                          rb_cv_dlopen=yes ;;
 709          aix*)           LDSHARED='/usr/ccs/bin/ld'
 710                          XLDFLAGS='-Wl,-bE:ruby.imp'
 711                          DLDFLAGS='-brtl -eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
 712                          LDFLAGS="-brtl"
 713                          rb_cv_dlopen=yes ;;
 714  
 715          human*)         DLDFLAGS=''
 716                          LDSHARED=''
 717                          LDFLAGS=''
 718                          rb_cv_dlopen=yes ;;
 719          beos*)          case "$target_cpu" in
 720                            powerpc*)
 721                              LDSHARED="ld -xms"
 722                              DLDFLAGS='-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
 723                              ;;
 724                            i586*)
 725                              LDSHARED="ld -shared"
 726                              DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot"
 727                              ;;
 728                          esac
 729                          rb_cv_dlopen=yes ;;
 730          nto-qnx*)       DLDFLAGS="-L/lib -L/usr/lib -L/usr/local/lib"
 731                          LDSHARED='ld -Bshareable -x'
 732                          LDFLAGS="-L/lib -L/usr/lib -L/usr/local/lib"
 733                          rb_cv_dlopen=yes;;
 734          cygwin*|mingw*) : ${LDSHARED="${CC} -shared -s"}
 735                          LDFLAGS='-Wl,--stack,0x02000000'
 736                          rb_cv_dlopen=yes ;;
 737          hiuxmpp)        LDSHARED='ld -r' ;;
 738          *)              LDSHARED='ld' ;;
 739    esac
 740    AC_MSG_RESULT($rb_cv_dlopen)
 741  fi
 742  
 743  dln_a_out_works=no
 744  if test "$ac_cv_header_a_out_h" = yes; then
 745    if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
 746      cat confdefs.h > config.h
 747      AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out,
 748      [AC_TRY_COMPILE([
 749  #define USE_DLN_A_OUT
 750  #include "dln.c"
 751  ],
 752          [], 
 753          rb_cv_dln_a_out=yes,
 754          rb_cv_dln_a_out=no)])
 755      if test "$rb_cv_dln_a_out" = yes; then
 756        dln_a_out_works=yes
 757        AC_DEFINE(USE_DLN_A_OUT)
 758      fi
 759    fi
 760  fi
 761  
 762  if test "$dln_a_out_works" = yes; then
 763    if test "$GCC" = yes; then
 764      STATIC=-static
 765    else
 766      STATIC=-Bstatic
 767    fi
 768    DLEXT=so
 769    AC_DEFINE(DLEXT, ".so")
 770    CCDLFLAGS=
 771  else
 772    case "$target_os" in
 773      hpux*)      DLEXT=sl
 774                  AC_DEFINE(DLEXT, ".sl");;
 775      nextstep*)  DLEXT=bundle
 776                  AC_DEFINE(DLEXT, ".bundle");;
 777      openstep*)  DLEXT=bundle
 778                  AC_DEFINE(DLEXT, ".bundle");;
 779      rhapsody*)  DLEXT=bundle
 780                  AC_DEFINE(DLEXT, ".bundle");;
 781      darwin*)    DLEXT=bundle
 782                  AC_DEFINE(DLEXT, ".bundle");;
 783      os2_emx*)   DLEXT=dll
 784                  AC_DEFINE(DLEXT, ".dll");;
 785      cygwin*|mingw*)     DLEXT=so
 786                  AC_DEFINE(DLEXT, ".so")
 787                  DLEXT2=dll
 788                  AC_DEFINE(DLEXT2, ".dll");;
 789      *)          DLEXT=so
 790                  AC_DEFINE(DLEXT, ".so");;
 791    esac
 792  fi
 793  
 794  AC_SUBST(STRIP)dnl
 795  if test "$with_dln_a_out" = yes; then
 796    STRIP=true
 797  else
 798    STRIP=strip
 799  fi
 800  
 801  case "$target_os" in
 802    linux*)
 803          STRIP='strip -S -x';;
 804    gnu*)
 805          STRIP='strip -S -x';;
 806    nextstep*)
 807          STRIP='strip -A -n';;
 808    openstep*)
 809          STRIP='strip -A -n';;
 810    rhapsody*)
 811          STRIP='strip -A -n';;
 812    darwin*)
 813          STRIP='strip -A -n';;
 814  esac
 815  
 816  EXTSTATIC=
 817  AC_SUBST(EXTSTATIC)dnl
 818  AC_ARG_WITH(static-linked-ext,
 819              [  --with-static-linked-ext link external modules statically],
 820              [case $withval in
 821               yes) STATIC=
 822                    EXTSTATIC=static;;
 823               *) ;;
 824               esac])
 825  
 826  case "$target_os" in
 827    human*)
 828      AC_CHECK_LIB(signal, _harderr)
 829      AC_CHECK_LIB(hmem, hmemset)
 830      AC_CHECK_FUNCS(select gettimeofday)
 831      AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
 832                     rb_cv_missing__dtos18,
 833      [AC_TRY_RUN(
 834  changequote(<<, >>)dnl
 835  <<
 836  #include <stdio.h>
 837  main ()
 838  {
 839     char buf[256];
 840     sprintf (buf, "%g", 1e+300);
 841     exit (strcmp (buf, "1e+300") ? 0 : 1);
 842  }
 843  >>,
 844  changequote([, ])dnl
 845  rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no, rb_cv_missing__dtos18=no)])
 846      if test "$rb_cv_missing__dtos18" = yes; then
 847        AC_DEFINE(MISSING__DTOS18)
 848      fi
 849      AC_CACHE_CHECK(whether PD libc fconvert fail to round,
 850                     rb_cv_missing_fconvert,
 851      [AC_TRY_RUN(
 852  changequote(<<, >>)dnl
 853  <<
 854  #include <stdio.h>
 855  #include <math.h>
 856  main ()
 857  {
 858    char buf[256];
 859    sprintf (buf, "%f", log(exp(1.0)));
 860    exit (strcmp (buf, "1.000000") ? 0 : 1);
 861  }
 862  >>,
 863  changequote([, ])dnl
 864  rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no)])
 865      if test "$rb_cv_missing_fconvert" = yes; then
 866        AC_DEFINE(MISSING_FCONVERT)
 867      fi
 868      AC_LIBOBJ([x68.o])
 869      CFLAGS="$CFLAGS -fansi-only -cc1-stack=262144 -cpp-stack=2694144"
 870      EXEEXT=.x
 871      OBJEXT=o
 872      setup=Setup.x68
 873      ;;
 874    dnl OS/2 environment w/ Autoconf 2.1x for EMX
 875    os2_emx)
 876      AC_LIBOBJ([os2])
 877      setup=Setup.emx
 878      ;;
 879    *djgpp*)
 880      setup=Setup.dj
 881      ;;
 882    *)
 883      setup=Setup
 884      ;;
 885  esac
 886  
 887  AC_SUBST(setup)
 888  
 889  if test "$prefix" = NONE; then
 890    prefix=$ac_default_prefix
 891  fi
 892  
 893  if test "$fat_binary" = yes ; then
 894    CFLAGS="$CFLAGS $ARCH_FLAG"
 895  fi
 896  
 897  if test x"$cross_compiling" = xyes; then
 898    MINIRUBY="ruby -I`pwd` -rfake"
 899    PREP=fake.rb
 900  else
 901    MINIRUBY='./miniruby$(EXEEXT)'
 902    PREP=''
 903  fi
 904  AC_SUBST(MINIRUBY)
 905  AC_SUBST(PREP)
 906  
 907  FIRSTMAKEFILE=""
 908  LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
 909  LIBRUBY='$(LIBRUBY_A)'
 910  LIBRUBYARG='$(LIBRUBY_A)'
 911  SOLIBS=
 912  
 913  case "$target_os" in
 914    cygwin*|mingw*|beos*|openstep*|nextstep*|rhapsody*|darwin*|os2_emx*)
 915      DLDLIBS=""
 916      ;;
 917    *)
 918      DLDLIBS="-lc"
 919      ;;
 920  esac
 921  
 922  LIBRUBY_LDSHARED=$LDSHARED
 923  LIBRUBY_DLDFLAGS=$DLDFLAGS
 924  LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
 925  LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
 926  ENABLE_SHARED=no
 927  
 928  AC_ARG_ENABLE(shared,
 929         [  --enable-shared         build a shared library for Ruby. ],
 930         [enable_shared=$enableval])
 931  if test "$enable_shared" = 'yes'; then
 932    LIBRUBY='$(LIBRUBY_SO)'
 933    LIBRUBYARG='-L. -l$(RUBY_INSTALL_NAME)'
 934    CFLAGS="$CFLAGS $CCDLFLAGS"
 935    ENABLE_SHARED=yes
 936    if test "$rb_cv_binary_elf" = yes; then
 937      SOLIBS='$(LIBS)'
 938    fi
 939    case "$target_os" in
 940      sunos4*)
 941          LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
 942          ;;
 943      linux*)
 944          LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)'
 945          LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
 946          ;;
 947      gnu*)
 948          LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)'
 949          LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
 950          ;;
 951      freebsd*)
 952          SOLIBS='$(LIBS)'
 953          LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)'
 954          if test "$rb_cv_binary_elf" != "yes" ; then
 955              LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
 956              LIBRUBY_ALIASES=''
 957          fi
 958          ;;
 959      netbsd*)
 960          SOLIBS='$(LIBS)'
 961          LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR).$(TEENY)'
 962          LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)'
 963          LIBRUBYARG='-Wl,-R -Wl,${prefix}/lib -L${prefix}/lib -L. -l$(RUBY_INSTALL_NAME)'
 964          if test "$rb_cv_binary_elf" = yes; then # ELF platforms
 965             LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_INSTALL_NAME).so'
 966          else    # a.out platforms
 967             LIBRUBY_ALIASES=""
 968          fi
 969          ;;
 970      openbsd*)
 971          SOLIBS='$(LIBS)'
 972          ;;
 973      solaris*)
 974          XLDFLAGS='-R${prefix}/lib'
 975          ;;
 976      hpux*)
 977          XLDFLAGS='-Wl,+s,+b,$(prefix)/lib'
 978          LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
 979          LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
 980          ;;
 981      aix*)
 982          if test "$GCC" = yes; then
 983              LIBRUBY_LDSHARED='$(CC) -shared'
 984              LIBRUBY_DLDFLAGS='-Wl,-bE:ruby.imp'
 985          else
 986              LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
 987              LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry'
 988          fi
 989          LIBRUBYARG='-L${prefix}/lib -Wl,lib$(RUBY_INSTALL_NAME).so'
 990          SOLIBS='-lm -lc'
 991          ;;
 992      beos*)
 993          case "$target_cpu" in
 994          powerpc*)
 995              LIBRUBY_DLDFLAGS='-f ruby.exp -lnet -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
 996              ;;
 997          esac
 998          ;;
 999      darwin*)
1000          LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib'
1001          LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace'
1002          LIBRUBY_DLDFLAGS='-install_name $(prefix)/lib/lib$(RUBY_INSTALL_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
1003          LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_INSTALL_NAME).dylib'
1004          ;;
1005      *)
1006          ;;
1007    esac
1008  fi
1009  
1010  case "$target_os" in
1011      netbsd*)
1012          CFLAGS="$CFLAGS -pipe"
1013          ;;
1014      nextstep*)
1015          CFLAGS="$CFLAGS -pipe"
1016          ;;
1017      openstep*)
1018          CFLAGS="$CFLAGS -pipe"
1019          ;;
1020      rhapsody*)
1021          CFLAGS="$CFLAGS -pipe -no-precomp"
1022          ;;
1023      darwin*)
1024          CFLAGS="$CFLAGS -pipe"
1025          ;;
1026      os2_emx)
1027          CFLAGS="$CFLAGS -DOS2"
1028          ;;
1029      osf*)
1030          if test "$GCC" != "yes" ; then
1031            # compile something small: taint.c is fine for this.
1032            # the main point is the '-v' flag of 'cc'.
1033            case "`cc -v -I. -c main.c -o /tmp/main.o 2>&1`" in
1034            */gemc_cc*)   # we have the new DEC GEM CC
1035                          CFLAGS="$CFLAGS -oldc"
1036                          ;;
1037            *)            # we have the old MIPS CC
1038                          ;;
1039            esac
1040            # cleanup
1041            rm -f /tmp/main.o
1042            CFLAGS="$CFLAGS -std"
1043          fi
1044                  ;;
1045      beos*)
1046          case "$target_cpu" in
1047          powerpc*)
1048              CFLAGS="$CFLAGS -relax_pointers"
1049              ;;
1050          esac
1051          ;;
1052      cygwin*|mingw*)
1053          case "$target_os" in
1054          cygwin*)
1055              RUBY_SO_NAME=$target_os-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
1056              AC_LIBOBJ([strftime])
1057              CCDLFLAGS=-DUSEIMPORTLIB ;;
1058          mingw*)
1059              RUBY_SO_NAME=msvcrt-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
1060              AC_LIBOBJ([win32])
1061              CFLAGS="-DNT -D__NO_ISOCEXT $CFLAGS"
1062              CCDLFLAGS=-DIMPORT ;;
1063          esac
1064          if test x"$enable_shared" = xyes; then
1065              LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
1066              LIBRUBY_DLDFLAGS='-Wl,--out-implib=$(LIBRUBY) $(RUBYDEF)'
1067              LIBRUBY='lib$(LIBRUBY_SO).a'
1068          else
1069              LIBRUBY_SO=dummy
1070              LIBRUBY_DLDFLAGS=''
1071              LIBRUBY='lib$(RUBY_SO_NAME).a'
1072          fi
1073          LIBRUBY_ALIASES=''
1074          LIBRUBY_A='lib$(RUBY_INSTALL_NAME)s.a'
1075          LIBRUBYARG='-L. -l$(RUBY_SO_NAME)'
1076          FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
1077          SOLIBS='$(LIBS)'
1078          ;;
1079      *)
1080          ;;
1081  esac
1082  
1083  AC_SUBST(LIBRUBY_LDSHARED)
1084  AC_SUBST(LIBRUBY_DLDFLAGS)
1085  AC_SUBST(RUBY_INSTALL_NAME)
1086  AC_SUBST(RUBY_SO_NAME)
1087  AC_SUBST(LIBRUBY_A)
1088  AC_SUBST(LIBRUBY_SO)
1089  AC_SUBST(LIBRUBY_ALIASES)
1090  AC_SUBST(LIBRUBY)
1091  AC_SUBST(LIBRUBYARG)
1092  AC_SUBST(SOLIBS)
1093  AC_SUBST(DLDLIBS)
1094  AC_SUBST(ENABLE_SHARED)
1095  AC_SUBST(MAINLIBS)
1096  
1097  ri_prefix=
1098  test "$program_prefix" != NONE &&
1099    ri_prefix=$program_prefix
1100  
1101  ri_suffix=
1102  test "$program_suffix" != NONE &&
1103    ri_suffix=$program_suffix
1104  
1105  RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
1106  case "$target_os" in
1107    cygwin*|mingw*|*djgpp*|os2_emx*)
1108      RUBY_LIB_PREFIX="/lib/ruby"
1109      ;;
1110    *)
1111      RUBY_LIB_PREFIX="${prefix}/lib/ruby"
1112      ;;
1113  esac
1114  RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
1115  
1116  AC_ARG_WITH(sitedir,
1117              [  --with-sitedir=DIR      site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
1118              [sitedir=$withval],
1119              [sitedir='${prefix}/lib/ruby/site_ruby'])
1120  SITE_DIR="`eval \"echo ${sitedir}\"`"
1121  case "$target_os" in
1122    cygwin*|mingw*|*djgpp*|os2_emx*)
1123      RUBY_SITE_LIB_PATH="`expr "$SITE_DIR" : "$prefix\(/.*\)"`" ||
1124      RUBY_SITE_LIB_PATH="$SITE_DIR";;
1125    *)
1126      RUBY_SITE_LIB_PATH="$SITE_DIR";;
1127  esac
1128  RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}"
1129  
1130  AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
1131  AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
1132  AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
1133  
1134  AC_SUBST(arch)dnl
1135  AC_SUBST(sitearch)dnl
1136  AC_SUBST(sitedir)dnl
1137  
1138  configure_args=$ac_configure_args
1139  AC_SUBST(configure_args)dnl
1140  
1141  if test "$fat_binary" = yes ; then
1142      arch="fat-${target_os}"
1143  
1144      AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
1145                   "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1146  
1147      AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
1148                   "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}")
1149      AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}")
1150  else
1151      arch="${target_cpu}-${target_os}"
1152      AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
1153  fi
1154  
1155  case "$target_os" in
1156    mingw*) sitearch="i386-msvcrt" ;;
1157    *) sitearch="${arch}" ;;
1158  esac
1159  
1160  AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
1161  AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
1162  
1163  AC_ARG_WITH(search-path,
1164                  [  --with-search-path=DIR specify the additional search path],
1165                  [search_path=$withval])
1166  if test "$search_path" != ""; then
1167      AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
1168  fi
1169  
1170  if test -f config.h && tr -d '\015' < confdefs.h | cmp -s config.h -; then
1171    echo "config.h unchanged"
1172  else
1173    echo "creating config.h"
1174    tr -d '\015' < confdefs.h > config.h
1175  fi
1176  : > confdefs.h
1177  
1178  AC_CONFIG_FILES([$FIRSTMAKEFILE Makefile])
1179  AC_OUTPUT