~ubuntu-branches/ubuntu/vivid/gcl/vivid

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
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
AC_INIT()
AC_CONFIG_HEADER(h/gclincl.h)
# some parts of this configure script are taken from the tcl configure.in

# Step 1: set the variable "system" to hold the name and version number
# for the system.  This can usually be done via the "uname" command, but
# there are a few systems, like Next, where this doesn't work.


AC_MSG_CHECKING([system version (for dynamic loading)])
if machine=`uname -m` ; then true; else machine=unknown ; fi

AC_CHECK_PROGS(AWK,gawk nawk awk,"")

AC_CHECK_PROGS(MAKEINFO,makeinfo,"false")
AC_SUBST(MAKEINFO)

if test -f /usr/lib/NextStep/software_version; then
    system=NEXTSTEP-`${AWK} '/3/,/3/' /usr/lib/NextStep/software_version`
else
    system=`uname -s`-`uname -r`
    if test "$?" -ne 0 ; then
	AC_MSG_RESULT([unknown (can't find uname command)])
	system=unknown
    else
	# Special check for weird MP-RAS system (uname returns weird
	# results, and the version is kept in special file).
    
	if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
	    system=MP-RAS-`${AWK} '{print $3}' /etc/.relid'`
	fi
	if test "`uname -s`" = "AIX" ; then
	    system=AIX-`uname -v`.`uname -r`
	fi
	AC_MSG_RESULT($system)
    fi
fi

# Find where Data begins.  This is used by the storage allocation
# mechanism, in the PAGE macro.  This offset is subtracted from
# addresses, in calculating a page for an address in the heap.

AC_PROG_CC
# can only test for numbers -- CM
# if test "${GCC}" -eq "yes" ; then
if [[ "${GCC}" = "yes" ]] ; then
# Allog for environment variable overrides on compiler selection -- CM
GCC=$CC
else
GCC=""
fi
# subst GCC not only under 386-linux, but where available -- CM
AC_SUBST(GCC)
AC_CHECK_SIZEOF(long *,0)
AC_CHECK_HEADERS(endian.h,
	AC_MSG_CHECKING("endianness")
	AC_TRY_RUN([#include <endian.h> 
		int main() { return BYTE_ORDER == __LITTLE_ENDIAN ? 0 : 1;}],
	AC_DEFINE(LITTLE_END) AC_MSG_RESULT(little),
	AC_MSG_RESULT(big),AC_MSG_RESULT(big)))
AC_SUBST(LITTLE_END)

AC_MSG_CHECKING("finding DBEGIN")
AC_TRY_RUN([#include <stdio.h>
            #include <stdlib.h>
main()
{
  char *b = (void *) malloc(1000);
  FILE *fp = fopen("conftest1","w");
  fprintf(fp,"0x%lx",((unsigned long) b) & ~(unsigned long)0xffffff);
  fclose(fp);
  return 0;
}],dbegin=`cat conftest1`,dbegin=0,dbegin=0)
AC_DEFINE_UNQUOTED(DBEGIN,$dbegin \
/* where data begins */
)
AC_MSG_RESULT(got $dbegin)


AC_MSG_CHECKING("finding CSTACK_ADDRESS")
AC_TRY_RUN([#include <stdio.h>
main()
{
  char *b ;
  FILE *fp = fopen("conftest1","w");
  fprintf(fp,"%d",((int) &b));
  fclose(fp);
  return 0;
}],cstack_address=`cat conftest1`,cstack_address=0,cstack_address=0)
AC_DEFINE_UNQUOTED(CSTACK_ADDRESS,$cstack_address \
)
AC_MSG_RESULT(got $cstack_address)



AC_MSG_CHECKING("sizeof long long int")
AC_TRY_RUN([#include <stdio.h>
main()
{
  if (sizeof(long long int) == 2*sizeof(long)) return 0;
  return 1;
}
],[AC_DEFINE(HAVE_LONG_LONG)
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no),
AC_MSG_RESULT(no)
)

AC_SUBST(HAVE_LONG_LONG)

# readline
AC_ARG_ENABLE(readline,
	[--enable-readine    enables command line completion via the readline library ],,
	enable_readline="yes")

# ansi lisp
AC_ARG_ENABLE(ansi,[--enable-ansi builds a large gcl aiming for ansi compliance, 
		    --disable-ansi builds the smaller traditional CLtL1 image],,enable_ansi="no")

if test "$enable_ansi" = "yes" ; then
	FLISP=saved_ansi_gcl;
else
	FLISP=saved_gcl
fi

AC_SUBST(FLISP)

# pagewidth
AC_MSG_CHECKING(for pagewidth)
AC_TRY_RUN([#include <stdio.h>
            #include <unistd.h>
int main() {size_t i=getpagesize(),j; 
	    FILE *fp=fopen("conftest1","w");
	    for (j=0;i>>=1;j++);
	    fprintf(fp,"%u",j);
	    return 0;}],PAGEWIDTH=`cat conftest1`,PAGEWIDTH=0,PAGEWIDTH=0)
AC_MSG_RESULT($PAGEWIDTH)
AC_DEFINE_UNQUOTED(PAGEWIDTH,$PAGEWIDTH)
AC_SUBST(PAGEWIDTH)

# bfd probe

AC_ARG_ENABLE(bfd,
	[ --disable-bfd prevents gcl from using libbfd.a for fast object loading and symbol table lookups ] ,,
	enable_bfd="yes")


# Maximum number of pages

help="--enable-maxpage=XXXX will compile in a page table of size XXX (default ${default_maxpage})"
AC_ARG_ENABLE(maxpage,[ --enable-maxpage=XXXX will compile in a page table of size XXX (eg '--enable-maxpage=64*1024' would give 64K pages allowing 256 MB if pages are 4K each)] ,
[AC_DEFINE_UNQUOTED(MAXPAGE,$enable_maxpage)]
)

AC_ARG_ENABLE(vssize,[ --enable-vssize=XXXX will compile in a value stack of size XXX] ,
[AC_DEFINE_UNQUOTED(VSSIZE,$enable_vssize)]
)

AC_ARG_ENABLE(machine,[ --enable-machine=XXXX will force the use of one of the definitions in h/XXXX.defs] ,
[enable_machine=$enableval],[enable_machine=""])

AC_ARG_ENABLE(gmp,[ --enable-gmp=no will disable use of GMP gnu multiprecision arithmetic, (default is =yes)] ,
[use_gmp=$enableval],[use_gmp="yes"])

AC_ARG_ENABLE(notify,[ --enable-notify=no will disable the automatic notification of gcl maintainers of successful builds/problems] ,
[enable_notify=$enableval],[enable_notify="yes"])

AC_ARG_ENABLE(tkconfig,[ --enable-tkconfig=XXXX will force the use of a TK_CONFIG_PREFIX=XXXXX as place to look for tkConfig.sh and tclConfig.sh ] ,
[TK_CONFIG_PREFIX=$enableval],[TK_CONFIG_PREFIX="unknown"])


AC_ARG_ENABLE(tclconfig,[ --enable-tclconfig=XXXX will force the use of a TCL_CONFIG_PREFIX=XXXXX as place to look for tclConfig.sh and tclConfig.sh ] ,
[TCL_CONFIG_PREFIX=$enableval],[TCL_CONFIG_PREFIX="unknown"])


AC_ARG_ENABLE(infodir,[ --enable-infodir=XXXX will force the use of a INFO_DIR=XXXXX as place to look for info ] ,
[INFO_DIR=$enableval],[INFO_DIR="unknown"])




# Check if Posix compliant getcwd exists, if not we'll use getwd.
AC_CHECK_FUNCS(getcwd)
AC_CHECK_FUNCS(getwd)
AC_CHECK_FUNC(uname, , AC_DEFINE(NO_UNAME))
AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD))


AC_CHECK_HEADERS(sys/ioctl.h)


#--------------------------------------------------------------------
#	The code below deals with several issues related to gettimeofday:
#	1. Some systems don't provide a gettimeofday function at all
#	   (set NO_GETTOD if this is the case).
#	2. SGI systems don't use the BSD form of the gettimeofday function,
#	   but they have a BSDgettimeofday function that can be used instead.
#	3. See if gettimeofday is declared in the <sys/time.h> header file.
#	   if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
#	   declare it.
#--------------------------------------------------------------------

AC_CHECK_FUNC([BSDgettimeofday],
              [AC_DEFINE(HAVE_BSDGETTIMEOFDAY)],
	      [AC_CHECK_FUNC([gettimeofday], ,
	                     [AC_DEFINE([NO_GETTOD])])])

AC_MSG_CHECKING([for gettimeofday declaration])

AC_EGREP_HEADER([gettimeofday],
                [sys/time.h],
		[AC_MSG_RESULT([present])],
		[AC_MSG_RESULT([missing])
    		 AC_DEFINE(GETTOD_NOT_DECLARED)])


AC_CHECK_LIB(m,sin,LIBS="${LIBS} -lm",true)
AC_CHECK_LIB(mingwex,main,LIBS="${LIBS} -lmingwex",true)

# Should really find a way to check for prototypes, but this 
# basically works for now.  CM
#
AC_CHECK_HEADERS(math.h,AC_DEFINE(NEED_MATH_H))

#
# The second alternative is for solaris.  This needs to be
# a more comprehensive later, i.e. checking that the fpclass
# test makes sense.  CM
#
AC_MSG_CHECKING([for isnormal])
AC_TRY_RUN([#define _GNU_SOURCE
	    #include <math.h>
	    int main() {
		float f;
		return isnormal(f) || !isnormal(f) ? 0 : 1;
		}],
		AC_DEFINE(HAVE_ISNORMAL) AC_MSG_RESULT(yes),
		AC_MSG_CHECKING([for fpclass in ieeefp.h])
		AC_TRY_RUN([#include <ieeefp.h>
			    int main() {
				float f;
				return fpclass(f)>=FP_NZERO || fpclass(f)<FP_NZERO ? 0 : 1;
				}],
		AC_DEFINE(HAVE_IEEEFP) AC_MSG_RESULT(yes),
		HAVE_IEEEFP=0 AC_MSG_RESULT(no),HAVE_IEEEFP=0 AC_MSG_RESULT(no))
	,HAVE_ISNORMAL=0 AC_MSG_RESULT(no),HAVE_ISNORMAL=0 AC_MSG_RESULT(no))

AC_MSG_CHECKING([for isfinite])
AC_TRY_RUN([#define _GNU_SOURCE
	    #include <math.h>
	    int main() {
		float f;
		return isfinite(f) || !isfinite(f) ? 0 : 1;
		}],
		AC_DEFINE(HAVE_ISFINITE) AC_MSG_RESULT(yes),
		AC_MSG_CHECKING([for finite()])
		AC_TRY_RUN([#include <math.h>
			    int main() {
				float f;
				return finite(f) || !finite(f) ? 0 : 1;
				}],
		AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes),
		HAVE_FINITE=0 AC_MSG_RESULT(no),HAVE_FINITE=0 AC_MSG_RESULT(no))
	,HAVE_ISFINITE=0 AC_MSG_RESULT(no),HAVE_ISFINITE=0 AC_MSG_RESULT(no))



