OSDN Git Service

* gcc-interface/Makefile.in (gnatlib-shared-default): Append
[pf3gnuchains/gcc-fork.git] / gcc / ada / gcc-interface / Makefile.in
index b64ba55..f9e7eda 100644 (file)
@@ -1,5 +1,5 @@
 # Makefile for GNU Ada Compiler (GNAT).
-#   Copyright (C) 1994-2010 Free Software Foundation, Inc.
+#   Copyright (C) 1994-2012 Free Software Foundation, Inc.
 
 #This file is part of GCC.
 
@@ -105,22 +105,23 @@ TEXI2PDF = texi2pdf
 GNATBIND_FLAGS = -static -x
 ADA_CFLAGS =
 ADAFLAGS = -W -Wall -gnatpg -gnata
-SOME_ADAFLAGS =-gnata
 FORCE_DEBUG_ADAFLAGS = -g
-GNATLIBFLAGS = -gnatpg -nostdinc
+NO_SIBLING_ADAFLAGS = -fno-optimize-sibling-calls
+NO_REORDER_ADAFLAGS = -fno-toplevel-reorder
+GNATLIBFLAGS = -W -Wall -gnatpg -nostdinc
 GNATLIBCFLAGS = -g -O2
+PICFLAG_FOR_TARGET = @PICFLAG_FOR_TARGET@
+
 # Pretend that _Unwind_GetIPInfo is available for the target by default.  This
 # should be autodetected during the configuration of libada and passed down to
 # here, but we need something for --disable-libada and hope for the best.
-GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
-       -DIN_RTS -DHAVE_GETIPINFO
+GNATLIBCFLAGS_FOR_C = -W -Wall $(GNATLIBCFLAGS) \
+       -fexceptions -DIN_RTS -DHAVE_GETIPINFO
 ALL_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS)
-MOST_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(SOME_ADAFLAGS)
 THREAD_KIND = native
 THREADSLIB =
 GMEM_LIB =
 MISCLIB =
-SYMDEPS = $(LIBINTL_DEP)
 OUTPUT_OPTION = @OUTPUT_OPTION@
 
 objext = .o
@@ -174,11 +175,15 @@ top_builddir = ../..
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
 
+# Character encoding conversion library.
+LIBICONV = @LIBICONV@
+LIBICONV_DEP = @LIBICONV_DEP@
+
 # 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 ../../version.o
+# List extra gnattools
+EXTRA_GNATTOOLS =
 
 # List of target dependent sources, overridden below as necessary
 TARGET_ADA_SRCS =
@@ -216,15 +221,15 @@ endif
 
 all.indirect: Makefile ../gnat1$(exeext)
 
-# IN_GCC distinguishes between code compiled into GCC itself and other
-# programs built during a bootstrap.
+# IN_GCC is meant to distinguish between code compiled into GCC itself, i.e.
+# for the host, and the rest.  But we also use it for the tools (link.c) and
+# even break the host/target wall by using it for the library (targext.c).
 # autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a cross
 # compiler which does not use the native libraries and headers.
 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) $(T_CFLAGS) $(LOOSE_CFLAGS)
+ALL_CFLAGS = $(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS)
 
 # Likewise.
 ALL_CPPFLAGS = $(CPPFLAGS)
@@ -237,23 +242,49 @@ LIBIBERTY = ../../libiberty/libiberty.a
 
 # How to link with both our special library facilities
 # and the system's installed libraries.
-LIBS = $(LIBINTL) $(LIBIBERTY) $(SYSLIBS)
-LIBDEPS = $(LIBINTL_DEP) $(LIBIBERTY)
+LIBS = $(LIBINTL) $(LIBICONV) $(LIBIBERTY) $(SYSLIBS)
+LIBDEPS = $(LIBINTL_DEP) $(LIBICONV_DEP) $(LIBIBERTY)
 # Default is no TGT_LIB; one might be passed down or something
 TGT_LIB =
-TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o $(LIBGNAT) ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
+TOOLS_LIBS = targext.o link.o ../../libcommon-target.a ../../libcommon.a \
+  ../../../libcpp/libcpp.a $(LIBGNAT) $(LIBINTL) $(LIBICONV) \
+  ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB)
+
+# 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
 
 # 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)/ada -I$(srcdir) -I$(srcdir)/config \
-       -I$(srcdir)/../include
+INCLUDES = -I- -I. -I.. -I$(srcdir)/ada -I$(srcdir) -I$(srcdir)/../include
 
 ADA_INCLUDES = -I- -I. -I$(srcdir)/ada
 
-INCLUDES_FOR_SUBDIR = -I. -I.. -I../.. -I$(fsrcdir)/ada \
-       -I$(fsrcdir)/../include -I$(fsrcdir)
+# Likewise, but valid for subdirectories of the current dir.
+# FIXME: for VxWorks, we cannot add $(fsrcdir) because the regs.h file in
+# that directory conflicts with a system header file.
+ifneq ($(findstring vxworks,$(osys)),)
+  INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. \
+                       -iquote $(fsrcdir)/ada \
+                       -I$(fsrcdir)/../include
+else
+  INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. \
+                       -iquote $(fsrcdir)/ada -iquote $(fsrcdir) \
+                       -I$(fsrcdir)/../include
+endif
+
 ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
 
 # Avoid a lot of time thinking about remaking Makefile.in and *.def.
@@ -296,37 +327,22 @@ GNATLINK_OBJS = gnatlink.o \
  sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \
  types.o validsw.o widechar.o
 
-GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o \
- alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\
+GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \
+ atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o errout.o \
  erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
  gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
  make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o \
  mlib-tgt-specific.o mlib-utl.o namet.o nlists.o opt.o osint.o osint-m.o \
  output.o prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o \
- prj-conf.o prj-pp.o \
- prj-err.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 s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
- scans.o scng.o sdefault.o sfn_scan.o s-purexc.o s-htable.o sinfo.o sinput.o \
- sinput-c.o sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o \
validsw.o switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o \
- uintp.o uname.o urealp.o usage.o widechar.o scil_ll.o \
+ prj-conf.o prj-pp.o prj-err.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 restrict.o rident.o s-exctab.o \
s-secsta.o s-stalib.o s-stoele.o scans.o scng.o sdefault.o sfn_scan.o \
+ s-purexc.o s-htable.o scil_ll.o sem_aux.o sinfo.o sinput.o sinput-c.o \
+ sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o \
switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o uintp.o \
+ uname.o urealp.o usage.o widechar.o \
  $(EXTRA_GNATMAKE_OBJS)
 
-# 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
-
 # Make arch match the current multilib so that the RTS selection code
 # picks up the right files. For a given target this must be coherent
 # with MULTILIB_DIRNAMES defined in gcc/config/target/t-*.
@@ -390,10 +406,10 @@ DUMMY_SOCKETS_TARGET_PAIRS = \
   g-sothco.adb<g-sothco-dummy.adb \
   g-sothco.ads<g-sothco-dummy.ads
 
-# On platform where atomic increment/decrement operations are supported
+# On platforms where atomic increment/decrement operations are supported,
 # special version of Ada.Strings.Unbounded package can be used.
 
-ATOMICS_TARGET_PAIRS += \
+ATOMICS_TARGET_PAIRS = \
   a-stunau.adb<a-stunau-shared.adb \
   a-suteio.adb<a-suteio-shared.adb \
   a-strunb.ads<a-strunb-shared.ads \
@@ -407,6 +423,21 @@ ATOMICS_TARGET_PAIRS += \
   a-szunau.adb<a-szunau-shared.adb \
   a-szuzti.adb<a-szuzti-shared.adb
 
+ATOMICS_BUILTINS_TARGET_PAIRS = \
+  s-atocou.adb<s-atocou-builtin.adb
+
+# Special version of units for x86 and x86-64 platforms.
+
+X86_TARGET_PAIRS = \
+  a-numaux.ads<a-numaux-x86.ads \
+  a-numaux.adb<a-numaux-x86.adb \
+  s-atocou.adb<s-atocou-x86.adb
+
+X86_64_TARGET_PAIRS = \
+  a-numaux.ads<a-numaux-x86.ads \
+  a-numaux.adb<a-numaux-x86.adb \
+  s-atocou.adb<s-atocou-builtin.adb
+
 LIB_VERSION = $(strip $(shell grep ' Library_Version :' $(fsrcpfx)ada/gnatvsn.ads | sed -e 's/.*"\(.*\)".*/\1/'))
 
 # $(filter-out PATTERN...,TEXT) removes all PATTERN words from TEXT.
@@ -417,7 +448,7 @@ ifeq ($(strip $(filter-out m68k% wrs vx%,$(targ))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
@@ -436,8 +467,6 @@ ifeq ($(strip $(filter-out m68k% wrs vx%,$(targ))),)
   g-socthi.ads<g-socthi-vxworks.ads \
   g-socthi.adb<g-socthi-vxworks.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-vxworks-m68k.ads
 
   TOOLS_TARGET_PAIRS=mlib-tgt-specific.adb<mlib-tgt-specific-vxworks.adb
@@ -458,11 +487,11 @@ ifeq ($(strip $(filter-out m68k% wrs vx%,$(targ))),)
   endif
 endif
 
-ifeq ($(strip $(filter-out powerpc% wrs vxworks,$(targ))),)
+ifeq ($(strip $(filter-out e500% powerpc% wrs vxworks,$(targ))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
   s-osinte.ads<s-osinte-vxworks.ads \
@@ -479,9 +508,8 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworks,$(targ))),)
   g-socthi.ads<g-socthi-vxworks.ads \
   g-socthi.adb<g-socthi-vxworks.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS=\
   mlib-tgt-specific.adb<mlib-tgt-specific-vxworks.adb \
@@ -507,29 +535,35 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworks,$(targ))),)
   else
     ifeq ($(strip $(filter-out rtp-smp,$(THREAD_KIND))),)
       LIBGNAT_TARGET_PAIRS += \
+      s-mudido.adb<s-mudido-affinity.adb \
       s-vxwext.ads<s-vxwext-rtp.ads \
       s-vxwext.adb<s-vxwext-rtp-smp.adb \
       s-tpopsp.adb<s-tpopsp-vxworks-tls.adb \
       system.ads<system-vxworks-ppc-rtp.ads
 
       EXTRA_GNATRTL_NONTASKING_OBJS=s-vxwexc.o
-      EXTRA_GNATRTL_TASKING_OBJS=affinity.o
+      EXTRA_LIBGNAT_OBJS+=affinity.o
+      EXTRA_LIBGNAT_SRCS+=affinity.c
     else
       ifeq ($(strip $(filter-out kernel-smp,$(THREAD_KIND))),)
         LIBGNAT_TARGET_PAIRS += \
         s-interr.adb<s-interr-hwint.adb \
