File: configure.in

package info (click to toggle)
gclcvs 2.7.0-36
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 55,836 kB
  • ctags: 98,717
  • sloc: ansic: 526,054; lisp: 203,944; asm: 49,617; sh: 15,664; cpp: 8,131; makefile: 4,319; tcl: 3,181; perl: 2,355; sed: 469; yacc: 152; lex: 79; awk: 30; fortran: 24; csh: 23
file content (1838 lines) | stat: -rw-r--r-- 47,966 bytes parent folder | download
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
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
AC_INIT()
AC_CONFIG_HEADER(h/gclincl.h)

VERSION=`cat majvers`.`cat minvers`
AC_SUBST(VERSION)

# some parts of this configure script are taken from the tcl configure.in

#
# Arguments
#

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(holepage,[ --enable-holepage=XXXX will compile in a XXX-sized hole between the heap and relocatable memory area (eg '--enable-holepage=64*1024' would give 64K pages allowing 256 MB if pages are 4K each)] ,
[AC_DEFINE_UNQUOTED(HOLEPAGE,$enable_holepage)])

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(bdssize,[ --enable-bdssize=XXXX will compile in a binding stack of size XXX] ,
[AC_DEFINE_UNQUOTED(BDSSIZE,$enable_bdssize)])

AC_ARG_ENABLE(ihssize,[ --enable-ihssize=XXXX will compile in a invocation history stack of size XXX] ,
[AC_DEFINE_UNQUOTED(IHSSIZE,$enable_ihssize)])

AC_ARG_ENABLE(frssize,[ --enable-frssize=XXXX will compile in a frame stack of size XXX] ,
[AC_DEFINE_UNQUOTED(FRSSIZE,$enable_frssize)])

AC_ARG_ENABLE(cssize,[ --enable-cssize=XXXX produces executables with a C stack of size XXX] ,
[AC_DEFINE_UNQUOTED(CSSIZE,$enable_cssize)])

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"])

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"])
INFO_DIR=`eval echo $INFO_DIR/`

AC_ARG_ENABLE(emacsdir,[ --enable-emacsdir=XXXX will manually specify the location for elisp files ] ,
[EMACS_SITE_LISP=$enableval],[EMACS_SITE_LISP="unknown"])
EMACS_SITE_LISP=`eval echo $EMACS_SITE_LISP`

AC_ARG_ENABLE(common-binary,[ --enable-common-binary=yes forces use of lowest common denominator instruction sets, (default is =yes)] ,
[use_common_binary=$enableval],[use_common_binary="yes"])

AC_ARG_ENABLE(japi,[ --enable-japi=yes will compile in support for the JAPI graphical interface if present on your system],
[try_japi=$enableval],[try_japi="no"])

AC_ARG_ENABLE(xdr,[ --enable-xdr=yes will compile in support for XDR],
[try_xdr=$enableval],[try_xdr="no"])

#
# Host information 
#


AC_CANONICAL_HOST
canonical=$host
my_host_kernel=`echo $host_os | awk '{j=split($1,A,"-");print A[[1]]}'`
my_host_system=`echo $host_os | awk '{j=split($1,A,"-");if (j>=2) print A[[2]]}'`
AC_DEFINE_UNQUOTED(HOST_CPU,"`echo $host_cpu | awk '{print toupper($0)}'`")
AC_DEFINE_UNQUOTED(HOST_KERNEL,"`echo $my_host_kernel | awk '{print toupper($0)}'`")
if test "$my_host_system" != "" ; then 
	AC_DEFINE_UNQUOTED(HOST_SYSTEM,"`echo $my_host_system | awk '{print toupper($0)}'`")
fi
AC_MSG_RESULT(host=$host)

PROCESSOR_FLAGS=${PROCESSOR_FLAGS:-""}
LD_STACK_FLAGS=""

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

     *x86_64*linux*)
	use=amd64-linux;;

     *86*linux*)
	use=386-linux;;

# m6800 not working with gcc-3.2
     m68k*linux*)
       if test "$use_common_binary" = "yes"; then
         host=m68020-unknown-linux-gnu
         echo "The host is canonicalised to $host"
       fi
     	use=m68k-linux;;

     alpha*linux*)
     	use=alpha-linux;;

     mips*linux*)
     	use=mips-linux;;

     mipsel*linux*)
     	use=mipsel-linux;;

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

     arm*linux*)
     	use=arm-linux;;

     s390*linux*)
     	use=s390-linux;;

     ia64*linux*)
     	use=ia64-linux;;

     hppa*linux*)
     	use=hppa-linux;;

     powerpc*linux*)
     	use=powerpc-linux;;

     powerpc-*-darwin*)
     	use=powerpc-macosx;;
     
     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;;

     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*mingw*)
       if test "$use_common_binary" = "yes"; then
         host=i386-pc-mingw32
         PROCESSOR_FLAGS="-march=i686 -mfpmath=387"
         echo "The host is canonicalised to $host"
       fi
       # If we have set the C stack size on the command line then send them to
       # the linker.  Set a default otherwise of 2 Mbytes (Windows default).
       if test "$enable_cssize" == "" ; then
         enable_cssize=1024*1024*2
       else
	 LD_STACK_FLAGS="-Wl,--stack=$CSSIZE"
         echo "Linker stack size flags added: $LD_STACK_FLAGS"
       fi
       echo "Executable C stack size will be $CSSIZE"
       AC_DEFINE_UNQUOTED(CSSIZE,$enable_cssize)

       use=mingw;;

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

     *openbsd*)
	# 'ld -Z' means disable W^X
	TLDFLAGS="$TLDFLAGS -Z"
	use=FreeBSD;;
  
esac

AC_SUBST(PROCESSOR_FLAGS)

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

def_dlopen="no"
def_statsysbfd="yes"
def_custreloc="no"
def_locbfd="no"
def_pic="no";
def_static="no";
def_static="debug";
case $use in 
     *linux)
	ln -snf linux.defs h/$use.defs;
	case $use in
		alpha*)
			def_dlopen="yes" ; def_statsysbfd="no" ;;
		mips*)
			def_dlopen="yes" ; def_statsysbfd="no" ;;
# def_static -- Function descriptors are currently realized at runtime in a non-reproducible fashion
# on these architectures -- CM			
		ia64*)
			def_dlopen="yes" ; def_statsysbfd="no" ; def_static="no" ;;
		hppa*)
			def_dlopen="yes" ; def_statsysbfd="no" ; def_pic="yes" ; def_debug="yes" ;;
	esac;;
    *mingw*)
	def_statsysbfd="no" ; def_custreloc="yes" ;;
    powerpc-macosx)
	def_statsysbfd="no" ; def_locbfd="yes" ;;
esac

AC_ARG_ENABLE(dlopen,
	[ --enable-dlopen uses dlopen for loading objects, which can then not be retained  in saved images ]
	,,enable_dlopen="$def_dlopen")
AC_ARG_ENABLE(statsysbfd,
	[ --enable-statsysbfd uses a static sytem bfd library for loading and relocationing object files ]
	,,enable_statsysbfd="$def_statsysbfd")
AC_ARG_ENABLE(dynsysbfd,
	[ --enable-dynsysbfd uses a dynamic shared sytem bfd library for loading and relocationing object files ]
	,,enable_dynsysbfd="no")
AC_ARG_ENABLE(locbfd,
	[ --enable-locbfd uses a static bfd library built from this source tree for loading and relocationing object files ]
	,,enable_locbfd="$def_locbfd")
AC_ARG_ENABLE(custreloc,
	[ --enable-custreloc uses custom gcl code if available for loading  and relocationing object files ]
	,,enable_custreloc="$def_custreloc")
AC_ARG_ENABLE(debug,
	[ --enable-debug builds gcl with -g in CFLAGS to enable running under gdb ]
	,,enable_debug="$def_debug")
AC_ARG_ENABLE(gprof,
	[ --enable-gprof builds gcl with -pg in CFLAGS to enable profiling with gprof ]
	,,enable_gprof="no")
AC_ARG_ENABLE(static,[ --enable-static will link your GCL against static as opposed to shared system libraries ] ,
        [enable_static=$enableval],[enable_static="$def_static"])
AC_ARG_ENABLE(pic,
	[ --enable-pic builds gcl with -fPIC in CFLAGS ]
	,,enable_pic="$def_pic")

AC_ARG_ENABLE(dynsysgmp,
	[ --enable-dynsysgmp will link against the system libgmp3 overriding certain functions with patched versions from the local source ]
	,,enable_dynsysgmp="yes")

load_opt="0"
if test "$enable_dlopen" = "yes" ; then
   load_opt=1
fi
if test "$enable_statsysbfd" = "yes" ; then
   case $load_opt in
   0) load_opt=1;;
   1) load_opt=2;;
   esac
fi
if test "$enable_dynsysbfd" = "yes" ; then
   case $load_opt in
   0) load_opt=1;;
   1) load_opt=2;;
   2) load_opt=3;;
   esac
fi
if test "$enable_locbfd" = "yes" ; then
   case $load_opt in
   0) load_opt=1;;
   1) load_opt=2;;
   2) load_opt=3;;
   3) load_opt=4;;
   esac
fi
if test "$enable_custreloc" = "yes" ; then
   case $load_opt in
   0) load_opt=1;;
   1) load_opt=2;;
   2) load_opt=3;;
   3) load_opt=4;;
   4) load_opt=5;;
   esac
fi

if test "$load_opt" != "1" ; then
	echo "Exactly one loader option must be chosen: dlopen=$enable_dlopen statsysbfd=$enable_statsysbfd dynsysbfd=$enable_dynsysbfd locbfd=$enable_locbfd custreloc=$enable_custreloc"
	exit 1
fi

TLIBS=""
if test "$enable_static" = "yes" ; then
   TLIBS="-static $TLIBS";
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)	


#
# System programs
#

# We set the default CFLAGS below, and don't want the autoconf default
# CM 20040106
if test "$CFLAGS" = "" ; then
	CFLAGS=" "
fi
if test "$LDFLAGS" = "" ; then
	LDFLAGS=" "
fi

AC_PROG_CC
AC_PROG_CPP
AC_SUBST(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


TCFLAGS="-Wall -DVOL=volatile -fsigned-char"
if test "$GCC" = "yes" ; then
	TCFLAGS="$TCFLAGS -pipe"
	case $use in
	     *mingw*)
	        echo "WARNING: Remove -fno-zero-initialized-in-bss from makedefs if gcc less than 3.3.1."
	        echo "         It is ptherwise needed for the Unexec stuff to work."
		TCFLAGS="$TCFLAGS -fno-zero-initialized-in-bss -mms-bitfields";;
        esac
fi
#if test -f /proc/sys/kernel/exec-shield ; then
#	exec_stat=`cat /proc/sys/kernel/exec-shield`
#	if test "$exec_stat" != "0" ; then
#		# CFLAGS here to hopefully cover the DBEGIN routine below
#		CFLAGS="$CFLAGS -Wa,--execstack"
#	fi
#fi

TO3FLAGS=""
TO2FLAGS=""

#TFPFLAG="-fomit-frame-pointer"
# FIXME -- remove when mingw compiler issues are fixed
case "$use" in
  *mingw*)
	TFPFLAG="";;
  *)
	TFPFLAG="-fomit-frame-pointer";;
esac

AC_CHECK_PROGS(AWK,gawk nawk awk,"")

if test "$enable_gprof" = "yes" ; then
	TCFLAGS="$TCFLAGS -pg"
	TLIBS="$TLIBS -pg"
	TFPFLAG=""
	AC_DEFINE(GCL_GPROF)
	AC_MSG_CHECKING(for text start)
	echo 'int main () {return(0);}' >foo.c
	$CC foo.c -o foo
	GCL_GPROF_START=`nm foo | $AWK  '/  *T  *_[_]*start$/ {print $NF}'`
	rm -f foo.c foo
	AC_MSG_RESULT($GCL_GPROF_START)
	AC_DEFINE_UNQUOTED(GCL_GPROF_START,$GCL_GPROF_START)
	case "$use" in	
	  arm*)	
	#FIXME report and remove this when done
		AC_MSG_RESULT(Reducing optimization on profiling arm build to workaround gcc bug)
		enable_debug=yes;;
	esac
fi

if test "$enable_debug" = "yes" ; then
	TCFLAGS="$TCFLAGS -g"
	# for subconfigurations
	CFLAGS="$CFLAGS -g"
else
# FIXME -- remove when mingw compiler issues are fixed
	case "$use" in
	  *mingw*)
		TO3FLAGS="-O3 $TFPFLAG";;
	  *)
		TO3FLAGS="-O3 $TFPFLAG";;
	esac
#	TO3FLAGS="-O3 $TFPFLAG"
	TO2FLAGS="-O"
fi

# gcc on ppc cannot compile our new_init.c with full opts --CM
TONIFLAGS=""
case $use in 
     *linux)
	case $use in
#		amd64*) # stack-boundary option does not work
#			TCFLAGS="$TCFLAGS -m64 -mpreferred-stack-boundary=8";;  
		alpha*)
			TCFLAGS="$TCFLAGS -mieee";;
#		m68k*)
#			TCFLAGS="$TCFLAGS -ffloat-store";;
		hppa*)
			TCFLAGS="$TCFLAGS -ffunction-sections"
			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O $TFPFLAG" ; fi
			if test "$enable_debug" != "yes" ; then TO2FLAGS="-O" ; fi
			;;
		arm*)
			TCFLAGS="$TCFLAGS -mlong-calls";;	
		powerpc*) 
			if $CC -v 2>&1 | grep -q "gcc version 3.2" ; then
			   echo Reducing optimization for buggy gcc-3.2
			   if test "$enable_debug" != "yes" ; then TONIFLAGS="-O $TFPFLAG" ; fi
			fi;
			echo Probing for longcall
			if ! $CC -v 2>&1 | $AWK '/^gcc version / {split($3,A,".");if (A[[1]]+0>=3 && A[[2]]+0>=3) exit 1;}'; then
			   echo Enabling longcall on gcc 3.3 or later
			   TCFLAGS="$TCFLAGS -mlongcall"
			   echo Reducing optimization for buggy gcc 3.3 or later
			   if test "$enable_debug" != "yes" ; then TONIFLAGS="-O $TFPFLAG" ; fi
			fi;;
	esac;;
esac
if test "$enable_pic" = "yes" ; then
	TCFLAGS="$TCFLAGS -fPIC"
fi


# 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(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

# sysconf

AC_CHECK_HEADER(unistd.h,
	AC_CHECK_LIB(c,sysconf,
		AC_MSG_CHECKING("for _SC_CLK_TCK")
		AC_TRY_RUN([#include <unistd.h>
		            #include <stdio.h>
		            int
			    main() {
			   	FILE *fp=fopen("conftest1","w");
				fprintf(fp,"%lu\n",sysconf(_SC_CLK_TCK));
				fclose(fp);
			        return 0;
			    }],
			    hz=`cat conftest1`
			    AC_DEFINE_UNQUOTED(HZ,$hz)
			    ,hz=0,hz=0)
	        AC_MSG_RESULT($hz)))


