aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/Makefile.in
blob: 72a72dd86981b04911755c900e1f39e719f39f38 (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
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
# Makefile for GNU Ada Compiler (GNAT).
#   Copyright (C) 1994-2002 Free Software Foundation, Inc.

#This file is part of GNU CC.

#GNU CC is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2, or (at your option)
#any later version.

#GNU CC is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with GNU CC; see the file COPYING.  If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330,
#Boston, MA 02111-1307, USA.

# The makefile built from this file lives in the language subdirectory.
# It's purpose is to provide support for:
#
# 1) recursion where necessary, and only then (building .o's), and
# 2) building and debugging cc1 from the language subdirectory, and
# 3) nothing else.
#
# The parent makefile handles all other chores, with help from the
# language makefile fragment, of course.
#
# The targets for external use are:
# all, TAGS, ???mostlyclean, ???clean.

# This makefile will only work with Gnu make.
# The rules are written assuming a minimum subset of tools are available:
#
# Required:
#      MAKE:    Only Gnu make will work.
#      MV:      Must accept (at least) one, maybe wildcard, source argument,
#               a file or directory destination, and support creation/
#               modification date preservation.  Gnu mv -f works.
#      RM:      Must accept an arbitrary number of space separated file
#               arguments, or one wildcard argument. Gnu rm works.
#      RMDIR:   Must delete a directory and all its contents. Gnu rm -rf works.
#      ECHO:    Must support command line redirection. Any Unix-like
#               shell will typically provide this, otherwise a custom version
#               is trivial to write.
#      AR:      Gnu ar works.
#      MKDIR:   Gnu mkdir works.
#      CHMOD:   Gnu chmod works.
#      true:    Does nothing and returns a normal successful return code.
#      pwd:     Prints the current directory on stdout.
#      cd:      Change directory.
#
# Optional:
#      BISON:   Gnu bison works.
#      FLEX:    Gnu flex works.
#      Other miscellaneous tools for obscure targets.

# Tell GNU make 3.79 not to run this directory in parallel.
# Not all of the required dependencies are present.
.NOTPARALLEL:

# Suppress smart makes who think they know how to automake Yacc files
.y.c:

# Variables that exist for you to override.
# See below for how to change them for certain systems.

# Various ways of specifying flags for compilations:  
# CFLAGS is for the user to override to, e.g., do a bootstrap with -O2.
# BOOT_CFLAGS is the value of CFLAGS to pass
# to the stage2 and stage3 compilations
# XCFLAGS is used for most compilations but not when using the GCC just built.
XCFLAGS =
CFLAGS = -g
BOOT_CFLAGS = -O $(CFLAGS)
# These exists to be overridden by the x-* and t-* files, respectively.
X_CFLAGS =
T_CFLAGS =

X_CPPFLAGS =
T_CPPFLAGS =

X_ADA_CFLAGS =
T_ADA_CFLAGS =

X_ADAFLAGS =
T_ADAFLAGS =

CC = cc
# Let the configure setting prevail only if CC hasn't been overridden
# to xgcc by the top level Makefile (in a later stage of bootstrap).
ifeq ($(findstring xgcc, $(CC)),)
ADAC = @ADAC@
else
ADAC = $(CC)
endif

BISON = bison
BISONFLAGS =
ECHO = echo
LEX = flex
LEXFLAGS =
CHMOD = chmod
CP = cp -p
MV = mv -f
RM = rm -f
RMDIR = rm -rf
MKDIR = mkdir -p
AR = ar
AR_FLAGS = rc
# How to invoke ranlib.
RANLIB = ranlib
# Test to use to see whether ranlib exists on the system.
RANLIB_TEST = [ -f /usr/bin/ranlib -o -f /bin/ranlib ]
SHELL = @SHELL@
PWD = $${PWDCMD-pwd}
# How to copy preserving the date
INSTALL_DATA_DATE = cp -p
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
GNATBIND = $(STAGE_PREFIX)gnatbind -C
GNATBIND_FLAGS = -static -x
ADA_CFLAGS =
ADAFLAGS = -W -Wall -gnatpg -gnata
SOME_ADAFLAGS =-gnata
FORCE_DEBUG_ADAFLAGS = -g
GNATLIBFLAGS = -gnatpg
GNATLIBCFLAGS = -g -O2
GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
	-DIN_RTS
ALL_ADA_CFLAGS = $(X_ADA_CFLAGS) $(T_ADA_CFLAGS) $(ADA_CFLAGS)
ALL_ADAFLAGS = $(CFLAGS) $(ALL_ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \
	$(ADAFLAGS)
MOST_ADAFLAGS = $(CFLAGS) $(ALL_ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \
	$(SOME_ADAFLAGS)
THREAD_KIND = native
THREADSLIB =
GMEM_LIB =
MISCLIB =

objext = .o
exeext =
arext  = .a
soext  = .so
shext  =

HOST_CC=$(CC)
HOST_CFLAGS=$(ALL_CFLAGS)
HOST_CLIB=$(CLIB)
HOST_LDFLAGS=$(LDFLAGS)
HOST_CPPFLAGS=$(ALL_CPPFLAGS)
HOST_ALLOCA=$(ALLOCA)
HOST_MALLOC=$(MALLOC)
HOST_OBSTACK=$(OBSTACK)

# Define this as & to perform parallel make on a Sequent.
# Note that this has some bugs, and it seems currently necessary 
# to compile all the gen* files first by hand to avoid erroneous results.
P =

# This is used instead of ALL_CFLAGS when compiling with GCC_FOR_TARGET.
# It omits XCFLAGS, and specifies -B./.
# It also specifies -B$(tooldir)/ to find as and ld for a cross compiler.
GCC_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS)

# Tools to use when building a cross-compiler.
# These are used because `configure' appends `cross-make'
# to the makefile when making a cross-compiler.

# We don't use cross-make.  Instead we use the tools from the build tree,
# if they are available.
# program_transform_name and objdir are set by configure.in.
program_transform_name =
objdir = .

target=@target@
target_alias=@target_alias@
xmake_file=@dep_host_xmake_file@
tmake_file=@dep_tmake_file@
host_canonical=@host_canonical@
#version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < $(srcdir)/version.c`
#mainversion=`sed -e 's/.*\"\([0-9]*\.[0-9]*\).*/\1/' < $(srcdir)/version.c`

# Directory where sources are, from where we are.
srcdir = @srcdir@
VPATH = @srcdir@

fsrcdir := $(shell cd $(srcdir);${PWD})
fsrcpfx := $(shell cd $(srcdir);${PWD})/
fcurdir := $(shell ${PWD})
fcurpfx := $(shell ${PWD})/

# Top build directory, relative to here.
top_builddir = ..

# Internationalization library.
INTLLIBS = @INTLLIBS@
INTLDEPS = @INTLDEPS@

# Any system libraries needed just for GNAT.
SYSLIBS = @GNAT_LIBEXC@

# List of extra object files linked in with various programs.
EXTRA_GNATTOOLS_OBJS = ../prefix.o

# List extra gnattools
EXTRA_GNATTOOLS =

# End of variables for you to override.

# Definition of `all' is here so that new rules inserted by sed
# do not specify the default target.
all: all.indirect

# This tells GNU Make version 3 not to put all variables in the environment.
.NOEXPORT:

# sed inserts variable overrides after the following line.
####target overrides
@target_overrides@

####host overrides
@host_overrides@

# Now figure out from those variables how to compile and link.

all.indirect: Makefile ../gnat1$(exeext)

# IN_GCC distinguishes between code compiled into GCC itself and other
# programs built during a bootstrap.
# autoconf inserts -DCROSS_COMPILE if we are building a cross compiler.
INTERNAL_CFLAGS = @CROSS@ -DIN_GCC

# This is the variable actually used when we compile.
LOOSE_CFLAGS = `echo $(CFLAGS) $(WARN2_CFLAGS)|sed -e 's/-pedantic//g' -e 's/-Wtraditional//g'`
ALL_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(LOOSE_CFLAGS) \
	$(XCFLAGS)

# Likewise.
ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS)

# This is where we get libiberty.a from.
LIBIBERTY = ../../libiberty/libiberty.a

# How to link with both our special library facilities
# and the system's installed libraries.
LIBS = $(INTLLIBS) $(LIBIBERTY) $(SYSLIBS)
LIBDEPS = $(INTLDEPS) $(LIBIBERTY)
TOOLS_LIBS = ../../prefix.o $(LIBGNAT) ../../../libiberty/libiberty.a \
	$(SYSLIBS)

# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order,
# so that tm.h and config.h will be found in the compilation
# subdirectory rather than in the source directory.
INCLUDES = -I- -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config \
	-I$(srcdir)/../../include

ADA_INCLUDES = -I- -I. -I$(srcdir)

INCLUDES_FOR_SUBDIR = -I. -I.. -I../.. -I$(fsrcdir) \
	-I$(fsrcdir)/.. -I$(fsrcdir)/../config -I$(fsrcdir)/../../include
ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)

# Avoid a lot of time thinking about remaking Makefile.in and *.def.
.SUFFIXES: .in .def

# Say how to compile Ada programs.
.SUFFIXES: .ada .adb .ads