+        s-mudido.adb<s-mudido-affinity.adb \
         s-tpopsp.adb<s-tpopsp-vxworks-tls.adb \
         s-vxwext.ads<s-vxwext-kernel.ads \
         s-vxwext.adb<s-vxwext-kernel-smp.adb \
         system.ads<system-vxworks-ppc-kernel.ads
 
-        EXTRA_GNATRTL_TASKING_OBJS=affinity.o
+        EH_MECHANISM=-gcc
+        EXTRA_LIBGNAT_OBJS+=affinity.o
+        EXTRA_LIBGNAT_SRCS+=affinity.c
       else
         LIBGNAT_TARGET_PAIRS += \
         s-interr.adb<s-interr-hwint.adb \
         s-tpopsp.adb<s-tpopsp-vxworks.adb
 
         ifeq ($(strip $(filter-out kernel,$(THREAD_KIND))),)
+          EH_MECHANISM=-gcc
           LIBGNAT_TARGET_PAIRS += \
           s-vxwext.ads<s-vxwext-kernel.ads \
           s-vxwext.adb<s-vxwext-kernel.adb \
@@ -540,6 +574,8 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworks,$(targ))),)
         endif
       endif
       EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o i-vxwoio.o s-vxwexc.o
+      EXTRA_LIBGNAT_OBJS+=sigtramp-ppcvxw.o
+      EXTRA_LIBGNAT_SRCS+=sigtramp-ppcvxw.c
     endif
   endif
 
@@ -550,15 +586,14 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworks,$(targ))),)
 endif
 
 # vxworks 653
-ifeq ($(strip $(filter-out powerpc% wrs vxworksae,$(targ))),)
+ifeq ($(strip $(filter-out powerpc% e500v2 wrs vxworksae,$(targ))),)
   # target pairs for vthreads runtime
   LIBGNAT_TARGET_PAIRS = \
   a-elchha.adb<a-elchha-vxworks-ppc-full.adb \
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
   g-io.adb<g-io-vxworks-ppc-cert.adb \
-  g-io.ads<g-io-vxworks-ppc-cert.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
@@ -574,10 +609,9 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworksae,$(targ))),)
   s-vxwext.adb<s-vxwext-noints.adb \
   s-vxwext.ads<s-vxwext-vthreads.ads \
   s-vxwork.ads<s-vxwork-ppc.ads \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-vxworks-ppc-vthread.ads \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS=\
   mlib-tgt-specific.adb<mlib-tgt-specific-vxworks.adb \
@@ -586,6 +620,9 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworksae,$(targ))),)
   EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o i-vxwoio.o s-vxwexc.o
   EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o s-vxwext.o
 
+  EXTRA_LIBGNAT_SRCS+=sigtramp-ppcvxw.c
+  EXTRA_LIBGNAT_OBJS+=sigtramp-ppcvxw.o
+
   # Extra pairs for the vthreads runtime
   ifeq ($(strip $(filter-out vthreads,$(THREAD_KIND))),)
     LIBGNAT_TARGET_PAIRS += \
@@ -612,14 +649,14 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworksae,$(targ))),)
 endif
 
 # vxworks MILS
-ifeq ($(strip $(filter-out powerpc% wrs vxworksmils,$(targ))),)
+ifeq ($(strip $(filter-out e500% powerpc% wrs vxworksmils,$(targ))),)
   # target pairs for vthreads runtime
   LIBGNAT_TARGET_PAIRS = \
+  a-elchha.adb<a-elchha-vx6-raven-cert.adb \
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
   g-io.adb<g-io-vxworks-ppc-cert.adb \
-  g-io.ads<g-io-vxworks-ppc-cert.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
@@ -636,10 +673,9 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworksmils,$(targ))),)
   s-thread.adb<s-thread-ae653.adb \
   s-tpopsp.adb<s-tpopsp-vxworks.adb \
   s-vxwork.ads<s-vxwork-ppc.ads \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
