2015-08-21 41 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