#MY_SUBDIRS=

#
# GMP
#

rm -f makedefsafter

MP_INCLUDE=""
if test $use_gmp = yes ; then

 GMPDIR=gmp3
 PATCHED_SYMBOLS=""
 if test "$enable_dynsysgmp" = "yes" ; then
	AC_CHECK_HEADER(gmp.h,
		AC_CHECK_LIB(gmp,__gmpz_init,
			AC_MSG_CHECKING("for external gmp version")
			AC_TRY_RUN([#include <gmp.h>
				    int main() {
				    #if __GNU_MP_VERSION == 4
					return 0;
				    #else
					return -1;
				    #endif
				    }],
#				MPFILES=$GMPDIR/mpn/mul_n.o
#				PATCHED_SYMBOLS=__gmpn_toom3_mul_n
				MPFILES=
				PATCHED_SYMBOLS=
				if test "$use" = "m68k-linux" ; then
					MPFILES="$MPFILES $GMPDIR/mpn/lshift.o $GMPDIR/mpn/rshift.o"
					PATCHED_SYMBOLS="$PATCHED_SYMBOLS __gmpn_lshift __gmpn_rshift"
				fi
				TLIBS="$TLIBS -lgmp"
				echo "#include \"gmp.h\"" >foo.c
				echo "int main() {return 0;}" >>foo.c
				MP_INCLUDE=`cpp foo.c | grep /gmp.h | head -n 1 | $AWK '{print $3}' | tr -d '"'`
				rm -f foo.c,
				echo "Cannot use dynamic gmp lib" , echo "Cannot use dynamic gmp lib" ),
			echo "Cannot use dynamic gmp lib" ,),
		echo "Cannot use dynamic gmp lib" ,)
fi

NEED_LOCAL_GMP=''
if test "$MP_INCLUDE" = "" ; then			
	NEED_LOCAL_GMP=1;
fi
if test "$PATCHED_SYMBOLS" != "" ; then			
	NEED_LOCAL_GMP=1;
fi

if test "$NEED_LOCAL_GMP" != "" ; then			

	 AC_MSG_CHECKING([use_gmp=yes, doing configure in gmp directory])
	 echo
	 echo "#"
	 echo "#"
	 echo "# -------------------"
	 echo "# Subconfigure of GMP"
	 echo "#"
	 echo "#"

	 if test "$use_common_binary" = "yes"; then
	   cd $GMPDIR && ./configure --host=$host && cd ..
	 else
	   cd $GMPDIR && ./configure && cd ..
	 fi
	#MY_SUBDIRS="$MY_SUBDIRS $GMPDIR" 

	 echo "#"
	 echo "#"
	 echo "#"
	 echo "# Subconfigure of GMP done"
	 echo "# ------------------------"
	 echo "#"

	if test "$MP_INCLUDE" = "" ; then
		cp $GMPDIR/gmp.h h/gmp.h
		MP_INCLUDE=h/gmp.h
		MPFILES=gmp_all
	fi

fi

AC_MSG_CHECKING("for leading underscore in object symbols")
cat>foo.c <<EOFF
#include <math.h>
int main() {double d=0.0;cos(d);return 0;}
EOFF
$CC -c foo.c -o foo.o
if nm foo.o |grep " U " | grep "_cos" >/dev/null ; then
	LEADING_UNDERSCORE=1
	AC_MSG_RESULT("yes")
else
	LEADING_UNDERSCORE=""
	AC_MSG_RESULT("no")
fi
AC_MSG_CHECKING("for GNU ld option -Map")
touch map
$CC -o foo [ -Wl,-Map ] map foo.o >/dev/null 2>&1
if test `cat map | wc -l` != "0" ; then
	AC_MSG_RESULT("yes")
	AC_DEFINE(HAVE_GNU_LD)
	GNU_LD=1
else
	AC_MSG_RESULT("no")
	GNU_LD=
