I include __TIME__ and __DATE__ strings in some files (main.c & commands.c) - I want these files to be recompiled everytime even if they
are not changed. I am using teh standard makefile structure. How can I do this?
I include __TIME__ and __DATE__ strings in some files (main.c & commands.c) - I want these files to be recompiled everytime even if they
are not changed. I am using teh standard makefile structure. How can I do this?
Hello,
I'm no makefile expert, but according to the stackoverflow thread linked below it seems like the most common approach is to create a new target named FORCE that is always run and then add this target as a dependency to the object files you want to rebuild every time.
https://stackoverflow.com/questions/7643838/how-to-force-make-to-always-rebuild-a-file
You may try to add the lines below to the end of your project Makefile.
$(OUTPUT_DIRECTORY)/${TARGETS}/main.c.o: FORCE
$(OUTPUT_DIRECTORY)/${TARGETS}/commands.c.o: FORCE
.PHONY: FORCE
FORCE:
Best regards,
Vidar
Hi Vidar - thanks, that works! And ChatGPT helped me modify this as follows:
# Add files here that need to be recompiled every time, e.g. because they contain __TIME__ and __DATE__
FILES_TO_FORCE_REBUILD := main ble_commands
# Force recompilation of any files in the last that contain __TIME__ and __DATE__
# Generate rules for each file in FILES_TO_FORCE_REBUILD list:
$(foreach file, $(FILES_TO_FORCE_REBUILD), \
$(eval $(OUTPUT_DIRECTORY)/${TARGETS}/$(file).c.o: FORCE) \
)
.PHONY: FORCE
FORCE:Hi Vidar - thanks, that works! And ChatGPT helped me modify this as follows:
# Add files here that need to be recompiled every time, e.g. because they contain __TIME__ and __DATE__
FILES_TO_FORCE_REBUILD := main ble_commands
# Force recompilation of any files in the last that contain __TIME__ and __DATE__
# Generate rules for each file in FILES_TO_FORCE_REBUILD list:
$(foreach file, $(FILES_TO_FORCE_REBUILD), \
$(eval $(OUTPUT_DIRECTORY)/${TARGETS}/$(file).c.o: FORCE) \
)
.PHONY: FORCE
FORCE: