2013-08-22 21 views

回答

1

這聽起來不像是一個很好的設計,但這裏的一個辦法做到這一點:

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

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

它的工作原理!非常感謝你! :) – vir2al

0

值得一提的是,make支持懶惰的評價,這意味着它不擴展變量直到在命令中實際使用變量(或者在分配值時使用:=而不是=)。這允許您直到最後一刻(當它們在命令行中使用時)修改變量。

this Makefile doc報價:

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.