For what it's worth, I found the following utility at the QNX web site.
It seems to work a lot better than makedepend from X.  I'm also including
the modified depcomp needed to use mkdep.

### begin mkdep ###


#! /bin/ksh
#ifdef __USAGE
#%C - build a dependency table for the make utility.
#
#%C [options] file [file ...]
#
#Options:
# -a           Append to the dependencies file.
# -f <file>    Specify the name of the dependencies file (Default: .depend).
# -h           Show usage.
# -p           Don't append .o suffix to target file names.
# -u           Build standard /usr/include files into dependencies.
# -I <path>    Specify an additional include path.
# -D <sym=txt> Define a symbol.
#endif

# Get my name and setup a unique tmp file.

me=${0##*/}
tmp=$TMPDIR/$me.$NODE.$$

# Signal handler

trapper ()
{
  echo "$me: interrupted by user, exiting." >&2

  rm -f $tmp $tmp.?
  exit 1
}

# Print usage message and exit

print_usage ()
{
        echo; echo
        use $1
        exit 1
}

# Process any command line options

typeset -i aflag=0 pflag=0 uflag=0

outfile=""
suffix=".o"

# Set the C preprocessor to use, and any default options.

cpp="cc -E"
options=""

while getopts ":ahf:puD:I:" opt $*
do
        case $opt in
                a)  aflag=1 ;;
                f)  outfile=$OPTARG ;;
        h)  print_usage $0 ;;
                p)  suffix="" ;;
                u)  uflag=1 ;;
                D)  options="$options -D$OPTARG" ;;
                I)  options="$options -I$OPTARG" ;;
           \?)  print_usage $0 ;;
        esac
done

# If an output filename was not specified we use .depend for standard
# make dependencies and .dependfull for the full cross-reference table .

if test "$outfile" = ""
then
        outfile=".depend"
fi

# Use the .o suffix for standard make dependencies and use the .c suffix
# for the full cross-reference table.

# Shift options out of command line

let i=OPTIND-1
shift $i
                
# Trap to signal handler

trap trapper INT QUIT

# Make dependencies for a file.
#
# mkdep file

mkdep ()
{
# Preprocess the file, grep for #line directives, use sed to strip
# the #line directives down to a simple path and file name, use sort -u
# to remove duplicate file names, store the output in the tmp file.

        $cpp $options $1 |grep "#line" | \
    sed -e "s/^ *.*#line [0123456789]* \"//" -e "s/\"[  ]*.*$//" | \
    sort -u >$tmp.a

# Remove standard /usr/include files unless specified.

        if test $uflag -eq 0
        then
                grep -v /usr/include $tmp.a >$tmp.b
        else
                mv $tmp.a $tmp.b
        fi

# Remove reference to current file.
        grep -v $1 $tmp.b >$tmp.c

    case $1 in
                *.cpp)          target=${1%.cpp}$suffix;;
                *.cc)           target=${1%.cc}$suffix;;
                *.[cC])         target=${1%.[cC]}$suffix;;
                *)
        esac

# Massage the info into standard make dependency notation.

        echo $target': \\'
        for f in $(<$tmp.c)
        do
                echo "\t$f"' \\'
        done

# Add reference to current file.
        echo "\t./$1"
        echo
}

# Remove output file if not in append mode.

if test $aflag -ne 1
then
        if test -f $outfile
        then
                rm -f $outfile
        fi
        echo "###" >> $outfile
        echo "# Begin dependencies " >> $outfile
        echo >> $outfile
fi

# Make dependencies for each file.

for f in $*
do
        mkdep $f >> $outfile
done

# Remove tmp files and exit.

rm -f $tmp $tmp.?

exit 0

### end mkdep ###

### begin modified depcomp ###


#! /bin/sh

# depcomp - compile a program generating dependencies as side-effects
# Copyright (C) 1999 Free Software Foundation, Inc.

# This program 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.

# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

# Originally written by Alexandre Oliva <[EMAIL PROTECTED]>.

if test -z "$depmode" || test -z "$source" || test -z "$object"; then
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
  exit 1
fi
# `libtool' can also be set to `yes' or `no'.

depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}

rm -f "$tmpdepfile"

# Some modes work just like other modes, but use different flags.  We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write.  Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
  # HP compiler uses -M and no extra arg.
  gccflag=-M
  depmode=gcc
fi

if test "$depmode" = dashXmstdout; then
   # This is just like dashmstdout with a different argument.
   dashmflag=-xM
   depmode=dashmstdout
fi

case "$depmode" in
gcc)
## There are various ways to get dependency output from gcc.  Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
##   up in a subdir.  Having to rename by hand is ugly.
##   (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
##   -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
##   than renaming).
  if test -z "$gccflag"; then
    gccflag=-MD,
  fi
  if "$@" -Wp,"$gccflag$tmpdepfile"; then :
  else
    stat=$?
    rm -f "$tmpdepfile"
    exit $stat
  fi
  rm -f "$depfile" 
  echo "$object : \\" > "$depfile"
  sed 's/^[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header).  We avoid this by adding
## dummy dependencies for each header file.  Too bad gcc doesn't do
## this for us directly.
  tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'.  On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly.  Breaking it into two sed invocations is a workaround.
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

hp)
  # 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
  ;;

dashmd)
  # The Java front end to gcc doesn't run cpp, so we can't use the -Wp
  # trick.  Instead we must use -M and then rename the resulting .d
  # file.  This is also the case for older versions of gcc, which
  # don't implement -Wp.
  if "$@" -MD; then :
  else
    stat=$?
    rm -f FIXME
    exit $stat
  fi
  FIXME: rewrite the file
  ;;

sgi)
  if test "$libtool" = yes; then
    "$@" "-Wp,-MDupdate,$tmpdepfile"
  else
    "$@" -MDupdate "$tmpdepfile"
  fi
  stat=$?
  if test $stat -eq 0; then :
  else
    stat=$?
    rm -f "$tmpdepfile"
    exit $stat
  fi
  rm -f "$depfile" 
  echo "$object : \\" > "$depfile"

  # Clip off the initial element (the dependent). Don't try to be
  # clever and remove the tr invocations, as IRIX sed won't handle
  # lines with more than 8192 characters.
  tr ' ' '
' < "$tmpdepfile" | sed 's/^[^\.]*\.o://' | tr '
' ' ' >> $depfile

  tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly.  Breaking it into two sed invocations is a workaround.
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

#nosideeffect)
  # This comment above is used by automake to tell side-effect
  # dependency tracking mechanisms from slower ones.

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.
  test -z "$dashmflag" && dashmflag=-M
  ( IFS=" "
    case " $* " in
    *" --mode=compile "*) # this is libtool, let us make it quiet
      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
    "$@" $dashmflag | sed 's:^[^:]*\:[  ]*:'"$object"'\: :' > "$tmpdepfile"
  ) &
  proc=$!
  "$@"
  stat=$?
  wait "$proc"
  if test "$stat" != 0; then exit $stat; fi
  rm -f "$depfile" 
  cat < "$tmpdepfile" > "$depfile"
  tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly.  Breaking it into two sed invocations is a workaround.
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

dashXmstdout)
  # This case only exists to satisfy depend.m4.  It is never actually
  # run, as this mode is specially recognized in the preamble.
  exit 1
  ;;

mkdep)
  # mkdep from QNX
  (
        MKDEP="/usr/local/bin/mkdep -u"
    shift
    cleared=no
    for arg in "$@"; do
      case $cleared in no)
        set ""; shift
        cleared=yes
      esac
      case "$arg" in
        -D*|-I*)
          set fnord "$@" "$arg"; shift;;
        -*)
          ;;
        *.o)    # removes *.o arguments...
          set fnord "$@"; shift;;
        *)
          set fnord "$@" "$arg"; shift;;
      esac
    done
    obj_suffix="`echo $object | sed 's/^.*\././'`"
    touch "$tmpdepfile"
    ${MKDEP} 2>/dev/null -f"$tmpdepfile" "$@"
  ) &
  proc=$!
  "$@"
  stat=$?
  wait "$proc"
  if test "$stat" != 0; then exit $stat; fi
  rm -f "$depfile" 
  cat < "$tmpdepfile" > "$depfile"
  rm -f "$tmpdepfile" "$tmpdepfile".bak
  ;;

makedepend)
  # X makedepend
  (
    shift
    cleared=no
    for arg in "$@"; do
      case $cleared in no)
        set ""; shift
        cleared=yes
      esac
      case "$arg" in
        -D*|-I*)
          set fnord "$@" "$arg"; shift;;
        -*)
          ;;
        *)
          set fnord "$@" "$arg"; shift;;
      esac
    done
    obj_suffix="`echo $object | sed 's/^.*\././'`"
    touch "$tmpdepfile"
    ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
  ) &
  proc=$!
  "$@"
  stat=$?
  wait "$proc"
  if test "$stat" != 0; then exit $stat; fi
  rm -f "$depfile" 
  cat < "$tmpdepfile" > "$depfile"
  tail +3 "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly.  Breaking it into two sed invocations is a workaround.
    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile" "$tmpdepfile".bak
  ;;

cpp)
  # 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)
  exec "$@"
  ;;

*)
  echo "Unknown depmode $depmode" 1>&2
  exit 1
  ;;
esac

exit 0

### end modified depcomp ###

Jiann-Ming Su, [EMAIL PROTECTED]
Criminals, by definition, break the law...

Reply via email to