summaryrefslogtreecommitdiff
path: root/configure.in
blob: 6801880f25175d14846db2107cf08b0493d601ef (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
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
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
dnl The contents of this file are subject to the Mozilla Public
dnl License Version 1.1 (the "License"); you may not use this file
dnl except in compliance with the License. You may obtain a copy of
dnl the License at http://www.mozilla.org/MPL/
dnl
dnl Software distributed under the License is distributed on an "AS
dnl IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
dnl implied. See the License for the specific language governing
dnl rights and limitations under the License.
dnl
dnl The Original Code is the configure.in script for NSPR.
dnl
dnl The Initial Developer of the Original Code is Christopher
dnl Seawood. Portions created by Christopher Seawood are
dnl Copyright (C) 1999 Christopher Seawood. All
dnl Rights Reserved.
dnl
dnl Contributor(s):
dnl
dnl Process this file with autoconf to produce a configure script.
dnl
AC_PREREQ(2.12)
AC_INIT(config/libc_r.h)

AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
AC_CANONICAL_SYSTEM

dnl Set this define to make fixes w/o breaking anything else.
AC_DEFINE(USE_AUTOCONF)

dnl ========================================================
dnl = Defaults
dnl ========================================================
MOD_MAJOR_VERSION=4
MOD_MINOR_VERSION=0
MOD_REVISION_VERSION=1
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
USE_USER_PTHREADS=
USE_NSPR_THREADS=
USE_N32=
USE_64=
USE_CPLUS=
USE_IPV6=
USE_MDUPDATE=
_OPTIMIZE_FLAGS=-O
_DEBUG_FLAGS=-g
MOZ_DEBUG=1
MOZ_OPTIMIZE=
OBJDIR=.
OBJDIR_NAME=.
NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
NOSUCHFILE=/no-such-file
LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'

dnl Link in libraries necessary to resolve all symbols for shared libs
RESOLVE_LINK_SYMBOLS=

dnl ========================================================
dnl =
dnl = Dont change the following lines.  Doing so breaks:
dnl =
dnl = CFLAGS="-foo" ./configure
dnl =
dnl ========================================================
CFLAGS="${CFLAGS=}"
CXXFLAGS="${CXXFLAGS=}"
LDFLAGS="${LDFLAGS=}"
HOST_CFLAGS="${HOST_CFLAGS=}"
HOST_LDFLAGS="${HOST_LDFLAGS=}"

dnl ========================================================
dnl = Irix 6.x should use n32 ABI by default
dnl ========================================================
case "$target" in
*-irix6*)
	USE_N32=1 ;;
*-cygwin*)
    # Check to see if we are really running in a msvc environemnt
    _WIN32_MSVC=
    if test "$CC" = "cl" || test "$CXX" = "cl"; then
        _WIN32_MSVC=1
    elif test -z "$CC"; then
        echo 'main() { return 0; }' > dummy.c
        cl -o dummy dummy.c
        if test $? = 0; then
            _WIN32_MSVC=1
        fi
        rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
    fi
    ;;
*-msvc*)
    _WIN32_MSVC=1
    ;;
esac

if test -n "$_WIN32_MSVC"; then
    SKIP_PATH_CHECKS=1
    SKIP_COMPILER_CHECKS=1
    SKIP_LIBRARY_CHECKS=1
fi

dnl ========================================================
dnl =
dnl = Check options that may affect the compiler
dnl =
dnl ========================================================
dist_prefix='${MOD_DEPTH}/dist'
dist_bindir='${dist_prefix}/bin'
dist_includedir='${dist_prefix}/include'
dist_libdir='${dist_prefix}/lib'

AC_ARG_WITH(dist-prefix,
    [  --with-dist-prefix=DIST_PREFIX
                          place build files in DIST_PREFIX [dist]],
    dist_prefix=$withval)

AC_ARG_WITH(dist-bindir,
    [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
    dist_bindir=$withval)

AC_ARG_WITH(dist-includedir,
    [  --with-dist-includedir=DIR
                          build include files in DIR [DIST_PREFIX/include]],
    dist_includedir=$withval)

AC_ARG_WITH(dist-libdir,
    [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
    dist_libdir=$withval)

AC_SUBST(dist_prefix)
AC_SUBST(dist_bindir)
AC_SUBST(dist_includedir)
AC_SUBST(dist_libdir)

dnl Check if NSPR is being compiled for Mozilla
dnl Let --with-arg override environment setting
dnl
AC_ARG_WITH(mozilla,
    [  --with-mozilla          Compile NSPR with Mozilla support],
    [   if test "$withval" = "yes"; then
            AC_DEFINE(MOZILLA_CLIENT)
            MOZILLA_CLIENT=1
	    else
	        MOZILLA_CLIENT=
	    fi],
    [	if test -n "$MOZILLA_CLIENT"; then
	        AC_DEFINE(MOZILLA_CLIENT)
	    fi])

AC_ARG_ENABLE(optimize,
    [  --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ],
    [ if test "$enableval" != "no"; then
        MOZ_OPTIMIZE=1
        if test -n "$enableval" && test "$enableval" != "yes"; then
    	    _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
            _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
        fi
    fi ])

AC_ARG_ENABLE(debug,
    [  --disable-debug         Do not compile in debugging symbols],
    [	if test "$enableval" = "no"; then
    	    MOZ_DEBUG=
	    fi])

AC_ARG_ENABLE(win32-target,
    [  --enable-win32-target=\$t
                          Specify win32 flavor. (WIN95 or WINNT)],
    MOZ_WIN32_TARGET=`echo $enableval | tr a-z A-Z`,
    MOZ_WIN32_TARGET=)

AC_ARG_ENABLE(n32,
    [  --enable-n32            Enable n32 ABI support (IRIX only)],
    [ if test "$enableval" = "yes"; then
	USE_N32=1
      else if test "$enableval" = "no"; then
	USE_N32=
      fi
    fi ])

AC_ARG_ENABLE(64bit,
    [  --enable-64bit          Enable 64-bit support (on certain platforms)],
    [ if test "$enableval" = "yes"; then
	    USE_64=1
      fi ])

AC_ARG_ENABLE(mdupdate,
    [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
    [ if test "$enableval" = "yes"; then
	    USE_MDUPDATE=1
      fi ])

if test -z "$SKIP_PATH_CHECKS"; then
    AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami)
elif test -z "$WHOAMI"; then
    WHOAMI=whoami
fi

if test -n "$MOZ_DEBUG"; then
    AC_DEFINE(DEBUG)
    AC_DEFINE_UNQUOTED(DEBUG_`$WHOAMI`)
    DEFINES="$DEFINES -UNDEBUG"
else
    AC_DEFINE(NDEBUG)
    DEFINES="$DEFINES -U_DEBUG -UDEBUG"
fi

if test -z "$SKIP_COMPILER_CHECKS"; then
dnl ========================================================
dnl Checks for compilers.
dnl ========================================================
if test "$target" != "$host"; then
    echo "cross compiling from $host to $target"
    cross_compiling=yes

    _SAVE_CC="$CC"
    _SAVE_CFLAGS="$CFLAGS"
    _SAVE_LDFLAGS="$LDFLAGS"

    AC_MSG_CHECKING([for $host compiler])
    if test -z "$HOST_CC"; then
	    AC_CHECK_PROGS(HOST_CC, gcc cc /usr/ucb/cc, "")
	    if test -z "$HOST_CC"; then
	        AC_MSG_ERROR([no acceptable cc found in \$PATH])
	    fi
    fi
    AC_MSG_RESULT([$HOST_CC])
    if test -z "$HOST_CFLAGS"; then
	    HOST_CFLAGS="$CFLAGS"
    fi
    if test -z "$HOST_LDFLAGS"; then
	    HOST_LDFLAGS="$LDFLAGS"
    fi

    CC="$HOST_CC"
    CFLAGS="$HOST_CFLAGS"
    LDFLAGS="$HOST_LDFLAGS"

    AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
    AC_TRY_COMPILE([], [return(0);], 
	[ac_cv_prog_host_cc_works=1 AC_MSG_RESULT([yes])],
	AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.]) )
    
    CC=$_SAVE_CC
    CFLAGS=$_SAVE_CFLAGS
    LDFLAGS=$_SAVE_LDFLAGS

    if test -z "$CC"; then
	    AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", echo)
    fi
    unset ac_cv_prog_CC
    AC_PROG_CC
    if test -z "$CXX"; then
	    AC_CHECK_PROGS(CXX, "${target_alias}-g++" "${target}-g++", echo)
    fi
    unset ac_cv_prog_CXX
    AC_PROG_CXX
    if test -z "$RANLIB"; then
	    AC_CHECK_PROGS(RANLIB, "${target_alias}-ranlib" "${target}-ranlib", echo)
    fi
    if test -z "$AR"; then
	    AC_CHECK_PROGS(AR, "${target_alias}-ar" "${target}-ar", echo)
    fi
    if test -z "$AS"; then
	    AC_CHECK_PROGS(AS, "${target_alias}-as" "${target}-as", echo)
    fi
    if test -z "$LD"; then
	    AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", echo)
    fi
    if test -z "$STRIP"; then
	    AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", echo)
    fi
    if test -z "$DLLTOOL"; then
	    AC_CHECK_PROGS(DLLTOOL, "${target_alias}-dlltool" "${target}-dlltool", echo)
    fi
    if test -z "$WINDRES"; then
	    AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", echo)
    fi

