在高级语法中,我们会讲到Makefile的嵌套,命令包,函数定义等
嵌套Makefile
在一些场景中,我们会需要多个Makefile协同工作,这就用到Makefile的嵌套。 常用的方法是使用include函数,在Makefile文件末尾包括其他的Makefile文件。 假设我们有Makefile, WEB_Makefile和API_Makefile需要一起编译 Makefile具体如下:
.PHONY : all
all: build
build:
@echo "---> Start to make ..."
@make build_web
@make build_api
@echo "---> Done to make ..."
include ./WEB/WEB_Makefile
include ./API/API_Makefile
WEB_Makefile如下:
build_web:
@echo "---> Make the WEB APP ..."
@echo "---> Done to make WEB APP ..."
API_Makefile如下:
build_api:
@echo "---> Make the API APP ..."
@echo "---> Done to make API APP ..."
则执行结果为:
$ make
---> Start to make ...
make[1]: Entering di