是否可以通過命令'make all'在變量初始化之前執行bash腳本。這個想法是,這個腳本編譯idls並創建新的目錄,例如放入.h和.cpp文件等。在執行腳本之後,必須初始化makefile中的變量。Makefile:通過'make all'命令運行bash腳本在全局變量初始化之前
BR, d
是否可以通過命令'make all'在變量初始化之前執行bash腳本。這個想法是,這個腳本編譯idls並創建新的目錄,例如放入.h和.cpp文件等。在執行腳本之後,必須初始化makefile中的變量。Makefile:通過'make all'命令運行bash腳本在全局變量初始化之前
BR, d
這聽起來不像是一個很好的設計,但這裏的一個辦法做到這一點:
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.
它的工作原理!非常感謝你! :) – vir2al