summaryrefslogtreecommitdiff
path: root/configure.in
blob: 069cffba8e6944a2bb802ad693c090f45a4c356b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ruby.h)

rb_version=`grep RUBY_VERSION $srcdir/version.h`
MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(TEENY)
dnl checks for alternative programs
AC_ARG_WITH(gcc, [--without-gcc             never use gcc], [
	case $withval in
	no)	CC=cc
		without_gcc=yes;;
	yes)	CC=gcc
		without_gcc=no;;
	*)	CC=$withval
		without_gcc=$withval;;
	esac], [without_gcc=no])
dnl If the user switches compilers, we can't believe the cache
if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
then
  AC_ERROR(cached CC is different -- throw away $cache_file
(it is also a good idea to do 'make clean' before compiling))
fi

dnl checks for thread
rb_thread=yes
AC_ARG_ENABLE(thread, [--disable-thread          never use user-level thread], [
	rb_thread=$enableval
])
if test $rb_thread = yes; then
  AC_DEFINE(USE_THREAD)
fi

AC_CANONICAL_HOST

dnl checks for fat-binary
fat_binary=no
AC_ARG_ENABLE(fat-binary,
       [--enable-fat-binary       build a NeXT/Apple Multi Architecture Binary. ],
       [fat_binary=$enableval])
 if test "$fat_binary" = yes ; then

    AC_MSG_CHECKING(target architecture)

    case "$host_os" in
    rhapsody*)
        echo -n "MacOS X Server: "
  	if test "$TARGET_ARCHS" = "" ; then
           TARGET_ARCHS="ppc i386"
  	fi
	;;
    nextstep*|openstep*)
  	echo -n "NeXTSTEP/OPENSTEP: "

        if test "$host_os" = "rhapsody" ; then
            echo -n "Rhapsody: "
	    if test "$TARGET_ARCHS" = "" ; then
               TARGET_ARCHS="ppc i486"
  	    fi
        else
  	    echo -n "NeXTSTEP/OPENSTEP: "
	    if test "$TARGET_ARCHS" = "" ; then
	       if test `/usr/bin/arch` = "m68k" ; then
		   TARGET_ARCHS="m68k i486"
	       else # Black and Native one
		   TARGET_ARCHS="m68k `/usr/bin/arch`"
	       fi
	    fi
        fi
        ;;
    esac
    # /usr/lib/arch_tool -archify_list $TARGET_ARCHS
    for archs in $TARGET_ARCHS 
    do
        ARCH_FLAG="$ARCH_FLAG -arch $archs "
        echo -n " $archs"
    done
    AC_DEFINE( NEXT_FAT_BINARY )
    echo "."
fi 

AC_ARG_PROGRAM

dnl Checks for programs.
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AC_PROG_YACC
AC_PROG_RANLIB
AC_SUBST(AR)
AC_CHECK_PROGS(AR, ar aal, ar)
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

# checks for UNIX variants that set C preprocessor variables
AC_MINIX

AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void*)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)

AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
  [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
	rb_cv_have_prototypes=yes,
	rb_cv_have_prototypes=no)])
if test "$rb_cv_have_prototypes" = yes; then
  AC_DEFINE(HAVE_PROTOTYPES)
fi

AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
  [AC_TRY_COMPILE([#define paste(a,b) a##b],
		  [int xy = 1; return paste(x,y);],
		  rb_cv_tokenpaste=ansi,
		  rb_cv_tokenpaste=knr)])
if test "$rb_cv_tokenpaste" = ansi; then
  AC_DEFINE(TOKEN_PASTE(x,y),[x##y])
else
  AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
fi

AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
  [AC_TRY_COMPILE([
#include <stdarg.h>
int foo(int x, ...) {
	va_list va;
	va_start(va, x);
	va_arg(va, int);
	va_arg(va, char *);
	va_arg(va, double);
	return 0;
}
], [return foo(10, "", 3.14);],
	rb_cv_stdarg=yes,
	rb_cv_stdarg=no)])
if test "$rb_cv_stdarg" = yes; then
  AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi

AC_CACHE_CHECK(for gcc attribute noreturn, rb_cv_have_attr_noreturn,
  [AC_TRY_COMPILE([void exit(int x) __attribute__ ((noreturn));], [],
	rb_cv_have_attr_noreturn=yes,
	rb_cv_have_attr_noreturn=no)])
if test "$rb_cv_have_attr_noreturn" = yes; then
  AC_DEFINE(HAVE_ATTR_NORETURN)
fi

dnl Checks for libraries.
case "$host_os" in
nextstep*)	;;
openstep*)	;;
rhapsody*)	;;
human*)		;;
beos*)		;;
*) LIBS="-lm $LIBS";;
esac
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
AC_CHECK_LIB(xpg4, setlocale)	# FreeBSD needs this

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \
		 sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\
		 syscall.h a.out.h string.h utime.h memory.h direct.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T
