makefile - how to make clean without any modification? -
i have makefile huge library, when modify files not want compile library , make clean
, @ first compile files clean. how can make clean without other modifications?
i have used
.phony: clean force
clean: force
rm *.o rm *.mod force:
i resolve problem using:
ifneq ($(makecmdgoals),clean)
-include $(objs:%.o=%.d)
endif
as zhertal says there's no way know sure without seeing definition of clean rule, @ least. there 2 possibilities this.
the first clean
target listing prerequisite causing rebuild. unlikely, i've seen people things before.
the second, , more likely, cause you're using method described in gnu make manual automatically generating prerequisites, add %.d
pattern %.o
pattern rule , -include
.d
files. problem here make try make sure makefile date first before running targets, , means trying rebuild included .d
files, means recompiling everything.
you have 2 options fix this. first put include
line inside conditional doesn't run if make clean
, this:
ifeq ($(filter clean,$(makecmdgoals)),) -include $(objs:%.o=%.d) endif
of course, have tweaked if have more clean-type rules (distclean
etc.)
the other rework way auto-generated makefiles use more modern, advanced method. can find description @ advanced auto-dependencies
Comments
Post a Comment