fi
rm -f foo.c foo.o foo map

 AC_MSG_CHECKING("for size of gmp limbs")
 AC_TRY_RUN([#include <stdio.h>
	#include "$MP_INCLUDE"
	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) 

 AC_MSG_CHECKING("_SHORT_LIMB")
 AC_TRY_RUN([#include <stdio.h>
	#include "$MP_INCLUDE"
	int main() {
	#ifdef _SHORT_LIMB
	return 0;
	#else
	return 1;
	#endif
	}],AC_DEFINE(__SHORT_LIMB) AC_MSG_RESULT(yes),AC_MSG_RESULT(no),AC_MSG_RESULT(no))
 AC_MSG_CHECKING("_LONG_LONG_LIMB")
 AC_TRY_RUN([#include <stdio.h>
	#include "$MP_INCLUDE"
	int main() {
	#ifdef _LONG_LONG_LIMB
	return 0;
	#else
	return 1;
	#endif
	}],AC_DEFINE(__LONG_LONG_LIMB) AC_MSG_RESULT(yes),AC_MSG_RESULT(no),AC_MSG_RESULT(no))

 GMP=1
 AC_DEFINE(GMP)
 AC_SUBST(GMP)
 AC_SUBST(GMPDIR)
 echo > makedefsafter
 echo "MPFILES=$MPFILES" >> makedefsafter
 echo "PATCHED_SYMBOLS=$PATCHED_SYMBOLS" >> makedefsafter
 echo >> makedefsafter
fi


#
# X windows
# 

AC_PATH_XTRA
echo $X_CFLAGS
echo $X_LIBS
echo $X_EXTRA_LIBS
echo $X_PRE_LIBS

miss=0
AC_CHECK_LIB(Xmu,main,X_LIBS="$X_LIBS -lXmu",miss=1,$X_LIBS)
AC_CHECK_LIB(Xt,main,X_LIBS="$X_LIBS -lXt",miss=1,$X_LIBS)
AC_CHECK_LIB(Xext,main,X_LIBS="$X_LIBS -lXext",miss=1,$X_LIBS)
AC_CHECK_LIB(Xaw,main,X_LIBS="$X_LIBS -lXaw",miss=1,$X_LIBS)
AC_CHECK_LIB(X11,main,X_LIBS="$X_LIBS -lX11",miss=1,$X_LIBS)
 
if test "$miss" = "1" ; then
	X_CFLAGS=
	X_LIBS=
	echo missing x libraries -- cannot compile xgcl
fi


AC_SUBST(X_LIBS)
AC_SUBST(X_CFLAGS)

#
# Dynamic loading
#

if test "$enable_dlopen" = "yes" ; then

 	AC_CHECK_LIB(dl,dlopen,have_dl=1,have_dl=0)
 	if test "$have_dl" = "0" ; then
 		echo "Cannot find dlopen in -dl"
 		exit 1
 	fi
dnl	AC_SEARCH_LIBS(dlopen, dl, have_dl=1, AC_ERROR(dlopen not found))
dnl LIBS and TLIBS - why not merged from the beginning?

	TLIBS="$TLIBS -ldl -rdynamic"
dnl	TLIBS="$TLIBS -rdynamic"
	AC_DEFINE(USE_DLOPEN)
fi

if test "$enable_statsysbfd" = "yes" || test "$enable_dynsysbfd" = "yes" ; then
	AC_CHECK_HEADER(bfd.h,
		AC_CHECK_LIB(bfd,bfd_init,
		#
		# 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_TRY_RUN([#define CONST const
                                            #define IN_GCC
					    #include <bfd.h>
					    int main() {symbol_info t; return 0;}],
					AC_MSG_RESULT(yes) 
					AC_DEFINE(NEED_CONST),
					AC_MSG_RESULT(cannot use bfd) exit 1;,
					AC_MSG_RESULT(cannot use bfd) exit 1;),
				AC_MSG_RESULT(cannot use bfd) exit 1;)
			,,-liberty))

	AC_DEFINE(HAVE_LIBBFD)

#
# BFD boolean syntax
#

	AC_MSG_CHECKING(for useable bfd_boolean)
	AC_TRY_RUN([#define IN_GCC
		    #include <bfd.h>
		    bfd_boolean foo() {return FALSE;}
		    int main() {return 0;}],
		AC_MSG_RESULT(yes) 
		AC_DEFINE(HAVE_BFD_BOOLEAN),
		AC_MSG_RESULT(no),
		AC_MSG_RESULT(no))


#
# FIXME: Need to workaround mingw before this point -- CM
#
	if test "$enable_statsysbfd" = "yes" && ! $CC -v 2>&1 | fgrep ming > /dev/null ; then
		echo 'int main() {bfd_init();bfd_openr("/dev/null",0);return 0;}' >foo.c
		MP=`$CC [ -Wl,-M ] -static -o foo foo.c -lbfd -liberty 2>&1 | grep -v : | tr '()' '\012\012' | $AWK '{print $NF}' | sort | uniq`
		rm -f foo.c foo
		if echo $MP | tr ' ' '\012' | grep -q libbfd.a ; then
		   TLIBS="$TLIBS `echo $MP | tr ' ' '\012' | grep libbfd.a | $AWK '{i=split($1,A,"/");for (j=1;j<=i;j++) if (j>1 && A[[j]]=="..") {j--;i-=2;for (k=j;k<=i;k++) A[[k]]=A[[k+2]];j--;}} END {for (j=1;j<=i;j++) printf("%s%s",A[[j]],j!=i ? "/" : "")}'`"
		else
		   echo Guessing path to libbfd.a due to gcc bug
		   TLIBS="$TLIBS /usr/lib/libbfd.a"
		fi   
		if echo $MP | tr ' ' '\012' | grep -q libiberty.a ; then
		   TLIBS="$TLIBS `echo $MP | tr ' ' '\012' | grep libiberty.a | $AWK '{i=split($1,A,"/");for (j=1;j<=i;j++) if (j>1 && A[[j]]=="..") {j--;i-=2;for (k=j;k<=i;k++) A[[k]]=A[[k+2]];j--;}} END {for (j=1;j<=i;j++) printf("%s%s",A[[j]],j!=i ? "/" : "")}'`"
		else
		   echo Guessing path to libiberty.a due to gcc bug
		   TLIBS="$TLIBS /usr/lib/libiberty.a"
		fi   
	else
		TLIBS="$TLIBS -lbfd -liberty"
	fi