-  system.ads<system-vxworks-ppc.ads \
+  system.ads<system-vxworks-ppc-mils.ads \
   $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS) \
   $(DUMMY_SOCKETS_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS=\
@@ -649,8 +685,8 @@ ifeq ($(strip $(filter-out powerpc% wrs vxworksmils,$(targ))),)
   EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o i-vxwoio.o s-thread.o s-vxwexc.o
   EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o s-vxwext.o
 
-  EXTRA_LIBGNAT_SRCS+=vx_stack_info.c
-  EXTRA_LIBGNAT_OBJS+=vx_stack_info.o
+  EXTRA_LIBGNAT_SRCS+=vx_stack_info.c sigtramp-ppcvxw.c
+  EXTRA_LIBGNAT_OBJS+=vx_stack_info.o sigtramp-ppcvxw.o
   GNATRTL_SOCKETS_OBJS =
 
   ifeq ($(strip $(filter-out yes,$(TRACE))),)
@@ -669,14 +705,10 @@ ifeq ($(strip $(filter-out %86 wrs vxworksae vxworksmils,$(targ))),)
   LIBGNAT_TARGET_PAIRS = \
   a-elchha.adb<a-elchha-vxworks-ppc-full.adb \
   a-intnam.ads<a-intnam-vxworks.ads \
-  a-numaux.ads<a-numaux-x86.ads \
-  a-numaux.adb<a-numaux-x86.adb \
   a-sytaco.ads<1asytaco.ads \
   a-sytaco.adb<1asytaco.adb \
-  g-bytswa.adb<g-bytswa-x86.adb \
   g-io.adb<g-io-vxworks-ppc-cert.adb \
-  g-io.ads<g-io-vxworks-ppc-cert.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
@@ -691,8 +723,8 @@ ifeq ($(strip $(filter-out %86 wrs vxworksae vxworksmils,$(targ))),)
   s-vxwext.adb<s-vxwext-noints.adb \
   s-vxwext.ads<s-vxwext-vthreads.ads \
   s-vxwork.ads<s-vxwork-x86.ads \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
+  $(ATOMICS_TARGET_PAIRS) \
+  $(X86_TARGET_PAIRS) \
   system.ads<system-vxworks-x86.ads
 
   TOOLS_TARGET_PAIRS=\
@@ -731,7 +763,7 @@ ifeq ($(strip $(filter-out sparc% wrs vx%,$(targ))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
@@ -750,8 +782,6 @@ ifeq ($(strip $(filter-out sparc% wrs vx%,$(targ))),)
   g-socthi.ads<g-socthi-vxworks.ads \
   g-socthi.adb<g-socthi-vxworks.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-vxworks-sparcv9.ads   \
 
   TOOLS_TARGET_PAIRS=\
@@ -771,11 +801,9 @@ ifeq ($(strip $(filter-out %86 wrs vxworks,$(targ))),)
   i-vxwork.ads<i-vxwork-x86.ads \
   s-osinte.adb<s-osinte-vxworks.adb \
   s-osinte.ads<s-osinte-vxworks.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
-  a-numaux.adb<a-numaux-x86.adb \
-  a-numaux.ads<a-numaux-x86.ads \
   s-osprim.adb<s-osprim-vxworks.adb \
   s-parame.ads<s-parame-vxworks.ads \
   s-parame.adb<s-parame-vxworks.adb \
@@ -785,12 +813,11 @@ ifeq ($(strip $(filter-out %86 wrs vxworks,$(targ))),)
   s-tasinf.ads<s-tasinf-vxworks.ads \
   s-taspri.ads<s-taspri-vxworks.ads \
   s-vxwork.ads<s-vxwork-x86.ads \
-  g-bytswa.adb<g-bytswa-x86.adb \
   g-socthi.ads<g-socthi-vxworks.ads \
   g-socthi.adb<g-socthi-vxworks.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb
+  $(ATOMICS_TARGET_PAIRS) \
+  $(X86_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS=\
   mlib-tgt-specific.adb<mlib-tgt-specific-vxworks.adb \
@@ -816,22 +843,26 @@ ifeq ($(strip $(filter-out %86 wrs vxworks,$(targ))),)
   else
     ifeq ($(strip $(filter-out rtp-smp, $(THREAD_KIND))),)
       LIBGNAT_TARGET_PAIRS += \
+      s-mudido.adb<s-mudido-affinity.adb \
       s-vxwext.ads<s-vxwext-rtp.ads \
       s-vxwext.adb<s-vxwext-rtp-smp.adb \
       s-tpopsp.adb<s-tpopsp-vxworks-tls.adb \
       system.ads<system-vxworks-x86-rtp.ads
 
       EXTRA_GNATRTL_NONTASKING_OBJS=s-vxwexc.o
-      EXTRA_GNATRTL_TASKING_OBJS=affinity.o
+      EXTRA_LIBGNAT_OBJS+=affinity.o
+      EXTRA_LIBGNAT_SRCS+=affinity.c
     else
       ifeq ($(strip $(filter-out kernel-smp, $(THREAD_KIND))),)
         LIBGNAT_TARGET_PAIRS += \
         s-interr.adb<s-interr-hwint.adb \
+        s-mudido.adb<s-mudido-affinity.adb \
         s-tpopsp.adb<s-tpopsp-vxworks-tls.adb \
         s-vxwext.ads<s-vxwext-kernel.ads \
         s-vxwext.adb<s-vxwext-kernel-smp.adb \
         system.ads<system-vxworks-x86-kernel.ads
-        EXTRA_GNATRTL_TASKING_OBJS=affinity.o
+        EXTRA_LIBGNAT_OBJS+=affinity.o
+        EXTRA_LIBGNAT_SRCS+=affinity.c
       else
         LIBGNAT_TARGET_PAIRS += \
         s-interr.adb<s-interr-hwint.adb \
@@ -861,7 +892,7 @@ ifeq ($(strip $(filter-out arm% coff wrs vx%,$(targ))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
@@ -880,8 +911,6 @@ ifeq ($(strip $(filter-out arm% coff wrs vx%,$(targ))),)
   g-socthi.ads<g-socthi-vxworks.ads \
   g-socthi.adb<g-socthi-vxworks.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-vxworks-arm.ads
 
   TOOLS_TARGET_PAIRS=\
@@ -899,7 +928,7 @@ ifeq ($(strip $(filter-out mips% wrs vx%,$(targ))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-vxworks.ads \
   a-numaux.ads<a-numaux-vxworks.ads \
-  s-inmaop.adb<s-inmaop-posix.adb \
+  s-inmaop.adb<s-inmaop-vxworks.adb \
   s-interr.adb<s-interr-hwint.adb \
   s-intman.ads<s-intman-vxworks.ads \
   s-intman.adb<s-intman-vxworks.adb \
@@ -918,8 +947,6 @@ ifeq ($(strip $(filter-out mips% wrs vx%,$(targ))),)
   g-socthi.ads<g-socthi-vxworks.ads \
   g-socthi.adb<g-socthi-vxworks.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-vxworks-mips.ads
 
   TOOLS_TARGET_PAIRS=\
@@ -938,6 +965,7 @@ ifeq ($(strip $(filter-out sparc% sun solaris%,$(targ))),)
   a-intnam.ads<a-intnam-solaris.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-solaris.adb \
+  s-mudido.adb<s-mudido-affinity.adb \
   s-osinte.adb<s-osinte-solaris.adb \
   s-osinte.ads<s-osinte-solaris.ads \
   s-osprim.adb<s-osprim-solaris.adb \
@@ -953,7 +981,8 @@ ifeq ($(strip $(filter-out sparc% sun solaris%,$(targ))),)
 
   LIBGNAT_TARGET_PAIRS_64 = \
   system.ads<system-solaris-sparcv9.ads \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   ifeq ($(strip $(filter-out sparc sun solaris%,$(targ))),)
     ifeq ($(strip $(MULTISUBDIR)),/sparcv9)
@@ -1005,13 +1034,12 @@ ifeq ($(strip $(filter-out sparc% sun solaris%,$(targ))),)
   endif
 endif
 
-ifeq ($(strip $(filter-out %86 solaris2%,$(arch) $(osys))),)
-  LIBGNAT_TARGET_PAIRS = \
-  a-numaux.adb<a-numaux-x86.adb \
-  a-numaux.ads<a-numaux-x86.ads \
+ifeq ($(strip $(filter-out %86 %x86_64 solaris2%,$(arch) $(osys))),)
+  LIBGNAT_TARGET_PAIRS_COMMON = \
   a-intnam.ads<a-intnam-solaris.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-solaris.adb \
+  s-mudido.adb<s-mudido-affinity.adb \
   s-osinte.adb<s-osinte-solaris.adb \
   s-osinte.ads<s-osinte-solaris.ads \
   s-osprim.adb<s-osprim-solaris.adb \
@@ -1020,15 +1048,33 @@ ifeq ($(strip $(filter-out %86 solaris2%,$(arch) $(osys))),)
   s-tasinf.ads<s-tasinf-solaris.ads \
   s-taspri.ads<s-taspri-solaris.ads \
   s-tpopsp.adb<s-tpopsp-solaris.adb \
-  g-soliop.ads<g-soliop-solaris.ads
+  g-soliop.ads<g-soliop-solaris.ads \
+  $(ATOMICS_TARGET_PAIRS)
 
-  ifeq ($(strip $(MULTISUBDIR)),/amd64)
-    LIBGNAT_TARGET_PAIRS += \
-    system.ads<system-solaris-x86_64.ads
+  LIBGNAT_TARGET_PAIRS_32 = \
+  $(X86_TARGET_PAIRS) \
+  system.ads<system-solaris-x86.ads
+
+  LIBGNAT_TARGET_PAIRS_64 = \
+  $(X86_64_TARGET_PAIRS) \
+  system.ads<system-solaris-x86_64.ads
+
+  ifeq ($(strip $(filter-out %86 solaris2%,$(arch) $(osys))),)
+    ifeq ($(strip $(MULTISUBDIR)),/amd64)
+      LIBGNAT_TARGET_PAIRS = \
+      $(LIBGNAT_TARGET_PAIRS_COMMON) $(LIBGNAT_TARGET_PAIRS_64)
+    else
+      LIBGNAT_TARGET_PAIRS = \
+      $(LIBGNAT_TARGET_PAIRS_COMMON) $(LIBGNAT_TARGET_PAIRS_32)
+    endif
   else
-    LIBGNAT_TARGET_PAIRS += \
-    g-bytswa.adb<g-bytswa-x86.adb \
-    system.ads<system-solaris-x86.ads
+    ifeq ($(strip $(MULTISUBDIR)),/32)
+      LIBGNAT_TARGET_PAIRS = \
+      $(LIBGNAT_TARGET_PAIRS_COMMON) $(LIBGNAT_TARGET_PAIRS_32)
+    else
+      LIBGNAT_TARGET_PAIRS = \
+      $(LIBGNAT_TARGET_PAIRS_COMMON) $(LIBGNAT_TARGET_PAIRS_64)
+    endif
   endif
 
   TOOLS_TARGET_PAIRS=mlib-tgt-specific.adb<mlib-tgt-specific-solaris.adb
@@ -1045,67 +1091,54 @@ endif
 ifeq ($(strip $(filter-out %86 linux%,$(arch) $(osys))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-linux.ads \
-  a-numaux.adb<a-numaux-x86.adb \
-  a-numaux.ads<a-numaux-x86.ads \
-  g-bytswa.adb<g-bytswa-x86.adb \
+  a-synbar.adb<a-synbar-posix.adb \
+  a-synbar.ads<a-synbar-posix.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-posix.adb \
-  s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
-  g-sercom.adb<g-sercom-linux.adb
+  s-tpopsp.adb<s-tpopsp-tls.adb \
+  g-sercom.adb<g-sercom-linux.adb \
+  a-exetim.adb<a-exetim-posix.adb \
+  a-exetim.ads<a-exetim-default.ads \
+  s-linux.ads<s-linux.ads \
+  s-osinte.adb<s-osinte-posix.adb \
+  $(ATOMICS_TARGET_PAIRS)
 
-  ifeq ($(strip $(filter-out marte,$(THREAD_KIND))),)
-    LIBGNAT_TARGET_PAIRS += \
-    a-exetim.adb<a-exetim-linux-marte.adb \
-    a-exetim.ads<a-exetim-linux-marte.ads \
-    a-extiti.adb<a-extiti-linux-marte.adb \
-    a-extiti.ads<a-extiti-linux-marte.ads \
-    a-rttiev.adb<a-rttiev-linux-marte.adb \
-    a-rttiev.ads<a-rttiev-linux-marte.ads \
-    s-osinte.adb<s-osinte-linux-marte.adb \
-    s-osinte.ads<s-osinte-linux-marte.ads \
-    s-osprim.adb<s-osprim-posix.adb \
-    s-taprop.adb<s-taprop-linux-marte.adb \
-    s-taspri.ads<s-taspri-posix.ads \
-    system.ads<system-linux-x86.ads
+  LIBGNAT_TARGET_PAIRS_32 = \
+  $(X86_TARGET_PAIRS) \
+  system.ads<system-linux-x86.ads
 
-    EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o a-extiti.o
+  LIBGNAT_TARGET_PAIRS_64 = \
+  $(X86_64_TARGET_PAIRS) \
+  system.ads<system-linux-x86_64.ads
 
-    EH_MECHANISM=
-    THREADSLIB = -lmarte
+  ifeq ($(strip $(MULTISUBDIR)),/64)
+    LIBGNAT_TARGET_PAIRS += $(LIBGNAT_TARGET_PAIRS_64)
   else
-    LIBGNAT_TARGET_PAIRS += \
-    a-exetim.adb<a-exetim-posix.adb \
-    a-exetim.ads<a-exetim-default.ads \
-    s-linux.ads<s-linux.ads \
-    s-osinte.adb<s-osinte-posix.adb
-
-    ifeq ($(strip $(filter-out xenomai,$(THREAD_KIND))),)
-      LIBGNAT_TARGET_PAIRS += \
-      s-osinte.ads<s-osinte-linux-xenomai.ads \
-      s-osprim.adb<s-osprim-linux-xenomai.adb \
-      s-taprop.adb<s-taprop-linux-xenomai.adb \
-      s-taspri.ads<s-taspri-linux-xenomai.ads \
-      system.ads<system-linux-x86-xenomai.ads
-
-      EH_MECHANISM=-gcc
-    else
-      LIBGNAT_TARGET_PAIRS += \
-      s-osinte.ads<s-osinte-linux.ads \
-      s-osprim.adb<s-osprim-posix.adb \
-      s-taprop.adb<s-taprop-linux.adb \
-      s-tasinf.ads<s-tasinf-linux.ads \
-      s-tasinf.adb<s-tasinf-linux.adb \
-      s-taspri.ads<s-taspri-posix.ads \
-      system.ads<system-linux-x86.ads
-
-      EH_MECHANISM=-gcc
-    endif
+    LIBGNAT_TARGET_PAIRS += $(LIBGNAT_TARGET_PAIRS_32)
+  endif
 
-    THREADSLIB = -lpthread -lrt
-    EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
-    EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o
+  ifeq ($(strip $(filter-out xenomai,$(THREAD_KIND))),)
+    LIBGNAT_TARGET_PAIRS += \
+    s-osinte.ads<s-osinte-linux-xenomai.ads \
+    s-osprim.adb<s-osprim-linux-xenomai.adb \
+    s-taprop.adb<s-taprop-linux-xenomai.adb \
+    s-taspri.ads<s-taspri-linux-xenomai.ads
+  else
+    LIBGNAT_TARGET_PAIRS += \
+    s-mudido.adb<s-mudido-affinity.adb \
+    s-osinte.ads<s-osinte-linux.ads \
+    s-osprim.adb<s-osprim-posix.adb \
+    s-taprop.adb<s-taprop-linux.adb \
+    s-tasinf.ads<s-tasinf-linux.ads \
+    s-tasinf.adb<s-tasinf-linux.adb \
+    s-taspri.ads<s-taspri-posix.ads
   endif
 
+  EH_MECHANISM=-gcc
+  THREADSLIB = -lpthread -lrt
+  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
+  EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o
+
   TOOLS_TARGET_PAIRS =  \
     mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
     indepsw.adb<indepsw-gnu.adb
@@ -1118,8 +1151,6 @@ endif
 ifeq ($(strip $(filter-out %86 kfreebsd%,$(arch) $(osys))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-freebsd.ads \
-  a-numaux.adb<a-numaux-x86.adb \
-  a-numaux.ads<a-numaux-x86.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-posix.adb \
   s-osinte.adb<s-osinte-posix.adb \
@@ -1130,6 +1161,8 @@ ifeq ($(strip $(filter-out %86 kfreebsd%,$(arch) $(osys))),)
   s-tasinf.adb<s-tasinf-linux.adb \
   s-taspri.ads<s-taspri-posix.ads \
   s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
+  $(ATOMICS_TARGET_PAIRS) \
+  $(X86_TARGET_PAIRS) \
   system.ads<system-freebsd-x86.ads
 
   TOOLS_TARGET_PAIRS =  \
@@ -1141,6 +1174,7 @@ ifeq ($(strip $(filter-out %86 kfreebsd%,$(arch) $(osys))),)
   GNATLIB_SHARED = gnatlib-shared-dual
   GMEM_LIB = gmemlib
   LIBRARY_VERSION := $(LIB_VERSION)
+  MISCLIB = -lutil
 endif
 
 ifeq ($(strip $(filter-out x86_64 kfreebsd%,$(arch) $(osys))),)
@@ -1174,9 +1208,6 @@ endif
 ifeq ($(strip $(filter-out %86 freebsd%,$(arch) $(osys))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-freebsd.ads \
-  a-numaux.adb<a-numaux-x86.adb \
-  a-numaux.ads<a-numaux-x86.ads \
-  g-bytswa.adb<g-bytswa-x86.adb \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-posix.adb \
   s-osinte.adb<s-osinte-freebsd.adb \
@@ -1185,6 +1216,8 @@ ifeq ($(strip $(filter-out %86 freebsd%,$(arch) $(osys))),)
   s-taprop.adb<s-taprop-posix.adb \
   s-taspri.ads<s-taspri-posix.ads \
   s-tpopsp.adb<s-tpopsp-posix.adb \
+  $(ATOMICS_TARGET_PAIRS) \
+  $(X86_TARGET_PAIRS) \
   system.ads<system-freebsd-x86.ads
 
   TOOLS_TARGET_PAIRS = \
@@ -1195,6 +1228,34 @@ ifeq ($(strip $(filter-out %86 freebsd%,$(arch) $(osys))),)
   THREADSLIB= -lpthread
   GMEM_LIB = gmemlib
   LIBRARY_VERSION := $(LIB_VERSION)
+  MISCLIB = -lutil
+endif
+
+ifeq ($(strip $(filter-out %86_64 freebsd%,$(arch) $(osys))),)
+  LIBGNAT_TARGET_PAIRS = \
+  a-intnam.ads<a-intnam-freebsd.ads \
+  s-inmaop.adb<s-inmaop-posix.adb \
+  s-intman.adb<s-intman-posix.adb \
+  s-osinte.adb<s-osinte-freebsd.adb \
+  s-osinte.ads<s-osinte-freebsd.ads \
+  s-osprim.adb<s-osprim-posix.adb \
+  s-taprop.adb<s-taprop-posix.adb \
+  s-taspri.ads<s-taspri-posix.ads \
+  s-tpopsp.adb<s-tpopsp-posix.adb \
+  g-trasym.adb<g-trasym-dwarf.adb \
+  $(ATOMICS_TARGET_PAIRS) \
+  $(X86_64_TARGET_PAIRS) \
+  system.ads<system-freebsd-x86_64.ads
+
+  TOOLS_TARGET_PAIRS = \
+  mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb
+  GNATLIB_SHARED = gnatlib-shared-dual
+
+  EH_MECHANISM=-gcc
+  THREADSLIB= -lpthread
+  GMEM_LIB = gmemlib
+  LIBRARY_VERSION := $(LIB_VERSION)
+  MISCLIB = -lutil
 endif
 
 ifeq ($(strip $(filter-out s390% linux%,$(arch) $(osys))),)
@@ -1210,9 +1271,7 @@ ifeq ($(strip $(filter-out s390% linux%,$(arch) $(osys))),)
   s-tasinf.ads<s-tasinf-linux.ads \
   s-tasinf.adb<s-tasinf-linux.adb \
   s-taspri.ads<s-taspri-posix-noaltstack.ads \
-  s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb
+  s-tpopsp.adb<s-tpopsp-posix-foreign.adb
 
   LIBGNAT_TARGET_PAIRS_32 = \
   system.ads<system-linux-s390.ads
@@ -1247,6 +1306,8 @@ endif
 ifeq ($(strip $(filter-out mips sgi irix6%,$(targ))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.ads<a-intnam-irix.ads \
+  a-synbar.adb<a-synbar-posix.adb \
+  a-synbar.ads<a-synbar-posix.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-irix.adb \
   s-mastop.adb<s-mastop-irix.adb \
@@ -1341,7 +1402,8 @@ ifeq ($(strip $(filter-out ibm aix%,$(manu) $(osys))),)
   s-taprop.adb<s-taprop-posix.adb \
   s-taspri.ads<s-taspri-posix.ads \
   s-tpopsp.adb<s-tpopsp-posix.adb \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   LIBGNAT_TARGET_PAIRS_32 = \
   system.ads<system-aix.ads
@@ -1355,61 +1417,23 @@ ifeq ($(strip $(filter-out ibm aix%,$(manu) $(osys))),)
        ppc64)
     LIBGNAT_TARGET_PAIRS = \
     $(LIBGNAT_TARGET_PAIRS_COMMON) $(LIBGNAT_TARGET_PAIRS_64)
+    TOOLS_TARGET_PAIRS = \
+    indepsw.adb<indepsw-aix.adb
   else
     LIBGNAT_TARGET_PAIRS = \
     $(LIBGNAT_TARGET_PAIRS_COMMON) $(LIBGNAT_TARGET_PAIRS_32)
+    TOOLS_TARGET_PAIRS = \
+    indepsw.adb<indepsw-gnu.adb
   endif
 
   THREADSLIB = -lpthreads
-
-  TOOLS_TARGET_PAIRS = \
-  mlib-tgt-specific.adb<mlib-tgt-specific-aix.adb \
-  indepsw.adb<indepsw-aix.adb
+  EH_MECHANISM=-gcc
+  TOOLS_TARGET_PAIRS += \
+  mlib-tgt-specific.adb<mlib-tgt-specific-aix.adb
 
   GMEM_LIB = gmemlib
 endif
 
-ifeq ($(strip $(filter-out lynxos,$(osys))),)
-  TOOLS_TARGET_PAIRS = \
-  mlib-tgt-specific.adb<mlib-tgt-specific-lynxos.adb \
-  indepsw.adb<indepsw-gnu.adb
-
-  ifeq ($(strip $(filter-out %86 lynxos,$(arch) $(osys))),)
-    LIBGNAT_TARGET_PAIRS = \
-    a-numaux.adb<a-numaux-x86.adb \
-    a-numaux.ads<a-numaux-x86.ads \
-    a-intnam.ads<a-intnam-lynxos.ads \
-    g-bytswa.adb<g-bytswa-x86.adb \
-    s-inmaop.adb<s-inmaop-posix.adb \
-    s-intman.adb<s-intman-posix.adb \
-    s-osinte.adb<s-osinte-lynxos.adb \
-    s-osinte.ads<s-osinte-lynxos.ads \
-    s-osprim.adb<s-osprim-posix.adb \
-    s-taprop.adb<s-taprop-lynxos.adb \
-    s-taspri.ads<s-taspri-lynxos.ads \
-    s-tpopsp.adb<s-tpopsp-lynxos.adb \
-    g-trasym.ads<g-trasym-unimplemented.ads \
-    g-trasym.adb<g-trasym-unimplemented.adb \
-    system.ads<system-lynxos-x86.ads
-
-
-  else
-    LIBGNAT_TARGET_PAIRS = \
-    a-intnam.ads<a-intnam-lynxos.ads \
-    s-inmaop.adb<s-inmaop-posix.adb \
-    s-intman.adb<s-intman-posix.adb \
-    s-osinte.adb<s-osinte-lynxos.adb \
-    s-osinte.ads<s-osinte-lynxos.ads \
-    s-osprim.adb<s-osprim-posix.adb \
-    s-taprop.adb<s-taprop-lynxos.adb \
-    s-taspri.ads<s-taspri-lynxos.ads \
-    s-tpopsp.adb<s-tpopsp-lynxos.adb \
-    g-trasym.ads<g-trasym-unimplemented.ads \
-    g-trasym.adb<g-trasym-unimplemented.adb \
-    system.ads<system-lynxos-ppc.ads
-  endif
-endif
-
 ifeq ($(strip $(filter-out rtems%,$(osys))),)
   LIBGNAT_TARGET_PAIRS = \
   system.ads<system-rtems.ads \
@@ -1424,9 +1448,7 @@ ifeq ($(strip $(filter-out rtems%,$(osys))),)
   s-taspri.ads<s-taspri-posix.ads \
   s-tpopsp.adb<s-tpopsp-rtems.adb \
   s-stchop.adb<s-stchop-rtems.adb \
-  s-interr.adb<s-interr-hwint.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb
+  s-interr.adb<s-interr-hwint.adb
 endif
 
 ifeq ($(strip $(filter-out alpha% dec osf%,$(targ))),)
@@ -1444,7 +1466,8 @@ ifeq ($(strip $(filter-out alpha% dec osf%,$(targ))),)
   s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
   s-traceb.adb<s-traceb-mastop.adb \
   system.ads<system-tru64.ads \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS=mlib-tgt-specific.adb<mlib-tgt-specific-tru64.adb
 
@@ -1463,52 +1486,9 @@ hyphen = _
 LN = cp -p
 LN_S = cp -p
 
-.SUFFIXES: .sym
-
-.o.sym:
-       @ gnu:[bin]vmssymvec $<
 endif
 
 ifeq ($(strip $(filter-out alpha64 ia64 dec hp vms% openvms% alphavms%,$(targ))),)
-  ifeq ($(strip $(filter-out ia64 hp vms% openvms%,$(targ))),)
-    LIBGNAT_TARGET_PAIRS_AUX1 = \
-      g-enblsp.adb<g-enblsp-vms-ia64.adb \
-      g-trasym.adb<g-trasym-vms-ia64.adb \
-      s-asthan.adb<s-asthan-vms-ia64.adb \
-      s-auxdec.adb<s-auxdec-vms-ia64.adb \
-      s-osinte.adb<s-osinte-vms-ia64.adb \
-      s-osinte.ads<s-osinte-vms-ia64.ads \
-      s-vaflop.adb<s-vaflop-vms-ia64.adb \
-      system.ads<system-vms-ia64.ads
-
-    LIBGNAT_TARGET_PAIRS_AUX2 = \
-      s-parame.ads<s-parame-vms-ia64.ads \
-      $(ATOMICS_TARGET_PAIRS)
-  else
-    ifeq ($(strip $(filter-out alpha64 dec vms% openvms% alphavms%,$(targ))),)
-      LIBGNAT_TARGET_PAIRS_AUX1 = \
-        g-enblsp.adb<g-enblsp-vms-alpha.adb \
-        g-trasym.adb<g-trasym-vms-alpha.adb \
-        s-asthan.adb<s-asthan-vms-alpha.adb \
-        s-auxdec.adb<s-auxdec-vms-alpha.adb \
-        s-osinte.adb<s-osinte-vms.adb \
-        s-osinte.ads<s-osinte-vms.ads \
-        s-traent.adb<s-traent-vms.adb \
-        s-traent.ads<s-traent-vms.ads \
-        s-vaflop.adb<s-vaflop-vms-alpha.adb \
-        system.ads<system-vms_64.ads
-
-      ifeq ($(strip $(filter-out express EXPRESS,$(THREAD_KIND))),)
-        LIBGNAT_TARGET_PAIRS_AUX2 = \
-          s-parame.ads<s-parame-vms-restrict.ads
-      else
-        LIBGNAT_TARGET_PAIRS_AUX2 = \
-          s-parame.ads<s-parame-vms-alpha.ads \
-          $(ATOMICS_TARGET_PAIRS)
-      endif
-    endif
-  endif
-
   LIBGNAT_TARGET_PAIRS = \
     a-caldel.adb<a-caldel-vms.adb \
     a-calend.adb<a-calend-vms.adb \
@@ -1521,11 +1501,6 @@ ifeq ($(strip $(filter-out alpha64 ia64 dec hp vms% openvms% alphavms%,$(targ)))
     g-socthi.ads<g-socthi-vms.ads \
     g-socthi.adb<g-socthi-vms.adb \
     g-stsifd.adb<g-stsifd-sockets.adb \
-    i-c.ads<i-c-vms_64.ads \
-    i-cstrin.ads<i-cstrin-vms_64.ads \
-    i-cstrin.adb<i-cstrin-vms_64.adb \
-    i-cpoint.ads<i-cpoint-vms_64.ads \
-    i-cpoint.adb<i-cpoint-vms_64.adb \
     i-cstrea.adb<i-cstrea-vms.adb \
     memtrack.adb<memtrack-vms_64.adb \
     s-auxdec.ads<s-auxdec-vms_64.ads \
@@ -1540,34 +1515,58 @@ ifeq ($(strip $(filter-out alpha64 ia64 dec hp vms% openvms% alphavms%,$(targ)))
     s-taprop.adb<s-taprop-vms.adb \
     s-tasdeb.adb<s-tasdeb-vms.adb \
     s-taspri.ads<s-taspri-vms.ads \
-    s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
+    s-tpopsp.adb<s-tpopsp-vms.adb \
     s-tpopde.adb<s-tpopde-vms.adb \
-    s-tpopde.ads<s-tpopde-vms.ads \
-    $(LIBGNAT_TARGET_PAIRS_AUX1) \
-    $(LIBGNAT_TARGET_PAIRS_AUX2)
+    s-tpopde.ads<s-tpopde-vms.ads
 
   ifeq ($(strip $(filter-out ia64 hp vms% openvms%,$(targ))),)
+    LIBGNAT_TARGET_PAIRS += \
+      g-enblsp.adb<g-enblsp-vms-ia64.adb \
+      g-trasym.adb<g-trasym-vms-ia64.adb \
+      s-asthan.adb<s-asthan-vms-ia64.adb \
+      s-auxdec.adb<s-auxdec-vms-ia64.adb \
+      s-osinte.adb<s-osinte-vms-ia64.adb \
+      s-osinte.ads<s-osinte-vms-ia64.ads \
+      s-vaflop.adb<s-vaflop-vms-ia64.adb \
+      system.ads<system-vms-ia64.ads \
+      s-parame.ads<s-parame-vms-ia64.ads \
+      $(ATOMICS_TARGET_PAIRS) \
+      $(ATOMICS_BUILTINS_TARGET_PAIRS)
+
     TOOLS_TARGET_PAIRS= \
       mlib-tgt-specific.adb<mlib-tgt-specific-vms-ia64.adb \
       symbols.adb<symbols-vms.adb \
       symbols-processing.adb<symbols-processing-vms-ia64.adb
   else
+    ifeq ($(strip $(filter-out alpha64 dec vms% openvms% alphavms%,$(targ))),)
+      LIBGNAT_TARGET_PAIRS += \
+        g-enblsp.adb<g-enblsp-vms-alpha.adb \
+        g-trasym.adb<g-trasym-vms-alpha.adb \
+        s-asthan.adb<s-asthan-vms-alpha.adb \
+        s-auxdec.adb<s-auxdec-vms-alpha.adb \
+        s-osinte.adb<s-osinte-vms.adb \
+        s-osinte.ads<s-osinte-vms.ads \
+        s-traent.adb<s-traent-vms.adb \
+        s-traent.ads<s-traent-vms.ads \
+        s-vaflop.adb<s-vaflop-vms-alpha.adb \
+        system.ads<system-vms_64.ads \
+       s-parame.ads<s-parame-vms-alpha.ads \
+        $(ATOMICS_TARGET_PAIRS) \
+        $(ATOMICS_BUILTINS_TARGET_PAIRS)
+
     TOOLS_TARGET_PAIRS= \
       mlib-tgt-specific.adb<mlib-tgt-specific-vms-alpha.adb \
       symbols.adb<symbols-vms.adb \
       symbols-processing.adb<symbols-processing-vms-alpha.adb
+    endif
   endif
 
-adamsg.o: adamsg.msg
-       -$(DECC) --cc=message adamsg.msg -o adamsg.o
-
   EXTRA_GNATMAKE_OBJS = mlib-tgt-vms_common.o
 
   GMEM_LIB = gmemlib
   EH_MECHANISM=-gcc
   GNATLIB_SHARED=gnatlib-shared-vms
-  EXTRA_LIBGNAT_SRCS+=adamsg.msg
-  EXTRA_LIBGNAT_OBJS+=adamsg.o
+  EXTRA_GNATRTL_NONTASKING_OBJS+=s-po32gl.o
   EXTRA_GNATRTL_TASKING_OBJS=s-tpopde.o
   EXTRA_GNATTOOLS = \
      ../../gnatsym$(exeext)
@@ -1583,30 +1582,43 @@ ifeq ($(strip $(filter-out avr none powerpc% eabispe leon% erc32% unknown elf,$(
   indepsw.adb<indepsw-gnu.adb
 endif
 
-ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
-  LIBGNAT_TARGET_PAIRS = \
+ifeq ($(strip $(filter-out cygwin% mingw32% pe,$(osys))),)
+  # Cygwin provides a full Posix environment, and so we use the default
+  # versions of s-memory and g-socthi rather than the Windows-specific
+  # MinGW versions.  Ideally we would use all the default versions for
+  # Cygwin and none of the MinGW versions, but for historical reasons
+  # the Cygwin port has always been a CygMing frankenhybrid and it is
+  # a long-term project to disentangle them.
+  ifeq ($(strip $(filter-out cygwin%,$(osys))),)
+    LIBGNAT_TARGET_PAIRS = \
+    s-memory.adb<s-memory.adb \
+    g-socthi.ads<g-socthi.ads \
+    g-socthi.adb<g-socthi.adb
+  else
+    LIBGNAT_TARGET_PAIRS = \
+    s-memory.adb<s-memory-mingw.adb \
+    g-socthi.ads<g-socthi-mingw.ads \
+    g-socthi.adb<g-socthi-mingw.adb
+  endif
+  LIBGNAT_TARGET_PAIRS += \
   a-dirval.adb<a-dirval-mingw.adb \
   a-excpol.adb<a-excpol-abort.adb \
-  a-numaux.adb<a-numaux-x86.adb \
-  a-numaux.ads<a-numaux-x86.ads \
   s-gloloc.adb<s-gloloc-mingw.adb \
   s-inmaop.adb<s-inmaop-dummy.adb \
-  s-memory.adb<s-memory-mingw.adb \
   s-taspri.ads<s-taspri-mingw.ads \
   s-tasinf.adb<s-tasinf-mingw.adb \
   s-tasinf.ads<s-tasinf-mingw.ads \
-  g-bytswa.adb<g-bytswa-x86.adb \
-  g-socthi.ads<g-socthi-mingw.ads \
-  g-socthi.adb<g-socthi-mingw.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
-  g-soliop.ads<g-soliop-mingw.ads
+  g-soliop.ads<g-soliop-mingw.ads \
+  $(ATOMICS_TARGET_PAIRS)
 
   ifeq ($(strip $(filter-out rtx_w32 rtx_rtss,$(THREAD_KIND))),)
     LIBGNAT_TARGET_PAIRS += \
     s-intman.adb<s-intman-dummy.adb \
     s-osinte.ads<s-osinte-rtx.ads \
     s-osprim.adb<s-osprim-rtx.adb \
-    s-taprop.adb<s-taprop-rtx.adb
+    s-taprop.adb<s-taprop-rtx.adb \
+    $(X86_TARGET_PAIRS)
 
     EXTRA_GNATRTL_NONTASKING_OBJS = s-win32.o
 
@@ -1630,6 +1642,7 @@ ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
     g-sercom.adb<g-sercom-mingw.adb \
     s-interr.adb<s-interr-sigaction.adb \
     s-intman.adb<s-intman-mingw.adb \
+    s-mudido.adb<s-mudido-affinity.adb \
     s-osinte.ads<s-osinte-mingw.ads \
     s-osprim.adb<s-osprim-mingw.adb \
     s-taprop.adb<s-taprop-mingw.adb
@@ -1637,18 +1650,26 @@ ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
     ifeq ($(strip $(filter-out x86_64%,$(arch))),)
       ifeq ($(strip $(MULTISUBDIR)),/32)
        LIBGNAT_TARGET_PAIRS += \
+         $(X86_TARGET_PAIRS) \
          system.ads<system-mingw.ads
+       SO_OPTS= -m32 -Wl,-soname,
       else
        LIBGNAT_TARGET_PAIRS += \
+         $(X86_64_TARGET_PAIRS) \
          system.ads<system-mingw-x86_64.ads
+       SO_OPTS = -m64 -Wl,-soname,
       endif
     else
       ifeq ($(strip $(MULTISUBDIR)),/64)
        LIBGNAT_TARGET_PAIRS += \
+         $(X86_64_TARGET_PAIRS) \
          system.ads<system-mingw-x86_64.ads
+       SO_OPTS = -m64 -Wl,-soname,
       else
        LIBGNAT_TARGET_PAIRS += \
+         $(X86_TARGET_PAIRS) \
          system.ads<system-mingw.ads
+       SO_OPTS = -m32 -Wl,-soname,
       endif
     endif
 
@@ -1661,6 +1682,8 @@ ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
     # ??? This will be replaced by gnatlib-shared-dual-win32 when GNAT
     # auto-import support for array/record will be done.
     GNATLIB_SHARED = gnatlib-shared-win32
+
+    EH_MECHANISM=-gcc
   endif
 
   TOOLS_TARGET_PAIRS= \
@@ -1786,14 +1809,16 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(arch) $(osys))),)
   a-exetim.adb<a-exetim-posix.adb \
   a-exetim.ads<a-exetim-default.ads \
   a-intnam.ads<a-intnam-linux.ads \
+  a-synbar.adb<a-synbar-posix.adb \
+  a-synbar.ads<a-synbar-posix.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-posix.adb \
   s-linux.ads<s-linux.ads \
   s-osinte.adb<s-osinte-posix.adb \
-  s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
+  s-tpopsp.adb<s-tpopsp-tls.adb \
   g-sercom.adb<g-sercom-linux.adb \
-  g-trasym.adb<g-trasym-dwarf.adb \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   ifeq ($(strip $(filter-out xenomai,$(THREAD_KIND))),)
     LIBGNAT_TARGET_PAIRS = \
@@ -1804,7 +1829,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(arch) $(osys))),)
     s-osprim.adb<s-osprim-linux-xenomai.adb \
     s-taprop.adb<s-taprop-linux-xenomai.adb \
     s-taspri.ads<s-taspri-linux-xenomai.ads \
-    system.ads<system-linux-ppc-xenomai.ads
+    system.ads<system-linux-ppc.ads
   else
     LIBGNAT_TARGET_PAIRS_32 = \
     system.ads<system-linux-ppc.ads
@@ -1821,6 +1846,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(arch) $(osys))),)
     endif
 
     LIBGNAT_TARGET_PAIRS += \
+    s-mudido.adb<s-mudido-affinity.adb \
     s-osinte.ads<s-osinte-linux.ads \
     s-osprim.adb<s-osprim-posix.adb \
     s-taprop.adb<s-taprop-linux.adb \
@@ -1889,11 +1915,9 @@ ifeq ($(strip $(filter-out sparc% linux%,$(arch) $(osys))),)
   s-tasinf.ads<s-tasinf-linux.ads \
   s-tasinf.adb<s-tasinf-linux.adb \
   s-taspri.ads<s-taspri-posix-noaltstack.ads \
-  s-tpopsp.adb<s-tpopsp-posix-foreign.adb
+  s-tpopsp.adb<s-tpopsp-tls.adb
 
   LIBGNAT_TARGET_PAIRS_32 = \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-linux-sparc.ads
 
   LIBGNAT_TARGET_PAIRS_64 = \
@@ -1933,8 +1957,6 @@ ifeq ($(strip $(filter-out hppa% linux%,$(arch) $(osys))),)
   s-tasinf.adb<s-tasinf-linux.adb \
   s-taspri.ads<s-taspri-posix-noaltstack.ads \
   s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-linux-hppa.ads
 
   TOOLS_TARGET_PAIRS =  \
@@ -1968,7 +1990,7 @@ ifeq ($(strip $(filter-out sh4% linux%,$(arch) $(osys))),)
   TOOLS_TARGET_PAIRS =  \
     mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
     indepsw.adb<indepsw-linux.adb
+
   EXTRA_GNATRTL_TASKING_OBJS=s-linux.o
   EH_MECHANISM=-gcc
   MISCLIB=
@@ -1984,20 +2006,24 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(arch) $(osys))),)
   a-exetim.ads<a-exetim-default.ads \
   a-intnam.ads<a-intnam-linux.ads \
   a-numaux.ads<a-numaux-libc-x86.ads \
+  a-synbar.adb<a-synbar-posix.adb \
+  a-synbar.ads<a-synbar-posix.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-posix.adb \
   s-linux.ads<s-linux.ads \
+  s-mudido.adb<s-mudido-affinity.adb \
   s-osinte.ads<s-osinte-linux.ads \
   s-osinte.adb<s-osinte-posix.adb \
   s-osprim.adb<s-osprim-posix.adb \
   s-taprop.adb<s-taprop-linux.adb \
   s-tasinf.ads<s-tasinf-linux.ads \
   s-tasinf.adb<s-tasinf-linux.adb \
-  s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
+  s-tpopsp.adb<s-tpopsp-tls.adb \
   s-taspri.ads<s-taspri-posix-noaltstack.ads \
   g-sercom.adb<g-sercom-linux.adb \
   system.ads<system-linux-ia64.ads \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS =  \
     mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
@@ -2024,7 +2050,8 @@ ifeq ($(strip $(filter-out ia64% hp hpux%,$(targ))),)
   s-taspri.ads<s-taspri-posix-noaltstack.ads \
   s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
   system.ads<system-hpux-ia64.ads \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS = \
   mlib-tgt-specific.adb<mlib-tgt-specific-ia64-hpux.adb
@@ -2052,10 +2079,9 @@ ifeq ($(strip $(filter-out alpha% linux%,$(arch) $(osys))),)
   s-tasinf.adb<s-tasinf-linux.adb \
   s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
   s-taspri.ads<s-taspri-posix-noaltstack.ads \
-  g-trasym.ads<g-trasym-unimplemented.ads \
-  g-trasym.adb<g-trasym-unimplemented.adb \
   system.ads<system-linux-alpha.ads \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(ATOMICS_BUILTINS_TARGET_PAIRS)
 
   TOOLS_TARGET_PAIRS =  \
     mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
@@ -2074,22 +2100,24 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(arch) $(osys))),)
   a-exetim.adb<a-exetim-posix.adb \
   a-exetim.ads<a-exetim-default.ads \
   a-intnam.ads<a-intnam-linux.ads \
-  a-numaux.adb<a-numaux-x86.adb \
-  a-numaux.ads<a-numaux-x86.ads \
+  a-synbar.adb<a-synbar-posix.adb \
+  a-synbar.ads<a-synbar-posix.ads \
   s-inmaop.adb<s-inmaop-posix.adb \
   s-intman.adb<s-intman-posix.adb \
   s-linux.ads<s-linux.ads \
+  s-mudido.adb<s-mudido-affinity.adb \
   s-osinte.ads<s-osinte-linux.ads \
   s-osinte.adb<s-osinte-posix.adb \
   s-osprim.adb<s-osprim-posix.adb \
   s-taprop.adb<s-taprop-linux.adb \
   s-tasinf.ads<s-tasinf-linux.ads \
   s-tasinf.adb<s-tasinf-linux.adb \
-  s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
+  s-tpopsp.adb<s-tpopsp-tls.adb \
   s-taspri.ads<s-taspri-posix.ads \
   g-sercom.adb<g-sercom-linux.adb \
-  system.ads<system-linux-x86_64.ads \
-  $(ATOMICS_TARGET_PAIRS)
+  $(ATOMICS_TARGET_PAIRS) \
+  $(X86_64_TARGET_PAIRS) \
+  system.ads<system-linux-x86_64.ads
 
   TOOLS_TARGET_PAIRS =  \
     mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
@@ -2105,83 +2133,75 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(arch) $(osys))),)
 endif
 
 ifeq ($(strip $(filter-out darwin%,$(osys))),)
-  ifeq ($(strip $(filter-out %86,$(arch))),)
-    LIBGNAT_TARGET_PAIRS = \
+  SO_OPTS = -shared-libgcc
+  LIBGNAT_TARGET_PAIRS = \
     a-intnam.ads<a-intnam-darwin.ads \
-    i-forbla.adb<i-forbla-darwin.adb \
     s-inmaop.adb<s-inmaop-posix.adb \
-    s-intman.adb<s-intman-susv3.adb \
     s-osinte.adb<s-osinte-darwin.adb \
     s-osinte.ads<s-osinte-darwin.ads \
-    s-osprim.adb<s-osprim-darwin.adb \
     s-taprop.adb<s-taprop-posix.adb \
     s-taspri.ads<s-taspri-posix.ads \
-    s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
-    g-trasym.ads<g-trasym-unimplemented.ads \
-    g-trasym.adb<g-trasym-unimplemented.adb \
-    a-numaux.ads<a-numaux-x86.ads \
-    a-numaux.adb<a-numaux-x86.adb
+    s-tpopsp.adb<s-tpopsp-posix-foreign.adb
+  
+  ifeq ($(strip $(filter-out %86,$(arch))),)
+    LIBGNAT_TARGET_PAIRS += \
+      s-intman.adb<s-intman-susv3.adb \
+      s-osprim.adb<s-osprim-darwin.adb \
+      $(ATOMICS_TARGET_PAIRS)
+
     ifeq ($(strip $(MULTISUBDIR)),/x86_64)
       LIBGNAT_TARGET_PAIRS += \
-      system.ads<system-darwin-x86_64.ads
+        $(X86_64_TARGET_PAIRS) \
+        system.ads<system-darwin-x86_64.ads
+      SO_OPTS += -m64
     else
       LIBGNAT_TARGET_PAIRS += \
-      system.ads<system-darwin-x86.ads
+        $(X86_TARGET_PAIRS) \
+        system.ads<system-darwin-x86.ads
     endif
   endif
 
   ifeq ($(strip $(filter-out %x86_64,$(arch))),)
-    LIBGNAT_TARGET_PAIRS = \
-    a-intnam.ads<a-intnam-darwin.ads \
-    i-forbla.adb<i-forbla-darwin.adb \
-    s-inmaop.adb<s-inmaop-posix.adb \
-    s-intman.adb<s-intman-susv3.adb \
-    s-osinte.adb<s-osinte-darwin.adb \
-    s-osinte.ads<s-osinte-darwin.ads \
-    s-osprim.adb<s-osprim-darwin.adb \
-    s-taprop.adb<s-taprop-posix.adb \
-    s-taspri.ads<s-taspri-posix.ads \
-    s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
-    g-trasym.ads<g-trasym-unimplemented.ads \
-    g-trasym.adb<g-trasym-unimplemented.adb \
-    a-numaux.ads<a-numaux-x86.ads \
-    a-numaux.adb<a-numaux-x86.adb \
-    $(ATOMICS_TARGET_PAIRS)
+    LIBGNAT_TARGET_PAIRS += \
+      s-intman.adb<s-intman-susv3.adb \
+      s-osprim.adb<s-osprim-darwin.adb \
+      $(ATOMICS_TARGET_PAIRS)
+
     ifeq ($(strip $(MULTISUBDIR)),/i386)
       LIBGNAT_TARGET_PAIRS += \
-      system.ads<system-darwin-x86.ads
+        $(X86_TARGET_PAIRS) \
+        system.ads<system-darwin-x86.ads
+      SO_OPTS += -m32
     else
       LIBGNAT_TARGET_PAIRS += \
-      system.ads<system-darwin-x86_64.ads
+        $(X86_64_TARGET_PAIRS) \
+        system.ads<system-darwin-x86_64.ads
     endif
   endif
 
   ifeq ($(strip $(filter-out powerpc%,$(arch))),)
-    LIBGNAT_TARGET_PAIRS = \
-    a-intnam.ads<a-intnam-darwin.ads \
-    i-forbla.adb<i-forbla-darwin.adb \
-    s-inmaop.adb<s-inmaop-posix.adb \
-    s-intman.adb<s-intman-posix.adb \
-    s-osinte.adb<s-osinte-darwin.adb \
-    s-osinte.ads<s-osinte-darwin.ads \
-    s-osprim.adb<s-osprim-posix.adb \
-    s-taprop.adb<s-taprop-posix.adb \
-    s-taspri.ads<s-taspri-posix.ads \
-    s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
-    a-numaux.ads<a-numaux-darwin.ads \
-    a-numaux.adb<a-numaux-darwin.adb \
-    g-trasym.ads<g-trasym-unimplemented.ads \
-    g-trasym.adb<g-trasym-unimplemented.adb \
-    system.ads<system-darwin-ppc.ads
+    LIBGNAT_TARGET_PAIRS += \
+      s-intman.adb<s-intman-posix.adb \
+      s-osprim.adb<s-osprim-posix.adb \
+      a-numaux.ads<a-numaux-darwin.ads \
+      a-numaux.adb<a-numaux-darwin.adb
+    
+    ifeq ($(strip $(MULTISUBDIR)),/ppc64)
+      LIBGNAT_TARGET_PAIRS += \
+        system.ads<system-darwin-ppc64.ads
+        SO_OPTS += -m64
+    else
+      LIBGNAT_TARGET_PAIRS += \
+      system.ads<system-darwin-ppc.ads
+    endif
   endif
 
   TOOLS_TARGET_PAIRS =  \
-    mlib-tgt-specific.adb<mlib-tgt-specific-darwin.adb
+    mlib-tgt-specific.adb<mlib-tgt-specific-darwin.adb \
+    indepsw.adb<indepsw-darwin.adb
 
   EH_MECHANISM=-gcc
   GNATLIB_SHARED = gnatlib-shared-darwin
-  SO_OPTS = -Wl,-flat_namespace -shared-libgcc
-  RANLIB = ranlib -c
   GMEM_LIB = gmemlib
   LIBRARY_VERSION := $(LIB_VERSION)
   soext = .dylib
@@ -2219,12 +2239,13 @@ LIBGNAT_SRCS = adadecode.c adadecode.h adaint.c adaint.h        \
   argv.c cio.c cstreams.c errno.c exit.c cal.c ctrl_c.c env.c env.h    \
   arit64.c raise.h raise.c sysdep.c aux-io.c init.c initialize.c       \
   locales.c seh_init.c final.c tracebak.c tb-alvms.c tb-alvxw.c         \
-  tb-gcc.c expect.c mkdir.c socket.c gsocket.h targext.c $(EXTRA_LIBGNAT_SRCS)
+  tb-gcc.c expect.c mkdir.c socket.c gsocket.h targext.c terminals.c   \
+  thread.c $(EXTRA_LIBGNAT_SRCS)
 
 LIBGNAT_OBJS = adadecode.o adaint.o argv.o cio.o cstreams.o ctrl_c.o   \
   errno.o exit.o env.o raise.o sysdep.o aux-io.o init.o initialize.o   \
   locales.o seh_init.o cal.o arit64.o final.o tracebak.o expect.o       \
-  mkdir.o socket.o targext.o $(EXTRA_LIBGNAT_OBJS)
+  mkdir.o socket.o targext.o terminals.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
@@ -2236,11 +2257,8 @@ LIBGNAT_OBJS = adadecode.o adaint.o argv.o cio.o cstreams.o ctrl_c.o     \
 
 include $(fsrcdir)/ada/Makefile.rtl
 
-GNATRTL_LINEARALGEBRA_OBJS = a-nlcoar.o a-nllcar.o a-nllrar.o a-nlrear.o \
-  a-nucoar.o a-nurear.o i-forbla.o i-forlap.o s-gearop.o
-
 GNATRTL_OBJS = $(GNATRTL_NONTASKING_OBJS) $(GNATRTL_TASKING_OBJS) \
-  $(GNATRTL_LINEARALGEBRA_OBJS) g-trasym.o memtrack.o
+  memtrack.o
 
 # Default run time files
 
@@ -2253,8 +2271,32 @@ ADA_INCLUDE_SRCS =\
 
 LIBGNAT=../$(RTSDIR)/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)"      \
+       "fsrcdir=$(fsrcdir)"    \
+       "srcdir=$(fsrcdir)"     \
+       "TOOLS_LIBS=$(TOOLS_LIBS) $(TGT_LIB)"   \
+       "GNATMAKE=$(GNATMAKE)"  \
+       "GNATLINK=$(GNATLINK)"  \
+       "GNATBIND=$(GNATBIND)"
+
 GCC_LINK=$(CC) $(GCC_LINK_FLAGS) $(ADA_INCLUDES)
 
+# 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
+# Note: dummy target, stamp-tools is mainly handled by gnattools.
+
+../stamp-tools:
+       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)
@@ -2273,8 +2315,39 @@ ifeq ($(TOOLSCASE),cross)
   vpath %.h   ../
 endif
 
-common-tools:
-       $(GNATMAKE) -c -b $(ADA_INCLUDES) \
+# 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-$(RTSDIR)
+       $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
+         TOOLSCASE=native \
+         ../../gnatmake$(exeext) ../../gnatlink$(exeext)
+
+# gnatmake/link can be built 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 common-tools $(EXTRA_GNATTOOLS)
+
+# those tools are only built for the cross version
+gnattools4: ../stamp-tools
+ifeq ($(ENABLE_VXADDR2LINE),true)
+       $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
+         TOOLSCASE=cross top_buildir=../../.. \
+         ../../vxaddr2line$(exeext)
+endif
+
+common-tools: ../stamp-tools
+       $(GNATMAKE) -j0 -c -b $(ADA_INCLUDES) \
          --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
          gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
          gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS)
