根据个人所需,整理的比较简单,目前够用,后期遇到需要使用的再新增。哪里不对欢迎指出。
需要的目录中创建makefile或者Makefile,内容如下:
# 变量定义var1=1111# 定义函数define push-githubcd $(1) \ # 接收参数&& git pull \&& git push githubendef.PHONY:push_github:$(call push-github,/root/project/li-calendar-gin) # 调用函数$(call push-github,/root/project/li-calendar-vue) # 每行目录复位.PHONY:pull:git pull.PHONY:test_var1:echo $(var1).PHONY:test_var2: # 运行此命令需要命令行传递 make var2=2222 test_var2echo $(var2).PHONY:test_if: # if语句 make var2=v2 test_var2ifeq ($(var2),v1) # 还有其他的,如:nep...echo $(var2)else ifeq ($(var2),v2)echo $(var2)echo "这个是v2"elseecho "这个是else:"$(var2)endif
$(变量名称/函数名称)$(call 函数名称,参数1,参数2)tab,否则报错
# 普通运行make pull# 传递参数make var2=2222 test_var2
参考:
中文文档:https://seisman.github.io/how-to-write-makefile/variables.html#id7
命令行参数:https://blog.csdn.net/xiaowanbiao123/article/details/78274556
GNU Makefile—命令行参数的传递:https://blog.csdn.net/yeholmes/article/details/118884204
Makefile中条件分支ifeq/else/endif/else ifeq/ifneq/ifdef/ifndef用法详解 :https://www.cnblogs.com/SoaringLee/p/10532151.html
正在学习Go语言的PHP程序员。