How to force make to always rebuild a file

后端 未结 4 1054
野的像风
野的像风 2021-02-01 16:16

I have a version.c file in my project that contains current revision of the project and some other stuff that is passed as a definition (-D compiler option) from makefile.

4条回答
  •  借酒劲吻你
    2021-02-01 17:04

    The classic way to do it is:

    version.o:   .FORCE
    
    .FORCE:
    

    (and you might add .PHONY: .FORCE). The file '.FORCE' is presumed not to exist, so it is always 'created', so version.o is always out of date w.r.t it, so version.o is always compiled.

    I'm not sure that making version.o into a phony file is correct; it is actually a real file, not a phony one.

提交回复
热议问题