@@ -2297,32 +2370,34 @@ common-tools:
        $(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \
                --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
 
-../../gnatsym$(exeext): 
+../../gnatsym$(exeext): ../stamp-tools
        $(GNATMAKE) -c $(ADA_INCLUDES) gnatsym --GCC="$(CC) $(ALL_ADAFLAGS)"
        $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatsym
        $(GNATLINK) -v gnatsym -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
 
-../../gnatdll$(exeext): 
+../../gnatdll$(exeext): ../stamp-tools
        $(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)"
        $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatdll
        $(GNATLINK) -v gnatdll -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
 
-../../vxaddr2line$(exeext): targext.o
+../../vxaddr2line$(exeext): ../stamp-tools targext.o
        $(GNATMAKE) -c  $(ADA_INCLUDES) vxaddr2line --GCC="$(CC) $(ALL_ADAFLAGS)"
        $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) vxaddr2line
        $(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" targext.o $(CLIB)
 
-gnatmake-re:  link.o targext.o
-       $(GNATMAKE) $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
-       $(GNATMAKE) -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
+gnatmake-re: ../stamp-tools link.o targext.o
+       $(GNATMAKE) -j0 $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
+       $(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
        $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake
        $(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \
                --GCC="$(GCC_LINK)" $(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 targext.o
-       $(GNATMAKE) -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
+# gnatlink-re cannot be run at the same time as gnatmake-re, hence the
+# dependency
+gnatlink-re: ../stamp-tools link.o targext.o gnatmake-re
+       $(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
        $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink
        $(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \
                    --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
@@ -2363,7 +2438,6 @@ install-gnatlib: ../stamp-gnatlib-$(RTSDIR)
        for file in $(RTSDIR)/*.ali; do \
            $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
        done
-       -$(INSTALL_DATA) $(RTSDIR)/g-trasym$(objext) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
        -cd $(RTSDIR); for file in *$(arext);do \
            $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
            $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$$file; \
@@ -2439,21 +2513,52 @@ install-gnatlib: ../stamp-gnatlib-$(RTSDIR)
        $(foreach PAIR,$(LIBGNAT_TARGET_PAIRS), \
                  $(LN_S) $(fsrcpfx)ada/$(word 2,$(subst <, ,$(PAIR))) \
                        $(RTSDIR)/$(word 1,$(subst <, ,$(PAIR)));)
-# Copy generated target dependent sources
-       $(RM) $(RTSDIR)/s-oscons.ads
-       (cd $(RTSDIR); $(LN_S) ../s-oscons.ads s-oscons.ads)
+# Copy tsystem.h
+       $(CP) $(srcdir)/tsystem.h $(RTSDIR)
        $(RM) ../stamp-gnatlib-$(RTSDIR)
        touch ../stamp-gnatlib1-$(RTSDIR)
 
 # GNULLI End #############################################################
 
+ifeq ($(strip $(filter-out alpha64 ia64 dec hp vms% openvms% alphavms%,$(subst -, ,$(host)))),)
+OSCONS_CPP=../../$(DECC) -E /comment=as_is -DNATIVE \
+             -DTARGET='""$(target)""' $(fsrcpfx)ada/s-oscons-tmplt.c
+
+OSCONS_EXTRACT=../../$(DECC) -DNATIVE \
+                 -DTARGET='""$(target)""' $(fsrcpfx)ada/s-oscons-tmplt.c ; \
+  ld -o s-oscons-tmplt.exe s-oscons-tmplt.obj; \
+  ./s-oscons-tmplt.exe > s-oscons-tmplt.s
+
+else
+# GCC_FOR_TARGET has paths relative to the gcc directory, so we need to adjust
+# for running it from $(RTSDIR)
+OSCONS_CC=`echo "$(GCC_FOR_TARGET)" \
+  | sed -e 's^\./xgcc^../../xgcc^' -e 's^-B./^-B../../^'`
+OSCONS_CPP=$(OSCONS_CC) $(GNATLIBCFLAGS) -E -C \
+  -DTARGET=\"$(target)\" $(fsrcpfx)ada/s-oscons-tmplt.c > s-oscons-tmplt.i
+OSCONS_EXTRACT=$(OSCONS_CC) $(GNATLIBCFLAGS) -S s-oscons-tmplt.i
+endif
+
+./bldtools/oscons/xoscons: xoscons.adb xutil.ads xutil.adb
+       -$(MKDIR) ./bldtools/oscons
+       $(RM) $(addprefix ./bldtools/oscons/,$(notdir $^))
+       $(CP) $^ ./bldtools/oscons
+       (cd ./bldtools/oscons ; gnatmake -q xoscons)
+
+$(RTSDIR)/s-oscons.ads: ../stamp-gnatlib1-$(RTSDIR) s-oscons-tmplt.c gsocket.h ./bldtools/oscons/xoscons
+       $(RM) $(RTSDIR)/s-oscons-tmplt.i $(RTSDIR)/s-oscons-tmplt.s
+       (cd $(RTSDIR) ; \
+           $(OSCONS_CPP) ; \
+           $(OSCONS_EXTRACT) ; \
+           ../bldtools/oscons/xoscons)
+
 # 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 $(RTSDIR); ar rc libfoo.a $(LONG_LIST_OF_OBJS)
 # is guaranteed to overflow the buffer.
 
-gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR)
+gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR) $(RTSDIR)/s-oscons.ads
        $(MAKE) -C $(RTSDIR) \
                CC="`echo \"$(GCC_FOR_TARGET)\" \
                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
@@ -2479,9 +2584,6 @@ gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR)
        $(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnarl$(arext) \
           $(addprefix $(RTSDIR)/,$(GNATRTL_TASKING_OBJS))
        $(RANLIB_FOR_TARGET) $(RTSDIR)/libgnarl$(arext)
-       $(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnala$(arext) \
-          $(addprefix $(RTSDIR)/,$(GNATRTL_LINEARALGEBRA_OBJS))
-       $(RANLIB_FOR_TARGET) $(RTSDIR)/libgnala$(arext)
         ifeq ($(GMEM_LIB),gmemlib)
                $(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgmem$(arext) \
                  $(RTSDIR)/memtrack.o
@@ -2494,20 +2596,22 @@ gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR)
 gnatlib-shared-default:
        $(MAKE) $(FLAGS_TO_PASS) \
              GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
-            GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
+            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \
+            GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET)" \
             MULTISUBDIR="$(MULTISUBDIR)" \
             THREAD_KIND="$(THREAD_KIND)" \
              gnatlib
        $(RM) $(RTSDIR)/libgna*$(soext)
-       cd $(RTSDIR); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
-               $(TARGET_LIBGCC2_CFLAGS) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
+               $(PICFLAG_FOR_TARGET) \
                -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
                $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(MISCLIB) -lm
-       cd $(RTSDIR); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
-               $(TARGET_LIBGCC2_CFLAGS) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
+               $(PICFLAG_FOR_TARGET) \
                -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_TASKING_OBJS) \
                $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
@@ -2539,8 +2643,9 @@ gnatlib-shared-dual:
 gnatlib-shared-dual-win32:
        $(MAKE) $(FLAGS_TO_PASS) \
              GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
+            GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
             GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
+            PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \
             MULTISUBDIR="$(MULTISUBDIR)" \
             THREAD_KIND="$(THREAD_KIND)" \
              gnatlib-shared-win32
@@ -2562,19 +2667,21 @@ gnatlib-shared-dual-win32:
 gnatlib-shared-win32:
        $(MAKE) $(FLAGS_TO_PASS) \
              GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
-            GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
+            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \
+            GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET)" \
             MULTISUBDIR="$(MULTISUBDIR)" \
             THREAD_KIND="$(THREAD_KIND)" \
              gnatlib
        $(RM) $(RTSDIR)/libgna*$(soext)
-       cd $(RTSDIR); ../../xgcc -B../../ -shared -shared-libgcc \
-               $(TARGET_LIBGCC2_CFLAGS) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \
+               $(PICFLAG_FOR_TARGET) \
                -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
                $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB)
-       cd $(RTSDIR); ../../xgcc -B../../ -shared -shared-libgcc \
-               $(TARGET_LIBGCC2_CFLAGS) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \
+               $(PICFLAG_FOR_TARGET) \
                -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_TASKING_OBJS) \
                $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
@@ -2583,19 +2690,21 @@ gnatlib-shared-win32:
 gnatlib-shared-darwin:
        $(MAKE) $(FLAGS_TO_PASS) \
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS)" \
-            GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) -fno-common" \
+            GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \
+            GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET) -fno-common" \
             MULTISUBDIR="$(MULTISUBDIR)" \
             THREAD_KIND="$(THREAD_KIND)" \
             gnatlib
        $(RM) $(RTSDIR)/libgnat$(soext) $(RTSDIR)/libgnarl$(soext)
-       cd $(RTSDIR); ../../xgcc -B../../ -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG_FOR_TARGET) \
                -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
                $(SO_OPTS) \
                -Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
-               $(MISCLIB) -lm
-       cd $(RTSDIR); ../../xgcc -B../../ -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \
+               $(MISCLIB)
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG_FOR_TARGET) \
                -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_TASKING_OBJS) \
                $(SO_OPTS) \
@@ -2644,26 +2753,34 @@ gnatlib-shared:
             GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
             MULTISUBDIR="$(MULTISUBDIR)" \
             THREAD_KIND="$(THREAD_KIND)" \
-            TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \
+            PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \
              $(GNATLIB_SHARED)
 
+# When building a SJLJ runtime for VxWorks, in addition to forcing
+# ZCX_By_default to True, we need to ensure that -crtbe linker options
+# is not passed. Otherwise we will end with weak symbols on 
+# __register_frame_info and __deregister_frame_info. The VxWorks 5.x
+# will issue an error on weak symbols.
 gnatlib-sjlj:
        $(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="" \
        THREAD_KIND="$(THREAD_KIND)" ../stamp-gnatlib1-$(RTSDIR)
        sed -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := False;/' $(RTSDIR)/system.ads > $(RTSDIR)/s.ads
-       $(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads
+       cat $(RTSDIR)/s.ads | grep -v "Linker_Options.*-crtbe" > $(RTSDIR)/s2.ads
+       $(RM) $(RTSDIR)/s.ads
+       $(MV) $(RTSDIR)/s2.ads $(RTSDIR)/system.ads
        $(MAKE) $(FLAGS_TO_PASS) \
             EH_MECHANISM="" \
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
             GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
             GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
+            FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
             MULTISUBDIR="$(MULTISUBDIR)" \
             THREAD_KIND="$(THREAD_KIND)" \
-            TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib
+            PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" gnatlib
 
 gnatlib-zcx:
        $(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="-gcc" \
-       THREAD_KIND="$(THREAD_KIND)" ../stamp-gnatlib1-$(RTSDIR)
+         THREAD_KIND="$(THREAD_KIND)" ../stamp-gnatlib1-$(RTSDIR)
        sed -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := True;/' $(RTSDIR)/system.ads > $(RTSDIR)/s.ads
        $(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads
        $(MAKE) $(FLAGS_TO_PASS) \
@@ -2671,13 +2788,10 @@ gnatlib-zcx:
             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
             GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
             GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
+            FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
             MULTISUBDIR="$(MULTISUBDIR)" \
             THREAD_KIND="$(THREAD_KIND)" \
-            TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib
-
-# .s files for cross-building
-gnat-cross: force
-       make $(GNAT1_ADA_OBJS) CC="gcc -B../stage1/" CFLAGS="-S -gnatp"
+            PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" gnatlib
 
 # Compiling object files from source files.
 
@@ -2687,33 +2801,32 @@ gnat-cross: force
 # because all that file does, when not compiling with GCC,
 # is include the system varargs.h.
 
-b_gnatl.c : $(GNATLINK_OBJS)
-       $(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatl.c gnatlink.ali
-b_gnatl.o : b_gnatl.c
+b_gnatl.adb : $(GNATLINK_OBJS)
+       $(GNATBIND) $(ADA_INCLUDES) -o b_gnatl.adb gnatlink.ali
+
+b_gnatl.o : b_gnatl.adb
+       $(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) -gnatws -gnatyN \
+           $< $(OUTPUT_OPTION)
+
+b_gnatm.adb : $(GNATMAKE_OBJS)
+       $(GNATBIND) $(ADA_INCLUDES) -o b_gnatm.adb gnatmake.ali
 
-b_gnatm.c : $(GNATMAKE_OBJS)
-       $(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatm.c gnatmake.ali
-b_gnatm.o : b_gnatm.c
+b_gnatm.o : b_gnatm.adb
+       $(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) -gnatws -gnatyN \
+           $< $(OUTPUT_OPTION)
 
 ADA_INCLUDE_DIR = $(libsubdir)/adainclude
 ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
 
+# Special flags
+
 # 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
-# optimization. However we can do that only when building the runtime
-# (not the compiler) because the -fno-optimize-sibling-calls option exists
-# only in GCC 3 and above.
+# optimization.
 
-ifneq (,$(findstring xgcc,$(CC)))
-NO_SIBLING_ADAFLAGS=-fno-optimize-sibling-calls
-else
-NO_SIBLING_ADAFLAGS=
-endif
-
-s-traceb.o  : s-traceb.adb
+s-traceb.o  : s-traceb.adb s-traceb.ads
        $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) \
-             $(NO_SIBLING_ADAFLAGS) $(ADA_INCLUDES) \
-      $< $(OUTPUT_OPTION)
+             $(NO_SIBLING_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
 # force debugging information on s-tasdeb.o so that it is always
 # possible to set conditional breakpoints on tasks.
@@ -2722,11 +2835,16 @@ s-tasdeb.o  : s-tasdeb.adb s-tasdeb.ads
        $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) \
              $< $(OUTPUT_OPTION)
 
-# force no function reordering on a-except.o because of the exclusion bounds
-# mechanism (see the source file for more detailed information).
+# 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.
 
-NO_REORDER_ADAFLAGS=-fno-toplevel-reorder
+s-vaflop.o  : s-vaflop.adb s-vaflop.ads
+       $(CC) -c -O $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) $(ADA_INCLUDES) \
+             $< $(OUTPUT_OPTION)
 
+# force no function reordering on a-except.o because of the exclusion bounds
+# mechanism (see the source file for more detailed information).
 # 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.
@@ -2735,21 +2853,34 @@ a-except.o  : a-except.adb a-except.ads
        $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O1 -fno-inline \
              $(NO_REORDER_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
-# compile s-except.o without optimization and with debug info to let the
+# compile s-excdeb.o without optimization and with debug info to let the
 # debugger set breakpoints and inspect subprogram parameters on exception
 # related events.
 
-s-except.o  : s-except.adb s-except.ads
+s-excdeb.o  : s-excdeb.adb s-excdeb.ads s-except.ads
        $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) \
              $< $(OUTPUT_OPTION)
 
 # 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
-       $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O2 $(ADA_INCLUDES) \
+s-assert.o  : s-assert.adb s-assert.ads
+       $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) $(ADA_INCLUDES) \
+             $< $(OUTPUT_OPTION)
+
+# force debugging information on a-tags.o so that the debugger can find
+# the description of Ada.Tags.Type_Specific_Data.
+
+a-tags.o  : a-tags.adb a-tags.ads
+       $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) $(ADA_INCLUDES) \
              $< $(OUTPUT_OPTION)
 
+# need to keep the frame pointer in this file to pop the stack properly on
+# some targets.
+tracebak.o  : tracebak.c tb-alvms.c tb-alvxw.c tb-gcc.c
+       $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) \
+             $(INCLUDES) -fno-omit-frame-pointer $< $(OUTPUT_OPTION)
+
 adadecode.o : adadecode.c adadecode.h
 aux-io.o  : aux-io.c
 argv.o    : argv.c
@@ -2759,15 +2890,20 @@ errno.o   : errno.c
 exit.o    : adaint.h exit.c
 expect.o  : expect.c
 final.o   : final.c
-link.o    : link.c
 locales.o : locales.c
 mkdir.o   : mkdir.c
 socket.o  : socket.c gsocket.h
 sysdep.o  : sysdep.c
-raise-gcc.o : raise-gcc.c raise.h
 raise.o   : raise.c raise.h
+sigtramp-ppcvxw.o : sigtramp-ppcvxw.c sigtramp.h
+terminals.o : terminals.c
 vx_stack_info.o : vx_stack_info.c
 
+raise-gcc.o : raise-gcc.c raise.h
+       $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
+               -iquote $(srcdir) -iquote $(srcdir)/../libgcc \
+               $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+
 cio.o     : cio.c
        $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
                 $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
@@ -2780,16 +2916,16 @@ initialize.o : initialize.c raise.h
        $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
                 $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
 
-targext.o : targext.c
+link.o : link.c
        $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
                $(ALL_CPPFLAGS) $(INCLUDES_FOR_SUBDIR) \
                $< $(OUTPUT_OPTION)
 
-# Need to keep the frame pointer in this file to pop the stack properly on
-# some targets.
-tracebak.o  : tracebak.c tb-alvms.c tb-alvxw.c tb-gcc.c
-       $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) \
-             $(INCLUDES) -fno-omit-frame-pointer $< $(OUTPUT_OPTION)
+targext.o : targext.c
+       $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
+               -iquote $(srcdir) \
+               $(ALL_CPPFLAGS) $(INCLUDES_FOR_SUBDIR) \
+               $< $(OUTPUT_OPTION)
 
 # In GNU Make, ignore whether `stage*' exists.
 .PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap