1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 22:42:41 +01:00
nix/lib/find-includes.sh
Eelco Dolstra 7d386d5c29 * Automatically determine header file dependencies using the
`findIncludes' function.  The current implementation is impure and
  therefore not correct: it gathers header file dependencies only once
  for a specific path (due to caching).
2004-07-06 16:05:28 +00:00

20 lines
427 B
Bash

. $stdenv/setup
echo "finding includes of \`$(basename $main)'..."
makefile=$NIX_BUILD_TOP/makefile
mainDir=$(dirname $main)
(cd $mainDir && gcc -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