I've always meant to recreate the 'makemake' utility we used to use at Acorn - none of the current equivalents seem as good. These tools may come in useful: makedepend -Y *.c gcc -M file.c Since gcc -M lists math.h I might be able to use it to automatically add -lm ? e.g.: gcc -M matrixmath.c|&fgrep -q /usr/include/math.h && echo \-lm I'll get round to it eventually.