I am new to makefiles and trying to understand some code:
$(CC) $^ -c -Wall
$(CC) -MM $*.c > $*.dep
$(OBJECTDUMP) -d -M intel -S $@
@mv -f $*.dep $*.dep.tmp
@sed -e 's|.*:|$*.o:|' < $*.dep.tmp > $*.dep
@sed -e 's/.*://' -e 's/\\$$//' < $*.dep.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.dep
@rm -f $*.dep.tmp
$* corresponds roughly to the
% in the first line.
@mvline moves the old
@sedline edits what's in the
basename.dep.tmp, replacing anything up to a colon with
$*is expanded by
make, not the shell).
@sedline and the following line do some more editing — appending another variant of the
basename.dep.tmpfile to the end of
@rmline removes the temporary
A more thorough analysis of the second
sed sequence requires more detailed knowledge of what's in the
.dep file and exactly what
fmt -1 does for you.
However, it seems that the goal is to update the dependencies that apply to the source file, based on the information from the compiler plus massaging it in a way to suit the programmer. The why is not clear to me.