MakeFile的规则语法
格式
#注释
目标文件:依赖文件列表
............................
<Tab>命令列表
............................
示例
#makefile exaple
test: main.o test1.o test2.o
gcc -o test main.o test1.o test2.o
main.o: main.c head1.h head2.h
gcc -c main.o head1.h head2.h
test1.o: test1.c head2.h
gcc -c test1.h
test2.o: test2.c head3.h
gcc -c test2.c
install:
cp test /home/tmp
clean:
rm -f *.o
说明
#表示注释
:后表示依赖文件
:前面是目标文件
多个依赖文件用空格隔开
执行make会默认生成第一个目标文件
当然后面可以跟参数 如make install 等