else
    AC_PROG_CXX
    if test "$CXX" = "cl" -a -z "$CC"; then
        CC=$CXX
    else        
        AC_PROG_CC
    fi
    AC_PROG_RANLIB
    AC_PATH_PROGS(AS, as, $CC)
    AC_PATH_PROGS(AR, ar, echo not_ar)
    AC_PATH_PROGS(LD, ld link, echo not_ld)
    AC_PATH_PROGS(STRIP, strip, echo not_strip)
    AC_PATH_PROGS(DLLTOOL, dlltool, echo not_dlltool)
    AC_PATH_PROGS(WINDRES, windres, echo not_windres)
    if test -z "$HOST_CC"; then
	    HOST_CC="$CC"
    fi
    if test -z "$HOST_CFLAGS"; then
	    HOST_CFLAGS="$CFLAGS"
    fi
fi

if test "$GCC" = "yes"; then
    GNU_CC=1
fi
if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then
    GNU_AS=1
fi
rm -f a.out

if test "$cross_compiling"  = "yes"; then
    CROSS_COMPILE=1
else
    CROSS_COMPILE=
fi

fi # SKIP_COMPILER_CHECKS

dnl ========================================================
dnl Checks for programs.
dnl ========================================================
if test -z "$SKIP_PATH_CHECKS"; then
    AC_PATH_PROGS(PERL, perl5 perl, echo not_perl)
elif test -z "$PERL"; then
    PERL=perl
fi

dnl ========================================================
dnl Default platform specific options
dnl ========================================================
OBJ_SUFFIX=o
LIB_SUFFIX=a
DLL_SUFFIX=so
MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
PR_MD_ASFILES=
PR_MD_CSRCS=
PR_MD_ARCH_DIR=unix
AR_FLAGS='cr $@'
AS='$(CC)'

OS_ARCH=`uname -s | sed -e 's|/|_|g'`
OS_RELEASE=`uname -r`
OS_TEST=`uname -m`

if test "$OS_ARCH" = "IRIX64"; then
    OS_ARCH=IRIX
fi

if test "$OS_ARCH" = "POSIX_for_OpenVMS_AXP"; then
    OS_ARCH=OpenVMS
fi

#######################################################################
# Master "Core Components" macros for getting the OS target           #
#######################################################################

#
# Note: OS_TARGET should be specified on the command line for gmake.
# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
# The difference between the Win95 target and the WinNT target is that
# the WinNT target uses Windows NT specific features not available
# in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
# at lesser performance (the Win95 target uses threads; the WinNT target
# uses fibers).
#
# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target
# is built. See: win16_3.11.mk for lots more about the Win16 target.
#
# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
# cross-compilation.
#

#
# The following hack allows one to build on a WIN95 machine (as if
# s/he were cross-compiling on a WINNT host for a WIN95 target).
# It also accomodates for MKS's uname.exe.  If you never intend
# to do development on a WIN95 machine, you don't need this hack.
#
if test "$OS_ARCH" = "WIN95"; then
    OS_ARCH=WINNT
    OS_TARGET=WIN95
elif test "$OS_ARCH" = 'Windows_95'; then
    OS_ARCH=Windows_NT
    OS_TARGET=WIN95
elif test "$OS_ARCH" = 'Windows_98'; then
    OS_ARCH=Windows_NT
    OS_TARGET=WIN95
elif test "$OS_ARCH" = "CYGWIN_95-4.0"; then
    OS_ARCH='CYGWIN_NT-4.0'
    OS_TARGET=WIN95
elif test "$OS_ARCH" = "CYGWIN_98-4.10"; then
    OS_ARCH='CYGWIN_NT-4.0'
    OS_TARGET=WIN95
elif test "$OS_ARCH" = "OS_2"; then
    OS_ARCH=OS2
    OS_TARGET=OS2
fi

#
# On WIN32, we also define the variable CPU_ARCH.
#

if test "$OS_ARCH" = "WINNT"; then
    CPU_ARCH=`uname -p`
    if test "$CPU_ARCH" = "I386"; then
        CPU_ARCH=x86
    fi
elif test "$OS_ARCH" = "Windows_NT"; then
#
# If uname -s returns "Windows_NT", we assume that we are using
# the uname.exe in MKS toolkit.
#
# The -r option of MKS uname only returns the major version number.
# So we need to use its -v option to get the minor version number.
# Moreover, it doesn't have the -p option, so we need to use uname -m.
#
    OS_ARCH=WINNT
#    OS_MINOR_RELEASE=`uname -v`
    if test "$OS_MINOR_RELEASE" = "00"; then
        OS_MINOR_RELEASE=0
    fi
    OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
    CPU_ARCH=`uname -m`
    #
    # MKS's uname -m returns "586" on a Pentium machine.
    #
    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
        CPU_ARCH=x86
    fi
elif echo "$OS_ARCH" | grep -c CYGWIN_NT >/dev/null; then
#
# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
# the uname.exe in the Cygwin tools.
#
    OS_RELEASE=`echo $OS_ARCH | sed 's|^CYGWIN_NT-||'`
    OS_ARCH=WINNT
    CPU_ARCH=`uname -m`
    #
    # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
    #
    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
        CPU_ARCH=x86
    fi
elif test "$OS_ARCH" = "CYGWIN32_NT"; then
#
# Prior to the Beta 20 release, Cygwin was called GNU-Win32.
# If uname -s returns "CYGWIN32/NT", we assume that we are using
# the uname.exe in the GNU-Win32 tools.
#
    OS_ARCH=WINNT
    CPU_ARCH=`uname -m`
    #
    # GNU-Win32's uname -m returns "i686" on a Pentium Pro machine.
    #
    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
        CPU_ARCH=x86
    fi
fi

if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
    OS_TARGET=WIN95
    MOZ_WIN32_TARGET=WIN95
    if test -n "$MOZ_DEBUG"; then
        USE_DEBUG_RTL=1
    fi
fi
if test -z "$OS_TARGET"; then
    OS_TARGET=$OS_ARCH
fi
if test "$OS_TARGET" = "WIN95"; then
    OS_RELEASE="4.0"
fi
if test "$OS_TARGET" = "WIN16"; then
    OS_RELEASE=
fi
if test -z "$MOZ_WIN32_TARGET"; then
    MOZ_WIN32_TARGET=$OS_TARGET
fi
OS_CONFIG="${OS_TARGET}${OS_RELEASE}"

dnl ========================================================

dnl ========================================================
dnl Override of system specific host options
dnl ========================================================
case "$host" in
*-mingw*|*-cygwin*|*-msvc*)
    ;;
*-beos*)
    HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
    ;;
*os2*)
    ;;
*)
    HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
    ;;
esac

dnl ========================================================
dnl Override of system specific target options
dnl ========================================================
case "$target" in

