linux 一个超简单的makefile
2014-07-14 11:03
344 查看
makefile 自动化变量:
$@ : 规则的目标文件名
例如:main:main.o test.o
g++ -Wall -g main.o test.o -o main
可以写成:
main:main.o test.o
g++ -Wall -g main.o test.o -o $@
$< : 规则的第一个依赖文件名
例如:main.o: main.cpp
g++ -Wall -g -c main.cpp -o main.o
可以写成:
main.o: main.cpp
g++ -Wall -g -c $< -o main.o
$^ : 规则的所有依赖文件列表。
例如:test.o:test.cpp test.h
g++ -Wall -g -c
test.cpp test.h -o test.o
可以写成:
test.o:test.cpp test.h
g++ -Wall -g -c $^ -o test.o
//程序文件包括main.cpp test.cpp test.h
.PHONY:clean
XX=g++
exe=dididididididididi
obj=main.o test.o
$(exe):$(obj)
$(XX) -pthread -Wall -g -o $(exe) $(obj)
main.o:main.cpp test.h
$(XX) -c main.cpp -o main.o
test.o:test.cpp test.h
$(XX) -c test.cpp -o test.o
clean:
rm -f *.o $(exe)
$@ : 规则的目标文件名
例如:main:main.o test.o
g++ -Wall -g main.o test.o -o main
可以写成:
main:main.o test.o
g++ -Wall -g main.o test.o -o $@
$< : 规则的第一个依赖文件名
例如:main.o: main.cpp
g++ -Wall -g -c main.cpp -o main.o
可以写成:
main.o: main.cpp
g++ -Wall -g -c $< -o main.o
$^ : 规则的所有依赖文件列表。
例如:test.o:test.cpp test.h
g++ -Wall -g -c
test.cpp test.h -o test.o
可以写成:
test.o:test.cpp test.h
g++ -Wall -g -c $^ -o test.o
//程序文件包括main.cpp test.cpp test.h
.PHONY:clean
XX=g++
exe=dididididididididi
obj=main.o test.o
$(exe):$(obj)
$(XX) -pthread -Wall -g -o $(exe) $(obj)
main.o:main.cpp test.h
$(XX) -c main.cpp -o main.o
test.o:test.cpp test.h
$(XX) -c test.cpp -o test.o
clean:
rm -f *.o $(exe)
相关文章推荐
- 一个简单c++工程在linux下的makefile写法
- Linux环境下写一个 简单的 makefile
- 一个简单的Linux驱动程序和Makefile
- 一个简单的Makefile,辅助在Linux上练习笔试题用
- Linux下,使用Makefile文件编写一个简单的彩色进度条
- 一个简单的Linux驱动程序和Makefile
- 【Linux学习】 写一个简单的Makefile编译源码获取当前系统时间
- linux 一个超简单的makefile
- [Linux学习]一个简单的Makefile入门
- linux下编写的一个最简单的Makefile文件
- 一个简单的Linux驱动程序和Makefile
- 【Linux学习】 写一个简单的Makefile编译源码获取当前系统时间
- 一个简单的linux driver Makefile
- Linux环境下写一个 简单的 makefile
- Linux下书写一个简单的makefile
- 关于(在2410+linux平台上,关于led 的一个简单应用程序)的驱动程序
- 一个简单的linux下写日志的类
- 一个关于linux socket的简单例子
- 由最简单的一个例子说起,匿名用户可读可写的实现(LINUX)配置
- 编译和安装linux内核2.6.x,一个简单的内核驱动测试