* m4/depend.m4: Grep depcomp's stderr for icc warnings about
authorAlexandre Duret-Lutz <adl@gnu.org>
Tue, 11 Feb 2003 18:20:55 +0000 (18:20 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Tue, 11 Feb 2003 18:20:55 +0000 (18:20 +0000)
ignored options.
* lib/depcomp (icc): New mode.
* tests/depcomp5.test: New file.
* tests/defs.in: Handle required=icc.
* tests/Makefile.am (TESTS): Add it.

ChangeLog
lib/depcomp
m4/depend.m4
tests/Makefile.am
tests/Makefile.in
tests/defs.in
tests/depcomp5.test [new file with mode: 0755]

index bfb3d82..0f2592e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2003-02-11  Alexandre Duret-Lutz  <adl@gnu.org>
 
+       * m4/depend.m4: Grep depcomp's stderr for icc warnings about
+       ignored options.
+       * lib/depcomp (icc): New mode.
+       * tests/depcomp5.test: New file.
+       * tests/defs.in: Handle required=icc.
+       * tests/Makefile.am (TESTS): Add it.
+
        Temporary hack for PR automake/381:
        * automake.in (handle_gettext): Turn missing po/ and intl/ errors
        into -Wsyntax warnings.
index 46d3553..c90ff92 100755 (executable)
@@ -206,6 +206,35 @@ aix)
   rm -f "$tmpdepfile"
   ;;
 
+icc) # Must come before tru64.
+
+  # Intel's C compiler understands `-MD -MF file'.  However
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
 tru64)
    # The Tru64 compiler uses -MD to generate dependencies as a side
    # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
index 4d6ff22..d0b24dc 100644 (file)
@@ -92,11 +92,17 @@ AC_CACHE_CHECK([dependency style of $depcc],
     if depmode=$depmode \
        source=conftest.c object=conftest.o \
        depfile=conftest.Po tmpdepfile=conftest.TPo \
-       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c >/dev/null 2>&1 &&
+       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c \
+         >/dev/null 2>conftest.err &&
        grep conftest.h conftest.Po > /dev/null 2>&1 &&
        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      am_cv_$1_dependencies_compiler_type=$depmode
-      break
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored.
+      if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
     fi
   done
 
index ef74813..f0f653f 100644 (file)
@@ -139,6 +139,7 @@ depcomp.test \
 depcomp2.test \
 depcomp3.test \
 depcomp4.test \
+depcomp5.test \
 depdist.test \
 depend.test \
 depend2.test \
index c57331e..02adff9 100644 (file)
@@ -233,6 +233,7 @@ depcomp.test \
 depcomp2.test \
 depcomp3.test \
 depcomp4.test \
+depcomp5.test \
 depdist.test \
 depend.test \
 depend2.test \
index 93bc32e..5e6669d 100644 (file)
@@ -92,6 +92,16 @@ then
        echo "$me: running $CXX --version"
        ( $CXX --version ) || exit 77
        ;;
+      icc)
+        CC=icc
+       export CC
+       # There is no way to ask *only* the compiler's version.
+       # This tool always want to do something (by default
+       # it will try link *nothing* and complain it cannot find
+       # main(); funny).  -dryrun is a workaround.
+       echo "$me: running $CC -V -dryrun"
+       ( $CC -V -dryrun ) || exit 77
+       ;;
       non-root)
        # Skip this test case if the user is root.
        # We try to append to a read-only file to detect this.
diff --git a/tests/depcomp5.test b/tests/depcomp5.test
new file mode 100755 (executable)
index 0000000..02e614b
--- /dev/null
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check icc's dependency mode.
+
+required='icc'
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+check_PROGRAMS = prg
+prg_SOURCES = src/sub.c src/foo.h
+
+grepdeps:
+       grep 'src/sub.$(OBJEXT).*:' src/$(DEPDIR)/sub.Po
+
+END
+
+mkdir src
+
+touch src/foo.h
+
+cat >src/sub.c <<EOF
+#include "foo.h"
+int
+main ()
+{
+   return 0;
+}
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+grep 'depmode=icc' Makefile
+$MAKE check
+$MAKE grepdeps