*-aix*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(AIX)
    AC_DEFINE(SYSV)
    DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall'
    case "${target_os}" in
    aix3.2*)
        USE_NSPR_THREADS=1
        AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
        AC_DEFINE(AIX_RENAME_SELECT)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        AIX_LINK_OPTS='-bnso -berok'
        PR_MD_ASFILES=os_AIX.s
        ;;
    aix4.1*)
        AC_DEFINE(AIX_RENAME_SELECT)
        AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)
        AC_DEFINE(AIX_TIMERS)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        AC_DEFINE(AIX4_1)
        MKSHLIB=
        DSO_LDOPTS=
        USE_PTHREADS=1
        AIX_LINK_OPTS='-bnso -berok'
        LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)_shr'
        ;;
    aix4.3*)
        AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)
        AC_DEFINE(AIX_TIMERS)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(AIX4_3)
        AC_DEFINE(HAVE_SOCKLEN_T)
        USE_IPV6=1
        USE_PTHREADS=1
        AIX_LINK_OPTS='-brtl -bnso -berok'
        ;;
    *)
        AC_DEFINE(AIX_HAVE_ATOMIC_OP_H)
        AC_DEFINE(AIX_TIMERS)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AIX_LINK_OPTS='-brtl -bnso -berok'
        ;;
    esac
    CFLAGS="$CFLAGS -qro -qroconst"
    if echo "$CC" | grep -c xlC_r; then
        CFLAGS="$CFLAGS -qarch=com"
    fi
    AIX_WRAP='$(DIST)/lib/aixwrap.o'
    AIX_TMP='./_aix_tmp.o'
    if test -n "$USE_64"; then
        MDCPUCFG_H=_aix64.cfg
    else
        if test -n "$USE_IPV6"; then
            MDCPUCFG_H=_aix32in6.cfg
        else
            MDCPUCFG_H=_aix32.cfg
        fi
    fi
    PR_MD_CSRCS=aix.c
    RESOLVE_LINK_SYMBOLS=1
    ;;
        
*-beos*)
    AC_DEFINE(XP_BEOS)
    AC_DEFINE(BeOS)
    AC_DEFINE(BEOS)
    AC_DEFINE(_POSIX_SOURCE)
    DSO_LDOPTS=-nostart
    MDCPUCFG_H=_beos.cfg
    USE_BTHREADS=1
    PR_MD_ARCH_DIR=beos
    RESOLVE_LINK_SYMBOLS=1
    case "${target_cpu}" in
    i?86)
        _OPTIMIZE_FLAGS=-O2
        _DEBUG_FLAGS='-gdwarf-2 -O0'
        MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
        ;;
    powerpc)
        CC=mwcc
        CCC=mwcc
        LD=mwld
        DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o'
        _OPTIMIZE_FLAGS=-O2    
        _DEBUG_FLAGS='-g -O0'
        ;;
    esac
    ;;

*-bsdi*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(BSDI)
    AC_DEFINE(NEED_BSDREGEX)

    CFLAGS="$CFLAGS -Wall -Wno-format"
    CXXFLAGS="$CXXFLAGS -Wall -Wno-format"

    if echo "$OS_TEST" | grep -c 86 >/dev/null; then
        CPU_ARCH=x86
    elif echo "$OS_TEST" | grep -c sparc >/dev/null; then 
        CPU_ARCH=sparc
    fi

    MDCPUCFG_H=_bsdi.cfg
    PR_MD_CSRCS=bsdi.c

    DSO_LDOPTS=-r

    case "$target_os" in
    bsdi1.1*)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
        AC_DEFINE(_PR_STAT_HAS_ONLY_ST_ATIME)
        AC_DEFINE(_PR_NEED_H_ERRNO)
        MKSHLIB=
        DSO_CFLAGS=
        DSO_LDOPTS=
        ;;

    bsdi2.1*)
        AC_DEFINE(_PR_TIMESPEC_HAS_TS_SEC)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_ARRAY)
        AC_DEFINE(HAVE_DLL)
        AC_DEFINE(USE_DLFCN)
        AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
        PR_MD_ASFILES=os_BSD_OS_386_2.s
        ;;

    bsdi4.*)
        AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
        AC_DEFINE(HAVE_DLL)
        AC_DEFINE(USE_DLFCN)
        AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
        MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'
        DSO_CFLAGS=-fPIC
        DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)'
        STRIP="$STRIP -d"
        case "$target_os" in
        bsdi4.2*)
            AC_DEFINE(_PR_HAVE_GETPROTO_R)
            AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
            ;;
        esac
        ;;
    *)
        AC_DEFINE(_PR_SELECT_CONST_TIMEVAL)
        AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT)
        AC_DEFINE(HAVE_DLL)
        AC_DEFINE(USE_DLFCN)
        AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
        ;;
    esac

    ;;

*-dgux*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    AC_DEFINE(DGUX)
    AC_DEFINE(_DGUX_SOURCE)
    AC_DEFINE(_POSIX4A_DRAFT6_SOURCE)
    DSO_LDOPTS=-G
    _OPTIMIZE_FLAGS=-O2
    _DEBUG_FLAGS=
    MDCPUCFG_H=_dgux.cfg
    PR_MD_CSRCS=dgux.c
    ;;

*-freebsd*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(FREEBSD)
    AC_DEFINE(HAVE_BSD_FLOCK)
    CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall -pipe"
    MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
    if test "$MOZ_OBJFORMAT" = "elf"; then
        DLL_SUFFIX=so
    else
        DLL_SUFFIX=so.1.0
    fi
    DSO_CFLAGS=-fPIC
    DSO_LDOPTS=-Bshareable
    MDCPUCFG_H=_freebsd.cfg
    PR_MD_CSRCS=freebsd.c
    ;;

*-hpux*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(HPUX)
    AC_DEFINE(_HPUX_SOURCE)
    AC_DEFINE(hppa)
    AC_DEFINE(hpux)
    DLL_SUFFIX=sl
    DSO_LDOPTS='-b +h $(notdir $@)'
    PR_MD_CSRCS=hpux.c
    PR_MD_ASFILES=os_HPUX.s
    if test -n "$USE_64"; then
        MDCPUCFG_H=_hpux64.cfg
    else
        MDCPUCFG_H=_hpux32.cfg
    fi
    if test -z "$GNU_CC"; then
        CC="$CC -Ae"
        CXX="$CXX -ext"
        CFLAGS="$CFLAGS +ESlit"
        CXXFLAGS="$CXXFLAGS +ESlit"
        DSO_CFLAGS=+Z
    else
        DSO_CFLAGS=-fPIC
    fi

    if test -n "$MOZILLA_CLIENT"; then
        DEFAULT_IMPL_STRATEGY=_EMU
    fi

    if echo "$OS_RELEASE" | grep ^A.09 >/dev/null; then
        AC_DEFINE(_PR_NEED_H_ERRNO)
        AC_DEFINE(HPUX9)
        DEFAULT_IMPL_STRATEGY=_EMU
    	USE_NSPR_THREADS=1
    fi

    if echo "$OS_RELEASE" | egrep '^(A.09|B.10)' >/dev/null; then
        AC_DEFINE(_PR_NO_LARGE_FILES)
    fi

    if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
        AC_DEFINE(_PR_NEED_H_ERRNO)
    fi

    if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
        AC_DEFINE(HAVE_INT_LOCALTIME_R)
    fi

    if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00)' >/dev/null; then
        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
    fi

    if test "$OS_RELEASE" = "B.10.01"; then
        AC_DEFINE(HPUX10)
        DEFAULT_IMPL_STRATEGY=_EMU
    fi

    if test "$OS_RELEASE" = "B.10.10"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX10_10)
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if test "$OS_RELEASE" = "B.10.20"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX10_20)
        if test -z "$GNU_CC" && test 0 = 1; then
            CFLAGS="$CFLAGS +DAportable +DS1.1"
            CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
        fi
        DEFAULT_IMPL_STRATEGY=_EMU
    fi

    if test "$OS_RELEASE" = "B.10.30"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX10_30)
        #CXX="/opt/aCC/bin/aCC -ext"
        if test -z "$GNU_CC" && test 0 = 1; then
            CFLAGS="$CFLAGS +DAportable +DS1.1"
            CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
        fi
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if test "$OS_RELEASE" = "B.11.00"; then
        AC_DEFINE(HPUX10)
        AC_DEFINE(HPUX11)
        AC_DEFINE(_LARGEFILE64_SOURCE)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
        if test -z "$GNU_CC"; then
            if test 0 = 1; then
            if test -z "$USE_64"; then
                CFLAGS="$CFLAGS +DAportable +DS2.0"
                CXXFLAGS="$CXXFLAGS +DAportable +DS2.0"
            else
                CFLAGS="$CFLAGS +DA2.0W +DS2.0"
                CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0"
            fi
            fi
        fi
        DEFAULT_IMPL_STRATEGY=_PTH
    fi

    if test "$DEFAULT_IMPL_STRATEGY" = "_EMU"; then
        USE_NSPR_THREADS=1
        USE_PTHREADS=
        USE_USER_THREADS=
    elif test "$DEFAULT_IMPL_STRATEGY" = "_PTH"; then
        USE_PTHREADS=1
        if test "$MOZILLA_CLIENT"; then
            USE_PTHREADS=
        fi
        if test "$USE_USER_PTHREADS"; then
            USE_PTHREADS=
        fi
    fi
    ;;

