automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make depmode=cpp work with Microsoft Visual C++ on MSYS.


From: Peter Rosin
Subject: Re: Make depmode=cpp work with Microsoft Visual C++ on MSYS.
Date: Wed, 28 Jan 2009 12:57:43 +0100
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

Den 2009-01-28 09:12, skrev Ralf Wildenhues:
Hi Peter,

* Peter Rosin wrote on Tue, Jan 27, 2009 at 02:32:01AM CET:
When using MSVC on MSYS, there is nothing that prevents depmode=cpp
from being used. It works fine. depmode=msvisualcpp doesn't work
as it assumes that cygpath can be used.

Thanks for the report and patch.  What if the user uses any of these
flags (treated specially in msvisualcpp mode)?
  "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI"

Good point, I honestly don't know, let's not go there though...

If they are passed in $CC or $CFLAGS at configure time, I guess then
_AM_DEPENDENCIES will detect cpp depmode as non-working and try out
msvisualcpp depmode.  If however these flags are only used later in
the build process, then the cpp depmode could fall on its head, no?
More generally, I fear that the quirks worked around by msvisualcpp
depmode may show up in other corner cases, too.

Since you're really only trying to avoid the cygpath issue, how about a
different approach: let's make two depmodes, one for MSVC on Cygwin,
one for MSVC with MinGW.  The only real difference between them should
be the path translation used inside depcomp, and the _AM_DEPENDENCIES
test could be enhanced to find out the right one at configure time.
This means one more depmode to test at configure time, but essentially
no additional slowdown at build time.

(See at the beginning of depcomp, "Some modes work just like other
modes", for how this could be done without duplicating too much code
there.)

Considering all of the above, how about the attached patch instead? (I
consider it tiny. Even if it touches a few more lines the changes are
trivial, much of it is copy-paste...)

It would be great to see how the Automake test suite fares with this
compiler (see tests/README for how to enable verbose output), esp.
the depcomp*.test tests.

Sorry, but I get this

configure: error: Autoconf 2.61a-341 or better is required.

and I have plain old 2.61. I'm not too keen on building autoconf and
possibly muddy up my install...

But if you are looking for bugs to squash, one obvious problem is
that the standard
AC_PROG_CC
AM_PROG_CC_C_O
puts the dependency check before the -c -o check, which forces losers
like me to configure CC=".../path/to/compile cl" for the dependency
checker to work (as it compiles in subdirs with -c -o). Can some m4
magic be applied so that the dependency check is moved down or the
-c -o check moved up, that would be much appreciated!

Cheers,
Peter
diff --git a/ChangeLog b/ChangeLog
index 2463967..a859bbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-01-28  Peter Rosin  <address@hidden>
+
+       Add depmode=msvcmsys for Microsoft Visual C++ on MSYS.
+       * lib/depcomp: Add depmode=msvcmsys as a derivative of
+       depmode=msvisualcpp. msvcmsys uses echo instead of "cygpath -u"
+       to prevent any path translation.
+       Also transform any backslashes into forward slashes to make the
+       grep in depend.m4 match.
+
 2009-01-23  Eric Blake  <address@hidden>
 
        Use no-arg macros via AC_REQUIRE for consistency.
diff --git a/lib/depcomp b/lib/depcomp
index 0f2bf43..f3364f3 100755
--- a/lib/depcomp
+++ b/lib/depcomp
@@ -1,7 +1,7 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2007-03-29.01
+scriptversion=2009-01-28.01
 
 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
 # Foundation, Inc.
@@ -85,6 +85,13 @@ if test "$depmode" = dashXmstdout; then
    depmode=dashmstdout
 fi
 
+cygpath_u="cygpath -u"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   cygpath_u=echo
+   depmode=msvisualcpp
+fi
+
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
@@ -556,15 +563,22 @@ msvisualcpp)
     esac
   done
   "$@" -E |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' 
| sort | uniq > "$tmpdepfile"
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`$cygpath_u \\"\1\\"`":p' 
| sort | uniq > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> 
"$depfile"
+  . "$tmpdepfile" | sed -e 's%\\%/%g' -e 's% %\\ %g' | sed -n '/^\(.*\)$/ s::  
\1 \\:p' >> "$depfile"
   echo "       " >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> 
"$depfile"
+  . "$tmpdepfile" | sed -e 's%\\%/%g' -e 's% %\\ %g' | sed -n '/^\(.*\)$/ 
s::\1\::p' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 none)
   exec "$@"
   ;;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]