学无止境-Linux Makefile及时记

1、$(shell pwd)与$(PWD)区别

     $(shell pwd)是Make函数调用,Make解析时立即执行

     $(PWD)Make变量,来自环境变量

例如:
/root/test/Makefile:SHELL_PWD_DIR=$(shell pwd)PWD_DIR=$(PWD)all:@echo $(SHELL_PWD_DIR)@echo $(PWD_DIR)/root/Makefile:make -C /root/test/最后打印出来的结果:/root/test//root/

2、在Makefile中改变环境变量PATH

export PATH:=$(MY_DIR)/bin:$(PATH)

不能放在Target下。

3、判断文件是否存在:

@if [ -e $(PROJECT_DIR)/../images/sighop_user ]; then \
  rm -f $(PROJECT_DIR)/../images/sighop_user; \
fi
每行末尾都要加";\"