#--------------------------------------------------------------------
#	Check for the existence of the -lsocket and -lnsl libraries.
#	The order here is important, so that they end up in the right
#	order in the command line generated by make.  Here are some
#	special considerations:
#	1. Use "connect" and "accept" to check for -lsocket, and
#	   "gethostbyname" to check for -lnsl.
#	2. Use each function name only once:  can't redo a check because
#	   autoconf caches the results of the last check and won't redo it.
#	3. Use -lnsl and -lsocket only if they supply procedures that
#	   aren't already present in the normal libraries.  This is because
#	   IRIX 5.2 has libraries, but they aren't needed and they're
#	   bogus:  they goof up name resolution if used.
#	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
#	   To get around this problem, check for both libraries together
#	   if -lsocket doesn't work by itself.
#--------------------------------------------------------------------
AC_MSG_CHECKING([for sockets])
tcl_checkBoth=0
AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
if test "$tcl_checkSocket" = 1; then
    AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tcl_checkBoth=1)
fi


if test "$tcl_checkBoth" = 1; then
    tk_oldLibs=$LIBS
    LIBS="$LIBS -lsocket -lnsl"
    AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
fi
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))

if test "$enable_readline" = "yes" ; then
	AC_CHECK_LIB([readline],
		     [main],
		     [AC_DEFINE(HAVE_READLINE)
	              LIBS="$LIBS -lreadline -lncurses"
	              RL_OBJS=readline.o
	              RL_LIB=lsp/readline.o],,
		     [-lncurses])
