Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8880>

Hi Dave, Jeff.

On 02/25/2012 03:22 AM, Dave Goodell wrote:
> Portland Group C Compiler support based on a code from Jeff Daily @ PNNL
> via the automake list and automake bug #8880:
> 
> [SNIP]
>
The paperwork issues have been finally sorted out (about time!), so I've
committed your diff (see attached patch for the full commit) and pushed
it to a public branch 'depcomp-pgcc'.  In the next hours or days, I intend
to follow up with some style and consistency changes, and maybe some further
refactoring to the depcomp scripts.  In case you are interested in helping
out with more QA, you can start testing the new branch with the Portland
compilers (which I lack access to).

Thanks,
  Stefano
>From 32eed29a7171549080a91514374cff7341d9c08e Mon Sep 17 00:00:00 2001
Message-Id: <32eed29a7171549080a91514374cff7341d9c08e.1342121162.git.stefano.lattar...@gmail.com>
From: Dave Goodell <good...@mcs.anl.gov>
Date: Thu, 12 Jul 2012 21:25:46 +0200
Subject: [PATCH] depcomp: initial support for Portland Group Compilers

* lib/depcomp: Here.  See automake bug#8880.

Co-authored-by: Jeff A. Daily <jeff.da...@pnnl.gov>
Acked-by: Stefano Lattarini <stefano.lattar...@gmail.com>
Signed-off-by: Stefano Lattarini <stefano.lattar...@gmail.com>
---
 lib/depcomp |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/lib/depcomp b/lib/depcomp
index debb6ff..8619fcb 100755
--- a/lib/depcomp
+++ b/lib/depcomp
@@ -1,7 +1,7 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2012-03-27.16; # UTC
+scriptversion=2012-07-12.20; # UTC
 
 # Copyright (C) 1999-2012 Free Software Foundation, Inc.
 
@@ -334,6 +334,80 @@ icc)
   rm -f "$tmpdepfile"
   ;;
 
+## The order of this option in the case statement is important, since the
+## shell code in configure will try each of these formats in the order
+## listed in this file.  A plain `-MD' option would be understood by many
+## compilers, so we must ensure this comes after the gcc and icc options.
+pgcc)
+  # Portland's C compiler understands `-MD'.
+  # Will always output deps to `file.d' where file is the root name of the
+  # source file under compilation, even if file resides in a subdirectory.
+  # The object file name does not affect the name of the ".d" file.
+  # pgcc 10.2 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  ##base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  # use the source, not the object to determine the base name, since that's
+  # sadly what pgcc will do too
+  base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'`
+  tmpdepfile="$base.d"
+
+  # For projects that build the same source file twice into different object
+  # files, the pgcc approach of using the *source* file root name can cause
+  # problems in parallel builds.  Use a locking strategy to avoid stomping on
+  # the same $tmpdepfile.
+  lockdir="$base.d-lock"
+  trap "echo '$0: caught signal, cleaning up...' ; rm -rf $lockdir" 1 2 13 15
+  numtries=100
+  i=$numtries
+  while test $i -gt 0 ; do
+    # mkdir is a portable test-and-set
+    if mkdir $lockdir 2>/dev/null; then
+      # this process acquired the lock
+      "$@" -MD
+      stat=$?
+      # release the lock
+      rm -rf $lockdir
+      break
+    else
+      ## the lock is being held by a different process,
+      ## wait until the winning process is done or we timeout
+      while test -d $lockdir && test $i -gt 0 ; do
+        sleep 1;
+        i=`expr $i - 1`
+      done
+    fi
+    i=`expr $i - 1`
+  done
+  trap - 1 2 13 15
+  if test $i -le 0 ; then
+    echo "$0 ERROR: failed to acquire lock after $numtries attempts, check lockdir '$lockdir'"
+    exit 1;
+  fi
+
+  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',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
 hp2)
   # The "hp" stanza above does not work with aCC (C++) and HP's ia64
   # compilers, which have integrated preprocessors.  The correct option
-- 
1.7.9.5

Reply via email to