]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
* m4/depend.m4 (AM_DEPENDENCIES): Test for depcc -E support.
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Sun, 25 Apr 1999 20:47:27 +0000 (20:47 +0000)
committerAlexandre Oliva <oliva@dcc.unicamp.br>
Sun, 25 Apr 1999 20:47:27 +0000 (20:47 +0000)
* depcomp (cpp): Extract dependencies from `# nnn "..."' lines.

ChangeLog
depcomp
m4/depend.m4

index 63f5cb80d7ff6c2855ffac11cc738fd387bb4d4a..249a8ebf2cbebed531e7dd598c44d713f61cb2a1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1999-04-26  Alexandre Oliva  <oliva@dcc.unicamp.br>
+
+       * m4/depend.m4 (AM_DEPENDENCIES): Test for depcc -E support.
+       * depcomp (cpp): Extract dependencies from `# nnn "..."' lines.
+
 1999-04-25  Alexandre Oliva  <oliva@dcc.unicamp.br>
 
        * m4/depend.m4 (AM_DEPENDENCIES): Add a definition to conftest.h,
diff --git a/depcomp b/depcomp
index c27b5f36f3929b92a4bece516d3119ff691de9ca..694ec3ce1b1ff2257d9e442e6206c2b56983ea1c 100755 (executable)
--- a/depcomp
+++ b/depcomp
@@ -68,6 +68,9 @@ sgi)
   ;;
 
 dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
   ( IFS=" "
     case " $* " in
     *" --mode=compile "*) # this is libtool, let us make it quiet
@@ -80,18 +83,21 @@ dashmstdout)
          shift # fnord
          ;;
        esac
-       set fnord "$@" "$1"
+       set fnord "$@" "$arg"
        shift # fnord
-       shift # "$1"
+       shift # "$arg"
       done
       ;;
     esac
-    "$@" -M | sed 's:^[^:]*\:[         ]*:'"$object"'\: :' > "$tmpdepfile") &
+    "$@" -M | sed 's:^[^:]*\:[         ]*:'"$object"'\: :' > "$tmpdepfile"
+  ) &
   proc=$!
   "$@"
-  rm -f "$depfile" 
+  stat=$?
   wait "$proc"
-  cat < "$tmpdepfile" >> "$depfile"
+  if test "$stat" != 0; then exit $stat; fi
+  rm -f "$depfile" 
+  cat < "$tmpdepfile" > "$depfile"
   tr ' ' '
 ' < "$tmpdepfile" | \
     sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' -e 's/$/ :/' >> "$depfile"
@@ -99,11 +105,39 @@ dashmstdout)
   ;;
 
 cpp)
-  # We want a pre compilation step which runs CPP (but with all
-  # the right options!  This is hard).  Then we want to run sed
-  # on the output, extract `#line' or `# NNN' lines, and turn
-  # that into correct dependencies.  We might as well do this
-  # all in one step, so we have no post-compilation step here.
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  ( IFS=" "
+    case " $* " in
+    *" --mode=compile "*)
+      for arg
+      do # cycle over the arguments
+        case "$arg" in
+       "--mode=compile")
+         # insert --quiet before "--mode=compile"
+         set fnord "$@" --quiet
+         shift # fnord
+         ;;
+       esac
+       set fnord "$@" "$arg"
+       shift # fnord
+       shift # "$arg"
+      done
+      ;;
+    esac
+    "$@" -E |
+    sed -n '/^# [0-9][0-9]* "\([^"]*\)"/ s::'"$object"'\: \1:p' > "$tmpdepfile"
+  ) &
+  proc=$!
+  "$@"
+  stat=$?
+  wait "$proc"
+  if test "$stat" != 0; then exit $stat; fi
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed < "$tmpdepfile" -e 's/^[^:]*: //' -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
   ;;
 
 none)
index bb26635a0227fc5912049b1e7e43e6c0ca1b413f..f69ee5bdfeddfefd299272012b47baa07df800e1 100644 (file)
@@ -51,6 +51,14 @@ else
       fi
    fi
 
+   if test "$am_cv_[$1]_dependencies_compiler_type" = none; then
+      # -o /dev/null avoids selecting -E for a compiler that would
+      # output dependencies to the object file
+      if test -n "`$depcc -E conftest.c -o /dev/null 2>/dev/null`"; then
+        am_cv_[$1]_dependencies_compiler_type=cpp
+      fi
+   fi
+
    dnl As a last resort, see if we can run CPP and extract line
    dnl information from the output.
    dnl FIXME