domd revision 325335
155714Skris#!/bin/sh
255714Skris# Do a makedepend, only leave out the standard headers
355714Skris# Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
455714Skris
555714SkrisTOP=$1
655714Skrisshift
7109998Smarkmif [ "$1" = "-MD" ]; then
8109998Smarkm    shift
9109998Smarkm    MAKEDEPEND=$1
10109998Smarkm    shift
11109998Smarkmfi
12109998Smarkmif [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi
1355714Skris
14312826Sjkim# Preserve Makefile timestamp by moving instead of copying (cp -p is GNU only)
15312826Sjkimmv Makefile Makefile.save
16312826Sjkimcp Makefile.save Makefile
17109998Smarkm# fake the presence of Kerberos
18109998Smarkmtouch $TOP/krb5.h
19295009Sjkimif ${MAKEDEPEND} --version 2>&1 | grep "clang" > /dev/null ||
20295009Sjkim   echo $MAKEDEPEND | grep "gcc" > /dev/null; then
21109998Smarkm    args=""
22109998Smarkm    while [ $# -gt 0 ]; do
23109998Smarkm	if [ "$1" != "--" ]; then args="$args $1"; fi
24109998Smarkm	shift
25109998Smarkm    done
26142425Snectar    sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp
27109998Smarkm    echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp
28238405Sjkim    ${MAKEDEPEND} -Werror -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp || exit 1
29109998Smarkm    ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
30238405Sjkim    RC=$?
31109998Smarkm    rm -f Makefile.tmp
32109998Smarkmelse
33238405Sjkim    ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND $@ && \
34142425Snectar    ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new
35238405Sjkim    RC=$?
36109998Smarkmfi
37325335Sjkimif cmp -s Makefile.save Makefile.new; then
38312826Sjkim    mv Makefile.save Makefile
39312826Sjkim    rm -f Makefile.new
40325335Sjkimelse
41325335Sjkim    mv Makefile.new Makefile
42312826Sjkimfi
43109998Smarkm# unfake the presence of Kerberos
44109998Smarkmrm $TOP/krb5.h
45238405Sjkim
46238405Sjkimexit $RC
47