fi

if test "$enable_bfd" = "yes" ; then
	AC_CHECK_HEADER(bfd.h,
		AC_CHECK_LIB(bfd,bfd_init,
			if $CC -v 2>&1 | fgrep ming > /dev/null ; then
				BFDLIB="-lbfd"
				IBRLIB="-liberty"
			else
				echo 'int main() {bfd_init();bfd_openr("/dev/null",0);return 0;}' >foo.c
				MP=`$GCC [[ -Wl,-M ]] -static -o foo foo.c -lbfd -liberty 2>&1 | tr '()' '\012\012' | $AWK '{print $NF}' | sort | uniq`
				rm -f foo.c foo
				BFDLIB=`echo $MP | tr ' ' '\012' | grep libbfd.a`
				IBRLIB=`echo $MP | tr ' ' '\012' | grep libiberty.a`
			fi
#
# Old binutils appear to need CONST defined to const
#
			AC_MSG_CHECKING(if need to define CONST for bfd)
			AC_TRY_RUN([#define IN_GCC
				    #include <bfd.h>
				    int main() { symbol_info t; return 0;}],
				AC_MSG_RESULT(no)
				AC_DEFINE(HAVE_LIBBFD)
				LIBS="$LIBS  $BFDLIB $IBRLIB",
				AC_TRY_RUN([#define IN_GCC
					    #include <bfd.h>
                                            #define CONST const
					    int main() {symbol_info t; return 0;}],
					AC_MSG_RESULT(yes) 
					AC_DEFINE(NEED_CONST)
					AC_DEFINE(HAVE_LIBBFD)
					LIBS="$LIBS  $BFDLIB $IBRLIB",
					AC_MSG_RESULT(cannot use bfd),AC_MSG_RESULT(cannot use bfd)),
				AC_MSG_RESULT(cannot use bfd))
					
			,,-liberty))