AC_TYPE_SIZE_T
AC_STRUCT_ST_BLKSIZE
save_LIBOJBS="$LIBOBJS"
AC_STRUCT_ST_BLOCKS
LIBOBJS="$save_LIBOBJS"
AC_STRUCT_ST_RDEV

dnl Checks for library functions.
AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
AC_FUNC_ALLOCA
AC_FUNC_VFORK
AC_FUNC_MEMCMP
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strerror strftime\
		 strchr strstr strtoul strdup crypt flock vsnprintf)
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd\
	      truncate chsize times utimes fcntl lockf setitimer\
	      setruid seteuid setreuid setrgid setegid setregid\
	      setpgrp2 getpgid setpgid getgroups getpriority\
	      dlopen sigprocmask sigaction _setjmp setpgrp setsid)
if test "$ac_cv_func_strftime" = no; then
    AC_STRUCT_TIMEZONE
    AC_TRY_LINK([],
	 [extern int daylight; int i = daylight;], AC_DEFINE(HAVE_DAYLIGHT))
fi

if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
   AC_DEFINE(POSIX_SIGNAL)
else
  AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
    [AC_TRY_RUN([
#include <stdio.h>
#include <signal.h>

void
sig_handler(dummy)
     int dummy;
{
}

int
main()
{
  signal(SIGINT, sig_handler);
  kill(getpid(), SIGINT);
  kill(getpid(), SIGINT);
  return 0;
}
],
	rb_cv_bsd_signal=yes,
	rb_cv_bsd_signal=no,
	rb_cv_bsd_signal=no)])
  if test "$rb_cv_bsd_signal" = yes; then
    AC_DEFINE(BSD_SIGNAL)
  fi
fi

if test "$ac_cv_func_setpgrp2" = yes; then
  AC_DEFINE(BSD_GETPGRP, getpgrp2)
  AC_DEFINE(BSD_SETPGRP, setpgrp2)
else
  AC_CACHE_CHECK(whether getpgrp() has arg, rb_cv_bsdgetpgrp,
    [AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);],
      rb_cv_bsdgetpgrp=yes,
      rb_cv_bsdgetpgrp=no)])
  if test "$rb_cv_bsdgetpgrp" = yes; then
    AC_DEFINE(BSD_GETPGRP, getpgrp)
  fi

  AC_CACHE_CHECK(whether setpgrp() has args, rb_cv_bsdsetpgrp,
    [AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(1, 1);],
	rb_cv_bsdsetpgrp=yes,
	rb_cv_bsdsetpgrp=no)])
  if test "$rb_cv_bsdsetpgrp" = yes; then
    AC_DEFINE(BSD_SETPGRP, setpgrp)
  fi
fi

AC_CACHE_CHECK(for working strtod, rb_cv_func_strtod,
[AC_TRY_RUN([
double strtod ();
int
main()
{
  {
    /* Some versions of Linux strtod mis-parse strings with leading '+'.  */
    char *string = " +69";
    char *term;
    double value;
    value = strtod(string, &term);
    if (value != 69 || term != (string + 4))
      exit(1);
  }

  {
    /* Under Solaris 2.4, strtod returns the wrong value for the
       terminating character under some conditions.  */
    char *string = "NaN";
    char *term;
    strtod(string, &term);
    if (term != string && *(term - 1) == 0)
      exit(1);
  }
  exit(0);
}
], rb_cv_func_strtod=yes, rb_cv_func_strtod=no, rb_cv_func_strtod=no)])
test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"

AC_C_BIGENDIAN
AC_CHAR_UNSIGNED

AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
    [AC_TRY_RUN([
int
main()
{
  if (-1==(-1>>1))
    return 0;
  return 1;
}
],
	rb_cv_rshift_sign=yes,
	rb_cv_rshift_sign=no,
	rb_cv_rshift_sign=yes)])
if test "$rb_cv_rshift_sign" = yes; then
  AC_DEFINE(RSHIFT(x,y), ((x)>>y))
else
  AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
fi

