Debugging GNU make

后端 未结 7 1033
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 18:33

Is there a command line way in make to find out which of the prerequisites of a target is not updated?

7条回答
  •  滥情空心
    2020-12-22 19:02

    i am using make gnu make templates to define the make rules per target;

    Templates are like macros that write rules, they are explained here https://www.gnu.org/software/make/manual/html_node/Eval-Function.html

    this feature is useful when you have a make system that includes a core makefile to generate all rules per project type; if it says to do a shared library then it writes the rules to compile a shared library; etc. for other types of targets.

    in this example: if you add SHOW_RULES=1 to the make command line it also shows the text of the rules that are generated by the PROGRAM_target_setup_template ; along with generating the rules themselves (with eval).

     # this one defines the target for real
     $(foreach prog, $(TARGETS), $(eval $(call PROGRAM_target_setup_template,$(prog))))
    
     ifneq "$(SHOW_RULES)" ""
     $(foreach prog, $(TARGETS), $(info $(call PROGRAM_target_setup_template,$(prog))))
     endif
    
    • $(call ... ) invokes the template
    • $(info ... ) prints the result of template substitution; ( eval would have invoked parsing of the output and addition to the current make file )

    More about my make files here: http://mosermichael.github.io/cstuff/all/projects/2011/06/17/make-system.html

提交回复
热议问题