zoukankan      html  css  js  c++  java
  • GNU make manual 翻译(二十)

    继续翻译

    2.4 Variables Make Makefiles Simpler                        
    ====================================                        
                            
    In our example, we had to list all the object files twice in the rule                        
    for `edit' (repeated here):                        
                            
         edit : main.o kbd.o command.o display.o \                        
                       insert.o search.o files.o utils.o                        
                 cc -o edit main.o kbd.o command.o display.o \                        
                       insert.o search.o files.o utils.o                        
                            
       Such duplication is error-prone; if a new object file is added to the 
    system, we might add it to one list and forget the other.  We can
    eliminate the risk and simplify the makefile by using a variable. 
    Variables allow a text string to be defined once and substituted in 
    multiple places later (*note How to Use Variables: Using Variables.).  

    2.4 变量使得makefile 更加简单 
    ====================================
    在我们的例子中,我们在 edit 的规则里面,不得不列举了所有目标文件两次:

    edit : main.o kbd.o command.o display.o \
    insert.o search.o files.o utils.o
    cc -o edit main.o kbd.o command.o display.o \
    insert.o search.o files.o utils.o

    这种重复容易导致出错;如果一个新的 目标文件被加入到系统中,我们也许会在某处加入了,而某处忘记了加入。

    我们可以通过使用变量,来消除这个风险,简化makefile。

    变量允许一个文本串定义一次,到处使用(*not How to Use Variables:Using Variables)。

    后文待续

  • 相关阅读:
    LeetCode之Z字形变换
    统计文本中字母的频次(不区分大小写)
    凯撒密码实现
    DES 实现
    cmake 学习
    ubuntu18 ssh服务器拒绝连了密码
    Ubuntu13 安装vim
    面向对象和面向过程的理解
    图像变换
    基于关键帧的RGB-D视觉惯性里程计
  • 原文地址:https://www.cnblogs.com/gaojian/p/2683394.html
Copyright © 2011-2022 走看看