Makefile If-Then Else and Loops

前端 未结 4 1551
青春惊慌失措
青春惊慌失措 2020-12-24 10:18

Can someone explain how to use if-then statements and for loops in Makefiles? I can\'t seem to find any good documentation with examples.

4条回答
  •  轮回少年
    2020-12-24 11:01

    You do see for loops alot of the time, but they are usually not needed. Here is an example of how one might perform a for loop without resorting to the shell

    LIST_OF_THINGS_TO_DO = do_this do_that 
    $(LIST_OF_THINGS_TO_DO): 
           run $@ > $@.out
    
    SUBDIRS = snafu fubar
    $(SUBDIRS):
         cd $@ && $(MAKE)
    

提交回复
热议问题