Makefile  $@, $^, $< 
$@  表示目标文件
$^  表示所有的依赖文件
$<  表示第一个依赖文件
$?  表示比目标还要新的依赖文件列表

如一个目录下有如下文件:

$ ls
hello.c  hi.c  main.c  Makefile

按照 Makefile 的一般写法:

main: main.o hello.o hi.o
        gcc -o main main.o hello.o hi.o

main.o: main.c
        cc -c main.c

hello.o: hello.c
        cc -c hello.c

hi.o: hi.c
        cc -c hi.c

clean:
        rm *.o
        rm main

改为用上述符号进行替代:

main: main.o hello.o hi.o
        gcc -o $@ $^
main.o: main.c
        cc -c $<
hello.o: hello.c
        cc -c $<
hi.o: hi.c
        cc -c $<
clean:
        rm *.o
        rm main

beyes@debian:~/makefile_test/semicolon/real$ make
cc -c main.c
cc -c hello.c
cc -c hi.c
gcc -o main main.o hello.o hi.o
beyes@debian:~/makefile_test/semicolon/real$ ls
hello.c  hello.o  hi.c  hi.o  main  main.c  main.o  Makefile

随机推荐

  1. go-001-环境部署,IDEA插件

    一.下载安装 https://golang.org/dl/ 下载之后安装即可 官网地址:https://golang.org/ 1.1.mac上安装go 1.安装Homebrew 安装命令: ruby ...

  2. java实现Comparable接口和Comparator接口,并重写compareTo方法和compare方法

    原文地址https://segmentfault.com/a/1190000005738975 实体类:java.lang.Comparable(接口) + comareTo(重写方法),业务排序类 ...

  3. Girls Off-White x Air Jordan 1 from JordansUnveil.com

    The Jordans Unveil is a hardwood classic, re-imagined for the modern day sneakerhead. It's a hybrid ...

  4. php开启mbstring扩展并设置支持utf-8编码

    前一段时间使用一个服务的接口,因为调用接口时使用的参数里面有中文,调用接口会出现异常问题,后来才明白是编码不一致的问题.然而,我本地项目开发使用的是utf-8,接口那边也是需要utf-8的,那么问题来 ...

  5. js匿名自执行函数中闭包的高级使用(---------------------------******-----------------------------)

    先看看最常见的一个问题: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  6. IOS中position:fixed吸底时的滑动出现抖动的解决方案

    H5方法: //吸顶头部 .header{ width:100%; height:50px; position:fixed; top:0px; } //main滑动区域 .main{ width:10 ...

  7. Centos7下添加Tomcat为系统服务

    文章参考:点击打开链接 因为个人感觉在centos中启动tomcat比较麻烦.要一直cd到目录下面startup.sh才可以,所以网上找到将tomcat作为系统服务,使用systemctl直接启动方法 ...

  8. SQL语句调优汇总

    1.插入数据的表或临时表,预先创建好表结构,能够加快执行速度 2.where 条件判断的字段以及连接查询的条件字段   都添加上索引   能够加快执行速度 3.尽量避免使用 like ,类似 like ...

  9. phpstudy升级mysql版本到5.7 ,重启mysql不启动

    phpstudy中mysql升级后MySQL服务无法启动 问题产生: 安装好phpstudy后,升级了MySQL后,通过phpstudy启动,Apache可以启动,Mysql无法启动. 解决方法: 之 ...

  10. P4281 [AHOI2008]紧急集合 / 聚会

    P4281 [AHOI2008]紧急集合 / 聚会 lca 题意:求3个点的lca,以及3个点与lca的距离之和. 性质:设点q1,q2,q3 两点之间的lca t1=lca(q1,q2) t2=lc ...