make和

make是一条指令
Makefile是一个文件

hello.c文件

  1 #include<stdio.h>
  2 
  3 int main()
  4 {
  5     printf("hello Makefile!\n");
  6     return 0;
  7 }  

Makefile文件

  1 hello:hello.o
  2     gcc hello.o -o hello
  3 ello.o:hello.s
  4     gcc -c hello.s -o hello.o
  5 hello.s:hello.i
  6     gcc -S hello.i -o hello.s
  7 hello.i:hello.c
  8     gcc -E hello.c -o hello.i
  9 .PHONY:clean
 10 clean:
 11     rm -f hello.i hello.s hello.o hello

执行

[admin@bogon code]$ make
cc    -c -o hello.o hello.c
gcc hello.o -o hello
[admin@bogon code]$ make
make: `hello' is up to date.
[admin@bogon code]$ clean
bash: clean: command not found
[admin@bogon code]$ make clean
rm -f hello.i hello.s hello.o hello
[admin@bogon code]$ make clean
rm -f hello.i hello.s hello.o hello

make不是总能执行的,它和文件的修改时间有关,
make clean 总能执行是因为用.PHONY 修饰了

.PHONY修饰之后就变成了伪目标
特征:总是被执行

Makefile文件

  1 hello:hello.c
  2     gcc hello.c -o hello
  3 .PHONY:clean
  4 clean:
  5     rm -f hello.i hello.s hello.o hello
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值