summaryrefslogtreecommitdiff
path: root/packages/gcc/gcc-4.3.1/debian/ada-sjlj.dpatch
blob: 8d480302d534998638a0f3a484821f39337899c8 (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
#! /bin/sh -e

# DP: There are two exception mechanisms to choose from: zero-cost and
# DP: setjump/longjump.  The Ada run-time library uses either of them
# DP: but not both.  Build both versions of the run-time library.

# This patch changes the way the upstream Makefiles build the run-time
# library.  Before the patch: libada/Makefile calls gcc/ada/Makefile,
# which builds the "rts" subdirectory containing symbolic links to
# most source files, and modified copies of a few source files (to
# take target dependencies into account, and also to select the
# exception handling mechanism in system.ads).  Then, gcc/ada/Makefile
# calls itself recursively but in the "rts" subdirectory and builds
# libgnat.a and libgnarl.a (and a couple other libraries:
# libgccprefix.a, libgmem.a).  Upon return from this recursive call,
# it deletes the source and object files from "rts", reconstructs the
# source files, and builds libgnat.so and libgnarl.so by calling
# itself recursively a second time in the "rts" directory.

# Furthermore, gcc/ada/Makefile disables parallel makes, so building
# the static and then shared versions of the RTS is entirely
# sequential even on SMP systems.

# As a consequence of the above, building the SJLJ version of the
# library would overwrite the ZCX version.  Thus it is necessary to
# manually save the previous version of the library before building the
# second one.

# After the patch: libada/Makefile calls gcc/ada/Makefile, which
# builds the source directory (named gnatlib-sources instead of rts),
# containing the symbolic links and target-dependent files.

# In a second step, libada/Makefile calls gcc/ada/Makefile again to
# build the targets gnatlib-shared-zcx, gnatlib-static-zcx and
# gnatlib-static-sjlj (we could also build gnatlib-shared-sjlj, but
# that triggers compiler errors on PowerPC).

# Each of these three targets copies the source directory "rts" into a
# new directory named rts-shared-zcx, rts-static-zcx or
# rts-static-sjlj.  In the new directory, they change the value of
# System.ZCX_By_Default, and then they call gcc/ada/Makefile
# recursively in the new directory to build the library.

# gcc/ada/Makefile.in has a .NOTPARALLEL directive preventing it from
# launching commands in parallel.  However, libada/Makefile has no
# such directive and can invoke up to three instances of
# gcc/ada/Makefile.in in parallel.  This is okay because each of them
# runs in a different directory.

# This patch also updates libgnat{vsn,prj}/Makefile and
# gnattools/Makefile to look for the shared ZCX version of the library
# in the appropriate directory, rather than just "rts", and updates
# the "make install" and binary targets as well.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p1 < $0
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p1 < $0
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0


Index: src/libada/Makefile.in
===================================================================
--- src.orig/libada/Makefile.in
+++ src/libada/Makefile.in
@@ -16,7 +16,8 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 # Default target; must be first.
-all: gnatlib
+GNATLIB = gnatlib-static-zcx gnatlib-static-sjlj gnatlib-shared-zcx
+all: $(GNATLIB)
 
 # Standard autoconf-set variables.
 SHELL = @SHELL@
@@ -78,30 +79,38 @@
         "CFLAGS=$(CFLAGS) $(WARN_CFLAGS)"
 
 # Rules to build gnatlib.
-.PHONY: gnatlib gnatlib-plain gnatlib-sjlj gnatlib-zcx gnatlib-shared
-gnatlib: @default_gnatlib_target@
+.PHONY: $(GNATLIB)
 
-gnatlib-plain: $(GCC_DIR)/ada/Makefile
-	test -f stamp-libada || \
+$(GCC_DIR)/ada/gnatlib-sources-sjlj/a-except.ads:
 	$(MAKE) -C $(GCC_DIR)/ada $(FLAGS_TO_PASS) \
 	  GNATLIBFLAGS="$(GNATLIBFLAGS)" \
 	  GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
 	  TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
 	  THREAD_KIND="$(THREAD_KIND)" \
 	  TRACE="$(TRACE)" \
-	  gnatlib \
-	&& touch stamp-libada
+	  EH_MECHANISM="" \
+	  gnatlib-sources-sjlj/a-except.ads
 
-gnatlib-sjlj gnatlib-zcx gnatlib-shared: $(GCC_DIR)/ada/Makefile
-	test -f stamp-libada || \
+$(GCC_DIR)/ada/gnatlib-sources-zcx/a-except.ads:
 	$(MAKE) -C $(GCC_DIR)/ada $(FLAGS_TO_PASS) \
 	  GNATLIBFLAGS="$(GNATLIBFLAGS)" \
 	  GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
 	  TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
 	  THREAD_KIND="$(THREAD_KIND)" \
 	  TRACE="$(TRACE)" \
-	  $@ \
-	&& touch stamp-libada
+	  EH_MECHANISM="-gcc" \
+	  gnatlib-sources-zcx/a-except.ads
+
+$(GNATLIB): $(GCC_DIR)/ada/Makefile \
+$(GCC_DIR)/ada/gnatlib-sources-zcx/a-except.ads \
+$(GCC_DIR)/ada/gnatlib-sources-sjlj/a-except.ads
+	$(MAKE) -C $(GCC_DIR)/ada $(FLAGS_TO_PASS) \
+	  GNATLIBFLAGS="$(GNATLIBFLAGS)" \
+	  GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
+	  TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
+	  THREAD_KIND="$(THREAD_KIND)" \
+	  TRACE="$(TRACE)" \
+	  $@
 
 # Check uninstalled version.
 check:
Index: src/libada/configure
===================================================================
--- src.orig/libada/configure
+++ src/libada/configure
@@ -1552,17 +1552,6 @@
   *) x_ada_cflags= ;;
 esac
 
-
-# Determine what to build for 'gnatlib'
-if test $build = $target \
-   && test ${enable_shared} = yes ; then
-  # Note that build=target is almost certainly the wrong test; FIXME
-  default_gnatlib_target="gnatlib-shared"
-else
-  default_gnatlib_target="gnatlib-plain"
-fi
-
-
 # Output: create a Makefile.
           ac_config_files="$ac_config_files Makefile"
 
@@ -2222,7 +2211,6 @@
 s,@enable_shared@,$enable_shared,;t t
 s,@LN_S@,$LN_S,;t t
 s,@x_ada_cflags@,$x_ada_cflags,;t t
-s,@default_gnatlib_target@,$default_gnatlib_target,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
Index: src/gcc/ada/Makefile.in
===================================================================
--- src.orig/gcc/ada/Makefile.in
+++ src/gcc/ada/Makefile.in
@@ -1324,6 +1324,50 @@
   LIBRARY_VERSION := $(LIB_VERSION)
 endif
 
