Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Makefile to force compilation of certain files

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?

Parents Reply Children
  • 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:

Related