aboutsummaryrefslogtreecommitdiff
path: root/make/lib/find-includes.sh
blob: 4824207c29175464198aa5a99bdf9eee68c1a2a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
. $stdenv/setup

echo "finding includes of \`$(basename $main)'..."

makefile=$NIX_BUILD_TOP/makefile

mainDir=$(dirname $main)
(cd $mainDir && gcc $cFlags -MM $(basename $main) -MF $makefile) || false

echo "[" >$out

while read line; do
    line=$(echo "$line" | sed 's/.*://')
    for i in $line; do
        fullPath=$(readlink -f $mainDir/$i)
        echo "  [ $fullPath \"$i\" ]" >>$out
    done
done < $makefile

echo "]" >>$out