+ifeq ($(strip $(filter-out mips linux%,$(arch) $(osys))),)
+  LIBGNAT_TARGET_PAIRS = \
+  a-intnam.ads<a-intnam-linux.ads \
+  g-soccon.ads<g-soccon-linux-mips.ads \
+  s-inmaop.adb<s-inmaop-posix.adb \
+  s-intman.adb<s-intman-posix.adb \
+  s-osinte.adb<s-osinte-posix.adb \
+  s-osinte.ads<s-osinte-linux.ads \
+  s-osprim.adb<s-osprim-posix.adb \
+  s-taprop.adb<s-taprop-linux.adb \
+  s-taspri.ads<s-taspri-posix.ads \
+  s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
+  system.ads<system-linux-mips.ads
+
+  EH_MECHANISM=-gcc
+  THREADSLIB = -lpthread
+  GNATLIB_SHARED = gnatlib-shared-dual
+  GMEM_LIB = gmemlib
+  PREFIX_OBJS = $(PREFIX_REAL_OBJS)
+  LIBRARY_VERSION := $(LIB_VERSION)
+endif
+
+ifeq ($(strip $(filter-out mipsel linux%,$(arch) $(osys))),)
+  LIBGNAT_TARGET_PAIRS = \
+  a-intnam.ads<a-intnam-linux.ads \
+  g-soccon.ads<g-soccon-linux-mips.ads \
+  s-inmaop.adb<s-inmaop-posix.adb \
+  s-intman.adb<s-intman-posix.adb \
+  s-osinte.adb<s-osinte-posix.adb \
+  s-osinte.ads<s-osinte-linux.ads \
+  s-osprim.adb<s-osprim-posix.adb \
+  s-taprop.adb<s-taprop-linux.adb \
+  s-taspri.ads<s-taspri-posix.ads \
+  s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
+  system.ads<system-linux-mipsel.ads
+
+  EH_MECHANISM=-gcc
+  THREADSLIB = -lpthread
+  GNATLIB_SHARED = gnatlib-shared-dual
+  GMEM_LIB = gmemlib
+  PREFIX_OBJS = $(PREFIX_REAL_OBJS)
+  LIBRARY_VERSION := $(LIB_VERSION)
+endif
+
 ifeq ($(strip $(filter-out sparc% linux%,$(arch) $(osys))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-linux.ads \
@@ -1563,53 +1607,79 @@
  a-[a-o]*.adb a-[p-z]*.adb a-[a-o]*.ads a-[p-z]*.ads g-*.ad? i-*.ad? \
  s-[a-o]*.adb s-[p-z]*.adb s-[a-o]*.ads s-[p-z]*.ads  
 
-../stamp-gnatlib:
-	@if [ ! -f stamp-gnatlib ] ; \
-	then \
-	  $(ECHO) You must first build the GNAT library: make gnatlib; \
-	  false; \
-	else \
-	  true; \
-	fi
+libgnat = libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
+libgnat-sjlj = libgnat$(hyphen)sjlj$(hyphen)$(LIBRARY_VERSION)$(soext)
 
-install-gnatlib: ../stamp-gnatlib
+install-gnatlib: rts-static-zcx/libgnat$(arext) rts-static-sjlj/libgnat$(arext)
+install-gnatlib: rts-shared-zcx/$(libgnat)
 #	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) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
-	-$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
-	$(RMDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
-	$(RMDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
-	-$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
-	-$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
-	for file in rts/*.ali; do \
-	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
+	-$(MKDIR) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR)
+	$(RMDIR) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR)
+	$(RMDIR) $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR)
+
+	-$(MKDIR) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR)
+	$(RMDIR) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR)
+	$(RMDIR) $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR)
+
+	for file in rts-shared-zcx/*.ali; do \
+	$(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR); \
+	done
+	for file in rts-static-sjlj/*.ali; do \
+	$(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR); \
+	done
+
+	-cd rts-static-zcx; for file in *$(arext);do \
+	$(INSTALL_DATA) $$file $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR); \
+	$(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR)/$$file; \
 	done
-	-cd rts; for file in *$(arext);do \
-	    $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
-	    $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$$file; \
+	-cd rts-static-sjlj; for file in *$(arext);do \
+	$(INSTALL_DATA) $$file $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR); \
+	$(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR)/$$file; \
 	done
+
+	-$(foreach file, $(EXTRA_ADALIB_FILES), \
+	    $(INSTALL_DATA_DATE) rts-static-zcx/$(file) $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR) && \
+	) true
 	-$(foreach file, $(EXTRA_ADALIB_FILES), \
-	    $(INSTALL_DATA_DATE) rts/$(file) $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \
+	    $(INSTALL_DATA_DATE) rts-static-sjlj/$(file) $(DESTDIR)$(ADA_SJLJ_RTL_OBJ_DIR) && \
 	) true
+
 #     Install the shared libraries, if any, using $(INSTALL) instead
 #     of $(INSTALL_DATA). The latter may force a mode inappropriate
 #     for shared libraries on some targets, e.g. on HP-UX where the x
 #     permission is required.
 	for file in gnat gnarl; do \
-	   if [ -f rts/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) ]; then \
-	      $(INSTALL) rts/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
-			 $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
+	   if [ -f rts-shared-zcx/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 ]; then \
+	      $(INSTALL) rts-shared-zcx/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
+			 $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR); \
 	      $(LN_S) lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
-	      $(DESTDIR)$(ADA_RTL_OBJ_DIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext); \
+	      $(DESTDIR)$(ADA_NATIVE_RTL_OBJ_DIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext); \
 	   fi; \
 	done
+
 # This copy must be done preserving the date on the original file.
-	for file in rts/*.ad?; do \
-	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \
+	for file in rts-shared-zcx/*.adb rts-shared-zcx/*.ads; do \
+	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR); \
+	done
+	$(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR)/*.adb
+	$(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_NATIVE_INCLUDE_DIR)/*.ads
+	for file in rts-static-sjlj/*.adb rts-static-sjlj/*.ads; do \
+	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR); \
 	done
-	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
-	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads
+	$(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR)/*.adb
+	$(CHMOD) u=rw,go=r $(DESTDIR)$(ADA_SJLJ_INCLUDE_DIR)/*.ads
+
+	(cd $(DESTDIR)$(libsubdir); \
+	ln -s rts-native/adainclude adainclude; \
+	ln -s rts-native/adalib     adalib;)
 
 # NOTE: The $(foreach ...) commands assume ";" is the valid separator between
 #       successive target commands. Although the Gnu make documentation
@@ -1620,23 +1690,30 @@
 
 # GNULLI Begin ###########################################################
 
-../stamp-gnatlib1: Makefile
-	$(RMDIR) rts
-	$(MKDIR) rts
-	$(CHMOD) u+w rts
+replace_zcx_by_default=\
+'s/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := $(zcx_by_default);/'
+
+gnatlib-sources-zcx/a-except.ads: dir=$(dir $@)
+gnatlib-sources-zcx/a-except.ads: zcx_by_default=True
+
+gnatlib-sources-sjlj/a-except.ads: dir=$(dir $@)
+gnatlib-sources-sjlj/a-except.ads: zcx_by_default=False
+
+gnatlib-sources-zcx/a-except.ads gnatlib-sources-sjlj/a-except.ads:
+	$(MKDIR) $(dir)
+	$(CHMOD) u+w $(dir)
 # Copy target independent sources
 	$(foreach f,$(ADA_INCLUDE_SRCS) $(LIBGNAT_SRCS), \
-	  $(LN_S) $(fsrcpfx)$(f) rts ;) true
+	  $(LN_S) $(fsrcpfx)$(f) $(dir) ;) true
 # Remove files to be replaced by target dependent sources
 	$(RM) $(foreach PAIR,$(LIBGNAT_TARGET_PAIRS), \
-	                rts/$(word 1,$(subst <, ,$(PAIR))))
-	$(RM) rts/*-*-*.ads rts/*-*-*.adb
+	                $(dir)/$(word 1,$(subst <, ,$(PAIR))))
+	$(RM) $(dir)/*-*-*.ads $(dir)/*-*-*.adb
 # 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
+	                $(dir)/$(word 1,$(subst <, ,$(PAIR)));)
+	sed -e $(replace_zcx_by_default) $(dir)/system.ads > $(dir)/s.ads
 
 # GNULLI End #############################################################
 
@@ -1646,57 +1723,60 @@
 # Example: cd rts; ar rc libfoo.a $(LONG_LIST_OF_OBJS)
 # is guaranteed to overflow the buffer.
 
-gnatlib: ../stamp-gnatlib1
-	$(MAKE) -C rts \
+%/libgnat$(arext): build_dir = $(dir $@)
+%/libgnat$(arext): libgnarl = $(subst libgnat,libgnarl,$@)
+%/libgnat$(arext): libgnala = $(subst libgnat,libgnala,$@)
+%/libgnat$(arext): %
+	$(MAKE) -C $(build_dir) \
 		CC="`echo \"$(GCC_FOR_TARGET)\" \
 		| sed -e 's,^\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
-	        INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
-                CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \
-	        FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
+		INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
+		CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \
 		srcdir=$(fsrcdir) \
-	        -f ../Makefile $(LIBGNAT_OBJS)
-	$(MAKE) -C rts \
+		-f ../Makefile $(LIBGNAT_OBJS)
+	$(MAKE) -C $(build_dir) \
 		CC="`echo \"$(GCC_FOR_TARGET)\" \
 		| sed -e 's,^\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
-	        ADA_INCLUDES="" \
-                CFLAGS="$(GNATLIBCFLAGS)" \
-	        ADAFLAGS="$(GNATLIBFLAGS)" \
-	        FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
+		ADA_INCLUDES="" \
+		CFLAGS="$(GNATLIBCFLAGS)" \
+		ADAFLAGS="$(GNATLIBFLAGS)" \
 		srcdir=$(fsrcdir) \
-	        -f ../Makefile \
-	        $(GNATRTL_OBJS)
-	$(RM) rts/libgnat$(arext) rts/libgnarl$(arext)
-	$(AR_FOR_TARGET) $(AR_FLAGS) rts/libgnat$(arext) \
-	   $(addprefix rts/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) g-trasym.o convert_addresses.o)
+		-f ../Makefile \
+		$(GNATRTL_OBJS)
+	$(RM) $@ $(libgnarl)
+	$(AR_FOR_TARGET) $(AR_FLAGS) $@ \
+	   $(addprefix $(build_dir),$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) g-trasym.o convert_addresses.o)
         ifneq ($(PREFIX_OBJS),)
-		$(AR_FOR_TARGET) $(AR_FLAGS) rts/libgccprefix$(arext) \
+		$(AR_FOR_TARGET) $(AR_FLAGS) $(build_dir)libgccprefix$(arext) \
 		  $(PREFIX_OBJS);
-		$(RANLIB_FOR_TARGET) rts/libgccprefix$(arext)
+		$(RANLIB_FOR_TARGET) $(build_dir)libgccprefix$(arext)
         endif
-	$(RANLIB_FOR_TARGET) rts/libgnat$(arext)
-	$(AR_FOR_TARGET) $(AR_FLAGS) rts/libgnarl$(arext) \
-	   $(addprefix rts/,$(GNATRTL_TASKING_OBJS))
-	$(RANLIB_FOR_TARGET) rts/libgnarl$(arext)
-	$(AR_FOR_TARGET) $(AR_FLAGS) rts/libgnala$(arext) \
-	   $(addprefix rts/,$(GNATRTL_LINEARALGEBRA_OBJS))
-	$(RANLIB_FOR_TARGET) rts/libgnala$(arext)
+	$(RANLIB_FOR_TARGET) $@
+	$(AR_FOR_TARGET) $(AR_FLAGS) $(libgnarl) \
+	   $(addprefix $(build_dir),$(GNATRTL_TASKING_OBJS))
+	$(RANLIB_FOR_TARGET) $(libgnarl)
+	$(AR_FOR_TARGET) $(AR_FLAGS) $(libgnala) \
+	   $(addprefix $(build_dir),$(GNATRTL_LINEARALGEBRA_OBJS))
+	$(RANLIB_FOR_TARGET) $(libgnala)
         ifeq ($(GMEM_LIB),gmemlib)
-		$(AR_FOR_TARGET) $(AR_FLAGS) rts/libgmem$(arext) \
-		  rts/memtrack.o
-		$(RANLIB_FOR_TARGET) rts/libgmem$(arext)
+		$(AR_FOR_TARGET) $(AR_FLAGS) $(build_dir)libgmem$(arext) \
+		  $(build_dir)memtrack.o
+		$(RANLIB_FOR_TARGET) $(build_dir)libgmem$(arext)
         endif
-	touch ../stamp-gnatlib
 
 # Warning: this target assumes that LIBRARY_VERSION has been set correctly.
-gnatlib-shared-default: ../stamp-gnatlib1
-	$(MAKE) -C rts \
+%/$(libgnat) %/$(libgnat-sjlj): build_dir = $(dir $@)
+%/$(libgnat) %/$(libgnat-sjlj): libgnarl = $(notdir $(subst libgnat,libgnarl,$@))
+%/$(libgnat) %/$(libgnat-sjlj): libgnala = $(notdir $(subst libgnat,libgnala,$@))
+%/$(libgnat) %/$(libgnat-sjlj): %
+	$(MAKE) -C $(build_dir) \
 		CC="`echo \"$(GCC_FOR_TARGET)\" \
 		| sed -e 's,^\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
 	        INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
                 CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \
 		srcdir=$(fsrcdir) \
 	        -f ../Makefile $(LIBGNAT_OBJS)
-	$(MAKE) -C rts \
+	$(MAKE) -C $(build_dir) \
 		CC="`echo \"$(GCC_FOR_TARGET)\" \
 		| sed -e 's,^\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
 	        ADA_INCLUDES="" \
@@ -1706,157 +1786,75 @@
 		srcdir=$(fsrcdir) \
 	        -f ../Makefile \
 	        $(GNATRTL_OBJS)
-	$(RM) rts/libgna*$(soext) rts/libgna*$(soext).1
-	cd rts; ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
+	$(RM) $(build_dir)/libgna*$(soext) $(build_dir)/libgna*$(soext).1
+	cd $(build_dir); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
 		$(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
+		-o $(notdir $@).1 \
 		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
 		g-trasym.o convert_addresses.o \
-		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
+		$(SO_OPTS)$(notdir $@).1 \
 		$(MISCLIB) -lm
-	cd rts; ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
+	cd $(build_dir); $(LN_S) $(notdir $@).1 $(notdir $@)
+	cd $(build_dir); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
 		$(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
+		-o $(libgnarl).1 \
 		$(GNATRTL_TASKING_OBJS) \
-		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
+		$(SO_OPTS)$(libgnarl).1 \
 		$(THREADSLIB)
-	cd rts; for lib in gnat gnarl; do \
-		l=lib$${lib}$(hyphen)$(LIBRARY_VERSION)$(soext); \
-		$(LN_S) $$l.1 $$l; \
-	done
-# Delete the object files, lest they be linked statically into the tools
-# executables.  Only the .ali, .a and .so files must remain.
-	rm -f rts/*.o
-	$(CHMOD) a-wx rts/*.ali
-
-gnatlib-shared-dual:
-	$(MAKE) $(FLAGS_TO_PASS) \
-             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-             gnatlib
-	$(RM) rts/*.o rts/*.ali
-	$(MAKE) $(FLAGS_TO_PASS) \
-             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-             gnatlib-shared-default
-
-gnatlib-shared-dual-win32:
-	$(MAKE) $(FLAGS_TO_PASS) \
-             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-             gnatlib
-	$(RM) rts/*.o rts/*.ali
-	$(MAKE) $(FLAGS_TO_PASS) \
-             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-             gnatlib-shared-win32
-
-# ??? we need to add the option to support auto-import of arrays/records to
-# the GNATLIBFLAGS when this will be supported by GNAT. At this point we will
-# use the gnatlib-shared-dual-win32 target to build the GNAT runtimes on
-# Windows.
-gnatlib-shared-win32:
-	$(MAKE) $(FLAGS_TO_PASS) \
-             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-             gnatlib
-	$(RM) rts/libgna*$(soext)
-	cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
-		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB)
-	cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		$(GNATRTL_TASKING_OBJS) \
-		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
-
-gnatlib-shared-darwin:
-	$(MAKE) $(FLAGS_TO_PASS) \
-	     GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) \
-	                    -fno-common" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-	     gnatlib
-	$(RM) rts/libgnat$(soext) rts/libgnarl$(soext)
-	cd rts; ../../xgcc -B../../ -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
-		$(SO_OPTS) \
-		$(MISCLIB) -lm
-	cd rts; ../../xgcc -B../../ -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		$(GNATRTL_TASKING_OBJS) \
-		$(SO_OPTS) \
-		$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
-	cd rts; $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		libgnat$(soext)
-	cd rts; $(LN_S) libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		libgnarl$(soext)
-
-gnatlib-shared-vms:
-	$(MAKE) $(FLAGS_TO_PASS) \
-             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-             gnatlib
-	$(RM) rts/libgna*$(soext)
-	cd rts && echo "case_sensitive=yes" > SYMVEC_$$$$.opt && \
-	objdump --syms $(LIBGNAT_OBJS) $(GNATRTL_NONTASKING_OBJS) | \
-	$(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt && \
-	echo "case_sensitive=NO" >> SYMVEC_$$$$.opt && \
-	../../xgcc -g -B../../ -shared -shared-libgcc \
-	   -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) libgnat.a \
-	   sys\$$library:trace.exe \
-	   --for-linker=/noinform \
-	   --for-linker=SYMVEC_$$$$.opt \
-	   --for-linker=gsmatch=equal,$(GSMATCH_VERSION)
-	cd rts && echo "case_sensitive=yes" > SYMVEC_$$$$.opt && \
-	objdump --syms $(GNATRTL_TASKING_OBJS) | \
-	$(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt && \
-	echo "case_sensitive=NO" >> SYMVEC_$$$$.opt && \
-	../../xgcc -g -B../../ -shared -shared-libgcc \
-	   -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
-	   libgnarl.a libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
-	   sys\$$library:trace.exe \
-	   --for-linker=/noinform \
-	   --for-linker=SYMVEC_$$$$.opt \
-	   --for-linker=gsmatch=equal,$(GSMATCH_VERSION)
+	cd $(build_dir); $(LN_S) $(libgnarl).1 $(libgnarl)
+# TODO: enable building the shared libgnala
+ifeq (libgnala-shared-enabled,yes)
+	cd $(build_dir); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
+		$(TARGET_LIBGCC2_CFLAGS) \
+		-o $(libgnala).1 \
+		$(GNATRTL_LINEARALGEBRA_OBJS) \
+		$(SO_OPTS)$(libgnala).1
+	cd $(build_dir); $(LN_S) $(libgnala).1 $(libgnala)
+endif
 
-gnatlib-shared:
+gnatlib-shared-dual: gnatlib-static-zcx gnatlib-static-sjlj gnatlib-shared-zcx
+
+gnatlib-shared-zcx: rts = $(subst gnatlib,rts,$@)
+gnatlib-shared-zcx: gnatlib-sources-zcx/a-except.ads
+	if [ ! -d $(rts) ] ; then \
+	    cp -a gnatlib-sources-zcx $(rts); \
+	    $(MV) $(rts)/s.ads $(rts)/system.ads; \
+	fi
 	$(MAKE) $(FLAGS_TO_PASS) \
+	     EH_MECHANISM="-gcc" \
              GNATLIBFLAGS="$(GNATLIBFLAGS)" \
 	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
 	     THREAD_KIND="$(THREAD_KIND)" \
 	     TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
-             $(GNATLIB_SHARED)
+             $(rts)/$(libgnat)
 
-gnatlib-sjlj:
-	$(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="" ../stamp-gnatlib1
-	sed -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := False;/' rts/system.ads > rts/s.ads
-	$(MV) rts/s.ads rts/system.ads
+gnatlib-static-sjlj: rts = $(subst gnatlib,rts,$@)
+gnatlib-static-sjlj: gnatlib-sources-sjlj/a-except.ads
+	if [ ! -d $(rts) ] ; then \
+	    cp -a gnatlib-sources-sjlj $(rts); \
+	    $(MV) $(rts)/s.ads $(rts)/system.ads; \
+	fi
 	$(MAKE) $(FLAGS_TO_PASS) \
 	     EH_MECHANISM="" \
 	     GNATLIBFLAGS="$(GNATLIBFLAGS)" \
 	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
 	     THREAD_KIND="$(THREAD_KIND)" \
-	     TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib
+	     TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
+	     $(rts)/libgnat$(arext)
 
-gnatlib-zcx:
-	$(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="-gcc" ../stamp-gnatlib1
-	sed -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := True;/' rts/system.ads > rts/s.ads
-	$(MV) rts/s.ads rts/system.ads
+gnatlib-static-zcx: rts = $(subst gnatlib,rts,$@)
+gnatlib-static-zcx: gnatlib-sources-zcx/a-except.ads
+	if [ ! -d $(rts) ] ; then \
+	    cp -a gnatlib-sources-zcx $(rts); \
+	    $(MV) $(rts)/s.ads $(rts)/system.ads; \
+	fi
 	$(MAKE) $(FLAGS_TO_PASS) \
 	     EH_MECHANISM="-gcc" \
 	     GNATLIBFLAGS="$(GNATLIBFLAGS)" \
 	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
 	     THREAD_KIND="$(THREAD_KIND)" \
-	     TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib
+	     TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
+	     $(rts)/libgnat$(arext)
 
 # .s files for cross-building
 gnat-cross: force
@@ -1864,6 +1862,10 @@
 
 ADA_INCLUDE_DIR = $(libsubdir)/adainclude
 ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
+ADA_NATIVE_INCLUDE_DIR = $(libsubdir)/rts-native/adainclude
+ADA_NATIVE_RTL_OBJ_DIR = $(libsubdir)/rts-native/adalib
+ADA_SJLJ_INCLUDE_DIR = $(libsubdir)/rts-sjlj/adainclude
+ADA_SJLJ_RTL_OBJ_DIR = $(libsubdir)/rts-sjlj/adalib
 
 # force no sibling call optimization on s-traceb.o so the number of stack
 # frames to be skipped when computing a call chain is not modified by
Index: src/gnattools/Makefile.in
===================================================================
--- src.orig/gnattools/Makefile.in
+++ src/gnattools/Makefile.in
@@ -34,12 +34,13 @@
 LN_S=@LN_S@
 target_noncanonical=@target_noncanonical@
 
+RTS=../gcc/ada/rts-shared-zcx
 CFLAGS=-O2 -Wall
 ADA_CFLAGS=-O2 -gnatn
-ADA_INCLUDES=-nostdinc -I- -I. -I../gcc/ada/rts -I../libgnatvsn -I../libgnatprj
+ADA_INCLUDES=-nostdinc -I- -I. -I$(RTS) -I../libgnatvsn -I../libgnatprj
 LIB_VERSION=$(strip $(shell grep ' Library_Version :' \
               ../libgnatvsn/gnatvsn.ads | sed -e 's/.*"\(.*\)".*/\1/'))
-ADA_LIBS := -L../gcc/ada/rts -lgnat-$(LIB_VERSION)
+ADA_LIBS := -L$(RTS) -lgnat-$(LIB_VERSION)
 ADA_LIBS += -L../libgnatvsn -lgnatvsn
 ADA_LIBS += -L../libgnatprj -lgnatprj
 
@@ -109,6 +110,7 @@
 
 .PHONY: gnattools gnattools-native gnattools-cross regnattools
 gnattools: @default_gnattools_target@
+	(cd $(RTS); if [ -d obj ]; then mv obj/* .; rmdir obj; fi)
 
 BODIES := $(foreach f,$(OBJECTS),$(wildcard $(patsubst %.o,@srcdir@/../gcc/ada/%.adb,$(f))))
 SPECS  := $(foreach f,$(OBJECTS),$(wildcard $(patsubst %.o,@srcdir@/../gcc/ada/%.ads,$(f))))
@@ -119,9 +121,12 @@
 	for file in $(BODIES) $(SPECS); do \
 	   $(LN_S) -f $$file .; \
 	done
+# Move the RTS object files away lest they be linked statically into the
+# tools.  Only the .ali, .a and .so files must remain.
+	(cd $(RTS); mkdir obj; mv *.o obj; chmod a-wx *.ali)
 	touch $@
 
-gnattools-native: ../gcc/ada/rts/libgnat-$(LIB_VERSION).so
+gnattools-native: $(RTS)/libgnat-$(LIB_VERSION).so
 gnattools-native: ../libgnatvsn/libgnatvsn.so
 gnattools-native: stamp-gnattools-sources
 gnattools-native: $(TOOLS) gnatbl
@@ -137,7 +142,7 @@
 	$(GCC) -o $@ $^ \
 	   ../libgnatprj/libgnatprj.a \
 	   ../libgnatvsn/libgnatvsn.a \
-	   ../gcc/ada/rts/libgnat.a \
+	   ../gcc/ada/rts-static-zcx/libgnat.a \
 	   ../libiberty/libiberty.a
 
 gnatlink: $(GNATLINK_OBJS) b_gnatl.o
@@ -155,7 +160,7 @@
 	$(GCC) -o $@ $(ADA_CFLAGS) $^ \
 	   ../libgnatprj/libgnatprj.a \
 	   ../libgnatvsn/libgnatvsn.a \
-	   ../gcc/ada/rts/libgnat.a \
+	   ../gcc/ada/rts-static-zcx/libgnat.a \
 	   ../libiberty/libiberty.a
 
 gnatmake: $(GNATMAKE_OBJS) b_gnatm.o
Index: src/libgnatprj/Makefile.in
===================================================================
--- src.orig/libgnatprj/Makefile.in
+++ src/libgnatprj/Makefile.in
@@ -25,7 +25,8 @@
                  @srcdir@/../gcc/ada/gnatvsn.ads | \
 	         sed -e 's/.*"\(.*\)".*/\1/'))
 GCC:=../gcc/xgcc -B../gcc/
-LIBGNAT_JUST_BUILT := -nostdinc -I../gcc/ada/rts
+RTS:=../gcc/ada/rts-shared-zcx
+LIBGNAT_JUST_BUILT := -nostdinc -I$(RTS)
 LIBGNATVSN := -I../libgnatvsn
 CFLAGS := -g -O2
 ADAFLAGS := -g -O2 -gnatn
@@ -65,7 +66,7 @@
 libgnatprj.so.$(LIB_VERSION): $(addprefix obj-shared/,$(OBJECTS))
 	: # Make libgnatprj.so
 	$(GCC) -o $@ -shared -fPIC -Wl,--soname,$@ $^ \
-	   -L../gcc/ada/rts -lgnat-$(LIB_VERSION) \
+	   -L$(RTS) -lgnat-$(LIB_VERSION) \
 	   -L../libgnatvsn -lgnatvsn
 	$(LN_S) -f libgnatprj.so.$(LIB_VERSION) libgnatprj.so
 	chmod a=r obj-shared/*.ali
Index: src/libgnatvsn/Makefile.in
===================================================================
--- src.orig/libgnatvsn/Makefile.in
+++ src/libgnatvsn/Makefile.in
@@ -25,7 +25,8 @@
                  @srcdir@/../gcc/ada/gnatvsn.ads | \
 	         sed -e 's/.*"\(.*\)".*/\1/'))
 GCC:=../gcc/xgcc -B../gcc/
-LIBGNAT_JUST_BUILT := -nostdinc -I../gcc/ada/rts
+RTS:=../gcc/ada/rts-shared-zcx
+LIBGNAT_JUST_BUILT := -nostdinc -I$(RTS)
 CFLAGS := -g -O2 -gnatn
 BASEVER := $(shell cat @srcdir@/../gcc/BASE-VER)
 DEVPHASE := $(shell cat @srcdir@/../gcc/DEV-PHASE)
@@ -64,7 +65,7 @@
 libgnatvsn.so.$(LIB_VERSION): $(addprefix obj-shared/,$(OBJECTS))
 	: # Make libgnatvsn.so
 	$(GCC) -o $@ -shared -fPIC -Wl,--soname,$@ $^ \
-	   -L../gcc/ada/rts -lgnat-$(LIB_VERSION)
+	   -L$(RTS) -lgnat-$(LIB_VERSION)
 	ln -s libgnatvsn.so.$(LIB_VERSION) libgnatvsn.so
 	chmod a=r obj-shared/*.ali
 # Make the .ali files, but not the .o files, visible to the gnat tools.
Index: src/gcc/ada/Make-lang.in
===================================================================
--- src.orig/gcc/ada/Make-lang.in
+++ src/gcc/ada/Make-lang.in
@@ -62,7 +62,8 @@
 	"ADA_FOR_TARGET=$(ADA_FOR_TARGET)"	\
 	"INSTALL=$(INSTALL)" 			\
 	"INSTALL_DATA=$(INSTALL_DATA)"		\
-	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)"
+	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)"	\
+	"GCC_FOR_TARGET=$(GCC_FOR_TARGET)"
 
 # Say how to compile Ada programs.
 .SUFFIXES: .ada .adb .ads
Index: src/gcc/ada/system-linux-mips.ads
===================================================================
--- /dev/null
+++ src/gcc/ada/system-linux-mips.ads
@@ -0,0 +1,154 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                        GNAT RUN-TIME COMPONENTS                          --
+--                                                                          --
+--                               S Y S T E M                                --
+--                                                                          --
+--                                 S p e c                                  --
+--                          (GNU-Linux/MIPS Version)                        --
+--                                                                          --
+--          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--                                                                          --
+-- This specification is derived from the Ada Reference Manual for use with --
+-- GNAT. The copyright notice above, and the license provisions that follow --
+-- apply solely to the  contents of the part following the private keyword. --
+--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT 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  distributed with GNAT;  see file COPYING.  If not, write --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
+--                                                                          --
+-- As a special exception,  if other files  instantiate  generics from this --
+-- unit, or you link  this unit with other files  to produce an executable, --
+-- this  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.                                      --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+package System is
+   pragma Pure;
+   --  Note that we take advantage of the implementation permission to make
+   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
+   --  2005, this is Pure in any case (AI-362).
+
+   type Name is (SYSTEM_NAME_GNAT);
+   System_Name : constant Name := SYSTEM_NAME_GNAT;
+
+   --  System-Dependent Named Numbers
+
+   Min_Int               : constant := Long_Long_Integer'First;
+   Max_Int               : constant := Long_Long_Integer'Last;
+
+   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
+   Max_Nonbinary_Modulus : constant := Integer'Last;
+
+   Max_Base_Digits       : constant := Long_Long_Float'Digits;
+   Max_Digits            : constant := Long_Long_Float'Digits;
+
+   Max_Mantissa          : constant := 63;
+   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
+
+   Tick                  : constant := 0.000_001;
+
+   --  Storage-related Declarations
+
+   type Address is private;
+   Null_Address : constant Address;
+
+   Storage_Unit : constant := 8;
+   Word_Size    : constant := 32;
+   Memory_Size  : constant := 2 ** 32;
+
+   --  Address comparison
+
+   function "<"  (Left, Right : Address) return Boolean;
+   function "<=" (Left, Right : Address) return Boolean;
+   function ">"  (Left, Right : Address) return Boolean;
+   function ">=" (Left, Right : Address) return Boolean;
+   function "="  (Left, Right : Address) return Boolean;
+
+   pragma Import (Intrinsic, "<");
+   pragma Import (Intrinsic, "<=");
+   pragma Import (Intrinsic, ">");
+   pragma Import (Intrinsic, ">=");
+   pragma Import (Intrinsic, "=");
+
+   --  Other System-Dependent Declarations
+
+   type Bit_Order is (High_Order_First, Low_Order_First);
+   Default_Bit_Order : constant Bit_Order := High_Order_First;
+   pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
+
+   --  Priority-related Declarations (RM D.1)
+
+   Max_Priority           : constant Positive := 30;
+   Max_Interrupt_Priority : constant Positive := 31;
+
+   subtype Any_Priority       is Integer      range  0 .. 31;
+   subtype Priority           is Any_Priority range  0 .. 30;
+   subtype Interrupt_Priority is Any_Priority range 31 .. 31;
+
+   Default_Priority : constant Priority := 15;
+
+private
+
+   type Address is mod Memory_Size;
+   Null_Address : constant Address := 0;
+
+   --------------------------------------
+   -- System Implementation Parameters --
+   --------------------------------------
+
+   --  These parameters provide information about the target that is used
+   --  by the compiler. They are in the private part of System, where they
+   --  can be accessed using the special circuitry in the Targparm unit
+   --  whose source should be consulted for more detailed descriptions
+   --  of the individual switch values.
+
+   AAMP                      : constant Boolean := False;
+   Backend_Divide_Checks     : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := False;
+   Command_Line_Args         : constant Boolean := True;
+   Compiler_System_Version   : constant Boolean := False;
+   Configurable_Run_Time     : constant Boolean := False;
+   Denorm                    : constant Boolean := True;
+   Duration_32_Bits          : constant Boolean := False;
+   Exit_Status_Supported     : constant Boolean := True;
+   Fractional_Fixed_Ops      : constant Boolean := False;
+   Frontend_Layout           : constant Boolean := False;
+   Functions_Return_By_DSP   : constant Boolean := False;
+   Machine_Overflows         : constant Boolean := False;
+   Machine_Rounds            : constant Boolean := True;
+   OpenVMS                   : constant Boolean := False;
+   Preallocated_Stacks       : constant Boolean := False;
+   Signed_Zeros              : constant Boolean := True;
+   Stack_Check_Default       : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := False;
+   Support_64_Bit_Divides    : constant Boolean := True;
+   Support_Aggregates        : constant Boolean := True;
+   Support_Composite_Assign  : constant Boolean := True;
+   Support_Composite_Compare : constant Boolean := True;
+   Support_Long_Shifts       : constant Boolean := True;
+   Suppress_Standard_Library : constant Boolean := False;
+   Use_Ada_Main_Program_Name : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := True;
+   GCC_ZCX_Support           : constant Boolean := True;
+   Front_End_ZCX_Support     : constant Boolean := False;
+
+   --  Obsolete entries, to be removed eventually (bootstrap issues!)
+
+   High_Integrity_Mode       : constant Boolean := False;
+   Long_Shifts_Inlined       : constant Boolean := True;
+
+end System;
Index: src/gcc/ada/system-linux-mipsel.ads
===================================================================
--- /dev/null
+++ src/gcc/ada/system-linux-mipsel.ads
@@ -0,0 +1,154 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                        GNAT RUN-TIME COMPONENTS                          --
+--                                                                          --
+--                               S Y S T E M                                --
+--                                                                          --
+--                                 S p e c                                  --
+--                        (GNU-Linux/MIPSEL Version)                        --
+--                                                                          --
+--          Copyright (C) 1992-2005, Free Software Foundation, Inc.         --
+--                                                                          --
+-- This specification is derived from the Ada Reference Manual for use with --
+-- GNAT. The copyright notice above, and the license provisions that follow --
+-- apply solely to the  contents of the part following the private keyword. --
+--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT 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  distributed with GNAT;  see file COPYING.  If not, write --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
+--                                                                          --
+-- As a special exception,  if other files  instantiate  generics from this --
+-- unit, or you link  this unit with other files  to produce an executable, --
+-- this  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.                                      --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+package System is
+   pragma Pure;
+   --  Note that we take advantage of the implementation permission to make
+   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
+   --  2005, this is Pure in any case (AI-362).
+
+   type Name is (SYSTEM_NAME_GNAT);
+   System_Name : constant Name := SYSTEM_NAME_GNAT;
+
+   --  System-Dependent Named Numbers
+
+   Min_Int               : constant := Long_Long_Integer'First;
+   Max_Int               : constant := Long_Long_Integer'Last;
+
+   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
+   Max_Nonbinary_Modulus : constant := Integer'Last;
+
+   Max_Base_Digits       : constant := Long_Long_Float'Digits;
+   Max_Digits            : constant := Long_Long_Float'Digits;
+
+   Max_Mantissa          : constant := 63;
+   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
+
+   Tick                  : constant := 0.000_001;
+
+   --  Storage-related Declarations
+
+   type Address is private;
+   Null_Address : constant Address;
+
+   Storage_Unit : constant := 8;
+   Word_Size    : constant := 32;
+   Memory_Size  : constant := 2 ** 32;
+
+   --  Address comparison
+
+   function "<"  (Left, Right : Address) return Boolean;
+   function "<=" (Left, Right : Address) return Boolean;
+   function ">"  (Left, Right : Address) return Boolean;
+   function ">=" (Left, Right : Address) return Boolean;
+   function "="  (Left, Right : Address) return Boolean;
+
+   pragma Import (Intrinsic, "<");
+   pragma Import (Intrinsic, "<=");
+   pragma Import (Intrinsic, ">");
+   pragma Import (Intrinsic, ">=");
+   pragma Import (Intrinsic, "=");
+
+   --  Other System-Dependent Declarations
+
+   type Bit_Order is (High_Order_First, Low_Order_First);
+   Default_Bit_Order : constant Bit_Order := Low_Order_First;
+   pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
+
+   --  Priority-related Declarations (RM D.1)
+
+   Max_Priority           : constant Positive := 30;
+   Max_Interrupt_Priority : constant Positive := 31;
+
+   subtype Any_Priority       is Integer      range  0 .. 31;
+   subtype Priority           is Any_Priority range  0 .. 30;
+   subtype Interrupt_Priority is Any_Priority range 31 .. 31;
+
+   Default_Priority : constant Priority := 15;
+
+private
+
+   type Address is mod Memory_Size;
+   Null_Address : constant Address := 0;
+
+   --------------------------------------
+   -- System Implementation Parameters --
+   --------------------------------------
+
+   --  These parameters provide information about the target that is used
+   --  by the compiler. They are in the private part of System, where they
+   --  can be accessed using the special circuitry in the Targparm unit
+   --  whose source should be consulted for more detailed descriptions
+   --  of the individual switch values.
+
+   AAMP                      : constant Boolean := False;
+   Backend_Divide_Checks     : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := False;
+   Command_Line_Args         : constant Boolean := True;
+   Compiler_System_Version   : constant Boolean := False;
+   Configurable_Run_Time     : constant Boolean := False;
+   Denorm                    : constant Boolean := True;
+   Duration_32_Bits          : constant Boolean := False;
+   Exit_Status_Supported     : constant Boolean := True;
+   Fractional_Fixed_Ops      : constant Boolean := False;
+   Frontend_Layout           : constant Boolean := False;
+   Functions_Return_By_DSP   : constant Boolean := False;
+   Machine_Overflows         : constant Boolean := False;
+   Machine_Rounds            : constant Boolean := True;
+   OpenVMS                   : constant Boolean := False;
+   Preallocated_Stacks       : constant Boolean := False;
+   Signed_Zeros              : constant Boolean := True;
+   Stack_Check_Default       : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := False;
+   Support_64_Bit_Divides    : constant Boolean := True;
+   Support_Aggregates        : constant Boolean := True;
+   Support_Composite_Assign  : constant Boolean := True;
+   Support_Composite_Compare : constant Boolean := True;
+   Support_Long_Shifts       : constant Boolean := True;
+   Suppress_Standard_Library : constant Boolean := False;
+   Use_Ada_Main_Program_Name : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := True;
+   GCC_ZCX_Support           : constant Boolean := True;
+   Front_End_ZCX_Support     : constant Boolean := False;
+
+   --  Obsolete entries, to be removed eventually (bootstrap issues!)
+
+   High_Integrity_Mode       : constant Boolean := False;
+   Long_Shifts_Inlined       : constant Boolean := True;
+
+end System;
Index: src/gcc/ada/g-soccon-linux-mips.ads
===================================================================
--- /dev/null
+++ src/gcc/ada/g-soccon-linux-mips.ads
@@ -0,0 +1,184 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                         GNAT COMPILER COMPONENTS                         --
+--                                                                          --
+--               G N A T . S O C K E T S . C O N S T A N T S                --
+--                                                                          --
+--                                 S p e c                                  --
+--                                                                          --
+--          Copyright (C) 2000-2005, Free Software Foundation, Inc.         --
+--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT 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  distributed with GNAT;  see file COPYING.  If not, write --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
+--                                                                          --
+-- As a special exception,  if other files  instantiate  generics from this --
+-- unit, or you link  this unit with other files  to produce an executable, --
+-- this  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.                                      --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+--  This package provides target dependent definitions of constant for use
+--  by the GNAT.Sockets package (g-socket.ads). This package should not be
+--  directly with'ed by an applications program.
+
+--  This is the version for mips-linux, manually edited for the first shot
+--  no mips hardware at hand
+--  using http://www.gelato.unsw.edu.au/lxr/source/include/asm-mips/socket.h
+--  in order to find differents values
+--  This file is generated automatically, do not modify it by hand! Instead,
+--  make changes to gen-soccon.c and re-run it on each target.
+
+package GNAT.Sockets.Constants is
+
+   --------------
+   -- Families --
+   --------------
+
+   AF_INET            : constant :=            2; --  IPv4 address family
+   AF_INET6           : constant :=           10; --  IPv6 address family
+
+   -----------
+   -- Modes --
+   -----------
+
+   SOCK_STREAM        : constant :=            1; --  Stream socket
+   SOCK_DGRAM         : constant :=            2; --  Datagram socket
+
+   -------------------
+   -- Socket errors --
+   -------------------
+
+   EACCES             : constant :=           13; --  Permission denied
+   EADDRINUSE         : constant :=           98; --  Address already in use
+   EADDRNOTAVAIL      : constant :=           99; --  Cannot assign address
+   EAFNOSUPPORT       : constant :=           97; --  Addr family not supported
+   EALREADY           : constant :=          114; --  Operation in progress
+   EBADF              : constant :=            9; --  Bad file descriptor
+   ECONNABORTED       : constant :=          103; --  Connection aborted
+   ECONNREFUSED       : constant :=          111; --  Connection refused
+   ECONNRESET         : constant :=          104; --  Connection reset by peer
+   EDESTADDRREQ       : constant :=           89; --  Destination addr required
+   EFAULT             : constant :=           14; --  Bad address
+   EHOSTDOWN          : constant :=          112; --  Host is down
+   EHOSTUNREACH       : constant :=          113; --  No route to host
+   EINPROGRESS        : constant :=          115; --  Operation now in progress
+   EINTR              : constant :=            4; --  Interrupted system call
+   EINVAL             : constant :=           22; --  Invalid argument
+   EIO                : constant :=            5; --  Input output error
+   EISCONN            : constant :=          106; --  Socket already connected
+   ELOOP              : constant :=           40; --  Too many symbolic lynks
+   EMFILE             : constant :=           24; --  Too many open files
+   EMSGSIZE           : constant :=           90; --  Message too long
+   ENAMETOOLONG       : constant :=           36; --  Name too long
+   ENETDOWN           : constant :=          100; --  Network is down
+   ENETRESET          : constant :=          102; --  Disconn. on network reset
+   ENETUNREACH        : constant :=          101; --  Network is unreachable
+   ENOBUFS            : constant :=          105; --  No buffer space available
+   ENOPROTOOPT        : constant :=           92; --  Protocol not available
+   ENOTCONN           : constant :=          107; --  Socket not connected
+   ENOTSOCK           : constant :=           88; --  Operation on non socket
+   EOPNOTSUPP         : constant :=           95; --  Operation not supported
+   EPFNOSUPPORT       : constant :=           96; --  Unknown protocol family
+   EPROTONOSUPPORT    : constant :=           93; --  Unknown protocol
+   EPROTOTYPE         : constant :=           91; --  Unknown protocol type
+   ESHUTDOWN          : constant :=          108; --  Cannot send once shutdown
+   ESOCKTNOSUPPORT    : constant :=           94; --  Socket type not supported
+   ETIMEDOUT          : constant :=          110; --  Connection timed out
+   ETOOMANYREFS       : constant :=          109; --  Too many references
+   EWOULDBLOCK        : constant :=           11; --  Operation would block
+
+   -----------------
+   -- Host errors --
+   -----------------
+
+   HOST_NOT_FOUND     : constant :=            1; --  Unknown host
+   TRY_AGAIN          : constant :=            2; --  Host name lookup failure
+   NO_DATA            : constant :=            4; --  No data record for name
+   NO_RECOVERY        : constant :=            3; --  Non recoverable errors
+
+   -------------------
+   -- Control flags --
+   -------------------
+
+   FIONBIO            : constant :=     16#667e#; --  Set/clear non-blocking io
+   FIONREAD           : constant :=     16#467f#; --  How many bytes to read
+
+   --------------------
+   -- Shutdown modes --
+   --------------------
+
+   SHUT_RD            : constant :=            0; --  No more recv
+   SHUT_WR            : constant :=            1; --  No more send
+   SHUT_RDWR          : constant :=            2; --  No more recv/send
+
+   ---------------------
+   -- Protocol levels --
+   ---------------------
+
+   SOL_SOCKET         : constant :=            1; --  Options for socket level
+   IPPROTO_IP         : constant :=            0; --  Dummy protocol for IP
+   IPPROTO_UDP        : constant :=           17; --  UDP
+   IPPROTO_TCP        : constant :=            6; --  TCP
+
+   -------------------
+   -- Request flags --
+   -------------------
+
+   MSG_OOB            : constant :=            1; --  Process out-of-band data
+   MSG_PEEK           : constant :=            2; --  Peek at incoming data
+   MSG_EOR            : constant :=          128; --  Send end of record
+   MSG_WAITALL        : constant :=          256; --  Wait for full reception
+   MSG_NOSIGNAL       : constant :=        16384; --  No SIGPIPE on send
+   MSG_Forced_Flags   : constant := MSG_NOSIGNAL;
+   --  Flags set on all send(2) calls
+
+   --------------------
+   -- Socket options --
+   --------------------
+
+   TCP_NODELAY        : constant :=            1; --  Do not coalesce packets
+   SO_REUSEADDR       : constant :=            4; --  Bind reuse local address
+   SO_KEEPALIVE       : constant :=            8; --  Enable keep-alive msgs
+   SO_LINGER          : constant :=       16#80#; --  Defer close to flush data
+   SO_BROADCAST       : constant :=       16#20#; --  Can send broadcast msgs
+   SO_SNDBUF          : constant :=     16#1001#; --  Set/get send buffer size
+   SO_RCVBUF          : constant :=     16#1002#; --  Set/get recv buffer size
+   SO_SNDTIMEO        : constant :=     16#1005#; --  Emission timeout
+   SO_RCVTIMEO        : constant :=     16#1006#; --  Reception timeout
+   SO_ERROR           : constant :=     16#1007#; --  Get/clear error status
+   IP_MULTICAST_IF    : constant :=           32; --  Set/get mcast interface
+   IP_MULTICAST_TTL   : constant :=           33; --  Set/get multicast TTL
+   IP_MULTICAST_LOOP  : constant :=           34; --  Set/get mcast loopback
+   IP_ADD_MEMBERSHIP  : constant :=           35; --  Join a multicast group
+   IP_DROP_MEMBERSHIP : constant :=           36; --  Leave a multicast group
+
+   -------------------
+   -- System limits --
+   -------------------
+
+   IOV_MAX            : constant :=   2147483647; --  Maximum writev iovcnt
+
+   ----------------------
+   -- Type definitions --
+   ----------------------
+
+   --  Sizes (in bytes) of the components of struct timeval
+
+   SIZEOF_tv_sec      : constant :=            4; --  tv_sec
+   SIZEOF_tv_usec     : constant :=            4; --  tv_usec
+
+end GNAT.Sockets.Constants;