fi

AC_SUBST(LIBS)
AC_SUBST(RL_OBJS)
AC_SUBST(RL_LIB)

AC_MSG_CHECKING(For network code for nsocket.c)
AC_TRY_LINK([
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>

/************* for the sockets ******************/ 
#include <sys/socket.h>		/* struct sockaddr, SOCK_STREAM, ... */
#ifndef NO_UNAME
#   include <sys/utsname.h>	/* uname system call. */
#endif
#include <netinet/in.h>		/* struct in_addr, struct sockaddr_in */
#include <arpa/inet.h>		/* inet_ntoa() */
#include <netdb.h>		/* gethostbyname() */
],[ connect(0,(struct sockaddr *)0,0);
    gethostbyname("jil");
    socket(AF_INET, SOCK_STREAM, 0);
	],
[AC_DEFINE(HAVE_NSOCKET)
 AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))


AC_MSG_CHECKING(check for listen using fcntl)
AC_TRY_COMPILE([#include <stdio.h>
#include <fcntl.h>
],
[FILE *fp=fopen("configure.in","r");
  int orig;
  orig = fcntl(fileno(fp), F_GETFL);
  if (! (orig & O_NONBLOCK )) return 0;
],
[AC_DEFINE(LISTEN_USE_FCNTL)
 AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))




AC_CHECK_FUNC(profil, ,[AC_DEFINE(NO_PROFILE)])
AC_SUBST(NO_PROFILE)
AC_CHECK_FUNC(setenv,[AC_DEFINE(HAVE_SETENV)],no_setenv=1 )
AC_SUBST(HAVE_SETENV)
if test "$no_setenv" = "1" ; then
AC_CHECK_FUNC(putenv,[AC_DEFINE(HAVE_PUTENV)],)
AC_SUBST(HAVE_PUTENV)
fi

AC_CHECK_FUNC(_cleanup, [AC_DEFINE(USE_CLEANUP)],)
AC_SUBST(USE_CLEANUP)
gcl_ok=no

AC_HEADER_EGREP(LITTLE_ENDIAN, ctype.h, gcl_ok=yes, gcl_ok=noo)
if test $gcl_ok = yes ; then
AC_DEFINE(ENDIAN_ALREADY_DEFINED)
fi

AC_SUBST(ENDIAN_ALREADY_DEFINED)




# if test "x$enable_machine" = "x" ; then
AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])

case $system in
       OSF*)
	AC_DEFINE(USE_FIONBIO)
	AC_MSG_RESULT(FIONBIO)
	;;
    SunOS-4*)
	AC_DEFINE(USE_FIONBIO)
	AC_MSG_RESULT(FIONBIO)
	;;
    ULTRIX-4.*)
	AC_DEFINE(USE_FIONBIO)
	AC_MSG_RESULT(FIONBIO)
	;;
    *)
	AC_MSG_RESULT(O_NONBLOCK)
	;;
esac


AC_CANONICAL_HOST
canonical=$host
## host=CPU-COMPANY-SYSTEM
AC_MSG_RESULT(host=$host)

use=unknown