AC_MSG_CHECKING(count field in FILE structures)
AC_CACHE_VAL(rb_cv_fcnt,
[AC_TRY_COMPILE([#include <stdio.h>],
	[FILE *f = stdin; f->_cnt = 0;], rb_cv_fcnt="_cnt", )
if test "$rb_cv_fcnt" = ""; then
    AC_TRY_COMPILE([#include <stdio.h>],
	[FILE *f = stdin; f->__cnt = 0;], rb_cv_fcnt="__cnt", )
fi
if test "$rb_cv_fcnt" = ""; then
    AC_TRY_COMPILE([#include <stdio.h>],
	[FILE *f = stdin; f->_r = 0;], rb_cv_fcnt="_r", )
fi
if test "$rb_cv_fcnt" = ""; then
    AC_TRY_COMPILE([#include <stdio.h>],
	[FILE *f = stdin; f->readCount = 0;],
	rb_cv_fcnt="readCount", rb_cv_fcnt="not found")
fi])
if test "$rb_cv_fcnt" = "not found"; then
  AC_MSG_RESULT([not found(OK if using GNU libc)])
else
  AC_MSG_RESULT($rb_cv_fcnt)
  AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
fi

dnl wheather use dln_a_out ot not
AC_ARG_WITH(dln-a-out, [--with-dln-a-out          use dln_a_out if possible], [
	case $withval in
	yes) with_dln_a_out=yes;;
	*)   with_dln_a_out=no;;
	esac], [with_dln_a_out=no])

case "$host_os" in
    linux*)
  AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
  [AC_TRY_RUN([
/* Test for whether ELF binaries are produced */
#include <fcntl.h>
#include <stdlib.h>
main() {
	char buffer[4];
	int i=open("conftest",O_RDONLY);
	if(i==-1)
		exit(1); /* fail */
	if(read(i,&buffer[0],4)<4)
		exit(1); /* fail */
	if(buffer[0] != 127 || buffer[1] != 'E' ||
           buffer[2] != 'L' || buffer[3] != 'F')
		exit(1); /* fail */
	exit(0); /* succeed (yes, it's ELF) */
}
],
	rb_cv_binary_elf=yes,
	rb_cv_binary_elf=no,
	rb_cv_binary_elf=yes)])
  if test "$rb_cv_binary_elf" = no; then
    with_dln_a_out=yes
    host_os=${host_os}-a_out
  else
    LDFLAGS="-rdynamic"
  fi;;
esac

AC_SUBST(DLDFLAGS)dnl

AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl
AC_SUBST(LDSHARED)dnl
AC_SUBST(DLEXT)dnl

STATIC=

if test "$with_dln_a_out" != yes; then
  rb_cv_dlopen=unknown
  AC_MSG_CHECKING(whether OS depend dynamic link works)
  if test "$GCC" = yes; then
    case "$host_os" in
    nextstep*)	;;
    openstep*)	;;
    rhapsody*)	;;
    human*)	;;
    cygwin*)	CCDLFLAGS=-DDLLIMPORT;;
    *) CCDLFLAGS=-fPIC;;
    esac
  else
    case "$host_os" in
	hpux*)		CCDLFLAGS='+z';;
	solaris*|irix*)	CCDLFLAGS='-K PIC' ;;
	sunos*)		CCDLFLAGS='-PIC' ;;
	esix*|uxpds*)   CCDLFLAGS='-KPIC' ;;
	*)		CCDLFLAGS='' ;;
    esac
  fi

  case "$host_os" in
	hpux*)		DLDFLAGS="-E"
			LDSHARED='ld -b'
			LDFLAGS="-Wl,-E"
			rb_cv_dlopen=yes;;
	solaris*) 	LDSHARED='ld -G'
			LDFLAGS="-Wl,-E"
			rb_cv_dlopen=yes;;
	sunos*) 	LDSHARED='ld -assert nodefinitions'
			rb_cv_dlopen=yes;;
	irix*) 	 	LDSHARED='ld -ignore_unresolved'
			rb_cv_dlopen=yes;;
	sysv4*) 	LDSHARED='ld -G'
			rb_cv_dlopen=yes;;
	esix*|uxpds*) 	LDSHARED="ld -G"
			rb_cv_dlopen=yes ;;
	linux*) 	LDSHARED="gcc -shared"
			rb_cv_dlopen=yes ;;
	freebsd*)       LDSHARED="gcc -shared"
			if test -x /usr/bin/objformat && \
			   test `/usr/bin/objformat` = "elf" ; then
			    LDFLAGS="-rdynamic"
			    DLDFLAGS='-Wl,-soname,$(.TARGET)'
			    rb_cv_freebsd_elf=yes
			fi
			rb_cv_dlopen=yes ;;
	netbsd*) 	LDSHARED="ld -Bshareable"
			case "$host_cpu" in
			alpha|mips)
				LDFLAGS="-export-dynamic" ;;
			*)
				;;
			esac
			rb_cv_dlopen=yes ;;
	openbsd*) 	LDSHARED="ld -Bforcearchive -Bshareable"
			rb_cv_dlopen=yes ;;
	nextstep*)	LDSHARED='cc -r'
			LDFLAGS="-u libsys_s"
			DLDFLAGS="$ARCH_FLAG" 
			rb_cv_dlopen=yes ;;
	openstep*)	LDSHARED='cc -dynamic -bundle -undefined suppress'
			LDFLAGS=""
			DLDFLAGS="$ARCH_FLAG"
			rb_cv_dlopen=yes ;;
	rhapsody*)	LDSHARED='cc -dynamic -bundle -undefined suppress'
			LDFLAGS=""
			DLDFLAGS="$ARCH_FLAG"
			rb_cv_dlopen=yes ;;
	aix*)		LDSHARED='../../miniruby ../aix_ld.rb $(TARGET)'
			rb_cv_dlopen=yes ;;
	human*)		DLDFLAGS=''
			LDSHARED=''
			LDFLAGS='' ;;
	beos*) 		LDSHARED="ld -xms"
			case "$host_cpu" in
			  powerpc*)
			    DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
                            ;;
			  *)
			    DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
			    ;;
			esac
			rb_cv_dlopen=yes ;;
	cygwin*)	LDSHARED='../../miniruby ../cygwin32_ld.rb' ;;
	*) 		LDSHARED='ld' ;;
  esac
  AC_MSG_RESULT($rb_cv_dlopen)
