zoukankan      html  css  js  c++  java
  • makefile笔记


    http://stackoverflow.com/questions/3932895/makefile-aliases

    SRC=$(wildcard '*.c')

    test: $(SRC)
        gcc -o $@ $^ $(CFLAGS) $(LIBS)

        $@ is the target i.e. test
        $^ is the list of pre-requisites for the rule (which in this case is the expanded wild card list as specified in SRC=$(wildcard '*.c'))

        SRC=$(wildcard '*.c')    it's a file matching wildcard. https://www.gnu.org/software/make/manual/html_node/Wildcard-Function.html#Wildcard-Function
        
    All such variables are explained in the Automatic variables page of the GNU make manual.
    https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables

    a makefile to compile all C source files in the directory and then link them together could be written as follows:

    objects := $(patsubst %.c,%.o,$(wildcard *.c))

    foo : $(objects)
            cc -o foo $(objects)

    $(patsubst %.c,%.o,$(wildcard *.c))    it can  change the list of C source files into a list of object files by replacing the ‘.c’ suffix with ‘.o’ in the result,

    $(wildcard *.c)    it can get a list of all the C source files in a directory       

  • 相关阅读:
    UI测试
    软件测试用例详解(转载)
    Mac设置命令别名
    CentOS7 开启免密登陆
    使用systemctl命令管理服务mysql
    Redis学习笔记02--主从数据库配置
    CentOS使用dnf安装Redis
    CentOS 7 防火墙设置
    Redis学习笔记01---配置文件
    CentOS7搭建Maven的Nexus私服仓库
  • 原文地址:https://www.cnblogs.com/cutepig/p/4298631.html
Copyright © 2011-2022 走看看