case $canonical in
     older)
     use=386-bsd;;

     *86-*-linux*)
     use=386-linux; ln -snf linux.defs h/$use.defs;;

     m68k-*-linux*)
     use=m68k-linux; ln -snf linux.defs h/$use.defs;;

     alpha*-*-linux*)
     use=alpha-linux; ln -snf linux.defs h/$use.defs;;

     mips-*-linux*)
     use=mips-linux; ln -snf linux.defs h/$use.defs;;

     mipsel-*-linux*)
     use=mipsel-linux; ln -snf linux.defs h/$use.defs;;

     sparc*-*-linux*)
     use=sparc-linux; ln -snf linux.defs h/$use.defs;;

     arm*-*-linux*)
     use=arm-linux; ln -snf linux.defs h/$use.defs;;

     s390-*-linux*)
     use=s390-linux; ln -snf linux.defs h/$use.defs;;

     ia64-*-linux*)
     use=ia64-linux; ln -snf linux.defs h/$use.defs;;

     hppa-*-linux*)
     use=hppa-linux; ln -snf linux.defs h/$use.defs;;

     powerpc-*-linux*)
     use=powerpc-linux; ln -snf linux.defs h/$use.defs;;

     alpha-dec-osf)
     use=alpha-osf1;;

     mips-dec-ultrix)
     use=dec3100;;

     old)
     use=dos-go32;;

     *86*-freebsd)
     use=FreeBSD;;

     hp3*-*hpux*)
     use=hp300;;

     hp3*-*-*bsd*)
     use=hp300-bsd;;

     hppa*-*hpux*)
     use=hp800;;

     mips-sgi-irix)
       case $system in
           IRIX5*)
            use=irix5;;
           IRIX6*)
            use=irix6;;
           IRIX3*)
            use=sgi4d;;
       esac ;;
 

     m68k-apple-aux*)
     use=mac2;;

     old)
     use=mp386;;

     *86-ncr-sysv4)
     use=ncr;;

     *[3-9]86-*netbsd*)
     use=NetBSD;;

     old)
     use=NeXT;;

     old)
     use=NeXT30-m68k;;

     *86-*nextstep*)
     use=NeXT32-i386;;

     *m68*-*nextstep*)
     use=NeXT32-m68k;;

     *rs6000-*-aix4*)
     use=rios;;

     *rs6000-*-aix3*)
     use=rios-aix3;;

     old)
     use=rt_aix;;

     old)
     use=sgi;;

     sparc-sun-solaris*)
     use=solaris;;

     i?86-pc-solaris*)
     use=solaris-i386;;

     sparc-*-linux*)
     use=sparc-linux;;

     old)
     use=sun2r3;;

     old)
     use=sun3;;

     m68*-sunos*)
     use=sun3-os4;;

     old)
     use=sun386i;;

     sparc*sunos*)
     use=sun4;;

     *86-sequent-dynix)
     use=symmetry;;

     u370*aix)
     use=u370_aix;;

     old)
     use=vax;;

     i*cygwin*)
	if $CC -v 2>&1 | fgrep ming > /dev/null ;
            then use=mingw
          else  use=gnuwin95
        fi;;
  

esac
AC_MSG_CHECKING(check for SV_ONSTACK)
AC_TRY_COMPILE([#include <signal.h>
int joe=SV_ONSTACK;
],
[],
[AC_DEFINE(HAVE_SV_ONSTACK)
 AC_SUBST(HAVE_SV_ONSTACK)
 AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))


AC_MSG_CHECKING(check for SIGSYS)
AC_TRY_COMPILE([#include <signal.h>
int joe=SIGSYS;
],
[],
[AC_DEFINE(HAVE_SIGSYS)
 AC_SUBST(HAVE_SIGSYS)
 AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))


AC_MSG_CHECKING(check for SIGEMT)
AC_TRY_COMPILE([#include <signal.h>
int joe=SIGEMT;
],
[],
[AC_DEFINE(HAVE_SIGEMT)
 AC_SUBST(HAVE_SIGEMT)
 AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))




#if test $use = "386-linux" ; then
	AC_CHECK_HEADERS(asm/sigcontext.h)
	AC_CHECK_HEADERS(asm/signal.h)
        AC_TRY_COMPILE([#include <signal.h>
                        long code;  
       ],
       [
        void *p = ((void *)(((struct sigcontext_struct *)(&code))));
       ],
       [
        sigcontext_struct_works=1;
        AC_DEFINE(SIGNAL_H_HAS_SIGCONTEXT)
	AC_MSG_RESULT("sigcontext in signal.h")
       ],
        
	[sigcontext_struct_works=0;
         AC_MSG_RESULT("sigcontext NOT in signal.h")]
       )
       if test "$sigcontext_struct_works" = 0 ; then
       AC_TRY_COMPILE([#include <signal.h>
             #ifdef HAVE_ASM_SIGCONTEXT_H     
             #include <asm/sigcontext.h>
             #endif
             #ifdef HAVE_ASM_SIGNAL_H          
             #include <asm/signal.h>
             #endif
             long code;
          ],
        [ 
        void *p = ((void *)(((struct sigcontext *)(&code))));
        ],
        [
        sigcontext_works=1 ;
        AC_DEFINE(HAVE_SIGCONTEXT)
	AC_MSG_RESULT("use struct sigcontext")
        ],
        [
        sigcontext_works=0 ; 
     ])


       fi