fi

if test "$enable_locbfd" = "yes" ; then

	# check for gettext.  It is part of glibc, but others
	# need GNU gettext separately.
	AC_CHECK_HEADER(libintl.h, true,
			   AC_MSG_ERROR(libintl.h (gettext) not found))
	AC_SEARCH_LIBS(dgettext, intl, true, AC_MSG_ERROR(gettext library not found))
 
	echo "#"
	echo "#"
	echo "# -------------------------"
	echo "# Subconfigure of LIBIBERTY"
	echo "#"
	echo "#"
	cd binutils/libiberty && chmod +x configure && ./configure && cd ../..
#       MY_SUBDIRS="$MY_SUBDIRS binutils/libiberty " 
	echo "#"
	echo "#"
	echo "#"
	echo "# Subconfigure of LIBIBERTY done"
	echo "# ------------------------------"
	echo "#"
	echo "#"
	echo "#"
	echo "# -------------------"
	echo "# Subconfigure of BFD"
	echo "#"
	echo "#"
	cd binutils/bfd && chmod +x configure && ./configure && cd ../..
#       MY_SUBDIRS="$MY_SUBDIRS binutils/bfd " 
	echo "#"
	echo "#"
	echo "#"
	echo "# Subconfigure of BFD done"
	echo "# ------------------------"
	echo "#"
#	TLIBS="$TLIBS `pwd`/binutils/bfd/libbfd.a `pwd`/binutils/libiberty/libiberty.a"
	AC_DEFINE(HAVE_LIBBFD)
	BUILD_BFD="h/bfd.h h/bfdlink.h h/ansidecl.h h/symcat.h"
	AC_SUBST(BUILD_BFD)
fi

#AC_CONFIG_SUBDIRS($MY_SUBDIRS)

# 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_CHECK_SIZEOF(long,0)
AC_MSG_CHECKING(sizeof struct contblock)

# work around MSYS pwd result incompatibility
if test "$use" = "mingw" ; then
AC_TRY_RUN([#include <stdio.h>
	#define EXTER
	#include "$MP_INCLUDE"
	#include "h/enum.h"
	#include "h/object.h"
	int main(int argc,char **argv,char **envp) {
	FILE *f=fopen("conftest1","w");
	fprintf(f,"%u",sizeof(struct contblock));
	fclose(f);
	return 0;
	}],sizeof_contblock=`cat conftest1`,
	   echo Cannot find sizeof struct contblock;exit 1,
	   echo Cannot find sizeof struct contblock;exit 1)
else
AC_TRY_RUN([#include <stdio.h>
	#define EXTER
	#include "$MP_INCLUDE"
	#include "`pwd`/h/enum.h"
	#include "`pwd`/h/object.h"
	int main(int argc,char **argv,char **envp) {
	FILE *f=fopen("conftest1","w");
	fprintf(f,"%u",sizeof(struct contblock));
	fclose(f);
	return 0;
	}],sizeof_contblock=`cat conftest1`,
	   echo Cannot find sizeof struct contblock;exit 1,
	   echo Cannot find sizeof struct contblock;exit 1)
fi
AC_MSG_RESULT($sizeof_contblock)
AC_DEFINE_UNQUOTED(SIZEOF_CONTBLOCK,$sizeof_contblock)



