make工具使用
文章目录
make概念
linux上用的比较多,大多用来编译程序,比如通过源码安装软件,CICD发布,复杂工程发布等非容器化原生部署,下载后经常使用make命令编译
windows上没有make命令,MinGW命令可实现make同样功能,windows上下载后,mingw32-make.exe文件名字改为make.exe放入环境变量即可
基础示例
a.txt 是由 b.txt、c.txt生成,命令体现为
cat b.txt c.txt > a.txt意味着 a.txt 文件的生成依赖 b.txt c.txt 的存在,在make中体现为
a.txt: b.txt c.txt
cat b.txt c.txt > a.txt # 这是一个注释,此行前面是一个tab符,不可随意空格将上诉内容写在一个 result.txt 的文件中,执行命令
如将result.txt文件名命名为Makefile/makefile,make 命令默认读取此文件规则,无需指定具体文件
make -f rules.txt
或者
make --file=rules.txt
-f --file为make命令指定的执行规则文件执行体现为
- 确认 b.txt 和 c.txt 必须已经存在
- cat b.txt c.txt > a.txt
语法细节
参考w3c
https://www.w3cschool.cn/mexvtg/sriygozt.html具体示例
删文件
.PHONY: cleanall cleanobj cleandiff
cleanall : cleanobj cleandiff
rm program
cleanobj :
rm *.o
cleandiff :
rm *.diff
version :
@date > time.txt
echo 'help version_1'
help :
# helP me部署前端
.PHONY: webdir branch code package build
webdir : branch code package build
cd /home/qianduan/lianshan_saas_admin_vue
branch :
git checkout pre
code :
git pull
package :
npm install
build :
npm run build:stage
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论