#	echo 'foo() {}' > conftest1.c
#	$CC -S conftest1.c
#	use_underscore=0	
#	if fgrep _foo conftest1.s ; then use_underscore=1 ; fi
#	if test $use_underscore = 0 ; then
#            MPI_FILE=mpi-386_no_under.o
#          else
#	     MPI_FILE=mpi-386d.o
#        fi
#	AC_SUBST(MPI_FILE)
#       GCC=$CC
#        if test -x  /usr/bin/i386-glibc20-linux-gcc ; then
#          GCC=/usr/bin/i386-glibc20-linux-gcc
#       fi
#	AC_SUBST(GCC)

#fi

AC_PATH_PROG(EMACS,emacs)


# check for where the emacs site lisp directory is.
rm -f conftest.el
cat >> conftest.el <<EOF
(let ((ans ".") (tem load-path) cur)
 (while (setq cur (car tem))
   (setq tem (cdr tem))
   (cond ((and (string-match "site-lisp/?$" cur) (file-directory-p cur))
          (setq ans cur)
           (if (string-match "-[0-9.]+$" cur) nil
               (setq tem nil)))))
  (message ans))
EOF

AC_MSG_CHECKING([emacs site lisp directory])
#EMACS_SITE_LISP=unknown
if [[ "$EMACS" != "" ]] ; then
	EMACS_SITE_LISP=`$EMACS -q -batch --no-site-file -l conftest.el 2>&1 | sed -e /Loading/d | sed -e /load/d `
else
	EMACS_SITE_LISP=""
fi
AC_MSG_RESULT($EMACS_SITE_LISP)
AC_SUBST(EMACS_SITE_LISP)

# check for where the emacs site lisp default.el is
rm -f conftest.el
cat >> conftest.el <<EOF
(let ((ans "./default.el") file (tem load-path))
 (while tem
   (cond ((file-exists-p
           (setq file (expand-file-name "/default.el" (car tem))))
	  (setq tem nil) (setq ans file)))
   (setq tem (cdr tem)))
  (message ans))
EOF

AC_MSG_CHECKING([emacs default.el])
if [[ "$EMACS" != "" ]] ; then
	EMACS_DEFAULT_EL=`$EMACS -q -batch --no-site-file -l conftest.el 2>&1 | sed -e /Loading/d | sed -e /load/d `
else
	EMACS_DEFAULT_EL=""
fi
if  test -f "${EMACS_DEFAULT_EL}"  ; then true;else
  if test -d "$EMACS_SITE_LISP" ; then
     EMACS_DEFAULT_EL=${EMACS_SITE_LISP}/default.el
  fi
fi
AC_MSG_RESULT($EMACS_DEFAULT_EL)
AC_SUBST(EMACS_DEFAULT_EL)



# check for where the emacs site lisp info/dir is
rm -f conftest.el
cat >> conftest.el <<EOF
(let ((ans "") file (tem Info-default-directory-list))
 (while tem
   (cond ((file-exists-p (setq file (expand-file-name "dir" (car tem))))
          (setq ans (file-name-as-directory (car tem)))		
	  (setq tem nil) ))
   (setq tem (cdr tem)))
  (message ans))
EOF

AC_MSG_CHECKING([emacs info/dir])
if [[ "$EMACS" != "" ]] ; then
	INFO_DIR=`$EMACS -q -batch --no-site-file -l conftest.el 2>&1 | sed -e /Loading/d | sed -e /load/d `
fi
if  test -f "${INFO_DIR}dir"  ; then true;else
if test -f /usr/info/dir ; then
  INFO_DIR=/usr/info/
else true;
fi
fi
AC_MSG_RESULT($INFO_DIR)
AC_SUBST(INFO_DIR)

AC_MSG_CHECKING([for tcl/tk])


if test -d "${TCL_CONFIG_PREFIX}"  ; then true ; else
rm -f conftest.tcl
cat >> conftest.tcl <<EOF
[
set dir [set tcl_library]
if { [file exists [file join [set dir] tclConfig.sh]] } {
      puts  [set dir]
      exit	
  }
set dir [file dirname [set tcl_library]]
if { [file exists [file join [set dir] tclConfig.sh]] } {
      puts  [set dir]
  }
]
EOF
#cp conftest.tcl foo.tcl

AC_CHECK_PROG(TCLSH,tclsh,tclsh,${TCLSH})
#AC_CHECK_PROG(TCLSH,tclsh8.0,tclsh8.0,${TCLSH})

if test "${TCLSH}" = "" ; then true ; else
TCL_CONFIG_PREFIX=`${TCLSH} < conftest.tcl`
fi
fi
if test -f ${TCL_CONFIG_PREFIX}/tclConfig.sh  ; then . ${TCL_CONFIG_PREFIX}/tclConfig.sh ; fi


