Generate all project dependencies in a single file using gcc -MM flag
Posted
by Jabez
on Stack Overflow
See other posts from Stack Overflow
or by Jabez
Published on 2009-12-30T18:08:01Z
Indexed on
2010/04/09
4:33 UTC
Read the original article
Hit count: 311
Hi all,
I want to generate a single dependency file which consists of all the dependencies of source files using gcc -M flags through Makefile. I googled for this solution but, all the solutions mentioned are for generating multiple deps files for multiple objects.
DEPS = make.dep
$(OBJS): $(SOURCES)
@$(CC) -MM $(SOURCEs) > $(DEPS)
@mv -f $(DEPS) $(DEPS).tmp
@sed -e 's|.$@:|$@:|' < $(DEPS).tmp > $(DEPS)
@sed -e 's/.*://' -e 's/\\$$//' < $(DEPS).tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(DEPS)
@rm -f $(DEPS).tmp
But it is not working properly. Please tell me where i'm making the mistake.
© Stack Overflow or respective owner