summaryrefslogtreecommitdiff
path: root/src/depend.sh
blob: b6084b1b503047c86b91f7db720627d1f40a5c36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
DIR="$1"
shift 1
case "$DIR" in
    "" | ".")
        gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@\1.d \1.o:@"
    ;;
    *)
        gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@$DIR/\1.d $DIR/\1.o:@"
    ;;
esac

# Shamelessly stolen from Peter Miller's "Recursive Make Considered Harmful"
    # https://web.archive.org/web/20250404190928/https://aegis.sourceforge.net/auug97.pdf