if test -d "${TK_CONFIG_PREFIX}"  ; then true ; else
if test -f ${TCL_CONFIG_PREFIX}/tkConfig.sh ; then
TK_CONFIG_PREFIX=${TCL_CONFIG_PREFIX}
else
#rm -f conftest.tcl
#cat >> conftest.tcl <<EOF
#[
#set dir [set tk_library]
#if { [file exists [file join [set dir] tkConfig.sh]] } {
#      puts  [set dir]
#      exit
#  }
#set dir [file dirname [set tk_library]]
#if { [file exists [file join [set dir] tkConfig.sh]] } {
#      puts  [set dir]
#  }
#exit 0
#]
#EOF
#cp conftest.tcl foo.tcl
#AC_CHECK_PROG(TKSH,wish,wish,${TKSH})
##AC_CHECK_PROG(TKSH,wish8.0,wish8.0,${TKSH})
#if test "${TKSH}" = "" ; then true ; else
#TK_CONFIG_PREFIX=`${TKSH} < conftest.tcl`
#fi

if test "${TCLSH}" = "" ; then true ; else
	TK_CONFIG_PREFIX=`echo tcl_findLibrary \"tk\" \"${TCL_VERSION}\" \"\" \"tkConfig.sh\" \"TK_LIBRARY\" tk_library | ${TCLSH} 2>&1 | ${AWK} '/"source / {if (i++) next;sub("/[[^/]]*$","",$2);print $2}'`
fi

fi
fi
#AC_MSG_CHECKING(TK_CONFIG_PREFIX=${TK_CONFIG_PREFIX})
if test -f ${TK_CONFIG_PREFIX}/tkConfig.sh  ; then . ${TK_CONFIG_PREFIX}/tkConfig.sh ; fi

if test -d ${TK_CONFIG_PREFIX}/tk${TK_VERSION} ; then
  TK_LIBRARY=${TK_CONFIG_PREFIX}/tk${TK_VERSION}
  else
  if test -d ${TK_CONFIG_PREFIX}/../tk${TK_VERSION} ; then
    TK_LIBRARY=${TK_CONFIG_PREFIX}/../tk${TK_VERSION}
  fi
fi
if test -d ${TK_CONFIG_PREFIX}/tcl${TCL_VERSION} ; then
  TCL_LIBRARY=${TK_CONFIG_PREFIX}/tcl${TCL_VERSION}
  else
  if test -d ${TK_CONFIG_PREFIX}/../tcl${TCL_VERSION} ; then
    TCL_LIBRARY=${TK_CONFIG_PREFIX}/../tcl${TCL_VERSION}
  fi
fi
if test -f ${TK_CONFIG_PREFIX}/../include/tk.h ; then
  TK_INCLUDE=-I${TK_CONFIG_PREFIX}/../include
  else
  if test -f /usr/include/tcl${TCL_VERSION}/tk.h ; then
    TK_INCLUDE=-I/usr/include/tcl${TCL_VERSION}
  fi	
fi
if test -f ${TCL_CONFIG_PREFIX}/../include/tcl.h ; then
  TCL_INCLUDE=-I${TCL_CONFIG_PREFIX}/../include
  else
  if test -f /usr/include/tcl${TCL_VERSION}/tcl.h ; then
    TCL_INCLUDE=-I/usr/include/tcl${TCL_VERSION}
  fi
fi
AC_CHECK_LIB(lieee,main,have_ieee=1,have_ieee=0)
if test "$have_ieee" = "0" ; then
 TCL_LIBS=`echo ${TCL_LIBS} | sed -e "s:-lieee::g" `
fi
AC_CHECK_LIB(dl,dlopen,have_dl=1,have_dl=0)
if test "$have_dl" = "0" ; then
 TCL_LIBS=`echo ${TCL_LIBS} | sed -e "s:-ldl::g"`
fi

AC_SUBST(TK_CONFIG_PREFIX)
AC_SUBST(TK_LIBRARY)
AC_SUBST(TCL_LIBRARY)
AC_SUBST(TK_XINCLUDES)
AC_SUBST(TK_INCLUDE)
AC_SUBST(TCL_INCLUDE)
AC_SUBST(TK_LIB_SPEC)
AC_SUBST(TK_BUILD_LIB_SPEC)
AC_SUBST(TK_XLIBSW)
AC_SUBST(TK_XINCLUDES)
AC_SUBST(TCL_LIB_SPEC)
AC_SUBST(TCL_DL_LIBS)
AC_SUBST(TCL_LIBS)