# Always use -I$(srcdir)/config when compiling.
.c.o:
	$(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
.adb.o:
	$(ADAC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $<
.ads.o:
	$(ADAC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $<

# This tells GNU make version 3 not to export all the variables
# defined in this file into the environment.
.NOEXPORT:

# Lists of files for various purposes.

# Object files for gnat executables
GNATLINK_OBJS = gnatlink.o link.o \
 ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o gnatvsn.o \
 hostparm.o namet.o opt.o osint.o output.o rident.o sdefault.o stylesw.o \
 switch.o table.o tree_io.o types.o validsw.o widechar.o

GNATMAKE_OBJS = ali.o ali-util.o \
 alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o einfo.o elists.o \
 errout.o fmap.o fname.o fname-uf.o fname-sf.o \
 gnatmake.o gnatvsn.o hostparm.o krunch.o lib.o make.o makeusg.o \
 mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o mlib-utl.o \
 namet.o nlists.o opt.o osint.o osint-m.o output.o \
 prj.o prj-attr.o prj-com.o prj-dect.o prj-env.o prj-ext.o prj-nmsc.o \
 prj-pars.o prj-part.o prj-proc.o prj-strt.o prj-tree.o prj-util.o \
 rident.o scans.o scn.o sdefault.o sfn_scan.o sinfo.o sinfo-cn.o \
 sinput.o sinput-l.o sinput-p.o \
 snames.o stand.o stringt.o style.o stylesw.o validsw.o switch.o switch-m.o \
 switch-c.o table.o targparm.o tree_io.o types.o \
 uintp.o uname.o urealp.o usage.o widechar.o

# Convert the target variable into a space separated list of architecture,
# manufacturer, and operating system and assign each of those to its own
# variable.

host:=$(subst -, ,$(host_canonical))
targ:=$(subst -, ,$(target))
arch:=$(word 1,$(targ))
ifeq ($(words $(targ)),2)
  manu:=
  osys:=$(word 2,$(targ))
else
  manu:=$(word 2,$(targ))
  osys:=$(word 3,$(targ))
endif

# LIBGNAT_TARGET_PAIRS is a list of pairs of filenames.
# The members of each pair must be separated by a '<' and no whitespace.
# Each pair must be separated by some amount of whitespace from the following
# pair.

# Non-tasking case:

LIBGNAT_TARGET_PAIRS = \
a-intnam.ads<4nintnam.ads \
s-inmaop.adb<5ninmaop.adb \
s-intman.adb<5nintman.adb \
s-osinte.ads<5nosinte.ads \
s-osprim.adb<7sosprim.adb \
s-taprop.adb<5ntaprop.adb \
s-taspri.ads<5ntaspri.ads

# Default shared object option. Note that we rely on the fact that the "soname"
# option will always be present and last in this flag, so that we can have
# $(SO_OPTS)libgnat-x.xx

SO_OPTS = -Wl,-soname,

# Default gnatlib-shared target.
# This is needed on some targets to use a different gnatlib-shared target, e.g
# gnatlib-shared-dual
GNATLIB_SHARED = gnatlib-shared-default

# default value for gnatmake's target dependent file
MLIB_TGT = mlib-tgt

# $(filter-out PATTERN...,TEXT) removes all PATTERN words from TEXT.
# $(strip STRING) removes leading and trailing spaces from STRING.
# If what's left is null then it's a match.

ifeq ($(strip $(filter-out %86 os2 OS2 os2_emx,$(arch) $(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-excpol.adb<4wexcpol.adb \
  a-intnam.ads<4nintnam.ads \
  a-numaux.adb<86numaux.adb \
  a-numaux.ads<86numaux.ads \
  s-inmaop.adb<5ninmaop.adb \
  s-interr.adb<5ointerr.adb \
  s-intman.adb<5nintman.adb \
  s-mastop.adb<5omastop.adb \
  s-osinte.adb<5oosinte.adb \
  s-osinte.ads<5oosinte.ads \
  s-osprim.adb<5oosprim.adb \
  s-parame.adb<5oparame.adb \
  system.ads<5osystem.ads \
  s-taprop.adb<5otaprop.adb \
  s-taspri.ads<5otaspri.ads

  EXTRA_GNATRTL_NONTASKING_OBJS = \
  i-os2err.o \
  i-os2lib.o \
  i-os2syn.o \
  i-os2thr.o
endif

ifeq ($(strip $(filter-out %86 interix%,$(arch) $(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-excpol.adb<4hexcpol.adb \
  a-intnam.ads<4pintnam.ads \
  a-numaux.adb<86numaux.adb \
  a-numaux.ads<86numaux.ads \
  g-soccon.ads<3psoccon.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<7sintman.adb \
  s-mastop.adb<5omastop.adb \
  s-osinte.adb<7sosinte.adb \
  s-osinte.ads<5posinte.ads \
  s-osprim.adb<5posprim.adb \
  s-taprop.adb<7staprop.adb \
  system.ads<5psystem.ads \
  s-taspri.ads<7staspri.ads \
  s-tpopsp.adb<7stpopsp.adb

  THREADSLIB = -lgthreads -lmalloc
endif

# sysv5uw is SCO UnixWare 7
ifeq ($(strip $(filter-out %86 sysv5uw%,$(arch) $(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-excpol.adb<4wexcpol.adb \
  a-intnam.ads<41intnam.ads \
  a-numaux.adb<86numaux.adb \
  a-numaux.ads<86numaux.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<7sintman.adb \
  s-mastop.adb<5omastop.adb \
  s-osinte.ads<51osinte.ads \
  s-osinte.adb<51osinte.adb \
  s-osprim.adb<5posprim.adb \
  s-taprop.adb<7staprop.adb \
  s-taspri.ads<7staspri.ads \
  s-tpopsp.adb<5atpopsp.adb \
  system.ads<51system.ads \
  g-soccon.ads<31soccon.ads \
  g-soliop.ads<31soliop.ads

  THREADSLIB = -lthread
  SO_OPTS = -Wl,-h,
  GNATLIB_SHARED = gnatlib-shared-dual
  LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/'))
endif

ifeq ($(strip $(filter-out alpha% dec vx%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-sytaco.ads<4zsytaco.ads \
  a-sytaco.adb<4zsytaco.adb \
  a-intnam.ads<4zintnam.ads \
  a-numaux.ads<4znumaux.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-interr.adb<5zinterr.adb \
  s-intman.adb<5zintman.adb \
  s-osinte.adb<5zosinte.adb \
  s-osinte.ads<5zosinte.ads \
  s-osprim.adb<5zosprim.adb \
  s-taprop.adb<5ztaprop.adb \
  s-taspri.ads<5ztaspri.ads \
  s-vxwork.ads<5avxwork.ads \
  g-soccon.ads<3zsoccon.ads \
  g-socthi.ads<3zsocthi.ads \
  g-socthi.adb<3zsocthi.adb \
  system.ads<5zsystem.ads

  EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o i-vxwoio.o
  EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o
endif

ifeq ($(strip $(filter-out m68k% wrs vx%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-sytaco.ads<4zsytaco.ads \
  a-sytaco.adb<4zsytaco.adb \
  a-intnam.ads<4zintnam.ads \
  a-numaux.ads<4znumaux.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-interr.adb<5zinterr.adb \
  s-intman.adb<5zintman.adb \
  s-osinte.adb<5zosinte.adb \
  s-osinte.ads<5zosinte.ads \
  s-osprim.adb<5zosprim.adb \
  s-taprop.adb<5ztaprop.adb \
  s-taspri.ads<5ztaspri.ads \
  s-vxwork.ads<5kvxwork.ads \
  g-soccon.ads<3zsoccon.ads \
  g-socthi.ads<3zsocthi.ads \
  g-socthi.adb<3zsocthi.adb \
  system.ads<5ksystem.ads

  EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o i-vxwoio.o
  EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o

  ifeq ($(strip $(filter-out yes,$(TRACE))),)
    LIBGNAT_TARGET_PAIRS += \
    s-traces.adb<7straces.adb \
    s-tratas.adb<7stratas.adb \
    s-trafor.adb<7strafor.adb \
    s-trafor.ads<7strafor.ads \
    s-tfsetr.adb<5ztfsetr.adb 
  endif
endif

ifeq ($(strip $(filter-out powerpc% wrs vx%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-sytaco.ads<4zsytaco.ads \
  a-sytaco.adb<4zsytaco.adb \
  a-intnam.ads<4zintnam.ads \
  a-numaux.ads<4znumaux.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-interr.adb<5zinterr.adb \
  s-intman.adb<5zintman.adb \
  s-osinte.adb<5zosinte.adb \
  s-osinte.ads<5zosinte.ads \
  s-osprim.adb<5zosprim.adb \
  s-taprop.adb<5ztaprop.adb \
  s-taspri.ads<5ztaspri.ads \
  s-vxwork.ads<5pvxwork.ads \
  g-soccon.ads<3zsoccon.ads \
  g-socthi.ads<3zsocthi.ads \
  g-socthi.adb<3zsocthi.adb \
  system.ads<5ysystem.ads

  EXTRA_RAVEN_SOURCES=i-vxwork.ads s-vxwork.ads
  EXTRA_RAVEN_OBJS=i-vxwork.o s-vxwork.o
  EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o
  EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o
endif

ifeq ($(strip $(filter-out sparc% wrs vx%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-sytaco.ads<4zsytaco.ads \
  a-sytaco.adb<4zsytaco.adb \
  a-intnam.ads<4zintnam.ads \
  a-numaux.ads<4znumaux.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-interr.adb<5zinterr.adb \
  s-intman.adb<5zintman.adb \
  s-osinte.adb<5zosinte.adb \
  s-osinte.ads<5zosinte.ads \
  s-osprim.adb<5zosprim.adb \
  s-taprop.adb<5ztaprop.adb \
  s-taspri.ads<7staspri.ads \
  s-vxwork.ads<5svxwork.ads \
  system.ads<5ysystem.ads

  EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o
  EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o
endif

ifeq ($(strip $(filter-out mips% wrs vx%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-sytaco.ads<4zsytaco.ads \
  a-sytaco.adb<4zsytaco.adb \
  a-intnam.ads<4zintnam.ads \
  a-numaux.ads<4znumaux.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-interr.adb<5zinterr.adb \
  s-intman.adb<5zintman.adb \
  s-osinte.adb<5zosinte.adb \
  s-osinte.ads<5zosinte.ads \
  s-osprim.adb<5zosprim.adb \
  s-taprop.adb<5ztaprop.adb \
  s-taspri.ads<7staspri.ads \
  s-vxwork.ads<5mvxwork.ads \
  system.ads<5zsystem.ads

  EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o
  EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o
endif

ifeq ($(strip $(filter-out sparc sun solaris2% sunos5%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-intnam.ads<4sintnam.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<5sintman.adb \
  s-osinte.adb<5sosinte.adb \
  s-osinte.ads<5sosinte.ads \
  s-osprim.adb<5posprim.adb \
  s-parame.adb<5sparame.adb \
  s-taprop.adb<5staprop.adb \
  s-tasinf.adb<5stasinf.adb \
  s-tasinf.ads<5stasinf.ads \
  s-taspri.ads<5staspri.ads \
  s-tpopse.adb<5stpopse.adb \
  g-soccon.ads<3ssoccon.ads \
  g-soliop.ads<3ssoliop.ads \
  system.ads<5ssystem.ads

  THREADSLIB = -lposix4 -lthread
  MISCLIB = -lposix4 -lnsl -lsocket
  SYMLIB = -laddr2line -lbfd $(INTLLIBS)
  SO_OPTS = -Wl,-h,
  GNATLIB_SHARED = gnatlib-shared-dual
  GMEM_LIB = gmemlib
  LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/'))

  ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),)
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<4sintnam.ads \
    s-inmaop.adb<7sinmaop.adb \
    s-intman.adb<5sintman.adb \
    s-osinte.adb<7sosinte.adb \
    s-osinte.ads<5tosinte.ads \
    s-osprim.adb<5posprim.adb \
    s-taprop.adb<7staprop.adb \
    s-taspri.ads<7staspri.ads \
    s-tpopsp.adb<7stpopsp.adb \
    g-soccon.ads<3ssoccon.ads \
    g-soliop.ads<3ssoliop.ads \
    system.ads<5ssystem.ads

    THREADSLIB = -lgthreads -lmalloc
  endif

  ifeq ($(strip $(filter-out pthread PTHREAD,$(THREAD_KIND))),)
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<4sintnam.ads \
    s-inmaop.adb<7sinmaop.adb \
    s-intman.adb<7sintman.adb \
    s-osinte.adb<5iosinte.adb \
    s-osinte.ads<54osinte.ads \
    s-osprim.adb<5posprim.adb \
    s-taprop.adb<7staprop.adb \
    s-taspri.ads<7staspri.ads \
    s-tpopsp.adb<5atpopsp.adb \
    g-soccon.ads<3ssoccon.ads \
    g-soliop.ads<3ssoliop.ads \
    system.ads<5ssystem.ads

    THREADSLIB = -lposix4 -lpthread
  endif
endif

ifeq ($(strip $(filter-out %86 solaris2%,$(arch) $(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-numaux.adb<86numaux.adb \
  a-numaux.ads<86numaux.ads \
  a-intnam.ads<4sintnam.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<5sintman.adb \
  s-mastop.adb<5omastop.adb \
  s-osinte.adb<5sosinte.adb \
  s-osinte.ads<5sosinte.ads \
  s-osprim.adb<5posprim.adb \
  s-parame.adb<5sparame.adb \
  s-taprop.adb<5staprop.adb \
  s-tasinf.adb<5stasinf.adb \
  s-tasinf.ads<5stasinf.ads \
  s-taspri.ads<5staspri.ads \
  s-tpopse.adb<5etpopse.adb \
  g-soccon.ads<3ssoccon.ads \
  g-soliop.ads<3ssoliop.ads \
  system.ads<5esystem.ads

  THREADSLIB = -lposix4 -lthread
  MISCLIB = -lposix4 -lnsl -lsocket
  SO_OPTS = -Wl,-h,
  GNATLIB_SHARED = gnatlib-shared-dual
  LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/'))
endif

ifeq ($(strip $(filter-out %86 linux%,$(arch) $(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-intnam.ads<4lintnam.ads \
  a-numaux.adb<86numaux.adb \
  a-numaux.ads<86numaux.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<5lintman.adb \
  s-mastop.adb<5omastop.adb \
  s-osinte.adb<5iosinte.adb \
  s-osinte.ads<5iosinte.ads \
  s-osprim.adb<7sosprim.adb \
  s-taprop.adb<5itaprop.adb \
  s-taspri.ads<5itaspri.ads \
  s-tpopsp.adb<5atpopsp.adb \
  system.ads<5lsystem.ads

  TOOLS_TARGET_PAIRS = mlib-tgt.adb<5lml-tgt.adb
  SYMLIB = -laddr2line -lbfd $(INTLLIBS)
  THREADSLIB = -lpthread
  GNATLIB_SHARED = gnatlib-shared-dual
  GMEM_LIB = gmemlib
  LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/'))

  ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),)
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<4lintnam.ads \
    a-numaux.adb<86numaux.adb \
    a-numaux.ads<86numaux.ads \
    s-inmaop.adb<7sinmaop.adb \
    s-intman.adb<5lintman.adb \
    s-mastop.adb<5omastop.adb \
    s-osinte.adb<7sosinte.adb \
    s-osinte.ads<5losinte.ads \
    s-osprim.adb<7sosprim.adb \
    s-taprop.adb<7staprop.adb \
    s-taspri.ads<7staspri.ads \
    s-tpopsp.adb<7stpopsp.adb \
    system.ads<5lsystem.ads

    THREADSLIB = -lgthreads -lmalloc
  endif

  ifeq ($(strip $(filter-out rt-linux RT-LINUX,$(THREAD_KIND))),)
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<4nintnam.ads \
    s-inmaop.adb<5ninmaop.adb \
    s-intman.adb<5nintman.adb \
    s-osinte.adb<5qosinte.adb \
    s-osinte.ads<5qosinte.ads \
    s-osprim.adb<5qosprim.adb \
    s-stache.adb<5qstache.adb \
    s-taprop.adb<5qtaprop.adb \
    s-taspri.ads<5qtaspri.ads \
    system.ads<5lsystem.ads

    RT_FLAGS = -D__RT__
  endif
endif

ifeq ($(strip $(filter-out mips sgi irix%,$(targ))),)
  ifeq ($(strip $(filter-out mips sgi irix6%,$(targ))),)
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<4gintnam.ads \
    s-inmaop.adb<7sinmaop.adb \
    s-intman.adb<5fintman.adb \
    s-mastop.adb<5gmastop.adb \
    s-osinte.adb<5aosinte.adb \
    s-osinte.ads<5fosinte.ads \
    s-osprim.adb<7sosprim.adb \
    s-proinf.adb<5gproinf.adb \
    s-proinf.ads<5gproinf.ads \
    s-taprop.adb<5ftaprop.adb \
    s-tasinf.ads<5ftasinf.ads \
    s-taspri.ads<7staspri.ads \
    s-traceb.adb<7straceb.adb \
    g-soccon.ads<3gsoccon.ads \
    system.ads<5gsystem.ads

    THREADSLIB = -lpthread

  else
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<4gintnam.ads \
    s-inmaop.adb<5ninmaop.adb \
    s-interr.adb<5ginterr.adb \
    s-intman.adb<5gintman.adb \
    s-mastop.adb<5gmastop.adb \
    s-osinte.adb<5aosinte.adb \
    s-osinte.ads<5gosinte.ads \
    s-osprim.adb<7sosprim.adb \
    s-proinf.adb<5gproinf.adb \
    s-proinf.ads<5gproinf.ads \
    s-taprop.adb<5gtaprop.adb \
    s-tasinf.adb<5gtasinf.adb \
    s-tasinf.ads<5gtasinf.ads \
    s-taspri.ads<7staspri.ads \
    s-traceb.adb<7straceb.adb \
    g-soccon.ads<3gsoccon.ads \
    system.ads<5fsystem.ads

    THREADSLIB = -lathread
  endif

  TGT_LIB = -lexc
  MISCLIB = -lexc
  SO_OPTS = -Wl,-all,-set_version,sgi1.0,-update_registry,../so_locations,-soname,
  LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/'))
endif

ifeq ($(strip $(filter-out hppa% hp hpux%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-intnam.ads<4hintnam.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<7sintman.adb \
  s-osinte.adb<5iosinte.adb \
  s-osinte.ads<53osinte.ads \
  s-parame.ads<5hparame.ads \
  s-osprim.adb<7sosprim.adb \
  s-traceb.adb<5htraceb.adb \
  s-taprop.adb<7staprop.adb \
  s-taspri.ads<7staspri.ads \
  s-tpopsp.adb<5atpopsp.adb \
  g-soccon.ads<3hsoccon.ads \
  system.ads<5hsystem.ads

  TGT_LIB = /usr/lib/libcl.a -lpthread
  THREADSLIB = -lpthread -lc_r
  SYMLIB = -laddr2line -lbfd $(INTLLIBS)
  soext = .sl
  SO_OPTS = -Wl,+h,
  GNATLIB_SHARED = gnatlib-shared-dual

  ifeq ($(strip $(filter-out dce DCE,$(THREAD_KIND))),)
    LIBGNAT_TARGET_PAIRS = \
    a-excpol.adb<4wexcpol.adb \
    a-intnam.ads<4hintnam.ads \
    s-inmaop.adb<7sinmaop.adb \
    s-interr.adb<5ginterr.adb \
    s-intman.adb<7sintman.adb \
    s-osinte.adb<5hosinte.adb \
    s-osinte.ads<5hosinte.ads \
    s-parame.ads<5hparame.ads \
    s-osprim.adb<7sosprim.adb \
    s-taprop.adb<5htaprop.adb \
    s-taspri.ads<5htaspri.ads \
    g-soccon.ads<3hsoccon.ads \
    system.ads<5hsystem.ads

    THREADSLIB = -lcma
  endif
endif

ifeq ($(strip $(filter-out ibm aix4%,$(manu) $(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-intnam.ads<4cintnam.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<7sintman.adb \
  s-osinte.adb<5bosinte.adb \
  s-osinte.ads<5bosinte.ads \
  s-osprim.adb<7sosprim.adb \
  s-taprop.adb<7staprop.adb \
  s-taspri.ads<7staspri.ads \
  s-tpopsp.adb<7stpopsp.adb \
  g-soccon.ads<3bsoccon.ads \
  system.ads<5bsystem.ads

  THREADSLIB = -lpthreads
  ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),)
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<4cintnam.ads \
    s-inmaop.adb<7sinmaop.adb \
    s-intman.adb<7sintman.adb \
    s-osinte.adb<7sosinte.adb \
    s-osinte.ads<5cosinte.ads \
    s-osprim.adb<7sosprim.adb \
    s-taprop.adb<7staprop.adb \
    s-taspri.ads<7staspri.ads \
    s-tpopsp.adb<7stpopsp.adb \
    g-soccon.ads<3bsoccon.ads \
    system.ads<5bsystem.ads

    THREADSLIB = -lgthreads -lmalloc
  endif
endif

ifeq ($(strip $(filter-out lynxos,$(osys))),)
  ifeq ($(strip $(filter-out %86 lynxos,$(arch) $(osys))),)
    LIBGNAT_TARGET_PAIRS = \
    a-numaux.adb<86numaux.adb \
    a-numaux.ads<86numaux.ads \
    a-intnam.ads<42intnam.ads \
    s-mastop.adb<5omastop.adb \
    s-inmaop.adb<7sinmaop.adb \
    s-intman.adb<7sintman.adb \
    s-osinte.adb<52osinte.adb \
    s-osinte.ads<52osinte.ads \
    s-osprim.adb<7sosprim.adb \
    s-taprop.adb<7staprop.adb \
    s-taspri.ads<7staspri.ads \
    s-tpopsp.adb<7stpopsp.adb \
    system.ads<52system.ads

    ifeq ($(strip $(filter-out pthread PTHREAD,$(THREAD_KIND))),)
      LIBGNAT_TARGET_PAIRS = \
      a-numaux.adb<86numaux.adb \
      a-numaux.ads<86numaux.ads \
      a-intnam.ads<42intnam.ads \
      s-mastop.adb<5omastop.adb \
      s-inmaop.adb<7sinmaop.adb \
      s-intman.adb<7sintman.adb \
      s-osinte.adb<56osinte.adb \
      s-osinte.ads<56osinte.ads \
      s-osprim.adb<7sosprim.adb \
      s-taprop.adb<56taprop.adb \
      s-taspri.ads<56taspri.ads \
      s-tpopsp.adb<5atpopsp.adb \
      system.ads<52system.ads
    endif

  else
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<42intnam.ads \
    s-inmaop.adb<7sinmaop.adb \
    s-intman.adb<7sintman.adb \
    s-osinte.adb<56osinte.adb \
    s-osinte.ads<56osinte.ads \
    s-osprim.adb<7sosprim.adb \
    s-taprop.adb<56taprop.adb \
    s-taspri.ads<56taspri.ads \
    s-tpopsp.adb<5atpopsp.adb \
    system.ads<52system.ads
  endif
endif

ifeq ($(strip $(filter-out rtems,$(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-intnam.ads<4rintnam.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<7sintman.adb \
  s-osinte.adb<5rosinte.adb \
  s-osinte.ads<5rosinte.ads \
  s-osprim.adb<7sosprim.adb \
  s-parame.adb<5rparame.adb \
  s-taprop.adb<7staprop.adb \
  s-taspri.ads<7staspri.ads \
  s-tpopsp.adb<5atpopsp.adb
endif

ifeq ($(strip $(filter-out go32 msdos,$(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-intnam.ads<4dintnam.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<7sintman.adb \
  s-osinte.adb<7sosinte.adb \
  s-osinte.ads<5dosinte.ads \
  s-osprim.adb<7sosprim.adb \
  s-taprop.adb<7staprop.adb \
  s-taspri.ads<7staspri.ads \
  s-tpopsp.adb<7stpopsp.adb
endif

ifeq ($(strip $(filter-out alpha% dec osf%,$(targ))),)
  LIBGNAT_TARGET_PAIRS = \
  a-intnam.ads<4aintnam.ads \
  s-inmaop.adb<7sinmaop.adb \
  s-intman.adb<7sintman.adb \
  s-mastop.adb<5amastop.adb \
  s-osinte.adb<5aosinte.adb \
  s-osinte.ads<5aosinte.ads \
  s-osprim.adb<5posprim.adb \
  s-taprop.adb<5ataprop.adb \
  s-tasinf.ads<5atasinf.ads \
  s-taspri.ads<5ataspri.ads \
  s-tpopsp.adb<5atpopsp.adb \
  s-traceb.adb<7straceb.adb \
  g-soccon.ads<3asoccon.ads \
  system.ads<5asystem.ads

  THREADSLIB = -lpthread -lmach -lexc -lrt
  SYMLIB = -laddr2line -lbfd $(INTLLIBS)
  LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/'))
endif

ifeq ($(strip $(filter-out alpha% dec vms% openvms% alphavms%,$(host))),)

EXTRA_GNAT1_OBJS = ../prefix.o vmshandler.o
EXTRA_GNATBIND_OBJS = ../prefix.o vmshandler.o

endif

ifeq ($(strip $(filter-out alpha% dec vms% openvms% alphavms%,$(targ))),)

ifeq ($(strip $(filter-out alpha64% dec vms% openvms% alphavms%,$(targ))),)
  LIBGNAT_TARGET_PAIRS_AUX =
else
ifeq ($(strip $(filter-out express EXPRESS,$(THREAD_KIND))),)
  LIBGNAT_TARGET_PAIRS_AUX = \
  s-parame.ads<5xparame.ads
else
  LIBGNAT_TARGET_PAIRS_AUX = \
  s-parame.ads<5vparame.ads
endif
endif

  LIBGNAT_TARGET_PAIRS = \
  a-caldel.adb<4vcaldel.adb \
  a-calend.adb<4vcalend.adb \
  a-calend.ads<4vcalend.ads \
  a-excpol.adb<4wexcpol.adb \
  a-intnam.ads<4vintnam.ads \
  g-enblsp.adb<3venblsp.adb \
  i-cstrea.adb<6vcstrea.adb \
  i-cpp.adb<6vcpp.adb \
  interfac.ads<6vinterf.ads \
  s-asthan.adb<5vasthan.adb \
  s-inmaop.adb<5vinmaop.adb \
  s-interr.adb<5vinterr.adb \
  s-intman.adb<5vintman.adb \
  s-intman.ads<5vintman.ads \
  s-osinte.adb<5vosinte.adb \
  s-osinte.ads<5vosinte.ads \
  s-osprim.adb<5vosprim.adb \
  s-osprim.ads<5vosprim.ads \
  s-taprop.adb<5vtaprop.adb \
  s-taspri.ads<5vtaspri.ads \
  s-tpopde.adb<5vtpopde.adb \
  s-tpopde.ads<5vtpopde.ads \
  s-vaflop.adb<5vvaflop.adb \
  system.ads<5xsystem.ads   \
  $(LIBGNAT_TARGET_PAIRS_AUX)

  GNATLIB_SHARED=gnatlib-shared-vms
  EXTRA_LIBGNAT_SRCS=vmshandler.asm
  EXTRA_LIBGNAT_OBJS=vmshandler.o
  EXTRA_GNATRTL_TASKING_OBJS=s-tpopde.o
  EXTRA_GNATTOOLS_OBJS = ../prefix.o vmshandler.o
endif

ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
  LIBGNAT_TARGET_PAIRS = \
  a-calend.adb<4wcalend.adb \
  a-excpol.adb<4wexcpol.adb \
  a-intnam.ads<4wintnam.ads \
  a-numaux.adb<86numaux.adb \
  a-numaux.ads<86numaux.ads \
  s-gloloc.adb<5wgloloc.adb \
  s-inmaop.adb<5ninmaop.adb \
  s-interr.adb<5ginterr.adb \
  s-intman.adb<5wintman.adb \
  s-mastop.adb<5omastop.adb \
  s-memory.adb<5wmemory.adb \
  s-osinte.ads<5wosinte.ads \
  s-osprim.adb<5wosprim.adb \
  s-taprop.adb<5wtaprop.adb \
  s-taspri.ads<5wtaspri.ads \
  g-socthi.ads<3wsocthi.ads \
  g-socthi.adb<3wsocthi.adb \
  g-soccon.ads<3wsoccon.ads \
  g-soliop.ads<3wsoliop.ads \
  system.ads<5wsystem.ads

  MISCLIB = -lwsock32
  SYMLIB = -laddr2line -lbfd $(INTLLIBS)
  GMEM_LIB = gmemlib
  EXTRA_GNATTOOLS = ../../gnatdll$(exeext)
  EXTRA_GNATRTL_NONTASKING_OBJS = g-regist.o
endif

# The runtime library for gnat comprises two directories.  One contains the
# Ada source files that the compiler (gnat1) needs -- these files are listed
# by ADA_INCLUDE_SRCS -- and the other contains the object files and their
# corresponding .ali files for the parts written in Ada, libgnat.a for
# the parts of the runtime written in C, and libgthreads.a for the pthreads
# emulation library.  LIBGNAT_OBJS lists the objects that go into libgnat.a,
# while GNATRTL_OBJS lists the object files compiled from Ada sources that
# go into the directory.  The pthreads emulation is built in the threads
# subdirectory and copied.
LIBGNAT_SRCS = ada.h adaint.c adaint.h argv.c cio.c cstreams.c \
  errno.c exit.c cal.c \
  raise.h raise.c sysdep.c types.h aux-io.c init.c \
  final.c tracebak.c expect.c mkdir.c $(EXTRA_LIBGNAT_SRCS)

LIBGNAT_OBJS = adaint.o argv.o cio.o cstreams.o errno.o exit.o \
  raise.o sysdep.o aux-io.o init.o cal.o final.o \
  tracebak.o expect.o mkdir.o $(EXTRA_LIBGNAT_OBJS)

# NOTE ??? - when the -I option for compiling Ada code is made to work,
#  the library installation will change and there will be a
#  GNAT_RTL_SRCS.  Right now we count on being able to build GNATRTL_OBJS
#  from ADA_INCLUDE_SRCS.

# Objects needed only for tasking
GNATRTL_TASKING_OBJS= \
  a-dynpri.o \
  a-interr.o \
  a-intsig.o \
  a-intnam.o \
  a-reatim.o \
  a-retide.o \
  a-sytaco.o \
  a-taside.o \
  g-thread.o \
  s-asthan.o \
  s-inmaop.o \
  s-interr.o \
  s-intman.o \
  s-osinte.o \
  s-proinf.o \
  s-taenca.o \
  s-taprob.o \
  s-taprop.o \
  s-tarest.o \
  s-tasdeb.o \
  s-tasinf.o \
  s-tasini.o \
  s-taskin.o \
  s-taspri.o \
  s-tasque.o \
  s-tasres.o \
  s-tasren.o \
  s-tassta.o \
  s-tasuti.o \
  s-taasde.o \
  s-tadeca.o \
  s-tadert.o \
  s-tataat.o \
  s-tpinop.o \
  s-tpoben.o \
  s-tpobop.o \
  s-tposen.o \
  s-tratas.o $(EXTRA_GNATRTL_TASKING_OBJS)

# Objects needed for non-tasking.
GNATRTL_NONTASKING_OBJS= \
  a-caldel.o \
  a-calend.o \
  a-chahan.o \
  a-charac.o \
  a-chlat1.o \
  a-chlat9.o \
  a-colien.o \
  a-colire.o \
  a-comlin.o \
  a-cwila1.o \
  a-cwila9.o \
  a-decima.o \
  a-einuoc.o \
  a-except.o \
  a-exctra.o \
  a-filico.o \
  a-finali.o \
  a-flteio.o \
  a-fwteio.o \
  a-inteio.o \
  a-ioexce.o \
  a-iwteio.o \
  a-lfteio.o \
  a-lfwtio.o \
  a-liteio.o \
  a-liwtio.o \
  a-llftio.o \
  a-llfwti.o \
  a-llitio.o \
  a-lliwti.o \
  a-ncelfu.o \
  a-nlcefu.o \
  a-nlcoty.o \
  a-nlelfu.o \
  a-nllcef.o \
  a-nllcty.o \
  a-nllefu.o \
  a-nscefu.o \
  a-nscoty.o \
  a-nselfu.o \
  a-nucoty.o \
  a-nuelfu.o \
  a-nuflra.o \
  a-numaux.o \
  a-numeri.o \
  a-sfteio.o \
  a-sfwtio.o \
  a-siteio.o \
  a-siwtio.o \
  a-ssicst.o \
  a-ssitio.o \
  a-ssiwti.o \
  a-stmaco.o \
  a-strbou.o \
  a-stream.o \
  a-strfix.o \
  a-string.o \
  a-strmap.o \
  a-strsea.o \
  a-strunb.o \
  a-ststio.o \
  a-stunau.o \
  a-stwibo.o \
  a-stwifi.o \
  a-stwima.o \
  a-stwise.o \
  a-stwiun.o \
  a-suteio.o \
  a-swuwti.o \
  a-swmwco.o \
  a-tags.o \
  a-teioed.o \
  a-textio.o \
  a-ticoau.o \
  a-tideau.o \
  a-tienau.o \
  a-tiflau.o \
  a-tigeau.o \
  a-tiinau.o \
  a-timoau.o \
  a-tiocst.o \
  a-titest.o \
  a-witeio.o \
  a-wtcoau.o \
  a-wtcstr.o \
  a-wtdeau.o \
  a-wtedit.o \
  a-wtenau.o \
  a-wtflau.o \
  a-wtgeau.o \
  a-wtinau.o \
  a-wtmoau.o \
  a-wttest.o \
  ada.o \
  calendar.o \
  g-awk.o \
  g-busora.o \
  g-calend.o \
  g-casuti.o \
  g-catiio.o \
  g-cgi.o    \
  g-cgicoo.o \
  g-cgideb.o \
  g-comlin.o \
  g-crc32.o \
  g-curexc.o \
  g-debuti.o \
  g-debpoo.o \
  g-diopit.o \
  g-dirope.o \
  g-except.o \
  g-exctra.o \
  g-expect.o \
  g-flocon.o \
  g-hesora.o \
  g-htable.o \
  g-io.o \
  g-io_aux.o \
  g-locfil.o \
  g-md5.o \
  g-moreex.o \
  g-os_lib.o \
  g-regexp.o \
  g-regpat.o \
  g-soccon.o \
  g-socket.o \
  g-socthi.o \
  g-soliop.o \
  g-souinf.o \
  g-speche.o \
  g-spipat.o \
  g-spitbo.o \
  g-sptabo.o \
  g-sptain.o \
  g-sptavs.o \
  g-tasloc.o \
  g-traceb.o \
  gnat.o \
  i-c.o \
  i-cexten.o \
  i-cobol.o \
  i-cpp.o \
  i-cstrea.o \
  i-cstrin.o \
  i-fortra.o \
  i-pacdec.o \
  interfac.o \
  ioexcept.o \
  machcode.o \
  s-addima.o \
  s-arit64.o \
  s-assert.o \
  s-auxdec.o \
  s-bitops.o \
  s-chepoo.o \
  s-crc32.o  \
  s-direio.o \
  s-errrep.o \
  s-except.o \
  s-exctab.o \
  s-exnflt.o \
  s-exngen.o \
  s-exnint.o \
  s-exnlfl.o \
  s-exnlin.o \
  s-exnllf.o \
  s-exnlli.o \
  s-exnsfl.o \
  s-exnsin.o \
  s-exnssi.o \
  s-expflt.o \
  s-expgen.o \
  s-expint.o \
  s-explfl.o \
  s-explin.o \
  s-expllf.o \
  s-explli.o \
  s-expllu.o \
  s-expmod.o \
  s-expsfl.o \
  s-expsin.o \
  s-expssi.o \
  s-expuns.o \
  s-fatflt.o \
  s-fatlfl.o \
  s-fatllf.o \
  s-fatsfl.o \
  s-ficobl.o \
  s-fileio.o \
  s-finimp.o \
  s-finroo.o \
  s-fore.o \
  s-imgbiu.o \
  s-imgboo.o \
  s-imgcha.o \
  s-imgdec.o \
  s-imgenu.o \
  s-imgint.o \
  s-imgllb.o \
  s-imglld.o \
  s-imglli.o \
  s-imgllu.o \
  s-imgllw.o \
  s-imgrea.o \
  s-imguns.o \
  s-imgwch.o \
  s-imgwiu.o \
  s-io.o \
  s-gloloc.o \
  s-maccod.o \
  s-mantis.o \
  s-mastop.o \
  s-osprim.o \
  s-pack03.o \
  s-pack05.o \
  s-pack06.o \
  s-pack07.o \
  s-pack09.o \
  s-pack10.o \
  s-pack11.o \
  s-pack12.o \
  s-pack13.o \
  s-pack14.o \
  s-pack15.o \
  s-pack17.o \
  s-pack18.o \
  s-pack19.o \
  s-pack20.o \
  s-pack21.o \
  s-pack22.o \
  s-pack23.o \
  s-pack24.o \
  s-pack25.o \
  s-pack26.o \
  s-pack27.o \
  s-pack28.o \
  s-pack29.o \
  s-pack30.o \
  s-pack31.o \
  s-pack33.o \
  s-pack34.o \
  s-pack35.o \
  s-pack36.o \
  s-pack37.o \
  s-pack38.o \
  s-pack39.o \
  s-pack40.o \
  s-pack41.o \
  s-pack42.o \
  s-pack43.o \
  s-pack44.o \
  s-pack45.o \
  s-pack46.o \
  s-pack47.o \
  s-pack48.o \
  s-pack49.o \
  s-pack50.o \
  s-pack51.o \
  s-pack52.o \
  s-pack53.o \
  s-pack54.o \
  s-pack55.o \
  s-pack56.o \
  s-pack57.o \
  s-pack58.o \
  s-pack59.o \
  s-pack60.o \
  s-pack61.o \
  s-pack62.o \
  s-pack63.o \
  s-parame.o \
  s-parint.o \
  s-pooglo.o \
  s-pooloc.o \
  s-poosiz.o \
  s-powtab.o \
  s-rpc.o \
  s-scaval.o \
  s-secsta.o \
  s-sequio.o \
  s-shasto.o \
  s-sopco3.o \
  s-sopco4.o \
  s-sopco5.o \
  s-stache.o \
  s-stalib.o \
  s-stoele.o \
  s-stopoo.o \
  s-stratt.o \
  s-strops.o \
  s-soflin.o \
  s-memory.o \
  s-traceb.o \
  s-traces.o \
  s-unstyp.o \
  s-vaflop.o \
  s-valboo.o \
  s-valcha.o \
  s-valdec.o \
  s-valenu.o \
  s-valint.o \
  s-vallld.o \
  s-vallli.o \
  s-valllu.o \
  s-valrea.o \
  s-valuns.o \
  s-valuti.o \
  s-valwch.o \
  s-vercon.o \
  s-vmexta.o \
  s-wchcnv.o \
  s-wchcon.o \
  s-wchjis.o \
  s-wchstw.o \
  s-wchwts.o \
  s-widboo.o \
  s-widcha.o \
  s-widenu.o \
  s-widlli.o \
  s-widllu.o \
  s-widwch.o \
  s-wwdcha.o \
  s-wwdenu.o \
  s-wwdwch.o \
  system.o \
  text_io.o $(EXTRA_GNATRTL_NONTASKING_OBJS)

GNATRTL_OBJS = $(GNATRTL_NONTASKING_OBJS) $(GNATRTL_TASKING_OBJS) g-trasym.o

# Files which are suitable in no run time/hi integrity mode

HIE_SOURCES = \
 system.ads   \
 ada.ads      \
 a-unccon.ads \
 a-uncdea.ads \
 gnat.ads     \
 g-souinf.ads \
 interfac.ads \
 s-stoele.ads \
 s-stoele.adb \
 unchconv.ads \
 unchdeal.ads \
 s-maccod.ads \
 s-unstyp.ads \
 s-fatgen.ads \
 s-fatgen.adb \
 s-fatflt.ads \
 s-fatlfl.ads \
 s-fatllf.ads \
 s-fatsfl.ads \
 s-secsta.ads \
 s-secsta.adb \
 a-tags.ads   \
 a-tags.adb $(EXTRA_HIE_SOURCES)

HIE_OBJS =  \
 system.o   \
 ada.o      \
 a-except.o \
 gnat.o     \
 g-souinf.o \
 interfac.o \
 i-c.o      \
 s-stoele.o \
 s-maccod.o \
 s-unstyp.o \
 s-fatflt.o \
 s-fatlfl.o \
 s-fatllf.o \
 s-secsta.o \
 a-tags.o $(EXTRA_HIE_OBJS)

# Files which are needed in ravenscar mode

RAVEN_SOURCES = \
 $(HIE_SOURCES) \
 s-parame.ads \
 s-parame.adb \
 g-except.ads \
 s-osinte.ads \
 s-osinte.adb \
 s-tasinf.ads \
 s-tasinf.adb \
 s-taspri.ads \
 s-taprop.ads \
 s-taprop.adb \
 s-taskin.ads \
 s-taskin.adb \
 s-interr.ads \
 s-interr.adb \
 a-interr.ads \
 a-interr.adb \
 a-intnam.ads \
 a-reatim.ads \
 a-reatim.adb \
 a-retide.ads \
 a-retide.adb \
 s-taprob.ads \
 s-taprob.adb \
 s-tposen.ads \
 s-tposen.adb \
 s-tasres.ads \
 s-tarest.ads \
 s-tarest.adb $(EXTRA_RAVEN_SOURCES)

# Objects to generate for the ravenscar run time

RAVEN_OBJS = \
 $(HIE_OBJS) \
 s-parame.o  \
 g-except.o  \
 s-osinte.o  \
 s-tasinf.o  \
 s-taspri.o  \
 s-taprop.o  \
 s-taskin.o  \
 s-interr.o  \
 a-interr.o  \
 a-intnam.o  \
 a-reatim.o  \
 a-retide.o  \
 s-taprob.o  \
 s-tposen.o  \
 s-tasres.o  \
 s-tarest.o  $(EXTRA_RAVEN_OBJS)

# Default run time files

ADA_INCLUDE_DIR = $(libsubdir)/adainclude
ADA_RTL_OBJ_DIR = $(libsubdir)/adalib

ADA_INCLUDE_SRCS =\
 ada.ads calendar.ads directio.ads gnat.ads interfac.ads ioexcept.ads \
 machcode.ads text_io.ads unchconv.ads unchdeal.ads \
 sequenio.ads system.ads Makefile.adalib memtrack.adb \
 a-*.adb a-*.ads g-*.ad? i-*.ad? \
 s-[a-o]*.adb s-[p-z]*.adb \
 s-[a-o]*.ads s-[p-z]*.ads

# Language-independent object files.
LIBGNAT=../rts/libgnat.a 
TOOLS_FLAGS_TO_PASS=		\
        "CC=$(CC)" 		\
        "CFLAGS=$(CFLAGS)"	\
	"LDFLAGS=$(LDFLAGS)"	\
        "ADAFLAGS=$(ADAFLAGS)"	\
        "INCLUDES=$(INCLUDES_FOR_SUBDIR)"\
	"ADA_INCLUDES=$(ADA_INCLUDES) $(ADA_INCLUDES_FOR_SUBDIR)"\
	"libsubdir=$(libsubdir)"	\
	"exeext=$(exeext)"	\
	"srcdir=$(fsrcdir)"	\
	"VPATH=$(fsrcdir)"      \
        "TOOLS_LIBS=$(TOOLS_LIBS) $(TGT_LIB)"	\
	"GNATMAKE=$(GNATMAKE)"	\
	"GNATLINK=$(GNATLINK)"	\
	"GNATBIND=$(GNATBIND)"

# Build directory for the tools. Let's copy the target dependent
# sources using the same mechanism as for gnatlib. The other sources are 
# accessed using the vpath directive below

../stamp-tools:
	-$(RM) tools/*
	-$(RMDIR) tools
	-$(MKDIR) tools
	-(cd tools; $(LN_S) ../sdefault.adb .)
	-$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \
	          $(RM) tools/$(word 1,$(subst <, ,$(PAIR)));\
	          $(LN_S) $(fsrcdir)/$(word 2,$(subst <, ,$(PAIR))) \
	                tools/$(word 1,$(subst <, ,$(PAIR)));)
	touch ../stamp-tools

# when compiling the tools, the runtime has to be first on the path so that
# it hides the runtime files lying with the rest of the sources
ifeq ($(TOOLSCASE),native)
  vpath %.ads ../rts ../
  vpath %.adb ../rts ../
  vpath %.c   ../rts ../
  vpath %.h   ../rts ../
endif

# in the cross tools case, everything is compiled with the native 
# gnatmake/link. Therefore only -I needs to be modified in ADA_INCLUDES
ifeq ($(TOOLSCASE),cross)
  vpath %.ads ../
  vpath %.adb ../
  vpath %.c   ../
  vpath %.h   ../
endif

# gnatmake/link  tools cannot always be built with gnatmake/link for bootstrap 
# reasons: gnatmake should be built with a recent compiler, a recent compiler
# may not generate ALI files compatible with an old gnatmake so it is important
# to be able to build gnatmake without a version of gnatmake around. Once 
# everything has been compiled once, gnatmake can be recompiled with itself 
# (see target gnattools1-re) 
gnattools1: ../stamp-tools ../stamp-gnatlib
	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
	  TOOLSCASE=native \
	  ../../gnatmake$(exeext) ../../gnatlink$(exeext) ../../gnatbl$(exeext)

# gnatmake/link can be build with recent gnatmake/link if they are available.
# This is especially convenient for building cross tools or for rebuilding
# the tools when the original bootstrap has already be done.
gnattools1-re: ../stamp-tools
	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
	  TOOLSCASE=cross INCLUDES="" gnatmake-re gnatlink-re

# these tools are built with gnatmake & are common to native and cross
gnattools2: ../stamp-tools
	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
	  TOOLSCASE=native \
	  ../../gnatchop$(exeext) ../../gnat$(exeext) ../../gnatkr$(exeext) \
	  ../../gnatls$(exeext) ../../gnatprep$(exeext) \
	  ../../gnatpsta$(exeext) ../../gnatxref$(exeext) \
          ../../gnatfind$(exeext) ../../gnatname$(exeext)

# These tools are only built for the native version.
gnattools3: ../stamp-tools
#	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
#	  TOOLSCASE=native \
#	  top_builddir=../.. ../../gnatmem$(exeext) $(EXTRA_GNATTOOLS)

../../gnatchop$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatchop --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatchop 
	$(GNATLINK) -v gnatchop -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
		$(TOOLS_LIBS)

../../gnat$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatcmd --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatcmd 
	$(GNATLINK) -v gnatcmd -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
		$(TOOLS_LIBS)

../../gnatkr$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatkr --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatkr 
	$(GNATLINK) -v gnatkr -o $@ --GCC="$(CC) $(ADA_INCLUDES)" $(TOOLS_LIBS)

../../gnatls$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatls --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatls 
	$(GNATLINK) -v gnatls -o $@ --GCC="$(CC) $(ADA_INCLUDES)" $(TOOLS_LIBS)

../../gnatname$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatname --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatname 
	$(GNATLINK) -v gnatname -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
		$(TOOLS_LIBS)

../../gnatprep$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatprep --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatprep 
	$(GNATLINK) -v gnatprep -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
		$(TOOLS_LIBS)

../../gnatpsta$(exeext): deftarg.o
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatpsta --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatpsta 
	$(GNATLINK) -v gnatpsta -o $@ --GCC="$(CC) $(ADA_INCLUDES)"\
                      ../targtyps.o deftarg.o $(TOOLS_LIBS)

../../gnatxref$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatxref --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatxref 
	$(GNATLINK) -v gnatxref -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
		$(TOOLS_LIBS)

../../gnatfind$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatfind --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatfind 
	$(GNATLINK) -v gnatfind -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
		$(TOOLS_LIBS)

../../gnatmem$(exeext): gmem.o $(SYMDEPS)
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatmem --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmem 
	$(GNATLINK) -v gnatmem -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
	            gmem.o $(SYMLIB) $(TOOLS_LIBS)

../../gnatdll$(exeext):
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) $(GNATBIND_FLAGS) gnatdll
	$(GNATLINK) -v gnatdll -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \
		$(TOOLS_LIBS)

gnatmake-re:
	$(GNATMAKE) $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake 
	$(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \
		--GCC="$(CC) $(ADA_INCLUDES)" $(TOOLS_LIBS)

# Note the use of the "mv" command in order to allow gnatlink to be linked with
# with the former version of gnatlink itself which cannot override itself.
gnatlink-re: link.o
	$(GNATMAKE) -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink 
	$(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \
		--GCC="$(CC) $(ADA_INCLUDES)" link.o $(TOOLS_LIBS)
	$(MV)  ../../gnatlinknew$(exeext)  ../../gnatlink$(exeext)
  

# Needs to be built with CC=gcc
# Since the RTL should be built with the latest compiler, remove the
#  stamp target in the parent directory whenever gnat1 is rebuilt
# Likewise for the tools
../../gnatmake$(exeext): $(P) b_gnatm.o $(GNATMAKE_OBJS)
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) \
	      $(TOOLS_LIBS)

../../gnatlink$(exeext): $(P) b_gnatl.o $(GNATLINK_OBJS)
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) \
	      $(TOOLS_LIBS)

../../gnatbl$(exeext): gnatbl.o
	$(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) gnatbl.o $(TOOLS_LIBS)

gnatbl.o: gnatbl.c adaint.h
	$(CC) $(ALL_CFLAGS) $(INCLUDES) -c $< 
  
../stamp-gnatlib:
	@if [ ! -f stamp-gnatlib ] ; \
	then \
	  $(ECHO) You must first build the GNAT library: make gnatlib; \
	  false; \
	else \
	  true; \
	fi

install-gnatlib: ../stamp-gnatlib
#	Create the directory before deleting it, in case the directory is
#	a list of directories (as it may be on VMS). This ensures we are
#	deleting the right one.
	-$(MKDIR) $(ADA_RTL_OBJ_DIR)
	-$(MKDIR) $(ADA_INCLUDE_DIR)
	$(RMDIR) $(ADA_RTL_OBJ_DIR)
	$(RMDIR) $(ADA_INCLUDE_DIR)
	-$(MKDIR) $(ADA_RTL_OBJ_DIR)
	-$(MKDIR) $(ADA_INCLUDE_DIR)
	-$(INSTALL_DATA) ada/rts/Makefile.adalib $(ADA_RTL_OBJ_DIR)
	for file in ada/rts/*.ali; do \
	    $(INSTALL_DATA) $$file $(ADA_RTL_OBJ_DIR); \
	done
	-for file in ada/rts/*$(arext);do \
	    $(INSTALL_DATA) $$file $(ADA_RTL_OBJ_DIR); \
	done
ifeq ($(strip $(filter-out alpha% dec vms% openvms% alphavms%,$(targ))),)
	-for file in ada/rts/lib*$(soext);do \
	    $(INSTALL_DATA) $$file $(ADA_RTL_OBJ_DIR); \
	done
else
	-for file in ada/rts/lib*-**$(soext);do \
	    $(INSTALL_DATA) $$file $(ADA_RTL_OBJ_DIR); \
	done
endif
	-$(LN_S) $(ADA_RTL_OBJ_DIR)/libgnat-*$(soext) \
	       $(ADA_RTL_OBJ_DIR)/libgnat$(soext)
	-$(LN_S) $(ADA_RTL_OBJ_DIR)/libgnarl-*$(soext) \
	       $(ADA_RTL_OBJ_DIR)/libgnarl$(soext)
# This copy must be done preserving the date on the original file.
	for file in ada/rts/*.adb ada/rts/*.ads; do \
	    $(INSTALL_DATA_DATE) $$file $(ADA_INCLUDE_DIR); \
	done
	cd $(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
	cd $(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads

../stamp-gnatlib2:
	$(RM) rts/s-*.ali
	$(RM) rts/s-*$(objext)
	$(RM) rts/a-*.ali
	$(RM) rts/a-*$(objext)
	$(RM) rts/*.ali
	$(RM) rts/*$(objext)
	$(RM) rts/*$(arext)
	$(RM) rts/*$(soext)
	touch ../stamp-gnatlib2
	$(RM) ../stamp-gnatlib

# NOTE: The $(foreach ...) commands assume ";" is the valid separator between
#       successive target commands. Although the Gnu make documentation
#       implies this is true on all systems, I suspect it may not be, So care
#       has been taken to allow a sed script to look for ";)" and substitue
#       for ";" the appropriate character in the range of lines below
#       beginning with "GNULLI Begin" and ending with "GNULLI End"

# GNULLI Begin ###########################################################

../stamp-gnatlib1: Makefile ../stamp-gnatlib2
	$(RMDIR) rts
	$(MKDIR) rts
	$(CHMOD) u+w rts
# Copy target independent sources
	$(foreach f,$(ADA_INCLUDE_SRCS) $(LIBGNAT_SRCS), \
	  $(LN_S) $(fsrcpfx)$(f) rts ;) true
# Remove files to be replaced by target dependent sources
	$(RM) $(foreach PAIR,$(LIBGNAT_TARGET_PAIRS), \
	                rts/$(word 1,$(subst <, ,$(PAIR))))
# Copy new target dependent sources
	$(foreach PAIR,$(LIBGNAT_TARGET_PAIRS), \
	          $(LN_S) $(fsrcpfx)$(word 2,$(subst <, ,$(PAIR))) \
	                rts/$(word 1,$(subst <, ,$(PAIR)));)
	$(RM) ../stamp-gnatlib
	touch ../stamp-gnatlib1

# GNULLI End #############################################################

# Don't use semicolon separated shell commands that involve list expansions.
# The semicolon triggers a call to DCL on VMS and DCL can't handle command
# line lengths in excess of 256 characters.
# Example: cd rts; ar rc libfoo.a $(LONG_LIST_OF_OBJS)
# is guaranteed to overflow the buffer.

gnatlib: ../stamp-gnatlib1 ../stamp-gnatlib2
#	../xgcc -B../ -dD -E ../tconfig.h $(INCLUDES) > rts/tconfig.h
	$(MAKE) -C rts CC="../../xgcc -B../../" \
	        INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
                CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \
		srcdir=$(fsrcdir) \
	        -f ../Makefile $(LIBGNAT_OBJS) prefix.o
	$(MAKE) -C rts CC="../../xgcc -B../../" \
	        ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \
                CFLAGS="$(GNATLIBCFLAGS)" ADA_CFLAGS="$(GNATLIBCFLAGS)" \
	        ADAFLAGS="$(GNATLIBFLAGS)" \
		srcdir=$(fsrcdir) VPATH=$(fsrcdir) \
	        -f ../Makefile \
	        $(GNATRTL_OBJS)
	$(RM) rts/libgnat$(arext) rts/libgnarl$(arext)
	$(AR) $(AR_FLAGS) rts/libgnat$(arext) \
	   $(addprefix rts/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) prefix.o)
	if $(RANLIB_TEST) ; then $(RANLIB) rts/libgnat$(arext); else true; fi
	$(AR) $(AR_FLAGS) rts/libgnarl$(arext) \
	   $(addprefix rts/,$(GNATRTL_TASKING_OBJS))
	if $(RANLIB_TEST) ; then $(RANLIB) rts/libgnarl$(arext); else true; fi
        ifeq ($(GMEM_LIB),gmemlib)
		$(AR) $(AR_FLAGS) rts/libgmem$(arext) rts/memtrack.o;
        endif
	$(CHMOD) a-wx rts/*.ali
	touch ../stamp-gnatlib

HIE_NONE_TARGET_PAIRS=\
 a-except.ads<1aexcept.ads \
 a-except.adb<1aexcept.adb \
 a-tags.adb<1atags.adb \
 s-secsta.ads<1ssecsta.ads \
 s-secsta.adb<1ssecsta.adb \
 i-c.ads<1ic.ads

HIE_SUBST:='s/High_Integrity_Mode.*/High_Integrity_Mode      : constant Boolean := True;/'
# This target needs RTS_NAME, RTS_SRCS, RTS_TARGET_PAIRS to be set properly
# it creates a rts with the proper structure and the right target dependent srcs
prepare-rts:
	$(RMDIR) rts-$(RTS_NAME)
	$(MKDIR) rts-$(RTS_NAME)
	$(CHMOD) u+w rts-$(RTS_NAME)
	$(MKDIR) rts-$(RTS_NAME)/adalib
	$(MKDIR) rts-$(RTS_NAME)/adainclude
	$(CHMOD) u+w rts-$(RTS_NAME)/*
	$(LN) $(fsrcpfx)$(RTS_NAME).gpr rts-$(RTS_NAME)
# Copy target independent sources
	$(foreach f,$(RTS_SRCS), \
	  $(LN) $(fsrcpfx)$(f) rts-$(RTS_NAME)/adainclude ;) true
# Remove files to be replaced by target dependent sources
	$(RM) $(foreach PAIR,$(RTS_TARGET_PAIRS), \
	         rts-$(RTS_NAME)/adainclude/$(word 1,$(subst <, ,$(PAIR))))
# Copy new target dependent sources
	$(foreach PAIR,$(RTS_TARGET_PAIRS), \
	    $(LN) $(fsrcpfx)$(word 2,$(subst <, ,$(PAIR))) \
	            rts-$(RTS_NAME)/adainclude/$(word 1,$(subst <, ,$(PAIR)));)
# change system.High_Integrity_Mode to true for the none & ravenscar rts
        ifeq ($(filter-out none ravenscar,$(RTS_NAME)),)
	  sed -e $(HIE_SUBST) rts-$(RTS_NAME)/adainclude/system.ads \
	      > dummy
	  $(MV) dummy rts-$(RTS_NAME)/adainclude/system.ads
        endif

install-rts: force
	$(CP) -r rts-$(RTS_NAME) $(libsubdir)/

rts-none: force
	$(MAKE) $(FLAGS_TO_PASS) prepare-rts \
	   RTS_NAME=none RTS_SRCS="$(HIE_SOURCES)" \
	   RTS_TARGET_PAIRS="$(HIE_NONE_TARGET_PAIRS)" 
	-$(GNATMAKE) -Prts-none/none.gpr
	$(RM) rts-none/adalib/*.o
	$(CHMOD) a-wx rts-none/adalib/*.ali

rts-ravenscar: force
	$(MAKE)  $(FLAGS_TO_PASS) prepare-rts \
	   RTS_NAME=ravenscar RTS_SRCS="$(RAVEN_SOURCES)" \
	   RTS_TARGET_PAIRS="$(HIE_RAVEN_TARGET_PAIRS)" 
	-$(GNATMAKE) -Prts-ravenscar/none.gpr
	$(CHMOD) a-wx rts-ravenscar/adalib/*.ali

internal-hielib: ../stamp-gnatlib1
	sed -e 's/High_Integrity_Mode.*/High_Integrity_Mode       : constant Boolean := True;/' rts/system.ads > rts/s.ads
	$(MV) rts/s.ads rts/system.ads
	$(MAKE) -C rts CC="../../xgcc -B../../" \
	  ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \
	  CFLAGS="$(GNATLIBCFLAGS)" \
	  ADAFLAGS="$(GNATLIBFLAGS)" \
	  srcdir=$(fsrcdir) VPATH=$(fsrcdir) \
	  -f ../Makefile \
	  $(HIE_OBJS)
	$(CHMOD) a-wx rts/*.ali
	$(RM) $(addprefix rts/,$(HIE_OBJS))
	touch ../stamp-gnatlib

hielib:
	$(MAKE) ADA_INCLUDE_SRCS="$(HIE_SOURCES)" LIBGNAT_SRCS="" \
	  LIBGNAT_TARGET_PAIRS="a-except.ads<1aexcept.ads \
	    a-except.adb<1aexcept.adb \
	    a-tags.adb<1atags.adb \
	    s-secsta.ads<1ssecsta.ads \
	    s-secsta.adb<1ssecsta.adb \
	    i-c.ads<1ic.ads" internal-hielib

internal-ravenlib: ../stamp-gnatlib1
	sed -e 's/High_Integrity_Mode.*/High_Integrity_Mode       : constant Boolean := True;/' rts/system.ads > rts/s.ads
	$(MV) rts/s.ads rts/system.ads
	$(MAKE) -C rts CC="../../xgcc -B../../" \
	  ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \
	  CFLAGS="$(GNATLIBCFLAGS)" \
	  ADAFLAGS="$(GNATLIBFLAGS)" \
	  srcdir=$(fsrcdir) VPATH=$(fsrcdir) \
	  -f ../Makefile \
	  $(RAVEN_OBJS)
	$(CHMOD) a-wx rts/*.ali
	touch ../stamp-gnatlib

# Target for building a ravenscar run time for VxWorks/Cert PPC
ravenppclib:
	$(MAKE) ADA_INCLUDE_SRCS="$(RAVEN_SOURCES)" LIBGNAT_SRCS="" \
	  LIBGNAT_TARGET_PAIRS="a-except.ads<1aexcept.ads \
	    a-except.adb<1aexcept.adb \
	    a-tags.adb<1atags.adb \
	    s-secsta.ads<1ssecsta.ads \
	    s-secsta.adb<1ssecsta.adb \
	    i-c.ads<1ic.ads           \
	    a-reatim.ads<1areatim.ads \
	    a-reatim.adb<1areatim.adb \
	    a-retide.adb<1aretide.adb \
	    a-interr.adb<1ainterr.adb \
	    s-interr.ads<1sinterr.ads \
	    s-interr.adb<1sinterr.adb \
	    s-taskin.ads<1staskin.ads \
	    s-taskin.adb<1staskin.adb \
	    s-tarest.adb<1starest.adb \
	    s-tposen.ads<1stposen.ads \
	    s-tposen.adb<1stposen.adb \
	    s-osinte.adb<1sosinte.adb \
	    s-taprop.ads<1staprop.ads \
	    s-taprop.adb<1staprop.adb \
	    a-sytaco.ads<1asytaco.ads \
	    a-sytaco.adb<1asytaco.adb \
	    a-intnam.ads<4zintnam.ads \
	    s-osinte.adb<5zosinte.adb \
	    s-osinte.ads<5zosinte.ads \
	    s-taspri.ads<5ztaspri.ads \
	    s-vxwork.ads<5pvxwork.ads \
	    system.ads<5ysystem.ads" internal-ravenlib

# Warning: this target assumes that LIBRARY_VERSION has been set correctly.
gnatlib-shared-default:
	$(MAKE) $(FLAGS_TO_PASS) \
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
	     GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
	     THREAD_KIND="$(THREAD_KIND)" \
             gnatlib
	$(RM) rts/libgnat$(soext) rts/libgnarl$(soext)
	cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
		-o libgnat-$(LIBRARY_VERSION)$(soext) \
		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
		$(SO_OPTS)libgnat-$(LIBRARY_VERSION)$(soext) $(MISCLIB) -lm
	cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
		-o libgnarl-$(LIBRARY_VERSION)$(soext) \
		$(GNATRTL_TASKING_OBJS) \
		$(SO_OPTS)libgnarl-$(LIBRARY_VERSION)$(soext) $(THREADSLIB)
	cd rts; $(LN_S) libgnat-$(LIBRARY_VERSION)$(soext) libgnat$(soext)
	cd rts; $(LN_S) libgnarl-$(LIBRARY_VERSION)$(soext) libgnarl$(soext)

gnatlib-shared-dual:
	$(MAKE) $(FLAGS_TO_PASS) \
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
	     THREAD_KIND="$(THREAD_KIND)" \
             gnatlib
	$(MV) rts/libgnat$(arext) rts/libgnarl$(arext) .
	$(RM) ../stamp-gnatlib2
	$(MAKE) $(FLAGS_TO_PASS) \
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
	     THREAD_KIND="$(THREAD_KIND)" \
             gnatlib-shared-default
	$(MV) libgnat$(arext) libgnarl$(arext) rts

gnatlib-shared-vms:
	$(MAKE) $(FLAGS_TO_PASS) \
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
	     THREAD_KIND="$(THREAD_KIND)" \
             gnatlib
	$(RM) rts/libgnat$(soext) rts/libgnarl$(soext)
	rm -f rts/*.sym rts/gnatlib_symvec.opt 
	make -C rts -f ../Makefile.vms \
	   $(patsubst %.obj,%.sym,$(LIBGNAT_OBJS) $(GNATRTL_NONTASKING_OBJS)) 
	append /new [.rts]*.sym [.rts]gnatlib_symvec.opt 
	../xgcc.exe -g -B../ -nostartfiles -shared --for-linker=/noinform \
	   -o rts/libgnat.exe rts/libgnat.olb \
	   --for-linker=rts/gnatlib_symvec.opt \
	   --for-linker=gsmatch=equal,YY,MMDD
	rm -f rts/*.sym rts/gnatlib_symvec.opt 
	make -C rts -f ../Makefile.vms \
	   $(patsubst %.obj,%.sym,$(GNATRTL_TASKING_OBJS)) 
	append /new [.rts]*.sym [.rts]gnatlib_symvec.opt 
	../xgcc.exe -g -B../ -nostartfiles -shared --for-linker=/noinform \
	   -o rts/libgnarl.exe rts/libgnarl.olb rts/libgnat.exe \
	   --for-linker=rts/gnatlib_symvec.opt \
	   --for-linker=gsmatch=equal,YY,MMDD

gnatlib-shared:
	$(MAKE) $(FLAGS_TO_PASS) \
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
	     THREAD_KIND="$(THREAD_KIND)" \
	     TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
             $(GNATLIB_SHARED)

# .s files for cross-building
gnat-cross: force
	make $(GNAT1_ADA_OBJS) CC="gcc -B../stage1/" CFLAGS="-S -gnatp" \
		HOST_CFLAGS= HOST_CC=cc

# Compiling object files from source files.

# Ada language specific files.

b_gnatl.c : $(GNATLINK_OBJS)
	$(GNATBIND) $(ADA_INCLUDES) -o b_gnatl.c gnatlink.ali
b_gnatl.o : b_gnatl.c

b_gnatm.c : $(GNATMAKE_OBJS)
	$(GNATBIND) $(ADA_INCLUDES) -o b_gnatm.c gnatmake.ali
b_gnatm.o : b_gnatm.c

# force debugging information on s-tasdeb.o so that it is always
# possible to set conditional breakpoints on tasks.

s-tasdeb.o  : s-tasdeb.adb s-tasdeb.ads
	$(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) $(ADA_INCLUDES) $<

# force debugging information on s-vaflop.o so that it is always
# possible to call the VAX float debug print routines.
# force at least -O so that the inline assembly works.

s-vaflop.o  : s-vaflop.adb s-vaflop.ads
	$(ADAC) -c -O $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) \
	 $(ADA_INCLUDES) $<

# force debugging information on a-except.o so that it is always
# possible to set conditional breakpoints on exceptions.
# use -O1 otherwise gdb isn't able to get a full backtrace on mips targets.

a-except.o  : a-except.adb a-except.ads
	$(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O1 -fno-inline \
	 $(ADA_INCLUDES) $<

# force debugging information on s-assert.o so that it is always
# possible to set breakpoint on assert failures.

s-assert.o  : s-assert.adb s-assert.ads a-except.ads
	$(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O2 \
	 $(ADA_INCLUDES) $<

mdll.o : mdll.adb mdll.ads mdll-file.ads mdll-utl.ads
	$(CC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< 

mdll-fil.o : mdll-fil.adb mdll.ads mdll-fil.ads
	$(CC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< 

mdll-utl.o : mdll-utl.adb mdll.ads mdll-utl.ads sdefault.ads types.ads
	$(CC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< 
  
# force debugging information and no optimization on s-memory.o so that it 
# is always possible to set breakpoint on __gnat_malloc and __gnat_free
# this is important for gnatmem using GDB. memtrack.o is built from
# memtrack.adb, and used by the post-mortem analysis with gnatmem.

s-memory.o  : s-memory.adb s-memory.ads memtrack.o
	$(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \
	 $(ADA_INCLUDES) $< 

memtrack.o  : memtrack.adb s-memory.ads
	$(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \
	 $(ADA_INCLUDES) $< 

# Need to keep the frame pointer in this file to pop the stack properly on
# some targets.

traceb.o : traceb.c
	$(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) \
	      $< 


aux-io.o  : aux-io.c
argv.o    : argv.c
cal.o     : cal.c
deftarg.o  : deftarg.c
errno.o   : errno.c
exit.o    : raise.h exit.c
expect.o  : expect.c
final.o   : raise.h final.c
gmem.o    : gmem.c
link.o    : link.c
mkdir.o   : mkdir.c
sysdep.o  : sysdep.c

cio.o     : cio.c 
	$(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \
	         $(ALL_CPPFLAGS) $(INCLUDES) $< 

init.o    : init.c ada.h types.h raise.h
	$(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \
	         $(ALL_CPPFLAGS) $(INCLUDES) $< 

raise.o   : raise.c raise.h
	$(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \
		 $(ALL_CPPFLAGS) $(INCLUDES) $< 

# Need to keep the frame pointer in this file to pop the stack properly on
# some targets.
tracebak.o  : tracebak.c
	$(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
	      -fno-omit-frame-pointer $< 

targtyps.o : targtyps.c $(CONFIG_H) ada.h types.h atree.h nlists.h elists.h \
   uintp.h sinfo.h einfo.h namet.h snames.h stringt.h urealp.h fe.h \
   $(ADA_TREE_H) gigi.h

# Rule to compile prefix.o for the run-time.

prefix.o : $(srcdir)/../prefix.c
	$(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \
	      $(ALL_CPPFLAGS) $(INCLUDES) -I$(srcdir)/../.. -I../.. \
	      -DPREFIX=\"$(prefix)\" $< 

# In GNU Make, ignore whether `stage*' exists.
.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap
.PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4

force:

# Gnatlbr is only used on VMS

GNATLBR_RTL_C_OBJS = adaint.o argv.o cio.o cstreams.o exit.o final.o init.o \
  raise.o sysdep.o tracebak.o
GNATLBR_C_OBJS = $(GNATLBR_RTL_C_OBJS)

../gnatlbr$(exeext):: sdefault.o $(GNATLBR_C_OBJS) $(EXTRA_GNATTOOLS_OBJS)
	$(RM) $@
../gnatlbr$(exeext):: force
	$(GNATMAKE) -a --GCC="$(CC)" $(ALL_ADAFLAGS) $(ADA_INCLUDES) \
	  --GNATBIND="$(GNATBIND)" --GNATLINK="$(GNATLINK)" \
	  -nostdlib $(fsrcpfx)gnatlbr -o $@ \
	  -largs --GCC="$(CC) $(ALL_CFLAGS) $(LDFLAGS)" \
	  $(GNATLBR_C_OBJS) $(EXTRA_GNATTOOLS_OBJS)