*-irix*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(IRIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(_SGI_MP_SOURCE)
    PR_MD_CSRCS=irix.c
    PR_MD_ASFILES=os_Irix.s
    MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@'
    #DSO_LDOPTS='-elf -shared -all'
    STRIP="$STRIP -f"
    if test -n "$USE_64"; then
        MDCPUCFG_H=_irix64.cfg
    else
        MDCPUCFG_H=_irix32.cfg
    fi
    case "${target_os}" in
    irix6*)
           AC_DEFINE(IRIX6)
	   USE_PTHREADS=1
           ;;
    irix5*)
           AC_DEFINE(IRIX5)
	   USE_NSPR_THREADS=1
	   ;;
    *)
	   USE_PTHREADS=1
	   ;;
 	esac
    if test "$GNU_CC"; then
	    AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)'
	    CFLAGS="$CFLAGS -Wall -Wno-format"
	    _OPTIMIZE_FLAGS="-O6"
    else
	    if test -n "$USE_N32"; then
		AS='as -D_ASM $(INCLUDES) -n32'
	    else
		AS='as -D_ASM $(INCLUDES)'
	    fi
	    CFLAGS="$CFLAGS -fullwarn -xansi"
	    if test "$USE_N32"; then
	        _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000"
	    else
	        _OPTIMIZE_FLAGS="-O -Olimit 4000"
	    fi
	    if test "$USE_MDUPDATE"; then
	        $CFLAGS="$CFLAGS -MDupdate"
	    fi
	    case "$target}" in
	    *-irix6.*)
	        CFLAGS="$CFLAGS -multigot"
	        DSO_LDOPTS="-no_unresolved"
	        if test "$USE_N32"; then
		        CFLAGS="$CFLAGS -n32 -woff 1209"
		        LDFLAGS="$LDFLAGS -n32"
		        DSO_LDOPTS="$DSO_LDOPTS -n32"
		        if test "${target_os}" = "irix6.2"; then
		            LDFLAGS="$LDFLAGS -Wl,-woff,85"
		            DSO_LDOPTS="$DSO_LDOPTS -woff 85"
		        fi
	        else
		        if test "$USE_64"; then
		            CFLAGS="$CFLAGS -64"
		        else
		            CFLAGS="$CFLAGS -32"
		        fi
	        fi
	        ;;
	    *)
	        CFLAGS="$CFLAGS -xgot"
	        ;;
	    esac
    fi
    if test "${target_os}" = "irix5.3"; then
	    AC_DEFINE(IRIX5_3)
    fi
    case "${target_os}" in
	irix6.5*)
	    if test -z "$GNU_CC"; then
		    CFLAGS="$CFLAGS -mips3"
	    fi
	    AC_DEFINE(_PR_HAVE_GETPROTO_R)
	    AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER)
	    AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
	    ;;
	irix5*)
	    ;;
	*)
	    AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
	    ;;
	esac
    case "${target_cpu}" in
    alpha*)
	    AC_DEFINE(_POSIX_SOURCE)
	    AC_DEFINE(_BSD_SOURCE)
	    ;;
    esac
    ;;

*-linux*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(_POSIX_SOURCE)
    AC_DEFINE(_BSD_SOURCE)
    AC_DEFINE(_SVID_SOURCE)
    AC_DEFINE(LINUX)
    CFLAGS="$CFLAGS -pipe -ansi"
    CXXFLAGS="$CXXFLAGS -pipe -ansi"
    MDCPUCFG_H=_linux.cfg
    PR_MD_CSRCS=linux.c
    MKSHLIB='$(LD) $(DSO_LDOPTS) -soname $(notdir $@) -o $@'
    DSO_CFLAGS=-fPIC
    DSO_LDOPTS=-shared
    OS_LIBS="$OS_LIBS -lc"
    case "${target_cpu}" in
    alpha)
        AC_DEFINE(_ALPHA_)
        AC_DEFINE(__alpha)
        CFLAGS="$CFLAGS -mieee"
        CXXFLAGS="$CXXFLAGS -mieee"
        _OPTIMIZE_FLAGS=-O2
        ;;
    i?86)
        PR_MD_ASFILES=os_Linux_x86.s
        _OPTIMIZE_FLAGS=-O2
        ;;
    m68k)
        _OPTIMIZE_FLAGS=-O
        CFLAGS="$CFLAGS -m68020-40"
        CXXFLAGS="$CXXFLAGS -m68020-40"
        ;;
    *)
        _OPTIMIZE_FLAGS=-O2
        ;;
    esac    
    ;;

*-mingw*|*-cygwin*|*-msvc*)
    AC_DEFINE(XP_PC)
    AC_DEFINE(WIN32)
    PR_MD_ARCH_DIR=windows
    RESOLVE_LINK_SYMBOLS=1

    if test -n "$GNU_CC"; then
        AC_DEFINE(NONAMELESSUNION)
        MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'
    else
        CC=cl
        CXX=cl
        LD=link
        AR='lib -NOLOGO -OUT:"$@"'
        AR_FLAGS=
        RANLIB='echo not_ranlib'
        STRIP='echo not_strip'
        NSINSTALL=nsinstall
        RC=rc.exe
        GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb'
	    OBJ_SUFFIX=obj
	    LIB_SUFFIX=lib
	    DLL_SUFFIX=dll
        
        CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
        _DEBUG_FLAGS=

        if test -n "$MOZ_OPTIMIZE"; then
            CFLAGS="$CFLAGS -MD"
            OPTIMIZER=-O2
            DLLFLAGS='-OUT:"$@"'
            OBJDIR_TAG=_OPT

            if test -n "$MOZ_PROFILE"; then
                OPTIMIZER="$OPTIMIZER -Z7"
                DLLFLAGS="$DLLFLAGS -DEBUG -DEBUGTYPE:CV"
                LDFLAGS="$LDFLAGS -DEBUG -DEBUGTYPE:CV"
            fi
        else
            if test -n "$USE_DEBUG_RTL"; then
                CFLAGS="$CFLAGS -MDd"
            else
                CFLAGS="$CFLAGS -MD"
            fi
            OPTIMIZER="-Od -Z7"
            DLLFLAGS='-DEBUG -DEBUGTYPE:CV -OUT:"$@"'
            if test -n "$GLOWCODE"; then
                DLLFLAGS='-DEBUG -DEBUGTYPE:both -INCLUDE:_GlowCode -OUT:"$@"'
                DLL_LIBS='$(GLOWDIR)/glowcode.lib'
            fi
            OBJDIR_TAG=_DBG
            LDFLAGS="$LDFLAGS -DEBUG -DEBUGTYPE:CV"
            if test -n "$PROFILE"; then
                LDFLAGS="$LDFLAGS -PROFILE -MAP"
                DLLFLAGS="$DLLFLAGS -PROFILE -MAP"
            fi
        fi
        
        if test "$OS_TARGET" = "WINNT"; then
            CFLAGS="$CFLAGS -GT"
            LIBNSPR='$(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
            LIBPLC='$(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
        else
            LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
            LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
        fi
    fi # GNU_CC

    if test -n "$USE_STATIC_TLS"; then
        AC_DEFINE(_PR_USE_STATIC_TLS)
    fi

    if test "$OS_TARGET" = "WINNT"; then
        if test "$CPU_ARCH" = "x86"; then
            CFLAGS="$CFLAGS -G5"
        fi
        AC_DEFINE(WINNT)
    else
        AC_DEFINE(WIN95)
        AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
    fi

    if test "$CPU_ARCH" = "x86"; then
        CPU_ARCH_TAG=
    else
        CPU_ARCH_TAG=$CPU_ARCH
    fi

    if test -n "$USE_DEBUG_RTL"; then
        OBJDIR_SUFFIX=OBJD
    else
        OBJDIR_SUFFIX=OBJ
    fi

    OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
    OBJDIR='${OBJDIR_NAME}'

    OS_DLLFLAGS='-nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE'

    case "$MOZ_WIN32_TARGET" in
    WINNT)
	    MDCPUCFG_H=_winnt.cfg
	    ;;
    WIN95)
	    MDCPUCFG_H=_win95.cfg
	    ;;
    WIN16)
	    MDCPUCFG_H=_win16.cfg
	    ;;
    *)
	    AC_MSG_ERROR([Missing MOZ_WIN32_TARGET for ${target}.  Use --enable-win32-target to set.])
   	;;
    esac

    case "$target_cpu" in
    i?86)
	    AC_DEFINE(_X86_)
        ;;
    alpha)
	    AC_DEFINE(_ALPHA_)
   	    ;;
    mips)
	    AC_DEFINE(_MIPS_)
	    ;;
    *)
	    AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
	    ;;
    esac

    ;;

