C++ Makefile:通过';使所有';全局变量初始化之前的命令

C++ Makefile:通过';使所有';全局变量初始化之前的命令,c++,bash,makefile,C++,Bash,Makefile,在变量初始化之前,是否可以通过命令'make all'执行bash脚本。其思想是该脚本编译IDL并在which put.h和.cpp文件等中创建新目录。。在执行该脚本之后,必须初始化makefile中的变量 比尔, 这听起来不是一个好的设计,但这里有一个方法: all: bash-script $(MAKE) other-things other-things: some-prereq $(FOO) other-stuff $(BAR) 值得一提的是,make支持延迟

在变量初始化之前,是否可以通过命令'make all'执行bash脚本。其思想是该脚本编译IDL并在which put.h和.cpp文件等中创建新目录。。在执行该脚本之后,必须初始化makefile中的变量

比尔,
这听起来不是一个好的设计,但这里有一个方法:

all:
    bash-script
    $(MAKE) other-things

other-things: some-prereq $(FOO)
    other-stuff $(BAR)

值得一提的是,
make
支持延迟求值,这意味着在命令中实际使用变量之前(或者在赋值时使用
:=
而不是
=
时),它不会展开变量。这允许您修改变量直到最后一刻(当它们在命令行中使用时)

引述自:

A variable is evaluated when it is part of the right side of the ``:='' or the ``!=''
operator, or directly before executing a shell command which the variable is part of.
In all other cases, make(1) performs lazy evaluation, that is, variables are not
evaluated until there's no other way. The ``modifiers'' mentioned in the man page
also evaluate the variable.