RT3856: Fix memory leaks in test code
[openssl.git] / util / domd
index 9f75131f221ea3b8334269878a81f83a8de5442f..552a352e3a84bea33ffd88b05f1dceb032760b4f 100755 (executable)
--- a/util/domd
+++ b/util/domd
@@ -4,8 +4,31 @@
 
 TOP=$1
 shift
+if [ "$1" = "-MD" ]; then
+    shift
+    MAKEDEPEND=$1
+    shift
+fi
+if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi
 
-cp Makefile.ssl Makefile.save
-makedepend -f Makefile.ssl $@
-perl $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new
-mv Makefile.new Makefile.ssl
+cp Makefile Makefile.save
+if expr "$MAKEDEPEND" : '.*cc' > /dev/null; then
+    args=""
+    while [ $# -gt 0 ]; do
+       if [ "$1" != "--" ]; then args="$args $1"; fi
+       shift
+    done
+    sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp
+    echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp
+    ${MAKEDEPEND} -Werror -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp || exit 1
+    ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
+    RC=$?
+    rm -f Makefile.tmp
+else
+    ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND $@ && \
+    ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new
+    RC=$?
+fi
+mv Makefile.new Makefile
+
+exit $RC