if test -d "${TK_CONFIG_PREFIX}" ; then
AC_MSG_RESULT([using TK_VERSION=${TK_VERSION} in ${TK_CONFIG_PREFIX}])
else
AC_MSG_RESULT([not found])
fi

NOTIFY=$enable_notify
AC_SUBST(NOTIFY)





echo enable_machine=$enable_machine
if test "x$enable_machine" != "x" ; then
  use=$enable_machine
fi

## finally warn if we did not find a recognized machine.s
##
#if test "$use" = "unknown" ; then
#types=`echo h/*.defs` | sed -e "s:h/::g" -e "s:\.defs:g"`
#echo got canonical=$canonical, but was not recognized. 
#echo Unable to guess type to use.  Try one of 
#exit(1)
#fi

AC_MSG_RESULT(use=$use)	

      


# for sgbc the mprotect capabilities.

# the time handling for unixtime, add timezone

AC_MSG_CHECKING([alloca])
AC_TRY_RUN([int main() { exit(alloca(500) != NULL ? 0 : 1);}],
  ,gcl_ok=yes, gcl_ok=no,gcl_ok=no)
if test $gcl_ok = yes ; then
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_ALLOCA)
else
  AC_TRY_RUN([#include <alloca.h>
  int main() { exit(alloca(500) != NULL ? 0 : 1)}],
  ,gcl_ok=yes, gcl_ok=no,gcl_ok=no)
 if test $gcl_ok = yes ; then
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_ALLOCA)
    AC_DEFINE(NEED_ALLOCA_H)
 fi
fi
if test $gcl_ok = no ; then     AC_MSG_RESULT(no) ; fi










# alloca

# dlopen etc
# idea make it so you do something dlopen(libX.so,RTLD_GLOBAL)
# then dlload("foo.o") a lisp file can refer to things in libX.so
# 

# what machine this is, and include then a machine specific hdr.
# and machine specific defs.

# check bzero,

# check getcwd, getwd etc..




# check socket stuff..

# getrlimit

# fionread or block

rm -f makedefsafter

MP_INLCUDE=""
if test $use_gmp = yes ; then
 AC_MSG_CHECKING([use_gmp=yes, doing configure in gmp directory])
 case "${canonical}" in
#   i[[5-9]]86* | pentium* | k6* | athlon*)
#      (cd gmp ; ./configure --target=i486) ;;
   *)
      (cd gmp ; ./configure) ;;
 esac
 [[ "`ls -1 gmp/mpn/add_n.* 2>/dev/null`" != "" ]] || cp gmp/mpn/generic/*.c gmp/mpn/
 AC_MSG_CHECKING("for size of gmp limbs")
 AC_TRY_RUN([#include <stdio.h>
	#include "h/gmp.h"
	
	int main() {
	FILE *fp=fopen("conftest1","w");
	fprintf(fp,"%u",sizeof(mp_limb_t));
	fclose(fp);
	return 0;
}],mpsize=`cat conftest1`,mpsize=0,mpsize=0)
 if test "$mpsize" = "0" ; then
	echo "Cannot determine mpsize"
	exit 1
 fi
 AC_DEFINE_UNQUOTED(MP_LIMB_BYTES,$mpsize)
 AC_MSG_RESULT($mpsize) 
 GMP=1
 AC_DEFINE(GMP)
 AC_SUBST(GMP)
 MP_INCLUDE=h/gmp.h
 echo > makedefsafter
 echo 'MPFILES=${GMP_DIR}libgmp.a' >> makedefsafter
 echo >> makedefsafter
fi
AC_SUBST(MP_INCLUDE)
 
# redhat/cygnus released for some reason a buggy version of gcc,
# which no one else released.   Catch that here.
AC_MSG_CHECKING([Checking for buggy gcc version from redhat])
if  2>&1 $CC -v | fgrep "gcc version 2.96" > /dev/null 
   then 
        BROKEN_O4_OPT=1
        AC_DEFINE(BROKEN_O4_OPT)
        AC_SUBST(BROKEN_O4_OPT)
        echo ODIR_DEBUG=-O >> makedefsafter
	echo >> makedefsafter
	AC_MSG_RESULT([yes .. turning off -O4])
   else
	AC_MSG_RESULT([no])
fi 


if test -f h/$use.defs  ; then

  AC_SUBST(use)
  AC_OUTPUT(makedefc)
  echo makedefc
  cat makedefc

  echo    add-defs1 $use
  CC=$CC ./add-defs1 $use

else
  echo "Unable to guess machine type"
  echo use configure --enable-machine=XXX,  for XXX such that h/XXX.defs exists, ie in h/*.defs
fi