I am learning GNU make recently. The following is the example of auto-dependency generation from the GNU make manual. I know the general meaning the above script (it's basically replacing something with something else with the sed command). But I have two questions with respect to the details in the command. First, what does the \1.o mean in the command? Is it related to position parameter? And second, why $* is put into a pair of () since $* itself already means the stem of the target filename? (I tried to without the parenthesis, it didn't work.)
%.d: %.c
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
I tried the following, it didn't work.
%.d: %.c
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,$*\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
Can anyone explain the reasons behind? Thanks.