about summary refs log blame commit diff
path: root/make/lib/find-includes.sh
blob: 4824207c29175464198aa5a99bdf9eee68c1a2a1 (plain) (tree)



















                                                                         
. $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