fi

dln_a_out_works=no
if test "$ac_cv_header_a_out_h" = yes; then
  if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
    cat confdefs.h > config.h
    AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out,
    [AC_TRY_COMPILE([
#define USE_DLN_A_OUT
#include "dln.c"
],
	[], 
	rb_cv_dln_a_out=yes,
	rb_cv_dln_a_out=no)])
    if test "$rb_cv_dln_a_out" = yes; then
      dln_a_out_works=yes
      AC_DEFINE(USE_DLN_A_OUT)
    fi
  fi
fi

if test "$dln_a_out_works" = yes; then
  if test "$GCC" = yes; then
    STATIC=-static
  else
    STATIC=-Bstatic
  fi
  DLEXT=o
  AC_DEFINE(DLEXT, ".o")
  CCDLFLAGS=
else
  case "$host_os" in
    hpux*)	DLEXT=sl
	 	AC_DEFINE(DLEXT, ".sl");;
    nextstep*)	DLEXT=o
	 	AC_DEFINE(DLEXT, ".o");;
    openstep*)	DLEXT=bundle
	 	AC_DEFINE(DLEXT, ".bundle");;
    rhapsody*)	DLEXT=bundle
	 	AC_DEFINE(DLEXT, ".bundle");;
    cygwin*)	DLEXT=dll
	 	AC_DEFINE(DLEXT, ".dll");;
    *)		DLEXT=so
    		AC_DEFINE(DLEXT, ".so");;
  esac
fi

AC_SUBST(STRIP)dnl
if test "$with_dln_a_out" = yes; then
  STRIP=true
else
  STRIP=strip
fi

case "$host_os" in
  linux*)
	STRIP='strip -S -x';;
  nextstep*)
	STRIP='strip -A -n';;
  openstep*)
	STRIP='strip -A -n';;
  rhapsody*)
	STRIP='strip -A -n';;
esac

EXTSTATIC=
AC_SUBST(EXTSTATIC)dnl
AC_ARG_WITH(static-linked-ext,
	    [--with-static-linked-ext  link external modules statically],
            [case $withval in
	     yes) STATIC=
		  EXTSTATIC=static;;
	     *)	;;
	     esac])

