Multiline bash commands in makefile

后端 未结 5 1473
醉梦人生
醉梦人生 2020-11-27 11:57

I have a very comfortable way to compile my project via a few lines of bash commands. But now I need to compile it via makefile. Considering, that every command is run in it

5条回答
  •  Happy的楠姐
    2020-11-27 13:01

    Of course, the proper way to write a Makefile is to actually document which targets depend on which sources. In the trivial case, the proposed solution will make foo depend on itself, but of course, make is smart enough to drop a circular dependency. But if you add a temporary file to your directory, it will "magically" become part of the dependency chain. Better to create an explicit list of dependencies once and for all, perhaps via a script.

    GNU make knows how to run gcc to produce an executable out of a set of .c and .h files, so maybe all you really need amounts to

    foo: $(wildcard *.h) $(wildcard *.c)
    

提交回复
热议问题