Makefile.in: Don't use directly ../xgcc to build shared libgnat.
authorNicolas Roche <roche@adacore.com>
Fri, 5 Aug 2011 15:57:05 +0000 (15:57 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 5 Aug 2011 15:57:05 +0000 (17:57 +0200)
2011-08-05  Nicolas Roche  <roche@adacore.com>

* gcc-interface/Makefile.in: Don't use directly ../xgcc to build shared
libgnat. Use rather the value of GCC_FOR_TARGET. Fix issue with
canadian cross.
* gcc-interface/Make-lang.in: Add support for canadian cross setting.

From-SVN: r177462

gcc/ada/ChangeLog
gcc/ada/gcc-interface/Make-lang.in
gcc/ada/gcc-interface/Makefile.in

index 1dcb3eb5981c7bd53ac8a4f5b90021edf46cbe1e..5fc09eca0877f161573d66bab983d4420e64110a 100644 (file)
@@ -1,3 +1,10 @@
+2011-08-05  Nicolas Roche  <roche@adacore.com>
+
+       * gcc-interface/Makefile.in: Don't use directly ../xgcc to build shared
+       libgnat. Use rather the value of GCC_FOR_TARGET. Fix issue with
+       canadian cross.
+       * gcc-interface/Make-lang.in: Add support for canadian cross setting.
+
 2011-08-05  Matthew Heaney  <heaney@adacore.com>
 
        * a-comutr.adb, a-cimutr.adb, a-cbmutr.adb (Child_Count, Child_Depth):
index 18a22bc0b695d04dbca02ce690bfefb381e51bb0..98f142ec628d16792e609fd29802e7b20e73a69d 100644 (file)
@@ -94,7 +94,11 @@ ada: gnat1$(exeext) gnatbind$(exeext)
 
 # There are too many Ada sources to check against here.  Let's
 # always force the recursive make.
-ADA_TOOLS_FLAGS_TO_PASS=\
+ifeq ($(build), $(host))
+  ifeq ($(host), $(target))
+    # This is a regular native. So use the compiler from our current build
+    # tree.
+    ADA_TOOLS_FLAGS_TO_PASS=\
         "CC=../../xgcc -B../../"       \
         "CFLAGS=$(CFLAGS)"             \
        "exeext=$(exeext)"              \
@@ -103,6 +107,58 @@ ADA_TOOLS_FLAGS_TO_PASS=\
        "GNATMAKE=../../gnatmake"       \
        "GNATLINK=../../gnatlink"       \
        "GNATBIND=../../gnatbind"
+  else
+    # This is a regular cross compiler. Use the native compiler to compile
+    # the tools.
+
+    # put the host RTS dir first in the PATH to hide the default runtime
+    # files that are among the sources
+    RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib )))
+
+    ADA_TOOLS_FLAGS_TO_PASS=\
+        CC="$(CC)" \
+        $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
+        ADA_INCLUDES="-I$(RTS_DIR)../adainclude -I$(RTS_DIR)" \
+        GNATMAKE="gnatmake" \
+        GNATBIND="gnatbind" \
+        GNATLINK="gnatlink" \
+        LIBGNAT=""
+  endif
+else
+  # Build is different from host so we are either building a canadian cross
+  # or a cross-native compiler. We provide defaults for tools targeting the
+  # host platform, but they can be overriden by just setting <tool>_FOR_HOST
+  # variables. 
+  GNATMAKE_FOR_HOST=$(host)-gnatmake
+  GNATBIND_FOR_HOST=$(host)-gnatbind
+  GNATLINK_FOR_HOST=$(host)-gnatlink
+  GNATLS_FOR_HOST=$(host)-gnatls
+
+  ifeq ($(host), $(target))
+    # This is a cross native. All the sources are taken from the currently
+    # built runtime.
+    ADA_TOOLS_FLAGS_TO_PASS=\
+        CC="$(CC)" \
+        $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS)  \
+        ADA_INCLUDES="-I../rts"                \
+        GNATMAKE="$(GNATMAKE_FOR_HOST)"      \
+        GNATBIND="$(GNATBIND_FOR_HOST)"      \
+        GNATLINK="$(GNATLINK_FOR_HOST)"      \
+        LIBGNAT=""
+  else
+    # This is a canadian cross. We should use a toolchain running on the
+    # build platform and targeting the host platform.
+    RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))
+    ADA_TOOLS_FLAGS_TO_PASS=\
+        CC="$(CC)" \
+        $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS)  \
+        ADA_INCLUDES="-I$(RTS_DIR)../adainclude -I$(RTS_DIR)" \
+        GNATMAKE="$(GNATMAKE_FOR_HOST)"      \
+        GNATBIND="$(GNATBIND_FOR_HOST)"      \
+        GNATLINK="$(GNATLINK_FOR_HOST)"      \
+        LIBGNAT=""
+  endif
+endif
 
 GCC_LINK=$(LINKER) $(ALL_LINKERFLAGS) -static-libgcc $(LDFLAGS)
 
index 1e7a392edf48caa47031952a22ea4089329fa7c6..f877417b7004248c2bd16ab8e80fdd7080110929 100644 (file)
@@ -2488,13 +2488,15 @@ gnatlib-shared-default:
             THREAD_KIND="$(THREAD_KIND)" \
              gnatlib
        $(RM) $(RTSDIR)/libgna*$(soext)
-       cd $(RTSDIR); ../../xgcc -B../../ -shared $(GNATLIBCFLAGS) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
                $(TARGET_LIBGCC2_CFLAGS) \
                -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) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
                $(TARGET_LIBGCC2_CFLAGS) \
                -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_TASKING_OBJS) \
@@ -2556,12 +2558,14 @@ gnatlib-shared-win32:
             THREAD_KIND="$(THREAD_KIND)" \
              gnatlib
        $(RM) $(RTSDIR)/libgna*$(soext)
-       cd $(RTSDIR); ../../xgcc -B../../ -shared -shared-libgcc \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \
                $(TARGET_LIBGCC2_CFLAGS) \
                -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 \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \
                $(TARGET_LIBGCC2_CFLAGS) \
                -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_TASKING_OBJS) \
@@ -2577,13 +2581,15 @@ gnatlib-shared-darwin:
             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 $(TARGET_LIBGCC2_CFLAGS) \
                -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) \
+       cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
+                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(TARGET_LIBGCC2_CFLAGS) \
                -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
                $(GNATRTL_TASKING_OBJS) \
                $(SO_OPTS) \