Make-lang.in: In the fallback mechanim...
authorNicolas Roche <roche@adacore.com>
Wed, 13 Sep 2017 13:18:46 +0000 (13:18 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Wed, 13 Sep 2017 13:18:46 +0000 (13:18 +0000)
2017-09-13  Nicolas Roche  <roche@adacore.com>

* Make-lang.in: In the fallback mechanim, parse the associated .ali
file and try to guess the locations of dependencies.

From-SVN: r252082

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

index 35ebd0c..468af07 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-13  Nicolas Roche  <roche@adacore.com>
+
+       * Make-lang.in: In the fallback mechanim, parse the associated .ali
+       file and try to guess the locations of dependencies.
+
 2017-09-13  Eric Botcazou  <ebotcazou@adacore.com>
 
        * sem_ch13.adb (Register_Address_Clause_Check): New procedure to save
index bbced49..113c84f 100644 (file)
@@ -106,14 +106,20 @@ ada/%.o: ada/gcc-interface/%.c
 
 # Function that dumps the dependencies of an Ada object. Dependency only work
 # fully if the compiler support -gnatd.n. Otherwise a fallback mechanism is
-# used. The fallback mechanism add dependency on all ada sources in the same
-# directory as the original source.
+# used. The fallback mechanism parse the ali files to get the list of
+# dependencies and try to guess their location. If the location cannot be found
+# then the dependency is ignored.
 ifeq ($(findstring -gnatd.n,$(ALL_ADAFLAGS)),)
 ADA_DEPS=\
    mkdir -p $(dir $@)/$(DEPDIR); \
    (o="$@: $<"; \
-    for d in $(dir $<)/*.ad[sb]; do \
-       o="$$o $$d"; \
+    a="`echo $@ | sed -e 's/.o$$/.ali/'`"; \
+    for d in `cat $$a | sed -ne 's;^D \([a-z0-9_\.-]*\).*;\1;gp'`; do \
+       for l in ada $(srcdir)/ada ada/libgnat $(srcdir)/ada/libgnat; do \
+          if test -f $$l/$$d; then \
+             o="$$o $$l/$$d"; \
+          fi; \
+       done; \
     done; \
     echo "$$o"; echo) \
     >$(dir $@)/$(DEPDIR)/$(patsubst %.o,%.Po,$(notdir $@))
@@ -121,11 +127,9 @@ ADA_OUTPUT_OPTION = $(OUTPUT_OPTION)
 else
 ADA_DEPS=\
    mkdir -p $(dir $@)/$(DEPDIR); \
-   (o="$@: $<"; \
-    for d in `cat $@.gnatd.n`; do \
-       o="$$o $$d"; \
-    done; \
-    echo "$$o"; echo) \
+   (echo "$@: $< " | tr -d '\015' | tr -d '\n'; \
+    cat $@.gnatd.n | tr -d '\015' | tr '\n' ' '; \
+    echo; echo) \
    >$(dir $@)/$(DEPDIR)/$(patsubst %.o,%.Po,$(notdir $@))
 ADA_OUTPUT_OPTION = $(OUTPUT_OPTION) > $@.gnatd.n
 endif
@@ -861,9 +865,11 @@ ada.uninstall:
 
 ada.mostlyclean:
        -$(RM) ada/*$(objext) ada/*.ali ada/b_gnat*.ads ada/b_gnat*.adb
+       -$(RM) ada/*$(objext).gnatd.n
        -$(RM) ada/*$(coverageexts)
        -$(RM) ada/sdefault.adb ada/stamp-sdefault ada/stamp-snames
        -$(RMDIR) ada/tools
+       -$(RMDIR) ada/libgnat
        -$(RM) gnatbind$(exeext) gnat1$(exeext)
 ada.clean:
 ada.distclean: