How to ensure a target is run before all the other build rules in a makefile?

后端 未结 2 702
南旧
南旧 2020-11-28 13:23

I have a C++ project which contains a generated file that all the other C++ files depend on. I\'m trying to force that file to be generated and compiled before any other com

2条回答
  •  萌比男神i
    2020-11-28 13:54

    If you're sure that's really what you want, here's one way to do it: have a rule for a dummy file which the makefile will include.

    .PHONY: dummy
    dummy:
        # generate the file here
    
    -include dummy
    

    No matter what target you specify, Make will first run the dummy rule, then restart itself.

提交回复
热议问题