*-ncr-sysv*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    AC_DEFINE(NCR)
    USE_NSPR_THREADS=1
    if test "$OS_RELEASE" = "2.03"; then
        AC_DEFINE(_PR_STAT_HAS_ST_ATIM)
    else
        AC_DEFINE(_PR_STAT_HAS_ST_ATIM_UNION)
    fi

    if test -z "$GNU_CC"; then
        CFLAGS="$CFLAGS -Hnocopyr"
        CXXFLAGS="$CXXFLAGS -Hnocopyr"
    else
        CFLAGS="$CFLAGS -fPIC -Wall -pipe"
        CXXFLAGS="$CXXFLAGS -fPIC -Wall -pipe"
        DSO_LDOPTS=-G
    fi
    MDCPUCFG_H=_ncr.cfg
    PR_MD_CSRCS=ncr.c
    ;;

mips-nec-sysv*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(__SVR4)
    AC_DEFINE(NEC)
    AC_DEFINE(nec_ews)
    USE_NSPR_THREADS=1
    if test -z "$GNU_CC"; then
        CC='$(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000'
        CXX=g++
    fi
    OS_LIBS="$OS_LIBS -lsocket -lnsl -ldl"
    DSO_LDOPTS=-G
    MDCPUCFG_H=_nec.cfg
    PR_MD_CSRCS=nec.c
    ;;

*-netbsd*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(NETBSD)
    AC_DEFINE(HAVE_BSD_FLOCK)
    USE_NSPR_THREADS=1
    MDCPUCFG_H=_netbsd.cfg
    PR_MD_CSRCS=netbsd.c

    DSO_CFLAGS='-fPIC -DPIC'
    CFLAGS="$CFLAGS -ansi -Wall -pipe"
    CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
    MKSHLIB='$(CC) -o $@ $(DSO_LDOPTS)'

    if test -z "$OBJECT_FMT"; then
        if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ 2>/dev/null; then
            OBJECT_FMT=a.out
            DLL_SUFFIX=so.1.0
            DSO_LDOPTS='-shared'
        else
            OBJECT_FMT=ELF
            DLL_SUFFIX=so
            DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
        fi
    fi

    if test "$LIBRUNPATH"; then
        DSO_LDOPTS="$DSO_LDOPTS -Wl,-R$LIBRUNPATH"
    fi
    ;;

mips-sony-newsos*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SONY)
    AC_DEFINE(SYSV)
    AC_DEFINE(SVR4)
    AC_DEFINE(__svr4)
    AC_DEFINE(__svr4__)
    AC_DEFINE(HAVE_SVID_GETTOD)
    USE_NSPR_THREADS=1
    CFLAGS="$CFLAGS -Xa -fullwarn"
    CXXFLAGS="$CXXFLAGS -Xa -fullwarn"
    DSO_LDOPTS=-G
    MDCPUCFG_H=_sony.cfg
    PR_MD_CSRCS=sony.c
    ;;

*-nextstep*|*-openstep*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(NEXTSTEP)
    AC_DEFINE(HAVE_BSD_FLOCK)
    AC_DEFINE(_POSIX_SOURCE)
    CFLAGS="$CFLAGS -Wall -fno-common -pipe -traditional-cpp -posix"
    CXXFLAGS="$CXXFLAGS -Wall -fno-common -pipe -traditional-cpp -posix"
    USE_NSPR_THREADS=1
    DLL_SUFFIX=dylib
    MDCPUCFG_H=_nextstep.cfg
    PR_MD_CSRCS=nextstep.c
    ;;


*-nto*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(NTO)
    AC_DEFINE(_QNX_SOURCE)
    AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
    MDCPUCFG_H=_nto.cfg
    PR_MD_CSRCS=nto.c
    MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M -o $(@:$(OBJDIR)/%.so=%.so)'
    CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -shared"
    OS_LIBS="$OS_LIBS -lsocket"
    _OPTIMIZE_FLAGS="-O1"
    _DEBUG_FLAGS="-O1 -gstabs"
    COMPILER_TAG="_qcc"
    CC="qcc -Vgcc_ntox86 -w"
    CXX='$(CC)'
    LD="qcc -Vgcc_ntox86 -nostdlib"
    AR="qcc -Vgcc_ntox86 -M -a $@"
    AR_FLAGS=
	;;

*-openbsd*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(OPENBSD)
    AC_DEFINE(HAVE_BSD_FLOCK)
    CFLAGS="$CFLAGS -ansi -Wall -pipe"
    CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
    DLL_SUFFIX=so.1.0
    DSO_CFLAGS=-fPIC
    MDCPUCFG_H=_openbsd.cfg
    PR_MD_CSRCS=openbsd.c
    USE_NSPR_THREADS=1
    case "$OS_TEST" in
    alpha|mips|pmax)
        DSO_LDOPTS=-shared ;;
    *)
        DSO_LDOPTS=-Bshareable ;;
    esac
    ;;

*-openvms*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(VMS)
    AC_DEFINE(VMS_AS_IS)
    AC_DEFINE(_SOCKADDR_LEN)
    AC_DEFINE(GENERIC_PTHREAD_REDEFINES)
    RESOLVE_LINK_SYMBOLS=1
    CROSS_COMPILE=1
    _HAVE_PTHREADS=1
    HOST_CC=c89
    HOST_CXX=cxx
    HOST_CFLAGS=-O
    HOST_CXXFLAGS=-O
    CC=ccc
    CXX=ccc
    CFLAGS="$CFLAGS -Wc,names=\(short,as\)"
    CXXFLAGS="$CXXFLAGS -Wc,names=\(short,as\)"
    MDCPUCFG_H=_openvms.cfg
    PR_MD_CSRCS=openvms.c
    MKSHLIB='vmsld $(OPTIMIZER)'
    ;;

*-osf*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(OSF1)

    if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then
        USE_NSPR_THREADS=1
    fi

    if test -z "$GNU_CC"; then
        CC="$CC -std1 -ieee_with_inexact"
        if test "$OS_RELEASE" = "V2.0"; then
            CC="$CC -readonly_strings"
        fi
        _OPTIMIZE_FLAGS='-Olimit 4000'
    fi

    if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then
        AC_DEFINE(HAVE_INT_LOCALTIME_R)
    else
        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
        AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H)
    fi
    DSO_LDOPTS='-shared -all -expect_unresolved "*" -soname $(notdir $@)'
    MDCPUCFG_H=_osf1.cfg
    PR_MD_CSRCS=osf1.c
    ;;

*-qnx*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(QNX)
    AC_DEFINE(_PR_NEED_H_ERRNO)
    USE_NSPR_THREADS=1
    MDCPUCFG_H=_qnx.cfg
    PR_MD_CSRCS=qnx.c
    ;;

*-rhapsody*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(RHAPSODY)
    AC_DEFINE(HAVE_BSD_FLOCK)
    CFLAGS="$CFLAGS -Wmost -fno-common -pipe"    
    if echo $OS_TEST | grep -c 86 2>/dev/null; then
        CFLAGS="$CFLAGS -mno-486"
        AC_DEFINE(i386)
        CPU_ARCH=i386
    else
        AC_DEFINE(ppc)
        CPU_ARCH=ppc
    fi
    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load'
    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
    DLL_SUFFIX=dylib
    USE_PTHREADS=1
    MDCPUCFG_H=_rhapsody.cfg
    PR_MD_CSRCS=rhapsody.c
    ;;

*-*-sco*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SCO)
    AC_DEFINE(sco)
    AC_DEFINE(SYSV)
    AC_DEFINE(_SVID3)
    AC_DEFINE(_PR_NEED_H_ERRNO)
    CC='cc -b elf -KPIC'
    CXX='$(NSDEPTH)/build/hcpp CC +.cpp +w'
    USE_NSPR_THREADS=1
    CPU_ARCH=x86
    DSO_LDOPTS='-b elf -G'
    MDCPUCFG_H=_scoos.cfg
    PR_MD_SRCS=scoos.c
    ;;

*-sinix*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(SNI)
    AC_DEFINE(RELIANTUNIX)
    AC_DEFINE(sinix)
    AC_DEFINE(HAVE_SVID_GETTOD)
    if echo "$OS_TEST" | grep -c 86 2>/dev/null; then
        AC_DEFINE(i386)
        CPU_ARCH=x86
    else
        CPU_ARCH=mips
    fi

    if test "$GNU_CC"; then
        AS='$(CC) -x assembler-with-cpp'
        if test "$CPU_ARCH" = "mips"; then
            LD=gld
            CFLAGS="$CFLAGS -pipe"
        fi
        CFLAGS="$CFLAGS -Wall -Wno-format"
    else
        AS='/usr/bin/cc'
        _OPTIMIZE_FLAGS='-O -F Olimit,4000'
    fi

    DSO_LDOPTS='-G -z defs -h $(@:$(OBJDIR)/%.so=%.so)'

    if test "$OS_RELEASE" = "5.43"; then
        AC_DEFINE(IP_MULTICAST)
    fi

    OS_LIBS="$OS_LIBS -lsocket -lnsl -lresolv -ldl -lc"
    USE_NSPR_THREADS=1
    MDCPUCFG_H=_reliantunix.cfg
    PR_MD_CSRCS=reliantunix.c
    if test "${OS_ARCH}" = "mips"; then
        PR_MD_ASFILES=os_ReliantUNIX.s
    fi
    ;;

*-sunos*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SUNOS4)
    CFLAGS="$CFLAGS -Wall -Wno-format"
    if test "$USE_MDUPDATE"; then
        CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
    fi
    CPU_ARCH=sparc
    DLL_SUFFIX=so.1.0
    DSO_LDOPTS=
    DSO_CFLAGS=-fPIC
    USE_NSPR_THREADS=1
    if test "$OS_RELEASE" = "4.1.3_U1"; then
        _OPTIMIZE_FLAGS=
        OS_LIBS="$OS_LIBS -lm"
    fi
    MDCPUCFG_H=_sunos4.cfg
    PR_MD_CSRCS=sunos4.c
    ;;

*-solaris*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    AC_DEFINE(__svr4)
    AC_DEFINE(__svr4__)
    AC_DEFINE(SOLARIS)
    if test -n "$USE_64"; then
        MDCPUCFG_H=_solaris64.cfg
    else
        MDCPUCFG_H=_solaris32.cfg
    fi
    PR_MD_CSRCS=solaris.c
    DSO_LDOPTS='-G -h $(notdir $@)'
    if test -n "$GNU_CC"; then
        DSO_CFLAGS=-fPIC
    else
        DSO_CFLAGS=-KPIC
    fi
    AS='$(CC)'
    if test -z "$GNU_AS"; then
        ASFLAGS="$ASFLAGS -Wa,-P"
    fi
    if test -n "$GNU_CC"; then
        if test -n "$USE_MDUPDATE"; then
            CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)"
            CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)"
        fi
    else
        CC="$CC -xstrconst"
        CXX="$CXX -Qoption cg -xstrconst"
    fi
    if test -n "$BUILD_NUMBER" && test -z "$MOZ_OPTIMIZE"; then
        CFLAGS="$CFLAGS -xs"
        CXXFLAGS="$CXXFLAGS -xs"
    fi
    if test -n "$USE_64" && test -z "$GNU_CC"; then
        CC="$CC -xarch=v9"
        CXX="$CXX -xarch=v9"
    fi
    if test "$OS_TEST" = "i86pc"; then
        AC_DEFINE(i386)
        if test -n "$MOZ_DEBUG" && test -n "$GNU_CC"; then
            _DEBUG_FLAGS="$_DEBUG_FLAGS -gstabs"
            if test -z "$GNU_AS"; then
                _DEBUG_FLAGS="$_DEBUG_FLAGS -Wa,-s"
            fi
        fi
    fi
    case "${target_os}" in
    solaris2.3*)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        ;;
    solaris2.4*)
        AC_DEFINE(_PR_NO_LARGE_FILES)
        ;;
    solaris2.5*)
        AC_DEFINE(SOLARIS2_5)    
        ;;
    *)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        if test -n "$GNU_CC"; then
            AC_DEFINE(_LARGEFILE64_SOURCE)
        fi
        ;;
    esac
    if test "$OS_TEST" = "sun4u"; then
        ULTRASPARC_LIBRARY=ultrasparc
        ULTRASPARC_FILTER_LIBRARY=libatomic.so
        DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)'
    fi
    ;;

*-sco-sysv5*)
    AC_DEFINE(XP_UNIX)
    AC_DEFINE(UNIXWARE)
    AC_DEFINE(SVR4)
    AC_DEFINE(SYSV)
    USE_NSPR_THREADS=1
    if echo $OS_RELEASE | grep -c 2.1 2>/dev/null; then
        AC_DEFINE(_PR_NO_LARGE_FILES)
        CC='$(NSDEPTH)/build/hcc cc'
        CXX='$(NSDEPTH)/build/hcpp CC'
        MDCPUCFG_H=_unixware.cfg
    else
        AC_DEFINE(_LARGEFILE64_SOURCE)
        AC_DEFINE(_PR_HAVE_OFF64_T)
        AC_DEFINE(_PR_HAVE_SOCKADDR_LEN)
        MDCPUCFG_H=_unixware7.cfg
    fi
    PR_MD_CSRCS=unixware.c
    DSO_LDOPTS=-G
    CPU_ARCH=x86
    ;;

*-os2*)
    AC_DEFINE(XP_OS2)
    AC_DEFINE(BSD_SELECT)
    AC_DEFINE(XP_PC)
    AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
    OBJ_SUFFIX=obj
    LIB_SUFFIX=lib
    DLL_SUFFIX=dll
    DLLTOOL=''
    RC=rc.exe
    PR_MD_ARCH_DIR=os2
    PROG_SUFFIX=.exe
    NSINSTALL=nsinstall
    MDCPUCFG_H=_os2.cfg
    RESOLVE_LINK_SYMBOLS=1

    case "$target" in
    *-os2_emx)
        AC_DEFINE(XP_OS2_EMX)
        AC_DEFINE(OS2)
        AR=emxomfar
        AR_FLAGS='-p256 r $@'
        CFLAGS="-Zmtd -Zomf"
        HOST_CFLAGS="$CFLAGS"
        CXXFLAGS="-Zmtd -Zomf"
        OS_LIBS="-lsocket -lemxio"
        LD='$(CC)'
        IMPLIB='emximp -o'
        FILTER='emxexp'
        OS_DLLFLAGS='$(DSO_LDOPTS) -o $@'
        _OPTIMIZE_FLAGS=-O3
        _DEBUG_FLAGS=-g
        if test -n "$MOZ_DEBUG"; then
          DLLFLAGS='-g'
          EXEFLAGS='-g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@'
          DSO_LDOPTS='-g -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO'
        else
          DLLFLAGS=
          EXEFLAGS='-Zmtd -o $@'
          DSO_LDOPTS='-Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO'
        fi
        ;;
    *-os2_vacpp)
        AC_DEFINE(XP_OS2_VACPP)
        AC_DEFINE(OS2,4)
        AC_DEFINE(TCPV40HDRS)
        AC_DEFINE(_X86_)
        AR=-ilib
        AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)'
        CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl-'
        HOST_CFLAGS="$CFLAGS"
        OS_CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Ge- /Tl-'
        OS_EXE_CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Ge+ /Tl-'
        CXXFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl-'
        OS_LIBS='so32dll.lib tcp32dll.lib'
        LD='-ilink'
        LDFLAGS='/FREE /DE /NOE /LINENUMBERS /nologo'
        MKSHLIB='$(LD) $(DSO_LDOPTS)'
        IMPLIB='implib -nologo -noignorecase'
        FILTER='cppfilt -q -B -P'
        _OPTIMIZE_FLAGS=/O+
        _DEBUG_FLAGS=/Ti+ 
        if test -n "$MOZ_DEBUG"; then
          DLLFLAGS='/O:$@ /DLL /INC:_dllentry /MAP:$(@:.dll=.map) /nologo /DEBUG /NOE'
          EXEFLAGS='/OUT:$@ /PMTYPE:VIO /MAP:$(@:.exe=.map) /nologo /DEBUG /NOE'
        else
          DLLFLAGS='/O:$@ /DLL /INC:_dllentry /MAP:$(@:.dll=.map) /nologo'
          EXEFLAGS='/OUT:$@ /PMTYPE:VIO /MAP:$(@:.exe=.map) /nologo'
        fi
        LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
        LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
        ;;
    esac

    ;;

