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
14142425Snectarcp Makefile Makefile.save
15109998Smarkm# fake the presence of Kerberos
16109998Smarkmtouch $TOP/krb5.h
17205128Ssimonif expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then
18109998Smarkm    args=""
19109998Smarkm    while [ $# -gt 0 ]; do
20109998Smarkm	if [ "$1" != "--" ]; then args="$args $1"; fi
21109998Smarkm	shift
22109998Smarkm    done
23142425Snectar    sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp
24109998Smarkm    echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp
25238405Sjkim    ${MAKEDEPEND} -Werror -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp || exit 1
26109998Smarkm    ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
27238405Sjkim    RC=$?
28109998Smarkm    rm -f Makefile.tmp
29109998Smarkmelse
30238405Sjkim    ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND $@ && \
31142425Snectar    ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new
32238405Sjkim    RC=$?
33109998Smarkmfi
34142425Snectarmv Makefile.new Makefile
35109998Smarkm# unfake the presence of Kerberos
36109998Smarkmrm $TOP/krb5.h
37238405Sjkim
38238405Sjkimexit $RC
39