How to use shell commands in Makefile

前端 未结 2 2087
梦毁少年i
梦毁少年i 2020-11-29 17:00

I\'m trying to use the result of ls in other commands (e.g. echo, rsync):

all:
    

        
2条回答
  •  再見小時候
    2020-11-29 17:22

    Also, in addition to torek's answer: one thing that stands out is that you're using a lazily-evaluated macro assignment.

    If you're on GNU Make, use the := assignment instead of =. This assignment causes the right hand side to be expanded immediately, and stored in the left hand variable.

    FILES := $(shell ...)  # expand now; FILES is now the result of $(shell ...)
    
    FILES = $(shell ...)   # expand later: FILES holds the syntax $(shell ...)
    

    If you use the = assignment, it means that every single occurrence of $(FILES) will be expanding the $(shell ...) syntax and thus invoking the shell command. This will make your make job run slower, or even have some surprising consequences.

提交回复
热议问题