AC_CHECK_HEADERS(endian.h,
	AC_MSG_CHECKING("endianness")
	AC_TRY_RUN([#define __ARMEB__
		#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)


# On systems with execshield, brk is randomized.  We need to catch
# this and restore the traditional behavior here

AC_MSG_CHECKING([for sbrk])
HAVE_SBRK=""
AC_TRY_RUN([#include <unistd.h>
	    #include <stdio.h>
	    int main() {
		FILE *f;
		if (!(f=fopen("conftest1","w")))
			return -1;
		fprintf(f,"%u",sbrk(0));
		return 0;
		}],
		HAVE_SBRK=1
		AC_MSG_RESULT(yes),
		AC_MSG_RESULT([no: WARNING you must be able to emulate sbrk: as on mingw or macosx]),
		AC_MSG_RESULT([no: WARNING you must be able to emulate sbrk: as on mingw or macosx]))

if test "$HAVE_SBRK" = "1" ; then
	AC_MSG_CHECKING([for randomized sbrk])
	AC_TRY_RUN([#include <unistd.h>
		    #include <stdio.h>
		    int main() {
			FILE *f;
			if (!(f=fopen("conftest1","w")))
				return -1;
			fprintf(f,"%u",sbrk(0));
			return 0;
			}],
			SBRK=`cat conftest1`,SBRK=0,SBRK=0)
	if test "$SBRK" = "0" ; then
		AC_MSG_RESULT(cannot trap sbrk)
		exit 1
	fi
	AC_TRY_RUN([#include <unistd.h>
		    #include <stdio.h>
		    int main() {
			FILE *f;
			if (!(f=fopen("conftest1","w")))
				return -1;
			fprintf(f,"%u",sbrk(0));
			return 0;
			}],
			SBRK1=`cat conftest1`,SBRK1=0,SBRK1=0)
	if test "$SBRK1" = "0" ; then
		AC_MSG_RESULT(cannot trap sbrk)
		exit 1
	fi
	
	if test "$SBRK" != "$SBRK1" ; then
		AC_MSG_RESULT(yes)
		AC_MSG_CHECKING([for randomized brk remedy])
		AC_TRY_RUN([#include <syscall.h>
			    #include <linux/personality.h>
	         	    #include <stdio.h>
			    #include <unistd.h>
			    int main(int argc,char * argv[]) {
				FILE *f;
				#if SIZEOF_LONG == 4
				if (!syscall(SYS_personality,PER_LINUX32))
				#else
				if (!syscall(SYS_personality,PER_LINUX))
				#endif
					execvp(argv[0],argv);
				if (!(f=fopen("conftest1","w")))
					return -1;
				fprintf(f,"%u",sbrk(0));
				return 0;
				}],
				SBRK=`cat conftest1`,SBRK=0,SBRK=0)
		if test "$SBRK" = "0" ; then
			AC_MSG_RESULT(cannot trap sbrk)
			exit 1
		fi
		AC_TRY_RUN([#include <syscall.h>
			    #include <linux/personality.h>
			    #include <stdio.h>
			    #include <unistd.h>
			    int main(int argc,char * argv[]) {
				FILE *f;
				#if SIZEOF_LONG == 4
				if (!syscall(SYS_personality,PER_LINUX32))
				#else
				if (!syscall(SYS_personality,PER_LINUX))
				#endif
					execvp(argv[0],argv);
				if (!(f=fopen("conftest1","w")))
					return -1;
				fprintf(f,"%u",sbrk(0));
				return 0;
				}],
				SBRK1=`cat conftest1`,SBRK1=0,SBRK1=0)
		if test "$SBRK1" = "0" ; then
			AC_MSG_RESULT(cannot trap sbrk)
			exit 1
		fi
		if test "$SBRK" = "$SBRK1" ; then
			AC_MSG_RESULT(yes)
			AC_DEFINE(NEED_NONRANDOM_SBRK)
		else
			AC_MSG_RESULT(no)
			echo "Cannot build with randomized sbrk"
			exit 1
		fi 
	else
		AC_MSG_RESULT(no)
	fi
fi


old_LDFLAGS="$LDFLAGS"
LDFLAGS="$TLDFLAGS"
AC_MSG_CHECKING("finding DBEGIN")
AC_TRY_RUN([#include <stdio.h>
            #include <stdlib.h>
	    #ifdef NEED_NONRANDOM_SBRK
		   #include <syscall.h>
		   #include <linux/personality.h>
		   #include <unistd.h>
	   #endif
int
main(int argc,char * argv[])
{
  char *b;
  FILE *fp;

#ifdef NEED_NONRANDOM_SBRK
#if SIZEOF_LONG == 4
if (!syscall(SYS_personality,PER_LINUX32))
#else
if (!syscall(SYS_personality,PER_LINUX))
#endif
     execvp(argv[0],argv);
#endif  
  b = (void *) malloc(1000);
  fp = fopen("conftest1","w");

#ifdef _WIN32
  fprintf ( fp,"0x%lx", 0x1a000000 );  /* Windows custom allocation from this point up */
#else
#if defined (__APPLE__) && defined (__MACH__)
  fprintf(fp,"get_dbegin()");
#else
  fprintf(fp,"0x%lx",((unsigned long) b) & ~(unsigned long)0xffffff);
#endif
#endif
  fclose(fp);
  return 0;
}],dbegin=`cat conftest1`,dbegin=0,dbegin=0)
AC_DEFINE_UNQUOTED(DBEGIN,$dbegin \
/* where data begins */
)
AC_MSG_RESULT(got $dbegin)
LDFLAGS="$old_LDFLAGS"


AC_MSG_CHECKING("finding CSTACK_ADDRESS")
AC_TRY_RUN([#include <stdio.h>
main()
{
  char *b ;
  FILE *fp = fopen("conftest1","w");
  fprintf(fp,"%ld",((long) &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
	SYSTEM=ansi_gcl
	AC_DEFINE(ANSI_COMMON_LISP)
	CLSTANDARD=ANSI
else
	SYSTEM=gcl
	CLSTANDARD=CLtL1
fi

FLISP="saved_$SYSTEM"
AC_SUBST(FLISP)
AC_SUBST(SYSTEM)
AC_SUBST(CLSTANDARD)

# 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)

# Maximum number of pages



# 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)

# OpenBSD has elf_abi.h instead of elf.h
AC_CHECK_HEADERS(elf.h elf_abi.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)

EXTRA_LOBJS=
if test "$try_japi" = "yes" ; then
   AC_CHECK_HEADERS(japi.h,[AC_DEFINE(HAVE_JAPI_H)
				 EXTRA_LOBJS="${EXTRA_LOBJS} gcl_japi.o"
			 	 LIBS="${LIBS} -ljapi -lwsock32"] )
fi
if test "$use" = "mingw" ; then
 if test "$try_xdr" = "yes" ; then
   AC_CHECK_HEADERS(rpc/rpc.h,[AC_DEFINE(HAVE_XDR)
			 	 LIBS="${LIBS} -loncrpc"] )
 fi
else
 if test "$try_xdr" = "yes" ; then
   AC_CHECK_HEADERS(rpc/rpc.h,[AC_DEFINE(HAVE_XDR)
			 	 LIBS="${LIBS} -lrpc"] )
 fi
fi

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

#
# For DBL_MAX et. al. on (only) certain Linux arches, apparently CM
#
AC_CHECK_HEADERS(values.h,AC_DEFINE(HAVE_VALUES_H))

#
# Sparc solaris keeps this in float.h, rework either/or with values.h later
#
AC_CHECK_HEADERS(float.h,AC_DEFINE(HAVE_FLOAT_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>
	                    #include <ieeefp.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, TLIBS="$TLIBS -lsocket", tcl_checkBoth=1)
fi


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

RL_OJBS=""
RL_LIB=""
if test "$enable_readline" = "yes" ; then
	AC_CHECK_HEADERS(readline/readline.h,
		AC_CHECK_LIB(readline,main,
			AC_DEFINE(HAVE_READLINE) 
			TLIBS="$TLIBS -lreadline -lncurses"
			RL_OBJS=gcl_readline.o
# Readline support now initialized automatically when compiled in, this lisp
# object no longer needed, 20040102 CM
#			RL_LIB=mod/gcl_readline.o
			,,-lncurses))

# These tests discover differences between readline 4.1 and 4.3
	AC_CHECK_LIB(readline,rl_completion_matches,
			AC_DEFINE(HAVE_DECL_RL_COMPLETION_MATCHES)
			AC_DEFINE(HAVE_RL_COMPENTRY_FUNC_T),,)
fi

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_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_MSG_CHECKING([for sigcontext...])
        AC_TRY_COMPILE([#include <signal.h>
       ],
       [
        struct sigcontext foo;
       ],
       [
        sigcontext_works=1;
        AC_DEFINE(SIGNAL_H_HAS_SIGCONTEXT)
	AC_MSG_RESULT(sigcontext in signal.h)
       ],
        
	[sigcontext_works=0;
         AC_MSG_RESULT(sigcontext NOT in signal.h)]
       )
       if test "$sigcontext_works" = 0 ; then
       AC_MSG_CHECKING([for sigcontext...])
       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
          ],
        [ 
        struct sigcontext foo;
        ],
        [
        AC_DEFINE(HAVE_SIGCONTEXT)
	AC_MSG_RESULT(sigcontext in asm files)
        ],
        [
        AC_MSG_RESULT(no sigcontext found)
     ])


       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])
if [[ "$EMACS_SITE_LISP" = "unknown" ]] ; then
	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
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 test "$use" = "mingw" ; then
    INFO_DIR=\$\(prefix\)/lib/gcl-$VERSION/info/
else
    if [[ "$EMACS" != "" ]] && [[ "$INFO_DIR" = "unknown" ]] ; then
	INFO_DIR=`$EMACS -q -batch --no-site-file -l conftest.el 2>&1 | sed -e /Loading/d | sed -e /load/d `
    fi
fi
if  test -f "${INFO_DIR}dir"  ; then true;else
if test -f /usr/share/info/dir ; then
  INFO_DIR=/usr/share/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
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)

      


# 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

# 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 

LIBS="$LDFLAGS $TLDFLAGS $LIBS $TLIBS"
AC_SUBST(LIBS)
FINAL_CFLAGS="$CFLAGS $TCFLAGS $PROCESSOR_FLAGS"
AC_SUBST(FINAL_CFLAGS)
# Work around bug with gcc on ppc -- CM
NIFLAGS="$CFLAGS $TCFLAGS $TONIFLAGS $PROCESSOR_FLAGS -I\$(GCLDIR)/o"
AC_SUBST(NIFLAGS)
CFLAGS="$CFLAGS $TCFLAGS $TO3FLAGS $PROCESSOR_FLAGS -I\$(GCLDIR)/o"
AC_SUBST(CFLAGS)
O3FLAGS=$TO3FLAGS
AC_SUBST(O3FLAGS)
O2FLAGS=$TO2FLAGS
AC_SUBST(O2FLAGS)

AC_SUBST(EXTRA_LOBJS)
AC_SUBST(LEADING_UNDERSCORE)
AC_SUBST(GNU_LD)

AC_SUBST(LD_STACK_FLAGS)

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

  AC_SUBST(use)
  AC_OUTPUT(makedefc windows/gcl.iss windows/sysdir.bat windows/install.lsp)
  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