case "$host_os" in
  human*)
    AC_CHECK_LIB(signal, _harderr)
    AC_CHECK_LIB(hmem, hmemset)
    AC_CHECK_FUNCS(select)
    AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
		   rb_cv_missing__dtos18,
    [AC_TRY_RUN(
changequote(<<, >>)dnl
<<
#include <stdio.h>
main ()
{
   char buf[256];
   sprintf (buf, "%g", 1e+300);
   exit (strcmp (buf, "1e+300") ? 0 : 1);
}
>>,
changequote([, ])dnl
rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no, rb_cv_missing__dtos18=no)])
    if test "$rb_cv_missing__dtos18" = yes; then
      AC_DEFINE(MISSING__DTOS18)
    fi
    AC_CACHE_CHECK(whether PD libc fconvert fail to round,
		   rb_cv_missing_fconvert,
    [AC_TRY_RUN(
changequote(<<, >>)dnl
<<
#include <stdio.h>
#include <math.h>
main ()
{
  char buf[256];
  sprintf (buf, "%f", log(exp(1.0)));
  exit (strcmp (buf, "1.000000") ? 0 : 1);
}
>>,
changequote([, ])dnl
rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no)])
    if test "$rb_cv_missing_fconvert" = yes; then
      AC_DEFINE(MISSING_FCONVERT)
    fi
    LIBOBJS="$LIBOBJS x68.o"
    CFLAGS="$CFLAGS -fansi-only -cc1-stack=196608 -cpp-stack=2694144"
    binsuffix=.x
    setup=Setup.x68
    ;;
  cygwin*)
    binsuffix=.exe
    setup=Setup
    ;;
  *)
    binsuffix=
    setup=Setup
    ;;
esac



AC_SUBST(binsuffix)
AC_SUBST(setup)

if test "$prefix" = NONE; then
  prefix=$ac_default_prefix
fi

if test "$fat_binary" = yes ; then
  CFLAGS="$CFLAGS $ARCH_FLAG"
fi

LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
LIBRUBY='$(LIBRUBY_A)'
LIBRUBYARG='$(LIBRUBY_A)'
SOLIBS=
if test "$host_os" = "beos"; then
  CFLAGS="$CFLAGS -relax_pointers"
  LIBRUBY='$(LIBRUBY_SO)'
  LIBRUBYARG='-l$(RUBY_INSTALL_NAME)'
  SOLIBS='-lnet'
  echo creating ruby.def
  case "$host_cpu" in
    powerpc*)
      cp beos/ruby.def.in ruby.exp
      ;;
    *)
      echo EXPORTS > ruby.def
      cat beos/ruby.def.in >> ruby.def
      ;;
  esac
fi

LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
if test "$enable_shared" = 'yes'; then
  LIBRUBY='$(LIBRUBY_SO)'
  LIBRUBYARG='-L./ -l$(RUBY_INSTALL_NAME)'
  CFLAGS="$CFLAGS $CCDLFLAGS"
  case "$host_os" in
    sunos4*|linux*)
	LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
	;;
    freebsd*)
	LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)'
	if test "$rb_cv_freebsd_elf" != "yes" ; then
	    LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
	    LIBRUBY_ALIASES=''
	fi
	;;
    hpux*)
	LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
	LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
	;;
    *)
	;;
  esac
fi

case "$host_os" in
	nextstep*)
    	CFLAGS="$CFLAGS -pipe"
		;;
	openstep*)
    	CFLAGS="$CFLAGS -pipe"
		;;
	rhasody*)
    	CFLAGS="$CFLAGS -pipe -no-precomp"
		;;
	*)
		;;	
esac

AC_SUBST(RUBY_INSTALL_NAME)
AC_SUBST(LIBRUBY_A)
AC_SUBST(LIBRUBY_SO)
AC_SUBST(LIBRUBY_ALIASES)
AC_SUBST(LIBRUBY)
AC_SUBST(LIBRUBYARG)
AC_SUBST(SOLIBS)

ri_prefix=
test "$program_prefix" != NONE &&
  ri_prefix=$program_prefix

ri_suffix="${MAJOR}.${MINOR}"
test "$program_suffix" != NONE &&
  ri_suffix=$program_suffix

RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
#RUBY_LIB_PATH="${prefix}/lib/${RUBY_INSTALL_NAME}/${MAJOR}.${MINOR}"
RUBY_LIB_PATH="${prefix}/lib/ruby/${MAJOR}.${MINOR}"
AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_LIB_PATH}/site_ruby")
AC_SUBST(arch)dnl

if test "$fat_binary" = yes ; then
    arch="fat-${host_os}"

    AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
                 "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}" )

    AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
                 "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}" )
else
    arch="${host_cpu}-${host_os}"
fi
AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_LIB_PATH}/site_ruby/${arch}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")

echo "creating config.h"
cat confdefs.h > config.h

AC_OUTPUT(Makefile ext/extmk.rb)