2015-08-21 92 views
1

我不能在這裏找到任何回答這個命名約定:是否有Makefile和變量

http://www.gnu.org/software/make/manual/html_node/Makefile-Conventions.html#Makefile-Conventions

+0

你的意思是除了'clean','veryclean'和target-name-same-name-of-file-it-builds? – Beta

+0

您已經選擇了其中一個主要規格。 Perl有它自己的一套規則,儘管它們受GNU慣例的啓發。其他大型項目可能還有其他一些公約,但大多數會受到GNU公約的影響。 GNU需要「檢查」;一些其他系統使用'test'來代替。 –

+1

除了標準的目標集(比如clean,distcleant,install等)之外,我還想知道是否有任何命名約定,比如使用什麼作爲字詞分隔符,無論是短劃線還是下劃線。傳遞給Makefile的參數名稱的約定是什麼?通常它們是指所有大寫的環境變量,並且是作爲分隔符的下劃線? –

回答

0

最常用的(我認爲)都是,清潔,編譯,運行,安裝,測試,以及你可能需要建立你正在構建的任何常見任務。

您可以在Linux,Vim等大型項目中學習makefiles,但是如果您想要在您的項目中獲得標準,您也可以使用Autotools。

對於小型項目,我通常使用基於上下文meaningfull的名字,這樣我就可以做這樣的事情:

$make compile (to compile) 
$make lib  (to create the libraries) 
$make link  (to link the objects into the executable) 
$make run  (to run the program) 
$make all  (to make all of them at once) 

,並要做到這一點不如預期,我要插入的依賴關係,如:

all: run 

run: link 
    # Instructions for run 

link: lib 
    # Instructions for link 

lib: compile 
    # Instructions for make the lib 

compile: 
    #Instructions for compilation