*)
    AC_DEFINE(XP_UNIX)
    ;;
   
esac

dnl Turn off shared libraries if asked to do so.
if test "$enable_shared" = no; then
    MKSHLIB=
fi

if test -z "$SKIP_LIBRARY_CHECKS"; then
dnl ========================================================
dnl Check for system libraries
dnl ========================================================
dnl AC_CHECK_LIB(C, main)
dnl AC_CHECK_LIB(C_r, main)
dnl AC_CHECK_LIB(c, main)
dnl AC_CHECK_LIB(c_r, main)
dnl AC_CHECK_LIB(dce, main)
dnl AC_CHECK_LIB(dl, main)
dnl AC_CHECK_LIB(dld, main)
dnl AC_CHECK_LIB(gen, main)
dnl AC_CHECK_LIB(ip6, main)
dnl AC_CHECK_LIB(l, main)
dnl AC_CHECK_LIB(m, main)
dnl AC_CHECK_LIB(nsl, main)
dnl AC_CHECK_LIB(posix4, main)
dnl AC_CHECK_LIB(prstrms, main)
dnl AC_CHECK_LIB(prstrms_shr, main)
dnl AC_CHECK_LIB(pthread, main)
dnl AC_CHECK_LIB(pthreads, main)
dnl AC_CHECK_LIB(resolv, main)
dnl AC_CHECK_LIB(rt, main)
dnl AC_CHECK_LIB(socket, main)
dnl AC_CHECK_LIB(svld, main)
dnl AC_CHECK_LIB(thread, main)
dnl AC_CHECK_LIB(vms_jackets, main)

AC_CHECK_FUNC(dlopen,,[
    AC_CHECK_LIB(dl, dlopen, [OS_LIBS="-ldl $OS_LIBS"])
])

dnl ========================================================
dnl Check for system header files.
dnl ========================================================
dnl AC_HEADER_DIRENT
dnl AC_HEADER_STDC
dnl AC_HEADER_SYS_WAIT
dnl AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h unistd.h)

dnl ========================================================
dnl Check for typedefs and structs
dnl ========================================================
dnl AC_C_CONST
dnl AC_TYPE_UID_T
dnl AC_TYPE_MODE_T
dnl AC_TYPE_OFF_T
dnl AC_TYPE_PID_T
dnl AC_TYPE_SIZE_T
dnl AC_STRUCT_ST_BLKSIZE
dnl AC_STRUCT_ST_BLOCKS
dnl AC_STRUCT_ST_RDEV
dnl AC_HEADER_TIME
dnl AC_STRUCT_TM

dnl ========================================================
dnl Checks for library functions.
dnl ========================================================
AC_PROG_GCC_TRADITIONAL
AC_CHECK_FUNCS(lchown strerror)

dnl AC_FUNC_MEMCMP
dnl AC_FUNC_MMAP
dnl AC_FUNC_SETVBUF_REVERSED
dnl AC_FUNC_STRCOLL
dnl AC_FUNC_STRFTIME
dnl AC_FUNC_UTIME_NULL
dnl AC_FUNC_VPRINTF
dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname)

dnl ========================================================
dnl Check options
dnl ========================================================

dnl
dnl Apparently, some systems cannot properly check for the pthread
dnl library unless <pthread.h> is included so we need to test
dnl using it
dnl
dnl MOZ_CHECK_PTHREADS(lib, success, failure)
AC_DEFUN(MOZ_CHECK_PTHREADS,
[
AC_MSG_CHECKING([for pthread_create in -l$1])
echo "
    #include <pthread.h> 
    void *foo(void *v) { int a = 1;  } 
    int main() { 
        pthread_t t;
        if (!pthread_create(&t, 0, &foo, 0)) {
            pthread_join(t, 0);
        }
        exit(0);
    }" > dummy.c ;
    echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
    ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
    _res=$? ;
    rm -f dummy.c dummy${ac_exeext} ;
    if test "$_res" = "0"; then
        AC_MSG_RESULT([yes])
        [$2]
    else
        AC_MSG_RESULT([no])
        [$3]
    fi
])

MOZ_CHECK_PTHREADS(pthreads,
    _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
    MOZ_CHECK_PTHREADS(pthread,
        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
        MOZ_CHECK_PTHREADS(c_r,
            _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
            MOZ_CHECK_PTHREADS(c,
                _HAVE_PTHREADS=1
            )
        )
    )
)
                        
AC_ARG_WITH(pthreads,
    [  --with-pthreads         Use system pthreads library as thread subsystem],
    [ if test "$withval" = "yes"; then
	    if test -n "$_HAVE_PTHREADS"; then
		    USE_PTHREADS=1 
		    USE_USER_PTHREADS=
		    USE_NSPR_THREADS=
	    else
		    AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
	    fi
	  else
	    USE_PTHREADS=
	    _PTHREAD_LDFLAGS=
	  fi],
	[ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then
	    USE_PTHREADS=1
	    USE_USER_PTHREADS=
	    USE_NSPR_THREADS=
	  fi])

AC_ARG_ENABLE(user-pthreads,
    [  --enable-user-pthreads  Build using userland pthreads],
    [ if test "$enableval" = "yes"; then
        if test -n "$_HAVE_PTHREADS"; then
		    USE_PTHREADS=
		    USE_USER_PTHREADS=1
		    USE_NSPR_THREADS=
	    else
		    AC_MSG_ERROR([ --enable-user-pthreads specified for a system without pthread support ]);
	    fi
	  fi])

AC_ARG_ENABLE(nspr-threads,
    [  --enable-nspr-threads   Build using classic nspr threads],
    [ if test "$enableval" = "yes"; then
	    USE_PTHREADS=
	    USE_USER_PTHREADS=
	    USE_NSPR_THREADS=1
	  fi])

case "$target" in
*-beos*)
    AC_ARG_WITH(bthreads,
    [  --with-bthreads         Use system bthreads library as thread subsystem (BeOS only)],
    [	if test "$withval" = "yes"; then
    	    USE_BTHREADS=1
	        USE_USER_PTHREADS=
	        USE_PTHREADS=
	    fi])
    ;;

*-solaris*)
    AC_ARG_WITH(native-threads,
    [  --with-native-threads   Use native system threads as thread subsystem (Solaris only)],
    [ if test "$withval" = "yes"; then
	    USE_NATIVE_THREADS=1
	    USE_USER_PTHREADS=
	    USE_PTHREADS=
	  fi])
    ;;
esac

fi # SKIP_LIBRARY_CHECKS

AC_ARG_ENABLE(cplus,
    [  --enable-cplus          Enable some c++ api routines],
    [ if test "$enableval" = "yes"; then
	    USE_CPLUS=1
      fi]) 

AC_ARG_ENABLE(ipv6,
    [  --enable-ipv6           Compile ipv6 support],
    [ if test "$enableval" = "yes"; then
	    USE_IPV6=1
      fi])


AC_ARG_ENABLE(boehm,
    [  --enable-boehm          Enable the Boehm Garbage Collector],
    [ if test "$enableval" = "yes"; then
        AC_DEFINE(GC_LEAK_DETECTOR)
        GC_LEAK_DETECTOR=1
    fi])

if test -n "$USE_PTHREADS"; then
   dnl See if -pthread is supported.
   rm -f conftest*
   ac_cv_have_dash_pthread=no
   AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
   echo 'int main() { return 0; }' | cat > conftest.c
   ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
   if test $? -eq 0; then
	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
	    ac_cv_have_dash_pthread=yes
	    CFLAGS="$CFLAGS -pthread"
	    CXXFLAGS="$CXXFLAGS -pthread"
	fi
    fi
    rm -f conftest*
    AC_MSG_RESULT($ac_cv_have_dash_pthread)

	dnl
	dnl See if -pthreads is supported.
	dnl
    ac_cv_have_dash_pthreads=no
    if test "$ac_cv_have_dash_pthread" = "no"; then
	    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
    	echo 'int main() { return 0; }' | cat > conftest.c
	    ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
    	if test $? -eq 0; then
	    	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
			    ac_cv_have_dash_pthreads=yes
			    CFLAGS="$CFLAGS -pthreads"
			    CXXFLAGS="$CXXFLAGS -pthreads"
		    fi
	    fi
	    rm -f conftest*
    	AC_MSG_RESULT($ac_cv_have_dash_pthreads)
    fi

    case "$target" in
    *-mingw*|*-cygwin*|*-uwin*|*-msvc*)
	    ;;
    *-solaris*)
	    AC_DEFINE(_REENTRANT)
        if test "$ac_cv_have_dash_pthreads" = "yes"; then
            _PTHREAD_LDFLAGS=
        fi
	    ;;
    *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
	    AC_DEFINE(_REENTRANT)
	    AC_DEFINE(_THREAD_SAFE)
	    dnl -pthread links in -lc_r, so don't specify it explicitly.
	    if test "$ac_cv_have_dash_pthread" = "yes"; then
	        _PTHREAD_LDFLAGS=
	    fi
	    ;;
    *)
	    AC_DEFINE(_REENTRANT)
	    ;;
    esac

else 
    if test -n "$USE_USER_PTHREADS"; then
	    USE_PTHREADS=
	    USE_NSPR_THREADS=
    else
        _PTHREAD_LDFLAGS=
        if test -n "$USE_NSPR_THREADS"; then
    	    AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
        fi
    fi
fi
dnl Special thread exceptions

case "$target" in
*-aix*)
    if test -n "$USE_NSPR_THREADS"; then
        OS_LIBS="$OS_LIBS -lc"
    else
        OS_LIBS="$OS_LIBS -lc_r"
    fi
    case "$target_os" in
    aix4.1*)
        if test -z "$USE_PTHREADS"; then
            AC_DEFINE(AIX_RENAME_SELECT)
        fi
        ;;
    aix4.[23]*)
        if test -z "$USE_NSPR_THREADS"; then
            AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
        fi
        ;;
    esac
    ;;
*-bsdi*)
    if test -n "$USE_PTHREADS"; then
        AC_DEFINE(_PR_NEED_PTHREAD_INIT)
    fi
    ;;
*-hpux*)
    if test "$USE_PTHREADS"; then
        if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
            AC_DEFINE(REENTRANT)
            AC_DEFINE(_PR_DCETHREADS)
        else
            AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
        fi
    fi
    if test "$USE_USER_PTHREADS"; then
        AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
    fi
    ;;
*-mingw*|*-cygwin*|*-uwin*|*-msvc*)
    dnl win32 does not use pthreads
    USE_PTHREADS=
    _PTHREAD_LDFLAGS=
    USE_USER_PTHREADS=
    ;;
*-solaris*)
    if test -n "$USE_NATIVE_THREADS"; then
        AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
    else
        if test -n "$USE_USER_PTHREADS"; then
            AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
        fi
    fi
    if test -z "$USE_USER_PTHREADS"; then
        AC_DEFINE(_REENTRANT)
        AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
        if test "$OS_TEST" = "i86pc"; then
            PR_MD_ASFILES=os_SunOS_x86.s
        else
            PR_MD_ASFILES=os_SunOS.s
            if test -z "$USE_64"; then
                PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_32.s"
            fi
        fi
    fi
    ;;
esac

OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"

dnl If the user passed in arg to --enable-optimize,
dnl make sure that we use it.
if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
    _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
fi

if test -n "$MOZ_OPTIMIZE"; then
    CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS"
    CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
fi

if test -n "$MOZ_DEBUG"; then
    CFLAGS="$CFLAGS $_DEBUG_FLAGS"
    CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
fi

dnl ========================================================
dnl Substitution of found variables.
dnl ========================================================
AC_SUBST(MOZILLA_CLIENT)
AC_SUBST(CC)
AC_SUBST(CXX)
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(HOST_CC)
AC_SUBST(HOST_CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(GNU_CC)
AC_SUBST(CROSS_COMPILE)

AC_SUBST(MOZ_OPTIMIZE)

AC_SUBST(USE_CPLUS)
AC_SUBST(USE_IPV6)
AC_SUBST(USE_N32)
AC_SUBST(USE_64)
AC_SUBST(GC_LEAK_DETECTOR)

AC_SUBST(USE_PTHREADS)
AC_SUBST(USE_BTHREADS)
AC_SUBST(USE_USER_PTHREADS)
AC_SUBST(USE_NATIVE_THREADS)
AC_SUBST(USE_NSPR_THREADS)

AC_SUBST(LIBNSPR)
AC_SUBST(LIBPLC)

AC_SUBST(MOD_MAJOR_VERSION)
AC_SUBST(MOD_MINOR_VERSION)
AC_SUBST(MOD_REVISION_VERSION)
AC_SUBST(NSPR_MODNAME)
AC_SUBST(MDCPUCFG_H)
AC_SUBST(MOZ_WIN32_TARGET)
AC_SUBST(PR_MD_CSRCS)
AC_SUBST(PR_MD_ASFILES)
AC_SUBST(PR_MD_ARCH_DIR)
AC_SUBST(CPU_ARCH)

AC_SUBST(OBJ_SUFFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(DLL_SUFFIX)
AC_SUBST(MKSHLIB)
AC_SUBST(DSO_CFLAGS)
AC_SUBST(DSO_LDOPTS)

AC_SUBST(OS_TARGET)
AC_SUBST(OS_ARCH)
AC_SUBST(OS_RELEASE)
AC_SUBST(OS_TEST)

AC_SUBST(DEFINES)
AC_SUBST(DEFS)
AC_SUBST(AR)
AC_SUBST(AR_FLAGS)
AC_SUBST(AS)
AC_SUBST(ASFLAGS)
AC_SUBST(LD)
AC_SUBST(DLLTOOL)
AC_SUBST(WINDRES)
AC_SUBST(RANLIB)
AC_SUBST(PERL)
AC_SUBST(STRIP)
AC_SUBST(FILTER)
AC_SUBST(IMPLIB)

AC_SUBST(OS_LIBS)
AC_SUBST(RESOLVE_LINK_SYMBOLS)
AC_SUBST(AIX_LINK_OPTS)
AC_SUBST(NOSUCHFILE)
AC_SUBST(MOZ_OBJFORMAT)
AC_SUBST(ULTRASPARC_LIBRARY)
AC_SUBST(ULTRASPARC_FILTER_LIBRARY)

AC_SUBST(OBJDIR)
AC_SUBST(OBJDIR_NAME)
AC_SUBST(NSINSTALL)
AC_SUBST(OPTIMIZER)
AC_SUBST(RC)
AC_SUBST(CPU_ARCH_TAG)
AC_SUBST(DLLFLAGS)
AC_SUBST(EXEFLAGS)
AC_SUBST(OS_DLLFLAGS)

dnl ========================================================
dnl Generate output files.
dnl ========================================================
MAKEFILES="
Makefile 
config/Makefile
config/autoconf.mk
config/nsprincl.mk
config/nsprincl.sh
config/nspr-config
lib/Makefile 
lib/ds/Makefile 
lib/libc/Makefile 
lib/libc/include/Makefile 
lib/libc/src/Makefile 
pr/Makefile 
pr/include/Makefile 
pr/include/md/Makefile 
pr/include/obsolete/Makefile 
pr/include/private/Makefile 
pr/src/Makefile 
pr/src/io/Makefile 
pr/src/linking/Makefile 
pr/src/malloc/Makefile 
pr/src/md/Makefile 
pr/src/md/${PR_MD_ARCH_DIR}/Makefile 
pr/src/memory/Makefile 
pr/src/misc/Makefile 
pr/src/threads/Makefile 
pr/tests/Makefile 
pr/tests/dll/Makefile 
"

dnl lib/tests/Makefile
dnl pr/tests/w16gui/Makefile
dnl tools/Makefile

if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then
    MAKEFILES="$MAKEFILES pr/src/threads/combined/Makefile"
elif test -n "$USE_PTHREADS"; then
    MAKEFILES="$MAKEFILES pr/src/pthreads/Makefile"
elif test -n "$USE_BTHREADS"; then
    MAKEFILES="$MAKEFILES pr/src/bthreads/Makefile"
fi

if test -n "$USE_CPLUS"; then
    MAKEFILES="$MAKEFILES pr/src/cplus/Makefile pr/src/cplus/tests/Makefile"
fi

AC_OUTPUT([$MAKEFILES], [chmod +x config/nspr-config])